diff options
author | Serhiy Storchaka <storchaka@gmail.com> | 2017-05-13 12:40:52 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-05-13 12:40:52 +0300 |
commit | 7e19dbc92ec06a987eaae72f7cdfd32006aa4960 (patch) | |
tree | 29a0b2c806b128c9c111b09b0c01ba3107e88bce /Objects/typeobject.c | |
parent | a66f9c6bb134561a24374f10e8c35417d356ce14 (diff) | |
download | cpython-git-7e19dbc92ec06a987eaae72f7cdfd32006aa4960.tar.gz |
bpo-28974: `object.__format__(x, '')` is now equivalent to `str(x)` (#506)
rather than `format(str(self), '')`.
Diffstat (limited to 'Objects/typeobject.c')
-rw-r--r-- | Objects/typeobject.c | 10 |
1 files changed, 1 insertions, 9 deletions
diff --git a/Objects/typeobject.c b/Objects/typeobject.c index 9eb725f062..121d66d8bc 100644 --- a/Objects/typeobject.c +++ b/Objects/typeobject.c @@ -4493,9 +4493,6 @@ static PyObject * object___format___impl(PyObject *self, PyObject *format_spec) /*[clinic end generated code: output=34897efb543a974b input=7c3b3bc53a6fb7fa]*/ { - PyObject *self_as_str = NULL; - PyObject *result = NULL; - /* Issue 7994: If we're converting to a string, we should reject format specifications */ if (PyUnicode_GET_LENGTH(format_spec) > 0) { @@ -4504,12 +4501,7 @@ object___format___impl(PyObject *self, PyObject *format_spec) self->ob_type->tp_name); return NULL; } - self_as_str = PyObject_Str(self); - if (self_as_str != NULL) { - result = PyObject_Format(self_as_str, format_spec); - Py_DECREF(self_as_str); - } - return result; + return PyObject_Str(self); } /*[clinic input] |