evaluate lambda keyword-only defaults after positional defaults (#16967 again)
This commit is contained in:
parent
8b466c9932
commit
419d9a83d5
|
@ -396,7 +396,7 @@ Known values:
|
||||||
3210 (added size modulo 2**32 to the pyc header)
|
3210 (added size modulo 2**32 to the pyc header)
|
||||||
Python 3.3a1 3220 (changed PEP 380 implementation)
|
Python 3.3a1 3220 (changed PEP 380 implementation)
|
||||||
Python 3.3a4 3230 (revert changes to implicit __class__ closure)
|
Python 3.3a4 3230 (revert changes to implicit __class__ closure)
|
||||||
Python 3.4a1 3240 (evaluate positional default arguments before
|
Python 3.4a1 3250 (evaluate positional default arguments before
|
||||||
keyword-only defaults)
|
keyword-only defaults)
|
||||||
|
|
||||||
MAGIC must change whenever the bytecode emitted by the compiler may no
|
MAGIC must change whenever the bytecode emitted by the compiler may no
|
||||||
|
@ -404,7 +404,7 @@ longer be understood by older implementations of the eval loop (usually
|
||||||
due to the addition of new opcodes).
|
due to the addition of new opcodes).
|
||||||
|
|
||||||
"""
|
"""
|
||||||
_RAW_MAGIC_NUMBER = 3240 | ord('\r') << 16 | ord('\n') << 24
|
_RAW_MAGIC_NUMBER = 3250 | ord('\r') << 16 | ord('\n') << 24
|
||||||
_MAGIC_BYTES = bytes(_RAW_MAGIC_NUMBER >> n & 0xff for n in range(0, 25, 8))
|
_MAGIC_BYTES = bytes(_RAW_MAGIC_NUMBER >> n & 0xff for n in range(0, 25, 8))
|
||||||
|
|
||||||
_PYCACHE = '__pycache__'
|
_PYCACHE = '__pycache__'
|
||||||
|
|
|
@ -183,6 +183,10 @@ class KeywordOnlyArgTestCase(unittest.TestCase):
|
||||||
def f(v=a, x=b, *, y=c, z=d):
|
def f(v=a, x=b, *, y=c, z=d):
|
||||||
pass
|
pass
|
||||||
self.assertEqual(str(err.exception), "global name 'b' is not defined")
|
self.assertEqual(str(err.exception), "global name 'b' is not defined")
|
||||||
|
with self.assertRaises(NameError) as err:
|
||||||
|
f = lambda v=a, x=b, *, y=c, z=d: None
|
||||||
|
self.assertEqual(str(err.exception), "global name 'b' is not defined")
|
||||||
|
|
||||||
|
|
||||||
def test_main():
|
def test_main():
|
||||||
run_unittest(KeywordOnlyArgTestCase)
|
run_unittest(KeywordOnlyArgTestCase)
|
||||||
|
|
|
@ -1794,14 +1794,14 @@ compiler_lambda(struct compiler *c, expr_ty e)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (args->defaults)
|
||||||
|
VISIT_SEQ(c, expr, args->defaults);
|
||||||
if (args->kwonlyargs) {
|
if (args->kwonlyargs) {
|
||||||
int res = compiler_visit_kwonlydefaults(c, args->kwonlyargs,
|
int res = compiler_visit_kwonlydefaults(c, args->kwonlyargs,
|
||||||
args->kw_defaults);
|
args->kw_defaults);
|
||||||
if (res < 0) return 0;
|
if (res < 0) return 0;
|
||||||
kw_default_count = res;
|
kw_default_count = res;
|
||||||
}
|
}
|
||||||
if (args->defaults)
|
|
||||||
VISIT_SEQ(c, expr, args->defaults);
|
|
||||||
if (!compiler_enter_scope(c, name, COMPILER_SCOPE_FUNCTION,
|
if (!compiler_enter_scope(c, name, COMPILER_SCOPE_FUNCTION,
|
||||||
(void *)e, e->lineno))
|
(void *)e, e->lineno))
|
||||||
return 0;
|
return 0;
|
||||||
|
|
|
@ -756,7 +756,7 @@ unsigned char _Py_M__importlib[] = {
|
||||||
114,101,109,111,118,101,100,49,1,0,0,115,2,0,0,0,
|
114,101,109,111,118,101,100,49,1,0,0,115,2,0,0,0,
|
||||||
0,8,117,25,0,0,0,95,99,97,108,108,95,119,105,116,
|
0,8,117,25,0,0,0,95,99,97,108,108,95,119,105,116,
|
||||||
104,95,102,114,97,109,101,115,95,114,101,109,111,118,101,100,
|
104,95,102,114,97,109,101,115,95,114,101,109,111,118,101,100,
|
||||||
105,168,12,0,0,117,1,0,0,0,13,105,16,0,0,0,
|
105,178,12,0,0,117,1,0,0,0,13,105,16,0,0,0,
|
||||||
117,1,0,0,0,10,105,24,0,0,0,99,1,0,0,0,
|
117,1,0,0,0,10,105,24,0,0,0,99,1,0,0,0,
|
||||||
0,0,0,0,2,0,0,0,3,0,0,0,99,0,0,0,
|
0,0,0,0,2,0,0,0,3,0,0,0,99,0,0,0,
|
||||||
115,29,0,0,0,124,0,0,93,19,0,125,1,0,116,0,
|
115,29,0,0,0,124,0,0,93,19,0,125,1,0,116,0,
|
||||||
|
|
Loading…
Reference in New Issue