[issue17620] Python interactive console doesn't use sys.stdin for input

2021-03-15 Thread Eryk Sun
Change by Eryk Sun : -- versions: +Python 3.10, Python 3.8, Python 3.9 -Python 3.6 ___ Python tracker ___ ___ Python-bugs-list maili

[issue17620] Python interactive console doesn't use sys.stdin for input

2020-03-06 Thread Brett Cannon
Change by Brett Cannon : -- nosy: -brett.cannon ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail

[issue17620] Python interactive console doesn't use sys.stdin for input

2016-09-08 Thread Steve Dower
Steve Dower added the comment: Unassigning this. I meant to close it with another fix, but that would be wrong as we really ought to keep this open until we solve it properly. All I've done is make it use the right APIs on Windows, but we still don't handle it properly when we change stdin. -

[issue17620] Python interactive console doesn't use sys.stdin for input

2016-08-14 Thread Adam Bartoš
Adam Bartoš added the comment: > Unfortunately, it looks like detecting when a readline hook has been added is > going to involve significant changes to the tokenizer, which I really don't > want to do. We don't need to detect the presence of readline hook, it may be so that there is always a

[issue17620] Python interactive console doesn't use sys.stdin for input

2016-08-14 Thread Steve Dower
Steve Dower added the comment: I'm working on this as part of my fix for issue1602. Not yet sure how this will come out - compatibility with GNU readline seems to be the biggest issue, as if we want to keep that then we can't allow embedded '\0' in the encoded text (i.e. UTF-16 cannot be used,

[issue17620] Python interactive console doesn't use sys.stdin for input

2015-11-28 Thread Adam Bartoš
Adam Bartoš added the comment: I've formulated a proposal regarding this issue: https://mail.python.org/pipermail/python-dev/2015-November/142246.html . Does it make sense? -- ___ Python tracker _

[issue17620] Python interactive console doesn't use sys.stdin for input

2015-05-15 Thread STINNER Victor
Changes by STINNER Victor : -- nosy: -haypo ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.pytho

[issue17620] Python interactive console doesn't use sys.stdin for input

2015-05-10 Thread Paul Moore
Changes by Paul Moore : -- nosy: +paul.moore ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.pytho

[issue17620] Python interactive console doesn't use sys.stdin for input

2015-04-28 Thread Drekin
Drekin added the comment: Note that under status quo PyOS_Readline is called from two places: the tokenizer during an interactive session and the builtin function input. The tokenizer passes promptstring encoded in sys.stdin.encoding while input() passes promtstring encoded in sys.stdout.encod

[issue17620] Python interactive console doesn't use sys.stdin for input

2015-01-21 Thread Drekin
Drekin added the comment: Unfortunately, I have little or no experience with Python C code and I even don't have a C compiler installed so I cannot experiment. I'll just put my ideas how to solve this here. • Add sys.__readlinehook__ attribute, which can be set to a function taking a prompt s

[issue17620] Python interactive console doesn't use sys.stdin for input

2014-09-15 Thread Drekin
Drekin added the comment: I have found another problem. PyOS_Readline can be called from two different places – from Parser/tokenizer.c:tok_nextc (by REPL), which uses sys.stdin.encoding to encode prompt argument, and from Python/bltinmodule.c:builtin_input_impl (by input() function), which us

[issue17620] Python interactive console doesn't use sys.stdin for input

2014-08-30 Thread Drekin
Drekin added the comment: Antoine Pitrou: I understand. It would be nice to have that new Python string based readline hook. Its default implementation could be to call PyOS_Readline and decode the bytes using sys.stdin.encoding (as the tokenizer currently does). Tokenizer then woudn't need to

[issue17620] Python interactive console doesn't use sys.stdin for input

2014-08-30 Thread STINNER Victor
STINNER Victor added the comment: The Python parser works well with UTF8. If you know the encoding, decode from your encoding and encode to UTF8. You should pass the UTF8 flag to the parser. -- ___ Python tracker _

[issue17620] Python interactive console doesn't use sys.stdin for input

2014-08-29 Thread Antoine Pitrou
Antoine Pitrou added the comment: > Why does PyOS_Readline return *char, rather than Python string object? For historical reasons and now for compatibility: we can't change the hook's signature without breaking obvious applications, obviously. If necessary, we could add a new hook that would ta

[issue17620] Python interactive console doesn't use sys.stdin for input

2014-08-29 Thread Antoine Pitrou
Antoine Pitrou added the comment: > without breaking obvious applications without breaking *existing* applications ;-) -- ___ Python tracker ___

[issue17620] Python interactive console doesn't use sys.stdin for input

2014-08-29 Thread Drekin
Drekin added the comment: I realized that the behavior I want can be achieved by setting PyOS_ReadlineFunctionPointer to a function calling sys.stdin.readline(). However I found another problem: Python REPL just doesn't work, when sys.stdin.encoding is UTF-16-LE. The tokenizer (Parser/tokenize

[issue17620] Python interactive console doesn't use sys.stdin for input

2014-08-28 Thread Drekin
Drekin added the comment: I have found another example of where the current interaction between readline and Python core lead to confussion. It started with following report on my package: https://github.com/Drekin/win-unicode-console/issues/2 . Basically, IPython interactive console on Window

[issue17620] Python interactive console doesn't use sys.stdin for input

2014-07-31 Thread Drekin
Drekin added the comment: Sorry for formating in the previous message. Repeating… I looked to the sourcecode and found the following. First, the codepath of how interactive loop gets its input follows: Python/pythonrun.c:PyRun_InteractiveLoopFlags Python/pythonrun.c:PyRun_InteractiveOneObject P

[issue17620] Python interactive console doesn't use sys.stdin for input

2014-07-31 Thread Drekin
Drekin added the comment: I looked to the sourcecode and found the following. First, the codepath of how interactive loop gets its input follows: Python/pythonrun.c:PyRun_InteractiveLoopFlags Python/pythonrun.c:PyRun_InteractiveOneObject Python/pythonrun.c:PyParser_ASTFromFileObject Parse/parset

[issue17620] Python interactive console doesn't use sys.stdin for input

2014-07-30 Thread Guido van Rossum
Guido van Rossum added the comment: sys.stdin.readline() never delegates to GNU readline. The REPL calls GNU readline directly. There's clearly some condition that determines whether to call GNU readline or sys.stdin.readline, but it may not correspond to what you want (e.g. it may just test

[issue17620] Python interactive console doesn't use sys.stdin for input

2014-07-30 Thread Drekin
Drekin added the comment: My naive picture of ideal situation looks like this: When the interactive loop wants input, it just calls sys.stdin.readline, which delegates to sys.stdin.buffer.raw.readinto or .read, these can use GNU readline if available to get the data. May I ask, what's wrong wi

[issue17620] Python interactive console doesn't use sys.stdin for input

2014-07-30 Thread Guido van Rossum
Guido van Rossum added the comment: I propose not to mess with GNU readline. But that doesn't mean we can't try to fix this issue by detecting that sys.stdin has changed and use it if it isn't referring to the original process stdin. It will be tricky however to make sure nothing breaks. (T

[issue17620] Python interactive console doesn't use sys.stdin for input

2014-07-30 Thread Antoine Pitrou
Antoine Pitrou added the comment: Yes, it is. GNU readline will use a FILE*. Apparently, one can customize this behaviour, see http://cnswww.cns.cwru.edu/php/chet/readline/readline.html#SEC25 """Variable: rl_getc_func_t * rl_getc_function If non-zero, Readline will call indirectly through t

[issue17620] Python interactive console doesn't use sys.stdin for input

2014-07-30 Thread Guido van Rossum
Guido van Rossum added the comment: Is this at all related to the use of GNU readline? -- nosy: +gvanrossum ___ Python tracker ___ ___

[issue17620] Python interactive console doesn't use sys.stdin for input

2014-07-18 Thread Drekin
Drekin added the comment: There is still the serious inconsistency that the `sys.stdin` is not used for input by interactive loop but its encoding is. So if I replace `sys.stdin` with a custom object with its own `encoding` attribute, the standard interactive loop tries to use this encoding wh

[issue17620] Python interactive console doesn't use sys.stdin for input

2014-06-21 Thread Steve Dower
Steve Dower added the comment: Thanks Nick, but this has a pretty clear scope that may help the Unicode situation in cmd but doesn't directly relate to it. -- ___ Python tracker ___

[issue17620] Python interactive console doesn't use sys.stdin for input

2014-06-21 Thread Nick Coghlan
Nick Coghlan added the comment: Steve, another one to look at in the context of improving the Unicode handling situation at the Windows command prompt. -- nosy: +steve.dower ___ Python tracker

[issue17620] Python interactive console doesn't use sys.stdin for input

2013-07-28 Thread Drekin
Drekin added the comment: Is there any chance the API will be added and used by python.exe? -- ___ Python tracker ___ ___ Python-bugs-

[issue17620] Python interactive console doesn't use sys.stdin for input

2013-04-11 Thread Antoine Pitrou
Antoine Pitrou added the comment: Ok, I guess it would need a new API (PyRun_Stdio()?) to run the interactive loop from sys.stdin, rather than from a fixed FILE*. -- stage: -> needs patch type: behavior -> enhancement versions: -Python 3.3 ___ Pyth

[issue17620] Python interactive console doesn't use sys.stdin for input

2013-04-11 Thread Drekin
Drekin added the comment: I encountered it when I changed sys.stdin at runtime (I thought it was a supported feature) to affect the interactive console, see http://bugs.python.org/issue1602 . -- versions: -Python 2.7 ___ Python tracker

[issue17620] Python interactive console doesn't use sys.stdin for input

2013-04-11 Thread Antoine Pitrou
Antoine Pitrou added the comment: > • interactive console doesn't use sys.stdin for input, why? Modules/main.c calls PyRun_AnyFileFlags(stdin, "", ...). At this point, sys.stdin *is* the same as C stdin by construction, so I'm not sure how you came to encounter the issue. However, it's also t

[issue17620] Python interactive console doesn't use sys.stdin for input

2013-04-10 Thread Ezio Melotti
Changes by Ezio Melotti : -- nosy: +haypo ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.or

[issue17620] Python interactive console doesn't use sys.stdin for input

2013-04-06 Thread Antoine Pitrou
Changes by Antoine Pitrou : -- assignee: pitrou -> ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail

[issue17620] Python interactive console doesn't use sys.stdin for input

2013-04-06 Thread Georg Brandl
Changes by Georg Brandl : -- assignee: -> pitrou nosy: +pitrou ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe:

[issue17620] Python interactive console doesn't use sys.stdin for input

2013-04-06 Thread Drekin
Drekin added the comment: Sorry for typos. • interactive console doesn't use sys.stdin for input, why? • it uses sys.stdin.encoding, shouldn't it rather use sys.__stdin__.encoding if anything? • input() and hence code.interact() uses sys.stdin -- ___

[issue17620] Python interactive console doesn't use sys.stdin for input

2013-04-05 Thread Tshepang Lekhonkhobe
Changes by Tshepang Lekhonkhobe : -- nosy: +tshepang ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe: http://mai

[issue17620] Python interactive console doesn't use sys.stdin for input

2013-04-02 Thread Éric Araujo
Changes by Éric Araujo : -- nosy: +eric.araujo ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.pyth

[issue17620] Python interactive console doesn't use sys.stdin for input

2013-04-02 Thread Drekin
New submission from Drekin: The Python interactive console actually doesn't use sys.stdin but standard C stdin for input. Is there any reason for this? Why it then uses its encoding attribute? (Assigning sys.stdin something, that doesn't have encoding attribute freezes the interpreter.) If any