Closed as not planned
Closed as not planned
Description
Bug report
Bug description:
In Python 3.11.9, the following code does not raise an Exception
:
from typing import Any, Generic, TypeVar
T = TypeVar("T")
class DataSet(Generic[T]):
def __setattr__(self, name: str, value: Any) -> None:
object.__setattr__(self, name, value)
if name == "__orig_class__":
raise Exception("Just randomly raising an exception for illustrative purposes.")
class Schema:
pass
# initializing an object with type parameter `Schema` will call
# `__setattr__("__orig_class__", (Schema,))`
df = DataSet[Schema]()
In other versions of Python (e.g. 3.11.8 or 3.12.2) this raises an Exception
, but in Python 3.11.9 it appears this Exception
is caught.
I use something similar to the above logic in typedspark to check whether the DataSet
follows the schema specified in Schema
, and I raise an Exception
if it doesn't. As of Python 3.11.9, these exceptions are caught, hence breaking my logic.
Thank you for looking into this!
CPython versions tested on:
3.9, 3.10, 3.11, 3.12
Operating systems tested on:
Linux, macOS, Windows