File tree Expand file tree Collapse file tree 3 files changed +23
-0
lines changed
Expand file tree Collapse file tree 3 files changed +23
-0
lines changed Original file line number Diff line number Diff line change 1+ import os
2+ import platform
3+
4+ from testutils import assert_raises
5+
6+ dir_path = os .path .dirname (os .path .realpath (__file__ ))
7+
8+ # TODO: RUSTPYTHON, RustPython raises a SyntaxError here, but cpython raise a ValueError
9+ error = SyntaxError if platform .python_implementation () == 'RustPython' else ValueError
10+ with assert_raises (error ):
11+ with open (os .path .join (dir_path , "non_utf8.txt" )) as f :
12+ eval (f .read ())
Original file line number Diff line number Diff line change @@ -145,6 +145,9 @@ where
145145 }
146146}
147147
148+ /// unicode_name2 does not expose `MAX_NAME_LENGTH`, so we replicate that constant here, fix #3798
149+ const MAX_UNICODE_NAME : usize = 88 ;
150+
148151impl < T > Lexer < T >
149152where
150153 T : Iterator < Item = char > ,
@@ -466,6 +469,14 @@ where
466469 }
467470 }
468471 }
472+
473+ if name. len ( ) > MAX_UNICODE_NAME {
474+ return Err ( LexicalError {
475+ error : LexicalErrorType :: UnicodeError ,
476+ location : self . get_pos ( ) ,
477+ } ) ;
478+ }
479+
469480 unicode_names2:: character ( & name) . ok_or ( LexicalError {
470481 error : LexicalErrorType :: UnicodeError ,
471482 location : start_pos,
You can’t perform that action at this time.
0 commit comments