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

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

Issue 22734: marshal needs a lower stack depth for debug builds on Windows
Patch Set: Created 5 years, 2 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 | « no previous file | Python/marshal.c » ('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 class HelperMixin: 10 class HelperMixin:
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after
181 181
182 def test_loads_recursion(self): 182 def test_loads_recursion(self):
183 s = b'c' + (b'X' * 4*5) + b'{' * 2**20 183 s = b'c' + (b'X' * 4*5) + b'{' * 2**20
184 self.assertRaises(ValueError, marshal.loads, s) 184 self.assertRaises(ValueError, marshal.loads, s)
185 185
186 def test_recursion_limit(self): 186 def test_recursion_limit(self):
187 # Create a deeply nested structure. 187 # Create a deeply nested structure.
188 head = last = [] 188 head = last = []
189 # The max stack depth should match the value in Python/marshal.c. 189 # The max stack depth should match the value in Python/marshal.c.
190 if os.name == 'nt' and hasattr(sys, 'gettotalrefcount'): 190 if os.name == 'nt' and hasattr(sys, 'gettotalrefcount'):
191 MAX_MARSHAL_STACK_DEPTH = 1500 191 MAX_MARSHAL_STACK_DEPTH = 1000
192 else: 192 else:
193 MAX_MARSHAL_STACK_DEPTH = 2000 193 MAX_MARSHAL_STACK_DEPTH = 2000
194 for i in range(MAX_MARSHAL_STACK_DEPTH - 2): 194 for i in range(MAX_MARSHAL_STACK_DEPTH - 2):
195 last.append([0]) 195 last.append([0])
196 last = last[-1] 196 last = last[-1]
197 197
198 # Verify we don't blow out the stack with dumps/load. 198 # Verify we don't blow out the stack with dumps/load.
199 data = marshal.dumps(head) 199 data = marshal.dumps(head)
200 new_head = marshal.loads(data) 200 new_head = marshal.loads(data)
201 # Don't use == to compare objects, it can exceed the recursion limit. 201 # Don't use == to compare objects, it can exceed the recursion limit.
(...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after
442 CodeTestCase, 442 CodeTestCase,
443 ContainerTestCase, 443 ContainerTestCase,
444 ExceptionTestCase, 444 ExceptionTestCase,
445 BufferTestCase, 445 BufferTestCase,
446 BugsTestCase, 446 BugsTestCase,
447 LargeValuesTestCase, 447 LargeValuesTestCase,
448 ) 448 )
449 449
450 if __name__ == "__main__": 450 if __name__ == "__main__":
451 test_main() 451 test_main()
OLDNEW
« no previous file with comments | « no previous file | Python/marshal.c » ('j') | no next file with comments »

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