Skip to content

SystemError when printing symbol table entry #109207

Description

@yunline

Bug report

Bug description:

Platform: Windows10
Tested version: 3.10, 3.11, 3.12rc2

import symtable

script = "a=0"

symt = symtable.symtable(script, "test.py", "exec")
print(symt._table)
<symtable entry top(-1), line 0>OverflowError: Python int too large to convert to C long

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "x:\python\oneliner\__develop\symt.py", line 8, in <module>
    print(symt._table)
SystemError: <built-in method write of _io.TextIOWrapper object at 0x000001508B5559A0> returned a result with an exception set

CPython versions tested on:

3.12

Operating systems tested on:

Windows

Linked PRs

Activity

  1. serhiy-storchaka commented on Sep 10, 2023

    @serhiy-storchaka
    Member

    I can see what the problem can be.

    The repr first converts the table id to C long using PyLong_AS_LONG(). But the table id is just the id() of the corresponding AST node, and in Python it is an integer representation of pointer. Pointers are 64-bit on 64-bit platform, but C long is 32-bit on Windows. So we get an exception on 64-bit Windows.

    Marking this as easy issue, as what you only need is simply remove PyLong_AS_LONG(), replace the %ld format code with %S or %R, and add a test and a NEWS entry. Welcome!

  2. added 3 commits that reference this issue on Sep 10, 2023
    063c06b
    6697542
    132a15e
  3. added a commit that references this issue on Sep 10, 2023
  4. added 2 commits that reference this issue on Sep 10, 2023
  5. added a commit that references this issue on Sep 10, 2023
  6. added a commit that references this issue on Oct 2, 2023
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

    3.11only security fixes3.12only security fixes3.13only security fixesOS-windowseasytype-bugAn unexpected behavior, bug, or error

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions