mirror of
https://github.com/python/cpython.git
synced 2025-08-04 17:08:35 +00:00
gh-122188: Remove _imp.pyc_magic_number (GH-122503)
_imp.pyc_magic_number_token should be enough.
This commit is contained in:
parent
d57f8a9f76
commit
03b88522f5
3 changed files with 8 additions and 10 deletions
|
@ -3116,10 +3116,12 @@ class CAPITests(unittest.TestCase):
|
|||
@cpython_only
|
||||
class TestMagicNumber(unittest.TestCase):
|
||||
def test_magic_number_endianness(self):
|
||||
magic_number = (_imp.pyc_magic_number).to_bytes(2, 'little') + b'\r\n'
|
||||
raw_magic_number = int.from_bytes(magic_number, 'little')
|
||||
|
||||
self.assertEqual(raw_magic_number, _imp.pyc_magic_number_token)
|
||||
magic_number_bytes = _imp.pyc_magic_number_token.to_bytes(4, 'little')
|
||||
self.assertEqual(magic_number_bytes[2:], b'\r\n')
|
||||
# Starting with Python 3.11, Python 3.n starts with magic number 2900+50n.
|
||||
magic_number = int.from_bytes(magic_number_bytes[:2], 'little')
|
||||
start = 2900 + sys.version_info.minor * 50
|
||||
self.assertIn(magic_number, range(start, start + 50))
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue