Evan Andrews added the comment:

Unfortunately shlex.shlex's defaults are probably going to remain that way for 
a long time in order to avoid breaking backwards compatibility. Presumably 
shlex.split was added so you didn't have to remember to set posix and 
whitespace_split yourself.

The particular problem I'm addressing in this issue is that the new 
punctuation_chars argument doesn't currently work with whitespace_split.

>>> def split(text, ws=False, pc=False):
...     s = shlex.shlex(text, posix=True, punctuation_chars=pc)
...     s.whitespace_split = ws
...     return list(s)
...
>>> split('foo,bar>baz')
['foo', ',', 'bar', '>', 'baz']
>>> split('foo,bar>baz', ws=True)
['foo,bar>baz']
>>> split('foo,bar>baz', pc=True)
['foo', ',', 'bar', '>', 'baz']
>>> split('foo,bar>baz', ws=True, pc=True)
['foo,bar>baz']

With my patch, the last example outputs ['foo,bar', '>', 'baz'].

Before the release of 3.6 I was arguing that punctuation_chars should not 
attempt to augment wordchars at all, since the idea of wordchars is inherently 
incorrect as you point out. Now I think it's too late to change, hence my patch 
treats this as a new feature in 3.7.

----------

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue28595>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to