Skip to content

Error on unicode surrogates in mypyc - #21936

Open
ilevkivskyi wants to merge 1 commit into
python:masterfrom
ilevkivskyi:fix-surrogate-nativeparse
Open

Error on unicode surrogates in mypyc#21936
ilevkivskyi wants to merge 1 commit into
python:masterfrom
ilevkivskyi:fix-surrogate-nativeparse

Conversation

@ilevkivskyi

Copy link
Copy Markdown
Member

This PR is expected to fail until mypyc/ast_serialize#82 is merged and released.

cc @JukkaL

@github-actions

github-actions Bot commented Sep 4, 2026

Copy link
Copy Markdown
Contributor

Diff from mypy_primer, showing the effect of this PR on open source code:

packaging (https://github.com/pypa/packaging)
+ src/packaging/__init__.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.4.0+dev.4afbdec6456574fcc4f3ec75245d870c9f8dfcf3
+ src/packaging/__init__.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 154, in main
+     res, messages, blockers = run_build(sources, options, fscache, t0, stdout, stderr)
+   File "/main.py", line 244, in run_build
+     res = build.build(sources, options, None, flush_errors, fscache, stdout, stderr)
+   File "/build.py", line 422, in build
+     result = build_inner(
+   File "/build.py", line 537, in build_inner
+     graph = dispatch(sources, manager, stdout, connect_threads)
+   File "/build.py", line 4078, in dispatch
+     graph = load_graph(sources, manager)
+   File "/build.py", line 4311, in load_graph
+     manager.parse_all([state for state in new if state.needs_parse])
+   File "/build.py", line 1054, in parse_all
+     with state.wrap_context():
+   File "/opt/hostedtoolcache/Python/3.14.7/x64/lib/python3.14/contextlib.py", line 162, in __exit__
+     self.gen.throw(value)
+   File "/build.py", line 3075, in wrap_context
+     yield
+   File "/build.py", line 1063, in parse_all
+     state.tree = load_from_raw(
+                  ~~~~~~~~~~~~~^
+         state.xpath,
+         ^^^^^^^^^^^^
+     ...<4 lines>...
+         imports_only=bool(self.workers),
+         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+     )
+     ^
+   File "/parse.py", line 80, in load_from_raw
+     defs = read_statements(state, data, n)
+   File "/nativeparse.py", line 269, in read_statements
+     stmt = read_statement(state, data)
+   File "/nativeparse.py", line 318, in read_statement
+     rvalue = read_expression(state, data)
+   File "/nativeparse.py", line 1351, in read_expression
+     se.has_surrogates = read_bool(data)
+                         ~~~~~~~~~^^^^^^
+ ValueError: invalid bool value
+ 

nox (https://github.com/wntrblm/nox)
- nox/virtualenv.py:52: error: Cannot find implementation or library stub for module named "python_discovery"  [import-not-found]
- nox/virtualenv.py:147: error: Cannot find implementation or library stub for module named "platformdirs"  [import-not-found]
- nox/virtualenv.py:367: error: Cannot find implementation or library stub for module named "pbs_installer"  [import-not-found]
- nox/_cli.py:195: error: Cannot find implementation or library stub for module named "python_discovery"  [import-not-found]
- nox/_cli.py:195: note: See https://mypy.readthedocs.io/en/stable/running_mypy.html#missing-imports
+ nox/__init__.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.4.0+dev.4afbdec6456574fcc4f3ec75245d870c9f8dfcf3
+ nox/__init__.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 154, in main
+     res, messages, blockers = run_build(sources, options, fscache, t0, stdout, stderr)
+   File "/main.py", line 244, in run_build
+     res = build.build(sources, options, None, flush_errors, fscache, stdout, stderr)
+   File "/build.py", line 422, in build
+     result = build_inner(
+   File "/build.py", line 537, in build_inner
+     graph = dispatch(sources, manager, stdout, connect_threads)
+   File "/build.py", line 4078, in dispatch
+     graph = load_graph(sources, manager)
+   File "/build.py", line 4311, in load_graph
+     manager.parse_all([state for state in new if state.needs_parse])
+   File "/build.py", line 1054, in parse_all
+     with state.wrap_context():
+   File "/opt/hostedtoolcache/Python/3.14.7/x64/lib/python3.14/contextlib.py", line 162, in __exit__
+     self.gen.throw(value)
+   File "/build.py", line 3075, in wrap_context
+     yield
+   File "/build.py", line 1063, in parse_all
+     state.tree = load_from_raw(
+                  ~~~~~~~~~~~~~^
+         state.xpath,
+         ^^^^^^^^^^^^
+     ...<4 lines>...
+         imports_only=bool(self.workers),
+         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+     )
+     ^
+   File "/parse.py", line 80, in load_from_raw
+     defs = read_statements(state, data, n)
+   File "/nativeparse.py", line 269, in read_statements
+     stmt = read_statement(state, data)
+   File "/nativeparse.py", line 318, in read_statement
+     rvalue = read_expression(state, data)
+   File "/nativeparse.py", line 1506, in read_expression
+     items = read_expression_list(state, data)
+   File "/nativeparse.py", line 1761, in read_expression_list
+     return [read_expression(state, data) for i in range(n)]
+             ~~~~~~~~~~~~~~~^^^^^^^^^^^^^
+   File "/nativeparse.py", line 1351, in read_expression
+     se.has_surrogates = read_bool(data)
+                         ~~~~~~~~~^^^^^^
+ ValueError: invalid bool value
+ 

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