Refactor and clean up str.format() code (and helpers) in advance of optimizations.

This commit is contained in:
Eric Smith 2008-05-30 18:10:19 +00:00
parent eb2c964aeb
commit 4a7d76ddb5
10 changed files with 98 additions and 99 deletions

View file

@ -5,8 +5,6 @@
#include "Python.h"
#include "longintrepr.h"
#include "formatter_unicode.h"
#include <ctype.h>
#ifndef NSMALLPOSINTS
@ -3590,10 +3588,13 @@ long_getN(PyLongObject *v, void *context) {
static PyObject *
long__format__(PyObject *self, PyObject *args)
{
/* when back porting this to 2.6, check type of the format_spec
and call either unicode_long__format__ or
string_long__format__ */
return unicode_long__format__(self, args);
PyObject *format_spec;
if (!PyArg_ParseTuple(args, "U:__format__", &format_spec))
return NULL;
return _PyLong_FormatAdvanced(self,
PyUnicode_AS_UNICODE(format_spec),
PyUnicode_GET_SIZE(format_spec));
}