Mercurial > cpython-lru_cache-weakref
comparison Modules/_struct.c @ 60392:f1ea03e37ff6 2.6
Fix incorrect stacklevel for struct warnings. (Partial backport of r78690).
| author | Mark Dickinson <dickinsm@gmail.com> |
|---|---|
| date | Tue, 06 Apr 2010 15:19:40 +0000 |
| parents | 9ed8991a9141 |
| children | e38335d4df91 |
comparison
equal
deleted
inserted
replaced
| 60388:3775a4fd11c2 | 60392:f1ea03e37ff6 |
|---|---|
| 158 #ifdef PY_STRUCT_FLOAT_COERCE | 158 #ifdef PY_STRUCT_FLOAT_COERCE |
| 159 if (PyFloat_Check(v)) { | 159 if (PyFloat_Check(v)) { |
| 160 PyObject *o; | 160 PyObject *o; |
| 161 int res; | 161 int res; |
| 162 PyErr_Clear(); | 162 PyErr_Clear(); |
| 163 if (PyErr_WarnEx(PyExc_DeprecationWarning, FLOAT_COERCE, 2) < 0) | 163 if (PyErr_WarnEx(PyExc_DeprecationWarning, FLOAT_COERCE, 1) < 0) |
| 164 return -1; | 164 return -1; |
| 165 o = PyNumber_Int(v); | 165 o = PyNumber_Int(v); |
| 166 if (o == NULL) | 166 if (o == NULL) |
| 167 return -1; | 167 return -1; |
| 168 res = get_long(o, p); | 168 res = get_long(o, p); |
| 267 #ifdef PY_STRUCT_FLOAT_COERCE | 267 #ifdef PY_STRUCT_FLOAT_COERCE |
| 268 if (PyFloat_Check(v)) { | 268 if (PyFloat_Check(v)) { |
| 269 PyObject *o; | 269 PyObject *o; |
| 270 int res; | 270 int res; |
| 271 PyErr_Clear(); | 271 PyErr_Clear(); |
| 272 if (PyErr_WarnEx(PyExc_DeprecationWarning, FLOAT_COERCE, 2) < 0) | 272 if (PyErr_WarnEx(PyExc_DeprecationWarning, FLOAT_COERCE, 1) < 0) |
| 273 return -1; | 273 return -1; |
| 274 o = PyNumber_Int(v); | 274 o = PyNumber_Int(v); |
| 275 if (o == NULL) | 275 if (o == NULL) |
| 276 return -1; | 276 return -1; |
| 277 res = get_wrapped_long(o, p); | 277 res = get_wrapped_long(o, p); |
| 278 Py_DECREF(o); | 278 Py_DECREF(o); |
| 279 return res; | 279 return res; |
| 280 } | 280 } |
| 281 #endif | 281 #endif |
| 282 if (PyErr_WarnEx(PyExc_DeprecationWarning, INT_OVERFLOW, 2) < 0) | 282 if (PyErr_WarnEx(PyExc_DeprecationWarning, INT_OVERFLOW, 1) < 0) |
| 283 return -1; | 283 return -1; |
| 284 wrapped = PyNumber_And(v, pylong_ulong_mask); | 284 wrapped = PyNumber_And(v, pylong_ulong_mask); |
| 285 if (wrapped == NULL) | 285 if (wrapped == NULL) |
| 286 return -1; | 286 return -1; |
| 287 x = (long)PyLong_AsUnsignedLong(wrapped); | 287 x = (long)PyLong_AsUnsignedLong(wrapped); |
| 306 #ifdef PY_STRUCT_FLOAT_COERCE | 306 #ifdef PY_STRUCT_FLOAT_COERCE |
| 307 if (PyFloat_Check(v)) { | 307 if (PyFloat_Check(v)) { |
| 308 PyObject *o; | 308 PyObject *o; |
| 309 int res; | 309 int res; |
| 310 PyErr_Clear(); | 310 PyErr_Clear(); |
| 311 if (PyErr_WarnEx(PyExc_DeprecationWarning, FLOAT_COERCE, 2) < 0) | 311 if (PyErr_WarnEx(PyExc_DeprecationWarning, FLOAT_COERCE, 1) < 0) |
| 312 return -1; | 312 return -1; |
| 313 o = PyNumber_Int(v); | 313 o = PyNumber_Int(v); |
| 314 if (o == NULL) | 314 if (o == NULL) |
| 315 return -1; | 315 return -1; |
| 316 res = get_wrapped_ulong(o, p); | 316 res = get_wrapped_ulong(o, p); |
| 319 } | 319 } |
| 320 #endif | 320 #endif |
| 321 wrapped = PyNumber_And(v, pylong_ulong_mask); | 321 wrapped = PyNumber_And(v, pylong_ulong_mask); |
| 322 if (wrapped == NULL) | 322 if (wrapped == NULL) |
| 323 return -1; | 323 return -1; |
| 324 if (PyErr_WarnEx(PyExc_DeprecationWarning, INT_OVERFLOW, 2) < 0) { | 324 if (PyErr_WarnEx(PyExc_DeprecationWarning, INT_OVERFLOW, 1) < 0) { |
| 325 Py_DECREF(wrapped); | 325 Py_DECREF(wrapped); |
| 326 return -1; | 326 return -1; |
| 327 } | 327 } |
| 328 x = (long)PyLong_AsUnsignedLong(wrapped); | 328 x = (long)PyLong_AsUnsignedLong(wrapped); |
| 329 Py_DECREF(wrapped); | 329 Py_DECREF(wrapped); |
| 415 Py_XDECREF(pvalue); | 415 Py_XDECREF(pvalue); |
| 416 Py_XDECREF(ptraceback); | 416 Py_XDECREF(ptraceback); |
| 417 if (msg == NULL) | 417 if (msg == NULL) |
| 418 return -1; | 418 return -1; |
| 419 rval = PyErr_WarnEx(PyExc_DeprecationWarning, | 419 rval = PyErr_WarnEx(PyExc_DeprecationWarning, |
| 420 PyString_AS_STRING(msg), 2); | 420 PyString_AS_STRING(msg), 1); |
| 421 Py_DECREF(msg); | 421 Py_DECREF(msg); |
| 422 if (rval == 0) | 422 if (rval == 0) |
| 423 return 0; | 423 return 0; |
| 424 } | 424 } |
| 425 #endif | 425 #endif |
