Skip to content

Commit 63c6de7

Browse files
authored
nanopb.patch: fix ValueError: invalid mode: 'rU' bug in nanopb_generator.py in python 3.11. (#10440)
1 parent 963db4d commit 63c6de7

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

cmake/external/nanopb.patch

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,17 @@ diff -Naur nanopb/CMakeLists.txt nanopb-fix/CMakeLists.txt
1010
execute_process(
1111
COMMAND ${PYTHON_EXECUTABLE} -c
1212
"from distutils import sysconfig; print(sysconfig.get_python_lib(prefix=''))"
13+
diff -Naur nanopb/generator/nanopb_generator.py nanopb-fix/generator/nanopb_generator.py
14+
--- nanopb/generator/nanopb_generator.py 2021-03-22 08:50:07.000000000 -0400
15+
+++ nanopb-fix/generator/nanopb_generator.py 2022-11-01 15:37:38.112297044 -0400
16+
@@ -1641,7 +1641,9 @@
17+
optfilename = os.path.join(p, optfilename)
18+
if options.verbose:
19+
sys.stderr.write('Reading options from ' + optfilename + '\n')
20+
- Globals.separate_options = read_options_file(open(optfilename, "rU"))
21+
+ # Patch in https://github.com/nanopb/nanopb/commit/01e9186a8b to avoid
22+
+ # using "U" in the filemode, whose support was removed in Python 3.11.
23+
+ Globals.separate_options = read_options_file(open(optfilename, 'r', encoding = 'utf-8'))
24+
break
25+
else:
26+
# If we are given a full filename and it does not exist, give an error.

0 commit comments

Comments
 (0)