Re: [IronPython] IPython is breathing but there's a compile() problem
On Tue, May 26, 2009 at 10:50 AM, Michael Foord fuzzy...@voidspace.org.ukwrote I wonder if it isn't in fact caused by the fact that the repr of an IronPython syntax error doesn't change if the you add new lines to the source code you are compiling. Yes, in this case that is the crux of the issue. Mike ___ Users mailing list Users@lists.ironpython.com http://lists.ironpython.com/listinfo.cgi/users-ironpython.com
[IronPython] IPython is breathing but there's a compile() problem
Now that 2.6B1 has frames support, I've started playing with IronPython under IPython again. I've managed to get a command prompt up (some modules are missing, but the only crucial one is codeop, which I stole from the standard distribution). However, there's a problem with entering multiline code snippets interactively. With CPython, this looks like: In [21]: if 1: : if 1: : (The indentation looks wrong without a fixed-width font, but you get the idea.) With IronPython, the second if 1: line blows up with a syntax error. This boils down to a difference in the way the compile() builtin works as used by the codeop module. I've written this up as a bug at codeplex. Please vote for the bug here: http://ironpython.codeplex.com/WorkItem/View.aspx?WorkItemId=22692 It would be awesome if we could have a good IronPython + IPython story before 2.6 is released! Below are more details about the problem as described in the bug description. Mike bug description at codeplex follows compile() behaves differently than in CPython in the presence of incomplete multiline code snippets. Fixing this incompatiblity is necessary for running IronPython under IPython. Here is a sample program illustrating the problem. The program is a modification of the code used in the standard codeop module by IPython to determine when to provide a continuation prompt for a multiline snippet. def testcompile(source, flags): err = err1 = err2 = None code = code1 = code2 = None try: code = compile(source, dummy, single, flags, 1) except SyntaxError, err: pass try: code1 = compile(source + \n, dummy, single, flags, 1) except SyntaxError, err1: pass try: code2 = compile(source + \n\n, dummy, single, flags, 1) except SyntaxError, err2: pass print for source = '%s' and flags = %d % (source, flags), if code: print Syntax valid elif not code1 and repr(err1) == repr(err2): print Syntax error! print print err1:, repr(err1) print err2:, repr(err2) else: print Continue on next line print print err1:, repr(err1) print err2:, repr(err2) print # 0x200 is PyCF_DONT_IMPLY_DEDENT testcompile(if 1:, 0x200) testcompile(if 1:, 0) testcompile(if 1:\n if 1:, 0x200) testcompile(if 1:\n if 1:, 0) Under CPython (2.6.1) the output is: for source = 'if 1:' and flags = 512 Continue on next line err1: SyntaxError('unexpected EOF while parsing', ('dummy', 1, 6, 'if 1:\n')) err2: IndentationError('expected an indented block', ('dummy', 2, 1, '\n')) for source = 'if 1:' and flags = 0 Continue on next line err1: SyntaxError('unexpected EOF while parsing', ('dummy', 1, 6, 'if 1:\n')) err2: IndentationError('expected an indented block', ('dummy', 2, 1, '\n')) for source = 'if 1: if 1:' and flags = 512 Continue on next line err1: IndentationError('expected an indented block', ('dummy', 2, 8, ' if 1:\n')) err2: IndentationError('expected an indented block', ('dummy', 3, 1, '\n')) for source = 'if 1: if 1:' and flags = 0 Continue on next line err1: IndentationError('expected an indented block', ('dummy', 2, 8, ' if 1:\n')) err2: IndentationError('expected an indented block', ('dummy', 3, 1, '\n')) In all cases the code correctly outputs Continue on next line since both snippets are incomplete but otherwise valid python. For IronPython 2.6 Beta 1 the output is: for source = 'if 1:' and flags = 512 Continue on next line err1: IndentationError(unexpected token 'eof', ('dummy', 2, 1, '')) err2: IndentationError(unexpected token 'eof', ('dummy', 3, 1, '')) for source = 'if 1:' and flags = 0 Continue on next line err1: IndentationError(unexpected token 'eof', ('dummy', 2, 1, '')) err2: IndentationError(unexpected token 'eof', ('dummy', 3, 1, '')) for source = 'if 1: if 1:' and flags = 512 Syntax error! err1: IndentationError(unexpected token 'eof', ('dummy', 2, 8, ' if 1:\n')) err2: IndentationError(unexpected token 'eof', ('dummy', 2, 8, ' if 1:\n')) for source = 'if 1: if 1:' and flags = 0 Syntax error! err1: IndentationError(unexpected token 'eof', ('dummy', 2, 8, ' if 1:\n')) err2: IndentationError(unexpected token 'eof', ('dummy', 2, 8, ' if 1:\n')) The second snippet is misinterpreted as being a syntax error instead of merely incomplete. This is very similar to the
[IronPython] 2.6 Beta 1 Bug: help() requires _getframe support which is now optional
With 2.6 beta 1 and without -X:frames: help() Traceback (most recent call last): File stdin, line 1, in module File C:\Program Files\IronPython 2.6\Lib\site.py, line 428, in __call__ File C:\Program Files\IronPython 2.6\Lib\pydoc.py, line 53, in C:\Program Files\IronPython 2.6\Lib\pydoc.py File C:\Program Files\IronPython 2.6\Lib\inspect.py, line 950, in C:\Program Files\IronPython 2.6\Lib\inspect.py AttributeError: 'module' object has no attribute '_getframe' This is now item 22640 on CodePlex. Mike ___ Users mailing list Users@lists.ironpython.com http://lists.ironpython.com/listinfo.cgi/users-ironpython.com
[IronPython] Scripting an unmanaged app with IronPython?
I have an unmanaged app written in C++ / MFC that I'd like to script in some capacity with IronPython. I can see perhaps three broad approaches to doing this: 1. Somehow hosting IP within the app. This would be the ideal, but I don't know if it's possible. It's clear that I would need to create some wrappers that mediate between managed and unmanaged code (i.e., expose functionality as CLR objects). But on top of that I'd need to host IP in the process. I have Michael F.'s excellent IronPython in Action and have been reading a little bit about embedding the engine, but it starts with the premise that the hosting app is itself managed. 2. Create a new managed app that would have access to the wrappers as in #1 and embed IP in that. I think this is definitely possible, but it would have limitations that #1 would not have (e.g., in #1, the user could still do things from the app's gui) 3. Have a new managed app that runs as a separate process and communicates with the unmanaged app, e.g. like COM. The app currently does not have COM interfaces and working with COM is a major pain. Is there an alternative in the .net world that would be similar but easier to use? Thanks in advance for any guidance y'all can offer. Mike ___ Users mailing list Users@lists.ironpython.com http://lists.ironpython.com/listinfo.cgi/users-ironpython.com
Re: [IronPython] Scripting an unmanaged app with IronPython?
On Tue, May 12, 2009 at 7:58 AM, Curt Hagenlocher c...@hagenlocher.org wrote: Is there any reason you wouldn't just do this with CPython? In a past life, I had a lot of success embedding CPython into a C++ / MFC application. Yes, in fact, I've done a limited version of my approach #2 before using boost.python. The big win with using IronPython scripting is access to .net libraries. Plus I like pushing the envelope -- as opposed to pushing boulders uphill :-) Mike ___ Users mailing list Users@lists.ironpython.com http://lists.ironpython.com/listinfo.cgi/users-ironpython.com
[IronPython] sys._getframe(n)?
Is it true that the dev team is considering implementing sys._getframe(n) where n 0? I'd love to see this since my understanding is that this is a stumbling block for running IronPython under IPython. Is there an issue number on CodePlex on this that I can vote for? Thanks, Mike ___ Users mailing list Users@lists.ironpython.com http://lists.ironpython.com/listinfo.cgi/users-ironpython.com
Re: [IronPython] sys._getframe(n)?
On Wed, Apr 29, 2009 at 8:34 AM, Dino Viehland di...@microsoft.com wrote: Yep, we're going to make it available via a command line option. The Interesting question is what does IPython need from frames? Does it need locals (which frequently won't be available), globals, the function or code, or something else? I hadn't looked at the source until now, but a cursory glance suggests that it typically wants to evaluate expressions with the locals (and globals) from various stack frames. Could you discuss in a bit more detail why certain locals wouldn't be available that would otherwise be available in CPython? Mike ___ Users mailing list Users@lists.ironpython.com http://lists.ironpython.com/listinfo.cgi/users-ironpython.com
[IronPython] Full forms editor with VS Express?
Hey all, My understanding is that it's not possible to use the full IronPython integration with VS Express. Given that, what is the best way to use the full power of the forms editor from VS express but code the forms and the rest of the app in IronPython? I don't want to use any of the (mostly incomplete) alternate form editors that are freely available. Is WPF / XAML a help here? Mike ___ users mailing list users@lists.ironpython.com http://lists.ironpython.com/listinfo.cgi/users-ironpython.com
[IronPython] Full forms editor with VS Express?
Hey all, My understanding is that it's not possible to use the full IronPython integration with VS Express. Given that, what is the best way to use the full power of the forms editor from VS express but code the forms and the rest of the app in IronPython? I don't want to use any of the (mostly incomplete) alternate form editors that are freely available. Is WPF / XAML a help here? Mike ___ users mailing list users@lists.ironpython.com http://lists.ironpython.com/listinfo.cgi/users-ironpython.com
Re: [IronPython] Please vote on bugs!
I think I want to vote for issue 1042, but the server throws an error whenever I click on that particular issue. Actually, I want to vote for whatever issues whose resolution will enable IronPython to run under IPython (which will require sys._getframe(n) support). Mike ___ users mailing list users@lists.ironpython.com http://lists.ironpython.com/listinfo.cgi/users-ironpython.com
Re: [IronPython] WinForms Text Missing
I had an issue with 0.9.5 and the forms tutorial example also. The example is supposed to create a new text box on the form at every point where the mouse is clicked. It actually does this, but the text is not visible. However, if you interactively loop over the controls and change the text, font, color, etc., then the change takes effect and you can see all the controls. Mike ___ users mailing list users@lists.ironpython.com http://lists.ironpython.com/listinfo.cgi/users-ironpython.com