* config.c: Added audioop to lists.

* Makefile: change default source directory
* socketmodule.c: added getsockname and getpeername
* bltinmodule.c: corrected typo in type() error message
* Added new built-in functions str() and repr(): repr(x) == `x`;
  str(x) == x if x is a string, otherwise str(x) == repr(x).
* Added joinfields to stropmodule.c (string.join calls joinfields now)
This commit is contained in:
Guido van Rossum 1992-11-26 08:54:07 +00:00
parent df9320f8bc
commit c89705d697
4 changed files with 152 additions and 1 deletions

View file

@ -601,13 +601,42 @@ builtin_reload(self, v)
return reload_module(v);
}
static object *
builtin_repr(self, v)
object *self;
object *v;
{
if (v == NULL) {
err_badarg();
return NULL;
}
return reprobject(v);
}
static object *
builtin_str(self, v)
object *self;
object *v;
{
if (v == NULL) {
err_badarg();
return NULL;
}
if (is_stringobject(v)) {
INCREF(v);
return v;
}
else
return reprobject(v);
}
static object *
builtin_type(self, v)
object *self;
object *v;
{
if (v == NULL) {
err_setstr(TypeError, "type() requres an argument");
err_setstr(TypeError, "type() requires an argument");
return NULL;
}
v = (object *)v->ob_type;
@ -642,7 +671,9 @@ static struct methodlist builtin_methods[] = {
{"range", builtin_range},
{"raw_input", builtin_raw_input},
{"reload", builtin_reload},
{"repr", builtin_repr},
{"setattr", builtin_setattr},
{"str", builtin_str},
{"type", builtin_type},
{NULL, NULL},
};