Skip to content
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

New REPL Traceback Not Formatted Correctly #123178

Closed
Siecje opened this issue Aug 20, 2024 · 5 comments
Closed

New REPL Traceback Not Formatted Correctly #123178

Siecje opened this issue Aug 20, 2024 · 5 comments
Labels
topic-repl Related to the interactive shell type-bug An unexpected behavior, bug, or error

Comments

@Siecje
Copy link
Contributor

Siecje commented Aug 20, 2024

Bug report

Bug description:

At first I thought it was because the window was small but it happens even if the window is large.

>>> import threading
>>> thread = threading.Thread(target=lambda: threading.current_thread().name == 'MainThread')
>>> thread.run()
>>> thread.join()
Traceback (most recent call last):
  File "<python-input-3>", line 1, in <module>
    thread.join()
    ~~~~~~~~~~~^^
  File "/Users/codyscott_1/.pyenv/versions/3.13t-dev/lib/python3.13t/threading.py", line 1083, in join
    raise RuntimeError("cannot join thread before it is started")
RuntimeError: cannot join thread before it is started
>>> thread.start()
Exception in thread Thread-1 (<lambda>):
>>> Traceback (most recent call last):
                                        File "/Users/codyscott_1/.pyenv/versions/3.13t-dev/lib/python3.13t/threading.py", line 991, in run
                                                                if self._target is not None:
                     ^^^^^^^^^^^^
                                 AttributeError: 'Thread' object has no attribute '_target'. Did you mean: '_started'?

                                        During handling of the above exception, another exception occurred:

                             Traceback (most recent call last):
                                                                 File "/Users/codyscott_1/.pyenv/versions/3.13t-dev/lib/python3.13t/threading.py", line 1041, in _bootstrap_inner
                         self.run()
                                       ~~~~~~~~^^
                                                   File "/Users/codyscott_1/.pyenv/versions/3.13t-dev/lib/python3.13t/threading.py", line 996, in run
                                                                           del self._target, self._args, self._kwargs
                                               ^^^^^^^^^^^^
                                                           AttributeError: 'Thread' object has no attribute '_target'

>>> 

CPython versions tested on:

3.13

Operating systems tested on:

macOS

@Siecje Siecje added the type-bug An unexpected behavior, bug, or error label Aug 20, 2024
@picnixz picnixz added the topic-repl Related to the interactive shell label Aug 20, 2024
@cfbolz
Copy link
Contributor

cfbolz commented Aug 24, 2024

confirmed on linux

@rruuaanng
Copy link
Contributor

rruuaanng commented Sep 6, 2024

I tested it on Ubuntu 22 and didn't encounter the issues mentioned, Maybe it's because my computer isn't a MacOS

Python 3.13.0rc1+ (heads/3.13:e5568e5e9da, Sep  6 2024, 09:06:23) [GCC 11.4.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
warning: can't use pyrepl: No module named 'msvcrt'
>>> import threading
>>> thread = threading.Thread(target=lambda: threading.current_thread().name == 'MainThread')
>>> thread.run()
>>> thread.join()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
    thread.join()
    ~~~~~~~~~~~^^
  File "/home/ruang/Desktop/cpython/Lib/threading.py", line 1083, in join
    raise RuntimeError("cannot join thread before it is started")
RuntimeError: cannot join thread before it is started
>>> thread.start()
Exception in thread Thread-1 (<lambda>):
>>> Traceback (most recent call last):
  File "/home/ruang/Desktop/cpython/Lib/threading.py", line 991, in run
    if self._target is not None:
       ^^^^^^^^^^^^
AttributeError: 'Thread' object has no attribute '_target'. Did you mean: '_started'?

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/ruang/Desktop/cpython/Lib/threading.py", line 1041, in _bootstrap_inner
    self.run()
    ~~~~~~~~^^
  File "/home/ruang/Desktop/cpython/Lib/threading.py", line 996, in run
    del self._target, self._args, self._kwargs
        ^^^^^^^^^^^^
AttributeError: 'Thread' object has no attribute '_target'

ambv added a commit to ambv/cpython that referenced this issue Sep 6, 2024
This switches the main pyrepl event loop to always be non-blocking so that it
can listen to incoming interruptions from other threads.

This also resolves invalid display of exceptions from other threads
(pythongh-123178).
ambv added a commit to ambv/cpython that referenced this issue Sep 6, 2024
This switches the main pyrepl event loop to always be non-blocking so that it
can listen to incoming interruptions from other threads.

This also resolves invalid display of exceptions from other threads
(pythongh-123178).
ambv added a commit that referenced this issue Sep 6, 2024
This switches the main pyrepl event loop to always be non-blocking so that it
can listen to incoming interruptions from other threads.

This also resolves invalid display of exceptions from other threads
(gh-123178).

This also fixes freezes with pasting and an active input hook.
miss-islington pushed a commit to miss-islington/cpython that referenced this issue Sep 6, 2024
…123795)

This switches the main pyrepl event loop to always be non-blocking so that it
can listen to incoming interruptions from other threads.

This also resolves invalid display of exceptions from other threads
(pythongh-123178).

This also fixes freezes with pasting and an active input hook.
(cherry picked from commit 033510e)

Co-authored-by: Łukasz Langa <lukasz@langa.pl>
ambv added a commit that referenced this issue Sep 6, 2024
… (#123799)

This switches the main pyrepl event loop to always be non-blocking so that it
can listen to incoming interruptions from other threads.

This also resolves invalid display of exceptions from other threads
(gh-123178).

This also fixes freezes with pasting and an active input hook.
(cherry picked from commit 033510e)

Co-authored-by: Łukasz Langa <lukasz@langa.pl>
@ambv
Copy link
Contributor

ambv commented Sep 6, 2024

Fixed by #123799.

@ambv ambv closed this as completed Sep 6, 2024
@Siecje
Copy link
Contributor Author

Siecje commented Sep 9, 2024

I just tried with 3.13.0rc2 and I get a KeyboardInterrupt after the traceback.

>>> import threading
>>> thread = threading.Thread(target=lambda: threading.current_thread().name == 'MainThread')
>>> thread.run()
>>> thread.join()
Traceback (most recent call last):
  File "<python-input-3>", line 1, in <module>
    thread.join()
    ~~~~~~~~~~~^^
  File "/Users/codyscott_1/.pyenv/versions/3.13.0rc2/lib/python3.13/threading.py", line 1083, in join
    raise RuntimeError("cannot join thread before it is started")
RuntimeError: cannot join thread before it is started
>>> thread.start()
>>> 
Exception in Thread-1 (<lambda>):
Traceback (most recent call last):
  File "/Users/codyscott_1/.pyenv/versions/3.13.0rc2/lib/python3.13/threading.py", line 991, in run
    if self._target is not None:
       ^^^^^^^^^^^^
AttributeError: 'Thread' object has no attribute '_target'. Did you mean: '_started'?

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Users/codyscott_1/.pyenv/versions/3.13.0rc2/lib/python3.13/threading.py", line 1041, in _bootstrap_inner
    self.run()
    ~~~~~~~~^^
  File "/Users/codyscott_1/.pyenv/versions/3.13.0rc2/lib/python3.13/threading.py", line 996, in run
    del self._target, self._args, self._kwargs
        ^^^^^^^^^^^^
AttributeError: 'Thread' object has no attribute '_target'

>>> 
KeyboardInterrupt

@Siecje
Copy link
Contributor Author

Siecje commented Oct 4, 2024

I get the same KeyboardInterrupt after with Python 3.13.0rc3.

>>> 
KeyboardInterrupt
>>> 

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
topic-repl Related to the interactive shell type-bug An unexpected behavior, bug, or error
Projects
None yet
Development

No branches or pull requests

5 participants