Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Z
ZEO
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
ZEO
Commits
c57189e3
Commit
c57189e3
authored
Apr 18, 2002
by
Toby Dickenson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Extra sanity checks on attributes of persistent objects; enough to fix a broken test case
parent
6f4a4332
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
69 additions
and
18 deletions
+69
-18
src/Persistence/cPickleCache.c
src/Persistence/cPickleCache.c
+22
-6
src/ZODB/cPickleCache.c
src/ZODB/cPickleCache.c
+22
-6
src/ZODB/tests/testCache.py
src/ZODB/tests/testCache.py
+3
-0
src/persistent/cPickleCache.c
src/persistent/cPickleCache.c
+22
-6
No files found.
src/Persistence/cPickleCache.c
View file @
c57189e3
...
@@ -88,7 +88,7 @@ process must skip such objects, rather than deactivating them.
...
@@ -88,7 +88,7 @@ process must skip such objects, rather than deactivating them.
static
char
cPickleCache_doc_string
[]
=
static
char
cPickleCache_doc_string
[]
=
"Defines the PickleCache used by ZODB Connection objects.
\n
"
"Defines the PickleCache used by ZODB Connection objects.
\n
"
"
\n
"
"
\n
"
"$Id: cPickleCache.c,v 1.6
1 2002/04/17 17:18:37
htrd Exp $
\n
"
;
"$Id: cPickleCache.c,v 1.6
2 2002/04/18 09:16:24
htrd Exp $
\n
"
;
#define ASSIGN(V,E) {PyObject *__e; __e=(E); Py_XDECREF(V); (V)=__e;}
#define ASSIGN(V,E) {PyObject *__e; __e=(E); Py_XDECREF(V); (V)=__e;}
#define UNLESS(E) if(!(E))
#define UNLESS(E) if(!(E))
...
@@ -786,7 +786,7 @@ static int
...
@@ -786,7 +786,7 @@ static int
cc_add_item
(
ccobject
*
self
,
PyObject
*
key
,
PyObject
*
v
)
cc_add_item
(
ccobject
*
self
,
PyObject
*
key
,
PyObject
*
v
)
{
{
int
result
;
int
result
;
PyObject
*
oid
,
*
object_again
;
PyObject
*
oid
,
*
object_again
,
*
jar
;
cPersistentObject
*
p
;
cPersistentObject
*
p
;
if
(
PyExtensionClass_Check
(
v
))
{
if
(
PyExtensionClass_Check
(
v
))
{
...
@@ -810,8 +810,15 @@ cc_add_item(ccobject *self, PyObject *key, PyObject *v)
...
@@ -810,8 +810,15 @@ cc_add_item(ccobject *self, PyObject *key, PyObject *v)
oid
=
PyObject_GetAttr
(
v
,
py__p_oid
);
oid
=
PyObject_GetAttr
(
v
,
py__p_oid
);
if
(
oid
==
NULL
)
if
(
oid
==
NULL
)
return
-
1
;
return
-
1
;
/* XXX key and oid should both be PyString objects.
if
(
!
PyString_Check
(
oid
))
{
May be helpful to check this. */
PyErr_Format
(
PyExc_TypeError
,
"Cached object oid must be a string, not a %s"
,
oid
->
ob_type
->
tp_name
);
return
-
1
;
}
/* we know they are both strings.
* now check if they are the same string.
*/
result
=
PyObject_Compare
(
key
,
oid
);
result
=
PyObject_Compare
(
key
,
oid
);
if
(
PyErr_Occurred
())
{
if
(
PyErr_Occurred
())
{
Py_DECREF
(
oid
);
Py_DECREF
(
oid
);
...
@@ -819,11 +826,20 @@ cc_add_item(ccobject *self, PyObject *key, PyObject *v)
...
@@ -819,11 +826,20 @@ cc_add_item(ccobject *self, PyObject *key, PyObject *v)
}
}
Py_DECREF
(
oid
);
Py_DECREF
(
oid
);
if
(
result
)
{
if
(
result
)
{
PyErr_SetString
(
PyExc_ValueError
,
"
c
ache key does not match oid"
);
PyErr_SetString
(
PyExc_ValueError
,
"
C
ache key does not match oid"
);
return
-
1
;
return
-
1
;
}
}
/* XXX check that object has valid _p_jar? */
/* useful sanity check, but not strictly an invariant of this class */
jar
=
PyObject_GetAttr
(
v
,
py__p_jar
);
if
(
jar
==
NULL
)
return
-
1
;
Py_DECREF
(
jar
);
if
(
jar
==
Py_None
)
{
PyErr_SetString
(
PyExc_ValueError
,
"Cached object jar missing"
);
return
-
1
;
}
object_again
=
object_from_oid
(
self
,
key
);
object_again
=
object_from_oid
(
self
,
key
);
if
(
object_again
)
{
if
(
object_again
)
{
...
...
src/ZODB/cPickleCache.c
View file @
c57189e3
...
@@ -88,7 +88,7 @@ process must skip such objects, rather than deactivating them.
...
@@ -88,7 +88,7 @@ process must skip such objects, rather than deactivating them.
static
char
cPickleCache_doc_string
[]
=
static
char
cPickleCache_doc_string
[]
=
"Defines the PickleCache used by ZODB Connection objects.
\n
"
"Defines the PickleCache used by ZODB Connection objects.
\n
"
"
\n
"
"
\n
"
"$Id: cPickleCache.c,v 1.6
1 2002/04/17 17:18:37
htrd Exp $
\n
"
;
"$Id: cPickleCache.c,v 1.6
2 2002/04/18 09:16:24
htrd Exp $
\n
"
;
#define ASSIGN(V,E) {PyObject *__e; __e=(E); Py_XDECREF(V); (V)=__e;}
#define ASSIGN(V,E) {PyObject *__e; __e=(E); Py_XDECREF(V); (V)=__e;}
#define UNLESS(E) if(!(E))
#define UNLESS(E) if(!(E))
...
@@ -786,7 +786,7 @@ static int
...
@@ -786,7 +786,7 @@ static int
cc_add_item
(
ccobject
*
self
,
PyObject
*
key
,
PyObject
*
v
)
cc_add_item
(
ccobject
*
self
,
PyObject
*
key
,
PyObject
*
v
)
{
{
int
result
;
int
result
;
PyObject
*
oid
,
*
object_again
;
PyObject
*
oid
,
*
object_again
,
*
jar
;
cPersistentObject
*
p
;
cPersistentObject
*
p
;
if
(
PyExtensionClass_Check
(
v
))
{
if
(
PyExtensionClass_Check
(
v
))
{
...
@@ -810,8 +810,15 @@ cc_add_item(ccobject *self, PyObject *key, PyObject *v)
...
@@ -810,8 +810,15 @@ cc_add_item(ccobject *self, PyObject *key, PyObject *v)
oid
=
PyObject_GetAttr
(
v
,
py__p_oid
);
oid
=
PyObject_GetAttr
(
v
,
py__p_oid
);
if
(
oid
==
NULL
)
if
(
oid
==
NULL
)
return
-
1
;
return
-
1
;
/* XXX key and oid should both be PyString objects.
if
(
!
PyString_Check
(
oid
))
{
May be helpful to check this. */
PyErr_Format
(
PyExc_TypeError
,
"Cached object oid must be a string, not a %s"
,
oid
->
ob_type
->
tp_name
);
return
-
1
;
}
/* we know they are both strings.
* now check if they are the same string.
*/
result
=
PyObject_Compare
(
key
,
oid
);
result
=
PyObject_Compare
(
key
,
oid
);
if
(
PyErr_Occurred
())
{
if
(
PyErr_Occurred
())
{
Py_DECREF
(
oid
);
Py_DECREF
(
oid
);
...
@@ -819,11 +826,20 @@ cc_add_item(ccobject *self, PyObject *key, PyObject *v)
...
@@ -819,11 +826,20 @@ cc_add_item(ccobject *self, PyObject *key, PyObject *v)
}
}
Py_DECREF
(
oid
);
Py_DECREF
(
oid
);
if
(
result
)
{
if
(
result
)
{
PyErr_SetString
(
PyExc_ValueError
,
"
c
ache key does not match oid"
);
PyErr_SetString
(
PyExc_ValueError
,
"
C
ache key does not match oid"
);
return
-
1
;
return
-
1
;
}
}
/* XXX check that object has valid _p_jar? */
/* useful sanity check, but not strictly an invariant of this class */
jar
=
PyObject_GetAttr
(
v
,
py__p_jar
);
if
(
jar
==
NULL
)
return
-
1
;
Py_DECREF
(
jar
);
if
(
jar
==
Py_None
)
{
PyErr_SetString
(
PyExc_ValueError
,
"Cached object jar missing"
);
return
-
1
;
}
object_again
=
object_from_oid
(
self
,
key
);
object_again
=
object_from_oid
(
self
,
key
);
if
(
object_again
)
{
if
(
object_again
)
{
...
...
src/ZODB/tests/testCache.py
View file @
c57189e3
...
@@ -233,6 +233,9 @@ class CacheErrors(unittest.TestCase):
...
@@ -233,6 +233,9 @@ class CacheErrors(unittest.TestCase):
o
=
StubObject
()
o
=
StubObject
()
# o._p_oid == None
# o._p_oid == None
self
.
assertRaises
(
TypeError
,
add
,
key
,
o
)
o
.
_p_oid
=
p64
(
3
)
self
.
assertRaises
(
ValueError
,
add
,
key
,
o
)
self
.
assertRaises
(
ValueError
,
add
,
key
,
o
)
o
.
_p_oid
=
key
o
.
_p_oid
=
key
...
...
src/persistent/cPickleCache.c
View file @
c57189e3
...
@@ -88,7 +88,7 @@ process must skip such objects, rather than deactivating them.
...
@@ -88,7 +88,7 @@ process must skip such objects, rather than deactivating them.
static
char
cPickleCache_doc_string
[]
=
static
char
cPickleCache_doc_string
[]
=
"Defines the PickleCache used by ZODB Connection objects.
\n
"
"Defines the PickleCache used by ZODB Connection objects.
\n
"
"
\n
"
"
\n
"
"$Id: cPickleCache.c,v 1.6
1 2002/04/17 17:18:37
htrd Exp $
\n
"
;
"$Id: cPickleCache.c,v 1.6
2 2002/04/18 09:16:24
htrd Exp $
\n
"
;
#define ASSIGN(V,E) {PyObject *__e; __e=(E); Py_XDECREF(V); (V)=__e;}
#define ASSIGN(V,E) {PyObject *__e; __e=(E); Py_XDECREF(V); (V)=__e;}
#define UNLESS(E) if(!(E))
#define UNLESS(E) if(!(E))
...
@@ -786,7 +786,7 @@ static int
...
@@ -786,7 +786,7 @@ static int
cc_add_item
(
ccobject
*
self
,
PyObject
*
key
,
PyObject
*
v
)
cc_add_item
(
ccobject
*
self
,
PyObject
*
key
,
PyObject
*
v
)
{
{
int
result
;
int
result
;
PyObject
*
oid
,
*
object_again
;
PyObject
*
oid
,
*
object_again
,
*
jar
;
cPersistentObject
*
p
;
cPersistentObject
*
p
;
if
(
PyExtensionClass_Check
(
v
))
{
if
(
PyExtensionClass_Check
(
v
))
{
...
@@ -810,8 +810,15 @@ cc_add_item(ccobject *self, PyObject *key, PyObject *v)
...
@@ -810,8 +810,15 @@ cc_add_item(ccobject *self, PyObject *key, PyObject *v)
oid
=
PyObject_GetAttr
(
v
,
py__p_oid
);
oid
=
PyObject_GetAttr
(
v
,
py__p_oid
);
if
(
oid
==
NULL
)
if
(
oid
==
NULL
)
return
-
1
;
return
-
1
;
/* XXX key and oid should both be PyString objects.
if
(
!
PyString_Check
(
oid
))
{
May be helpful to check this. */
PyErr_Format
(
PyExc_TypeError
,
"Cached object oid must be a string, not a %s"
,
oid
->
ob_type
->
tp_name
);
return
-
1
;
}
/* we know they are both strings.
* now check if they are the same string.
*/
result
=
PyObject_Compare
(
key
,
oid
);
result
=
PyObject_Compare
(
key
,
oid
);
if
(
PyErr_Occurred
())
{
if
(
PyErr_Occurred
())
{
Py_DECREF
(
oid
);
Py_DECREF
(
oid
);
...
@@ -819,11 +826,20 @@ cc_add_item(ccobject *self, PyObject *key, PyObject *v)
...
@@ -819,11 +826,20 @@ cc_add_item(ccobject *self, PyObject *key, PyObject *v)
}
}
Py_DECREF
(
oid
);
Py_DECREF
(
oid
);
if
(
result
)
{
if
(
result
)
{
PyErr_SetString
(
PyExc_ValueError
,
"
c
ache key does not match oid"
);
PyErr_SetString
(
PyExc_ValueError
,
"
C
ache key does not match oid"
);
return
-
1
;
return
-
1
;
}
}
/* XXX check that object has valid _p_jar? */
/* useful sanity check, but not strictly an invariant of this class */
jar
=
PyObject_GetAttr
(
v
,
py__p_jar
);
if
(
jar
==
NULL
)
return
-
1
;
Py_DECREF
(
jar
);
if
(
jar
==
Py_None
)
{
PyErr_SetString
(
PyExc_ValueError
,
"Cached object jar missing"
);
return
-
1
;
}
object_again
=
object_from_oid
(
self
,
key
);
object_again
=
object_from_oid
(
self
,
key
);
if
(
object_again
)
{
if
(
object_again
)
{
...
...
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