Skip to content

New REPL Traceback Not Formatted Correctly #123178

Description

@Siecje

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

Activity

  1. added
    type-bugAn unexpected behavior, bug, or error
    on Aug 20, 2024
  2. cfbolz commented on Aug 24, 2024

    @cfbolz
    Contributor

    confirmed on linux

  3. rruuaanng commented on Sep 6, 2024

    @rruuaanng
    Contributor

    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'
    
  4. added 3 commits that reference this issue on Sep 6, 2024
  5. added a commit that references this issue on Sep 6, 2024
  6. added a commit that references this issue on Sep 6, 2024
  7. ambv commented on Sep 6, 2024

    @ambv
    Contributor

    Fixed by #123799.

  8. Siecje commented on Sep 9, 2024

    @Siecje
    ContributorAuthor

    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
  9. Siecje commented on Oct 4, 2024

    @Siecje
    ContributorAuthor

    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

Metadata

Metadata

Assignees

No one assigned

    Labels

    topic-replRelated to the interactive shelltype-bugAn unexpected behavior, bug, or error

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions