diff Modules/_bytesio.c @ 57083:6c13bf35d166 2.6

Issue #7249: Methods of io.BytesIO now allow `long` as well as `int` arguments. Merged revisions 76071 via svnmerge from svn+ssh://pythondev@svn.python.org/python/trunk ........ r76071 | antoine.pitrou | 2009-11-02 21:47:33 +0100 (lun., 02 nov. 2009) | 4 lines Add acceptance of long ints to test_memoryio.py (in preparation for fix of #7249 in 2.6) ........
author Antoine Pitrou <solipsis@pitrou.net>
date Mon, 02 Nov 2009 21:03:53 +0000
parents 6a73134f9603
children 0bd616dfc977
line wrap: on
line diff
--- a/Modules/_bytesio.c	Mon Nov 02 00:59:52 2009 +0000
+++ b/Modules/_bytesio.c	Mon Nov 02 21:03:53 2009 +0000
@@ -219,8 +219,8 @@
     if (!PyArg_ParseTuple(args, "|O:read", &arg))
         return NULL;
 
-    if (PyInt_Check(arg)) {
-        size = PyInt_AsSsize_t(arg);
+    if (PyIndex_Check(arg)) {
+        size = PyNumber_AsSsize_t(arg, PyExc_OverflowError);
         if (size == -1 && PyErr_Occurred())
             return NULL;
     }
@@ -288,8 +288,8 @@
     if (!PyArg_ParseTuple(args, "|O:readline", &arg))
         return NULL;
 
-    if (PyInt_Check(arg)) {
-        size = PyInt_AsSsize_t(arg);
+    if (PyIndex_Check(arg)) {
+        size = PyNumber_AsSsize_t(arg, PyExc_OverflowError);
         if (size == -1 && PyErr_Occurred())
             return NULL;
     }
@@ -334,8 +334,8 @@
     if (!PyArg_ParseTuple(args, "|O:readlines", &arg))
         return NULL;
 
-    if (PyInt_Check(arg)) {
-        maxsize = PyInt_AsSsize_t(arg);
+    if (PyIndex_Check(arg)) {
+        maxsize = PyNumber_AsSsize_t(arg, PyExc_OverflowError);
         if (maxsize == -1 && PyErr_Occurred())
             return NULL;
     }
@@ -419,8 +419,8 @@
     if (!PyArg_ParseTuple(args, "|O:truncate", &arg))
         return NULL;
 
-    if (PyInt_Check(arg)) {
-        size = PyInt_AsSsize_t(arg);
+    if (PyIndex_Check(arg)) {
+        size = PyNumber_AsSsize_t(arg, PyExc_OverflowError);
         if (size == -1 && PyErr_Occurred())
             return NULL;
     }