Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(122454)

Side by Side Diff: Lib/test/test_marshal.py

Issue 23670: Modifications to support iOS as a development platform
Patch Set: Created 3 years, 8 months ago
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « Lib/test/test_mailcap.py ('k') | Lib/test/test_mmap.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 from test import support 1 from test import support
2 import array 2 import array
3 import io 3 import io
4 import marshal 4 import marshal
5 import sys 5 import sys
6 import unittest 6 import unittest
7 import os 7 import os
8 import types 8 import types
9 9
10 try: 10 try:
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after
194 def test_loads_recursion(self): 194 def test_loads_recursion(self):
195 s = b'c' + (b'X' * 4*5) + b'{' * 2**20 195 s = b'c' + (b'X' * 4*5) + b'{' * 2**20
196 self.assertRaises(ValueError, marshal.loads, s) 196 self.assertRaises(ValueError, marshal.loads, s)
197 197
198 def test_recursion_limit(self): 198 def test_recursion_limit(self):
199 # Create a deeply nested structure. 199 # Create a deeply nested structure.
200 head = last = [] 200 head = last = []
201 # The max stack depth should match the value in Python/marshal.c. 201 # The max stack depth should match the value in Python/marshal.c.
202 if os.name == 'nt' and hasattr(sys, 'gettotalrefcount'): 202 if os.name == 'nt' and hasattr(sys, 'gettotalrefcount'):
203 MAX_MARSHAL_STACK_DEPTH = 1000 203 MAX_MARSHAL_STACK_DEPTH = 1000
204 elsf sys.platform == 'ios':
205 MAX_MARSHAL_STACK_DEPTH = 1500
204 else: 206 else:
205 MAX_MARSHAL_STACK_DEPTH = 2000 207 MAX_MARSHAL_STACK_DEPTH = 2000
206 for i in range(MAX_MARSHAL_STACK_DEPTH - 2): 208 for i in range(MAX_MARSHAL_STACK_DEPTH - 2):
207 last.append([0]) 209 last.append([0])
208 last = last[-1] 210 last = last[-1]
209 211
210 # Verify we don't blow out the stack with dumps/load. 212 # Verify we don't blow out the stack with dumps/load.
211 data = marshal.dumps(head) 213 data = marshal.dumps(head)
212 new_head = marshal.loads(data) 214 new_head = marshal.loads(data)
213 # Don't use == to compare objects, it can exceed the recursion limit. 215 # Don't use == to compare objects, it can exceed the recursion limit.
(...skipping 310 matching lines...) Expand 10 before | Expand all | Expand 10 after
524 526
525 with open(support.TESTFN, 'wb') as f: 527 with open(support.TESTFN, 'wb') as f:
526 f.write(data[:1]) 528 f.write(data[:1])
527 with self.assertRaises(EOFError): 529 with self.assertRaises(EOFError):
528 _testcapi.pymarshal_read_object_from_file(support.TESTFN) 530 _testcapi.pymarshal_read_object_from_file(support.TESTFN)
529 support.unlink(support.TESTFN) 531 support.unlink(support.TESTFN)
530 532
531 533
532 if __name__ == "__main__": 534 if __name__ == "__main__":
533 unittest.main() 535 unittest.main()
OLDNEW
« no previous file with comments | « Lib/test/test_mailcap.py ('k') | Lib/test/test_mmap.py » ('j') | no next file with comments »

RSS Feeds Recent Issues | This issue
This is Rietveld 894c83f36cb7+