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
990213e8
Commit
990213e8
authored
Jul 20, 2017
by
Jason Madden
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Don't conflict with a class named 'result' in auto-pickle
Fixes #1786.
parent
23b6e66f
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
20 additions
and
7 deletions
+20
-7
Cython/Compiler/ParseTreeTransforms.py
Cython/Compiler/ParseTreeTransforms.py
+7
-7
tests/run/reduce_pickle.pyx
tests/run/reduce_pickle.pyx
+13
-0
No files found.
Cython/Compiler/ParseTreeTransforms.py
View file @
990213e8
...
...
@@ -1673,22 +1673,22 @@ if VALUE is not None:
if __pyx_checksum != %(checksum)s:
from pickle import PickleError
raise PickleError("Incompatible checksums (%%s vs %(checksum)s = (%(members)s))" %% __pyx_checksum)
result = %(class_name)s.__new__(__pyx_type)
__pyx_
result = %(class_name)s.__new__(__pyx_type)
if __pyx_state is not None:
%(unpickle_func_name)s__set_state(<%(class_name)s> result, __pyx_state)
return result
%(unpickle_func_name)s__set_state(<%(class_name)s>
__pyx_
result, __pyx_state)
return
__pyx_
result
cdef %(unpickle_func_name)s__set_state(%(class_name)s result, tuple __pyx_state):
cdef %(unpickle_func_name)s__set_state(%(class_name)s
__pyx_
result, tuple __pyx_state):
%(assignments)s
if hasattr(result, '__dict__'):
result.__dict__.update(__pyx_state[%(num_members)s])
if hasattr(
__pyx_
result, '__dict__'):
__pyx_
result.__dict__.update(__pyx_state[%(num_members)s])
"""
%
{
'unpickle_func_name'
:
unpickle_func_name
,
'checksum'
:
checksum
,
'members'
:
', '
.
join
(
all_members_names
),
'class_name'
:
node
.
class_name
,
'assignments'
:
'; '
.
join
(
'result.%s = __pyx_state[%s]'
%
(
v
,
ix
)
'
__pyx_
result.%s = __pyx_state[%s]'
%
(
v
,
ix
)
for
ix
,
v
in
enumerate
(
all_members_names
)),
'num_members'
:
len
(
all_members_names
),
},
level
=
'module'
,
pipeline
=
[
NormalizeTree
(
None
)]).
substitute
({})
...
...
tests/run/reduce_pickle.pyx
View file @
990213e8
...
...
@@ -114,6 +114,19 @@ cdef class DefaultReduceSubclass(DefaultReduce):
return
"DefaultReduceSubclass(i=%s, s=%r, x=%s)"
%
(
self
.
i
,
self
.
s
,
self
.
x
)
cdef
class
result
(
DefaultReduceSubclass
):
"""
>>> a = result(i=11, s='abc', x=1.5); a
result(i=11, s='abc', x=1.5)
>>> import pickle
>>> pickle.loads(pickle.dumps(a))
result(i=11, s='abc', x=1.5)
"""
def
__repr__
(
self
):
return
"result(i=%s, s=%r, x=%s)"
%
(
self
.
i
,
self
.
s
,
self
.
x
)
class
DefaultReducePySubclass
(
DefaultReduce
):
"""
>>> a = DefaultReducePySubclass(i=11, s='abc', x=1.5); a
...
...
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