diff options
author | Armin Rigo <arigo@tunes.org> | 2004-03-26 15:09:27 (GMT) |
---|---|---|
committer | Armin Rigo <arigo@tunes.org> | 2004-03-26 15:09:27 (GMT) |
commit | 01ab279056c0452516e58d47979be70455d3f581 (patch) | |
tree | d19cb861ece73a2365a0193bba8712aa7fb04943 /Python/import.c | |
parent | 01c9f8c35f583338e3638906ceeef9d2f29a0254 (diff) | |
download | cpython-01ab279056c0452516e58d47979be70455d3f581.zip cpython-01ab279056c0452516e58d47979be70455d3f581.tar.gz cpython-01ab279056c0452516e58d47979be70455d3f581.tar.bz2 |
Marshal clean-up (SF patch #873224)
Diffstat (limited to 'Python/import.c')
-rw-r--r-- | Python/import.c | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/Python/import.c b/Python/import.c index 5479677..71ee6c3 100644 --- a/Python/import.c +++ b/Python/import.c @@ -706,12 +706,12 @@ read_compiled_module(char *cpathname, FILE *fp) PyObject *co; co = PyMarshal_ReadLastObjectFromFile(fp); - /* Ugly: rd_object() may return NULL with or without error */ - if (co == NULL || !PyCode_Check(co)) { - if (!PyErr_Occurred()) - PyErr_Format(PyExc_ImportError, - "Non-code object in %.200s", cpathname); - Py_XDECREF(co); + if (co == NULL) + return NULL; + if (!PyCode_Check(co)) { + PyErr_Format(PyExc_ImportError, + "Non-code object in %.200s", cpathname); + Py_DECREF(co); return NULL; } return (PyCodeObject *)co; @@ -819,7 +819,7 @@ write_compiled_module(PyCodeObject *co, char *cpathname, long mtime) /* First write a 0 for mtime */ PyMarshal_WriteLongToFile(0L, fp); PyMarshal_WriteObjectToFile((PyObject *)co, fp); - if (ferror(fp)) { + if (fflush(fp) != 0 || ferror(fp)) { if (Py_VerboseFlag) PySys_WriteStderr("# can't write %s\n", cpathname); /* Don't keep partial file */ |