diff options
author | Guido van Rossum <guido@python.org> | 1993-11-30 13:40:46 (GMT) |
---|---|---|
committer | Guido van Rossum <guido@python.org> | 1993-11-30 13:40:46 (GMT) |
commit | 590baa4a7a43b596119b47f605e3e570c2b3b0ee (patch) | |
tree | 767cbcf90f5b53bf63be9c2ea9a8081551120f10 /Python/bltinmodule.c | |
parent | 8732d6aeea250f23af50b772d710109c9ee3bc00 (diff) | |
download | cpython-590baa4a7a43b596119b47f605e3e570c2b3b0ee.zip cpython-590baa4a7a43b596119b47f605e3e570c2b3b0ee.tar.gz cpython-590baa4a7a43b596119b47f605e3e570c2b3b0ee.tar.bz2 |
* import.c (get_module): pass .py filename to parse_file, not .pyc filename!
* funcobject.c (func_repr): don't call getstringvalue(None) for anonymous
functions.
* bltinmodule.c: removed lambda (which is now a built-in function);
removed implied lambda for string arg to filter/map/reduce.
* Grammar, graminit.[ch], compile.[ch]: replaced lambda as built-in
function by lambda as grammar entity: instead of "lambda('x: x+1')" you
write "lambda x: x+1".
* Xtmodule.c (checkargdict): return 0, not NULL, for error.
Diffstat (limited to 'Python/bltinmodule.c')
-rw-r--r-- | Python/bltinmodule.c | 47 |
1 files changed, 3 insertions, 44 deletions
diff --git a/Python/bltinmodule.c b/Python/bltinmodule.c index 97ed2f4..b63f56d 100644 --- a/Python/bltinmodule.c +++ b/Python/bltinmodule.c @@ -79,23 +79,13 @@ builtin_filter(self, args) if (!getargs(args, "(OO)", &func, &seq)) return NULL; - if (is_stringobject(func)) { - if ((func = exec_eval(func, lambda_input)) == NULL) - return NULL; - } - else { - INCREF(func); - } - if (is_stringobject(seq)) { object *r = filterstring(func, seq); - DECREF(func); return r; } if (is_tupleobject(seq)) { object *r = filtertuple(func, seq); - DECREF(func); return r; } @@ -150,13 +140,11 @@ builtin_filter(self, args) if (setlistslice(result, j, len, NULL) < 0) goto Fail_1; - DECREF(func); return result; Fail_1: DECREF(result); Fail_2: - DECREF(func); return NULL; } @@ -306,10 +294,10 @@ exec_eval(v, start) globals != NULL && !is_dictobject(globals) || locals != NULL && !is_dictobject(locals)) { err_setstr(TypeError, - "eval/lambda arguments must be (string|code)[,dict[,dict]]"); + "eval arguments must be (string|code)[,dict[,dict]]"); return NULL; } - /* XXX The following is only correct for eval(), not for lambda() */ + if (is_codeobject(str)) return eval_code((codeobject *) str, globals, locals, (object *)NULL, (object *)NULL); @@ -318,7 +306,7 @@ exec_eval(v, start) err_setstr(ValueError, "embedded '\\0' in string arg"); return NULL; } - if (start == eval_input || start == lambda_input) { + if (start == eval_input) { while (*s == ' ' || *s == '\t') s++; } @@ -460,14 +448,6 @@ builtin_map(self, args) func = gettupleitem(args, 0); n = gettuplesize(args) - 1; - if (is_stringobject(func)) { - if ((func = exec_eval(func, lambda_input)) == NULL) - return NULL; - } - else { - INCREF(func); - } - if ((seqs = NEW(sequence, n)) == NULL) { err_nomem(); goto Fail_2; @@ -549,13 +529,11 @@ builtin_map(self, args) } if (seqs) DEL(seqs); - DECREF(func); return result; Fail_1: DECREF(result); Fail_2: - DECREF(func); if (seqs) DEL(seqs); return NULL; } @@ -639,14 +617,6 @@ builtin_int(self, v) } static object * -builtin_lambda(self, v) - object *self; - object *v; -{ - return exec_eval(v, lambda_input); -} - -static object * builtin_len(self, v) object *self; object *v; @@ -977,14 +947,6 @@ builtin_reduce(self, args) return NULL; } - if (is_stringobject(func)) { - if ((func = exec_eval(func, lambda_input)) == NULL) - return NULL; - } - else { - INCREF(func); - } - if ((len = (*sqf->sq_length)(seq)) < 0) goto Fail_2; @@ -1025,7 +987,6 @@ builtin_reduce(self, args) } DECREF(args); - DECREF(func); return result; @@ -1035,7 +996,6 @@ Fail_0: Fail_1: DECREF(result); Fail_2: - DECREF(func); return NULL; } @@ -1133,7 +1093,6 @@ static struct methodlist builtin_methods[] = { {"id", builtin_id}, {"input", builtin_input}, {"int", builtin_int}, - {"lambda", builtin_lambda}, {"len", builtin_len}, {"long", builtin_long}, {"map", builtin_map}, |