diff Objects/stringobject.c @ 37855:dc8efd70ab56 legacy-trunk

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.
author Thomas Wouters <thomas@python.org>
date Wed, 19 Apr 2006 14:50:15 +0000
parents 20cb13bdf1f0
children 74f459a289be
line wrap: on
line diff
--- a/Objects/stringobject.c	Wed Apr 19 12:55:39 2006 +0000
+++ b/Objects/stringobject.c	Wed Apr 19 14:50:15 2006 +0000
@@ -2860,10 +2860,10 @@
 static PyObject *
 string_ljust(PyStringObject *self, PyObject *args)
 {
-    int width;
+    Py_ssize_t width;
     char fillchar = ' ';
 
-    if (!PyArg_ParseTuple(args, "i|c:ljust", &width, &fillchar))
+    if (!PyArg_ParseTuple(args, "n|c:ljust", &width, &fillchar))
         return NULL;
 
     if (PyString_GET_SIZE(self) >= width && PyString_CheckExact(self)) {
@@ -2884,10 +2884,10 @@
 static PyObject *
 string_rjust(PyStringObject *self, PyObject *args)
 {
-    int width;
+    Py_ssize_t width;
     char fillchar = ' ';
 
-    if (!PyArg_ParseTuple(args, "i|c:rjust", &width, &fillchar))
+    if (!PyArg_ParseTuple(args, "n|c:rjust", &width, &fillchar))
         return NULL;
 
     if (PyString_GET_SIZE(self) >= width && PyString_CheckExact(self)) {
@@ -2909,10 +2909,10 @@
 string_center(PyStringObject *self, PyObject *args)
 {
     Py_ssize_t marg, left;
-    long width;
+    Py_ssize_t width;
     char fillchar = ' ';
 
-    if (!PyArg_ParseTuple(args, "l|c:center", &width, &fillchar))
+    if (!PyArg_ParseTuple(args, "n|c:center", &width, &fillchar))
         return NULL;
 
     if (PyString_GET_SIZE(self) >= width && PyString_CheckExact(self)) {
@@ -2938,9 +2938,9 @@
     Py_ssize_t fill;
     PyObject *s;
     char *p;
-
-    long width;
-    if (!PyArg_ParseTuple(args, "l:zfill", &width))
+    Py_ssize_t width;
+
+    if (!PyArg_ParseTuple(args, "n:zfill", &width))
         return NULL;
 
     if (PyString_GET_SIZE(self) >= width) {