fix crash when serializing a type-ignored property setter#3493
fix crash when serializing a type-ignored property setter#3493gvanrossum merged 3 commits intopython:masterfrom
Conversation
This fixes the crash from python#3491. I wasn't able to reproduce the crash in a test, even with '# flags: --incremental', so I'm not adding any new tests. Do I need some special flags to make tests write the cache?
|
I think only tests in check-incremental.test and tests whose name ends in 'Incremental' exercise serialization. |
|
So please add such a test. |
Turns out the cache isn't written if there is any error, and I had a reveal_type which counts as an error. The change fixes both bugs from the original issue: - Without --disallow-untyped-defs, it no longer crashes during cache serialization. - With --disallow-untyped-defs, it no longer produces a spurious error because "self" doesn't have an annotation.
|
Thanks, it turns out the issue was that the cache isn't written when there is an error in the file, and I had a reveal_type(), which counts as an error. In other news, it turns out that this PR also fixes the other bug reported in #3491 (the spurious "missing type annotation" error). Therefore, I added tests both with and without |
| item.func.is_abstract = first_item.func.is_abstract | ||
| item.func.accept(self) | ||
| else: | ||
| self.fail("Decorated property not supported", item) |
There was a problem hiding this comment.
This should also be fixed (it's in a sense the true reason for the issue). But not in this PR.
gvanrossum
left a comment
There was a problem hiding this comment.
Great work. I'll merge once tests pass again after my PEP 8 change.
|
Oh, sorry, I should have copied your updated PR description. Oh well. |
* master: fix crash when serializing a type-ignored property setter (python#3493)
This fixes two issues from #3491: a crash in serialization and an incorrect error "Function is missing a type annotation for one or more arguments". Both had the same root cause; we were skipping semantic analysis for the function body if mypy was unhappy with the property.setter decorator.