ensure the attribute name string is initalized before using it (closes #16839)
This commit is contained in:
parent
5ca88d2b18
commit
6b3f8d375b
|
@ -9,6 +9,9 @@ What's New in Python 2.7.4
|
||||||
Core and Builtins
|
Core and Builtins
|
||||||
-----------------
|
-----------------
|
||||||
|
|
||||||
|
- Issue #16839: Fix a segfault when calling unicode() on a classic class early
|
||||||
|
in interpreter initialization.
|
||||||
|
|
||||||
- Issue #16761: Calling ``int()`` and ``long()`` with *base* argument only
|
- Issue #16761: Calling ``int()`` and ``long()`` with *base* argument only
|
||||||
now raises TypeError.
|
now raises TypeError.
|
||||||
|
|
||||||
|
|
|
@ -474,7 +474,7 @@ PyObject_Unicode(PyObject *v)
|
||||||
PyObject *func;
|
PyObject *func;
|
||||||
PyObject *str;
|
PyObject *str;
|
||||||
int unicode_method_found = 0;
|
int unicode_method_found = 0;
|
||||||
static PyObject *unicodestr;
|
static PyObject *unicodestr = NULL;
|
||||||
|
|
||||||
if (v == NULL) {
|
if (v == NULL) {
|
||||||
res = PyString_FromString("<NULL>");
|
res = PyString_FromString("<NULL>");
|
||||||
|
@ -491,6 +491,11 @@ PyObject_Unicode(PyObject *v)
|
||||||
if (PyInstance_Check(v)) {
|
if (PyInstance_Check(v)) {
|
||||||
/* We're an instance of a classic class */
|
/* We're an instance of a classic class */
|
||||||
/* Try __unicode__ from the instance -- alas we have no type */
|
/* Try __unicode__ from the instance -- alas we have no type */
|
||||||
|
if (!unicodestr) {
|
||||||
|
unicodestr = PyString_InternFromString("__unicode__");
|
||||||
|
if (!unicodestr)
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
func = PyObject_GetAttr(v, unicodestr);
|
func = PyObject_GetAttr(v, unicodestr);
|
||||||
if (func != NULL) {
|
if (func != NULL) {
|
||||||
unicode_method_found = 1;
|
unicode_method_found = 1;
|
||||||
|
|
Loading…
Reference in New Issue