Index: Python/errors.c =================================================================== --- Python/errors.c (revision 68185) +++ Python/errors.c (working copy) @@ -16,11 +16,6 @@ #include -#ifdef __cplusplus -extern "C" { -#endif - - void PyErr_Restore(PyObject *type, PyObject *value, PyObject *traceback) { @@ -755,7 +750,3 @@ return NULL; } -#ifdef __cplusplus -} -#endif - Index: Python/getargs.c =================================================================== --- Python/getargs.c (revision 68185) +++ Python/getargs.c (working copy) @@ -5,21 +5,9 @@ #include - #ifdef __cplusplus extern "C" { #endif -int PyArg_Parse(PyObject *, const char *, ...); -int PyArg_ParseTuple(PyObject *, const char *, ...); -int PyArg_VaParse(PyObject *, const char *, va_list); - -int PyArg_ParseTupleAndKeywords(PyObject *, PyObject *, - const char *, char **, ...); -int PyArg_VaParseTupleAndKeywords(PyObject *, PyObject *, - const char *, char **, va_list); - -#ifdef HAVE_DECLSPEC_DLL -/* Export functions */ PyAPI_FUNC(int) _PyArg_Parse_SizeT(PyObject *, char *, ...); PyAPI_FUNC(int) _PyArg_ParseTuple_SizeT(PyObject *, char *, ...); PyAPI_FUNC(int) _PyArg_ParseTupleAndKeywords_SizeT(PyObject *, PyObject *, @@ -28,6 +16,8 @@ PyAPI_FUNC(int) _PyArg_VaParse_SizeT(PyObject *, char *, va_list); PyAPI_FUNC(int) _PyArg_VaParseTupleAndKeywords_SizeT(PyObject *, PyObject *, const char *, char **, va_list); +#ifdef __cplusplus +} #endif #define FLAG_COMPAT 1 @@ -1866,6 +1856,3 @@ funcname); return 0; } -#ifdef __cplusplus -}; -#endif Index: Python/ast.c =================================================================== --- Python/ast.c (revision 68185) +++ Python/ast.c (working copy) @@ -1640,7 +1640,7 @@ NCH(ppower) == 1 && TYPE((patom = CHILD(ppower, 0))) == atom && TYPE((pnum = CHILD(patom, 0))) == NUMBER) { - char *s = PyObject_MALLOC(strlen(STR(pnum)) + 2); + char *s = (char *)PyObject_MALLOC(strlen(STR(pnum)) + 2); if (s == NULL) return NULL; s[0] = '-'; Index: Python/pystate.c =================================================================== --- Python/pystate.c (revision 68185) +++ Python/pystate.c (working copy) @@ -30,10 +30,6 @@ #define HEAD_LOCK() PyThread_acquire_lock(head_mutex, WAIT_LOCK) #define HEAD_UNLOCK() PyThread_release_lock(head_mutex) -#ifdef __cplusplus -extern "C" { -#endif - /* The single PyInterpreterState used by this process' GILState implementation */ @@ -636,11 +632,6 @@ else if (oldstate == PyGILState_UNLOCKED) PyEval_SaveThread(); } - -#ifdef __cplusplus -} -#endif - #endif /* WITH_THREAD */ Index: Python/getopt.c =================================================================== --- Python/getopt.c (revision 68185) +++ Python/getopt.c (working copy) @@ -27,13 +27,11 @@ /* Modified to support --help and --version, as well as /? on Windows * by Georg Brandl. */ +#include "Python.h" +#include "pygetopt.h" #include #include -#ifdef __cplusplus -extern "C" { -#endif - int _PyOS_opterr = 1; /* generate error messages */ int _PyOS_optind = 1; /* index into argv array */ char *_PyOS_optarg = NULL; /* optional argument */ @@ -119,8 +117,3 @@ return option; } - -#ifdef __cplusplus -} -#endif - Index: Python/pythonrun.c =================================================================== --- Python/pythonrun.c (revision 68185) +++ Python/pythonrun.c (working copy) @@ -17,6 +17,7 @@ #include "ast.h" #include "eval.h" #include "marshal.h" +#include "import.h" #ifdef HAVE_SIGNAL_H #include @@ -44,12 +45,6 @@ _Py_GetRefTotal()) #endif -#ifdef __cplusplus -extern "C" { -#endif - -extern char *Py_GetPath(void); - extern grammar _PyParser_Grammar; /* From graminit.c */ /* Forward */ @@ -150,8 +145,6 @@ char ibuf[128]; char buf[128]; #endif - extern void _Py_ReadyTypes(void); - if (initialized) return; initialized = 1; @@ -1343,7 +1336,6 @@ PyCodeObject *co; PyObject *v; long magic; - long PyImport_GetMagicNumber(void); magic = PyMarshal_ReadLongFromFile(fp); if (magic != PyImport_GetMagicNumber()) { @@ -1951,8 +1943,3 @@ { return PyRun_InteractiveLoopFlags(f, p, NULL); } - -#ifdef __cplusplus -} -#endif - Index: Python/import.c =================================================================== --- Python/import.c (revision 68185) +++ Python/import.c (working copy) @@ -18,10 +18,9 @@ #ifdef HAVE_FCNTL_H #include #endif -#ifdef __cplusplus -extern "C" { -#endif +#include + #ifdef MS_WINDOWS /* for stat.st_mode */ typedef unsigned short mode_t; @@ -2781,7 +2780,6 @@ static PyObject * call_find_module(char *name, PyObject *path) { - extern int fclose(FILE *); PyObject *fob, *ret; struct filedescr *fdp; char pathname[MAXPATHLEN+1]; @@ -3338,7 +3336,3 @@ return PyImport_ExtendInittab(newtab); } - -#ifdef __cplusplus -} -#endif Index: Python/Python-ast.c =================================================================== --- Python/Python-ast.c (revision 68185) +++ Python/Python-ast.c (working copy) @@ -12,7 +12,6 @@ #include "Python.h" #include "Python-ast.h" -static PyTypeObject AST_type; static PyTypeObject *mod_type; static PyObject* ast2obj_mod(void*); static PyTypeObject *Module_type; Index: Python/getmtime.c =================================================================== --- Python/getmtime.c (revision 68185) +++ Python/getmtime.c (working copy) @@ -6,10 +6,6 @@ #include "Python.h" #include "pyconfig.h" -#ifdef __cplusplus -extern "C" { -#endif - time_t PyOS_GetLastModificationTime(char *path, FILE *fp) { @@ -20,7 +16,3 @@ return st.st_mtime; } -#ifdef __cplusplus -} -#endif - Index: Include/unicodeobject.h =================================================================== --- Include/unicodeobject.h (revision 68185) +++ Include/unicodeobject.h (working copy) @@ -1390,6 +1390,9 @@ Py_UNICODE ch /* Unicode character */ ); +PyAPI_FUNC(void) _PyUnicode_Init(void); +PyAPI_FUNC(void) _PyUnicode_Fini(void); + #ifdef __cplusplus } #endif Index: Include/pystate.h =================================================================== --- Include/pystate.h (revision 68185) +++ Include/pystate.h (working copy) @@ -188,6 +188,8 @@ /* hook for PyEval_GetFrame(), requested for Psyco */ PyAPI_DATA(PyThreadFrameGetter) _PyThreadState_GetFrame; +PyAPI_FUNC(void) _PyGILState_Init(PyInterpreterState *i, PyThreadState *t); +PyAPI_FUNC(void) _PyGILState_Fini(void); #ifdef __cplusplus } Index: Include/object.h =================================================================== --- Include/object.h (revision 68185) +++ Include/object.h (working copy) @@ -967,6 +967,8 @@ else \ _PyTrash_deposit_object((PyObject*)op); +PyAPI_FUNC(void) _Py_ReadyTypes(void); + #ifdef __cplusplus } #endif Index: Objects/abstract.c =================================================================== --- Objects/abstract.c (revision 68185) +++ Objects/abstract.c (working copy) @@ -509,14 +509,14 @@ else { addone = _add_one_to_index_C; } - dest = buf; + dest = (char *)buf; /* XXX : This is not going to be the fastest code in the world several optimizations are possible. */ elements = len / view->itemsize; while (elements--) { addone(view->ndim, indices, view->shape); - ptr = PyBuffer_GetPointer(view, indices); + ptr = (char *)PyBuffer_GetPointer(view, indices); memcpy(dest, ptr, view->itemsize); dest += view->itemsize; } @@ -560,14 +560,14 @@ else { addone = _add_one_to_index_C; } - src = buf; + src = (char *)buf; /* XXX : This is not going to be the fastest code in the world several optimizations are possible. */ elements = len / view->itemsize; while (elements--) { addone(view->ndim, indices, view->shape); - ptr = PyBuffer_GetPointer(view, indices); + ptr = (char *)PyBuffer_GetPointer(view, indices); memcpy(ptr, src, view->itemsize); src += view->itemsize; } @@ -636,8 +636,8 @@ } while (elements--) { _add_one_to_index_C(view_src.ndim, indices, view_src.shape); - dptr = PyBuffer_GetPointer(&view_dest, indices); - sptr = PyBuffer_GetPointer(&view_src, indices); + dptr = (char *)PyBuffer_GetPointer(&view_dest, indices); + sptr = (char *)PyBuffer_GetPointer(&view_src, indices); memcpy(dptr, sptr, view_src.itemsize); } PyMem_Free(indices); Index: Objects/object.c =================================================================== --- Objects/object.c (revision 68185) +++ Objects/object.c (working copy) @@ -3,10 +3,6 @@ #include "Python.h" -#ifdef __cplusplus -extern "C" { -#endif - #ifdef Py_REF_DEBUG Py_ssize_t _Py_RefTotal; @@ -2289,7 +2285,3 @@ --_PyTrash_delete_nesting; } } - -#ifdef __cplusplus -} -#endif Index: Objects/typeobject.c =================================================================== --- Objects/typeobject.c (revision 68185) +++ Objects/typeobject.c (working copy) @@ -6134,7 +6134,7 @@ /* We specifically allow __hash__ to be set to None to prevent inheritance of the default implementation from object.__hash__ */ - specific = PyObject_HashNotImplemented; + specific = (void *)PyObject_HashNotImplemented; } else { use_generic = 1; Index: Objects/unicodeobject.c =================================================================== --- Objects/unicodeobject.c (revision 68185) +++ Objects/unicodeobject.c (working copy) @@ -87,11 +87,6 @@ */ - -#ifdef __cplusplus -extern "C" { -#endif - /* Free list for Unicode objects */ static PyUnicodeObject *free_list; static int numfree; @@ -259,7 +254,7 @@ it contains). */ oldstr = unicode->str; - unicode->str = PyObject_REALLOC(unicode->str, + unicode->str = (Py_UNICODE *)PyObject_REALLOC(unicode->str, sizeof(Py_UNICODE) * (length + 1)); if (!unicode->str) { unicode->str = (Py_UNICODE *)oldstr; @@ -626,7 +621,7 @@ /* step 2: allocate memory for the results of * PyObject_Str()/PyObject_Repr() calls */ if (callcount) { - callresults = PyObject_Malloc(sizeof(PyObject *)*callcount); + callresults = (PyObject **)PyObject_Malloc(sizeof(PyObject *)*callcount); if (!callresults) { PyErr_NoMemory(); return NULL; @@ -773,7 +768,7 @@ } expand: if (abuffersize > 20) { - abuffer = PyObject_Malloc(abuffersize); + abuffer = (char *)PyObject_Malloc(abuffersize); if (!abuffer) { PyErr_NoMemory(); goto fail; @@ -4259,7 +4254,7 @@ } /* Create a three-level trie */ - result = PyObject_MALLOC(sizeof(struct encoding_map) + + result = (PyObject *)PyObject_MALLOC(sizeof(struct encoding_map) + 16*count2 + 128*count3 - 1); if (!result) return PyErr_NoMemory(); @@ -9064,12 +9059,6 @@ } (void)PyUnicode_ClearFreeList(); } - -#ifdef __cplusplus -} -#endif - - /* Local variables: c-basic-offset: 4 Index: Objects/descrobject.c =================================================================== --- Objects/descrobject.c (revision 68185) +++ Objects/descrobject.c (working copy) @@ -1212,8 +1212,8 @@ PyObject *doc) { propertyobject *pold = (propertyobject *)old; - propertyobject *pnew = NULL; - PyObject *new, *type; + propertyobject *pres = NULL; + PyObject *res, *type; type = PyObject_Type(old); if (type == NULL) @@ -1236,23 +1236,23 @@ doc = pold->prop_doc ? pold->prop_doc : Py_None; } - new = PyObject_CallFunction(type, "OOOO", get, set, del, doc); + res = PyObject_CallFunction(type, "OOOO", get, set, del, doc); Py_DECREF(type); - if (new == NULL) + if (res == NULL) return NULL; - pnew = (propertyobject *)new; + pres = (propertyobject *)res; if (pold->getter_doc && get != Py_None) { PyObject *get_doc = PyObject_GetAttrString(get, "__doc__"); if (get_doc != NULL) { - Py_XDECREF(pnew->prop_doc); - pnew->prop_doc = get_doc; /* get_doc already INCREF'd by GetAttr */ - pnew->getter_doc = 1; + Py_XDECREF(pres->prop_doc); + pres->prop_doc = get_doc; /* get_doc already INCREF'd by GetAttr */ + pres->getter_doc = 1; } else { PyErr_Clear(); } } - return new; + return res; } static int Index: Objects/fileobject.c =================================================================== --- Objects/fileobject.c (revision 68185) +++ Objects/fileobject.c (working copy) @@ -3,6 +3,7 @@ #define PY_SSIZE_T_CLEAN #include "Python.h" #include "structmember.h" +#include #ifdef HAVE_SYS_TYPES_H #include @@ -72,10 +73,6 @@ fobj->unlocked_count--; \ assert(fobj->unlocked_count >= 0); -#ifdef __cplusplus -extern "C" { -#endif - FILE * PyFile_AsFile(PyObject *f) { @@ -243,7 +240,7 @@ assert(f->f_fp == NULL); /* probably need to replace 'U' by 'rb' */ - newmode = PyMem_MALLOC(strlen(mode) + 3); + newmode = (char *)PyMem_MALLOC(strlen(mode) + 3); if (!newmode) { PyErr_NoMemory(); return NULL; @@ -392,7 +389,6 @@ PyObject * PyFile_FromString(char *name, char *mode) { - extern int fclose(FILE *); PyFileObject *f; f = (PyFileObject *)PyFile_FromFile((FILE *)NULL, name, mode, fclose); @@ -1025,7 +1021,7 @@ return err_iterbuffered(); if (!PyArg_ParseTuple(args, "w*", &pbuf)) return NULL; - ptr = pbuf.buf; + ptr = (char *)pbuf.buf; ntodo = pbuf.len; ndone = 0; while (ntodo > 0) { @@ -1631,7 +1627,7 @@ if (f->f_binary) { if (!PyArg_ParseTuple(args, "s*", &pbuf)) return NULL; - s = pbuf.buf; + s = (char *)pbuf.buf; n = pbuf.len; } else if (!PyArg_ParseTuple(args, "t#", &s, &n)) @@ -1974,7 +1970,7 @@ static int set_softspace(PyFileObject *f, PyObject *value) { - int new; + int ival; if (PyErr_WarnPy3k("file.softspace not supported in 3.x", 1) < 0) return -1; @@ -1984,10 +1980,10 @@ return -1; } - new = PyInt_AsLong(value); - if (new == -1 && PyErr_Occurred()) + ival = PyInt_AsLong(value); + if (ival == -1 && PyErr_Occurred()) return -1; - f->f_softspace = new; + f->f_softspace = ival; return 0; } @@ -2343,7 +2339,7 @@ if ((flags & Py_PRINT_RAW) && PyUnicode_Check(v) && enc != Py_None) { char *cenc = PyString_AS_STRING(enc); - char *errors = fobj->f_errors == Py_None ? + const char *errors = fobj->f_errors == Py_None ? "strict" : PyString_AS_STRING(fobj->f_errors); value = PyUnicode_AsEncodedString(v, cenc, errors); if (value == NULL) @@ -2659,7 +2655,3 @@ f->f_skipnextlf = skipnextlf; return dst - buf; } - -#ifdef __cplusplus -} -#endif Index: Objects/frameobject.c =================================================================== --- Objects/frameobject.c (revision 68185) +++ Objects/frameobject.c (working copy) @@ -33,16 +33,16 @@ } \ Py_RETURN_NONE; \ } \ -static int frame_set_ ## NAME(PyFrameObject *f, PyObject *new) { \ +static int frame_set_ ## NAME(PyFrameObject *f, PyObject *newobj) { \ if (PyErr_WarnPy3k(#NAME " has been removed in 3.x", 2) < 0) \ return -1; \ if (f->NAME) { \ Py_CLEAR(f->NAME); \ } \ - if (new == Py_None) \ - new = NULL; \ - Py_XINCREF(new); \ - f->NAME = new; \ + if (newobj == Py_None) \ + newobj = NULL; \ + Py_XINCREF(newobj); \ + f->NAME = newobj; \ return 0; \ } @@ -654,7 +654,7 @@ Py_INCREF(builtins); } if (code->co_zombieframe != NULL) { - f = code->co_zombieframe; + f = (PyFrameObject *)code->co_zombieframe; code->co_zombieframe = NULL; _Py_NewReference((PyObject *)f); assert(f->f_code == code); Index: Objects/exceptions.c =================================================================== --- Objects/exceptions.c (revision 68185) +++ Objects/exceptions.c (working copy) @@ -1150,7 +1150,7 @@ if (have_filename) bufsize += PyString_GET_SIZE(self->filename); - buffer = PyMem_MALLOC(bufsize); + buffer = (char *)PyMem_MALLOC(bufsize); if (buffer == NULL) return str; Index: Objects/longobject.c =================================================================== --- Objects/longobject.c (revision 68185) +++ Objects/longobject.c (working copy) @@ -1874,7 +1874,7 @@ carry += v->ob_digit[i+k] - z + ((twodigits)zz << PyLong_SHIFT); v->ob_digit[i+k] = (digit)(carry & PyLong_MASK); - carry = Py_ARITHMETIC_RIGHT_SHIFT(PyLong_BASE_TWODIGITS_TYPE, + carry = Py_ARITHMETIC_RIGHT_SHIFT(stwodigits, carry, PyLong_SHIFT); carry -= zz; } @@ -1894,7 +1894,7 @@ carry += v->ob_digit[i+k] + w->ob_digit[i]; v->ob_digit[i+k] = (digit)(carry & PyLong_MASK); carry = Py_ARITHMETIC_RIGHT_SHIFT( - PyLong_BASE_TWODIGITS_TYPE, + stwodigits, carry, PyLong_SHIFT); } } Index: Objects/bytearrayobject.c =================================================================== --- Objects/bytearrayobject.c (revision 68185) +++ Objects/bytearrayobject.c (working copy) @@ -114,7 +114,7 @@ bytes_getbuffer(PyByteArrayObject *obj, Py_buffer *view, int flags) { int ret; - void *ptr; + char *ptr; if (view == NULL) { obj->ob_exports++; return 0; @@ -177,7 +177,7 @@ PyObject * PyByteArray_FromStringAndSize(const char *bytes, Py_ssize_t size) { - PyByteArrayObject *new; + PyByteArrayObject *newobj; Py_ssize_t alloc; if (size < 0) { @@ -186,30 +186,30 @@ return NULL; } - new = PyObject_New(PyByteArrayObject, &PyByteArray_Type); - if (new == NULL) + newobj = PyObject_New(PyByteArrayObject, &PyByteArray_Type); + if (newobj == NULL) return NULL; if (size == 0) { - new->ob_bytes = NULL; + newobj->ob_bytes = NULL; alloc = 0; } else { alloc = size + 1; - new->ob_bytes = PyMem_Malloc(alloc); - if (new->ob_bytes == NULL) { - Py_DECREF(new); + newobj->ob_bytes = (char *)PyMem_Malloc(alloc); + if (newobj->ob_bytes == NULL) { + Py_DECREF(newobj); return PyErr_NoMemory(); } if (bytes != NULL) - memcpy(new->ob_bytes, bytes, size); - new->ob_bytes[size] = '\0'; /* Trailing null byte */ + memcpy(newobj->ob_bytes, bytes, size); + newobj->ob_bytes[size] = '\0'; /* Trailing null byte */ } - Py_SIZE(new) = size; - new->ob_alloc = alloc; - new->ob_exports = 0; + Py_SIZE(newobj) = size; + newobj->ob_alloc = alloc; + newobj->ob_exports = 0; - return (PyObject *)new; + return (PyObject *)newobj; } Py_ssize_t @@ -272,7 +272,7 @@ return -1; } - ((PyByteArrayObject *)self)->ob_bytes = sval; + ((PyByteArrayObject *)self)->ob_bytes = (char *)sval; Py_SIZE(self) = size; ((PyByteArrayObject *)self)->ob_alloc = alloc; ((PyByteArrayObject *)self)->ob_bytes[size] = '\0'; /* Trailing null byte */ @@ -784,7 +784,7 @@ } if (PyBytes_Check(arg)) { - PyObject *new, *encoded; + PyObject *newobj, *encoded; if (encoding != NULL) { encoded = PyCodec_Encode(arg, encoding, errors); if (encoded == NULL) @@ -795,17 +795,17 @@ encoded = arg; Py_INCREF(arg); } - new = bytes_iconcat(self, arg); + newobj = bytes_iconcat(self, arg); Py_DECREF(encoded); - if (new == NULL) + if (newobj == NULL) return -1; - Py_DECREF(new); + Py_DECREF(newobj); return 0; } if (PyUnicode_Check(arg)) { /* Encode via the codec registry */ - PyObject *encoded, *new; + PyObject *encoded, *newobj; if (encoding == NULL) { PyErr_SetString(PyExc_TypeError, "unicode argument without an encoding"); @@ -815,11 +815,11 @@ if (encoded == NULL) return -1; assert(PyBytes_Check(encoded)); - new = bytes_iconcat(self, encoded); + newobj = bytes_iconcat(self, encoded); Py_DECREF(encoded); - if (new == NULL) + if (newobj == NULL) return -1; - Py_DECREF(new); + Py_DECREF(newobj); return 0; } @@ -924,7 +924,7 @@ /* 14 == strlen(quote_prefix) + 2 + strlen(quote_postfix) */ size_t newsize = 14 + 4 * length; PyObject *v; - if (newsize > PY_SSIZE_T_MAX || newsize / 4 - 3 != length) { + if (newsize > (size_t)PY_SSIZE_T_MAX || newsize / 4 - 3 != (size_t)length) { PyErr_SetString(PyExc_OverflowError, "bytearray object is too large to make repr"); return NULL; @@ -1159,11 +1159,11 @@ if (dir > 0) res = stringlib_find_slice( PyByteArray_AS_STRING(self), PyByteArray_GET_SIZE(self), - subbuf.buf, subbuf.len, start, end); + (char *)subbuf.buf, subbuf.len, start, end); else res = stringlib_rfind_slice( PyByteArray_AS_STRING(self), PyByteArray_GET_SIZE(self), - subbuf.buf, subbuf.len, start, end); + (char *)subbuf.buf, subbuf.len, start, end); PyBuffer_Release(&subbuf); return res; } @@ -1212,7 +1212,7 @@ _adjust_indices(&start, &end, PyByteArray_GET_SIZE(self)); count_obj = PyInt_FromSsize_t( - stringlib_count(str + start, end - start, vsub.buf, vsub.len) + stringlib_count(str + start, end - start, (char *)vsub.buf, vsub.len) ); PyBuffer_Release(&vsub); return count_obj; @@ -1289,7 +1289,7 @@ if (_getbuffer(arg, &varg) < 0) return -1; pos = stringlib_find(PyByteArray_AS_STRING(self), Py_SIZE(self), - varg.buf, varg.len, 0); + (char *)varg.buf, varg.len, 0); PyBuffer_Release(&varg); return pos >= 0; } @@ -2140,8 +2140,8 @@ } res = (PyObject *)replace((PyByteArrayObject *) self, - vfrom.buf, vfrom.len, - vto.buf, vto.len, count); + (char *)vfrom.buf, vfrom.len, + (char *)vto.buf, vto.len, count); PyBuffer_Release(&vfrom); PyBuffer_Release(&vto); @@ -2295,7 +2295,7 @@ if (_getbuffer(subobj, &vsub) < 0) return NULL; - sub = vsub.buf; + sub = (char *)vsub.buf; n = vsub.len; if (n == 0) { @@ -2359,14 +2359,14 @@ assert(PyTuple_GET_SIZE(result) == 3); for (i = 0; i < 3; i++) { if (PyTuple_GET_ITEM(result, i) == (PyObject *)nullbytes) { - PyObject *new = PyByteArray_FromStringAndSize(NULL, 0); - if (new == NULL) { + PyObject *newobj = PyByteArray_FromStringAndSize(NULL, 0); + if (newobj == NULL) { Py_DECREF(result); result = NULL; break; } Py_DECREF(nullbytes); - PyTuple_SET_ITEM(result, i, new); + PyTuple_SET_ITEM(result, i, newobj); } } } @@ -2530,7 +2530,7 @@ if (_getbuffer(subobj, &vsub) < 0) return NULL; - sub = vsub.buf; + sub = (char *)vsub.buf; n = vsub.len; if (n == 0) { @@ -2828,22 +2828,22 @@ bytes_strip(PyByteArrayObject *self, PyObject *args) { Py_ssize_t left, right, mysize, argsize; - void *myptr, *argptr; + unsigned char *myptr, *argptr; PyObject *arg = Py_None; Py_buffer varg; if (!PyArg_ParseTuple(args, "|O:strip", &arg)) return NULL; if (arg == Py_None) { - argptr = "\t\n\r\f\v "; + argptr = (unsigned char *)"\t\n\r\f\v "; argsize = 6; } else { if (_getbuffer(arg, &varg) < 0) return NULL; - argptr = varg.buf; + argptr = (unsigned char *)varg.buf; argsize = varg.len; } - myptr = self->ob_bytes; + myptr = (unsigned char *)self->ob_bytes; mysize = Py_SIZE(self); left = lstrip_helper(myptr, mysize, argptr, argsize); if (left == mysize) @@ -2864,22 +2864,22 @@ bytes_lstrip(PyByteArrayObject *self, PyObject *args) { Py_ssize_t left, right, mysize, argsize; - void *myptr, *argptr; + unsigned char *myptr, *argptr; PyObject *arg = Py_None; Py_buffer varg; if (!PyArg_ParseTuple(args, "|O:lstrip", &arg)) return NULL; if (arg == Py_None) { - argptr = "\t\n\r\f\v "; + argptr = (unsigned char *)"\t\n\r\f\v "; argsize = 6; } else { if (_getbuffer(arg, &varg) < 0) return NULL; - argptr = varg.buf; + argptr = (unsigned char *)varg.buf; argsize = varg.len; } - myptr = self->ob_bytes; + myptr = (unsigned char *)self->ob_bytes; mysize = Py_SIZE(self); left = lstrip_helper(myptr, mysize, argptr, argsize); right = mysize; @@ -2897,22 +2897,22 @@ bytes_rstrip(PyByteArrayObject *self, PyObject *args) { Py_ssize_t left, right, mysize, argsize; - void *myptr, *argptr; + unsigned char *myptr, *argptr; PyObject *arg = Py_None; Py_buffer varg; if (!PyArg_ParseTuple(args, "|O:rstrip", &arg)) return NULL; if (arg == Py_None) { - argptr = "\t\n\r\f\v "; + argptr = (unsigned char *)"\t\n\r\f\v "; argsize = 6; } else { if (_getbuffer(arg, &varg) < 0) return NULL; - argptr = varg.buf; + argptr = (unsigned char *)varg.buf; argsize = varg.len; } - myptr = self->ob_bytes; + myptr = (unsigned char *)self->ob_bytes; mysize = Py_SIZE(self); left = 0; right = rstrip_helper(myptr, mysize, argptr, argsize); Index: Parser/tokenizer.c =================================================================== --- Parser/tokenizer.c (revision 68185) +++ Parser/tokenizer.c (working copy) @@ -1611,7 +1611,7 @@ if (lineobj != NULL) { int linelen = PyString_Size(lineobj); const char *line = PyString_AsString(lineobj); - text = PyObject_MALLOC(linelen + 1); + text = (char *)PyObject_MALLOC(linelen + 1); if (text != NULL && line != NULL) { if (linelen) strncpy(text, line, linelen); Index: Modules/signalmodule.c =================================================================== --- Modules/signalmodule.c (revision 68185) +++ Modules/signalmodule.c (working copy) @@ -400,20 +400,20 @@ double first; double interval = 0; int which; - struct itimerval new, old; + struct itimerval newval, oldval; if(!PyArg_ParseTuple(args, "id|d:setitimer", &which, &first, &interval)) return NULL; - timeval_from_double(first, &new.it_value); - timeval_from_double(interval, &new.it_interval); + timeval_from_double(first, &newval.it_value); + timeval_from_double(interval, &newval.it_interval); /* Let OS check "which" value */ - if (setitimer(which, &new, &old) != 0) { + if (setitimer(which, &newval, &oldval) != 0) { PyErr_SetFromErrno(ItimerError); return NULL; } - return itimer_retval(&old); + return itimer_retval(&oldval); } PyDoc_STRVAR(setitimer_doc, Index: Modules/main.c =================================================================== --- Modules/main.c (revision 68185) +++ Modules/main.c (working copy) @@ -31,9 +31,6 @@ "Type \"help\", \"copyright\", \"credits\" or \"license\" " \ "for more information." -#ifdef __cplusplus -extern "C" { -#endif /* For Py_GetArgcArgv(); set by main() */ static char **orig_argv; @@ -655,8 +652,3 @@ *argc = orig_argc; *argv = orig_argv; } - -#ifdef __cplusplus -} -#endif - Index: Modules/getpath.c =================================================================== --- Modules/getpath.c (revision 68185) +++ Modules/getpath.c (working copy) @@ -1,6 +1,7 @@ /* Return the initial module search path. */ #include "Python.h" +#include "pythonrun.h" #include "osdefs.h" #include @@ -91,11 +92,6 @@ * process to find the installed Python tree. */ -#ifdef __cplusplus - extern "C" { -#endif - - #ifndef VERSION #define VERSION "2.1" #endif @@ -366,8 +362,6 @@ static void calculate_path(void) { - extern char *Py_GetProgramName(void); - static char delimiter[2] = {DELIM, '\0'}; static char separator[2] = {SEP, '\0'}; char *pythonpath = PYTHONPATH; @@ -686,9 +680,3 @@ calculate_path(); return progpath; } - - -#ifdef __cplusplus -} -#endif - Index: Modules/_codecsmodule.c =================================================================== --- Modules/_codecsmodule.c (revision 68185) +++ Modules/_codecsmodule.c (working copy) @@ -243,7 +243,7 @@ return NULL; consumed = pbuf.len; - decoded = PyUnicode_DecodeUTF7Stateful(pbuf.buf, pbuf.len, errors, + decoded = PyUnicode_DecodeUTF7Stateful((char *)pbuf.buf, pbuf.len, errors, final ? NULL : &consumed); PyBuffer_Release(&pbuf); if (decoded == NULL) @@ -266,7 +266,7 @@ return NULL; consumed = pbuf.len; - decoded = PyUnicode_DecodeUTF8Stateful(pbuf.buf, pbuf.len, errors, + decoded = PyUnicode_DecodeUTF8Stateful((char *)pbuf.buf, pbuf.len, errors, final ? NULL : &consumed); PyBuffer_Release(&pbuf); if (decoded == NULL) @@ -289,7 +289,7 @@ &pbuf, &errors, &final)) return NULL; consumed = pbuf.len; /* This is overwritten unless final is true. */ - decoded = PyUnicode_DecodeUTF16Stateful(pbuf.buf, pbuf.len, errors, + decoded = PyUnicode_DecodeUTF16Stateful((char *)pbuf.buf, pbuf.len, errors, &byteorder, final ? NULL : &consumed); PyBuffer_Release(&pbuf); if (decoded == NULL) @@ -313,7 +313,7 @@ return NULL; consumed = pbuf.len; /* This is overwritten unless final is true. */ - decoded = PyUnicode_DecodeUTF16Stateful(pbuf.buf, pbuf.len, errors, + decoded = PyUnicode_DecodeUTF16Stateful((char *)pbuf.buf, pbuf.len, errors, &byteorder, final ? NULL : &consumed); PyBuffer_Release(&pbuf); if (decoded == NULL) @@ -337,7 +337,7 @@ return NULL; consumed = pbuf.len; /* This is overwritten unless final is true. */ - decoded = PyUnicode_DecodeUTF16Stateful(pbuf.buf, pbuf.len, errors, + decoded = PyUnicode_DecodeUTF16Stateful((char *)pbuf.buf, pbuf.len, errors, &byteorder, final ? NULL : &consumed); PyBuffer_Release(&pbuf); if (decoded == NULL) @@ -368,7 +368,7 @@ &pbuf, &errors, &byteorder, &final)) return NULL; consumed = pbuf.len; /* This is overwritten unless final is true. */ - unicode = PyUnicode_DecodeUTF16Stateful(pbuf.buf, pbuf.len, errors, + unicode = PyUnicode_DecodeUTF16Stateful((char *)pbuf.buf, pbuf.len, errors, &byteorder, final ? NULL : &consumed); PyBuffer_Release(&pbuf); if (unicode == NULL) @@ -393,7 +393,7 @@ &pbuf, &errors, &final)) return NULL; consumed = pbuf.len; /* This is overwritten unless final is true. */ - decoded = PyUnicode_DecodeUTF32Stateful(pbuf.buf, pbuf.len, errors, + decoded = PyUnicode_DecodeUTF32Stateful((char *)pbuf.buf, pbuf.len, errors, &byteorder, final ? NULL : &consumed); PyBuffer_Release(&pbuf); if (decoded == NULL) @@ -416,7 +416,7 @@ &pbuf, &errors, &final)) return NULL; consumed = pbuf.len; /* This is overwritten unless final is true. */ - decoded = PyUnicode_DecodeUTF32Stateful(pbuf.buf, pbuf.len, errors, + decoded = PyUnicode_DecodeUTF32Stateful((char *)pbuf.buf, pbuf.len, errors, &byteorder, final ? NULL : &consumed); PyBuffer_Release(&pbuf); if (decoded == NULL) @@ -439,7 +439,7 @@ &pbuf, &errors, &final)) return NULL; consumed = pbuf.len; /* This is overwritten unless final is true. */ - decoded = PyUnicode_DecodeUTF32Stateful(pbuf.buf, pbuf.len, errors, + decoded = PyUnicode_DecodeUTF32Stateful((char *)pbuf.buf, pbuf.len, errors, &byteorder, final ? NULL : &consumed); PyBuffer_Release(&pbuf); if (decoded == NULL) @@ -470,7 +470,7 @@ &pbuf, &errors, &byteorder, &final)) return NULL; consumed = pbuf.len; /* This is overwritten unless final is true. */ - unicode = PyUnicode_DecodeUTF32Stateful(pbuf.buf, pbuf.len, errors, + unicode = PyUnicode_DecodeUTF32Stateful((char *)pbuf.buf, pbuf.len, errors, &byteorder, final ? NULL : &consumed); PyBuffer_Release(&pbuf); if (unicode == NULL) @@ -492,7 +492,7 @@ &pbuf, &errors)) return NULL; - unicode = PyUnicode_DecodeUnicodeEscape(pbuf.buf, pbuf.len, errors); + unicode = PyUnicode_DecodeUnicodeEscape((char *)pbuf.buf, pbuf.len, errors); PyBuffer_Release(&pbuf); return codec_tuple(unicode, pbuf.len); } @@ -509,7 +509,7 @@ &pbuf, &errors)) return NULL; - unicode = PyUnicode_DecodeRawUnicodeEscape(pbuf.buf, pbuf.len, errors); + unicode = PyUnicode_DecodeRawUnicodeEscape((char *)pbuf.buf, pbuf.len, errors); PyBuffer_Release(&pbuf); return codec_tuple(unicode, pbuf.len); } @@ -526,7 +526,7 @@ &pbuf, &errors)) return NULL; - unicode = PyUnicode_DecodeLatin1(pbuf.buf, pbuf.len, errors); + unicode = PyUnicode_DecodeLatin1((char *)pbuf.buf, pbuf.len, errors); PyBuffer_Release(&pbuf); return codec_tuple(unicode, pbuf.len); } @@ -543,7 +543,7 @@ &pbuf, &errors)) return NULL; - unicode = PyUnicode_DecodeASCII(pbuf.buf, pbuf.len, errors); + unicode = PyUnicode_DecodeASCII((char *)pbuf.buf, pbuf.len, errors); PyBuffer_Release(&pbuf); return codec_tuple(unicode, pbuf.len); } @@ -563,7 +563,7 @@ if (mapping == Py_None) mapping = NULL; - unicode = PyUnicode_DecodeCharmap(pbuf.buf, pbuf.len, mapping, errors); + unicode = PyUnicode_DecodeCharmap((char *)pbuf.buf, pbuf.len, mapping, errors); PyBuffer_Release(&pbuf); return codec_tuple(unicode, pbuf.len); } Index: Modules/posixmodule.c =================================================================== --- Modules/posixmodule.c (revision 68185) +++ Modules/posixmodule.c (working copy) @@ -34,10 +34,6 @@ # include #endif /* defined(__VMS) */ -#ifdef __cplusplus -extern "C" { -#endif - PyDoc_STRVAR(posix__doc__, "This module provides access to operating system functionality that is\n\ standardized by the C Standard and the POSIX standard (a thinly\n\ @@ -1960,7 +1956,8 @@ Py_BEGIN_ALLOW_THREADS do { bufsize = bufsize + bufsize_incr; - tmpbuf = malloc(bufsize); + /* XXX: Why not PyMem_MALLOC ? */ + tmpbuf = (char *)malloc(bufsize); if (tmpbuf == NULL) { break; } @@ -6409,7 +6406,7 @@ return NULL; /* Sanitize mode. See fileobject.c */ - mode = PyMem_MALLOC(strlen(orgmode)+3); + mode = (char *)PyMem_MALLOC(strlen(orgmode)+3); if (!mode) { PyErr_NoMemory(); return NULL; @@ -9016,9 +9013,3 @@ #endif /* __APPLE__ */ } - -#ifdef __cplusplus -} -#endif - -