Mercurial > cpython-lru_cache-weakref
diff Python/bltinmodule.c @ 1094:d2af6bdcb6d0 legacy-trunk
* 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)
| author | Guido van Rossum <guido@python.org> |
|---|---|
| date | Thu, 26 Nov 1992 08:54:07 +0000 |
| parents | e4c6a0dd5c2b |
| children | ce718457b172 |
line wrap: on
line diff
--- a/Python/bltinmodule.c Mon Nov 16 16:56:04 1992 +0000 +++ b/Python/bltinmodule.c Thu Nov 26 08:54:07 1992 +0000 @@ -602,12 +602,41 @@ } 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 @@ {"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}, };
