Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Possible regression in 7.1: click.edit() no longer accepts Path objects for filename #1520

Closed
samueldg opened this issue Apr 1, 2020 · 2 comments
Milestone

Comments

@samueldg
Copy link

samueldg commented Apr 1, 2020

Expected Behavior

In click 7.0, you could pass a pathlib.Path object as click.edit()'s filename parameter. In 7.1 this fails with a TypeError

To reproduce, create a regression.py file like so:

import click
from pathlib import Path
click.edit(filename=Path('here.txt'))

With 7.0:

$ pip install 'click==7.0'
$ python regression.py
Press ENTER or type command to continue

(editor is actually launched)

Actual Behavior

With 7.1:

$ pip install 'click==7.1'
$ python regression.py
Traceback (most recent call last):
  File "regression.py", line 4, in <module>
    click.edit(filename=Path('here.txt'))
  File "/Users/samuel/workspace/tmp/click-regression/.venv/lib/python3.7/site-packages/click/termui.py", line 588, in edit
    editor.edit_file(filename)
  File "/Users/samuel/workspace/tmp/click-regression/.venv/lib/python3.7/site-packages/click/_termui_impl.py", line 466, in edit_file
    "{} {}".format(shlex_quote(editor), shlex_quote(filename)),
  File "/usr/local/Cellar/python/3.7.7/Frameworks/Python.framework/Versions/3.7/lib/python3.7/shlex.py", line 319, in quote
    if _find_unsafe(s) is None:
TypeError: expected string or bytes-like object

Although the ability to use Path wasn't documented explicitly, it seems desirable from a compatibility perspective.

Environment

  • Python version: Python 3.7.7
  • Click version: 7.1

Other

Based on the traceback, looks like it could be related to #1470

@davidism davidism added this to the 7.1.2 milestone Apr 13, 2020
@davidism
Copy link
Member

Duplicate of #1514

@davidism davidism marked this as a duplicate of #1514 Apr 20, 2020
@davidism
Copy link
Member

Click 7.1.2 is available on PyPI.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Nov 13, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants