summaryrefslogtreecommitdiffstats
path: root/Python/errors.c
diff options
context:
space:
mode:
authorVictor Stinner <victor.stinner@haypocalc.com>2011-10-17 18:18:58 (GMT)
committerVictor Stinner <victor.stinner@haypocalc.com>2011-10-17 18:18:58 (GMT)
commit9ea8e4c29db12520bdd024357acf354b0653dd04 (patch)
tree69a5b6afd52b695169956b5fdc282f4ff7fa6986 /Python/errors.c
parentecd02074440b683b28f0946c2a03b499541d1ea8 (diff)
downloadcpython-9ea8e4c29db12520bdd024357acf354b0653dd04.zip
cpython-9ea8e4c29db12520bdd024357acf354b0653dd04.tar.gz
cpython-9ea8e4c29db12520bdd024357acf354b0653dd04.tar.bz2
Instantiate the OS-related exception as soon as we raise it, so that "except"
works properly. PyErr_SetFromErrnoWithFilenameObject() was already fixed by the changeset 793c75177d28. This commit fixes PyErr_SetExcFromWindowsErrWithFilenameObject(), used on Windows.
Diffstat (limited to 'Python/errors.c')
-rw-r--r--Python/errors.c14
1 files changed, 9 insertions, 5 deletions
diff --git a/Python/errors.c b/Python/errors.c
index d62648b..cd0f68d 100644
--- a/Python/errors.c
+++ b/Python/errors.c
@@ -468,7 +468,7 @@ PyObject *PyErr_SetExcFromWindowsErrWithFilenameObject(
int len;
WCHAR *s_buf = NULL; /* Free via LocalFree */
PyObject *message;
- PyObject *v;
+ PyObject *args, *v;
DWORD err = (DWORD)ierr;
if (err==0) err = GetLastError();
len = FormatMessageW(
@@ -504,12 +504,16 @@ PyObject *PyErr_SetExcFromWindowsErrWithFilenameObject(
filenameObject = Py_None;
/* This is the constructor signature for passing a Windows error code.
The POSIX translation will be figured out by the constructor. */
- v = Py_BuildValue("(iOOi)", 0, message, filenameObject, err);
+ args = Py_BuildValue("(iOOi)", 0, message, filenameObject, err);
Py_DECREF(message);
- if (v != NULL) {
- PyErr_SetObject(exc, v);
- Py_DECREF(v);
+ if (args != NULL) {
+ v = PyObject_Call(exc, args, NULL);
+ Py_DECREF(args);
+ if (v != NULL) {
+ PyErr_SetObject((PyObject *) Py_TYPE(v), v);
+ Py_DECREF(v);
+ }
}
LocalFree(s_buf);
return NULL;