| 1887 | } |
| 1888 | |
| 1889 | static inline PyObject* |
| 1890 | PyLongWriter_Finish(PyLongWriter *writer) |
| 1891 | { |
| 1892 | PyObject *obj = (PyObject *)writer; |
| 1893 | PyLongObject *self = (PyLongObject*)obj; |
| 1894 | Py_ssize_t j = _PyLong_DigitCount(self); |
| 1895 | Py_ssize_t i = j; |
| 1896 | int sign = _PyLong_Sign(obj); |
| 1897 | |
| 1898 | assert(Py_REFCNT(obj) == 1); |
| 1899 | |
| 1900 | // Normalize and get singleton if possible |
| 1901 | while (i > 0 && _PyLong_GetDigits(self)[i-1] == 0) { |
| 1902 | --i; |
| 1903 | } |
| 1904 | if (i != j) { |
| 1905 | if (i == 0) { |
| 1906 | sign = 0; |
| 1907 | } |
| 1908 | _PyLong_SetSignAndDigitCount(self, sign, i); |
| 1909 | } |
| 1910 | if (i <= 1) { |
| 1911 | long val = sign * (long)(_PyLong_GetDigits(self)[0]); |
| 1912 | Py_DECREF(obj); |
| 1913 | return PyLong_FromLong(val); |
| 1914 | } |
| 1915 | |
| 1916 | return obj; |
| 1917 | } |
| 1918 | #endif |
| 1919 | |
| 1920 |
nothing calls this directly
no test coverage detected