New submission from Jamil Raichouni <raicho...@gmail.com>:
import fileinput from pathlib import Path path = Path(252 * "x") path.write_text("") for line in fileinput.input(path, inplace=True): pass raises an OSError: [Errno 63] File name too long for perfectly valid (yes, quite long) file names. Reason: Internally the fileinput library creates a backup file when we pass 'inplace=True' to fileinput.input() and that backup file gets a file name that is longer than the name for the file of interest. Enhancement idea: Work with a backup file name that is sth like GUID.bak or remove some chars from the original file name. Hint: vim /path/to/my/file creates a .swp file and can handle very long file names with 252-255 chars. ---------- components: Library (Lib) files: long_filename_passed_to_fileinput.ipynb messages: 407534 nosy: jamil.raichouni priority: normal severity: normal status: open title: fileinput.input(path, inplace=True) crashes for valid filename with 252-255 characters type: enhancement versions: Python 3.10 Added file: https://bugs.python.org/file50471/long_filename_passed_to_fileinput.ipynb _______________________________________ Python tracker <rep...@bugs.python.org> <https://bugs.python.org/issue45965> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com