path converter#1148
Conversation
|
WIP for:
|
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
|
missing tests when path is a bytes instead of str. |
|
@SoniEx2, when does that happen? |
|
POSIX. |
|
|
|
but paths aren't always valid unicode. how is that handled by click? I just looked and paths can still be bytes, or at least the documentation still says so. |
|
@SoniEx2 as in my example you ignored in #python... surrogate escapes afaik. print(os.fspath(pathlib.Path(b'foo\xff\xff\xff\xfd\xfd\xfd'.decode(errors='surrogateescape')))) |
|
Well, https://docs.python.org/3/library/sys.html#sys.argv |
|
It's Python, not Click, that is treating
Based on this, it sounds like Click doesn't need to do anything extra. Python's file operations work with Python's argv handling. |
|
that's for File, not Path. Path still claims "str or bytes". |
|
That's an issue with the docs, not with Click. The docs were very focused on Python 2, which is what had the difference in this case. Fairly sure I updated them in master already. Also, that's totally tangential to this PR, which is only about passing whatever we were already getting to a converter, mainly to work with pathlib. Nothing you've commented so far seems to indicate there's an issue with that. |
|
the PR just grabs the former result and optionally wraps it. since the former result can be bytes (according to the docs in master), this could be a problem. |
|
I think we're going in circles. If you have an issue with this PR that can be addressed by Click, in this PR, you need to provide a concrete example or reference to what you're referring to. The fact that pathlib doesn't accept bytes, even though the filesystem may be bytes, is an issue (or design decision) of pathlib. There's nothing Click can do about it, all it sees is a function (not necessarily |
|
@SoniEx2 since you already found something you think is a problem, could you link it so we know where you found it? We like to fix things (well I do, I presume @davidism does as well...) but it's a pain to have to dig up what you claim is wrong when you haven't even said what docs you have a problem with. |
|
... meh. I think the problem is that click.Path and pathlib.Path are both called Path tbh. but just taking the return value of click.Path and passing it to pathlib.Path, when click.Path is documented (in master) as returning bytes sometimes, sounds like a recipe for disaster. |
|
@SoniEx2 'master' is a big space. Where is the documentation? Unlike your system GitHub allows you to link to specific lines of code. Use that feature. Let us know where the problem is. I'm not questioning whether an issue exists but I know it's easy to miss stuff. Another PR here I worked on involved at least three different ways a thing was implemented/documented... lots of confusion there as people said 'it says x' and someone else said 'it says y' and another said 'it does z' and all were correct. So, what exactly are you talking about? What line of documentation in what file? |
fixes #405