-
Notifications
You must be signed in to change notification settings - Fork 226
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
Avoid trying to use IPython unless it seems like it is present #197
Conversation
__IPYTHON__ was apparently removed from only 0.11, and then the developers got negative feedback and restored it for 0.12: ipython/ipython#1059 Various versions of IPython break demand loaders badly. The current version is 5.1 or thereabouts, I am using 4.x. It is unlikely that someone would be using 0.11 (July 2011), so look for this variable first.
Is this the fix for #177? |
# this skips the pain of demandimporters when IPython | ||
# is available but not actually active: | ||
# https://bz.mercurial-scm.org/show_bug.cgi?id=5346 | ||
__IPYTHON__ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't understand how this can work. The first time IPython is imported is below this line. Wouldn't this only work if PuDB is started from within IPython? We want to support more than just that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My understanding is that this variable exists iff IPython has been imported. Wouldn't 'IPython' in sys.modules
be an equivalent check?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, I guess it's rather if an IPython instance exists, which is a stronger condition than IPython just being imported (don't know which is relevant here, as I don't really understand what this fix is doing in any case).
Indeed, I just verified, in this branch when starting PuDB not from IPython (like with Did you mean to put |
@@ -96,12 +96,19 @@ def have_ipython(): | |||
# https://github.com/ipython/ipython/issues/9435 | |||
|
|||
try: | |||
# Assume don't have IronPython unless this variable is |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Typo? (IPython doesn't stand for IronPython)
And for the record, I want to reiterate my comment from here that demandimport is really poorly designed on mercurial's part. It should affect only mercurial modules by default, not globally every module. Arbitrary Python libraries shouldn't expected to work with some deep evil builtins hack/magic. Nonetheless if the fix is simple, isolated, and doesn't change the code semantics, I'm fine with it (the fix here does change the code semantics). |
Ok. so. here's the deal: Lots of software is installed in an environment. I have python, mercurial, pygments, ipython (for use as a standalone shell), and I have pudb (to debug whatever). IPython does not play nicely with demandimporters. So, from my perspective as long as nothing uses it, I'm pretty happy. The only thing I expect to use IPython is me -- when I use it from a commandline. Which could include: ``` sh`
|
What specific problem does this address? (Sorry if I'm being dense) What's happening now that you think shouldn't? AFAICT, pudb does exactly what you ask, i.e. unless the shell setting is set to IPython and we're about to start IPython, pudb will not even import IPython. |
I just tested setting the shell to "classic" and in the shell, @jsoref maybe you are missing that you can change the shell in the settings ( |
I think the version of pudb I was using was before the (py)sh-4.3$ ipython
iPython 2.7.8 (default, Oct 7 2015, 09:24:26)
Type "copyright", "credits" or "license" for more information.
IPython 4.0.1 -- An enhanced Interactive Python.
? -> Introduction and overview of IPython's features.
%quickref -> Quick reference.
help -> Python's own help system.
object? -> Details about 'object', use 'object??' for extra details.
In [1]: import sys
In [2]: ', '.join([a for a in sys.modules if a.startswith('ipython')])
Out[2]: 'ipython_genutils.py3compat, ipython_genutils, ipython_genutils.re, ipython_genutils.locale, ipython_genutils.textwrap, ipython_genutils._version, ipython_genutils.errno, ipython_genutils.shutil, ipython_genutils.random, ipython_genutils.text, ipython_genutils.sys, ipython_genutils.importstring, ipython_genutils.functools, ipython_genutils.__builtin__, ipython_genutils.string, ipython_genutils.path, ipython_genutils.encoding, ipython_genutils.warnings, ipython_genutils.os, ipython_genutils.types' |
__IPYTHON__
was apparently removed from only 0.11,and then the developers got negative feedback and restored it
for 0.12:
ipython/ipython#1059
Various versions of IPython break demand loaders badly.
The current version is 5.1 or thereabouts, I am using 4.x.
It is unlikely that someone would be using 0.11 (July 2011),
so look for this variable first.
I know, this is not the first time we've tried to address IPython. The previous attempt dies as some part of IPython tries to do something that the demand loader isn't expecting. (And the demandloader people thought they'd fixed IPython). This approach works.