Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(1875)

#1521950: shlex.split() does not tokenize like the shell

Can't Edit
Can't Publish+Mail
Start Review
Created:
1 year, 5 months ago by robodan
Modified:
1 year ago
Reviewers:
merwok, vinay_sajip, rdmurray
CC:
Vinay Sajip, eric.smith, robodan_users.sourceforge.net, ezio.melotti, eric.araujo, r.david.murray
Visibility:
Public.

Patch Set 1 #

Total comments: 7

Patch Set 2 #

Total comments: 30

Patch Set 3 #

Total comments: 21

Patch Set 4 #

Unified diffs Side-by-side diffs Delta from patch set Stats Patch
Doc/library/shlex.rst View 1 2 3 6 chunks +96 lines, -7 lines 0 comments Download
Lib/shlex.py View 1 2 3 9 chunks +57 lines, -22 lines 0 comments Download
Lib/test/test_shlex.py View 1 2 3 1 chunk +100 lines, -0 lines 0 comments Download

Messages

Total messages: 11
eric.araujo
Great patch. http://bugs.python.org/review/1521950/diff/3939/13004 File Lib/shlex.py (right): http://bugs.python.org/review/1521950/diff/3939/13004#newcode52 Lib/shlex.py:52: if not control: I wonder if this ...
1 year, 5 months ago #1
Vinay Sajip
BTW, I never got an email from the review tool from your comments! Just happened ...
1 year, 4 months ago #2
Vinay Sajip
http://bugs.python.org/review/1521950/diff/3939/13004 File Lib/shlex.py (right): http://bugs.python.org/review/1521950/diff/3939/13004#newcode52 Lib/shlex.py:52: if not control: On 2012/01/07 15:54:26, eric.araujo wrote: > ...
1 year, 4 months ago #3
eric.araujo
http://bugs.python.org/review/1521950/diff/3939/13005 File Lib/test/test_shlex.py (right): http://bugs.python.org/review/1521950/diff/3939/13005#newcode186 Lib/test/test_shlex.py:186: ref = ['echo', 'hi', delimiter, 'echo', 'bye'] > They ...
1 year, 3 months ago #4
r.david.murray
I've only really reviewed the docs (and thus the API) and have some concerns. I'd ...
1 year, 1 month ago #5
Vinay Sajip
My response to R. David Murray's comments. http://bugs.python.org/review/1521950/diff/4234/14802 File Doc/library/shlex.rst (right): http://bugs.python.org/review/1521950/diff/4234/14802#newcode73 Doc/library/shlex.rst:73: .. class:: ...
1 year, 1 month ago #6
r.david.murray
After you address the doc issues with a new patch and some decision is made ...
1 year, 1 month ago #7
Vinay Sajip
http://bugs.python.org/review/1521950/diff/4234/14802 File Doc/library/shlex.rst (right): http://bugs.python.org/review/1521950/diff/4234/14802#newcode73 Doc/library/shlex.rst:73: .. class:: shlex(instream=None, infile=None, posix=False, punctuation_chars=False) On 2012/04/23 11:42:09, ...
1 year, 1 month ago #8
Vinay Sajip
http://bugs.python.org/review/1521950/diff/4748/16844 File Doc/library/shlex.rst (right): http://bugs.python.org/review/1521950/diff/4748/16844#newcode87 Doc/library/shlex.rst:87: even closer behaviour to how reall shells parse, the ...
1 year, 1 month ago #9
r.david.murray
I haven't wrapped my head around the shlex parsing algorithm, so I haven't really evaluated ...
1 year ago #10
Vinay Sajip
1 year ago #11
New patch set with these changes is now available :-)

http://bugs.python.org/review/1521950/diff/4748/Doc/library/shlex.rst
File Doc/library/shlex.rst (right):

http://bugs.python.org/review/1521950/diff/4748/Doc/library/shlex.rst#newcode84
Doc/library/shlex.rst:84: mode: when *posix* is not true (default), the
:class:`shlex` instance will
On 2012/06/02 21:58:30, r.david.murray wrote:
> When you edit this next could you change "not true" to "false"?  The negative
is
> confusing.

Done.

http://bugs.python.org/review/1521950/diff/4748/Doc/library/shlex.rst#newcode87
Doc/library/shlex.rst:87: even closer behaviour to how reall shells parse, the
*punctuation_chars*
On 2012/06/02 21:58:30, r.david.murray wrote:
> On 2012/04/26 22:08:08, Vinay Sajip wrote:
> > s/reall/real/ when I next change this.
> 
> 
> I would remove the passive voice here.  How about "The *punctuation_chars*
> argument provides a way to make the behavior even closer to how real shells
> parse."

Done.

http://bugs.python.org/review/1521950/diff/4748/Doc/library/shlex.rst#newcode92
Doc/library/shlex.rst:92: single token. You can also provide a non-empty string
of characters, which
On 2012/06/02 21:58:30, r.david.murray wrote:
> To keep the paragraph parallel, this should be "If set to a non-empty string
of
> characters, those characters will be used as the punctuation characters."

Done.

http://bugs.python.org/review/1521950/diff/4748/Doc/library/shlex.rst#newcode95
Doc/library/shlex.rst:95: :ref:`improved-shell-compatibility` for more
information.
On 2012/06/02 21:58:30, r.david.murray wrote:
> If I understand the next change correctly, this should really read "Any
> characters in the :attr:`wordchars` attribute that appear in
*punctuation_chars*
> will be removed from :attr:`wordchars`."

Done.

http://bugs.python.org/review/1521950/diff/4748/Doc/library/shlex.rst#newcode238
Doc/library/shlex.rst:238: example, for parsing command lines with
:class:`shlex`, getting tokens in a
On 2012/06/02 21:58:30, r.david.murray wrote:
> Since whitespace_split=True is no longer the best way to get one closer to
> parsing like the shell does, I think we should just eliminate the "This is
> useful" sentence.

Done.

http://bugs.python.org/review/1521950/diff/4748/Doc/library/shlex.rst#newcode398
Doc/library/shlex.rst:398: .. note:: When ``punctuation_chars`` is specified,
the :attr:`~shlex.wordchars`
On 2012/06/02 21:58:30, r.david.murray wrote:
> I don't think this needs to be a note, but that's a judgement call so I'm fine
> if you leave it as one.

I'll leave it as is - I made it a note to stand out a little, because the
side-effect might be unexpected.

http://bugs.python.org/review/1521950/diff/4748/Lib/shlex.py
File Lib/shlex.py (right):

http://bugs.python.org/review/1521950/diff/4748/Lib/shlex.py#newcode21
Lib/shlex.py:21: def __init__(self, instream=None, infile=None, posix=False,
punctuation_chars=False):
On 2012/06/02 21:58:30, r.david.murray wrote:
> Please wrap this line to < 80 chars.

Done.

http://bugs.python.org/review/1521950/diff/4748/Lib/shlex.py#newcode66
Lib/shlex.py:66: self.wordchars.remove(c)
On 2012/06/02 21:58:30, r.david.murray wrote:
> This should be:
> 
>   self.wordchars = ''.join(c for c in self.wordchars if c not in
> self.punctuation_chars)
> 
> The fact that you missed this indicates you are missing a test :)

Done.

http://bugs.python.org/review/1521950/diff/4748/Lib/shlex.py#newcode213
Lib/shlex.py:213: and nextchar != escapedstate):
On 2012/06/02 21:58:30, r.david.murray wrote:
> I think it would be better to indent the 'and' further (I believe that's what
> PEP8 calls for...actually I think PEP8 would also have the previous line
ending
> with the operator rather than this line beginning with one.)

Done.

http://bugs.python.org/review/1521950/diff/4748/Lib/test/test_shlex.py
File Lib/test/test_shlex.py (right):

http://bugs.python.org/review/1521950/diff/4748/Lib/test/test_shlex.py#newcod...
Lib/test/test_shlex.py:256: self.assertEqual(observed, expected)
On 2012/06/02 21:58:30, r.david.murray wrote:
> As mentioned in the shlex review, you are missing a test for punctuation chars
> where a punc char appears in wordchars.
> 
> There should also be at least one test with both punctuation_chars and
> whitespace_split=True.

Done.
Sign in to reply to this message.

RSS Feeds Recent Issues | This issue
This is Rietveld cbc36f91f3f7