Python text files: f.seek(2, 1) raises "io.UnsupportedOperation: can't do nonzero cur-relative seeks"; f.tell() in a for loop raises "OSError: telling position disabled by next() call"
Files opened in text mode only support seeking to positions previously returned by tell() (opaque cookies), seek(0, 1) and seek(0, 2). f.seek(2, 1) raises io.UnsupportedOperation: can't do nonzero cur-relative seeks and f.seek(3, 2) raises can't do nonzero end-relative seeks. Calling f.tell() while iterating with for line in f raises OSError: telling position disabled by next() call. Also, open(path, 'w', buffering=0) fails with ValueError: can't have unbuffered text I/O. Code that tracks byte offsets for resumable log reading or indexing hits these. Fix: open in binary mode ('rb') when you need arbitrary offsets and decode lines yourself, or iterate with while line := f.readline(): so tell() keeps working. Same on Python 3.11.13, 3.12.12, 3.13.11 and 3.14.7.