[issue7741] Allow multiple statements in code.InteractiveConsole.push
Kristján Valur Jónsson added the comment: Sounds fine. Just a note to my original intent in #7741: We were using the InteractiveConsole class to implement a remote web-based console for our EVE servers. Often, as a means to hot-fix certain issues, we would paste code snippets into these windows to define functions, execute code, etc. Previously we had our own console like implementation, but the interactive features of the InteractiveConsole were _really_ nice, but lacking in multi-line support. We have had the stdlib patched as per my original suggestion for the past few years to support it. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue7741 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue7741] Allow multiple statements in code.InteractiveConsole.push
Nick Coghlan added the comment: Good to know - I guess in most circumstances copy-and-paste already works, because the input will be arriving via a line-buffered IO stream. I was thinking that with #16649 implemented, it would be possible to simply switch from single to exec, without users needing to request the multi-statement support explicitly. However, I'm now back to wondering if such a change might have a few unforeseen consequences I haven't thought of. So if that seems like too much of a risk to backwards compatibility, how about moving the symbol argument to __init__, rather than needing to supply it with each call to push? -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue7741 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue7741] Allow multiple statements in code.InteractiveConsole.push
Changes by Chris Withers ch...@simplistix.co.uk: -- nosy: -cjw296 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue7741 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue7741] Allow multiple statements in code.InteractiveConsole.push
Nick Coghlan added the comment: OK, after a long detour that delved deep into codeop and the vagaries of PyCF_DONT_IMPLY_DEDENT (due to a problem that turned out to be due to a missing \n in a test case I added), my main conclusion is: Coupling the single vs multiple statement decision to the implicit print after every call decision is *really* annoying. The latter should be its own flag *or else* also implied by the DONT_IMPLY_DEDENT flag that is already passed to the compiler by codeop. If *that* gets fixed, then the code module could simply switch over to compiling in exec mode always, without any side effects on the implicit display of expression results. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue7741 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue7741] Allow multiple statements in code.InteractiveConsole.push
Aaron Iles added the comment: Should a new issue be created to decouple print after every call from the single vs multiple statement condition that is a blocker for this issue? Or can it be resolved here? On Sunday, 9 December 2012, Nick Coghlan wrote: Nick Coghlan added the comment: OK, after a long detour that delved deep into codeop and the vagaries of PyCF_DONT_IMPLY_DEDENT (due to a problem that turned out to be due to a missing \n in a test case I added), my main conclusion is: Coupling the single vs multiple statement decision to the implicit print after every call decision is *really* annoying. The latter should be its own flag *or else* also implied by the DONT_IMPLY_DEDENT flag that is already passed to the compiler by codeop. If *that* gets fixed, then the code module could simply switch over to compiling in exec mode always, without any side effects on the implicit display of expression results. -- ___ Python tracker rep...@bugs.python.org javascript:; http://bugs.python.org/issue7741 ___ -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue7741 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue7741] Allow multiple statements in code.InteractiveConsole.push
Nick Coghlan added the comment: More implicit magic seems like a bad idea, so I've split out a proposal for an explicit PyCF_DISPLAY_EXPRESSION_RESULTS flag as #16649. The behaviour would then be selectable regardless of the compilation mode, but would remain the default for single. -- dependencies: +Add a PyCF_DISPLAY_EXPRESSION_RESULTS flag priority: normal - low versions: +Python 3.4 -Python 2.7 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue7741 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue7741] Allow multiple statements in code.InteractiveConsole.push
Kristján Valur Jónsson added the comment: What's the purpose of the new patch, particularly 2/2 since it is equivalent to multiple push() calls? I.e. since this issue has laid dormant for two years, what prompts the sudden activity? -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue7741 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue7741] Allow multiple statements in code.InteractiveConsole.push
Nick Coghlan added the comment: Aaron was looking for something to work on for the PyConAU sprints, and set himself the task of closing as many issues related to the code module as possible. The main outcome of that was the new test suite added in #12643, which should make it easier to work on the module (at least in 3.3+) -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue7741 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue7741] Allow multiple statements in code.InteractiveConsole.push
Changes by Andrew Svetlov andrew.svet...@gmail.com: -- nosy: +asvetlov ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue7741 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue7741] Allow multiple statements in code.InteractiveConsole.push
aliles added the comment: I agree that the second patch adds little value to InteractiveConsole. A third alternative would be to accept default grammar start symbol to be passed to __init__(). Although this would prevent mixing use of 'single' with 'exec'. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue7741 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue7741] Allow multiple statements in code.InteractiveConsole.push
aliles added the comment: Patch option 1 of 2. Incorporates Kristjan's patch and adds unit tests. This has the side effect of changing InteractiveConsole's behaviour with respect to displayhook(). I'm unsure if this is desirable. -- nosy: +aliles Added file: http://bugs.python.org/file26939/issue7741_x.patch ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue7741 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue7741] Allow multiple statements in code.InteractiveConsole.push
aliles added the comment: Patch option 2 of 2. Alternative patch that adds a new method to InteractiveConsole to split the string into multiple lines, feeding each line to interpreter using push(). This doesn't change the behaviour regarding the displayhook. But this may not meet Kristjan's original goals. -- Added file: http://bugs.python.org/file26940/issue7741_y.patch ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue7741 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue7741] Allow multiple statements in code.InteractiveConsole.push
aliles added the comment: A quick note regarding the last two patches submitted. These patches add unit tests using the test suite added for Issue #12643. This limits the patches suitable to Python 3.3 and up. -- nosy: +ncoghlan ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue7741 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue7741] Allow multiple statements in code.InteractiveConsole.push
Changes by Éric Araujo mer...@netwok.org: -- nosy: +eric.araujo ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue7741 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue7741] Allow multiple statements in code.InteractiveConsole.push
Chris Withers ch...@simplistix.co.uk added the comment: Please can you starts a small test suite for the code module that tests the fix you are proposing and include it as another patch? -- nosy: +cjw296 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue7741 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue7741] Allow multiple statements in code.InteractiveConsole.push
New submission from Kristján Valur Jónsson krist...@ccpgames.com: The code.InteractiveConsole() is useful to emulate a python console. However, any code currently pushed to it must be single statements. This is because it passes the ´single´ symbol mode to the underlying compile function. This patch allows the caller of InteractiveConsole.push to specify a different mode, e.g. ´exec´. This is useful if one wants to paste entire code snippets into the console. Without it, pasting the following: 'if True:\n print 1\nprint 2' Won't run. pushing such multiline code snippets with an additional 'exec' argument will allow it to work. Patch included. -- components: Library (Lib) files: code.patch keywords: patch messages: 98056 nosy: krisvale severity: normal status: open title: Allow multiple statements in code.InteractiveConsole.push type: feature request versions: Python 2.7 Added file: http://bugs.python.org/file15950/code.patch ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue7741 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue7741] Allow multiple statements in code.InteractiveConsole.push
Kristján Valur Jónsson krist...@ccpgames.com added the comment: Note, there are no regression tests for the code module. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue7741 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue7741] Allow multiple statements in code.InteractiveConsole.push
Kristján Valur Jónsson krist...@ccpgames.com added the comment: Here is how to test this manually: from code import InteractiveConsole c = InteractiveConsole() s = if True:\n print 1\nprint 2 c.push(s) #fails c.push(s, exec) #succeeds -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue7741 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com