|
1 | 1 | # Python test set -- part 5, built-in exceptions
|
2 | 2 |
|
3 | 3 | import copy
|
4 |
| -import ctypes |
5 | 4 | import os
|
6 | 5 | import sys
|
7 | 6 | import unittest
|
|
10 | 9 | import errno
|
11 | 10 | from textwrap import dedent
|
12 | 11 |
|
13 |
| -from _testcapi import INT_MAX |
| 12 | +from _testcapi import INT_MAX, PY_SSIZE_T_MAX |
14 | 13 | from test.support import (captured_stderr, check_impl_detail,
|
15 | 14 | cpython_only, gc_collect,
|
16 | 15 | no_tracing, script_helper,
|
@@ -320,19 +319,15 @@ def baz():
|
320 | 319 | check('(yield i) = 2', 1, 2)
|
321 | 320 | check('def f(*):\n pass', 1, 7)
|
322 | 321 |
|
323 |
| - @unittest.skipIf(ctypes.sizeof(ctypes.c_int) >= ctypes.sizeof(ctypes.c_ssize_t), |
324 |
| - "Downcasting to int is safe for col_offset") |
| 322 | + @unittest.skipIf(INT_MAX >= PY_SSIZE_T_MAX, "Downcasting to int is safe for col_offset") |
325 | 323 | @support.requires_resource('cpu')
|
326 | 324 | @support.bigmemtest(INT_MAX, memuse=2, dry_run=False)
|
327 | 325 | def testMemoryErrorBigSource(self, size):
|
328 | 326 | padding_needed = INT_MAX-len("pass")
|
329 | 327 | if size < padding_needed:
|
330 | 328 | self.skipTest('Not enough memory for overflow to occur')
|
331 | 329 |
|
332 |
| - # Construct buffer to hold just enough characters so that the tokenizer offset overflows. |
333 |
| - # This makes sure that we don't overflow in the string creation itself |
334 | 330 | src = f"if True:\n{' ' * padding_needed}pass"
|
335 |
| - |
336 | 331 | with self.assertRaisesRegex(OverflowError, "Parser column offset overflow"):
|
337 | 332 | compile(src, '<fragment>', 'exec')
|
338 | 333 |
|
|
0 commit comments