Mercurial > cpython-lru_cache-weakref
comparison Python/errors.c @ 24423:3db261a93a5b legacy-trunk
New functions for extension writers on Windows:
PyErr_SetExcFromWindowsErr(), PyErr_SetExcFromWindowsErrWithFilename().
Similar to PyErr_SetFromWindowsErrWithFilename() and
PyErr_SetFromWindowsErr(), but they allow to specify
the exception type to raise. Available on Windows.
See SF patch #576458.
| author | Thomas Heller <theller@ctypes.org> |
|---|---|
| date | Mon, 29 Jul 2002 14:27:41 +0000 |
| parents | 8142f8d668a0 |
| children | 861065256487 |
comparison
equal
deleted
inserted
replaced
| 24422:bd6268b17b75 | 24423:3db261a93a5b |
|---|---|
| 335 return PyErr_SetFromErrnoWithFilename(exc, NULL); | 335 return PyErr_SetFromErrnoWithFilename(exc, NULL); |
| 336 } | 336 } |
| 337 | 337 |
| 338 #ifdef MS_WINDOWS | 338 #ifdef MS_WINDOWS |
| 339 /* Windows specific error code handling */ | 339 /* Windows specific error code handling */ |
| 340 PyObject *PyErr_SetFromWindowsErrWithFilename( | 340 PyObject *PyErr_SetExcFromWindowsErrWithFilename( |
| 341 PyObject *exc, | |
| 341 int ierr, | 342 int ierr, |
| 342 const char *filename) | 343 const char *filename) |
| 343 { | 344 { |
| 344 int len; | 345 int len; |
| 345 char *s; | 346 char *s; |
| 364 if (filename != NULL) | 365 if (filename != NULL) |
| 365 v = Py_BuildValue("(iss)", err, s, filename); | 366 v = Py_BuildValue("(iss)", err, s, filename); |
| 366 else | 367 else |
| 367 v = Py_BuildValue("(is)", err, s); | 368 v = Py_BuildValue("(is)", err, s); |
| 368 if (v != NULL) { | 369 if (v != NULL) { |
| 369 PyErr_SetObject(PyExc_WindowsError, v); | 370 PyErr_SetObject(exc, v); |
| 370 Py_DECREF(v); | 371 Py_DECREF(v); |
| 371 } | 372 } |
| 372 LocalFree(s); | 373 LocalFree(s); |
| 373 return NULL; | 374 return NULL; |
| 374 } | 375 } |
| 375 | 376 |
| 377 PyObject *PyErr_SetExcFromWindowsErr(PyObject *exc, int ierr) | |
| 378 { | |
| 379 return PyErr_SetExcFromWindowsErrWithFilename(exc, ierr, NULL); | |
| 380 } | |
| 381 | |
| 376 PyObject *PyErr_SetFromWindowsErr(int ierr) | 382 PyObject *PyErr_SetFromWindowsErr(int ierr) |
| 377 { | 383 { |
| 378 return PyErr_SetFromWindowsErrWithFilename(ierr, NULL); | 384 return PyErr_SetExcFromWindowsErrWithFilename(PyExc_WindowsError, |
| 385 ierr, NULL); | |
| 386 } | |
| 387 PyObject *PyErr_SetFromWindowsErrWithFilename( | |
| 388 int ierr, | |
| 389 const char *filename) | |
| 390 { | |
| 391 return PyErr_SetExcFromWindowsErrWithFilename(PyExc_WindowsError, | |
| 392 ierr, filename); | |
| 379 } | 393 } |
| 380 #endif /* MS_WINDOWS */ | 394 #endif /* MS_WINDOWS */ |
| 381 | 395 |
| 382 void | 396 void |
| 383 _PyErr_BadInternalCall(char *filename, int lineno) | 397 _PyErr_BadInternalCall(char *filename, int lineno) |
