diff options
author | Dennis Sweeney <36520290+sweeneyde@users.noreply.github.com> | 2022-09-25 19:55:53 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-09-25 19:55:53 (GMT) |
commit | 05c92759b6078fd667ed2275a523893f0685f0b9 (patch) | |
tree | 213d52358e4a94b655a94431654ff9456f76f2cc | |
parent | c8c0afc7137ab9f22bf59d591084948ca967c97c (diff) | |
download | cpython-05c92759b6078fd667ed2275a523893f0685f0b9.zip cpython-05c92759b6078fd667ed2275a523893f0685f0b9.tar.gz cpython-05c92759b6078fd667ed2275a523893f0685f0b9.tar.bz2 |
Reject invalid opcode names in assertInBytecode (GH-97548)
-rw-r--r-- | Lib/test/support/bytecode_helper.py | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/Lib/test/support/bytecode_helper.py b/Lib/test/support/bytecode_helper.py index 05b5491..eb4ae1a 100644 --- a/Lib/test/support/bytecode_helper.py +++ b/Lib/test/support/bytecode_helper.py @@ -17,6 +17,7 @@ class BytecodeTestCase(unittest.TestCase): def assertInBytecode(self, x, opname, argval=_UNSPECIFIED): """Returns instr if opname is found, otherwise throws AssertionError""" + self.assertIn(opname, dis.opmap) for instr in dis.get_instructions(x): if instr.opname == opname: if argval is _UNSPECIFIED or instr.argval == argval: @@ -31,6 +32,7 @@ class BytecodeTestCase(unittest.TestCase): def assertNotInBytecode(self, x, opname, argval=_UNSPECIFIED): """Throws AssertionError if opname is found""" + self.assertIn(opname, dis.opmap) for instr in dis.get_instructions(x): if instr.opname == opname: disassembly = self.get_disassembly_as_string(x) |