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
4284df33
Commit
4284df33
authored
Jul 30, 2018
by
Jason Madden
Committed by
GitHub
Jul 30, 2018
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #70 from zopefoundation/issue69
Change cPickleCache to use PER_TypeCheck
parents
d1966b53
516f90ec
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
18 additions
and
18 deletions
+18
-18
CHANGES.rst
CHANGES.rst
+9
-1
persistent/cPickleCache.c
persistent/cPickleCache.c
+9
-17
No files found.
CHANGES.rst
View file @
4284df33
``persistent`` Changelog
========================
4.
2.5
(unreleased)
4.
3.0
(unreleased)
------------------
- Fix the possibility of a rare crash in the C extension when
deallocating items. See https://github.com/zopefoundation/persistent/issues/66
- Change cPickleCache's comparison of object sizes to determine
whether an object can go in the cache to use ``PyObject_TypeCheck()``.
This matches what the pure Python implementation does and is a
stronger test that the object really is compatible with the cache.
Previously, an object could potentially include ``cPersistent_HEAD``
and *not* set ``tp_base`` to ``cPersistenceCAPI->pertype`` and still
be eligible for the pickle cache; that is no longer the case. See
`issue 69 <https://github.com/zopefoundation/persistent/issues/69>`_.
4.2.4.2 (2017-04-23)
--------------------
...
...
persistent/cPickleCache.c
View file @
4284df33
...
...
@@ -99,11 +99,6 @@ static char cPickleCache_doc_string[] =
#include <stddef.h>
#undef Py_FindMethod
/* Python 2.4 backward compat */
#if PY_MAJOR_VERSION <= 2 && PY_MINOR_VERSION < 5
#define Py_ssize_t int
typedef
Py_ssize_t
(
*
lenfunc
)(
PyObject
*
);
#endif
/* Python string objects to speed lookups; set by module init. */
static
PyObject
*
py__p_changed
;
...
...
@@ -111,7 +106,7 @@ static PyObject *py__p_deactivate;
static
PyObject
*
py__p_jar
;
static
PyObject
*
py__p_oid
;
static
cPersistenceCAPIstruct
*
c
api
;
static
cPersistenceCAPIstruct
*
c
PersistenceCAPI
;
/* This object is the pickle cache. The CACHE_HEAD macro guarantees
that layout of this struct is the same as the start of
...
...
@@ -523,7 +518,7 @@ cc_debug_info(ccobject *self)
v
=
Py_BuildValue
(
"Oi"
,
k
,
v
->
ob_refcnt
);
else
if
(
!
PyType_Check
(
v
)
&&
(
v
->
ob_type
->
tp_basicsize
>=
sizeof
(
cPersistentObject
)
)
PER_TypeCheck
(
v
)
)
v
=
Py_BuildValue
(
"Oisi"
,
k
,
v
->
ob_refcnt
,
v
->
ob_type
->
tp_name
,
...
...
@@ -711,13 +706,12 @@ cc_new_ghost(ccobject *self, PyObject *args)
{
/* Its a persistent class, such as a ZClass. Thats ok. */
}
else
if
(
v
->
ob_type
->
tp_basicsize
<
sizeof
(
cPersistentObject
))
else
if
(
!
PER_TypeCheck
(
v
))
{
/* If it's not an instance of a persistent class, (ie Python
classes that derive from persistent.Persistent, BTrees,
etc), report an error.
TODO: checking sizeof() seems a poor test.
*/
PyErr_SetString
(
PyExc_TypeError
,
"Cache values must be persistent objects."
);
...
...
@@ -1034,13 +1028,11 @@ cc_add_item(ccobject *self, PyObject *key, PyObject *v)
{
/* Its a persistent class, such as a ZClass. Thats ok. */
}
else
if
(
v
->
ob_type
->
tp_basicsize
<
sizeof
(
cPersistentObject
))
else
if
(
!
PER_TypeCheck
(
v
))
{
/* If it's not an instance of a persistent class, (ie Python
classes that derive from persistent.Persistent, BTrees,
etc), report an error.
TODO: checking sizeof() seems a poor test.
*/
PyErr_SetString
(
PyExc_TypeError
,
"Cache values must be persistent objects."
);
...
...
@@ -1347,14 +1339,14 @@ module_init(void)
#endif
#ifdef PY3K
c
api
=
(
cPersistenceCAPIstruct
*
)
PyCapsule_Import
(
CAPI_CAPSULE_NAME
,
0
);
c
PersistenceCAPI
=
(
cPersistenceCAPIstruct
*
)
PyCapsule_Import
(
CAPI_CAPSULE_NAME
,
0
);
#else
c
api
=
(
cPersistenceCAPIstruct
*
)
PyCObject_Import
(
c
PersistenceCAPI
=
(
cPersistenceCAPIstruct
*
)
PyCObject_Import
(
"persistent.cPersistence"
,
"CAPI"
);
#endif
if
(
!
c
api
)
if
(
!
c
PersistenceCAPI
)
return
NULL
;
c
api
->
percachedel
=
(
percachedelfunc
)
cc_oid_unreferenced
;
c
PersistenceCAPI
->
percachedel
=
(
percachedelfunc
)
cc_oid_unreferenced
;
py__p_changed
=
INTERN
(
"_p_changed"
);
if
(
!
py__p_changed
)
...
...
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