-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
Crash when using try/except in platform-specific code in a function that takes an TypeVar argument #9682
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
Comments
Thanks for the report! Stack trace looks similar to #9615 (seems like the cast to Var is just faulty). Probably something like the fact that we're in "unreachable" code means there isn't a SymbolTableNode where it expects one to be. |
That correlates with other things I've seen. I did some digging around in mypy's internals, and it seems that I tried other some statements that would render it "unreachable." |
Fixes python#9615, fixes python#9682 Both issue reports hit the faulty cast on L2803. This changes the logic so that that cast is actually always true. If not, we just end up doing whatever the fallback else clause does; this resulted in behaviour that matched what I expected. After that, the python#9682 hit another crash in checker.py, where var.node was None instead of a Var. It seemed reasonable to just branch instead.
Fixes python#9615, fixes python#9682 Both issue reports hit the faulty cast on L2803. This changes the logic so that that cast is actually always true. If not, we just end up doing whatever the fallback else clause does; this resulted in behaviour that matched what I expected. After that, the python#9682 hit another crash in checker.py, where var.node was None instead of a Var. It seemed reasonable to just branch instead.
Fixes #9615, fixes #9682 Both issue reports hit the faulty cast on L2803. This changes the logic so that that cast is actually always true. If not, we just end up doing whatever the fallback else clause does; this resulted in behaviour that matched what I expected. After that, the #9682 hit another crash in checker.py, where var.node was None instead of a Var. It seemed reasonable to just branch instead. Co-authored-by: hauntsaninja <>
Fixes #9615, fixes #9682 Both issue reports hit the faulty cast on L2803. This changes the logic so that that cast is actually always true. If not, we just end up doing whatever the fallback else clause does; this resulted in behaviour that matched what I expected. After that, the #9682 hit another crash in checker.py, where var.node was None instead of a Var. It seemed reasonable to just branch instead. Co-authored-by: hauntsaninja <>
Crash Report
I added some platform-specific code to my program in a very specific context, and mypy started crashing with an
INTERNAL ERROR
. I managed to get it down to a minimal example below.Traceback
To Reproduce
I managed to simplify my code down to this:
For some reason, it must be in a function that takes
TypeVar
/AnyStr
argument, and it must be in anif
statement that performs asys.platform
check that isn't true on the current platform (I've reproduced this on both Linux and Windows).Your Environment
master
)mypy.ini
(and other config files): N/AAs mentioned above, I was also able to reproduce this on Windows (Python 3.8.4, mypy 0.790).
The text was updated successfully, but these errors were encountered: