-
-
Notifications
You must be signed in to change notification settings - Fork 30.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Deprecate shlex.split(None) to read from stdin. #77443
Comments
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. https://docs.python.org/3/library/shlex.html#shlex.split 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 |
I agree that it should be deprecated. That's crazy behavior. I'd also recommend that shlex.shlex with instream=None be deprecated, but maybe that's too radical. It seems way too easy to accidentally pass in None. |
I've just run into this as well -- I thought it was a bug until I found this issue. I also think that this is anything from sane. |
Can be closed as fixed (or perhaps renamed and kept open to track eventual raising of error in the future?) |
Follow-up issue #94352: shlex.split(): remove support for s=None. |
s
to shlex.split() #6514Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: