[Python-checkins] commit of r41775 - in python/branches/ssize_t: Modules/posixmodule.c Objects/bufferobject.c Objects/listobject.c Objects/obmalloc.c Objects/stringobject.c Python/getargs.c
martin.v.loewis
python-checkins at python.org
Tue Dec 20 10:32:38 CET 2005
Author: martin.v.loewis
Date: Tue Dec 20 10:32:34 2005
New Revision: 41775
Modified:
python/branches/ssize_t/Modules/posixmodule.c
python/branches/ssize_t/Objects/bufferobject.c
python/branches/ssize_t/Objects/listobject.c
python/branches/ssize_t/Objects/obmalloc.c
python/branches/ssize_t/Objects/stringobject.c
python/branches/ssize_t/Python/getargs.c
Log:
Revert a number of unnecessary changes; fix bugs.
Modified: python/branches/ssize_t/Modules/posixmodule.c
==============================================================================
--- python/branches/ssize_t/Modules/posixmodule.c (original)
+++ python/branches/ssize_t/Modules/posixmodule.c Tue Dec 20 10:32:34 2005
@@ -4220,7 +4220,7 @@
char modulepath[_MAX_PATH];
struct stat statinfo;
GetModuleFileName(NULL, modulepath, sizeof(modulepath));
- for (x = i = 0; modulepath[i]; i++)
+ for (i = x = 0; modulepath[i]; i++)
if (modulepath[i] == SEP)
x = i+1;
modulepath[x] = '\0';
Modified: python/branches/ssize_t/Objects/bufferobject.c
==============================================================================
--- python/branches/ssize_t/Objects/bufferobject.c (original)
+++ python/branches/ssize_t/Objects/bufferobject.c Tue Dec 20 10:32:34 2005
@@ -402,7 +402,7 @@
int size;
if (!get_buf(self, &ptr, &size))
return NULL;
- if (idx < 0 || idx >= size ) {
+ if ( idx < 0 || idx >= size ) {
PyErr_SetString(PyExc_IndexError, "buffer index out of range");
return NULL;
}
Modified: python/branches/ssize_t/Objects/listobject.c
==============================================================================
--- python/branches/ssize_t/Objects/listobject.c (original)
+++ python/branches/ssize_t/Objects/listobject.c Tue Dec 20 10:32:34 2005
@@ -138,7 +138,7 @@
PyErr_BadInternalCall();
return NULL;
}
- if (i >= ((PyListObject *)op) -> ob_size) {
+ if (i < 0 || i >= ((PyListObject *)op) -> ob_size) {
if (indexerr == NULL)
indexerr = PyString_FromString(
"list index out of range");
@@ -159,7 +159,7 @@
PyErr_BadInternalCall();
return -1;
}
- if (i >= ((PyListObject *)op) -> ob_size) {
+ if (i < 0 || i >= ((PyListObject *)op) -> ob_size) {
Py_XDECREF(newitem);
PyErr_SetString(PyExc_IndexError,
"list assignment index out of range");
Modified: python/branches/ssize_t/Objects/obmalloc.c
==============================================================================
--- python/branches/ssize_t/Objects/obmalloc.c (original)
+++ python/branches/ssize_t/Objects/obmalloc.c Tue Dec 20 10:32:34 2005
@@ -541,8 +541,8 @@
/* This is only useful when running memory debuggers such as
* Purify or Valgrind. Uncomment to use.
*
-#define Py_USING_MEMORY_DEBUGGER
*/
+#define Py_USING_MEMORY_DEBUGGER
#ifdef Py_USING_MEMORY_DEBUGGER
Modified: python/branches/ssize_t/Objects/stringobject.c
==============================================================================
--- python/branches/ssize_t/Objects/stringobject.c (original)
+++ python/branches/ssize_t/Objects/stringobject.c Tue Dec 20 10:32:34 2005
@@ -3900,17 +3900,17 @@
if (args->ob_type->tp_as_mapping && !PyTuple_Check(args) &&
!PyObject_TypeCheck(args, &PyBaseString_Type))
dict = args;
- while (fmtcnt-- != 0) {
+ while (--fmtcnt >= 0) {
if (*fmt != '%') {
- if (rescnt == 0) {
+ if (--rescnt < 0) {
rescnt = fmtcnt + 100;
reslen += rescnt;
if (_PyString_Resize(&result, reslen) < 0)
return NULL;
res = PyString_AS_STRING(result)
+ reslen - rescnt;
+ --rescnt;
}
- rescnt--;
*res++ = *fmt++;
}
else {
@@ -4192,7 +4192,7 @@
}
if (width < len)
width = len;
- if ((rescnt - (sign != 0)) < width) {
+ if (rescnt - (sign != 0) < width) {
reslen -= rescnt;
rescnt = width + fmtcnt + 100;
reslen += rescnt;
Modified: python/branches/ssize_t/Python/getargs.c
==============================================================================
--- python/branches/ssize_t/Python/getargs.c (original)
+++ python/branches/ssize_t/Python/getargs.c Tue Dec 20 10:32:34 2005
@@ -1144,7 +1144,6 @@
const char **p = va_arg(*p_va, const char **);
PyBufferProcs *pb = arg->ob_type->tp_as_buffer;
int count;
- FETCH_SIZE;
if (*format++ != '#')
return converterr(
@@ -1166,7 +1165,10 @@
count = pb->bf_getcharbuffer(arg, 0, p);
if (count < 0)
return converterr("(unspecified)", arg, msgbuf, bufsize);
- STORE_SIZE(count);
+ {
+ FETCH_SIZE;
+ STORE_SIZE(count);
+ }
break;
}
More information about the Python-checkins
mailing list