[issue36111] Negative `offset` values are no longer acceptable with implementation of `seek` with python3; should be per POSIX

2019-02-25 Thread Enji Cooper
Enji Cooper added the comment: ?! Being blunt: why should opening a file in binary vs text mode matter? POSIX doesn't make this distinction. Per the pydoc (https://docs.python.org/2/library/functions.html#open): > The default is to use text mode, which may convert '\n' characters to a > pl

[issue36111] Negative `offset` values are no longer acceptable with implementation of `seek` with python3; should be per POSIX

2019-02-25 Thread Steven D'Aprano
Steven D'Aprano added the comment: I believe you will find that this is because you opened the file in text mode, which means Unicode, not bytes. If you open it in binary mode, the POSIX spec applies: py> fp = open("sample", "rb"); fp.seek(-100, os.SEEK_END) 350 Supported values for seeking

[issue36111] Negative `offset` values are no longer acceptable with implementation of `seek` with python3; should be per POSIX

2019-02-25 Thread Enji Cooper
New submission from Enji Cooper : I tried using os.SEEK_END in a technical interview, but unfortunately, that didn't work with python 3.x: pinklady:cpython ngie$ python3 Python 3.7.2 (default, Feb 12 2019, 08:15:36) [Clang 10.0.0 (clang-1000.11.45.5)] on darwin Type "help", "copyright", "cred