Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Weirdint.__str__ behaviour inside sub-interpreters #117482

Open
Labels
3.12only security fixes3.13bugs and security fixes3.14bugs and security fixestopic-subinterpreterstype-bugAn unexpected behavior, bug, or error
@mliezun

Description

@mliezun

Bug report

Bug description:

Hi Python maintainers!

I noticed something weird when using subinterpreters, while converting an Enum to string I get an unexpected result. This occurs in Python 3.12 and 3.13.

Here's an script to reproduce it:

import_xxsubinterpretersasinterpretersscript="""from enum import _simple_enum, IntEnum@_simple_enum(IntEnum)class MyEnum:    DATA = 1print(str(MyEnum.DATA))"""exec(script)# Output: 1interp_id=interpreters.create(isolated=False)interpreters.run_string(interp_id,script)# Output: <MyEnum.DATA: 1>, Expected: 1

In all python versions previous to 3.12 this prints "1" two times, on newer versions I get<MyEnum.DATA: 1> when running inside a subinterpreter. For some reason, the__str__ function being used is different on new Python versions.

I also noticed that the function pointed by__str__ is different inside and outside the subinterpreter.

Outside:

...print(MyEnum.DATA.__str__)# Output: <method-wrapper '__repr__' of MyEnum object at 0x7f9a09a2e910>

Inside:

...print(MyEnum.DATA.__str__)# Output: <method-wrapper '__str__' of MyEnum object at 0x7f9a099a5e90>

NOTE: I'm creating subinterpreters passing theisolated=False flag, which uses theLegacy init config.
I first noticed the error on MacOS, then reproduced using Docker with various Python versions.

I hope this is enough to get to the source of the issue.

Appreciate all your work and effort on building Python, thank you!

CPython versions tested on:

3.8, 3.9, 3.10, 3.11, 3.12, 3.13

Operating systems tested on:

Linux, macOS

Linked PRs

Metadata

Metadata

Assignees

No one assigned

    Labels

    3.12only security fixes3.13bugs and security fixes3.14bugs and security fixestopic-subinterpreterstype-bugAn unexpected behavior, bug, or error

    Projects

    Status

    Todo

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions


      [8]ページ先頭

      ©2009-2025 Movatter.jp