[Python-checkins] cpython (merge default -> default): Merge
brett.cannon
python-checkins at python.org
Wed Apr 18 03:42:16 CEST 2012
http://hg.python.org/cpython/rev/6762b943ee59
changeset: 76385:6762b943ee59
parent: 76384:c1399cf7bd6a
parent: 76383:22844ddce57b
user: Brett Cannon <brett at python.org>
date: Tue Apr 17 21:42:07 2012 -0400
summary:
Merge
files:
Lib/test/test_keywordonlyarg.py | 6 ++++++
Misc/NEWS | 2 ++
Python/compile.c | 6 +++++-
3 files changed, 13 insertions(+), 1 deletions(-)
diff --git a/Lib/test/test_keywordonlyarg.py b/Lib/test/test_keywordonlyarg.py
--- a/Lib/test/test_keywordonlyarg.py
+++ b/Lib/test/test_keywordonlyarg.py
@@ -170,6 +170,12 @@
# used to fail with a SystemError.
lambda *, k1=unittest: None
+ def test_mangling(self):
+ class X:
+ def f(self, *, __a=42):
+ return __a
+ self.assertEqual(X().f(), 42)
+
def test_main():
run_unittest(KeywordOnlyArgTestCase)
diff --git a/Misc/NEWS b/Misc/NEWS
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -17,6 +17,8 @@
- Issue #14592: Attempting a relative import w/o __package__ or __name__ set in
globals raises a KeyError.
+- Issue #14607: Fix defaults keyword-only arguments which started with ``__``.
+
- Issue #10854: The ImportError raised when an extension module on Windows
fails to import now uses the new path and name attributes from
Issue #1559549.
diff --git a/Python/compile.c b/Python/compile.c
--- a/Python/compile.c
+++ b/Python/compile.c
@@ -1409,7 +1409,11 @@
arg_ty arg = asdl_seq_GET(kwonlyargs, i);
expr_ty default_ = asdl_seq_GET(kw_defaults, i);
if (default_) {
- ADDOP_O(c, LOAD_CONST, arg->arg, consts);
+ PyObject *mangled = _Py_Mangle(c->u->u_private, arg->arg);
+ if (!mangled)
+ return -1;
+ ADDOP_O(c, LOAD_CONST, mangled, consts);
+ Py_DECREF(mangled);
if (!compiler_visit_expr(c, default_)) {
return -1;
}
--
Repository URL: http://hg.python.org/cpython
More information about the Python-checkins
mailing list