[Python-checkins] r76073 - in python/branches/release26-maint: Lib/test/test_memoryio.py Misc/NEWS Modules/_bytesio.c
antoine.pitrou
python-checkins at python.org
Mon Nov 2 22:03:54 CET 2009
Author: antoine.pitrou
Date: Mon Nov 2 22:03:53 2009
New Revision: 76073
Log:
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)
........
Modified:
python/branches/release26-maint/ (props changed)
python/branches/release26-maint/Lib/test/test_memoryio.py
python/branches/release26-maint/Misc/NEWS
python/branches/release26-maint/Modules/_bytesio.c
Modified: python/branches/release26-maint/Lib/test/test_memoryio.py
==============================================================================
--- python/branches/release26-maint/Lib/test/test_memoryio.py (original)
+++ python/branches/release26-maint/Lib/test/test_memoryio.py Mon Nov 2 22:03:53 2009
@@ -80,6 +80,9 @@
self.assertEqual(memio.getvalue(), buf[:6])
self.assertEqual(memio.truncate(4), 4)
self.assertEqual(memio.getvalue(), buf[:4])
+ # truncate() accepts long objects
+ self.assertEqual(memio.truncate(4L), 4)
+ self.assertEqual(memio.getvalue(), buf[:4])
self.assertEqual(memio.tell(), 4)
memio.write(buf)
self.assertEqual(memio.getvalue(), buf[:4] + buf)
@@ -107,7 +110,8 @@
self.assertEqual(memio.read(0), self.EOF)
self.assertEqual(memio.read(1), buf[:1])
- self.assertEqual(memio.read(4), buf[1:5])
+ # read() accepts long objects
+ self.assertEqual(memio.read(4L), buf[1:5])
self.assertEqual(memio.read(900), buf[5:])
self.assertEqual(memio.read(), self.EOF)
memio.seek(0)
@@ -136,7 +140,8 @@
self.assertEqual(memio.readline(), self.EOF)
memio.seek(0)
self.assertEqual(memio.readline(5), buf[:5])
- self.assertEqual(memio.readline(5), buf[5:10])
+ # readline() accepts long objects
+ self.assertEqual(memio.readline(5L), buf[5:10])
self.assertEqual(memio.readline(5), buf[10:15])
memio.seek(0)
self.assertEqual(memio.readline(-1), buf)
@@ -164,7 +169,8 @@
memio.seek(5)
self.assertEqual(memio.readlines(), [buf[5:]] + [buf] * 9)
memio.seek(0)
- self.assertEqual(memio.readlines(15), [buf] * 2)
+ # readlines() accepts long objects
+ self.assertEqual(memio.readlines(15L), [buf] * 2)
memio.seek(0)
self.assertEqual(memio.readlines(-1), [buf] * 10)
memio.seek(0)
@@ -225,6 +231,8 @@
self.assertEqual(memio.seek(0, 0), 0)
self.assertEqual(memio.read(), buf)
self.assertEqual(memio.seek(3), 3)
+ # seek() accepts long objects
+ self.assertEqual(memio.seek(3L), 3)
self.assertEqual(memio.seek(0, 1), 3)
self.assertEqual(memio.read(), buf[3:])
self.assertEqual(memio.seek(len(buf)), len(buf))
Modified: python/branches/release26-maint/Misc/NEWS
==============================================================================
--- python/branches/release26-maint/Misc/NEWS (original)
+++ python/branches/release26-maint/Misc/NEWS Mon Nov 2 22:03:53 2009
@@ -24,6 +24,9 @@
Library
-------
+- Issue #7249: Methods of io.BytesIO now allow `long` as well as `int`
+ arguments.
+
- Issue #6665: Fix fnmatch to properly match filenames with newlines in them.
- Issue #1008086: Fixed socket.inet_aton() to always return 4 bytes even on
Modified: python/branches/release26-maint/Modules/_bytesio.c
==============================================================================
--- python/branches/release26-maint/Modules/_bytesio.c (original)
+++ python/branches/release26-maint/Modules/_bytesio.c Mon Nov 2 22:03:53 2009
@@ -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;
}
More information about the Python-checkins
mailing list