Commit 4527a40d authored by Jim Fulton's avatar Jim Fulton

Fixed bug in subclass_nonzero.

parent 53f3e722
/* /*
$Id: ExtensionClass.c,v 1.6 1997/02/24 15:43:57 jim Exp $ $Id: ExtensionClass.c,v 1.7 1997/02/24 23:17:47 jim Exp $
Extension Class Extension Class
...@@ -56,6 +56,9 @@ ...@@ -56,6 +56,9 @@
(540) 371-6909 (540) 371-6909
$Log: ExtensionClass.c,v $ $Log: ExtensionClass.c,v $
Revision 1.7 1997/02/24 23:17:47 jim
Fixed bug in subclass_nonzero.
Revision 1.6 1997/02/24 15:43:57 jim Revision 1.6 1997/02/24 15:43:57 jim
Added __version__ string. Added __version__ string.
...@@ -94,7 +97,7 @@ static char ExtensionClass_module_documentation[] = ...@@ -94,7 +97,7 @@ static char ExtensionClass_module_documentation[] =
" - They provide access to unbound methods,\n" " - They provide access to unbound methods,\n"
" - They can be called to create instances.\n" " - They can be called to create instances.\n"
"\n" "\n"
"$Id: ExtensionClass.c,v 1.6 1997/02/24 15:43:57 jim Exp $\n" "$Id: ExtensionClass.c,v 1.7 1997/02/24 23:17:47 jim Exp $\n"
; ;
#include <stdio.h> #include <stdio.h>
...@@ -1950,7 +1953,17 @@ subclass_nonzero(PyObject *self) ...@@ -1950,7 +1953,17 @@ subclass_nonzero(PyObject *self)
PyObject *m; PyObject *m;
long r; long r;
UNLESS(m=subclass_getspecial(self,py__nonzero__)) return -1; UNLESS(m=subclass_getspecial(self,py__nonzero__))
{ /* We are being asked is we are true
Check out len, and if that fails, say we are true.
*/
PyErr_Clear();
UNLESS(m=subclass_getspecial(self,py__len__))
{
PyErr_Clear();
return 1;
}
}
if(UnboundCMethod_Check(m) && AsCMethod(m)->meth==nonzero_by_name if(UnboundCMethod_Check(m) && AsCMethod(m)->meth==nonzero_by_name
&& SubclassInstance_Check(self,AsCMethod(m)->type)) && SubclassInstance_Check(self,AsCMethod(m)->type))
r=AsCMethod(m)->type->tp_as_number->nb_nonzero(self); r=AsCMethod(m)->type->tp_as_number->nb_nonzero(self);
...@@ -2789,7 +2802,7 @@ void ...@@ -2789,7 +2802,7 @@ void
initExtensionClass() initExtensionClass()
{ {
PyObject *m, *d; PyObject *m, *d;
char *rev="$Revision: 1.6 $"; char *rev="$Revision: 1.7 $";
PURE_MIXIN_CLASS(Base, "Minimalbase class for Extension Classes", NULL); PURE_MIXIN_CLASS(Base, "Minimalbase class for Extension Classes", NULL);
PMethodType.ob_type=&PyType_Type; PMethodType.ob_type=&PyType_Type;
......
/* /*
$Id: ExtensionClass.c,v 1.6 1997/02/24 15:43:57 jim Exp $ $Id: ExtensionClass.c,v 1.7 1997/02/24 23:17:47 jim Exp $
Extension Class Extension Class
...@@ -56,6 +56,9 @@ ...@@ -56,6 +56,9 @@
(540) 371-6909 (540) 371-6909
$Log: ExtensionClass.c,v $ $Log: ExtensionClass.c,v $
Revision 1.7 1997/02/24 23:17:47 jim
Fixed bug in subclass_nonzero.
Revision 1.6 1997/02/24 15:43:57 jim Revision 1.6 1997/02/24 15:43:57 jim
Added __version__ string. Added __version__ string.
...@@ -94,7 +97,7 @@ static char ExtensionClass_module_documentation[] = ...@@ -94,7 +97,7 @@ static char ExtensionClass_module_documentation[] =
" - They provide access to unbound methods,\n" " - They provide access to unbound methods,\n"
" - They can be called to create instances.\n" " - They can be called to create instances.\n"
"\n" "\n"
"$Id: ExtensionClass.c,v 1.6 1997/02/24 15:43:57 jim Exp $\n" "$Id: ExtensionClass.c,v 1.7 1997/02/24 23:17:47 jim Exp $\n"
; ;
#include <stdio.h> #include <stdio.h>
...@@ -1950,7 +1953,17 @@ subclass_nonzero(PyObject *self) ...@@ -1950,7 +1953,17 @@ subclass_nonzero(PyObject *self)
PyObject *m; PyObject *m;
long r; long r;
UNLESS(m=subclass_getspecial(self,py__nonzero__)) return -1; UNLESS(m=subclass_getspecial(self,py__nonzero__))
{ /* We are being asked is we are true
Check out len, and if that fails, say we are true.
*/
PyErr_Clear();
UNLESS(m=subclass_getspecial(self,py__len__))
{
PyErr_Clear();
return 1;
}
}
if(UnboundCMethod_Check(m) && AsCMethod(m)->meth==nonzero_by_name if(UnboundCMethod_Check(m) && AsCMethod(m)->meth==nonzero_by_name
&& SubclassInstance_Check(self,AsCMethod(m)->type)) && SubclassInstance_Check(self,AsCMethod(m)->type))
r=AsCMethod(m)->type->tp_as_number->nb_nonzero(self); r=AsCMethod(m)->type->tp_as_number->nb_nonzero(self);
...@@ -2789,7 +2802,7 @@ void ...@@ -2789,7 +2802,7 @@ void
initExtensionClass() initExtensionClass()
{ {
PyObject *m, *d; PyObject *m, *d;
char *rev="$Revision: 1.6 $"; char *rev="$Revision: 1.7 $";
PURE_MIXIN_CLASS(Base, "Minimalbase class for Extension Classes", NULL); PURE_MIXIN_CLASS(Base, "Minimalbase class for Extension Classes", NULL);
PMethodType.ob_type=&PyType_Type; PMethodType.ob_type=&PyType_Type;
......
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