question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

crash with input longer than line width

See original GitHub issue

I’m using iPython 5.1.0 with the latest prompt_toolkit package (1.0.7). iPython crashes every time I input a line with more characters than my terminal’s current line width. The crash report generated with verbose_crash=True is attached.

Crash_report_ipython.txt

Issue Analytics

  • State:open
  • Created 7 years ago
  • Comments:9 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
takluyvercommented, Sep 20, 2016

Pinging @jonathanslenders . Here’s the last couple of frames from the traceback, for convenience:

/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/prompt_toolkit/layout/margins.pyc in create_margin(self=<prompt_toolkit.layout.margins.ConditionalMargin object>, cli=<prompt_toolkit.interface.CommandLineInterface object>, window_render_info=<prompt_toolkit.layout.containers.WindowRenderInfo object>, width=8, height=2)
    124     """
    125     def __init__(self, margin, filter):
    126         assert isinstance(margin, Margin)
    127 
    128         self.margin = margin
    129         self.filter = to_cli_filter(filter)
    130 
    131     def get_width(self, cli, ui_content):
    132         if self.filter(cli):
    133             return self.margin.get_width(cli, ui_content)
    134         else:
    135             return 0
    136 
    137     def create_margin(self, cli, window_render_info, width, height):
    138         if width and self.filter(cli):
--> 139             return self.margin.create_margin(cli, window_render_info, width, height)
        self.margin.create_margin = <bound method PromptMargin.create_margin of <prompt_toolkit.layout.margins.PromptMargin object at 0x10d7291d0>>
        cli = <prompt_toolkit.interface.CommandLineInterface object at 0x10d792f50>
        window_render_info = <prompt_toolkit.layout.containers.WindowRenderInfo object at 0x1114b9c90>
        width = 8
        height = 2
    140         else:
    141             return []
    142 
    143 
    144 class ScrollbarMargin(Margin):
    145     """
    146     Margin displaying a scrollbar.
    147 
    148     :param display_arrows: Display scroll up/down arrows.
    149     """
    150     def __init__(self, display_arrows=False):
    151         self.display_arrows = to_cli_filter(display_arrows)
    152 
    153     def get_width(self, cli, ui_content):
    154         return 1

/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/prompt_toolkit/layout/margins.pyc in create_margin(self=<prompt_toolkit.layout.margins.PromptMargin object>, cli=<prompt_toolkit.interface.CommandLineInterface object>, window_render_info=<prompt_toolkit.layout.containers.WindowRenderInfo object>, width=8, height=2)
    232         # Next lines. (Show line numbering when numbering is enabled.)
    233         if self.get_continuation_tokens:
    234             tokens2 = self.get_continuation_tokens(cli, width)
    235         else:
    236             tokens2 = []
    237 
    238         show_numbers = self.show_numbers(cli)
    239         last_y = None
    240 
    241         for y in window_render_info.displayed_lines[1:]:
    242             tokens.append((Token, '\n'))
    243             if show_numbers:
    244                 if y != last_y:
    245                     tokens.append((Token.LineNumber, ('%i ' % (y + 1)).rjust(width)))
    246             else:
--> 247                 tokens.extend(tokens2)
        tokens.extend = <built-in method extend of list object at 0x1114bf128>
        tokens2 = None
    248             last_y = y
    249 
    250         return tokens

TypeError: 'NoneType' object is not iterable
0reactions
minrkcommented, Nov 30, 2016

IPython in general should try to be resilient against anything user-configurable. One simple option is we could run the prompt once ourselves at startup to validate it.

Read more comments on GitHub >

github_iconTop Results From Across the Web

scanf() without field width limits can crash with huge input data
Add a field width specifier to fix this problem. Sample program that can crash: #include <stdio. h> int main() { char c[5]; scanf("%s",...
Read more >
Application crashes when you input text at the beginning of ...
You move the cursor to the beginning of the first line, and then you type a character. In this scenario, the application crashes....
Read more >
gpt2 generation crashes when using `past` for some output ...
I am using run_generation.py to generate text from gpt2, but with the code slightly changed to make use of past to cache hidden...
Read more >
crash(8) - Linux manual page - man7.org
The crash utility is designed to be independent of Linux version ... If it is the string "input", a page describing the various...
Read more >
Fuzzing with afl-fuzz — AFL 2.53b documentation
In this mode, the fuzzer takes one or more crashing test cases as the input, and uses its feedback-driven fuzzing strategies to very...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found