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
4a196738
Commit
4a196738
authored
Sep 04, 2017
by
Stefan Behnel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Switch off all special methods for closure classes the hard way.
parent
753e262f
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
90 additions
and
9 deletions
+90
-9
Cython/Compiler/TypeSlots.py
Cython/Compiler/TypeSlots.py
+4
-0
tests/run/closure_names.pyx
tests/run/closure_names.pyx
+86
-9
No files found.
Cython/Compiler/TypeSlots.py
View file @
4a196738
...
...
@@ -367,6 +367,8 @@ class ConstructorSlot(InternalMethodSlot):
self
.
method
=
method
def
slot_code
(
self
,
scope
):
if
scope
.
is_closure_class_scope
:
return
"0"
if
(
self
.
slot_name
!=
'tp_new'
and
scope
.
parent_type
.
base_type
and
not
scope
.
has_pyobject_attrs
...
...
@@ -398,6 +400,8 @@ class SyntheticSlot(InternalMethodSlot):
self
.
default_value
=
default_value
def
slot_code
(
self
,
scope
):
if
scope
.
is_closure_class_scope
:
return
"0"
if
scope
.
defines_any
(
self
.
user_methods
):
return
InternalMethodSlot
.
slot_code
(
self
,
scope
)
else
:
...
...
tests/run/closure_names.pyx
View file @
4a196738
...
...
@@ -6,8 +6,27 @@
def
func
():
"""
>>> funcs = func()
>>> [f(1) for f in funcs]
['eq', 'str', 'weakref', 'new', 'dict']
>>> [f(1) for f in funcs] # doctest: +NORMALIZE_WHITESPACE
['eq',
'str',
'weakref',
'new',
'getitem',
'setitem',
'delitem',
'getslice',
'setslice',
'delslice_',
'getattr',
'getattribute',
'setattr',
'delattr',
'get',
'set',
'delete',
'dict',
'dealloc',
'cinit']
"""
def
__eq__
(
a
):
return
'eq'
...
...
@@ -21,19 +40,77 @@ def func():
def
__new__
(
a
):
return
'new'
def
__getitem__
(
a
):
return
'getitem'
def
__setitem__
(
a
):
return
'setitem'
def
__delitem__
(
a
):
return
'delitem'
def
__getslice__
(
a
):
return
'getslice'
def
__setslice__
(
a
):
return
'setslice'
def
__delslice__
(
a
):
return
'delslice_'
def
__getattr__
(
a
):
return
'getattr'
def
__getattribute__
(
a
):
return
'getattribute'
def
__setattr__
(
a
):
return
'setattr'
def
__delattr__
(
a
):
return
'delattr'
def
__get__
(
a
):
return
'get'
def
__set__
(
a
):
return
'set'
def
__delete__
(
a
):
return
'delete'
def
__dict__
(
a
):
return
'dict'
def
__
setitem__
(
x
):
return
'
__setitem__
'
def
__
dealloc__
(
a
):
return
'
dealloc
'
def
__
getslice__
(
x
):
return
'
__getslice__
'
def
__
cinit__
(
a
):
return
'
cinit
'
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__
,
__setitem__
,
__getslice__
][
i
]
for
i
in
range
(
5
))
return
list_from_gen
([
__eq__
,
__str__
,
__weakref__
,
__new__
,
__getitem__
,
__setitem__
,
__delitem__
,
__getslice__
,
__setslice__
,
__delslice__
,
__getattr__
,
__getattribute__
,
__setattr__
,
__delattr__
,
__get__
,
__set__
,
__delete__
,
__dict__
,
__dealloc__
,
__cinit__
,
][
i
]
for
i
in
range
(
20
))
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