[issue37466] Move casting prompt after its validation in _raw_input()

Steven D'Aprano report at bugs.python.org
Mon Jul 1 06:08:20 EDT 2019


Steven D'Aprano <steve+python at pearwood.info> added the comment:

I don't think that will work. If the user passes a non-string which is falsey, your patch will attempt to write it directly to the stream without converting it to a string.

Try ``_raw_input(0)`` as an example.

Tal Einat:
> one would expect passing prompt=None to result in no prompt displayed

I wouldn't. That's not how getpass works now, or input.

By the way, myungsekyo, that's not the best way to use timeit to time code snippets. You are timing the overhead of the loop, ten million lookups of the name "_raw_input", and most importantly, ten million times that _raw_input halts waiting for input from the user. Surely you didn't sit there hitting Enter over and over again?

----------
nosy: +steven.daprano

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue37466>
_______________________________________


More information about the Python-bugs-list mailing list