[IronPython] ironpython alternative to PyOS_ReadlineFunctionPointer

Dino Viehland dinov at exchange.microsoft.com
Wed Jul 5 18:47:39 CEST 2006


Thanks for the bug report - this one should be pretty easy to fix, we'll try and get it in for the next release.

-----Original Message-----
From: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] On Behalf Of Jörgen Stenarson
Sent: Tuesday, July 04, 2006 11:59 AM
To: Discussion of IronPython
Subject: Re: [IronPython] ironpython alternative to PyOS_ReadlineFunctionPointer

Dino,

thanks for your suggestion. It worked out fine. Now I have basic typing in pyreadline but I still have work to do to get editing and keyboard shortcuts to work. I'll post again when I have something more useful.

While doing this I stumbled on this traceback inconsistency to cpython which took me a while to figure out.

Python 2.4.3 (#69, Mar 29 2006, 17:35:34) [MSC v.1310 32 bit (Intel)] on
win32
Type "help", "copyright", "credits" or "license" for more information.
 >>> def c():
...     pass
...
 >>> a,b=c()
Traceback (most recent call last):
   File "<stdin>", line 1, in ?
TypeError: unpack non-sequence
 >>>


IronPython 1.0.2375 (Beta) on .NET 2.0.50727.42 Copyright (c) Microsoft Corporation. All rights reserved.
 >>> def c():
...     pass
...
 >>> a,b=c()
Traceback (most recent call last):
   File , line 0, in <stdin>##58
TypeError: None is not enumerable
 >>>



/Jörgen





Dino Viehland skrev:
> Unfortunately there's currently no way to switch this from Python code.
>
> What we need to do is expose something in IronPythonConsole.exe which lets you set PythonCommandLine.MyConsole (currently you can't do this because PythonCommandLine is private).  If you made PythonCommandLine public you could do clr.AddReference('IronPythonConsole.exe') and then from IronPythonConsole  import PythonCommandLine, IConsole.  Finally you can implement your own console:
>
> class MyConsole(IConsole):
>         def ReadLine(autoIndentSize): pass
>         def Write(text, style): pass
>         def WriteLine(text, style): pass
>
>
> and then call PythonCommandLine.MyConsole = MyConsole()
>
> and those methods will override the interface implementation (or in other words - it's quite easy to deal with overriding methods :) ).
>
> That's the hacky way to get to where you can start experimenting with this.  We probably need to come up w/ a better long-term way to do this.  This is an unfortunate side effect of the runtime & console being so separated - the runtime doesn't know anything about the console, and the console can't use the runtime's stdin because it needs to be able to deal w/ input such as arrow keys.
>
> I don't know that we could do anything here before 1.0, but I'll open a CodePlex bug for improving console <-> runtime interop.
>
>
_______________________________________________
users mailing list
users at lists.ironpython.com
http://lists.ironpython.com/listinfo.cgi/users-ironpython.com



More information about the Ironpython-users mailing list