Skip to content

Bpython crashed after executing nonlocal in interactive. #1051

@XiJet-Gary

Description

@XiJet-Gary

Version:

bpython version 0.26 on top of Python 3.14.3 /usr/bin/python

Excute:

nonlocal a

Then:

~> bpython
bpython version 0.26 on top of Python 3.14.3 /usr/bin/python
>>> nonlocal a
Traceback (most recent call last):
  File "/usr/lib/python3.14/code.py", line 64, in runsource
    code = self.compile(source, filename, symbol)
  File "/usr/lib/python3.14/codeop.py", line 154, in __call__
    return _maybe_compile(self.compiler, source, filename, symbol, flags=self.compiler.flags)
  File "/usr/lib/python3.14/codeop.py", line 75, in _maybe_compile
    return compiler(source, filename, symbol, incomplete_input=False)
  File "/usr/lib/python3.14/codeop.py", line 117, in __call__
    codeob = compile(source, filename, symbol, flags, True)
  File "<bpython-input-3>", line 1
SyntaxError: nonlocal declaration not allowed at module level

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/bin/bpython", line 8, in <module>
    sys.exit(main())
             ~~~~^^
  File "/usr/lib/python3.14/site-packages/bpython/curtsies.py", line 249, in main
    repl.mainloop(True, paste)
    ~~~~~~~~~~~~~^^^^^^^^^^^^^
  File "/usr/lib/python3.14/site-packages/bpython/curtsies.py", line 173, in mainloop
    self.process_event_and_paint(e)
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^
  File "/usr/lib/python3.14/site-packages/bpython/curtsies.py", line 136, in process_event_and_paint
    self.process_event(e)
    ~~~~~~~~~~~~~~~~~~^^^
  File "/usr/lib/python3.14/site-packages/bpython/curtsiesfrontend/repl.py", line 645, in process_event
    self.process_key_event(e)
    ~~~~~~~~~~~~~~~~~~~~~~^^^
  File "/usr/lib/python3.14/site-packages/bpython/curtsiesfrontend/repl.py", line 785, in process_key_event
    self.on_enter()
    ~~~~~~~~~~~~~^^
  File "/usr/lib/python3.14/site-packages/bpython/curtsiesfrontend/repl.py", line 953, in on_enter
    self.push(self.current_line, insert_into_history=new_code)
    ~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.14/site-packages/bpython/curtsiesfrontend/repl.py", line 1293, in push
    self.run_code_and_maybe_finish()
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^
  File "/usr/lib/python3.14/site-packages/bpython/curtsiesfrontend/repl.py", line 1297, in run_code_and_maybe_finish
    r = self.coderunner.run_code(for_code=for_code)
  File "/usr/lib/python3.14/site-packages/bpython/curtsiesfrontend/coderunner.py", line 138, in run_code
    request = self.code_context.switch()
  File "/usr/lib/python3.14/site-packages/bpython/curtsiesfrontend/coderunner.py", line 185, in _blocking_run_code
    unfinished = self.interp.runsource(self.source)
  File "/usr/lib/python3.14/site-packages/bpython/repl.py", line 152, in runsource
    return super().runsource(source, filename, symbol)
           ~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.14/code.py", line 67, in runsource
    self.showsyntaxerror(filename, source=source)
    ~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.14/site-packages/bpython/repl.py", line 166, in showsyntaxerror
    args = list(value.args[1])
                ~~~~~~~~~~^^^
IndexError: tuple index out of range

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions