Backport METH_FASTCALL from Python 3.7 (#328)

This commit is contained in:
Gautham 2022-05-12 14:57:16 +05:30 committed by GitHub
parent 70c97f598b
commit cf73bbd678
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
102 changed files with 2896 additions and 3301 deletions

View file

@ -5,6 +5,7 @@ from test.bytecode_helper import BytecodeTestCase
import difflib
import unittest
import sys
import cosmo
import dis
import io
import re
@ -344,10 +345,15 @@ class DisTests(unittest.TestCase):
return re.sub(r'\b0x[0-9A-Fa-f]+\b', '0x...', text)
def do_disassembly_test(self, func, expected):
t = self.maxDiff
self.maxDiff = None # to get full disassembly
got = self.get_disassembly(func)
if got != expected:
got = self.strip_addresses(got)
# filename issue because within zip store?
expected = expected.replace(".pyc", ".py")
self.assertEqual(got, expected)
self.maxDiff = t
def test_opmap(self):
self.assertEqual(dis.opmap["NOP"], 9)
@ -614,11 +620,13 @@ class CodeInfoTests(unittest.TestCase):
(async_def, code_info_async_def)
]
@unittest.skipIf("tiny" in cosmo.MODE, "docstrings not present")
def test_code_info(self):
self.maxDiff = 1000
for x, expected in self.test_pairs:
self.assertRegex(dis.code_info(x), expected)
@unittest.skipIf("tiny" in cosmo.MODE, "docstrings not present")
def test_show_code(self):
self.maxDiff = 1000
for x, expected in self.test_pairs:
@ -934,6 +942,7 @@ class BytecodeTests(unittest.TestCase):
actual = dis.Bytecode(simple, first_line=350).dis()[:3]
self.assertEqual(actual, "350")
@unittest.skipIf("tiny" in cosmo.MODE, "docstrings not present")
def test_info(self):
self.maxDiff = 1000
for x, expected in CodeInfoTests.test_pairs: