[New-bugs-announce] [issue33262] Deprecate shlex.split(None) to read from stdin.

Christian Heimes report at bugs.python.org
Wed Apr 11 06:28:49 EDT 2018

New submission from Christian Heimes <lists at cheimes.de>:

The shlex module implements simple tokenize for a shell-like mini language. The shlex.split() function splits a string into subcomponents just like a typical Unix shell. However function has a surprising feature. When None is passed into shlex.split().

Note: Since the split() function instantiates a shlex instance, passing None for s will read the string to split from standard input. 


This is both surprising, unnecessary and potentially dangerous. Reading from sys.stdin is a blocking operation. In case an application doesn't account for None, shlex.split(value) could lead to a blocked server application. I suggest to deprecate and eventually remove this mis-feature.

Credits: David R. MacIver reported the bug on Twitter: https://twitter.com/DRMacIver/status/984001867985367040

messages: 315189
nosy: christian.heimes
priority: normal
severity: normal
stage: needs patch
status: open
title: Deprecate shlex.split(None) to read from stdin.
type: behavior
versions: Python 3.8

Python tracker <report at bugs.python.org>

More information about the New-bugs-announce mailing list