| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -125,6 +125,7 @@ extern "C" { | |||
| 125 | 125 | #define FORMAT_VALUE 155 | |
| 126 | 126 | #define BUILD_CONST_KEY_MAP 156 | |
| 127 | 127 | #define BUILD_STRING 157 | |
| 128 | + #define BUILD_TUPLE_UNPACK_WITH_CALL 158 | ||
| 128 | 129 | ||
| 129 | 130 | /* EXCEPT_HANDLER is a special, implicit block type which is created when | |
| 130 | 131 | entering an except handler. It is not an opcode but we define it here | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -238,6 +238,7 @@ def _write_atomic(path, data, mode=0o666): | |||
| 238 | 238 | # #27985) | |
| 239 | 239 | # Python 3.6b1 3376 (simplify CALL_FUNCTIONs & BUILD_MAP_UNPACK_WITH_CALL) | |
| 240 | 240 | # Python 3.6b1 3377 (set __class__ cell from type.__new__ #23722) | |
| 241 | + # Python 3.6b2 3378 (add BUILD_TUPLE_UNPACK_WITH_CALL #28257) | ||
| 241 | 242 | # | |
| 242 | 243 | # MAGIC must change whenever the bytecode emitted by the compiler may no | |
| 243 | 244 | # longer be understood by older implementations of the eval loop (usually | |
@@ -246,7 +247,7 @@ def _write_atomic(path, data, mode=0o666): | |||
| 246 | 247 | # Whenever MAGIC_NUMBER is changed, the ranges in the magic_values array | |
| 247 | 248 | # in PC/launcher.c must also be updated. | |
| 248 | 249 | ||
| 249 | - MAGIC_NUMBER = (3377).to_bytes(2, 'little') + b'\r\n' | ||
| 250 | + MAGIC_NUMBER = (3378).to_bytes(2, 'little') + b'\r\n' | ||
| 250 | 251 | _RAW_MAGIC_NUMBER = int.from_bytes(MAGIC_NUMBER, 'little') # For import.c | |
| 251 | 252 | ||
| 252 | 253 | _PYCACHE = '__pycache__' | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -196,8 +196,6 @@ def jabs_op(name, op): | |||
| 196 | 196 | def_op('LOAD_CLASSDEREF', 148) | |
| 197 | 197 | hasfree.append(148) | |
| 198 | 198 | ||
| 199 | - jrel_op('SETUP_ASYNC_WITH', 154) | ||
| 200 | - | ||
| 201 | 199 | def_op('EXTENDED_ARG', 144) | |
| 202 | 200 | EXTENDED_ARG = 144 | |
| 203 | 201 | ||
@@ -207,8 +205,11 @@ def jabs_op(name, op): | |||
| 207 | 205 | def_op('BUILD_TUPLE_UNPACK', 152) | |
| 208 | 206 | def_op('BUILD_SET_UNPACK', 153) | |
| 209 | 207 | ||
| 208 | + jrel_op('SETUP_ASYNC_WITH', 154) | ||
| 209 | + | ||
| 210 | 210 | def_op('FORMAT_VALUE', 155) | |
| 211 | 211 | def_op('BUILD_CONST_KEY_MAP', 156) | |
| 212 | 212 | def_op('BUILD_STRING', 157) | |
| 213 | + def_op('BUILD_TUPLE_UNPACK_WITH_CALL', 158) | ||
| 213 | 214 | ||
| 214 | 215 | del def_op, name_op, jrel_op, jabs_op | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -233,6 +233,16 @@ | |||
| 233 | 233 | ... | |
| 234 | 234 | TypeError: h() argument after * must be an iterable, not function | |
| 235 | 235 | ||
| 236 | + >>> h(1, *h) | ||
| 237 | + Traceback (most recent call last): | ||
| 238 | + ... | ||
| 239 | + TypeError: h() argument after * must be an iterable, not function | ||
| 240 | + | ||
| 241 | + >>> h(*[1], *h) | ||
| 242 | + Traceback (most recent call last): | ||
| 243 | + ... | ||
| 244 | + TypeError: h() argument after * must be an iterable, not function | ||
| 245 | + | ||
| 236 | 246 | >>> dir(*h) | |
| 237 | 247 | Traceback (most recent call last): | |
| 238 | 248 | ... | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -46,6 +46,9 @@ Core and Builtins | |||
| 46 | 46 | Library | |
| 47 | 47 | ------- | |
| 48 | 48 | ||
| 49 | + - Issue #28257: Improved error message when pass a non-iterable as | ||
| 50 | + a var-positional argument. Added opcode BUILD_TUPLE_UNPACK_WITH_CALL. | ||
| 51 | + | ||
| 49 | 52 | - Issue #28322: Fixed possible crashes when unpickle itertools objects from | |
| 50 | 53 | incorrect pickle data. Based on patch by John Leitch. | |
| 51 | 54 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -2509,9 +2509,10 @@ _PyEval_EvalFrameDefault(PyFrameObject *f, int throwflag) | |||
| 2509 | 2509 | DISPATCH(); | |
| 2510 | 2510 | } | |
| 2511 | 2511 | ||
| 2512 | + TARGET(BUILD_TUPLE_UNPACK_WITH_CALL) | ||
| 2512 | 2513 | TARGET(BUILD_TUPLE_UNPACK) | |
| 2513 | 2514 | TARGET(BUILD_LIST_UNPACK) { | |
| 2514 | - int convert_to_tuple = opcode == BUILD_TUPLE_UNPACK; | ||
| 2515 | + int convert_to_tuple = opcode != BUILD_LIST_UNPACK; | ||
| 2515 | 2516 | Py_ssize_t i; | |
| 2516 | 2517 | PyObject *sum = PyList_New(0); | |
| 2517 | 2518 | PyObject *return_value; | |
@@ -2524,6 +2525,16 @@ _PyEval_EvalFrameDefault(PyFrameObject *f, int throwflag) | |||
| 2524 | 2525 | ||
| 2525 | 2526 | none_val = _PyList_Extend((PyListObject *)sum, PEEK(i)); | |
| 2526 | 2527 | if (none_val == NULL) { | |
| 2528 | + if (opcode == BUILD_TUPLE_UNPACK_WITH_CALL && | ||
| 2529 | + PyErr_ExceptionMatches(PyExc_TypeError)) { | ||
| 2530 | + PyObject *func = PEEK(1 + oparg); | ||
| 2531 | + PyErr_Format(PyExc_TypeError, | ||
| 2532 | + "%.200s%.200s argument after * " | ||
| 2533 | + "must be an iterable, not %.200s", | ||
| 2534 | + PyEval_GetFuncName(func), | ||
| 2535 | + PyEval_GetFuncDesc(func), | ||
| 2536 | + PEEK(i)->ob_type->tp_name); | ||
| 2537 | + } | ||
| 2527 | 2538 | Py_DECREF(sum); | |
| 2528 | 2539 | goto error; | |
| 2529 | 2540 | } | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -987,9 +987,9 @@ PyCompile_OpcodeStackEffect(int opcode, int oparg) | |||
| 987 | 987 | return 1-oparg; | |
| 988 | 988 | case BUILD_LIST_UNPACK: | |
| 989 | 989 | case BUILD_TUPLE_UNPACK: | |
| 990 | + case BUILD_TUPLE_UNPACK_WITH_CALL: | ||
| 990 | 991 | case BUILD_SET_UNPACK: | |
| 991 | 992 | case BUILD_MAP_UNPACK: | |
| 992 | - return 1 - oparg; | ||
| 993 | 993 | case BUILD_MAP_UNPACK_WITH_CALL: | |
| 994 | 994 | return 1 - oparg; | |
| 995 | 995 | case BUILD_MAP: | |
@@ -3549,7 +3549,7 @@ compiler_call_helper(struct compiler *c, | |||
| 3549 | 3549 | if (nsubargs > 1) { | |
| 3550 | 3550 | /* If we ended up with more than one stararg, we need | |
| 3551 | 3551 | to concatenate them into a single sequence. */ | |
| 3552 | - ADDOP_I(c, BUILD_TUPLE_UNPACK, nsubargs); | ||
| 3552 | + ADDOP_I(c, BUILD_TUPLE_UNPACK_WITH_CALL, nsubargs); | ||
| 3553 | 3553 | } | |
| 3554 | 3554 | else if (nsubargs == 0) { | |
| 3555 | 3555 | ADDOP_I(c, BUILD_TUPLE, 0); | |
| Back | FazBrowse Home | New Git URL |
0 commit comments