Skip to content
This repository was archived by the owner on Jan 23, 2024. It is now read-only.

Commit 67e3b8c

Browse files
mctavishcopybara-github
authored andcommitted
Add support for Python 3.9
Thanks to https://github.com/ermakov-oleg for initiating this contribution. PiperOrigin-RevId: 367461664 Change-Id: Ifd56e622a969ed171395b29516a45175202964d3
1 parent 91a4145 commit 67e3b8c

2 files changed

Lines changed: 31 additions & 4 deletions

File tree

src/googleclouddebugger/bytecode_manipulator.cc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,8 @@ static PythonOpcodeType GetOpcodeType(uint8_t opcode) {
133133
#endif
134134
case SETUP_FINALLY:
135135
case SETUP_WITH:
136-
#if PY_VERSION_HEX >= 0x03080000
136+
#if PY_VERSION_HEX >= 0x03080000 && PY_VERSION_HEX < 0x03090000
137+
// Added in Python 3.8 and removed in 3.9
137138
case CALL_FINALLY:
138139
#endif
139140
return BRANCH_DELTA_OPCODE;

src/googleclouddebugger/immutability_tracer.cc

Lines changed: 29 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -374,15 +374,25 @@ static OpcodeMutableStatus IsOpcodeMutable(const uint8_t opcode) {
374374
case UNPACK_EX:
375375
case CALL_FUNCTION_EX:
376376
case LOAD_CLASSDEREF:
377+
#if PY_VERSION_HEX < 0x03090000
378+
// Removed in Python 3.9.
377379
case BUILD_LIST_UNPACK:
378380
case BUILD_MAP_UNPACK:
379381
case BUILD_MAP_UNPACK_WITH_CALL:
380382
case BUILD_TUPLE_UNPACK:
383+
case BUILD_TUPLE_UNPACK_WITH_CALL:
381384
case BUILD_SET_UNPACK:
385+
#endif
386+
#if PY_VERSION_HEX > 0x03090000
387+
// Added in Python 3.9.
388+
case LIST_TO_TUPLE:
389+
case IS_OP:
390+
case CONTAINS_OP:
391+
case JUMP_IF_NOT_EXC_MATCH:
392+
#endif
382393
case FORMAT_VALUE:
383394
case BUILD_CONST_KEY_MAP:
384395
case BUILD_STRING:
385-
case BUILD_TUPLE_UNPACK_WITH_CALL:
386396
#if PY_VERSION_HEX >= 0x03070000
387397
// Added in Python 3.7.
388398
case LOAD_METHOD:
@@ -433,7 +443,6 @@ static OpcodeMutableStatus IsOpcodeMutable(const uint8_t opcode) {
433443
case STORE_DEREF:
434444
// TODO: allow exception handling
435445
case RAISE_VARARGS:
436-
case END_FINALLY:
437446
case SETUP_WITH:
438447
// TODO: allow closures
439448
case LOAD_CLOSURE:
@@ -447,8 +456,12 @@ static OpcodeMutableStatus IsOpcodeMutable(const uint8_t opcode) {
447456
case BEFORE_ASYNC_WITH:
448457
case LOAD_BUILD_CLASS:
449458
case GET_AWAITABLE:
459+
#if PY_VERSION_HEX < 0x03090000
460+
// Removed in 3.9.
450461
case WITH_CLEANUP_START:
451462
case WITH_CLEANUP_FINISH:
463+
case END_FINALLY:
464+
#endif
452465
case SETUP_ANNOTATIONS:
453466
case POP_EXCEPT:
454467
#if PY_VERSION_HEX < 0x03070000
@@ -459,11 +472,24 @@ static OpcodeMutableStatus IsOpcodeMutable(const uint8_t opcode) {
459472
case SETUP_ASYNC_WITH:
460473
#if PY_VERSION_HEX >= 0x03080000
461474
// Added in Python 3.8.
462-
case BEGIN_FINALLY:
463475
case END_ASYNC_FOR:
476+
#endif
477+
#if PY_VERSION_HEX >= 0x03080000 && PY_VERSION_HEX < 0x03090000
478+
// Added in Python 3.8 and removed in 3.9
479+
case BEGIN_FINALLY:
464480
case CALL_FINALLY:
465481
case POP_FINALLY:
466482
#endif
483+
#if PY_VERSION_HEX >= 0x03090000
484+
// Added in 3.9.
485+
case DICT_MERGE:
486+
case DICT_UPDATE:
487+
case LIST_EXTEND:
488+
case SET_UPDATE:
489+
case RERAISE:
490+
case WITH_EXCEPT_START:
491+
case LOAD_ASSERTION_ERROR:
492+
#endif
467493
#else
468494
case STORE_SLICE+0:
469495
case STORE_SLICE+1:

0 commit comments

Comments
 (0)