gh-126992: Change pickle code to base 10 for load_long and load_int (GH-127042)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
This commit is contained in:
Justin Applegate 2024-12-11 05:37:59 -07:00 committed by GitHub
parent d5d84c3f13
commit ce76b547f9
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 64 additions and 9 deletions

View file

@ -443,6 +443,43 @@ highest protocol among opcodes = 0
highest protocol among opcodes = 0
''')
def test_constants(self):
self.check_dis(b"(NI00\nI01\n\x89\x88t.", '''\
0: ( MARK
1: N NONE
2: I INT False
6: I INT True
10: \\x89 NEWFALSE
11: \\x88 NEWTRUE
12: t TUPLE (MARK at 0)
13: . STOP
highest protocol among opcodes = 2
''')
def test_integers(self):
self.check_dis(b"(I0\nI1\nI10\nI011\nL12\nL13L\nL014\nL015L\nt.", '''\
0: ( MARK
1: I INT 0
4: I INT 1
7: I INT 10
11: I INT 11
16: L LONG 12
20: L LONG 13
25: L LONG 14
30: L LONG 15
36: t TUPLE (MARK at 0)
37: . STOP
highest protocol among opcodes = 0
''')
def test_nondecimal_integers(self):
self.check_dis_error(b'I0b10\n.', '', 'invalid literal for int')
self.check_dis_error(b'I0o10\n.', '', 'invalid literal for int')
self.check_dis_error(b'I0x10\n.', '', 'invalid literal for int')
self.check_dis_error(b'L0b10L\n.', '', 'invalid literal for int')
self.check_dis_error(b'L0o10L\n.', '', 'invalid literal for int')
self.check_dis_error(b'L0x10L\n.', '', 'invalid literal for int')
class MiscTestCase(unittest.TestCase):
def test__all__(self):