GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — code.interact() gives SyntaxError instead of SyntaxWarning · Issue #97562 · python/cpython

code.interact() gives SyntaxError instead of SyntaxWarning #97562

New issue
Copy link
New issue
Copy link
Closed
Closed
code.interact() gives SyntaxError instead of SyntaxWarning#97562
Copy link
Labels
type-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error

Description

@aroberge
aroberge
opened on Sep 26, 2022
Issue body actions

Bug report

In the example below, the normal interpreter only emits a SyntaxWarning which, upon execution, gives rise to a TypeError, whereas code.interact() gives a SyntaxError right away.

Python 3.11.0rc2 (main, Sep 11 2022, 20:22:52) [MSC v.1933 64 bit (AMD64)] on win32
>>> def test():
...    [1, 2, 3]()
...
<stdin>:2: SyntaxWarning: 'list' object is not callable; perhaps you missed a comma?
>>> test()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "<stdin>", line 2, in test
TypeError: 'list' object is not callable
>>>
>>> import code
>>> code.interact()
(InteractiveConsole)
>>> def test():
...    [1, 2, 3]()
  File "<console>", line 2
SyntaxError: 'list' object is not callable; perhaps you missed a comma?

In addition to the above, I have been able to reproduce this with Python 3.9 and 3.10, but not with earlier Python versions.

Activity

  1. aroberge
    added
    type-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error
    on Sep 26, 2022
  2. vstinner commented on Sep 26, 2022

    @vstinner
    vstinner
    on Sep 26, 2022
    Member
    More actions

    cc @serhiy-storchaka

  3. serhiy-storchaka commented on Sep 26, 2022

    @serhiy-storchaka
    serhiy-storchaka
    on Sep 26, 2022
    Member
    More actions

    Seems it was fixed in #96052.

  4. serhiy-storchaka
    closed this as completedon Sep 29, 2022
  5. aroberge commented on Oct 24, 2022

    @aroberge
    aroberge
    on Oct 24, 2022
    ContributorAuthor
    More actions

    This was not fixed.

    > python
    Python 3.11.0 (main, Oct 24 2022, 18:26:48) [MSC v.1933 64 bit (AMD64)] on win32
    Type "help", "copyright", "credits" or "license" for more information.
    >>> def test():
    ...    [1, 2, 3]()
    ...
    <stdin>:2: SyntaxWarning: 'list' object is not callable; perhaps you missed a comma?
    >>> test()
    Traceback (most recent call last):
      File "<stdin>", line 1, in <module>
      File "<stdin>", line 2, in test
    TypeError: 'list' object is not callable
    >>> import code
    >>> code.interact()
    Python 3.11.0 (main, Oct 24 2022, 18:26:48) [MSC v.1933 64 bit (AMD64)] on win32
    Type "help", "copyright", "credits" or "license" for more information.
    (InteractiveConsole)
    >>> def test():
    ...    [1, 2, 3]()
      File "<console>", line 2
    SyntaxError: 'list' object is not callable; perhaps you missed a comma?
    
  6. serhiy-storchaka commented on Oct 25, 2022

    @serhiy-storchaka
    serhiy-storchaka
    on Oct 25, 2022
    Member
    More actions

    I only get a warning.

  7. aroberge commented on Oct 25, 2022

    @aroberge
    aroberge
    on Oct 25, 2022
    ContributorAuthor
    More actions

    I got a warning with 3.12.0a1, but not with 3.11.0. I assume it will be fixed in 3.11.1 and this can remained closed.

  8. vstinner commented on Nov 3, 2022

    @vstinner
    vstinner
    on Nov 3, 2022
    Member
    More actions

    I confirm that the fix is not in Python 3.11.0 final: you will have to wait for Python 3.11.1 bugfix release.

    Python 3.11.0 has the bug (raise SyntaxError):

    $ /opt/py311/bin/python3 -m code
    Python 3.11.0 (main, Oct 31 2022, 12:39:47) [GCC 12.2.1 20220819 (Red Hat 12.2.1-2)] on linux
    Type "help", "copyright", "credits" or "license" for more information.
    (InteractiveConsole)
    >>> def test(): [1, 2, 3]()
      File "<console>", line 1
    SyntaxError: 'list' object is not callable; perhaps you missed a comma?
    >>> 
    now exiting InteractiveConsole...
    

    The 3.11 development branch has the fix (display a warning):

    vstinner@mona$ ./python -m code
    Python 3.11.0+ (heads/3.11:eb023a84d9, Nov  3 2022, 15:59:57) [GCC 12.2.1 20220819 (Red Hat 12.2.1-2)] on linux
    Type "help", "copyright", "credits" or "license" for more information.
    (InteractiveConsole)
    >>> def test(): [1, 2, 3]()
    ... 
    <console>:1: SyntaxWarning: 'list' object is not callable; perhaps you missed a comma?
    >>> 
    now exiting InteractiveConsole...
    
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-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      You are visitor 01402503 — GeezerVison does not store the pages you look up.
      Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.