diff options
author | Tim Peters <tim.peters@gmail.com> | 2000-09-21 05:43:11 +0000 |
---|---|---|
committer | Tim Peters <tim.peters@gmail.com> | 2000-09-21 05:43:11 +0000 |
commit | f2e2d48a205dd68db8dc8987230707296d43860a (patch) | |
tree | 40b9d0789e4ef6a9579f99b7c2ac80663a08fe92 /Include | |
parent | a36e2a025b7e64f538cf4654746f1b519a2ddca0 (diff) | |
download | cpython-f2e2d48a205dd68db8dc8987230707296d43860a.tar.gz |
Derived from Martin's SF patch 110609: support unbounded ints in %d,i,u,x,X,o formats.
Note a curious extension to the std C rules: x, X and o formatting can never produce
a sign character in C, so the '+' and ' ' flags are meaningless for them. But
unbounded ints *can* produce a sign character under these conversions (no fixed-
width bitstring is wide enough to hold all negative values in 2's-comp form). So
these flags become meaningful in Python when formatting a Python long which is too
big to fit in a C long. This required shuffling around existing code, which hacked
x and X conversions to death when both the '#' and '0' flags were specified: the
hacks weren't strong enough to deal with the simultaneous possibility of the ' ' or
'+' flags too, since signs were always meaningless before for x and X conversions.
Isomorphic shuffling was required in unicodeobject.c.
Also added dozens of non-trivial new unbounded-int test cases to test_format.py.
Diffstat (limited to 'Include')
-rw-r--r-- | Include/stringobject.h | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/Include/stringobject.h b/Include/stringobject.h index 3bba7bc1f3..85ac0b6c02 100644 --- a/Include/stringobject.h +++ b/Include/stringobject.h @@ -59,6 +59,8 @@ extern DL_IMPORT(void) PyString_Concat(PyObject **, PyObject *); extern DL_IMPORT(void) PyString_ConcatAndDel(PyObject **, PyObject *); extern DL_IMPORT(int) _PyString_Resize(PyObject **, int); extern DL_IMPORT(PyObject *) PyString_Format(PyObject *, PyObject *); +extern DL_IMPORT(PyObject *) _PyString_FormatLong(PyObject*, int, int, + int, char**, int*); #ifdef INTERN_STRINGS extern DL_IMPORT(void) PyString_InternInPlace(PyObject **); |