Commit ea69e69
Make sure the type reference is removed from the seen references (#11145)
When parametrizing generic models, the `generic_recursion_self_type`
context manager is entered, and is used to avoid infinite recursions
if the same generic model happens to be parametrized again with the
same args during the first parametrization.
However, upon exiting the context manager (and thus when the parametrized
model is fully created), we forgot to remove the type ref from the set.
This happened only if we were already in the process of parametrizing
another model, as otherwise the `_generic_recursion_cache` would
be reset (see the `if token` condition).
In theory, this couldn't cause issues because parametrized models are
cached, and the cache is checked *before* entering the context manager.
However, because we have custom `mro()` implementation on the `BaseModel`
metaclass, this ends up causing issues is some really specific scenarios.
Co-authored-by: kc0506 <[email protected]>1 parent a07c31e commit ea69e69
2 files changed
Lines changed: 40 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
426 | 426 | | |
427 | 427 | | |
428 | 428 | | |
429 | | - | |
| 429 | + | |
| 430 | + | |
430 | 431 | | |
431 | 432 | | |
432 | 433 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3099 | 3099 | | |
3100 | 3100 | | |
3101 | 3101 | | |
| 3102 | + | |
| 3103 | + | |
| 3104 | + | |
| 3105 | + | |
| 3106 | + | |
| 3107 | + | |
| 3108 | + | |
| 3109 | + | |
| 3110 | + | |
| 3111 | + | |
| 3112 | + | |
| 3113 | + | |
| 3114 | + | |
| 3115 | + | |
| 3116 | + | |
| 3117 | + | |
| 3118 | + | |
| 3119 | + | |
| 3120 | + | |
| 3121 | + | |
| 3122 | + | |
| 3123 | + | |
| 3124 | + | |
| 3125 | + | |
| 3126 | + | |
| 3127 | + | |
| 3128 | + | |
| 3129 | + | |
| 3130 | + | |
| 3131 | + | |
| 3132 | + | |
| 3133 | + | |
| 3134 | + | |
| 3135 | + | |
| 3136 | + | |
| 3137 | + | |
| 3138 | + | |
| 3139 | + | |
0 commit comments