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
9c5281d4
Commit
9c5281d4
authored
Jul 21, 2017
by
scoder
Committed by
GitHub
Jul 21, 2017
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #1789 from NextThought/issue1786
Don't conflict with a class named 'result' in auto-pickle
parents
384f08f9
990213e8
Changes
2
Show 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 @
9c5281d4
...
@@ -1673,22 +1673,22 @@ if VALUE is not None:
...
@@ -1673,22 +1673,22 @@ if VALUE is not None:
if __pyx_checksum != %(checksum)s:
if __pyx_checksum != %(checksum)s:
from pickle import PickleError
from pickle import PickleError
raise PickleError("Incompatible checksums (%%s vs %(checksum)s = (%(members)s))" %% __pyx_checksum)
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:
if __pyx_state is not None:
%(unpickle_func_name)s__set_state(<%(class_name)s> result, __pyx_state)
%(unpickle_func_name)s__set_state(<%(class_name)s>
__pyx_
result, __pyx_state)
return result
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
%(assignments)s
if hasattr(result, '__dict__'):
if hasattr(
__pyx_
result, '__dict__'):
result.__dict__.update(__pyx_state[%(num_members)s])
__pyx_
result.__dict__.update(__pyx_state[%(num_members)s])
"""
%
{
"""
%
{
'unpickle_func_name'
:
unpickle_func_name
,
'unpickle_func_name'
:
unpickle_func_name
,
'checksum'
:
checksum
,
'checksum'
:
checksum
,
'members'
:
', '
.
join
(
all_members_names
),
'members'
:
', '
.
join
(
all_members_names
),
'class_name'
:
node
.
class_name
,
'class_name'
:
node
.
class_name
,
'assignments'
:
'; '
.
join
(
'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
)),
for
ix
,
v
in
enumerate
(
all_members_names
)),
'num_members'
:
len
(
all_members_names
),
'num_members'
:
len
(
all_members_names
),
},
level
=
'module'
,
pipeline
=
[
NormalizeTree
(
None
)]).
substitute
({})
},
level
=
'module'
,
pipeline
=
[
NormalizeTree
(
None
)]).
substitute
({})
...
...
tests/run/reduce_pickle.pyx
View file @
9c5281d4
...
@@ -114,6 +114,19 @@ cdef class DefaultReduceSubclass(DefaultReduce):
...
@@ -114,6 +114,19 @@ cdef class DefaultReduceSubclass(DefaultReduce):
return
"DefaultReduceSubclass(i=%s, s=%r, x=%s)"
%
(
self
.
i
,
self
.
s
,
self
.
x
)
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
):
class
DefaultReducePySubclass
(
DefaultReduce
):
"""
"""
>>> a = DefaultReducePySubclass(i=11, s='abc', x=1.5); a
>>> 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