Mercurial > cpython-lru_cache-weakref
diff Modules/newmodule.c @ 4562:d030ea533e63 legacy-trunk
Upgraded new.function() contributed by Tommy. Also got rid of #if 0'ed code.
| author | Guido van Rossum <guido@python.org> |
|---|---|
| date | Thu, 21 Nov 1996 16:02:12 +0000 |
| parents | 65d2d8e67da3 |
| children | d5023d0c5502 |
line wrap: on
line diff
--- a/Modules/newmodule.c Wed Nov 20 22:20:21 1996 +0000 +++ b/Modules/newmodule.c Thu Nov 21 16:02:12 1996 +0000 @@ -79,11 +79,8 @@ return newinstancemethodobject(func, self, classObj); } -/* XXX These internal interfaces have changed -- who'll fix this code? */ -#if 0 - static char new_function_doc[] = -"Create a function object from (CODE, GLOBALS, [NAME, ARGCOUNT, ARGDEFS])."; +"Create a function object from (CODE, GLOBALS, [NAME, ARGDEFS])."; static object * new_function(unused, args) @@ -93,16 +90,14 @@ object* code; object* globals; object* name = None; - int argcount = -1; - object* argdefs = None; + object* defaults = None; funcobject* newfunc; - if (!newgetargs(args, "O!O!|SiO!", + if (!newgetargs(args, "O!O!|SO!", &Codetype, &code, &Mappingtype, &globals, &name, - &argcount, - &Tupletype, &argdefs)) + &Tupletype, &defaults)) return NULL; newfunc = (funcobject *)newfuncobject(code, globals); @@ -114,16 +109,14 @@ XDECREF(newfunc->func_name); newfunc->func_name = name; } - newfunc->func_argcount = argcount; - if (argdefs != NULL) { - XINCREF(argdefs); - XDECREF(newfunc->func_argdefs); - newfunc->func_argdefs = argdefs; + if (defaults != NULL) { + XINCREF(defaults); + XDECREF(newfunc->func_defaults); + newfunc->func_defaults = defaults; } return (object *)newfunc; } -#endif static char new_code_doc[] = "Create a code object from (ARGCOUNT, NLOCALS, FLAGS, CODESTRING, CONSTANTS, NAMES, VARNAMES, FILENAME, NAME)."; @@ -143,13 +136,6 @@ object* filename; object* name; -#if 0 - if (!newgetargs(args, "SO!O!SS", - &code, &Tupletype, &consts, &Tupletype, &names, - &filename, &name)) - return NULL; - return (object *)newcodeobject(code, consts, names, filename, name); -#else if (!newgetargs(args, "iiiSO!O!O!SS", &argcount, &nlocals, &flags, /* These are new */ &code, &Tupletype, &consts, &Tupletype, &names, @@ -158,7 +144,6 @@ return NULL; return (object *)newcodeobject(argcount, nlocals, flags, code, consts, names, varnames, filename, name); -#endif } static char new_module_doc[] = @@ -197,9 +182,7 @@ static struct methodlist new_methods[] = { {"instance", new_instance, 1, new_instance_doc}, {"instancemethod", new_instancemethod, 1, new_im_doc}, -#if 0 {"function", new_function, 1, new_function_doc}, -#endif {"code", new_code, 1, new_code_doc}, {"module", new_module, 1, new_module_doc}, {"classobj", new_class, 1, new_class_doc},
