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)
........
diff --git a/Modules/_bytesio.c b/Modules/_bytesio.c
index c5c14b3..d342838 100644
--- a/Modules/_bytesio.c
+++ b/Modules/_bytesio.c
@@ -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;
     }