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
Boxiang Sun
cython
Commits
753e262f
Commit
753e262f
authored
Sep 03, 2017
by
Stefan Behnel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Switch off special methods for closure classes the hard way.
parent
bff0e5cb
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
42 additions
and
26 deletions
+42
-26
Cython/Compiler/ModuleNode.py
Cython/Compiler/ModuleNode.py
+27
-25
Cython/Compiler/TypeSlots.py
Cython/Compiler/TypeSlots.py
+6
-0
tests/run/closure_names.pyx
tests/run/closure_names.pyx
+9
-1
No files found.
Cython/Compiler/ModuleNode.py
View file @
753e262f
...
...
@@ -1200,6 +1200,8 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode):
self
.
generate_traverse_function
(
scope
,
code
,
entry
)
if
scope
.
needs_tp_clear
():
self
.
generate_clear_function
(
scope
,
code
,
entry
)
if
not
scope
.
is_closure_class_scope
:
# in closure classes, these are user defined variable names
if
scope
.
defines_any
([
"__getitem__"
]):
self
.
generate_getitem_int_function
(
scope
,
code
)
if
scope
.
defines_any
([
"__setitem__"
,
"__delitem__"
]):
...
...
Cython/Compiler/TypeSlots.py
View file @
753e262f
...
...
@@ -304,6 +304,8 @@ class MethodSlot(SlotDescriptor):
method_name_to_slot
[
method_name
]
=
self
def
slot_code
(
self
,
scope
):
if
scope
.
is_closure_class_scope
:
return
"0"
entry
=
scope
.
lookup_here
(
self
.
method_name
)
if
entry
and
entry
.
func_cname
:
return
entry
.
func_cname
...
...
@@ -404,6 +406,8 @@ class SyntheticSlot(InternalMethodSlot):
class
RichcmpSlot
(
MethodSlot
):
def
slot_code
(
self
,
scope
):
if
scope
.
is_closure_class_scope
:
return
"0"
entry
=
scope
.
lookup_here
(
self
.
method_name
)
if
entry
and
entry
.
func_cname
:
return
entry
.
func_cname
...
...
@@ -456,6 +460,8 @@ class SuiteSlot(SlotDescriptor):
substructures
.
append
(
self
)
def
is_empty
(
self
,
scope
):
if
scope
.
is_closure_class_scope
:
return
True
for
slot
in
self
.
sub_slots
:
if
slot
.
slot_code
(
scope
)
!=
"0"
:
return
False
...
...
tests/run/closure_names.pyx
View file @
753e262f
...
...
@@ -24,8 +24,16 @@ def func():
def
__dict__
(
a
):
return
'dict'
def
__setitem__
(
x
):
return
'__setitem__'
def
__getslice__
(
x
):
return
'__getslice__'
def
list_from_gen
(
g
):
return
list
(
g
)
# move into closure by using inside of generator expression
return
list_from_gen
([
__eq__
,
__str__
,
__weakref__
,
__new__
,
__dict__
][
i
]
for
i
in
range
(
5
))
return
list_from_gen
(
[
__eq__
,
__str__
,
__weakref__
,
__new__
,
__dict__
,
__setitem__
,
__getslice__
][
i
]
for
i
in
range
(
5
))
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