[Python-checkins] r79035 - in python/branches/py3k: Lib/test/test_compile.py Python/compile.c
benjamin.peterson
python-checkins at python.org
Wed Mar 17 21:56:59 CET 2010
Author: benjamin.peterson
Date: Wed Mar 17 21:56:58 2010
New Revision: 79035
Log:
Merged revisions 79034 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r79034 | benjamin.peterson | 2010-03-17 15:41:42 -0500 (Wed, 17 Mar 2010) | 1 line
prevent lambda functions from having docstrings #8164
........
Modified:
python/branches/py3k/ (props changed)
python/branches/py3k/Lib/test/test_compile.py
python/branches/py3k/Python/compile.c
Modified: python/branches/py3k/Lib/test/test_compile.py
==============================================================================
--- python/branches/py3k/Lib/test/test_compile.py (original)
+++ python/branches/py3k/Lib/test/test_compile.py Wed Mar 17 21:56:58 2010
@@ -292,9 +292,9 @@
f1, f2 = f()
self.assertNotEqual(id(f1.__code__), id(f2.__code__))
-## def test_unicode_encoding(self):
-## code = "# -*- coding: utf-8 -*-\npass\n"
-## self.assertRaises(SyntaxError, compile, code, "tmp", "exec")
+ def test_lambda_doc(self):
+ l = lambda: "foo"
+ self.assertIsNone(l.__doc__)
def test_subscripts(self):
# SF bug 1448804
Modified: python/branches/py3k/Python/compile.c
==============================================================================
--- python/branches/py3k/Python/compile.c (original)
+++ python/branches/py3k/Python/compile.c Wed Mar 17 21:56:58 2010
@@ -1660,6 +1660,11 @@
if (!compiler_enter_scope(c, name, (void *)e, e->lineno))
return 0;
+ /* Make None the first constant, so the lambda can't have a
+ docstring. */
+ if (compiler_add_o(c, c->u->u_consts, Py_None) < 0)
+ return 0;
+
c->u->u_argcount = asdl_seq_LEN(args->args);
c->u->u_kwonlyargcount = asdl_seq_LEN(args->kwonlyargs);
VISIT_IN_SCOPE(c, expr, e->v.Lambda.body);
More information about the Python-checkins
mailing list