Mercurial > cpython-lru_cache-weakref
diff Python/import.c @ 31824:331de8b9d1ed legacy-trunk
Marshal clean-up (SF patch #873224)
| author | Armin Rigo <arigo@tunes.org> |
|---|---|
| date | Fri, 26 Mar 2004 15:09:27 +0000 |
| parents | 846b3ee7e106 |
| children | adb42a711696 |
line wrap: on
line diff
--- a/Python/import.c Fri Mar 26 11:16:55 2004 +0000 +++ b/Python/import.c Fri Mar 26 15:09:27 2004 +0000 @@ -706,12 +706,12 @@ 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 @@ /* 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 */
