[pypy-commit] pypy default: Add function.__globals__ as an alias for func_globals, CPython had no tests for this :(
alex_gaynor
noreply at buildbot.pypy.org
Sun Aug 5 02:09:32 CEST 2012
Author: Alex Gaynor <alex.gaynor at gmail.com>
Branch:
Changeset: r56578:7f8c3a9ea0fb
Date: 2012-08-04 17:09 -0700
http://bitbucket.org/pypy/pypy/changeset/7f8c3a9ea0fb/
Log: Add function.__globals__ as an alias for func_globals, CPython had
no tests for this :(
diff --git a/pypy/interpreter/test/test_function.py b/pypy/interpreter/test/test_function.py
--- a/pypy/interpreter/test/test_function.py
+++ b/pypy/interpreter/test/test_function.py
@@ -16,6 +16,7 @@
assert f.func_defaults == None
assert f.func_dict == {}
assert type(f.func_globals) == dict
+ assert f.func_globals is f.__globals__
assert f.func_closure is None
assert f.func_doc == None
assert f.func_name == 'f'
diff --git a/pypy/interpreter/typedef.py b/pypy/interpreter/typedef.py
--- a/pypy/interpreter/typedef.py
+++ b/pypy/interpreter/typedef.py
@@ -37,7 +37,7 @@
assert __total_ordering__ in (None, 'auto'), "Unknown value for __total_ordering"
if __total_ordering__ == 'auto':
self.auto_total_ordering()
-
+
def add_entries(self, **rawdict):
# xxx fix the names of the methods to match what app-level expects
for key, value in rawdict.items():
@@ -228,7 +228,7 @@
def add(Proto):
for key, value in Proto.__dict__.items():
- if (not key.startswith('__') and not key.startswith('_mixin_')
+ if (not key.startswith('__') and not key.startswith('_mixin_')
or key == '__del__'):
if hasattr(value, "func_name"):
value = func_with_new_name(value, value.func_name)
@@ -315,10 +315,10 @@
class Proto(object):
def getdict(self, space):
return self.w__dict__
-
+
def setdict(self, space, w_dict):
self.w__dict__ = check_new_dictionary(space, w_dict)
-
+
def user_setup(self, space, w_subtype):
self.w__dict__ = space.newdict(
instance=True)
@@ -383,7 +383,7 @@
return %(name)s(%(args)s, %(extra)s)
"""
miniglobals[cls_name] = cls
-
+
name = func.__name__
extra = ', '.join(extraargs)
from pypy.interpreter import pycode
@@ -503,7 +503,7 @@
space, '__delattr__',
self.reqcls, Arguments(space, [w_obj,
space.wrap(self.name)]))
-
+
def descr_get_objclass(space, property):
return property.objclass_getter(space)
@@ -521,7 +521,7 @@
return space.w_None
else:
return w_value
-
+
return GetSetProperty(fget, cls=cls, doc=doc)
GetSetProperty.typedef = TypeDef(
@@ -543,7 +543,7 @@
self.index = index
self.name = name
self.w_cls = w_cls
-
+
def typecheck(self, space, w_obj):
if not space.is_true(space.isinstance(w_obj, self.w_cls)):
raise operationerrfmt(space.w_TypeError,
@@ -552,7 +552,7 @@
self.name,
self.w_cls.name,
space.type(w_obj).getname(space))
-
+
def descr_member_get(self, space, w_obj, w_w_cls=None):
"""member.__get__(obj[, type]) -> value
Read the slot 'member' of the given 'obj'."""
@@ -565,13 +565,13 @@
raise OperationError(space.w_AttributeError,
space.wrap(self.name)) # XXX better message
return w_result
-
+
def descr_member_set(self, space, w_obj, w_value):
"""member.__set__(obj, value)
Write into the slot 'member' of the given 'obj'."""
self.typecheck(space, w_obj)
w_obj.setslotvalue(self.index, w_value)
-
+
def descr_member_del(self, space, w_obj):
"""member.__delete__(obj)
Delete the value of the slot 'member' from the given 'obj'."""
@@ -803,15 +803,16 @@
func_dict = getset_func_dict,
func_defaults = getset_func_defaults,
func_globals = interp_attrproperty_w('w_func_globals', cls=Function),
- func_closure = GetSetProperty( Function.fget_func_closure ),
+ func_closure = GetSetProperty(Function.fget_func_closure),
__code__ = getset_func_code,
__doc__ = getset_func_doc,
__name__ = getset_func_name,
__dict__ = getset_func_dict,
__defaults__ = getset_func_defaults,
+ __globals__ = interp_attrproperty_w('w_func_globals', cls=Function),
__module__ = getset___module__,
__weakref__ = make_weakref_descr(Function),
- )
+)
Function.typedef.acceptable_as_base_class = False
Method.typedef = TypeDef(
More information about the pypy-commit
mailing list