mirror of https://github.com/python/cpython
Use Py_ssize_t to hold the 'width' argument to the ljust, rjust, center and
zfill stringmethods, so they can create strings larger than 2Gb on 64bit systems (even win64.) The unicode versions of these methods already did this right.
This commit is contained in:
parent
6719131129
commit
4abb3660ca
|
@ -2860,10 +2860,10 @@ PyDoc_STRVAR(ljust__doc__,
|
||||||
static PyObject *
|
static PyObject *
|
||||||
string_ljust(PyStringObject *self, PyObject *args)
|
string_ljust(PyStringObject *self, PyObject *args)
|
||||||
{
|
{
|
||||||
int width;
|
Py_ssize_t width;
|
||||||
char fillchar = ' ';
|
char fillchar = ' ';
|
||||||
|
|
||||||
if (!PyArg_ParseTuple(args, "i|c:ljust", &width, &fillchar))
|
if (!PyArg_ParseTuple(args, "n|c:ljust", &width, &fillchar))
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
if (PyString_GET_SIZE(self) >= width && PyString_CheckExact(self)) {
|
if (PyString_GET_SIZE(self) >= width && PyString_CheckExact(self)) {
|
||||||
|
@ -2884,10 +2884,10 @@ PyDoc_STRVAR(rjust__doc__,
|
||||||
static PyObject *
|
static PyObject *
|
||||||
string_rjust(PyStringObject *self, PyObject *args)
|
string_rjust(PyStringObject *self, PyObject *args)
|
||||||
{
|
{
|
||||||
int width;
|
Py_ssize_t width;
|
||||||
char fillchar = ' ';
|
char fillchar = ' ';
|
||||||
|
|
||||||
if (!PyArg_ParseTuple(args, "i|c:rjust", &width, &fillchar))
|
if (!PyArg_ParseTuple(args, "n|c:rjust", &width, &fillchar))
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
if (PyString_GET_SIZE(self) >= width && PyString_CheckExact(self)) {
|
if (PyString_GET_SIZE(self) >= width && PyString_CheckExact(self)) {
|
||||||
|
@ -2909,10 +2909,10 @@ static PyObject *
|
||||||
string_center(PyStringObject *self, PyObject *args)
|
string_center(PyStringObject *self, PyObject *args)
|
||||||
{
|
{
|
||||||
Py_ssize_t marg, left;
|
Py_ssize_t marg, left;
|
||||||
long width;
|
Py_ssize_t width;
|
||||||
char fillchar = ' ';
|
char fillchar = ' ';
|
||||||
|
|
||||||
if (!PyArg_ParseTuple(args, "l|c:center", &width, &fillchar))
|
if (!PyArg_ParseTuple(args, "n|c:center", &width, &fillchar))
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
if (PyString_GET_SIZE(self) >= width && PyString_CheckExact(self)) {
|
if (PyString_GET_SIZE(self) >= width && PyString_CheckExact(self)) {
|
||||||
|
@ -2938,9 +2938,9 @@ string_zfill(PyStringObject *self, PyObject *args)
|
||||||
Py_ssize_t fill;
|
Py_ssize_t fill;
|
||||||
PyObject *s;
|
PyObject *s;
|
||||||
char *p;
|
char *p;
|
||||||
|
Py_ssize_t width;
|
||||||
|
|
||||||
long width;
|
if (!PyArg_ParseTuple(args, "n:zfill", &width))
|
||||||
if (!PyArg_ParseTuple(args, "l:zfill", &width))
|
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
if (PyString_GET_SIZE(self) >= width) {
|
if (PyString_GET_SIZE(self) >= width) {
|
||||||
|
|
Loading…
Reference in New Issue