You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
fileinput inplace does not work with pathlib.Path #75462
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
assignee='https://github.com/ericvsmith'closed_at=<Date2017-09-04.18:15:28.145>created_at=<Date2017-08-26.01:50:52.589>labels= ['3.7', 'type-bug', 'library']
title='fileinput inplace does not work with pathlib.Path'updated_at=<Date2017-09-04.18:15:28.143>user='https://github.com/zmwangx'
Activity
zmwangx commentedon Aug 26, 2017
Consider
which results in
Traceback (most recent call last): File "./pathlib-fileinput.py", line 6, in <module> for line in fp: File "/Users/zmwang/.pyenv/versions/3.6.1/lib/python3.6/fileinput.py", line 250, in __next__ line = self._readline() File "/Users/zmwang/.pyenv/versions/3.6.1/lib/python3.6/fileinput.py", line 331, in _readline self._filename + (self._backup or ".bak")) TypeError: unsupported operand type(s) for +: 'PosixPath' and 'str'A trivial fix is converting the specified filename to str when assigning to self._filename:
ericvsmith commentedon Sep 4, 2017
New changeset 06de1ae by ericvsmith (Zhiming Wang) in branch 'master':
bpo-31281: Fix pathlib.Path incompatibility in fileinput (gh-3208)
06de1ae
ericvsmith commentedon Sep 4, 2017
I did not backport this to 3.6, because it depends on other changes that themselves have not been backported.