diff -r 6a3e09cd96f3 Modules/_datetimemodule.c --- a/Modules/_datetimemodule.c Fri Nov 29 12:19:53 2013 +0200 +++ b/Modules/_datetimemodule.c Fri Nov 29 19:30:16 2013 +0200 @@ -4763,7 +4763,7 @@ if (seconds == NULL) goto error; Py_DECREF(delta); - timestamp = PyLong_AsLong(seconds); + timestamp = _PyLong_AsTime_t(seconds); Py_DECREF(seconds); if (timestamp == -1 && PyErr_Occurred()) return NULL; diff -r 6a3e09cd96f3 Modules/_io/_iomodule.c --- a/Modules/_io/_iomodule.c Fri Nov 29 12:19:53 2013 +0200 +++ b/Modules/_io/_iomodule.c Fri Nov 29 19:30:16 2013 +0200 @@ -233,7 +233,8 @@ int text = 0, binary = 0, universal = 0; char rawmode[6], *m; - int line_buffering, isatty; + int line_buffering; + long isatty; PyObject *raw, *modeobj = NULL, *buffer = NULL, *wrapper = NULL; @@ -382,12 +383,12 @@ #ifdef HAVE_STRUCT_STAT_ST_BLKSIZE { struct stat st; - long fileno; + int fileno; PyObject *res = _PyObject_CallMethodId(raw, &PyId_fileno, NULL); if (res == NULL) goto error; - fileno = PyLong_AsLong(res); + fileno = _PyLong_AsInt(res); Py_DECREF(res); if (fileno == -1 && PyErr_Occurred()) goto error; diff -r 6a3e09cd96f3 Modules/posixmodule.c --- a/Modules/posixmodule.c Fri Nov 29 12:19:53 2013 +0200 +++ b/Modules/posixmodule.c Fri Nov 29 19:30:16 2013 +0200 @@ -9317,7 +9317,7 @@ */ struct constdef { char *name; - long value; + int value; }; static int @@ -9325,7 +9325,10 @@ size_t tablesize) { if (PyLong_Check(arg)) { - *valuep = PyLong_AS_LONG(arg); + int value = _PyLong_AsInt(arg); + if (value == -1 && PyErr_Occurred()) + return 0; + *valuep = value; return 1; } else { diff -r 6a3e09cd96f3 Modules/readline.c --- a/Modules/readline.c Fri Nov 29 12:19:53 2013 +0200 +++ b/Modules/readline.c Fri Nov 29 19:30:16 2013 +0200 @@ -800,7 +800,7 @@ if (r == Py_None) result = 0; else { - result = PyLong_AsLong(r); + result = _PyLong_AsInt(r); if (result == -1 && PyErr_Occurred()) goto error; } diff -r 6a3e09cd96f3 Modules/selectmodule.c --- a/Modules/selectmodule.c Fri Nov 29 12:19:53 2013 +0200 +++ b/Modules/selectmodule.c Fri Nov 29 19:30:16 2013 +0200 @@ -827,7 +827,7 @@ struct dvpoll dvp; PyObject *result_list = NULL, *tout = NULL; int poll_result, i; - long timeout; + int timeout; PyObject *value, *num1, *num2; if (self->fd_devpoll < 0) @@ -849,16 +849,15 @@ tout = PyNumber_Long(tout); if (!tout) return NULL; - timeout = PyLong_AsLong(tout); + timeout = _PyLong_AsInt(tout); Py_DECREF(tout); if (timeout == -1 && PyErr_Occurred()) return NULL; - } - - if ((timeout < -1) || (timeout > INT_MAX)) { - PyErr_SetString(PyExc_OverflowError, - "timeout is out of range"); - return NULL; + if (timeout < -1) { + PyErr_SetString(PyExc_OverflowError, + "timeout is out of range"); + return NULL; + } } if (devpoll_flush(self)) diff -r 6a3e09cd96f3 Objects/structseq.c --- a/Objects/structseq.c Fri Nov 29 12:19:53 2013 +0200 +++ b/Objects/structseq.c Fri Nov 29 19:30:16 2013 +0200 @@ -16,14 +16,14 @@ _Py_IDENTIFIER(n_unnamed_fields); #define VISIBLE_SIZE(op) Py_SIZE(op) -#define VISIBLE_SIZE_TP(tp) PyLong_AsLong( \ +#define VISIBLE_SIZE_TP(tp) PyLong_AsSsize_t( \ _PyDict_GetItemId((tp)->tp_dict, &PyId_n_sequence_fields)) -#define REAL_SIZE_TP(tp) PyLong_AsLong( \ +#define REAL_SIZE_TP(tp) PyLong_AsSsize_t( \ _PyDict_GetItemId((tp)->tp_dict, &PyId_n_fields)) #define REAL_SIZE(op) REAL_SIZE_TP(Py_TYPE(op)) -#define UNNAMED_FIELDS_TP(tp) PyLong_AsLong( \ +#define UNNAMED_FIELDS_TP(tp) PyLong_AsSsize_t( \ _PyDict_GetItemId((tp)->tp_dict, &PyId_n_unnamed_fields)) #define UNNAMED_FIELDS(op) UNNAMED_FIELDS_TP(Py_TYPE(op)) @@ -164,7 +164,8 @@ #define TYPE_MAXSIZE 100 PyTypeObject *typ = Py_TYPE(obj); - int i, removelast = 0; + Py_ssize_t i; + int removelast = 0; Py_ssize_t len; char buf[REPR_BUFFER_SIZE]; char *endofbuf, *pbuf = buf; @@ -236,8 +237,7 @@ PyObject* tup = NULL; PyObject* dict = NULL; PyObject* result; - Py_ssize_t n_fields, n_visible_fields, n_unnamed_fields; - int i; + Py_ssize_t n_fields, n_visible_fields, n_unnamed_fields, i; n_fields = REAL_SIZE(self); n_visible_fields = VISIBLE_SIZE(self); @@ -325,7 +325,7 @@ { PyObject *dict; PyMemberDef* members; - int n_members, n_unnamed_members, i, k; + Py_ssize_t n_members, n_unnamed_members, i, k; PyObject *v; #ifdef Py_TRACE_REFS @@ -373,9 +373,9 @@ Py_INCREF(type); dict = type->tp_dict; -#define SET_DICT_FROM_INT(key, value) \ +#define SET_DICT_FROM_SIZE(key, value) \ do { \ - v = PyLong_FromLong((long) value); \ + v = PyLong_FromSsize_t(value); \ if (v == NULL) \ return -1; \ if (PyDict_SetItemString(dict, key, v) < 0) { \ @@ -385,9 +385,9 @@ Py_DECREF(v); \ } while (0) - SET_DICT_FROM_INT(visible_length_key, desc->n_in_sequence); - SET_DICT_FROM_INT(real_length_key, n_members); - SET_DICT_FROM_INT(unnamed_fields_key, n_unnamed_members); + SET_DICT_FROM_SIZE(visible_length_key, desc->n_in_sequence); + SET_DICT_FROM_SIZE(real_length_key, n_members); + SET_DICT_FROM_SIZE(unnamed_fields_key, n_unnamed_members); return 0; } diff -r 6a3e09cd96f3 Python/Python-ast.c --- a/Python/Python-ast.c Fri Nov 29 12:19:53 2013 +0200 +++ b/Python/Python-ast.c Fri Nov 29 19:30:16 2013 +0200 @@ -750,7 +750,7 @@ return 1; } - i = (int)PyLong_AsLong(obj); + i = _PyLong_AsInt(obj); if (i == -1 && PyErr_Occurred()) return 1; *out = i; diff -r 6a3e09cd96f3 Python/pythonrun.c --- a/Python/pythonrun.c Fri Nov 29 12:19:53 2013 +0200 +++ b/Python/pythonrun.c Fri Nov 29 19:30:16 2013 +0200 @@ -1641,7 +1641,7 @@ parse_syntax_error(PyObject *err, PyObject **message, PyObject **filename, int *lineno, int *offset, PyObject **text) { - long hold; + int hold; PyObject *v; _Py_IDENTIFIER(msg); _Py_IDENTIFIER(filename); @@ -1674,11 +1674,11 @@ v = _PyObject_GetAttrId(err, &PyId_lineno); if (!v) goto finally; - hold = PyLong_AsLong(v); + hold = _PyLong_AsInt(v); Py_DECREF(v); if (hold < 0 && PyErr_Occurred()) goto finally; - *lineno = (int)hold; + *lineno = hold; v = _PyObject_GetAttrId(err, &PyId_offset); if (!v) @@ -1687,11 +1687,11 @@ *offset = -1; Py_DECREF(v); } else { - hold = PyLong_AsLong(v); + hold = _PyLong_AsInt(v); Py_DECREF(v); if (hold < 0 && PyErr_Occurred()) goto finally; - *offset = (int)hold; + *offset = hold; } v = _PyObject_GetAttrId(err, &PyId_text);