summaryrefslogtreecommitdiffstats
path: root/Modules/_pickle.c
diff options
context:
space:
mode:
authorSerhiy Storchaka <storchaka@gmail.com>2014-12-16 17:43:46 (GMT)
committerSerhiy Storchaka <storchaka@gmail.com>2014-12-16 17:43:46 (GMT)
commit707b5ccde56e89162660d7aaae584eeaf2736120 (patch)
tree719fe88e870eee24451dd4935d1f5df1be5158ec /Modules/_pickle.c
parent01bdd9a98070f12ad27611a37db91fd5ecae7358 (diff)
downloadcpython-707b5ccde56e89162660d7aaae584eeaf2736120.zip
cpython-707b5ccde56e89162660d7aaae584eeaf2736120.tar.gz
cpython-707b5ccde56e89162660d7aaae584eeaf2736120.tar.bz2
Issue #22783: Pickling now uses the NEWOBJ opcode instead of the NEWOBJ_EX
opcode if possible.
Diffstat (limited to 'Modules/_pickle.c')
-rw-r--r--Modules/_pickle.c25
1 files changed, 12 insertions, 13 deletions
diff --git a/Modules/_pickle.c b/Modules/_pickle.c
index 6416233..7a234f1 100644
--- a/Modules/_pickle.c
+++ b/Modules/_pickle.c
@@ -3506,20 +3506,19 @@ save_reduce(PicklerObject *self, PyObject *args, PyObject *obj)
}
PyErr_Clear();
}
- else if (self->proto >= 4) {
- _Py_IDENTIFIER(__newobj_ex__);
- use_newobj_ex = PyUnicode_Check(name) &&
- PyUnicode_Compare(
- name, _PyUnicode_FromId(&PyId___newobj_ex__)) == 0;
- Py_DECREF(name);
- }
- else {
- _Py_IDENTIFIER(__newobj__);
- use_newobj = PyUnicode_Check(name) &&
- PyUnicode_Compare(
- name, _PyUnicode_FromId(&PyId___newobj__)) == 0;
- Py_DECREF(name);
+ else if (PyUnicode_Check(name)) {
+ if (self->proto >= 4) {
+ _Py_IDENTIFIER(__newobj_ex__);
+ use_newobj_ex = PyUnicode_Compare(
+ name, _PyUnicode_FromId(&PyId___newobj_ex__)) == 0;
+ }
+ if (!use_newobj_ex) {
+ _Py_IDENTIFIER(__newobj__);
+ use_newobj = PyUnicode_Compare(
+ name, _PyUnicode_FromId(&PyId___newobj__)) == 0;
+ }
}
+ Py_XDECREF(name);
}
if (use_newobj_ex) {