diff options
author | Guido van Rossum <guido@python.org> | 1992-11-26 08:54:07 (GMT) |
---|---|---|
committer | Guido van Rossum <guido@python.org> | 1992-11-26 08:54:07 (GMT) |
commit | c89705d6975ffb1e4a3764f4f36bab339f969e8f (patch) | |
tree | b4e565a58d410ad3a60ffbe11f94c2567b14365d /Python/bltinmodule.c | |
parent | df9320f8bcad10431fa103459fcebd4b5430599a (diff) | |
download | cpython-c89705d6975ffb1e4a3764f4f36bab339f969e8f.zip cpython-c89705d6975ffb1e4a3764f4f36bab339f969e8f.tar.gz cpython-c89705d6975ffb1e4a3764f4f36bab339f969e8f.tar.bz2 |
* 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)
Diffstat (limited to 'Python/bltinmodule.c')
-rw-r--r-- | Python/bltinmodule.c | 33 |
1 files changed, 32 insertions, 1 deletions
diff --git a/Python/bltinmodule.c b/Python/bltinmodule.c index 18fae5c..a6e02be 100644 --- a/Python/bltinmodule.c +++ b/Python/bltinmodule.c @@ -602,12 +602,41 @@ builtin_reload(self, 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}, }; |