[issue9723] Add shlex.quote

2012-04-18 Thread Éric Araujo

É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
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue9723] Add shlex.quote

2011-08-16 Thread Éric Araujo

É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 can't be moved to shlex.quote verbatim as I
 originally proposed?

I took the opportunity of changing some convoluted code.

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue9723
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue9723] Add shlex.quote

2011-08-16 Thread Éric Araujo

É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 can't be moved to shlex.quote verbatim as I
 originally proposed?

I took the opportunity of changing some convoluted code.

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue9723
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue9723] Add shlex.quote

2011-08-16 Thread Roundup Robot

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
http://bugs.python.org/issue9723
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue9723] Add shlex.quote

2011-08-12 Thread Roundup Robot

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':
Avoid unwanted behavior change in shlex.quote (see #9723).
http://hg.python.org/cpython/rev/6ae0345a7e29

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue9723
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue9723] Add shlex.quote

2011-08-12 Thread Éric Araujo

É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
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue9723] Add shlex.quote

2011-08-12 Thread Ezio Melotti

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 it's at the end (or beginning) of the 
regex).

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue9723
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue9723] Add shlex.quote

2011-08-12 Thread Matt Joiner

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.

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue9723
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue9723] Add shlex.quote

2011-07-30 Thread Ezio Melotti

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 3.
'+' and '.' don't need to be escaped in a character class (i.e. [...]), because 
they lose their meta-characters meaning there.
'-' is correctly escaped there, but it's common practice to place it at the end 
of the character class, where it doesn't need escaping.

r'[^\w\d@%_\-\+=:,\./]' and r'[^\w@%+=:,./-]' should therefore be equivalent.

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue9723
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue9723] Add shlex.quote

2011-07-30 Thread Éric Araujo

É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.

 Also keep in mind that they match non-ASCII letters/numbers on
 Python 3.
This was not covered by the previous tests, but I think it’s fine: the shell is 
concerned about some metacharacters and spaces, not Unicode letters.  To be 
100% sure, I will add tests with Unicode characters for pipes.quote in 3.2, and 
when merging with 3.3 I’ll know if the new code still complies.

--
stage: committed/rejected - test needed
status: closed - open

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue9723
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue9723] Add shlex.quote

2011-07-29 Thread Roundup Robot

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

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue9723
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue9723] Add shlex.quote

2011-07-29 Thread Roundup Robot

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 rep...@bugs.python.org
http://bugs.python.org/issue9723
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue9723] Add shlex.quote

2011-07-29 Thread Éric Araujo

É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 the absence of review or opposition here, I have committed my patch.  
Feedback welcome.

--
resolution:  - fixed
stage: patch review - committed/rejected
status: open - closed

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue9723
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue9723] Add shlex.quote

2011-07-29 Thread R. David Murray

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
http://bugs.python.org/issue9723
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue9723] Add shlex.quote

2011-07-29 Thread Éric Araujo

É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 name, since the function is not limited to file names 
(as I hopefully made clear in the doc).

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue9723
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue9723] Add shlex.quote

2011-07-29 Thread R. David Murray

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 
translate might be even faster.)

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue9723
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue9723] Add shlex.quote

2011-07-29 Thread Éric Araujo

É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
http://bugs.python.org/issue9723
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue9723] Add shlex.quote

2011-07-29 Thread R. David Murray

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 regex has, it might be.  Note that the translate 
table can be pre-built, just like the compiled regex.

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue9723
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue9723] Add shlex.quote

2011-07-18 Thread Éric Araujo

É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 rep...@bugs.python.org
http://bugs.python.org/issue9723
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue9723] Add shlex.quote

2011-04-29 Thread Ezio Melotti

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
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue9723] Add shlex.quote

2011-04-27 Thread Xuanji Li

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
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue9723] Add shlex.quote

2011-04-27 Thread Éric Araujo

É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 doc from subprocess and pipes, and reply to the Stack Overflow thread.

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue9723
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue9723] Add shlex.quote

2011-03-03 Thread STINNER Victor

Changes by STINNER Victor victor.stin...@haypocalc.com:


--
nosy: +haypo

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue9723
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue9723] Add shlex.quote

2011-02-04 Thread Éric Araujo

É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.  I
 implemented my own thing, but the way pipes.quote works would have been
 nicer (the implementation could use a couple regexes instead of iterating
 over strings though).

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue9723
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue9723] Add shlex.quote

2011-01-24 Thread Éric Araujo

É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 rep...@bugs.python.org
http://bugs.python.org/issue9723
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue9723] Add shlex.quote

2011-01-24 Thread R. David Murray

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... :)

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue9723
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue9723] Add shlex.quote

2011-01-24 Thread Georg Brandl

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
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue9723] Add shlex.quote

2011-01-22 Thread Éric Araujo

É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. move code from pipes/test_pipes to 
shlex/test_shlex, add doc, write a pipes.quote function that sends a 
DeprecationWarning and calls shlex.quote).

--
assignee: docs@python - 
components: +Library (Lib) -Documentation
nosy:  -docs@python
title: pipes.quote() needs to be documented - Add shlex.quote
type:  - feature request
versions: +Python 3.3 -Python 2.7, Python 3.1, Python 3.2

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue9723
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue9723] Add shlex.quote

2011-01-22 Thread R. David Murray

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 
indefinitely.

--
nosy: +r.david.murray

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue9723
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com