-
Notifications
You must be signed in to change notification settings - Fork 16
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
Indentation changed since 0.2.0 #9
Comments
pure_eval doesn't deal with formatting so I can't imagine how it could affect this. stack_data would make more sense but I still don't know how. Can you provide a minimal script which reproduces the difference? The IPython PR you linked seems to be about the 7.x branch which doesn't use stack_data, but maybe that's irrelevant.
I see one additional expression, not a change in order of existing expressions. |
That might not be easy... I have just tried to reproduce it manually via typing things into IPython console and I see different indentation than via IPython testing suite. Manually:
Via ipdoctests:
That test is currently disabled in the main branch, and I was going to revive it (now I think I should not have been even bothered to 😆).
I would expect the function arguments to be first and after that everything else, now local variables are in between of function arguments. |
It sounds likely that this has something to do with IPython itself, maybe the data that it puts in linecache.
The variables are being fetched in https://github.com/ipython/ipython/blob/master/IPython/core/ultratb.py#L677 which calls https://github.com/alexmojaki/stack_data/blob/1434eff144df5743e25f8e3b1db3ddfd30749cef/stack_data/core.py#L833 which as far as I can see orders variables by the lineno they first appear in but sets no order within each line. |
Reproducer: import builtins
import doctest
def get_ipython():
from IPython.terminal.interactiveshell import TerminalInteractiveShell
if TerminalInteractiveShell._instance:
return TerminalInteractiveShell.instance()
from IPython.testing import tools
config = tools.default_config()
config.TerminalInteractiveShell.simple_prompt = True
# Create and initialize our test-friendly IPython instance.
shell = TerminalInteractiveShell.instance(config=config)
return shell
builtins.get_ipython = get_ipython
builtins._ip = get_ipython()
builtins.ip = get_ipython()
builtins.ip.builtin_trap.activate()
text = """
In [19]: %run simpleerr.py exit 2
An exception has occurred, use %tb to see the full traceback.
SystemExit: (2, 'Mode = exit')
In [23]: %xmode verbose
Exception reporting mode: Verbose
In [24]: %tb
---------------------------------------------------------------------------
SystemExit Traceback (most recent call last)
<BLANKLINE>
... in <module>
29 except IndexError:
30 mode = 'div'
---> 32 bar(mode)
mode = 'exit'
<BLANKLINE>
... in bar(mode='exit')
20 except:
21 stat = 1
---> 22 sysexit(stat, mode)
mode = 'exit'
stat = 2
23 else:
24 raise ValueError('Unknown mode')
<BLANKLINE>
... in sysexit(stat=2, mode='exit')
10 def sysexit(stat, mode):
---> 11 raise SystemExit(stat, 'Mode = %s' % mode)
stat = 2
mode = 'exit'
<BLANKLINE>
SystemExit: (2, 'Mode = exit')
"""
filename = 'asd.py'
name = 'asd'
globs = {"__name__": "__main__"}
from IPython.testing.plugin.ipdoctest import IPDoctestOutputChecker, IPDocTestRunner, IPDocTestParser
optionflags = doctest.NORMALIZE_WHITESPACE | doctest.ELLIPSIS
checker = IPDoctestOutputChecker()
runner = IPDocTestRunner(optionflags=optionflags,
checker=checker, verbose=False)
parser = IPDocTestParser()
test = parser.get_doctest(text, globs, name, filename, 0)
import os
import IPython.core.tests
os.chdir(os.path.dirname(IPython.core.tests.__file__))
failures = None
runner.run(test, out=failures, clear_globs=False) It is fine when run after
It could be IPython itself. I am fine with closing the issue if you think it is unlikely to be a pure_eval bug. |
This script is definitely way too separated from pure_eval for me to work with. I don't want to figure out what's going on in IPython tests. If you can reproduce using only stack_data (see the last code snippet in https://github.com/alexmojaki/stack_data) I'll take a look. I notice your test data doesn't show the value of |
I think the indentation difference came with switching to stack_data in ipython/ipython#11886 and I was just fooled by test failure diff that shows indentation difference even when it would be ignored later. Sorry for bothering you. |
Since
pure_eval>=0.2.0
stack traces thatstack_data
generates had changed in indentation, was that intentional? (IPython
tests were affected by that ipython/ipython#12874)In 0.1.1:
Since 0.2.0:
Full diff https://gist.github.com/Kojoley/fe2f74026457e84e65818201c9c6ce15/revisions (it also shows a strange decision in locals order showing)
Previously original code indentation was shown in the backtrace and now it is deindented by 1 step.
I have bisected the change to 73767d9 commit.
The text was updated successfully, but these errors were encountered: