summaryrefslogtreecommitdiffstats
path: root/Modules/_io
diff options
context:
space:
mode:
authorJesus Cea <jcea@jcea.es>2012-04-26 15:05:31 (GMT)
committerJesus Cea <jcea@jcea.es>2012-04-26 15:05:31 (GMT)
commit990eff0776a948b4a45b1c2750552c0c6864b5c7 (patch)
tree76e8958258e5d8eea71c5659119825f6547dc253 /Modules/_io
parent2b47f0a23ffcb0cd86dc9eacf379fbd329b895c7 (diff)
downloadcpython-990eff0776a948b4a45b1c2750552c0c6864b5c7.zip
cpython-990eff0776a948b4a45b1c2750552c0c6864b5c7.tar.gz
cpython-990eff0776a948b4a45b1c2750552c0c6864b5c7.tar.bz2
Backing out 86dc014cdd74. Not ready yet
Diffstat (limited to 'Modules/_io')
-rw-r--r--Modules/_io/bufferedio.c21
1 files changed, 3 insertions, 18 deletions
diff --git a/Modules/_io/bufferedio.c b/Modules/_io/bufferedio.c
index dc723b1..8a9ae47 100644
--- a/Modules/_io/bufferedio.c
+++ b/Modules/_io/bufferedio.c
@@ -1157,20 +1157,9 @@ buffered_seek(buffered *self, PyObject *args)
if (!PyArg_ParseTuple(args, "O|i:seek", &targetobj, &whence)) {
return NULL;
}
-
- /* Do some error checking instead of trusting OS 'seek()'
- ** error detection, just in case.
- */
- if ((whence < 0 || whence >2)
-#ifdef SEEK_HOLE
- && (whence != SEEK_HOLE)
-#endif
-#ifdef SEEK_DATA
- && (whence != SEEK_DATA)
-#endif
- ) {
+ if (whence < 0 || whence > 2) {
PyErr_Format(PyExc_ValueError,
- "whence value %d unsupported", whence);
+ "whence must be between 0 and 2, not %d", whence);
return NULL;
}
@@ -1183,11 +1172,7 @@ buffered_seek(buffered *self, PyObject *args)
if (target == -1 && PyErr_Occurred())
return NULL;
- /* SEEK_SET and SEEK_CUR are special because we could seek inside the
- buffer. Other whence values must be managed without this optimization.
- Some Operating Systems can provide additional values, like
- SEEK_HOLE/SEEK_DATA. */
- if (((whence == 0) || (whence == 1)) && self->readable) {
+ if (whence != 2 && self->readable) {
Py_off_t current, avail;
/* Check if seeking leaves us inside the current buffer,
so as to return quickly if possible. Also, we needn't take the