Éric Araujo mer...@netwok.org added the comment:
See #14616 for a doc edition related to this.
--
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue9723
___
Éric Araujo mer...@netwok.org added the comment:
FWIW there are still unnecessary escapes before '+' and '.', and
possibly '-'
This is IMO cosmetic and not as “important” as the duplicate characters already
implied by the character class. Feel free to change it.
Why can't pipes.quote
Éric Araujo mer...@netwok.org added the comment:
FWIW there are still unnecessary escapes before '+' and '.', and
possibly '-'
This is IMO cosmetic and not as “important” as the duplicate characters already
implied by the character class. Feel free to change it.
Why can't pipes.quote
Roundup Robot devn...@psf.upfronthosting.co.za added the comment:
New changeset 5d4438001069 by Ezio Melotti in branch 'default':
#9723: refactor regex.
http://hg.python.org/cpython/rev/5d4438001069
--
___
Python tracker rep...@bugs.python.org
Roundup Robot devn...@psf.upfronthosting.co.za added the comment:
New changeset 8032ea4c3619 by Éric Araujo in branch '3.2':
Test pipes.quote with a few non-ASCII characters (see #9723).
http://hg.python.org/cpython/rev/8032ea4c3619
New changeset 6ae0345a7e29 by Éric Araujo in branch 'default':
Éric Araujo mer...@netwok.org added the comment:
I have restored compatibility (see commit messages).
--
stage: test needed - committed/rejected
status: open - closed
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue9723
Ezio Melotti ezio.melo...@gmail.com added the comment:
-_find_unsafe = re.compile(r'[^\w\d@%_\-\+=:,\./]').search
+_find_unsafe = re.compile(r'[^\w@%\-\+=:,\./]', re.ASCII).search
FWIW there are still unnecessary escapes before '+' and '.', and possibly '-'
('-' doesn't need escaping only when
Matt Joiner anacro...@gmail.com added the comment:
Why can't pipes.quote can't be moved to shlex.quote verbatim as I originally
proposed?
Is there justification to also change it as part of the relocation? I think any
changes to its behaviour should be a separate issue.
--
Ezio Melotti ezio.melo...@gmail.com added the comment:
+_find_unsafe = re.compile(r'[^\w\d@%_\-\+=:,\./]').search
\w already includes both \d and _, so (unless you really want to be explicit
about it) they are redundant. Also keep in mind that they match non-ASCII
letters/numbers on Python
Éric Araujo mer...@netwok.org added the comment:
\w already includes both \d and _, so (unless you really want to be
explicit about it) they are redundant. [snip]
I just started from the previous list and turned it into a regex. Eliminating
redundancy sounds good, I’ll use your version.
Roundup Robot devn...@psf.upfronthosting.co.za added the comment:
New changeset 5966eeb0457d by Éric Araujo in branch 'default':
Add shlex.quote function, to escape filenames and command lines (#9723).
http://hg.python.org/cpython/rev/5966eeb0457d
--
nosy: +python-dev
Roundup Robot devn...@psf.upfronthosting.co.za added the comment:
New changeset 43c41e19527a by Éric Araujo in branch 'default':
Expand shlex.quote example (#9723)
http://hg.python.org/cpython/rev/43c41e19527a
--
___
Python tracker
Éric Araujo mer...@netwok.org added the comment:
I suck at regexes, but the one I came up with lets quote pass the tests that
existed for pipes.quote, so I figure it’s good. I did not change the string
operations at the end of the function (+ and replace) as it was simple and
working.
In
R. David Murray rdmur...@bitdance.com added the comment:
Sorry I didn't look at the patch earlier. I thought we were just *moving*
pipes.quote. Why is a new regex involved?
--
___
Python tracker rep...@bugs.python.org
Éric Araujo mer...@netwok.org added the comment:
Because I choose to follow Ian’s remark in msg127957:
the implementation could use a couple regexes instead of iterating
over strings though
I have not touched the tests, so I felt confident with my regex. FWIW, I’ve
also changed the argument
R. David Murray rdmur...@bitdance.com added the comment:
Well, it's a micro-optimization (it would be interesting to benchmark, but not
worth it). I find the original code much more readable than the regex, but it
doesn't matter all that much. (And as far as optimization goes, using
Éric Araujo mer...@netwok.org added the comment:
str.translate is not an option, as the code does not replace but add characters
(quotes).
Out of sheer curiosity, I may actually benchmark this.
--
___
Python tracker rep...@bugs.python.org
R. David Murray rdmur...@bitdance.com added the comment:
You aren't using a regex to replace the quotes, either.
len('abcd'.translate(str.maketrans('', '', string.ascii_letters ))) 0
False
I don't know if this is faster than the corresponding search regex, but
depending on how much overhead
Éric Araujo mer...@netwok.org added the comment:
Here’s the patch, please review.
--
assignee: - eric.araujo
keywords: +patch
stage: needs patch - patch review
Added file: http://bugs.python.org/file22685/shlex.quote.diff
___
Python tracker
Ezio Melotti ezio.melo...@gmail.com added the comment:
See also #11827 about subprocess.list2cmdline.
--
nosy: +ezio.melotti
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue9723
___
Changes by Xuanji Li xua...@gmail.com:
--
nosy: +xuanji
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue9723
___
___
Python-bugs-list mailing list
Éric Araujo mer...@netwok.org added the comment:
Someone on Stack Overflow suggested subprocess.list2cmdline. It’s one of those
functions undocumented and absent from __all__ that somehow get found and used
by some people. So when we make the patch, let’s include links to the new
function
Changes by STINNER Victor victor.stin...@haypocalc.com:
--
nosy: +haypo
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue9723
___
___
Éric Araujo mer...@netwok.org added the comment:
A note from Ian Bicking in
http://mail.python.org/pipermail/stdlib-sig/2010-May/000948.html:
I've had to do this sort of thing for similar reasons, like calling remote
ssh commands, where a shell command is embedded in a positional argument.
Éric Araujo mer...@netwok.org added the comment:
you can just do 'from shlex import quote' in pipes
We would have had to do that anyway, since pipes needs to use the function.
Agreed that a deprecation is not necessary.
--
___
Python tracker
R. David Murray rdmur...@bitdance.com added the comment:
Yes, I know you have to do it anyway, that's why I used the adverb 'just' (as
in 'just that, and nothing more') (I note that 'just' as an adverb tends to
get overused by English speakers, and so loses some of its semantic value... :)
Georg Brandl ge...@python.org added the comment:
Putting quote() into shlex sounds good to me.
--
nosy: +georg.brandl
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue9723
___
Éric Araujo mer...@netwok.org added the comment:
Even if quote does not start with an underscore, its absence from the docs and
from the module’s __all__ make it a private function.
I propose to make it public as shlex.quote in 3.3 and deprecate pipes.quote for
people that relied on it (i.e.
R. David Murray rdmur...@bitdance.com added the comment:
Rather than doing a code deprecation you can just do 'from shlex import quote'
in pipes (with a comment about backward compatibility). I don't think there is
any real harm in leaving that kind of backward compatibility in place
29 matches
Mail list logo