Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't capture the output of help(0) in a python console #23

Closed
jchain opened this issue Jul 11, 2014 · 8 comments
Closed

Can't capture the output of help(0) in a python console #23

jchain opened this issue Jul 11, 2014 · 8 comments

Comments

@jchain
Copy link

jchain commented Jul 11, 2014

I saw this issue in an IronPython prompt of a cygwin session. The cygwin session ran in Mintty. The output of help(0) was empty. I could see a very short halt of the prompt but nothing showed. It should print the type information of the int 0. Other kinds of outputs seemed all right.

Do you have any idea about the causes to that? Thanks.

@rprichard
Copy link
Owner

I'm seeing a "The system cannot find the path specified." error using winpty. I'm looking into it.

@rprichard
Copy link
Owner

Probable workaround: mintty sets TERM to xterm. Instead, unset it or set it to dumb before running IronPython.

Long version:

Setting TERM to dumb will fix the problem.

FWIW, I've been considering having the winpty console program set TERM. winpty operates a hidden Windows console, so I've been thinking winpty should set TERM the same way that Cygwin would set it for a Windows console, which is TERM=cygwin. Doing so fixes a cursor key problem with less.

However, TERM=cygwin doesn't work for IronPython. Only TERM=dumb does.

So, maybe the right behavior is for console to unset TERM? Cygwin programs shouldn't care -- the Cygwin library will notice that it's running under a console. For non-Cygwin programs, TERM=xterm seems strictly more wrong than an unset TERM.

@jchain
Copy link
Author

jchain commented Jul 13, 2014

I tried export TERM=dumb and export TERM=. Either of them worked. The output of help(0) in the IronPython prompt was still empty.

Still thank you a lot for your effort on this issue.

@rprichard
Copy link
Owner

Could you tell me the versions of software you're using? In particular, I'd like to know what version of IronPython, winpty, and Cygwin DLL you're using, but other details like OS version, 32/64-bitness, and mintty version might help. Are you're using a precompiled winpty binary?

One idea I had -- maybe instead of clearing the TERM variable before invoking console, clear it inside the winpty console, e.g.:

mintty prompt> console cmd
cmd prompt> set TERM=
cmd prompt> cd /D "C:\Program Files\IronPython 2.7"
cmd prompt> ipy
ipy prompt> help(0)

@jchain
Copy link
Author

jchain commented Jul 13, 2014

Ironpython: 2.7.4 (32bit)
winpty: 0.1.1 (precompiled)
cygwin: 1.7.30 (32bit)
Windows 8.1 (64bit)
mintty: 1.1.3

Your new idea didn't work either. The TERM in cmd is dumb before setting it to empty. Thank you.

@rprichard
Copy link
Owner

Do you have a PAGER environment variable set? When I set it to less, I notice that help(0) stops working in IronPython. (Actually, IronPython doesn't seem to work with any PAGER setting. Even PAGER=more.com breaks it, with no winpty involvement. CPython works with PAGER=more.com.)

What does pydoc.getpager() evaluate to, for you? For me, with TERM=dumb, it's plainpager. If I set a PAGER, then I instead get a lambda.

rprichard@vbwin7 /cygdrive/c/Program Files/IronPython 2.7
$ /cygdrive/c/rprichard/winpty-0.1.1-cygwin/console.exe cmd
Microsoft Windows [Version 6.1.7601]
Copyright (c) 2009 Microsoft Corporation.  All rights reserved.

C:\Program Files\IronPython 2.7>set TERM=

C:\Program Files\IronPython 2.7>set PAGER=

C:\Program Files\IronPython 2.7>ipy
IronPython 2.7.4 (2.7.0.40) on .NET 4.0.30319.18444 (32-bit)
Type "help", "copyright", "credits" or "license" for more information.
>>> import pydoc
>>> pydoc.getpager()
<function plainpager at 0x000000000000002B>
>>> ^Z

C:\Program Files\IronPython 2.7>set PAGER=more.com

C:\Program Files\IronPython 2.7>ipy
IronPython 2.7.4 (2.7.0.40) on .NET 4.0.30319.18444 (32-bit)
Type "help", "copyright", "credits" or "license" for more information.
>>> import pydoc
>>> pydoc.getpager()
<function <lambda$95> at 0x000000000000002B>

@jchain
Copy link
Author

jchain commented Jul 13, 2014

Awesome. After set TERM= and set PAGER=, help(0) worked! Thank you so much for taking care of this.

@rprichard
Copy link
Owner

I think this issue is fixed now?

rprichard added a commit that referenced this issue Feb 1, 2017
I didn't see a noticeable slowdown in winpty invocation times.

This change *did* break IronPython's help() command, as expected, because
when winpty reinvokes itself, it sets TERM to cygwin.  I think the adapter
could unset TERM, but then it wouldn't be set if winpty were used to
invoke a Cygwin program.  (#23)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants