Commit 135e52d5 authored by Stefan Behnel's avatar Stefan Behnel

fix access to attributes of optimised builtin methods (e.g. '__name__')

parent 3d10caf5
......@@ -15,6 +15,9 @@ Features added
Bugs fixed
----------
* Access to attributes of optimised builtin methods (e.g.
``[].append.__name__``) could fail to compile.
* Memory leak when extension subtypes add a memory view as attribute
to those of the parent type without having Python object attributes
or a user provided dealloc method.
......
......@@ -5436,7 +5436,7 @@ class AttributeNode(ExprNode):
if obj_type.can_coerce_to_pyobject(env):
if not immutable_obj:
self.obj = self.obj.coerce_to_pyobject(env)
elif (obj_type.is_cfunction and self.obj.is_name
elif (obj_type.is_cfunction and (self.obj.is_name or self.obj.is_attribute)
and self.obj.entry.as_variable
and self.obj.entry.as_variable.type.is_pyobject):
# might be an optimised builtin function => unpack it
......
......@@ -63,3 +63,11 @@ def append_unused_retval(L):
except TypeError:
print u"got error"
return L
def method_name():
"""
>>> method_name()
'append'
"""
return [].append.__name__
......@@ -199,3 +199,11 @@ def crazy_pop(L):
(1, 2, 3)
"""
return L.pop(1, 2, 3)
def method_name():
"""
>>> method_name()
'pop'
"""
return [].pop.__name__
......@@ -2,6 +2,8 @@
# mode: run
# tag: cyfunction,qualname
import sys
def test_qualname():
"""
......@@ -16,6 +18,20 @@ def test_qualname():
"""
def test_builtin_qualname():
"""
>>> test_builtin_qualname()
list.append
len
"""
if sys.version_info >= (3, 3):
print([1, 2, 3].append.__qualname__)
print(len.__qualname__)
else:
print('list.append')
print('len')
def test_nested_qualname():
"""
>>> outer, lambda_func, XYZ = test_nested_qualname()
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment