File tree Expand file tree Collapse file tree 1 file changed +9
-4
lines changed Expand file tree Collapse file tree 1 file changed +9
-4
lines changed Original file line number Diff line number Diff line change @@ -504,10 +504,15 @@ def handle_control_symbol(self, symbol):
504504
505505
506506 def handle_u (self , codepoint ):
507- # This ridiculous trick gives a surrogate pair for
508- # non-BMP codepoints on narrow Pythons, which is
509- # probably better than crashing
510- char = struct .pack ('<L' , 0x10000 ).decode ('utf-32' )
507+ codepoint = int (codepoint )
508+ try :
509+ char = unichr (codepoint )
510+ except ValueError :
511+ # This ridiculous trick gives a surrogate pair for
512+ # non-BMP codepoints on narrow Pythons, which is
513+ # probably better than crashing
514+ char = struct .pack ('<L' , codepoint ).decode ('utf-32' )
515+
511516 self .content .append (char )
512517 self .content .append (Skip (self .props .get ('unicode_skip' , 1 )))
513518
You can’t perform that action at this time.
0 commit comments