mirror of
				https://github.com/python/cpython.git
				synced 2025-11-03 19:34:08 +00:00 
			
		
		
		
	merge 3.2 (#14607)
This commit is contained in:
		
						commit
						2a1fdc4c76
					
				
					 3 changed files with 13 additions and 1 deletions
				
			
		| 
						 | 
				
			
			@ -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)
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -13,6 +13,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.
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -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;
 | 
			
		||||
            }
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue