Skip to content

REPL errors out on numpy.array initialization expression #879

Closed

Description

@georgipeev

As the user starts typing a numpy.array initialization expression, the REPL produces a TypeError and exits.
Consider the following example, where the error is produced when the user tries to type np.array([1, 2:

(env) /Users/georgepf>bpython
bpython version 0.20.1 on top of Python 3.9.1 /Users/georgepf/env/bin/python3
>>>  import numpy as np
>>>  np.array([1, 
Traceback (most recent call last):
  File "/Users/georgepf/env/bin/bpython", line 8, in <module>
    sys.exit(main())
  File "/Users/georgepf/env/lib/python3.9/site-packages/bpython/curtsies.py", line 221, in main
    exit_value = repl.mainloop(True, paste)
  File "/Users/georgepf/env/lib/python3.9/site-packages/bpython/curtsies.py", line 133, in mainloop
    self.process_event_and_paint(e)
  File "/Users/georgepf/env/lib/python3.9/site-packages/bpython/curtsies.py", line 97, in process_event_and_paint
    self.process_event(e)
  File "/Users/georgepf/env/lib/python3.9/site-packages/bpython/curtsiesfrontend/repl.py", line 658, in process_event
    return self.process_key_event(e)
  File "/Users/georgepf/env/lib/python3.9/site-packages/bpython/curtsiesfrontend/repl.py", line 825, in process_key_event
    self.add_normal_character(e)
  File "/Users/georgepf/env/lib/python3.9/site-packages/bpython/curtsiesfrontend/repl.py", line 1111, in add_normal_character
    self.cursor_offset += 1
  File "/Users/georgepf/env/lib/python3.9/site-packages/bpython/curtsiesfrontend/repl.py", line 1821, in _set_cursor_offset
    self.update_completion()
  File "/Users/georgepf/env/lib/python3.9/site-packages/bpython/curtsiesfrontend/repl.py", line 1143, in update_completion
    self.list_win_visible = self.complete(tab)
  File "/Users/georgepf/env/lib/python3.9/site-packages/bpython/repl.py", line 770, in complete
    self.matches_iter.update(
  File "/Users/georgepf/env/lib/python3.9/site-packages/bpython/repl.py", line 356, in update
    self.start, self.end, self.current_word = self.completer.locate(
TypeError: cannot unpack non-iterable NoneType object
(env) /Users/georgepf>

This was on an M1 MacBook Pro running macOS Big Sur 11.1, python 3.9.1 and bpython are running natively on Apple silicon, numpy is 1.21.0 compiled locally for M1.

Activity

  1. sebastinas commented on Jan 21, 2021

    @sebastinas
    Contributor

    Unfortunately I'm unable to reproduce the issue with both bpython 0.20.1 and master and numpy 1.19.5. So could you gives us some more info on the installed packages, e.g. versions of six, curtsies, jedi and so on.

  2. added
    moreinfoMore information required from the submitter
    on Mar 3, 2021
  3. erikv85 commented on Mar 8, 2021

    @erikv85

    Have the same issue, bpython version 0.18 on top of Python 3.8.5, numpy version 1.20.1.

  4. sebastinas commented on Mar 9, 2021

    @sebastinas
    Contributor

    @erikv85 Can you try with a more recent version of bpython? Do you have jedi installed?

  5. erikv85 commented on Mar 9, 2021

    @erikv85

    @sebastinas Upgraded to version 0.21, problem remains.

    jedi: I didn''t have jedi installed (i.e., doesn't show in "pip3 list"), installed 0.18.0, problem remains.
    six: 1.14.0
    curtsies: 0.3.5

  6. sebastinas commented on Mar 9, 2021

    @sebastinas
    Contributor

    @erikv85 Also on macOS?

  7. erikv85 commented on Mar 9, 2021

    @erikv85

    @sebastinas Ubuntu 20.04.2, uname -r -> 5.8.0-44-generic.

  8. sebastinas commented on Mar 9, 2021

    @sebastinas
    Contributor

    Does that happen within in a virtual env? Is numpy installed in that venv? Is bpython installed in that venv and run from within the venv? (Sorry for all the questions, but I'm still unable to reproduce the issue; even with the same Ubuntu version).

  9. erikv85 commented on Mar 9, 2021

    @erikv85

    I'm not very familiar with virtualenv, so I probably didn't install bpython that way.

    Re-created it in a Docker image. Something like this:

    cat << EOF > Dockerfile
    FROM ubuntu:20.04
    RUN apt-get update
    RUN apt-get upgrade -y
    RUN apt-get install -y python3 python3-pip
    RUN pip3 install numpy bpython
    RUN useradd -ms /bin/bash me
    WORKDIR /home/me
    EOF
    docker build . -t bpy
    docker run -di --name todaybpy bpy
    

    Finally enter the image (container? ...)
    docker exec -u me -it todaybpy bash
    and try commands as in OP, which will crash.

  10. added and removed
    moreinfoMore information required from the submitter
    on Mar 10, 2021
  11. sebastinas commented on Mar 10, 2021

    @sebastinas
    Contributor

    Thanks @erikv85, I was now able to reproduce the issue.

  12. added a commit that references this issue on Feb 25, 2026
    34f0e70
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions