mirror of
https://github.com/python/cpython.git
synced 2025-08-03 16:39:00 +00:00
gh-122188: Move magic number to its own file (#122243)
* gh-122188: Move magic number to its own file * Add versionadded directive * Do work in C * Integrate launcher.c * Make _pyc_magic_number private * Remove metadata * Move sys.implementation -> _imp * Modernize comment * Move _RAW_MAGIC_NUMBER to the C side as well * _pyc_magic_number -> pyc_magic_number * Remove unused import * Update docs * Apply suggestions from code review Co-authored-by: Eric Snow <ericsnowcurrently@gmail.com> * Fix typo in tests --------- Co-authored-by: Eric Snow <ericsnowcurrently@gmail.com>
This commit is contained in:
parent
2b163aa9e7
commit
af0a00f022
7 changed files with 307 additions and 295 deletions
|
@ -3113,6 +3113,15 @@ class CAPITests(unittest.TestCase):
|
|||
self.assertIs(mod, sys.modules[name])
|
||||
|
||||
|
||||
@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)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
# Test needs to be a package, so we can do relative imports.
|
||||
unittest.main()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue