You know, after several years of following this list, and many more of programming in Python, I don't know if I ever realized that forum existed... or at least differed from the mailing lists. Thanks!
-Mitch On Sat, May 13, 2023 at 3:45 PM Barry <ba...@barrys-emacs.org> wrote: > > > On 12 May 2023, at 18:54, mitchell.negus...@gmail.com wrote: > > At the moment, `shlex.join` raises > > ``` > TypeError: expected string or bytes-like object > ``` > > when given `pathlib.Path` objects. Since `subprocess.run` and related > subprocess commands allow `Path` since Python 3.6 and 3.8 for Windows, it > seems intuitive to me that `shlex.join` be able to handle paths as well. > This has been briefly discussed before on the bug tracker (issue 89293, > link below), but with the caveat that it was the wrong venue, and should be > brought up on this list instead. That said, I can't find any record that it > ever made it over here, but I am curious to get this community's > perspective. > > My understanding of arguments against in that discussion were that > `shlex.join` should not implicitly convert its arguments to strings, and > that `Path` objects were not special enough for an exception. However (and > as noted over there), `subprocess` takes the exact opposite approach, and > has an explicit `isinstance` check to allow and convert `os.PathLike` > objects. I'm assuming that some of the reasoning behind allow > path-to-string conversions there has to do with the prevalence of using > paths as command line arguments, and that seems to me like it could be > rationale enough for why `Path` objects warrant an exception to the > "don't-convert-inputs-to-strings" unwritten rule for `shlex.join`. > > Without getting into the specific details of implementation, I'd imagine > that changing this to just convert `os.PathLike` to strings in `shlex.join` > would not break much existing code. I find it rather unlikely—though I'll > admit I have no supporting evidence—that anyone is relying on `shlex.join` > to catch path objects that should be strings; I'd bet instead anyone using > paths already is just converting them to strings "manually" before passing > them to `shlex.join`. > > I'm curious to hear more opinions on this though, since I'm guessing there > may be very valid reasons that others have for not wanting to move in this > direction that I'm totally oblivious to. > > Thanks all! > > > Issue 89283: https://github.com/python/cpython/issues/89293 > > > You may find that you need to raise on as an idea on > https://discuss.python.org/ as that is where the python code dev are more > likely to read this idea. > > Barry > > _______________________________________________ > Python-ideas mailing list -- python-ideas@python.org > To unsubscribe send an email to python-ideas-le...@python.org > https://mail.python.org/mailman3/lists/python-ideas.python.org/ > Message archived at > https://mail.python.org/archives/list/python-ideas@python.org/message/UJYYYI3VQKXN46X5QQTAAS5RORIXJSMF/ > Code of Conduct: http://python.org/psf/codeofconduct/ > >
_______________________________________________ Python-ideas mailing list -- python-ideas@python.org To unsubscribe send an email to python-ideas-le...@python.org https://mail.python.org/mailman3/lists/python-ideas.python.org/ Message archived at https://mail.python.org/archives/list/python-ideas@python.org/message/EVZNF7JJELOWHHDT6LDJCMEEFU4QH5TQ/ Code of Conduct: http://python.org/psf/codeofconduct/