[Python-checkins] cpython (3.3): Issue #16304: Further optimize BZ2File.readlines?().
nadeem.vawda
python-checkins at python.org
Mon Oct 1 23:11:58 CEST 2012
http://hg.python.org/cpython/rev/6d7bf512e0c3
changeset: 79381:6d7bf512e0c3
branch: 3.3
user: Nadeem Vawda <nadeem.vawda at gmail.com>
date: Mon Oct 01 23:05:32 2012 +0200
summary:
Issue #16304: Further optimize BZ2File.readlines?().
files:
Lib/bz2.py | 14 ++++++++------
1 files changed, 8 insertions(+), 6 deletions(-)
diff --git a/Lib/bz2.py b/Lib/bz2.py
--- a/Lib/bz2.py
+++ b/Lib/bz2.py
@@ -319,9 +319,10 @@
non-negative, no more than size bytes will be read (in which
case the line may be incomplete). Returns b'' if already at EOF.
"""
- if not hasattr(size, "__index__"):
- raise TypeError("Integer argument expected")
- size = size.__index__()
+ if not isinstance(size, int):
+ if not hasattr(size, "__index__"):
+ raise TypeError("Integer argument expected")
+ size = size.__index__()
with self._lock:
self._check_can_read()
# Shortcut for the common case - the whole line is in the buffer.
@@ -341,9 +342,10 @@
further lines will be read once the total size of the lines read
so far equals or exceeds size.
"""
- if not hasattr(size, "__index__"):
- raise TypeError("Integer argument expected")
- size = size.__index__()
+ if not isinstance(size, int):
+ if not hasattr(size, "__index__"):
+ raise TypeError("Integer argument expected")
+ size = size.__index__()
with self._lock:
return io.BufferedIOBase.readlines(self, size)
--
Repository URL: http://hg.python.org/cpython
More information about the Python-checkins
mailing list