| LEFT | RIGHT |
| 1 | 1 |
| 2 /* Complex object implementation */ | 2 /* Complex object implementation */ |
| 3 | 3 |
| 4 /* Borrows heavily from floatobject.c */ | 4 /* Borrows heavily from floatobject.c */ |
| 5 | 5 |
| 6 /* Submitted by Jim Hugunin */ | 6 /* Submitted by Jim Hugunin */ |
| 7 | 7 |
| 8 #include "Python.h" | 8 #include "Python.h" |
| 9 #include "structmember.h" | 9 #include "structmember.h" |
| 10 | 10 |
| (...skipping 687 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 698 static PyObject * | 698 static PyObject * |
| 699 complex__format__(PyObject* self, PyObject* args) | 699 complex__format__(PyObject* self, PyObject* args) |
| 700 { | 700 { |
| 701 PyObject *format_spec; | 701 PyObject *format_spec; |
| 702 _PyUnicodeWriter writer; | 702 _PyUnicodeWriter writer; |
| 703 int ret; | 703 int ret; |
| 704 | 704 |
| 705 if (!PyArg_ParseTuple(args, "U:__format__", &format_spec)) | 705 if (!PyArg_ParseTuple(args, "U:__format__", &format_spec)) |
| 706 return NULL; | 706 return NULL; |
| 707 | 707 |
| 708 if (_PyUnicodeWriter_init(&writer, 0, 0) == -1) | 708 _PyUnicodeWriter_Init(&writer, 0); |
| 709 ret = _PyComplex_FormatAdvancedWriter( |
| 710 self, |
| 711 format_spec, 0, PyUnicode_GET_LENGTH(format_spec), |
| 712 &writer); |
| 713 if (ret == -1) { |
| 714 _PyUnicodeWriter_Dealloc(&writer); |
| 709 return NULL; | 715 return NULL; |
| 710 ret = _PyComplex_FormatWriter(self, format_spec, 0, | 716 } |
| 711 PyUnicode_GET_LENGTH(format_spec), | 717 return _PyUnicodeWriter_Finish(&writer); |
| 712 &writer); | |
| 713 if (ret == -1) { | |
| 714 _PyUnicodeWriter_dealloc(&writer); | |
| 715 return NULL; | |
| 716 } | |
| 717 return _PyUnicodeWriter_finish(&writer); | |
| 718 } | 718 } |
| 719 | 719 |
| 720 #if 0 | 720 #if 0 |
| 721 static PyObject * | 721 static PyObject * |
| 722 complex_is_finite(PyObject *self) | 722 complex_is_finite(PyObject *self) |
| 723 { | 723 { |
| 724 Py_complex c; | 724 Py_complex c; |
| 725 c = ((PyComplexObject *)self)->cval; | 725 c = ((PyComplexObject *)self)->cval; |
| 726 return PyBool_FromLong((long)(Py_IS_FINITE(c.real) && | 726 return PyBool_FromLong((long)(Py_IS_FINITE(c.real) && |
| 727 Py_IS_FINITE(c.imag))); | 727 Py_IS_FINITE(c.imag))); |
| (...skipping 377 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1105 0, /* tp_base */ | 1105 0, /* tp_base */ |
| 1106 0, /* tp_dict */ | 1106 0, /* tp_dict */ |
| 1107 0, /* tp_descr_get */ | 1107 0, /* tp_descr_get */ |
| 1108 0, /* tp_descr_set */ | 1108 0, /* tp_descr_set */ |
| 1109 0, /* tp_dictoffset */ | 1109 0, /* tp_dictoffset */ |
| 1110 0, /* tp_init */ | 1110 0, /* tp_init */ |
| 1111 PyType_GenericAlloc, /* tp_alloc */ | 1111 PyType_GenericAlloc, /* tp_alloc */ |
| 1112 complex_new, /* tp_new */ | 1112 complex_new, /* tp_new */ |
| 1113 PyObject_Del, /* tp_free */ | 1113 PyObject_Del, /* tp_free */ |
| 1114 }; | 1114 }; |
| LEFT | RIGHT |