[New-bugs-announce] [issue27775] `shlex.split(None)` causes infinite loop

Ram Rachum report at bugs.python.org
Tue Aug 16 04:27:37 EDT 2016


New submission from Ram Rachum:

I had a code that would freeze, and after debugging I realized that a bug in my code caused `shlex.split(None)` to be called, which puts Python in an infinite loop.

We probably want to do an `if not isinstance(s, ...): raise TypeError('Bla bla')` at the start of the `shlex` function, or maybe at `shlex.__init__`, or maybe both.

What bothers me though, is that it seems that shlex can accept both a string and a stream, so we should allow both of these and not others. Now, I don't know how to check whether it's a proper stream. Would `isinstance(s, io.IOBase)` be good enough? Will it catch all of the streams that people might use in `shlex.split`?

(Also, I recently proposed something related in python-ideas: https://groups.google.com/forum/#!searchin/python-ideas/stream%7Csort:relevance/python-ideas/uYlnnH52VEA/PSHkQRtaBwAJ )

----------
components: Library (Lib)
messages: 272847
nosy: cool-RR
priority: normal
severity: normal
status: open
title: `shlex.split(None)` causes infinite loop
type: crash
versions: Python 3.6

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue27775>
_______________________________________


More information about the New-bugs-announce mailing list