Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Gwenaël Samain
cython
Commits
74bedb03
Commit
74bedb03
authored
Jan 01, 2019
by
Stefan Behnel
Committed by
GitHub
Jan 01, 2019
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #2773 from jdemeyer/qualname
Only generate __qualname__ in Python versions supporting it
parents
8e7406a0
5b2513aa
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
17 additions
and
12 deletions
+17
-12
Cython/Utility/ObjectHandling.c
Cython/Utility/ObjectHandling.c
+4
-0
runtests.py
runtests.py
+1
-0
tests/run/decorators_T593.pyx
tests/run/decorators_T593.pyx
+2
-2
tests/run/locals_T732.pyx
tests/run/locals_T732.pyx
+2
-2
tests/run/metaclass.pyx
tests/run/metaclass.pyx
+8
-8
No files found.
Cython/Utility/ObjectHandling.c
View file @
74bedb03
...
@@ -913,8 +913,10 @@ static PyObject *__Pyx_CreateClass(PyObject *bases, PyObject *dict, PyObject *na
...
@@ -913,8 +913,10 @@ static PyObject *__Pyx_CreateClass(PyObject *bases, PyObject *dict, PyObject *na
if
(
PyDict_SetItem
(
dict
,
PYIDENT
(
"__module__"
),
modname
)
<
0
)
if
(
PyDict_SetItem
(
dict
,
PYIDENT
(
"__module__"
),
modname
)
<
0
)
return
NULL
;
return
NULL
;
#if PY_VERSION_HEX >= 0x03030000
if
(
PyDict_SetItem
(
dict
,
PYIDENT
(
"__qualname__"
),
qualname
)
<
0
)
if
(
PyDict_SetItem
(
dict
,
PYIDENT
(
"__qualname__"
),
qualname
)
<
0
)
return
NULL
;
return
NULL
;
#endif
/* Python2 __metaclass__ */
/* Python2 __metaclass__ */
metaclass
=
__Pyx_PyDict_GetItemStr
(
dict
,
PYIDENT
(
"__metaclass__"
));
metaclass
=
__Pyx_PyDict_GetItemStr
(
dict
,
PYIDENT
(
"__metaclass__"
));
...
@@ -974,7 +976,9 @@ static PyObject *__Pyx_Py3MetaclassPrepare(PyObject *metaclass, PyObject *bases,
...
@@ -974,7 +976,9 @@ static PyObject *__Pyx_Py3MetaclassPrepare(PyObject *metaclass, PyObject *bases,
/* Required here to emulate assignment order */
/* Required here to emulate assignment order */
if
(
unlikely
(
PyObject_SetItem
(
ns
,
PYIDENT
(
"__module__"
),
modname
)
<
0
))
goto
bad
;
if
(
unlikely
(
PyObject_SetItem
(
ns
,
PYIDENT
(
"__module__"
),
modname
)
<
0
))
goto
bad
;
#if PY_VERSION_HEX >= 0x03030000
if
(
unlikely
(
PyObject_SetItem
(
ns
,
PYIDENT
(
"__qualname__"
),
qualname
)
<
0
))
goto
bad
;
if
(
unlikely
(
PyObject_SetItem
(
ns
,
PYIDENT
(
"__qualname__"
),
qualname
)
<
0
))
goto
bad
;
#endif
if
(
unlikely
(
doc
&&
PyObject_SetItem
(
ns
,
PYIDENT
(
"__doc__"
),
doc
)
<
0
))
goto
bad
;
if
(
unlikely
(
doc
&&
PyObject_SetItem
(
ns
,
PYIDENT
(
"__doc__"
),
doc
)
<
0
))
goto
bad
;
return
ns
;
return
ns
;
bad:
bad:
...
...
runtests.py
View file @
74bedb03
...
@@ -428,6 +428,7 @@ VER_DEP_MODULES = {
...
@@ -428,6 +428,7 @@ VER_DEP_MODULES = {
(3,3) : (operator.lt, lambda x: x in ['build.package_compilation',
(3,3) : (operator.lt, lambda x: x in ['build.package_compilation',
'run.yield_from_py33',
'run.yield_from_py33',
'pyximport.pyximport_namespace',
'pyximport.pyximport_namespace',
'run.qualname',
]),
]),
(3,4): (operator.lt, lambda x: x in ['run.py34_signature',
(3,4): (operator.lt, lambda x: x in ['run.py34_signature',
'run.test_unicode', # taken from Py3.7, difficult to backport
'run.test_unicode', # taken from Py3.7, difficult to backport
...
...
tests/run/decorators_T593.pyx
View file @
74bedb03
...
@@ -110,8 +110,8 @@ class Base(type):
...
@@ -110,8 +110,8 @@ class Base(type):
class
Bar
(
metaclass
=
Base
):
class
Bar
(
metaclass
=
Base
):
"""
"""
>>>
Bar._order
>>>
[n for n in Bar._order if n != "__qualname__"]
['__module__', '__
qualname__', '__
doc__', 'bar']
['__module__', '__doc__', 'bar']
"""
"""
@
property
@
property
def
bar
(
self
):
def
bar
(
self
):
...
...
tests/run/locals_T732.pyx
View file @
74bedb03
...
@@ -23,8 +23,8 @@ def test_class_locals_and_dir():
...
@@ -23,8 +23,8 @@ def test_class_locals_and_dir():
>>> klass = test_class_locals_and_dir()
>>> klass = test_class_locals_and_dir()
>>> 'visible' in klass.locs and 'not_visible' not in klass.locs
>>> 'visible' in klass.locs and 'not_visible' not in klass.locs
True
True
>>>
klass.names
>>>
[n for n in klass.names if n != "__qualname__"]
['__module__', '
__qualname__', '
visible']
['__module__', 'visible']
"""
"""
not_visible
=
1234
not_visible
=
1234
class
Foo
:
class
Foo
:
...
...
tests/run/metaclass.pyx
View file @
74bedb03
...
@@ -69,8 +69,8 @@ class Py3ClassMCOnly(object, metaclass=Py3MetaclassPlusAttr):
...
@@ -69,8 +69,8 @@ class Py3ClassMCOnly(object, metaclass=Py3MetaclassPlusAttr):
321
321
>>> obj.metaclass_was_here
>>> obj.metaclass_was_here
True
True
>>>
obj._order
>>>
[n for n in obj._order if n != "__qualname__"]
['__module__', '__
qualname__', '__
doc__', 'bar', 'metaclass_was_here']
['__module__', '__doc__', 'bar', 'metaclass_was_here']
"""
"""
bar
=
321
bar
=
321
...
@@ -81,8 +81,8 @@ class Py3InheritedMetaclass(Py3ClassMCOnly):
...
@@ -81,8 +81,8 @@ class Py3InheritedMetaclass(Py3ClassMCOnly):
345
345
>>> obj.metaclass_was_here
>>> obj.metaclass_was_here
True
True
>>>
obj._order
>>>
[n for n in obj._order if n != "__qualname__"]
['__module__', '__
qualname__', '__
doc__', 'bar', 'metaclass_was_here']
['__module__', '__doc__', 'bar', 'metaclass_was_here']
"""
"""
bar
=
345
bar
=
345
...
@@ -109,8 +109,8 @@ class Py3Foo(object, metaclass=Py3Base, foo=123):
...
@@ -109,8 +109,8 @@ class Py3Foo(object, metaclass=Py3Base, foo=123):
123
123
>>> obj.bar
>>> obj.bar
321
321
>>>
obj._order
>>>
[n for n in obj._order if n != "__qualname__"]
['__module__', '__
qualname__', '__
doc__', 'bar', 'foo']
['__module__', '__doc__', 'bar', 'foo']
"""
"""
bar
=
321
bar
=
321
...
@@ -122,8 +122,8 @@ class Py3FooInherited(Py3Foo, foo=567):
...
@@ -122,8 +122,8 @@ class Py3FooInherited(Py3Foo, foo=567):
567
567
>>> obj.bar
>>> obj.bar
321
321
>>>
obj._order
>>>
[n for n in obj._order if n != "__qualname__"]
['__module__', '__
qualname__', '__
doc__', 'bar', 'foo']
['__module__', '__doc__', 'bar', 'foo']
"""
"""
bar
=
321
bar
=
321
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment