Skip to content

vm: with statement ignores a true non-bool __exit__ result #267

Open

Description

@drew-512

An __exit__ that returns a true value other than True does not silence the exception:

class Quiet:
    def __enter__(self):
        return self
    def __exit__(self, *exc):
        return 1

with Quiet():
    raise ValueError("boom")

print("ok")

On main (444ae5e):

ValueError: 'boom'

CPython prints ok: its WITH_CLEANUP tests the result with PyObject_IsTrue, while gpython's (vm/eval.go) compares it with py.True.

Go 1.27.1, darwin/arm64.

Activity

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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions