File tree Expand file tree Collapse file tree 1 file changed +13
-1
lines changed Expand file tree Collapse file tree 1 file changed +13
-1
lines changed Original file line number Diff line number Diff line change @@ -2062,7 +2062,7 @@ def warning_callback(msg: str) -> None:
20622062 if args .generate_allowlist :
20632063 generated_allowlist .add (error .object_desc )
20642064 continue
2065- print (error .get_description (concise = args .concise ))
2065+ safe_print (error .get_description (concise = args .concise ))
20662066 error_count += 1
20672067
20682068 # Print unused allowlist entries
@@ -2102,6 +2102,18 @@ def warning_callback(msg: str) -> None:
21022102 return exit_code
21032103
21042104
2105+ def safe_print (text : str ) -> None :
2106+ """Print a text replacing chars not representable in stdout encoding."""
2107+ # If `sys.stdout` encoding is not the same as out (usually UTF8) string,
2108+ # if may cause painful crashes. I don't want to reconfigure `sys.stdout`
2109+ # to do `errors = "replace"` as that sounds scary.
2110+ print (
2111+ text .encode (sys .stdout .encoding , errors = "replace" ).decode (
2112+ sys .stdout .encoding , errors = "replace"
2113+ )
2114+ )
2115+
2116+
21052117def parse_options (args : list [str ]) -> _Arguments :
21062118 parser = argparse .ArgumentParser (
21072119 description = "Compares stubs to objects introspected from the runtime."
You can’t perform that action at this time.
0 commit comments