summaryrefslogtreecommitdiffstats
path: root/Lib/_pyio.py
diff options
context:
space:
mode:
authorngie-eign <1574099+ngie-eign@users.noreply.github.com>2019-03-03 07:28:26 (GMT)
committerInada Naoki <songofacandy@gmail.com>2019-03-03 07:28:26 (GMT)
commit848037c1476ddf86dd2798fca35527a63c764a8a (patch)
tree3db7ffcabbc9549e0db1669d4d0f37a9c19dd847 /Lib/_pyio.py
parent8589f14bbe55fb1ff5c765af5281100c38f0df63 (diff)
downloadcpython-848037c1476ddf86dd2798fca35527a63c764a8a.zip
cpython-848037c1476ddf86dd2798fca35527a63c764a8a.tar.gz
cpython-848037c1476ddf86dd2798fca35527a63c764a8a.tar.bz2
Use names SEEK_SET, etc instead of magic number (GH-12057)
The previous code hardcoded `SEEK_SET`, etc. While it's very unlikely that these values will change, it's best to use the definitions to avoid there being mismatches in behavior with the code in the future. Signed-off-by: Enji Cooper <yaneurabeya@gmail.com>
Diffstat (limited to 'Lib/_pyio.py')
-rw-r--r--Lib/_pyio.py6
1 files changed, 3 insertions, 3 deletions
diff --git a/Lib/_pyio.py b/Lib/_pyio.py
index e4a8799..b0593c3 100644
--- a/Lib/_pyio.py
+++ b/Lib/_pyio.py
@@ -2386,18 +2386,18 @@ class TextIOWrapper(TextIOBase):
raise ValueError("tell on closed file")
if not self._seekable:
raise UnsupportedOperation("underlying stream is not seekable")
- if whence == 1: # seek relative to current position
+ if whence == SEEK_CUR:
if cookie != 0:
raise UnsupportedOperation("can't do nonzero cur-relative seeks")
# Seeking to the current position should attempt to
# sync the underlying buffer with the current position.
whence = 0
cookie = self.tell()
- if whence == 2: # seek relative to end of file
+ elif whence == SEEK_END:
if cookie != 0:
raise UnsupportedOperation("can't do nonzero end-relative seeks")
self.flush()
- position = self.buffer.seek(0, 2)
+ position = self.buffer.seek(0, whence)
self._set_decoded_chars('')
self._snapshot = None
if self._decoder: