diff options
| author | Yury Selivanov <yury@magic.io> | 2016-12-13 19:03:51 -0500 |
|---|---|---|
| committer | Yury Selivanov <yury@magic.io> | 2016-12-13 19:03:51 -0500 |
| commit | f2392133eba777f05947a8996c507690b95379c3 (patch) | |
| tree | 3d3e352b04691dabeab1eb8502c2417d2af04826 /Lib | |
| parent | e6bb53bf61ac24feca775bdaa651433b8466d2fa (diff) | |
| download | cpython-git-f2392133eba777f05947a8996c507690b95379c3.tar.gz | |
Issue #26110: Add LOAD_METHOD/CALL_METHOD opcodes.
Special thanks to INADA Naoki for pushing the patch through
the last mile, Serhiy Storchaka for reviewing the code, and to
Victor Stinner for suggesting the idea (originally implemented
in the PyPy project).
Diffstat (limited to 'Lib')
| -rw-r--r-- | Lib/importlib/_bootstrap_external.py | 3 | ||||
| -rw-r--r-- | Lib/opcode.py | 3 | ||||
| -rw-r--r-- | Lib/test/test_syntax.py | 27 |
3 files changed, 32 insertions, 1 deletions
diff --git a/Lib/importlib/_bootstrap_external.py b/Lib/importlib/_bootstrap_external.py index 9feec50842..ec528b2f0d 100644 --- a/Lib/importlib/_bootstrap_external.py +++ b/Lib/importlib/_bootstrap_external.py @@ -240,6 +240,7 @@ _code_type = type(_write_atomic.__code__) # Python 3.6b1 3377 (set __class__ cell from type.__new__ #23722) # Python 3.6b2 3378 (add BUILD_TUPLE_UNPACK_WITH_CALL #28257) # Python 3.6rc1 3379 (more thorough __class__ validation #23722) +# Python 3.7a0 3390 (add LOAD_METHOD and CALL_METHOD opcodes) # # MAGIC must change whenever the bytecode emitted by the compiler may no # longer be understood by older implementations of the eval loop (usually @@ -248,7 +249,7 @@ _code_type = type(_write_atomic.__code__) # Whenever MAGIC_NUMBER is changed, the ranges in the magic_values array # in PC/launcher.c must also be updated. -MAGIC_NUMBER = (3379).to_bytes(2, 'little') + b'\r\n' +MAGIC_NUMBER = (3390).to_bytes(2, 'little') + b'\r\n' _RAW_MAGIC_NUMBER = int.from_bytes(MAGIC_NUMBER, 'little') # For import.c _PYCACHE = '__pycache__' diff --git a/Lib/opcode.py b/Lib/opcode.py index b5916b6619..dffb38c314 100644 --- a/Lib/opcode.py +++ b/Lib/opcode.py @@ -212,4 +212,7 @@ def_op('BUILD_CONST_KEY_MAP', 156) def_op('BUILD_STRING', 157) def_op('BUILD_TUPLE_UNPACK_WITH_CALL', 158) +name_op('LOAD_METHOD', 160) +def_op('CALL_METHOD', 161) + del def_op, name_op, jrel_op, jabs_op diff --git a/Lib/test/test_syntax.py b/Lib/test/test_syntax.py index dd740b4984..5d398e6688 100644 --- a/Lib/test/test_syntax.py +++ b/Lib/test/test_syntax.py @@ -207,6 +207,33 @@ SyntaxError: Generator expression must be parenthesized if not sole argument ... # doctest: +ELLIPSIS () [('a000', 0), ('a001', 1), ('a002', 2), ..., ('a298', 298), ('a299', 299)] +>>> class C: +... def meth(self, *args): +... return args +>>> obj = C() +>>> obj.meth( +... 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, +... 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, +... 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, +... 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, +... 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, +... 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, +... 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, +... 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, 135, +... 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149, +... 150, 151, 152, 153, 154, 155, 156, 157, 158, 159, 160, 161, 162, 163, +... 164, 165, 166, 167, 168, 169, 170, 171, 172, 173, 174, 175, 176, 177, +... 178, 179, 180, 181, 182, 183, 184, 185, 186, 187, 188, 189, 190, 191, +... 192, 193, 194, 195, 196, 197, 198, 199, 200, 201, 202, 203, 204, 205, +... 206, 207, 208, 209, 210, 211, 212, 213, 214, 215, 216, 217, 218, 219, +... 220, 221, 222, 223, 224, 225, 226, 227, 228, 229, 230, 231, 232, 233, +... 234, 235, 236, 237, 238, 239, 240, 241, 242, 243, 244, 245, 246, 247, +... 248, 249, 250, 251, 252, 253, 254, 255, 256, 257, 258, 259, 260, 261, +... 262, 263, 264, 265, 266, 267, 268, 269, 270, 271, 272, 273, 274, 275, +... 276, 277, 278, 279, 280, 281, 282, 283, 284, 285, 286, 287, 288, 289, +... 290, 291, 292, 293, 294, 295, 296, 297, 298, 299) # doctest: +ELLIPSIS +(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, ..., 297, 298, 299) + >>> f(lambda x: x[0] = 3) Traceback (most recent call last): SyntaxError: lambda cannot contain assignment |
