Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Z
ZODB
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
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Kirill Smelkov
ZODB
Commits
709f6b3c
Commit
709f6b3c
authored
Aug 22, 2009
by
Jim Fulton
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added a missing type error to void crashes under unlikely situations.
parent
aa1f2622
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
33 additions
and
14 deletions
+33
-14
src/persistent/cPersistence.c
src/persistent/cPersistence.c
+11
-11
src/persistent/tests/test_persistent.py
src/persistent/tests/test_persistent.py
+22
-3
No files found.
src/persistent/cPersistence.c
View file @
709f6b3c
...
...
@@ -474,23 +474,23 @@ pickle___setstate__(PyObject *self, PyObject *state)
PyObject
**
dict
;
dict
=
_PyObject_GetDictPtr
(
self
);
if
(
dict
)
if
(
!
dict
)
{
if
(
!*
dict
)
{
*
dict
=
PyDict_New
();
if
(
!*
dict
)
return
NULL
;
}
PyErr_SetString
(
PyExc_TypeError
,
"this object has no instance dictionary"
);
return
NULL
;
}
if
(
*
dict
)
if
(
!
*
dict
)
{
PyDict_Clear
(
*
dict
);
if
(
PyDict_Update
(
*
dict
,
state
)
<
0
)
*
dict
=
PyDict_New
(
);
if
(
!*
dict
)
return
NULL
;
}
else
if
(
pickle_setattrs_from_dict
(
self
,
state
)
<
0
)
PyDict_Clear
(
*
dict
);
if
(
PyDict_Update
(
*
dict
,
state
)
<
0
)
return
NULL
;
}
...
...
src/persistent/tests/test_persistent.py
View file @
709f6b3c
##############################################################################
#
# Copyright (c)
2001, 2002 Zope Corpor
ation and Contributors.
# Copyright (c)
Zope Found
ation and Contributors.
# All Rights Reserved.
#
# This software is subject to the provisions of the Zope Public License,
# Version 2.
1
(ZPL). A copy of the ZPL should accompany this distribution.
# Version 2.
0
(ZPL). A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE.
#
##############################################################################
import
unittest
from
zope.testing
import
doctest
from
persistent
import
Persistent
...
...
@@ -20,5 +21,23 @@ class P(Persistent):
def
inc
(
self
):
self
.
x
+=
1
def
cpersistent_setstate_pointer_sanity
():
"""
>>> Persistent().__setstate__({})
Traceback (most recent call last):
...
TypeError: this object has no instance dictionary
>>> class C(Persistent): __slots__ = 'x', 'y'
>>> C().__setstate__(({}, {}))
Traceback (most recent call last):
...
TypeError: this object has no instance dictionary
"""
def
test_suite
():
return
doctest
.
DocFileSuite
(
"persistent.txt"
,
globs
=
{
"P"
:
P
})
return
unittest
.
TestSuite
((
doctest
.
DocFileSuite
(
"persistent.txt"
,
globs
=
{
"P"
:
P
}),
doctest
.
DocTestSuite
(),
))
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