|
4 | 4 |
|
5 | 5 | import unittest, string, sys, struct |
6 | 6 | from test import support |
| 7 | +from test.support import import_helper |
7 | 8 | from collections import UserList |
8 | 9 | import random |
9 | 10 |
|
@@ -1328,17 +1329,17 @@ class X(object): pass |
1328 | 1329 |
|
1329 | 1330 | @support.cpython_only |
1330 | 1331 | def test_formatting_c_limits(self): |
1331 | | - from _testcapi import PY_SSIZE_T_MAX, INT_MAX, UINT_MAX |
1332 | | - SIZE_MAX = (1 << (PY_SSIZE_T_MAX.bit_length() + 1)) - 1 |
| 1332 | + _testcapi = import_helper.import_module('_testcapi') |
| 1333 | + SIZE_MAX = (1 << (_testcapi.PY_SSIZE_T_MAX.bit_length() + 1)) - 1 |
1333 | 1334 | self.checkraises(OverflowError, '%*s', '__mod__', |
1334 | | - (PY_SSIZE_T_MAX + 1, '')) |
| 1335 | + (_testcapi.PY_SSIZE_T_MAX + 1, '')) |
1335 | 1336 | self.checkraises(OverflowError, '%.*f', '__mod__', |
1336 | | - (INT_MAX + 1, 1. / 7)) |
| 1337 | + (_testcapi.INT_MAX + 1, 1. / 7)) |
1337 | 1338 | # Issue 15989 |
1338 | 1339 | self.checkraises(OverflowError, '%*s', '__mod__', |
1339 | 1340 | (SIZE_MAX + 1, '')) |
1340 | 1341 | self.checkraises(OverflowError, '%.*f', '__mod__', |
1341 | | - (UINT_MAX + 1, 1. / 7)) |
| 1342 | + (_testcapi.UINT_MAX + 1, 1. / 7)) |
1342 | 1343 |
|
1343 | 1344 | def test_floatformatting(self): |
1344 | 1345 | # float formatting |
|
0 commit comments