Repository navigation
Fix native parser cache version mismatch for non-UTF-8 files - #22434
Merged
Merged
Conversation
Contributor
|
Diff from mypy_primer, showing the effect of this PR on open source code: pywin32 (https://github.com/mhammond/pywin32)
- ./pythonwin/pywin/test/_dbgscript.py: error: INTERNAL ERROR -- Please try using mypy master on GitHub:
- https://mypy.readthedocs.io/en/stable/common_issues.html#using-a-development-mypy-build
- Please report a bug at https://github.com/python/mypy/issues
- version: 2.5.0+dev.a0dda1c08e861018029fea6aaa2140e4d6c58333
- ./pythonwin/pywin/test/_dbgscript.py: note: use --pdb to drop into pdb
- Traceback (most recent call last):
- File "", line 6, in <module>
- sys.exit(console_entry())
- File "/__main__.py", line 16, in console_entry
- main()
- File "/main.py", line 167, in main
- res, messages, blockers = run_build(sources, options, fscache, t0, stdout, stderr)
- File "/main.py", line 257, in run_build
- res = build.build(sources, options, None, flush_errors, fscache, stdout, stderr)
- File "/build.py", line 427, in build
- result = build_inner(
- File "/build.py", line 542, in build_inner
- graph = dispatch(sources, manager, stdout, connect_threads)
- File "/build.py", line 4152, in dispatch
- graph = load_graph(sources, manager)
- File "/build.py", line 4385, in load_graph
- manager.parse_all([state for state in new if state.needs_parse])
- File "/build.py", line 1057, in parse_all
- with state.wrap_context():
- File "/opt/hostedtoolcache/Python/3.14.10/x64/lib/python3.14/contextlib.py", line 162, in __exit__
- self.gen.throw(value)
- File "/build.py", line 3119, in wrap_context
- yield
- File "/build.py", line 1066, in parse_all
- state.tree = load_from_raw(
- ~~~~~~~~~~~~~^
- state.xpath,
- ^^^^^^^^^^^^
- ...<4 lines>...
- imports_only=bool(self.workers),
- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
- )
- ^
- File "/parse.py", line 83, in load_from_raw
- defs = read_statements(state, data, n)
- File "/nativeparse.py", line 389, in read_statements
- stmt = read_statement(state, data)
- File "/nativeparse.py", line 535, in read_statement
- return read_func_def(state, data)
- File "/nativeparse.py", line 882, in read_func_def
- func_def.has_type_comments = read_bool(data)
- ~~~~~~~~~^^^^^^
- ValueError: invalid bool value
-
+ AutoDuck/Dump2HHC.py:85:5: note: By default the bodies of untyped functions are not checked, consider using --check-untyped-defs [annotation-unchecked]
+ win32/Demos/win32ts_logoff_disconnected.py:16:48: error: Argument 2 to "WTSQuerySessionInformation" has incompatible type "str | int"; expected "int" [arg-type]
+ win32/Demos/win32ts_logoff_disconnected.py:20:73: error: Argument 2 to "WTSLogoffSession" has incompatible type "str | int"; expected "int" [arg-type]
+ win32/scripts/VersionStamp/bulkstamp.py:94:5: note: By default the bodies of untyped functions are not checked, consider using --check-untyped-defs [annotation-unchecked]
+ win32/Lib/sspi.py:29:9: note: By default the bodies of untyped functions are not checked, consider using --check-untyped-defs [annotation-unchecked]
+ win32/Demos/security/set_policy_info.py:5:20: error: "LsaQueryInformationPolicy" does not return a value (it only ever returns None) [func-returns-value]
+ win32/Demos/security/set_policy_info.py:10:23: error: Value of type "None" is not indexable [index]
+ win32/Demos/security/set_policy_info.py:25:24: error: Argument 1 to "LsaClose" has incompatible type "PyLSA_HANDLE"; expected "int" [arg-type]
+ win32/Demos/security/lsastore.py:12:24: error: Argument 1 to "LsaClose" has incompatible type "PyLSA_HANDLE"; expected "int" [arg-type]
+ win32/Demos/security/get_policy_info.py:14:5: error: "LsaQueryInformationPolicy" does not return a value (it only ever returns None) [func-returns-value]
+ win32/Demos/security/get_policy_info.py:17:7: error: Cannot determine type of "domain_name" [has-type]
+ win32/Demos/security/get_policy_info.py:17:20: error: Cannot determine type of "dns_domain_name" [has-type]
+ win32/Demos/security/get_policy_info.py:17:37: error: Cannot determine type of "dns_forest_name" [has-type]
+ win32/Demos/security/get_policy_info.py:17:54: error: Cannot determine type of "domain_guid" [has-type]
+ win32/Demos/security/get_policy_info.py:17:67: error: Cannot determine type of "domain_sid" [has-type]
+ win32/Demos/security/get_policy_info.py:19:20: error: "LsaQueryInformationPolicy" does not return a value (it only ever returns None) [func-returns-value]
+ win32/Demos/security/get_policy_info.py:24:20: error: "LsaQueryInformationPolicy" does not return a value (it only ever returns None) [func-returns-value]
+ win32/Demos/security/get_policy_info.py:27:7: error: Cannot determine type of "domain_name" [has-type]
+ win32/Demos/security/get_policy_info.py:27:20: error: Cannot determine type of "sid" [has-type]
+ win32/Demos/security/get_policy_info.py:29:20: error: "LsaQueryInformationPolicy" does not return a value (it only ever returns None) [func-returns-value]
+ win32/Demos/security/get_policy_info.py:32:7: error: Cannot determine type of "domain_name" [has-type]
+ win32/Demos/security/get_policy_info.py:32:20: error: Cannot determine type of "sid" [has-type]
+ win32/Demos/security/get_policy_info.py:34:15: error: "LsaQueryInformationPolicy" does not return a value (it only ever returns None) [func-returns-value]
+ win32/Demos/security/get_policy_info.py:39:24: error: Argument 1 to "LsaClose" has incompatible type "PyLSA_HANDLE"; expected "int" [arg-type]
+ win32/Demos/security/setuserobjectsecurity.py:74:44: error: Argument 3 to "AdjustTokenPrivileges" has incompatible type "tuple[tuple[int, int], tuple[int, int], tuple[int, int], tuple[int, int], tuple[int, int], tuple[int, int], tuple[int, int], tuple[int, int], tuple[int, int], tuple[int, int], tuple[int, int], tuple[int, int]]"; expected "PyTOKEN_PRIVILEGES" [arg-type]
+ win32/Demos/security/setuserobjectsecurity.py:78:5: error: "GetProcessWindowStation" does not return a value (it only ever returns None) [func-returns-value]
+ win32/Demos/security/setuserobjectsecurity.py:79:42: error: Argument 1 to "GetUserObjectSecurity" has incompatible type "None"; expected "int" [arg-type]
+ win32/Demos/security/setuserobjectsecurity.py:90:37: error: Argument 1 to "SetUserObjectSecurity" has incompatible type "None"; expected "int" [arg-type]
+ win32/Demos/security/setuserobjectsecurity.py:91:46: error: Argument 1 to "GetUserObjectSecurity" has incompatible type "None"; expected "int" [arg-type]
+ win32/Demos/win32console_demo.py:80:25: error: No overload variant of "get" of "dict" matches argument types "int", "str" [call-overload]
+ win32/Demos/win32console_demo.py:80:25: note: Possible overload variants:
+ win32/Demos/win32console_demo.py:80:25: note: def get(self, str, None = ..., /) -> Any | None
+ win32/Demos/win32console_demo.py:80:25: note: def get(self, str, Any, /) -> Any
+ win32/Demos/win32console_demo.py:80:25: note: def [_T] get(self, str, _T, /) -> Any | _T
+ win32/Demos/dde/ddeclient.py:17:6: error: Too many arguments for "Request" of "PyDDEConv" [call-arg]
+ win32/Demos/dde/ddeclient.py:17:6: error: "Request" of "PyDDEConv" does not return a value (it only ever returns None) [func-returns-value]
+ win32/Lib/win32timezone.py:673: error: Unused "type: ignore" comment [unused-ignore]
+ win32/Lib/win32timezone.py:728: error: Unused "type: ignore" comment [unused-ignore]
+ win32/Lib/win32timezone.py:739: error: Unused "type: ignore" comment [unused-ignore]
+ win32/Demos/win32cred_demo.py:59:43: error: Argument 1 to "ImpersonateLoggedOnUser" has incompatible type "PyHANDLE"; expected "int" [arg-type]
+ win32/Demos/win32cred_demo.py:65:43: error: Argument 1 to "NetUserGetInfo" has incompatible type "None"; expected "str" [arg-type]
+ win32/Demos/win32cred_demo.py:73:9: error: Argument 1 to "LoadUserProfile" has incompatible type "PyHANDLE"; expected "int" [arg-type]
+ win32/Demos/win32cred_demo.py:73:13: error: Argument 2 to "LoadUserProfile" has incompatible type "dict[str, int | str | Any | None]"; expected "PyPROFILEINFO" [arg-type]
+ win32/Demos/win32cred_demo.py:76:47: error: Argument 1 to "CreateEnvironmentBlock" has incompatible type "PyHANDLE"; expected "int" [arg-type]
+ win32/Demos/win32cred_demo.py:79:36: error: Argument 1 to "UnloadUserProfile" has incompatible type "PyHANDLE"; expected "int" [arg-type]
+ win32/Demos/print_desktop.py:13:53: error: Argument 4 to "DocumentProperties" has incompatible type "None"; expected "PyDEVMODEW" [arg-type]
+ win32/Demos/print_desktop.py:13:59: error: Argument 5 to "DocumentProperties" has incompatible type "None"; expected "PyDEVMODEW" [arg-type]
+ win32/Demos/print_desktop.py:38:29: error: Argument 2 to "SelectObject" has incompatible type "PyGdiHANDLE"; expected "int | PyHANDLE | None" [arg-type]
+ win32/Demos/print_desktop.py:55:29: error: Argument 2 to "SelectObject" has incompatible type "PyGdiHANDLE"; expected "int | PyHANDLE | None" [arg-type]
+ win32/Demos/print_desktop.py:100:5: error: Argument 4 to "DrawText" has incompatible type "tuple[int, int, int, int]"; expected "PyRECT" [arg-type]
+ win32/Demos/getfilever.py:28:1: error: Unpacking a string is disallowed [str-unpack]
+ win32/Demos/desktopmanager.py:226:23: error: "GetUserObjectInformation" does not return a value (it only ever returns None) [func-returns-value]
+ win32/Demos/desktopmanager.py:227:5: error: Argument 1 to "GetUserObjectInformation" has incompatible type "PyHDESK"; expected "int" [arg-type]
+ win32/Demos/RegRestoreKey.py:30:61: error: Argument 3 to "AdjustTokenPrivileges" has incompatible type "tuple[tuple[int, int], tuple[int, int]]"; expected "PyTOKEN_PRIVILEGES" [arg-type]
+ win32/Demos/RegRestoreKey.py:38:9: error: Argument 1 to "RegCreateKeyEx" has incompatible type "int"; expected "PyHKEY" [arg-type]
+ win32/Demos/RegRestoreKey.py:62:9: error: Argument 1 to "RegCreateKeyEx" has incompatible type "int"; expected "PyHKEY" [arg-type]
+ win32/Demos/RegCreateKeyTransacted.py:11:5: error: Argument 1 to "RegCreateKeyEx" has incompatible type "int"; expected "PyHKEY" [arg-type]
+ win32/Demos/RegCreateKeyTransacted.py:22:9: error: Argument "Key" to "RegOpenKeyTransacted" has incompatible type "int"; expected "PyHKEY" [arg-type]
+ win32/Demos/RegCreateKeyTransacted.py:60:23: error: Argument 1 to "RegDeleteKey" has incompatible type "int"; expected "PyHKEY" [arg-type]
+ win32/Demos/CopyFileEx.py:52:5: error: Argument 3 to "CopyFileEx" has incompatible type "Callable[[Any, Any, Any, Any, Any, Any, Any, Any, Any], Any]"; expected "CopyProgressRoutine | None" [arg-type]
+ win32/Demos/security/setsecurityinfo.py:74:56: error: Argument 3 to "AdjustTokenPrivileges" has incompatible type "tuple[tuple[int, int], tuple[int, int], tuple[int, int], tuple[int, int], tuple[int, int], tuple[int, int], tuple[int, int], tuple[int, int], tuple[int, int], tuple[int, int], tuple[int, int], tuple[int, int]]"; expected "PyTOKEN_PRIVILEGES" [arg-type]
+ win32/Demos/security/setsecurityinfo.py:122:5: error: Argument 4 to "SetSecurityInfo" has incompatible type "None"; expected "PySID" [arg-type]
+ win32/Demos/security/setsecurityinfo.py:123:5: error: Argument 5 to "SetSecurityInfo" has incompatible type "None"; expected "PySID" [arg-type]
+ win32/Demos/security/setsecurityinfo.py:124:5: error: Argument 6 to "SetSecurityInfo" has incompatible type "None"; expected "PyACL" [arg-type]
+ win32/Demos/security/setsecurityinfo.py:125:5: error: Argument 7 to "SetSecurityInfo" has incompatible type "None"; expected "PyACL" [arg-type]
+ win32/Demos/security/setnamedsecurityinfo.py:75:44: error: Argument 3 to "AdjustTokenPrivileges" has incompatible type "tuple[tuple[int, int], tuple[int, int], tuple[int, int], tuple[int, int], tuple[int, int], tuple[int, int], tuple[int, int], tuple[int, int], tuple[int, int], tuple[int, int], tuple[int, int], tuple[int, int]]"; expected "PyTOKEN_PRIVILEGES" [arg-type]
+ win32/Demos/security/setkernelobjectsecurity.py:77:12: error: Argument 3 to "AdjustTokenPrivileges" has incompatible type "tuple[tuple[Any, int], ...]"; expected "PyTOKEN_PRIVILEGES" [arg-type]
+ win32/Demos/security/setkernelobjectsecurity.py:128:33: error: Argument 2 to "SetSecurityDescriptorSacl" of "PySECURITY_DESCRIPTOR" has incompatible type "None"; expected "PyACL" [arg-type]
+ win32/Demos/security/set_file_owner.py:43:44: error: Argument 3 to "AdjustTokenPrivileges" has incompatible type "tuple[tuple[int, int], tuple[int, int], tuple[int, int], tuple[int, int], tuple[int, int], tuple[int, int], tuple[int, int]]"; expected "PyTOKEN_PRIVILEGES" [arg-type]
+ win32/Demos/security/set_file_owner.py:62:5: error: "GetLength" of "PySECURITY_DESCRIPTOR" does not return a value (it only ever returns None) [func-returns-value]
+ win32/Demos/security/set_file_audit.py:34:61: error: Argument 3 to "AdjustTokenPrivileges" has incompatible type "tuple[tuple[int, int], tuple[int, int]]"; expected "PyTOKEN_PRIVILEGES" [arg-type]
+ win32/Demos/security/regsecurity.py:21:44: error: Argument 3 to "AdjustTokenPrivileges" has incompatible type "tuple[tuple[int, int], tuple[int, int]]"; expected "PyTOKEN_PRIVILEGES" [arg-type]
+ win32/Demos/security/regsecurity.py:23:40: error: Argument 3 to "RegOpenKey" has incompatible type "int"; expected "bool" [arg-type]
+ win32/Demos/security/regsecurity.py:27:28: error: Argument 3 to "RegOpenKey" has incompatible type "int"; expected "bool" [arg-type]
+ win32/Demos/security/regsave_sa.py:37:44: error: Argument 3 to "AdjustTokenPrivileges" has incompatible type "tuple[tuple[int, int], tuple[int, int], tuple[int, int], tuple[int, int]]"; expected "PyTOKEN_PRIVILEGES" [arg-type]
+ win32/Demos/security/regsave_sa.py:41:40: error: Argument 3 to "RegOpenKey" has incompatible type "int"; expected "bool" [arg-type]
+ win32/Demos/security/regsave_sa.py:43:44: error: Argument 3 to "RegOpenKey" has incompatible type "int"; expected "bool" [arg-type]
+ win32/Demos/security/list_rights.py:25:44: error: Argument 3 to "AdjustTokenPrivileges" has incompatible type "tuple[tuple[int, int], tuple[int, int], tuple[int, int]]"; expected "PyTOKEN_PRIVILEGES" [arg-type]
+ win32/Demos/security/list_rights.py:35:24: error: Argument 1 to "LsaClose" has incompatible type "PyLSA_HANDLE"; expected "int" [arg-type]
+ win32/Demos/security/account_rights.py:25:44: error: Argument 3 to "AdjustTokenPrivileges" has incompatible type "tuple[tuple[int, int], tuple[int, int], tuple[int, int]]"; expected "PyTOKEN_PRIVILEGES" [arg-type]
+ win32/Demos/security/account_rights.py:36:59: error: Argument 3 to "LsaAddAccountRights" has incompatible type "list[str]"; expected "tuple[Any, ...]" [arg-type]
+ win32/Demos/security/account_rights.py:43:65: error: Argument 4 to "LsaRemoveAccountRights" has incompatible type "list[str]"; expected "tuple[Any, ...]" [arg-type]
+ win32/Demos/security/account_rights.py:49:24: error: Argument 1 to "LsaClose" has incompatible type "PyLSA_HANDLE"; expected "int" [arg-type]
+ win32/Demos/security/sspi/validate_password.py:41:47: error: Cannot determine type of "msg" [has-type]
+ win32/Demos/security/sspi/validate_password.py:41:52: error: Cannot determine type of "hr" [has-type]
+ win32/Demos/security/sspi/simple_auth.py:54:17: error: "QueryContextAttributes" of "PyCtxtHandle" does not return a value (it only ever returns None) [func-returns-value]
+ win32/Demos/security/sspi/simple_auth.py:58:11: error: Value of type "None" is not indexable [index]
+ win32/Demos/security/sspi/simple_auth.py:67:15: error: Value of type "None" is not indexable [index]
+ win32/Demos/security/explicit_entries.py:46:44: error: Argument 3 to "AdjustTokenPrivileges" has incompatible type "tuple[tuple[int, int], tuple[int, int], tuple[int, int], tuple[int, int], tuple[int, int], tuple[int, int]]"; expected "PyTOKEN_PRIVILEGES" [arg-type]
+ win32/Demos/security/explicit_entries.py:121:26: error: Argument 1 to "SetEntriesInAcl" of "PyACL" has incompatible type "list[dict[str, Any]]"; expected "tuple[dict[str, int | dict[str, int | PySID]], ...]" [arg-type]
+ win32/Demos/security/explicit_entries.py:149:26: error: Argument 1 to "SetEntriesInAcl" of "PyACL" has incompatible type "list[dict[str, Any]]"; expected "tuple[dict[str, int | dict[str, int | PySID]], ...]" [arg-type]
+ win32/Demos/dde/ddeserver.py:36:17: error: Argument 1 to "AddTopic" of "PyDDEServer" has incompatible type "MySystemTopic"; expected "PyDDETopic" [arg-type]
... (truncated 29 lines) ...
|
JukkaL
approved these changes
Nov 10, 2026
JukkaL
left a comment
Collaborator
There was a problem hiding this comment.
Thanks for the quick fix!
ilevkivskyi
pushed a commit
that referenced
this pull request
Nov 14, 2026
…22474) #22434 made the native parser pass `AST_SERIALIZE_CACHE_VERSION` to `ast_serialize`, but `native_parse_type_string()` still passes a hardcoded `cache_version=5` to `ast_serialize.parse_type_string()` (the constant is now 7). The serialized output for type strings happens to be the same for versions 5 and 7 today, so nothing is broken yet, but the next version bump that changes the type encoding would be missed by this call and `read_type()` would then read data written in an older format. This uses the constant here as well.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fix is trivial.
cc @JukkaL