Author: Ian Foote <pyt...@ian.feete.org>
Branch: py3k-qualname
Changeset: r72559:d3fcc7dfcdee
Date: 2014-07-26 11:21 +0200
http://bitbucket.org/pypy/pypy/changeset/d3fcc7dfcdee/

Log:    Add __qualname__ attribute to Function

        Cheat by re-using __name__ implementation without adding extra
        functionality

diff --git a/pypy/interpreter/function.py b/pypy/interpreter/function.py
--- a/pypy/interpreter/function.py
+++ b/pypy/interpreter/function.py
@@ -404,6 +404,12 @@
                                                 "to a string object"))
             raise
 
+    def fget_func_qualname(self, space):
+        return self.fget_func_name(space)
+
+    def fset_func_qualname(self, space, w_name):
+        return self.fset_func_name(space, w_name)
+
     def fdel_func_doc(self, space):
         self.w_doc = space.w_None
 
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
@@ -146,6 +146,10 @@
         assert &#26085;&#26412;.__name__ == '&#26085;&#26412;'
         """
 
+    def test_qualname(self):
+        def f(): pass
+        assert hasattr(f, '__qualname__')
+
 
 class AppTestFunction:
     def test_simple_call(self):
diff --git a/pypy/interpreter/typedef.py b/pypy/interpreter/typedef.py
--- a/pypy/interpreter/typedef.py
+++ b/pypy/interpreter/typedef.py
@@ -807,6 +807,8 @@
                                   Function.fset_func_code)
 getset_func_name = GetSetProperty(Function.fget_func_name,
                                   Function.fset_func_name)
+getset_func_qualname = GetSetProperty(Function.fget_func_qualname,
+                                      Function.fset_func_qualname)
 getset_func_annotations = GetSetProperty(Function.fget_func_annotations,
                                         Function.fset_func_annotations,
                                         Function.fdel_func_annotations)
@@ -824,6 +826,7 @@
     __code__ = getset_func_code,
     __doc__ = getset_func_doc,
     __name__ = getset_func_name,
+    __qualname__ = getset_func_qualname,
     __dict__ = getset_func_dict,
     __defaults__ = getset_func_defaults,
     __kwdefaults__ = getset_func_kwdefaults,
_______________________________________________
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to