summaryrefslogtreecommitdiffstats
path: root/Modules
diff options
context:
space:
mode:
Diffstat (limited to 'Modules')
-rw-r--r--Modules/cPickle.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/Modules/cPickle.c b/Modules/cPickle.c
index 00641d8..639e68b 100644
--- a/Modules/cPickle.c
+++ b/Modules/cPickle.c
@@ -5241,6 +5241,13 @@ cpm_dumps(PyObject *self, PyObject *args, PyObject *kwds)
goto finally;
res = PycStringIO->cgetvalue(file);
+ if (res == NULL)
+ goto finally;
+ if (!PyBytes_Check(res)) {
+ PyObject *tmp = res;
+ res = PyBytes_FromObject(res);
+ Py_DECREF(tmp);
+ }
finally:
Py_XDECREF(pickler);