| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 7e81460 commit 1503249
19 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -241,9 +241,11 @@ the Python object to the required type. | |||
| 241 | 241 | ||
| 242 | 242 | For signed integer formats, :exc:`OverflowError` is raised if the value | |
| 243 | 243 | is out of range for the C type. | |
| 244 | - For unsigned integer formats, no range checking is done --- the | ||
| 244 | + For unsigned integer formats, the | ||
| 245 | 245 | most significant bits are silently truncated when the receiving field is too | |
| 246 | - small to receive the value. | ||
| 246 | + small to receive the value, and :exc:`DeprecationWarning` is emitted when | ||
| 247 | + the value is larger than the maximal value for the C type or less than | ||
| 248 | + the minimal value for the corresponding signed integer type of the same size. | ||
| 247 | 249 | ||
| 248 | 250 | ``b`` (:class:`int`) [unsigned char] | |
| 249 | 251 | Convert a nonnegative Python integer to an unsigned tiny integer, stored in a C | |
@@ -252,27 +254,25 @@ small to receive the value. | |||
| 252 | 254 | ``B`` (:class:`int`) [unsigned char] | |
| 253 | 255 | Convert a Python integer to a tiny integer without overflow checking, stored in a C | |
| 254 | 256 | :c:expr:`unsigned char`. | |
| 257 | + Convert a Python integer to a C :c:expr:`unsigned char`. | ||
| 255 | 258 | ||
| 256 | 259 | ``h`` (:class:`int`) [short int] | |
| 257 | 260 | Convert a Python integer to a C :c:expr:`short int`. | |
| 258 | 261 | ||
| 259 | 262 | ``H`` (:class:`int`) [unsigned short int] | |
| 260 | - Convert a Python integer to a C :c:expr:`unsigned short int`, without overflow | ||
| 261 | - checking. | ||
| 263 | + Convert a Python integer to a C :c:expr:`unsigned short int`. | ||
| 262 | 264 | ||
| 263 | 265 | ``i`` (:class:`int`) [int] | |
| 264 | 266 | Convert a Python integer to a plain C :c:expr:`int`. | |
| 265 | 267 | ||
| 266 | 268 | ``I`` (:class:`int`) [unsigned int] | |
| 267 | - Convert a Python integer to a C :c:expr:`unsigned int`, without overflow | ||
| 268 | - checking. | ||
| 269 | + Convert a Python integer to a C :c:expr:`unsigned int`. | ||
| 269 | 270 | ||
| 270 | 271 | ``l`` (:class:`int`) [long int] | |
| 271 | 272 | Convert a Python integer to a C :c:expr:`long int`. | |
| 272 | 273 | ||
| 273 | 274 | ``k`` (:class:`int`) [unsigned long] | |
| 274 | - Convert a Python integer to a C :c:expr:`unsigned long` without | ||
| 275 | - overflow checking. | ||
| 275 | + Convert a Python integer to a C :c:expr:`unsigned long`. | ||
| 276 | 276 | ||
| 277 | 277 | .. versionchanged:: 3.14 | |
| 278 | 278 | Use :meth:`~object.__index__` if available. | |
@@ -281,8 +281,7 @@ small to receive the value. | |||
| 281 | 281 | Convert a Python integer to a C :c:expr:`long long`. | |
| 282 | 282 | ||
| 283 | 283 | ``K`` (:class:`int`) [unsigned long long] | |
| 284 | - Convert a Python integer to a C :c:expr:`unsigned long long` | ||
| 285 | - without overflow checking. | ||
| 284 | + Convert a Python integer to a C :c:expr:`unsigned long long`. | ||
| 286 | 285 | ||
| 287 | 286 | .. versionchanged:: 3.14 | |
| 288 | 287 | Use :meth:`~object.__index__` if available. | |
@@ -310,6 +309,14 @@ small to receive the value. | |||
| 310 | 309 | ``D`` (:class:`complex`) [Py_complex] | |
| 311 | 310 | Convert a Python complex number to a C :c:type:`Py_complex` structure. | |
| 312 | 311 | ||
| 312 | + .. deprecated:: next | ||
| 313 | + | ||
| 314 | + For unsigned integer formats ``B``, ``H``, ``I``, ``k`` and ``K``, | ||
| 315 | + :exc:`DeprecationWarning` is emitted when the value is larger than | ||
| 316 | + the maximal value for the C type or less than the minimal value for | ||
| 317 | + the corresponding signed integer type of the same size. | ||
| 318 | + | ||
| 319 | + | ||
| 313 | 320 | Other objects | |
| 314 | 321 | ------------- | |
| 315 | 322 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -462,7 +462,11 @@ Porting to Python 3.15 | |||
| 462 | 462 | Deprecated C APIs | |
| 463 | 463 | ----------------- | |
| 464 | 464 | ||
| 465 | - * TODO | ||
| 465 | + * For unsigned integer formats in :c:func:`PyArg_ParseTuple`, | ||
| 466 | + accepting Python integers with value that is larger than the maximal value | ||
| 467 | + for the C type or less than the minimal value for the corresponding | ||
| 468 | + signed integer type of the same size is now deprecated. | ||
| 469 | + (Contributed by Serhiy Storchaka in :gh:`132629`.) | ||
| 466 | 470 | ||
| 467 | 471 | .. Add C API deprecations above alphabetically, not here at the end. | |
| 468 | 472 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1020,12 +1020,19 @@ test_unsigned_char_converter(PyObject *module, PyObject *const *args, Py_ssize_t | |||
| 1020 | 1020 | goto skip_optional; | |
| 1021 | 1021 | } | |
| 1022 | 1022 | { | |
| 1023 | - unsigned long ival = PyLong_AsUnsignedLongMask(args[2]); | ||
| 1024 | - if (ival == (unsigned long)-1 && PyErr_Occurred()) { | ||
| 1023 | + Py_ssize_t _bytes = PyLong_AsNativeBytes(args[2], &c, sizeof(unsigned char), | ||
| 1024 | + Py_ASNATIVEBYTES_NATIVE_ENDIAN | | ||
| 1025 | + Py_ASNATIVEBYTES_ALLOW_INDEX | | ||
| 1026 | + Py_ASNATIVEBYTES_UNSIGNED_BUFFER); | ||
| 1027 | + if (_bytes < 0) { | ||
| 1025 | 1028 | goto exit; | |
| 1026 | 1029 | } | |
| 1027 | - else { | ||
| 1028 | - c = (unsigned char) ival; | ||
| 1030 | + if ((size_t)_bytes > sizeof(unsigned char)) { | ||
| 1031 | + if (PyErr_WarnEx(PyExc_DeprecationWarning, | ||
| 1032 | + "integer value out of range", 1) < 0) | ||
| 1033 | + { | ||
| 1034 | + goto exit; | ||
| 1035 | + } | ||
| 1029 | 1036 | } | |
| 1030 | 1037 | } | |
| 1031 | 1038 | skip_optional: | |
@@ -1038,7 +1045,7 @@ test_unsigned_char_converter(PyObject *module, PyObject *const *args, Py_ssize_t | |||
| 1038 | 1045 | static PyObject * | |
| 1039 | 1046 | test_unsigned_char_converter_impl(PyObject *module, unsigned char a, | |
| 1040 | 1047 | unsigned char b, unsigned char c) | |
| 1041 | - /*[clinic end generated code: output=45920dbedc22eb55 input=021414060993e289]*/ | ||
| 1048 | + /*[clinic end generated code: output=49eda9faaf53372a input=021414060993e289]*/ | ||
| 1042 | 1049 | ||
| 1043 | 1050 | ||
| 1044 | 1051 | /*[clinic input] | |
@@ -1151,9 +1158,21 @@ test_unsigned_short_converter(PyObject *module, PyObject *const *args, Py_ssize_ | |||
| 1151 | 1158 | if (nargs < 3) { | |
| 1152 | 1159 | goto skip_optional; | |
| 1153 | 1160 | } | |
| 1154 | - c = (unsigned short)PyLong_AsUnsignedLongMask(args[2]); | ||
| 1155 | - if (c == (unsigned short)-1 && PyErr_Occurred()) { | ||
| 1156 | - goto exit; | ||
| 1161 | + { | ||
| 1162 | + Py_ssize_t _bytes = PyLong_AsNativeBytes(args[2], &c, sizeof(unsigned short), | ||
| 1163 | + Py_ASNATIVEBYTES_NATIVE_ENDIAN | | ||
| 1164 | + Py_ASNATIVEBYTES_ALLOW_INDEX | | ||
| 1165 | + Py_ASNATIVEBYTES_UNSIGNED_BUFFER); | ||
| 1166 | + if (_bytes < 0) { | ||
| 1167 | + goto exit; | ||
| 1168 | + } | ||
| 1169 | + if ((size_t)_bytes > sizeof(unsigned short)) { | ||
| 1170 | + if (PyErr_WarnEx(PyExc_DeprecationWarning, | ||
| 1171 | + "integer value out of range", 1) < 0) | ||
| 1172 | + { | ||
| 1173 | + goto exit; | ||
| 1174 | + } | ||
| 1175 | + } | ||
| 1157 | 1176 | } | |
| 1158 | 1177 | skip_optional: | |
| 1159 | 1178 | return_value = test_unsigned_short_converter_impl(module, a, b, c); | |
@@ -1165,7 +1184,7 @@ test_unsigned_short_converter(PyObject *module, PyObject *const *args, Py_ssize_ | |||
| 1165 | 1184 | static PyObject * | |
| 1166 | 1185 | test_unsigned_short_converter_impl(PyObject *module, unsigned short a, | |
| 1167 | 1186 | unsigned short b, unsigned short c) | |
| 1168 | - /*[clinic end generated code: output=e6e990df729114fc input=cdfd8eff3d9176b4]*/ | ||
| 1187 | + /*[clinic end generated code: output=f591c7797e150f49 input=cdfd8eff3d9176b4]*/ | ||
| 1169 | 1188 | ||
| 1170 | 1189 | ||
| 1171 | 1190 | /*[clinic input] | |
@@ -1298,9 +1317,21 @@ test_unsigned_int_converter(PyObject *module, PyObject *const *args, Py_ssize_t | |||
| 1298 | 1317 | if (nargs < 3) { | |
| 1299 | 1318 | goto skip_optional; | |
| 1300 | 1319 | } | |
| 1301 | - c = (unsigned int)PyLong_AsUnsignedLongMask(args[2]); | ||
| 1302 | - if (c == (unsigned int)-1 && PyErr_Occurred()) { | ||
| 1303 | - goto exit; | ||
| 1320 | + { | ||
| 1321 | + Py_ssize_t _bytes = PyLong_AsNativeBytes(args[2], &c, sizeof(unsigned int), | ||
| 1322 | + Py_ASNATIVEBYTES_NATIVE_ENDIAN | | ||
| 1323 | + Py_ASNATIVEBYTES_ALLOW_INDEX | | ||
| 1324 | + Py_ASNATIVEBYTES_UNSIGNED_BUFFER); | ||
| 1325 | + if (_bytes < 0) { | ||
| 1326 | + goto exit; | ||
| 1327 | + } | ||
| 1328 | + if ((size_t)_bytes > sizeof(unsigned int)) { | ||
| 1329 | + if (PyErr_WarnEx(PyExc_DeprecationWarning, | ||
| 1330 | + "integer value out of range", 1) < 0) | ||
| 1331 | + { | ||
| 1332 | + goto exit; | ||
| 1333 | + } | ||
| 1334 | + } | ||
| 1304 | 1335 | } | |
| 1305 | 1336 | skip_optional: | |
| 1306 | 1337 | return_value = test_unsigned_int_converter_impl(module, a, b, c); | |
@@ -1312,7 +1343,7 @@ test_unsigned_int_converter(PyObject *module, PyObject *const *args, Py_ssize_t | |||
| 1312 | 1343 | static PyObject * | |
| 1313 | 1344 | test_unsigned_int_converter_impl(PyObject *module, unsigned int a, | |
| 1314 | 1345 | unsigned int b, unsigned int c) | |
| 1315 | - /*[clinic end generated code: output=f9cdbe410ccc98a3 input=5533534828b62fc0]*/ | ||
| 1346 | + /*[clinic end generated code: output=50a413f1cc82dc11 input=5533534828b62fc0]*/ | ||
| 1316 | 1347 | ||
| 1317 | 1348 | ||
| 1318 | 1349 | /*[clinic input] | |
@@ -1414,7 +1445,22 @@ test_unsigned_long_converter(PyObject *module, PyObject *const *args, Py_ssize_t | |||
| 1414 | 1445 | _PyArg_BadArgument("test_unsigned_long_converter", "argument 3", "int", args[2]); | |
| 1415 | 1446 | goto exit; | |
| 1416 | 1447 | } | |
| 1417 | - c = PyLong_AsUnsignedLongMask(args[2]); | ||
| 1448 | + { | ||
| 1449 | + Py_ssize_t _bytes = PyLong_AsNativeBytes(args[2], &c, sizeof(unsigned long), | ||
| 1450 | + Py_ASNATIVEBYTES_NATIVE_ENDIAN | | ||
| 1451 | + Py_ASNATIVEBYTES_ALLOW_INDEX | | ||
| 1452 | + Py_ASNATIVEBYTES_UNSIGNED_BUFFER); | ||
| 1453 | + if (_bytes < 0) { | ||
| 1454 | + goto exit; | ||
| 1455 | + } | ||
| 1456 | + if ((size_t)_bytes > sizeof(unsigned long)) { | ||
| 1457 | + if (PyErr_WarnEx(PyExc_DeprecationWarning, | ||
| 1458 | + "integer value out of range", 1) < 0) | ||
| 1459 | + { | ||
| 1460 | + goto exit; | ||
| 1461 | + } | ||
| 1462 | + } | ||
| 1463 | + } | ||
| 1418 | 1464 | skip_optional: | |
| 1419 | 1465 | return_value = test_unsigned_long_converter_impl(module, a, b, c); | |
| 1420 | 1466 | ||
@@ -1425,7 +1471,7 @@ test_unsigned_long_converter(PyObject *module, PyObject *const *args, Py_ssize_t | |||
| 1425 | 1471 | static PyObject * | |
| 1426 | 1472 | test_unsigned_long_converter_impl(PyObject *module, unsigned long a, | |
| 1427 | 1473 | unsigned long b, unsigned long c) | |
| 1428 | - /*[clinic end generated code: output=d74eed227d77a31b input=f450d94cae1ef73b]*/ | ||
| 1474 | + /*[clinic end generated code: output=1bbf5620093cc914 input=f450d94cae1ef73b]*/ | ||
| 1429 | 1475 | ||
| 1430 | 1476 | ||
| 1431 | 1477 | /*[clinic input] | |
@@ -1529,7 +1575,22 @@ test_unsigned_long_long_converter(PyObject *module, PyObject *const *args, Py_ss | |||
| 1529 | 1575 | _PyArg_BadArgument("test_unsigned_long_long_converter", "argument 3", "int", args[2]); | |
| 1530 | 1576 | goto exit; | |
| 1531 | 1577 | } | |
| 1532 | - c = PyLong_AsUnsignedLongLongMask(args[2]); | ||
| 1578 | + { | ||
| 1579 | + Py_ssize_t _bytes = PyLong_AsNativeBytes(args[2], &c, sizeof(unsigned long long), | ||
| 1580 | + Py_ASNATIVEBYTES_NATIVE_ENDIAN | | ||
| 1581 | + Py_ASNATIVEBYTES_ALLOW_INDEX | | ||
| 1582 | + Py_ASNATIVEBYTES_UNSIGNED_BUFFER); | ||
| 1583 | + if (_bytes < 0) { | ||
| 1584 | + goto exit; | ||
| 1585 | + } | ||
| 1586 | + if ((size_t)_bytes > sizeof(unsigned long long)) { | ||
| 1587 | + if (PyErr_WarnEx(PyExc_DeprecationWarning, | ||
| 1588 | + "integer value out of range", 1) < 0) | ||
| 1589 | + { | ||
| 1590 | + goto exit; | ||
| 1591 | + } | ||
| 1592 | + } | ||
| 1593 | + } | ||
| 1533 | 1594 | skip_optional: | |
| 1534 | 1595 | return_value = test_unsigned_long_long_converter_impl(module, a, b, c); | |
| 1535 | 1596 | ||
@@ -1542,7 +1603,7 @@ test_unsigned_long_long_converter_impl(PyObject *module, | |||
| 1542 | 1603 | unsigned long long a, | |
| 1543 | 1604 | unsigned long long b, | |
| 1544 | 1605 | unsigned long long c) | |
| 1545 | - /*[clinic end generated code: output=5ca4e4dfb3db644b input=a15115dc41866ff4]*/ | ||
| 1606 | + /*[clinic end generated code: output=582a6623dc845824 input=a15115dc41866ff4]*/ | ||
| 1546 | 1607 | ||
| 1547 | 1608 | ||
| 1548 | 1609 | /*[clinic input] | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -48,18 +48,17 @@ | |||
| 48 | 48 | LARGE = 0x7FFFFFFF | |
| 49 | 49 | VERY_LARGE = 0xFF0000121212121212121242 | |
| 50 | 50 | ||
| 51 | - from _testcapi import UCHAR_MAX, USHRT_MAX, UINT_MAX, ULONG_MAX, INT_MAX, \ | ||
| 52 | - INT_MIN, LONG_MIN, LONG_MAX, PY_SSIZE_T_MIN, PY_SSIZE_T_MAX, \ | ||
| 51 | + from _testcapi import UCHAR_MAX, USHRT_MAX, UINT_MAX, ULONG_MAX, ULLONG_MAX, INT_MAX, \ | ||
| 52 | + INT_MIN, LONG_MIN, LONG_MAX, LLONG_MIN, LLONG_MAX, PY_SSIZE_T_MIN, PY_SSIZE_T_MAX, \ | ||
| 53 | 53 | SHRT_MIN, SHRT_MAX, FLT_MIN, FLT_MAX, DBL_MIN, DBL_MAX | |
| 54 | 54 | ||
| 55 | 55 | DBL_MAX_EXP = sys.float_info.max_exp | |
| 56 | 56 | INF = float('inf') | |
| 57 | 57 | NAN = float('nan') | |
| 58 | 58 | ||
| 59 | 59 | # fake, they are not defined in Python's header files | |
| 60 | - LLONG_MAX = 2**63-1 | ||
| 61 | - LLONG_MIN = -2**63 | ||
| 62 | - ULLONG_MAX = 2**64-1 | ||
| 60 | + SCHAR_MAX = UCHAR_MAX // 2 | ||
| 61 | + SCHAR_MIN = SCHAR_MAX - UCHAR_MAX | ||
| 63 | 62 | ||
| 64 | 63 | NULL = None | |
| 65 | 64 | ||
@@ -209,10 +208,23 @@ def test_B(self): | |||
| 209 | 208 | self.assertEqual(UCHAR_MAX, getargs_B(-1)) | |
| 210 | 209 | self.assertEqual(0, getargs_B(0)) | |
| 211 | 210 | self.assertEqual(UCHAR_MAX, getargs_B(UCHAR_MAX)) | |
| 212 | - self.assertEqual(0, getargs_B(UCHAR_MAX+1)) | ||
| 211 | + with self.assertWarns(DeprecationWarning): | ||
| 212 | + self.assertEqual(0, getargs_B(UCHAR_MAX+1)) | ||
| 213 | + with self.assertWarns(DeprecationWarning): | ||
| 214 | + self.assertEqual(1, getargs_B(-UCHAR_MAX)) | ||
| 215 | + self.assertEqual(SCHAR_MAX+1, getargs_B(SCHAR_MIN)) | ||
| 216 | + with self.assertWarns(DeprecationWarning): | ||
| 217 | + self.assertEqual(SCHAR_MAX, getargs_B(SCHAR_MIN-1)) | ||
| 218 | + | ||
| 219 | + self.assertEqual(128, getargs_B(-2**7)) | ||
| 220 | + with self.assertWarns(DeprecationWarning): | ||
| 221 | + self.assertEqual(127, getargs_B(-2**7-1)) | ||
| 213 | 222 | ||
| 214 | 223 | self.assertEqual(42, getargs_B(42)) | |
| 215 | - self.assertEqual(UCHAR_MAX & VERY_LARGE, getargs_B(VERY_LARGE)) | ||
| 224 | + with self.assertWarns(DeprecationWarning): | ||
| 225 | + self.assertEqual(UCHAR_MAX & VERY_LARGE, getargs_B(VERY_LARGE)) | ||
| 226 | + with self.assertWarns(DeprecationWarning): | ||
| 227 | + self.assertEqual(UCHAR_MAX & -VERY_LARGE, getargs_B(-VERY_LARGE)) | ||
| 216 | 228 | ||
| 217 | 229 | def test_H(self): | |
| 218 | 230 | from _testcapi import getargs_H | |
@@ -233,11 +245,18 @@ def test_H(self): | |||
| 233 | 245 | self.assertEqual(USHRT_MAX, getargs_H(-1)) | |
| 234 | 246 | self.assertEqual(0, getargs_H(0)) | |
| 235 | 247 | self.assertEqual(USHRT_MAX, getargs_H(USHRT_MAX)) | |
| 236 | - self.assertEqual(0, getargs_H(USHRT_MAX+1)) | ||
| 248 | + with self.assertWarns(DeprecationWarning): | ||
| 249 | + self.assertEqual(0, getargs_H(USHRT_MAX+1)) | ||
| 250 | + self.assertEqual(SHRT_MAX+1, getargs_H(SHRT_MIN)) | ||
| 251 | + with self.assertWarns(DeprecationWarning): | ||
| 252 | + self.assertEqual(SHRT_MAX, getargs_H(SHRT_MIN-1)) | ||
| 237 | 253 | ||
| 238 | 254 | self.assertEqual(42, getargs_H(42)) | |
| 239 | 255 | ||
| 240 | - self.assertEqual(VERY_LARGE & USHRT_MAX, getargs_H(VERY_LARGE)) | ||
| 256 | + with self.assertWarns(DeprecationWarning): | ||
| 257 | + self.assertEqual(USHRT_MAX & VERY_LARGE, getargs_H(VERY_LARGE)) | ||
| 258 | + with self.assertWarns(DeprecationWarning): | ||
| 259 | + self.assertEqual(USHRT_MAX & -VERY_LARGE, getargs_H(-VERY_LARGE)) | ||
| 241 | 260 | ||
| 242 | 261 | def test_I(self): | |
| 243 | 262 | from _testcapi import getargs_I | |
@@ -258,11 +277,18 @@ def test_I(self): | |||
| 258 | 277 | self.assertEqual(UINT_MAX, getargs_I(-1)) | |
| 259 | 278 | self.assertEqual(0, getargs_I(0)) | |
| 260 | 279 | self.assertEqual(UINT_MAX, getargs_I(UINT_MAX)) | |
| 261 | - self.assertEqual(0, getargs_I(UINT_MAX+1)) | ||
| 280 | + with self.assertWarns(DeprecationWarning): | ||
| 281 | + self.assertEqual(0, getargs_I(UINT_MAX+1)) | ||
| 282 | + self.assertEqual(INT_MAX+1, getargs_I(INT_MIN)) | ||
| 283 | + with self.assertWarns(DeprecationWarning): | ||
| 284 | + self.assertEqual(INT_MAX, getargs_I(INT_MIN-1)) | ||
| 262 | 285 | ||
| 263 | 286 | self.assertEqual(42, getargs_I(42)) | |
| 264 | 287 | ||
| 265 | - self.assertEqual(VERY_LARGE & UINT_MAX, getargs_I(VERY_LARGE)) | ||
| 288 | + with self.assertWarns(DeprecationWarning): | ||
| 289 | + self.assertEqual(UINT_MAX & VERY_LARGE, getargs_I(VERY_LARGE)) | ||
| 290 | + with self.assertWarns(DeprecationWarning): | ||
| 291 | + self.assertEqual(UINT_MAX & -VERY_LARGE, getargs_I(-VERY_LARGE)) | ||
| 266 | 292 | ||
| 267 | 293 | def test_k(self): | |
| 268 | 294 | from _testcapi import getargs_k | |
@@ -283,11 +309,18 @@ def test_k(self): | |||
| 283 | 309 | self.assertEqual(ULONG_MAX, getargs_k(-1)) | |
| 284 | 310 | self.assertEqual(0, getargs_k(0)) | |
| 285 | 311 | self.assertEqual(ULONG_MAX, getargs_k(ULONG_MAX)) | |
| 286 | - self.assertEqual(0, getargs_k(ULONG_MAX+1)) | ||
| 312 | + with self.assertWarns(DeprecationWarning): | ||
| 313 | + self.assertEqual(0, getargs_k(ULONG_MAX+1)) | ||
| 314 | + self.assertEqual(LONG_MAX+1, getargs_k(LONG_MIN)) | ||
| 315 | + with self.assertWarns(DeprecationWarning): | ||
| 316 | + self.assertEqual(LONG_MAX, getargs_k(LONG_MIN-1)) | ||
| 287 | 317 | ||
| 288 | 318 | self.assertEqual(42, getargs_k(42)) | |
| 289 | 319 | ||
| 290 | - self.assertEqual(VERY_LARGE & ULONG_MAX, getargs_k(VERY_LARGE)) | ||
| 320 | + with self.assertWarns(DeprecationWarning): | ||
| 321 | + self.assertEqual(ULONG_MAX & VERY_LARGE, getargs_k(VERY_LARGE)) | ||
| 322 | + with self.assertWarns(DeprecationWarning): | ||
| 323 | + self.assertEqual(ULONG_MAX & -VERY_LARGE, getargs_k(-VERY_LARGE)) | ||
| 291 | 324 | ||
| 292 | 325 | class Signed_TestCase(unittest.TestCase): | |
| 293 | 326 | def test_h(self): | |
@@ -434,11 +467,18 @@ def test_K(self): | |||
| 434 | 467 | self.assertEqual(ULLONG_MAX, getargs_K(ULLONG_MAX)) | |
| 435 | 468 | self.assertEqual(0, getargs_K(0)) | |
| 436 | 469 | self.assertEqual(ULLONG_MAX, getargs_K(ULLONG_MAX)) | |
| 437 | - self.assertEqual(0, getargs_K(ULLONG_MAX+1)) | ||
| 470 | + with self.assertWarns(DeprecationWarning): | ||
| 471 | + self.assertEqual(0, getargs_K(ULLONG_MAX+1)) | ||
| 472 | + self.assertEqual(LLONG_MAX+1, getargs_K(LLONG_MIN)) | ||
| 473 | + with self.assertWarns(DeprecationWarning): | ||
| 474 | + self.assertEqual(LLONG_MAX, getargs_K(LLONG_MIN-1)) | ||
| 438 | 475 | ||
| 439 | 476 | self.assertEqual(42, getargs_K(42)) | |
| 440 | 477 | ||
| 441 | - self.assertEqual(VERY_LARGE & ULLONG_MAX, getargs_K(VERY_LARGE)) | ||
| 478 | + with self.assertWarns(DeprecationWarning): | ||
| 479 | + self.assertEqual(ULLONG_MAX & VERY_LARGE, getargs_K(VERY_LARGE)) | ||
| 480 | + with self.assertWarns(DeprecationWarning): | ||
| 481 | + self.assertEqual(ULLONG_MAX & -VERY_LARGE, getargs_K(-VERY_LARGE)) | ||
| 442 | 482 | ||
| 443 | 483 | ||
| 444 | 484 | class Float_TestCase(unittest.TestCase, FloatsAreIdenticalMixin): | |
| Back | FazBrowse Home | New Git URL |
0 commit comments