[New-bugs-announce] [issue21999] shlex: bug in posix more handling of empty strings

Martin Morrison report at bugs.python.org
Thu Jul 17 18:37:00 CEST 2014

New submission from Martin Morrison:

Minimal testcase of the problem situation is tokenising (with posix mode on):


Specifically, an empty string, followed by a non-word character, followed by a non-space character. In this case, the token buffer is empty and due to a missing check for (self.posix and quoted), an extra token is consumed and returned in the wrong order:

>>> s = shlex.shlex("'')abc", posix=True)
>>> s.get_token()
>>> s.get_token()
>>> s.get_token()

I have patches to fix this issue in both default and 2.7. I've also checked there are no other occurrences of the same typo.

files: shlex.default.patch
keywords: patch
messages: 223348
nosy: isoschiz
priority: normal
severity: normal
status: open
title: shlex: bug in posix more handling of empty strings
versions: Python 2.7, Python 3.1, Python 3.2, Python 3.3, Python 3.4, Python 3.5
Added file: http://bugs.python.org/file35983/shlex.default.patch

Python tracker <report at bugs.python.org>

More information about the New-bugs-announce mailing list