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
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=Noneclosed_at=<Date2020-01-13.03:43:34.704>created_at=<Date2020-01-12.12:58:02.508>labels= ['library', '3.9']
title='difflib pathlike support for {unified,context}_diff() {from,to}file'updated_at=<Date2020-01-13.03:43:34.695>user='https://github.com/isidentical'
>>> tuple(difflib.context_diff(["abc"], ["bcd"], fromfile=Path("example.py")))
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python3.9/difflib.py", line 1254, in context_diff
_check_types(a, b, fromfile, tofile, fromfiledate, tofiledate, lineterm)
File "/usr/local/lib/python3.9/difflib.py", line 1301, in _check_types
raise TypeError('all arguments must be str, not: %r' % (arg,))
TypeError: all arguments must be str, not: PosixPath('example.py')
IMHO to and from file arguments should accept PathLike objects. If agreed I can prepare a patch.
Elsewhere users of Path objects must explicitly coerce to str. For example: json.dumps(str(Path("example.py"))). This makes good sense to me. We don't want to add an dependency on pathlib just to recognize Path objects.
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:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: