* Changed all copyright messages to include 1993.

* Stubs for faster implementation of local variables (not yet finished)
* Added function name to code object.  Print it for code and function
  objects.  THIS MAKES THE .PYC FILE FORMAT INCOMPATIBLE (the version
  number has changed accordingly)
* Print address of self for built-in methods
* New internal functions getattro and setattro (getattr/setattr with
  string object arg)
* Replaced "dictobject" with more powerful "mappingobject"
* New per-type functio tp_hash to implement arbitrary object hashing,
  and hashobject() to interface to it
* Added built-in functions hash(v) and hasattr(v, 'name')
* classobject: made some functions static that accidentally weren't;
  added __hash__ special instance method to implement hash()
* Added proper comparison for built-in methods and functions
This commit is contained in:
Guido van Rossum 1993-03-29 10:43:31 +00:00
parent 4b1302bd1d
commit 9bfef44d97
97 changed files with 559 additions and 246 deletions

View file

@ -281,10 +281,28 @@ builtin_getattr(self, args)
object *args;
{
object *v;
char *name;
if (!getargs(args, "(Os)", &v, &name))
object *name;
if (!getargs(args, "(OS)", &v, &name))
return NULL;
return getattr(v, name);
return getattro(v, name);
}
static object *
builtin_hasattr(self, args)
object *self;
object *args;
{
object *v;
object *name;
if (!getargs(args, "(OS)", &v, &name))
return NULL;
v = getattro(v, name);
if (v == NULL) {
err_clear();
return newintobject(0L);
}
DECREF(v);
return newintobject(1L);
}
static object *
@ -293,16 +311,31 @@ builtin_setattr(self, args)
object *args;
{
object *v;
char *name;
object *name;
object *value;
if (!getargs(args, "(OsO)", &v, &name, &value))
if (!getargs(args, "(OSO)", &v, &name, &value))
return NULL;
if (setattr(v, name, value) != 0)
if (setattro(v, name, value) != 0)
return NULL;
INCREF(None);
return None;
}
static object *
builtin_hash(self, args)
object *self;
object *args;
{
object *v;
long x;
if (!getargs(args, "O", &v))
return NULL;
x = hashobject(v);
if (x == -1)
return NULL;
return newintobject(x);
}
static object *
builtin_hex(self, v)
object *self;
@ -687,6 +720,8 @@ static struct methodlist builtin_methods[] = {
{"execfile", builtin_execfile},
{"float", builtin_float},
{"getattr", builtin_getattr},
{"hasattr", builtin_hasattr},
{"hash", builtin_hash},
{"hex", builtin_hex},
{"input", builtin_input},
{"int", builtin_int},