(self)
| 303 | self.assertRaises(SystemError, asdouble, NULL) |
| 304 | |
| 305 | def test_long_asvoidptr(self): |
| 306 | # Test PyLong_AsVoidPtr() |
| 307 | fromvoidptr = _testlimitedcapi.pylong_fromvoidptr |
| 308 | asvoidptr = _testlimitedcapi.pylong_asvoidptr |
| 309 | obj = object() |
| 310 | x = fromvoidptr(obj) |
| 311 | y = fromvoidptr(NULL) |
| 312 | self.assertIs(asvoidptr(x), obj) |
| 313 | self.assertIs(asvoidptr(y), NULL) |
| 314 | self.assertIs(asvoidptr(IntSubclass(x)), obj) |
| 315 | |
| 316 | # negative values |
| 317 | M = (1 << _testcapi.SIZEOF_VOID_P * 8) |
| 318 | if x >= M//2: |
| 319 | self.assertIs(asvoidptr(x - M), obj) |
| 320 | if y >= M//2: |
| 321 | self.assertIs(asvoidptr(y - M), NULL) |
| 322 | |
| 323 | self.assertRaises(TypeError, asvoidptr, Index(x)) |
| 324 | self.assertRaises(TypeError, asvoidptr, object()) |
| 325 | self.assertRaises(OverflowError, asvoidptr, 2**1000) |
| 326 | self.assertRaises(OverflowError, asvoidptr, -2**1000) |
| 327 | # CRASHES asvoidptr(NULL) |
| 328 | |
| 329 | def _test_long_aspid(self, aspid): |
| 330 | # Test PyLong_AsPid() |
nothing calls this directly
no test coverage detected