static PyObject * complex__format__(PyObject* self, PyObject* args) { PyObject *format_spec; if (!PyArg_ParseTuple(args, "O:__format__", &format_spec)) return NULL; if (PyBytes_Check(format_spec)) return _PyComplex_FormatAdvanced(self, PyBytes_AS_STRING(format_spec), PyBytes_GET_SIZE(format_spec)); if (PyUnicode_Check(format_spec)) { /* Convert format_spec to a str */ PyObject *result; PyObject *str_spec = PyObject_Str(format_spec); if (str_spec == NULL) return NULL; result = _PyComplex_FormatAdvanced(self, PyBytes_AS_STRING(str_spec), PyBytes_GET_SIZE(str_spec)); Py_DECREF(str_spec); return result; } PyErr_SetString(PyExc_TypeError, "__format__ requires str or unicode"); return NULL; }
static PyObject * complex__format__(PyObject* self, PyObject* args) { PyObject *format_spec; if (!PyArg_ParseTuple(args, "U:__format__", &format_spec)) return NULL; return _PyComplex_FormatAdvanced(self, format_spec, 0, PyUnicode_GET_LENGTH(format_spec)); }