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
Labels
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
nexedi
cython
Commits
159a3b9a
Commit
159a3b9a
authored
Jan 06, 2013
by
Stefan Behnel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add <locals> to __qualname__ for closures as defined by PEP 3155
parent
502394e7
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
16 additions
and
9 deletions
+16
-9
Cython/Compiler/ExprNodes.py
Cython/Compiler/ExprNodes.py
+7
-4
tests/run/cyfunction.pyx
tests/run/cyfunction.pyx
+9
-5
No files found.
Cython/Compiler/ExprNodes.py
View file @
159a3b9a
...
@@ -6019,10 +6019,13 @@ class DictItemNode(ExprNode):
...
@@ -6019,10 +6019,13 @@ class DictItemNode(ExprNode):
class
ModuleNameMixin
(
object
):
class
ModuleNameMixin
(
object
):
def
set_qualified_name
(
self
,
env
,
self_name
):
def
set_qualified_name
(
self
,
env
,
self_name
):
self
.
module_name
=
env
.
global_scope
().
qualified_name
self
.
module_name
=
env
.
global_scope
().
qualified_name
prefix
=
env
.
qualified_name
[
len
(
self
.
module_name
)
+
1
:]
qualified_name
=
[
self_name
]
if
prefix
:
while
env
and
not
env
.
is_module_scope
:
self_name
=
prefix
+
'.'
+
self_name
if
env
.
is_closure_scope
:
self
.
qualname
=
StringEncoding
.
EncodedString
(
self_name
)
qualified_name
.
append
(
'<locals>'
)
qualified_name
.
append
(
env
.
name
)
env
=
env
.
parent_scope
self
.
qualname
=
StringEncoding
.
EncodedString
(
'.'
.
join
(
qualified_name
[::
-
1
]))
def
get_py_mod_name
(
self
,
code
):
def
get_py_mod_name
(
self
,
code
):
return
code
.
get_py_string_const
(
return
code
.
get_py_string_const
(
...
...
tests/run/cyfunction.pyx
View file @
159a3b9a
...
@@ -47,20 +47,24 @@ def test_qualname():
...
@@ -47,20 +47,24 @@ def test_qualname():
def
test_nested_qualname
():
def
test_nested_qualname
():
"""
"""
>>> func = test_nested_qualname()
>>> func, lambda_func = test_nested_qualname()
>>> func().__qualname__
>>> func().__qualname__
'test_nested_qualname.
outer
.Test'
'test_nested_qualname.
<locals>.outer.<locals>
.Test'
>>> func().test.__qualname__
>>> func().test.__qualname__
'test_nested_qualname.
outer
.Test.test'
'test_nested_qualname.
<locals>.outer.<locals>
.Test.test'
>>> func()().test.__qualname__
>>> func()().test.__qualname__
'test_nested_qualname.outer.Test.test'
'test_nested_qualname.<locals>.outer.<locals>.Test.test'
>>> lambda_func.__qualname__
'test_nested_qualname.<locals>.<lambda>'
"""
"""
def
outer
():
def
outer
():
class
Test
(
object
):
class
Test
(
object
):
def
test
(
self
):
def
test
(
self
):
return
123
return
123
return
Test
return
Test
return
outer
return
outer
,
lambda
:
None
def
test_doc
():
def
test_doc
():
...
...
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