Commit 6f4a4332 authored by Toby Dickenson's avatar Toby Dickenson

fixed ZClass-related type-checking breakage introduced in reformatting in rev...

fixed ZClass-related type-checking breakage introduced in reformatting in rev 1.45. I guess there are no unit tests for ZClasses?
parent e7b0ae20
...@@ -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.60 2002/04/16 06:26:44 htrd Exp $\n"; "$Id: cPickleCache.c,v 1.61 2002/04/17 17:18:37 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,23 +786,21 @@ static int ...@@ -786,23 +786,21 @@ static int
cc_add_item(ccobject *self, PyObject *key, PyObject *v) cc_add_item(ccobject *self, PyObject *key, PyObject *v)
{ {
int result; int result;
PyExtensionClass *class;
PyObject *oid, *object_again; PyObject *oid, *object_again;
cPersistentObject *p; cPersistentObject *p;
if (!PyExtensionInstance_Check(v)) { if (PyExtensionClass_Check(v)) {
PyErr_SetString(PyExc_TypeError, /* Its a persistent class, such as a ZClass. Thats ok. */
"Cache values must be persistent objects."); }
return -1; else if( PyExtensionInstance_Check(v) &&
(((PyExtensionClass*)(v->ob_type))->class_flags & PERSISTENT_TYPE_FLAG) &&
(v->ob_type->tp_basicsize >= sizeof(cPersistentObject)) ) {
/* Its and instance of a persistent class, (ie Python classeses that
derive from Persistence.Persistent, BTrees, etc). Thats ok. */
} }
class = (PyExtensionClass *)(v->ob_type); else {
if (!((class->class_flags & PERSISTENT_TYPE_FLAG)
&& v->ob_type->tp_basicsize >= sizeof(cPersistentObject))) {
PyErr_SetString(PyExc_TypeError, PyErr_SetString(PyExc_TypeError,
"Cache values must be persistent objects."); "Cache values must be persistent objects.");
/* Must be either persistent classes (ie ZClasses), or instances
of persistent classes (ie Python classeses that derive from
Persistence.Persistent, BTrees, etc) */
return -1; return -1;
} }
......
...@@ -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.60 2002/04/16 06:26:44 htrd Exp $\n"; "$Id: cPickleCache.c,v 1.61 2002/04/17 17:18:37 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,23 +786,21 @@ static int ...@@ -786,23 +786,21 @@ static int
cc_add_item(ccobject *self, PyObject *key, PyObject *v) cc_add_item(ccobject *self, PyObject *key, PyObject *v)
{ {
int result; int result;
PyExtensionClass *class;
PyObject *oid, *object_again; PyObject *oid, *object_again;
cPersistentObject *p; cPersistentObject *p;
if (!PyExtensionInstance_Check(v)) { if (PyExtensionClass_Check(v)) {
PyErr_SetString(PyExc_TypeError, /* Its a persistent class, such as a ZClass. Thats ok. */
"Cache values must be persistent objects."); }
return -1; else if( PyExtensionInstance_Check(v) &&
(((PyExtensionClass*)(v->ob_type))->class_flags & PERSISTENT_TYPE_FLAG) &&
(v->ob_type->tp_basicsize >= sizeof(cPersistentObject)) ) {
/* Its and instance of a persistent class, (ie Python classeses that
derive from Persistence.Persistent, BTrees, etc). Thats ok. */
} }
class = (PyExtensionClass *)(v->ob_type); else {
if (!((class->class_flags & PERSISTENT_TYPE_FLAG)
&& v->ob_type->tp_basicsize >= sizeof(cPersistentObject))) {
PyErr_SetString(PyExc_TypeError, PyErr_SetString(PyExc_TypeError,
"Cache values must be persistent objects."); "Cache values must be persistent objects.");
/* Must be either persistent classes (ie ZClasses), or instances
of persistent classes (ie Python classeses that derive from
Persistence.Persistent, BTrees, etc) */
return -1; return -1;
} }
......
...@@ -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.60 2002/04/16 06:26:44 htrd Exp $\n"; "$Id: cPickleCache.c,v 1.61 2002/04/17 17:18:37 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,23 +786,21 @@ static int ...@@ -786,23 +786,21 @@ static int
cc_add_item(ccobject *self, PyObject *key, PyObject *v) cc_add_item(ccobject *self, PyObject *key, PyObject *v)
{ {
int result; int result;
PyExtensionClass *class;
PyObject *oid, *object_again; PyObject *oid, *object_again;
cPersistentObject *p; cPersistentObject *p;
if (!PyExtensionInstance_Check(v)) { if (PyExtensionClass_Check(v)) {
PyErr_SetString(PyExc_TypeError, /* Its a persistent class, such as a ZClass. Thats ok. */
"Cache values must be persistent objects."); }
return -1; else if( PyExtensionInstance_Check(v) &&
(((PyExtensionClass*)(v->ob_type))->class_flags & PERSISTENT_TYPE_FLAG) &&
(v->ob_type->tp_basicsize >= sizeof(cPersistentObject)) ) {
/* Its and instance of a persistent class, (ie Python classeses that
derive from Persistence.Persistent, BTrees, etc). Thats ok. */
} }
class = (PyExtensionClass *)(v->ob_type); else {
if (!((class->class_flags & PERSISTENT_TYPE_FLAG)
&& v->ob_type->tp_basicsize >= sizeof(cPersistentObject))) {
PyErr_SetString(PyExc_TypeError, PyErr_SetString(PyExc_TypeError,
"Cache values must be persistent objects."); "Cache values must be persistent objects.");
/* Must be either persistent classes (ie ZClasses), or instances
of persistent classes (ie Python classeses that derive from
Persistence.Persistent, BTrees, etc) */
return -1; return -1;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment