Commit 1cbeef98 authored by Jim Fulton's avatar Jim Fulton

Added check to getattr to fail on methods that begin with underscore.

Note that Missing really defeats testing from protocols by testing for
attributes.
parent cc0524b6
...@@ -53,7 +53,7 @@ ...@@ -53,7 +53,7 @@
static char Missing_module_documentation[] = static char Missing_module_documentation[] =
"" ""
"\n$Id: Missing.c,v 1.3 1997/09/17 22:49:35 jim Exp $" "\n$Id: Missing.c,v 1.4 1997/09/18 21:01:33 jim Exp $"
; ;
#include "ExtensionClass.h" #include "ExtensionClass.h"
...@@ -217,7 +217,9 @@ Missing_getattr(PyObject *self, PyObject *name) ...@@ -217,7 +217,9 @@ Missing_getattr(PyObject *self, PyObject *name)
if(!(c=PyString_AsString(name))) return NULL; if(!(c=PyString_AsString(name))) return NULL;
if(*c=='_' && strcmp(c,"__reduce__")==0) if(*c=='_')
{
if(strcmp(c,"__reduce__")==0)
{ {
if(self==theValue) if(self==theValue)
{ {
...@@ -226,6 +228,9 @@ Missing_getattr(PyObject *self, PyObject *name) ...@@ -226,6 +228,9 @@ Missing_getattr(PyObject *self, PyObject *name)
} }
return PyCFunction_New(reduce_ml, self); return PyCFunction_New(reduce_ml, self);
} }
PyErr_SetObject(PyExc_AttributeError, name);
return NULL;
}
Py_INCREF(self); Py_INCREF(self);
return self; return self;
...@@ -284,7 +289,7 @@ void ...@@ -284,7 +289,7 @@ void
initMissing() initMissing()
{ {
PyObject *m, *d; PyObject *m, *d;
char *rev="$Revision: 1.3 $"; char *rev="$Revision: 1.4 $";
if(! ((vname=PyString_FromString("V")) if(! ((vname=PyString_FromString("V"))
&& (Missing_dot_Value=PyString_FromString("Missing.Value")) && (Missing_dot_Value=PyString_FromString("Missing.Value"))
...@@ -319,6 +324,11 @@ initMissing() ...@@ -319,6 +324,11 @@ initMissing()
Revision Log: Revision Log:
$Log: Missing.c,v $ $Log: Missing.c,v $
Revision 1.4 1997/09/18 21:01:33 jim
Added check to getattr to fail on methods that begin with underscore.
Note that Missing really defeats testing from protocols by testing for
attributes.
Revision 1.3 1997/09/17 22:49:35 jim Revision 1.3 1997/09/17 22:49:35 jim
Fixed refcount bug. Fixed refcount bug.
Added logic so: Missing.Value.spam() returns Missing.Value. Added logic so: Missing.Value.spam() returns Missing.Value.
......
...@@ -53,7 +53,7 @@ ...@@ -53,7 +53,7 @@
static char Missing_module_documentation[] = static char Missing_module_documentation[] =
"" ""
"\n$Id: Missing.c,v 1.3 1997/09/17 22:49:35 jim Exp $" "\n$Id: Missing.c,v 1.4 1997/09/18 21:01:33 jim Exp $"
; ;
#include "ExtensionClass.h" #include "ExtensionClass.h"
...@@ -217,7 +217,9 @@ Missing_getattr(PyObject *self, PyObject *name) ...@@ -217,7 +217,9 @@ Missing_getattr(PyObject *self, PyObject *name)
if(!(c=PyString_AsString(name))) return NULL; if(!(c=PyString_AsString(name))) return NULL;
if(*c=='_' && strcmp(c,"__reduce__")==0) if(*c=='_')
{
if(strcmp(c,"__reduce__")==0)
{ {
if(self==theValue) if(self==theValue)
{ {
...@@ -226,6 +228,9 @@ Missing_getattr(PyObject *self, PyObject *name) ...@@ -226,6 +228,9 @@ Missing_getattr(PyObject *self, PyObject *name)
} }
return PyCFunction_New(reduce_ml, self); return PyCFunction_New(reduce_ml, self);
} }
PyErr_SetObject(PyExc_AttributeError, name);
return NULL;
}
Py_INCREF(self); Py_INCREF(self);
return self; return self;
...@@ -284,7 +289,7 @@ void ...@@ -284,7 +289,7 @@ void
initMissing() initMissing()
{ {
PyObject *m, *d; PyObject *m, *d;
char *rev="$Revision: 1.3 $"; char *rev="$Revision: 1.4 $";
if(! ((vname=PyString_FromString("V")) if(! ((vname=PyString_FromString("V"))
&& (Missing_dot_Value=PyString_FromString("Missing.Value")) && (Missing_dot_Value=PyString_FromString("Missing.Value"))
...@@ -319,6 +324,11 @@ initMissing() ...@@ -319,6 +324,11 @@ initMissing()
Revision Log: Revision Log:
$Log: Missing.c,v $ $Log: Missing.c,v $
Revision 1.4 1997/09/18 21:01:33 jim
Added check to getattr to fail on methods that begin with underscore.
Note that Missing really defeats testing from protocols by testing for
attributes.
Revision 1.3 1997/09/17 22:49:35 jim Revision 1.3 1997/09/17 22:49:35 jim
Fixed refcount bug. Fixed refcount bug.
Added logic so: Missing.Value.spam() returns Missing.Value. Added logic so: Missing.Value.spam() returns Missing.Value.
......
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