Mercurial > cpython-lru_cache-weakref
diff Objects/funcobject.c @ 1288:9fed5726a36d legacy-trunk
Several changes in one:
(1) dictionaries/mappings now have attributes values() and items() as
well as keys(); at the C level, use the new function mappinggetnext()
to iterate over a dictionary.
(2) "class C(): ..." is now illegal; you must write "class C: ...".
(3) Class objects now know their own name (finally!); and minor
improvements to the way how classes, functions and methods are
represented as strings.
(4) Added an "access" statement and semantics. (This is still
experimental -- as long as you don't use the keyword 'access' nothing
should be changed.)
| author | Guido van Rossum <guido@python.org> |
|---|---|
| date | Wed, 19 May 1993 14:50:45 +0000 |
| parents | 1cabc2b6c970 |
| children | cc172ce05561 |
line wrap: on
line diff
--- a/Objects/funcobject.c Mon May 17 08:34:16 1993 +0000 +++ b/Objects/funcobject.c Wed May 19 14:50:45 1993 +0000 @@ -28,12 +28,6 @@ #include "compile.h" #include "structmember.h" -typedef struct { - OB_HEAD - object *func_code; - object *func_globals; -} funcobject; - object * newfuncobject(code, globals) object *code; @@ -45,6 +39,8 @@ op->func_code = code; INCREF(globals); op->func_globals = globals; + op->func_name = ((codeobject*)(op->func_code))->co_name; + INCREF(op->func_name); } return (object *)op; } @@ -78,6 +74,7 @@ static struct memberlist func_memberlist[] = { {"func_code", T_OBJECT, OFF(func_code), READONLY}, {"func_globals",T_OBJECT, OFF(func_globals), READONLY}, + {"func_name", T_OBJECT, OFF(func_name), READONLY}, {NULL} /* Sentinel */ }; @@ -104,7 +101,7 @@ { char buf[140]; sprintf(buf, "<function %.100s at %lx>", - getstringvalue(((codeobject*)(op->func_code))->co_name), + getstringvalue(op->func_name), (long)op); return newstringobject(buf); }
