Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
P
persistent
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
Kirill Smelkov
persistent
Commits
d33e91a2
Commit
d33e91a2
authored
Jun 28, 2012
by
Tres Seaver
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix __getstate__ when derived class has slots.
parent
f6202dbb
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
18 additions
and
0 deletions
+18
-0
persistent/pyPersistence.py
persistent/pyPersistence.py
+9
-0
persistent/tests/test_pyPersistence.py
persistent/tests/test_pyPersistence.py
+9
-0
No files found.
persistent/pyPersistence.py
View file @
d33e91a2
...
...
@@ -262,6 +262,14 @@ class Persistent(object):
return
dict
([
x
for
x
in
idict
.
items
()
if
not
x
[
0
].
startswith
(
'_p_'
)
and
not
x
[
0
].
startswith
(
'_v_'
)])
slots
=
getattr
(
type
(
self
),
'__slots__'
,
None
)
if
slots
is
not
None
:
slots
=
[
x
for
x
in
slots
if
not
x
.
startswith
(
'_p_'
)
and
not
x
.
startswith
(
'_v_'
)
and
x
not
in
Persistent
.
__slots__
]
if
slots
:
return
None
,
dict
([(
x
,
getattr
(
self
,
x
))
for
x
in
slots
])
return
None
def
__setstate__
(
self
,
state
):
...
...
@@ -358,6 +366,7 @@ class Persistent(object):
if
self
.
__jar
is
not
None
and
self
.
__oid
is
not
None
:
self
.
__jar
.
_cache
.
mru
(
self
.
__oid
)
def
_estimated_size_in_24_bits
(
value
):
if
value
>
1073741696
:
return
16777215
...
...
persistent/tests/test_pyPersistence.py
View file @
d33e91a2
...
...
@@ -701,6 +701,15 @@ class _Persistent_Base(object):
inst
.
_v_qux
=
'spam'
self
.
assertEqual
(
inst
.
__getstate__
(),
{
'foo'
:
'bar'
})
def
test___getstate___derived_w_slots
(
self
):
class
Derived
(
self
.
_getTargetClass
()):
__slots__
=
(
'foo'
,
'_p_baz'
,
'_v_qux'
)
inst
=
Derived
()
inst
.
foo
=
'bar'
inst
.
_p_baz
=
'bam'
inst
.
_v_qux
=
'spam'
self
.
assertEqual
(
inst
.
__getstate__
(),
(
None
,
{
'foo'
:
'bar'
}))
def
test___setstate___empty
(
self
):
inst
=
self
.
_makeOne
()
inst
.
__setstate__
(
None
)
# doesn't raise, but doesn't change anything
...
...
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