Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix comments on safe_isinstance() #602

Merged
merged 1 commit into from
Mar 18, 2023
Merged

Conversation

JelleZijlstra
Copy link
Contributor

isinstance() is even less safe than I thought.

Proof:

>>> class X:
...     @property
...     def __class__(self): 1/0
... 
>>> isinstance(X(), int)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "<stdin>", line 3, in __class__
ZeroDivisionError: division by zero

isinstance() is even less safe than I thought.

Proof:

```
>>> class X:
...     @Property
...     def __class__(self): 1/0
... 
>>> isinstance(X(), int)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "<stdin>", line 3, in __class__
ZeroDivisionError: division by zero
```
@JelleZijlstra JelleZijlstra merged commit 0cfe48a into master Mar 18, 2023
@JelleZijlstra JelleZijlstra deleted the JelleZijlstra-patch-1 branch March 18, 2023 18:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant