Skip to content

crash on line typing (TypeError: 'NoneType' object is not iterable) #726

Closed

Description

@nil0x42

Steps to reproduce:

bpython version 0.16 on top of Python 3.6.4 /usr/bin/python
>>> from PyQt5 import Qt
>>> Qt.QWidget.setFocusPolicy(Qt.

(error happens after typing last '.' dot)

Traceback:

Traceback (most recent call last):
  File "/usr/bin/bpython", line 11, in <module>
    load_entry_point('bpython==0.16', 'console_scripts', 'bpython')()
  File "/usr/lib/python3.6/site-packages/bpython/curtsies.py", line 190, in main
    exit_value = repl.mainloop()
  File "/usr/lib/python3.6/site-packages/bpython/curtsies.py", line 125, in mainloop
    self.process_event_and_paint(e)
  File "/usr/lib/python3.6/site-packages/bpython/curtsies.py", line 89, in process_event_and_paint
    self.process_event(e)
  File "/usr/lib/python3.6/site-packages/bpython/curtsiesfrontend/repl.py", line 584, in process_event
    return self.process_key_event(e)
  File "/usr/lib/python3.6/site-packages/bpython/curtsiesfrontend/repl.py", line 736, in process_key_event
    self.add_normal_character(e)
  File "/usr/lib/python3.6/site-packages/bpython/curtsiesfrontend/repl.py", line 972, in add_normal_character
    self.cursor_offset += 1
  File "/usr/lib/python3.6/site-packages/bpython/curtsiesfrontend/repl.py", line 1544, in _set_cursor_offset
    self.update_completion()
  File "/usr/lib/python3.6/site-packages/bpython/curtsiesfrontend/repl.py", line 1003, in update_completion
    self.list_win_visible = BpythonRepl.complete(self, tab)
  File "/usr/lib/python3.6/site-packages/bpython/repl.py", line 720, in complete
    self.current_line, matches, completer)
  File "/usr/lib/python3.6/site-packages/bpython/repl.py", line 331, in update
    self.orig_cursor_offset, self.orig_line)
TypeError: 'NoneType' object is not iterable

System:

Archlinux x64
bpython 0.16
python 3.6.4

Activity

  1. self-assigned this
    on Feb 12, 2018
  2. AustinTSchaffer commented on Nov 14, 2019

    @AustinTSchaffer

    I'm getting a similar issue, but without requiring an external dependency. Figured I'd add my own reproduction steps. I've also included a screenshot which shows color information.

    The issue seems to be occurring any time I try to tab-complete a dict key when all of the keys contain a slash and have a shared prefix. This is occurring in cases where I'm using the names of a collection of files as keys in a dict. My workaround is to not use tab completion in those cases.

    I love this project and this tool by the way, use it every day. Let me know if there's anything else I can do to help with this.

    Steps to Reproduce

    For reference, the last sequence of keypresses was x, [, then <tab>

    bpython version 0.18 on top of Python 3.5.3 /home/austin/workspace/migrations/xxx/venv/bin/python3
    >>> x = {}
    >>> x["a/b"] = 1
    >>> x["a/c"] = 1
    >>> x["a/c"] = 1
    Traceback (most recent call last):
      File "/home/austin/workspace/migrations/xxx/venv/bin/bpython", line 10, in <module>
        sys.exit(main())
      File "/home/austin/workspace/migrations/xxx/venv/lib/python3.5/site-packages/bpython/curtsies.py", line 191, in main
        exit_value = repl.mainloop(True, paste)
      File "/home/austin/workspace/migrations/xxx/venv/lib/python3.5/site-packages/bpython/curtsies.py", line 126, in mainloop
        self.process_event_and_paint(e)
      File "/home/austin/workspace/migrations/xxx/venv/lib/python3.5/site-packages/bpython/curtsies.py", line 90, in process_event_and_paint
        self.process_event(e)
      File "/home/austin/workspace/migrations/xxx/venv/lib/python3.5/site-packages/bpython/curtsiesfrontend/repl.py", line 595, in process_event
        return self.process_key_event(e)
      File "/home/austin/workspace/migrations/xxx/venv/lib/python3.5/site-packages/bpython/curtsiesfrontend/repl.py", line 726, in process_key_event
        self.on_tab()
      File "/home/austin/workspace/migrations/xxx/venv/lib/python3.5/site-packages/bpython/curtsiesfrontend/repl.py", line 841, in on_tab
        cursor_and_line = self.matches_iter.substitute_cseq()
      File "/home/austin/workspace/migrations/xxx/venv/lib/python3.5/site-packages/bpython/repl.py", line 333, in substitute_cseq
        self.completer)
      File "/home/austin/workspace/migrations/xxx/venv/lib/python3.5/site-packages/bpython/repl.py", line 353, in update
        self.orig_cursor_offset, self.orig_line)
    TypeError: 'NoneType' object is not iterable
    

    image

    Working

    x = {}
    x["a/b"] = 1
    x[
    x = {}
    x["a/b"] = 1
    x["a.b"] = 1
    x[
    x = {}
    x["a/b"] = 1
    x["a.b"] = 1
    x["a/c"] = 1
    x[
    x = {}
    x["a/b"] = 1
    x["b/d"] = 1
    x[
    x = {}
    x["a/"] = 1
    x["b/"] = 1
    x["a/b"] = 1
    x[

    Not Working

    x = {}
    x["a/"] = 1
    x["a//"] = 1
    x[
    x = {}
    x["./a"] = 1
    x["./b"] = 1
    x["./c"] = 1
    x[
    x = {}
    x["asdfasdfasdf/1"] = 1
    x["asdfasdfasdf/2"] = 2
    x["asdfasdfasdf/3"] = 3
    x[

    System

    Debian 9 (uname -a # Linux debian 4.9.0-9-amd64 #1 SMP Debian 4.9.168-1+deb9u5 (2019-08-11) x86_64 GNU/Linux)
    bpython 0.18
    Python 3.5.3

  3. MoburgLeGrand commented on Mar 15, 2021

    @MoburgLeGrand

    I was about to open a new issue but i think it's the same as this one, so I'll post my issue here in case that can help.

    I'm working with numpy arrays, and i get a really weird crash when trying to create an integer array. Basically, I can create any type of arrays just fine, except when I want to create an integer array with either 2 or 3 as numbers (yeah, it's really weird).

    What works

    >>> import numpy as np 
    >>> np.array(['test1', 'test2'])
    array(['test1', 'test2'], dtype='<U5')
    >>> np.array([1, 6])
    array([1, 6])
    

    Doesn't work

    But if I try the exact same array as the second, but try to replace either number by either a 2 or a 3, i get a similar crash as people above :

    >>> np.array([1, 6])
    Traceback (most recent call last):
      File "/home/julien/.venv/Actuartech_Python_intro/bin/bpython", line 8, in <module>
        sys.exit(main())
      File "/home/julien/.venv/Actuartech_Python_intro/lib/python3.8/site-packages/bpython/curtsies.py", line 201, in main
        exit_value = repl.mainloop(True, paste)
      File "/home/julien/.venv/Actuartech_Python_intro/lib/python3.8/site-packages/bpython/curtsies.py", line 121, in mainloop
        self.process_event_and_paint(e)
      File "/home/julien/.venv/Actuartech_Python_intro/lib/python3.8/site-packages/bpython/curtsies.py", line 85, in process_event_and_paint
        self.process_event(e)
      File "/home/julien/.venv/Actuartech_Python_intro/lib/python3.8/site-packages/bpython/curtsiesfrontend/repl.py", line 615, in process_event
        return self.process_key_event(e)
      File "/home/julien/.venv/Actuartech_Python_intro/lib/python3.8/site-packages/bpython/curtsiesfrontend/repl.py", line 782, in process_key_event
        self.add_normal_character(e)
      File "/home/julien/.venv/Actuartech_Python_intro/lib/python3.8/site-packages/bpython/curtsiesfrontend/repl.py", line 1068, in add_normal_character
        self.cursor_offset += 1
      File "/home/julien/.venv/Actuartech_Python_intro/lib/python3.8/site-packages/bpython/curtsiesfrontend/repl.py", line 1780, in _set_cursor_offset
        self.update_completion()
      File "/home/julien/.venv/Actuartech_Python_intro/lib/python3.8/site-packages/bpython/curtsiesfrontend/repl.py", line 1100, in update_completion
        self.list_win_visible = self.complete(tab)
      File "/home/julien/.venv/Actuartech_Python_intro/lib/python3.8/site-packages/bpython/repl.py", line 723, in complete
        self.matches_iter.update(
      File "/home/julien/.venv/Actuartech_Python_intro/lib/python3.8/site-packages/bpython/repl.py", line 318, in update
        self.start, self.end, self.current_word = self.completer.locate(
    TypeError: cannot unpack non-iterable NoneType object
    

    System

    Ubuntu 20.04
    Python 3.8.5
    bpython 0.21

  4. added this to the release-0.22 milestone on Mar 16, 2021
  5. sebastinas commented on Mar 16, 2021

    @sebastinas
    Contributor

    Fixed in 34f0e70.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions