diff options
author | Brett Cannon <brett@python.org> | 2012-04-18 01:42:07 (GMT) |
---|---|---|
committer | Brett Cannon <brett@python.org> | 2012-04-18 01:42:07 (GMT) |
commit | 03c7ed15803def1eedec65522e6185fc5a1badf9 (patch) | |
tree | 5ef2c8718623b40b56bf8a941b8e858940965586 | |
parent | 7bd329d800b29e195a55b16093ef74c22e20476d (diff) | |
parent | 2a1fdc4c760bf862accf625558e9bf54b9b9cd7c (diff) | |
download | cpython-03c7ed15803def1eedec65522e6185fc5a1badf9.zip cpython-03c7ed15803def1eedec65522e6185fc5a1badf9.tar.gz cpython-03c7ed15803def1eedec65522e6185fc5a1badf9.tar.bz2 |
Merge
-rw-r--r-- | Lib/test/test_keywordonlyarg.py | 6 | ||||
-rw-r--r-- | Misc/NEWS | 2 | ||||
-rw-r--r-- | 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 index 61d40f9..0503a7f 100644 --- a/Lib/test/test_keywordonlyarg.py +++ b/Lib/test/test_keywordonlyarg.py @@ -170,6 +170,12 @@ class KeywordOnlyArgTestCase(unittest.TestCase): # 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) @@ -17,6 +17,8 @@ Core and Builtins - 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 index 1722a5f..79d1d21 100644 --- a/Python/compile.c +++ b/Python/compile.c @@ -1409,7 +1409,11 @@ compiler_visit_kwonlydefaults(struct compiler *c, asdl_seq *kwonlyargs, 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; } |