@@ -58,7 +58,7 @@ def __init__(self, path: str) -> None:
5858 self .path = path = os .path .normpath (path )
5959 directory = os .path .dirname (path )
6060 depends = set ()
61- with open (self .path , "r" ) as f :
61+ with open (self .path , "r" , encoding = "utf-8" ) as f :
6262 header = f .read ()
6363 header = RE_COMMENT .sub ("" , header )
6464 header = RE_CPLUSPLUS .sub ("" , header )
@@ -251,7 +251,7 @@ def fix_header(filepath: str) -> None:
251251
252252 This whitespace is causing issues with directives on some platforms.
253253 """
254- with open (filepath , "r+" ) as f :
254+ with open (filepath , "r+" , encoding = "utf-8" ) as f :
255255 current = f .read ()
256256 fixed = "\n " .join (line .strip () for line in current .split ("\n " ))
257257 if current == fixed :
@@ -406,11 +406,11 @@ def update_module_all(filename: str, new_all: str) -> None:
406406 r"(.*# --- From constants.py ---).*(# --- End constants.py ---.*)" ,
407407 re .DOTALL ,
408408 )
409- with open (filename , "r" ) as f :
409+ with open (filename , "r" , encoding = "utf-8" ) as f :
410410 match = RE_CONSTANTS_ALL .match (f .read ())
411411 assert match , "Can't determine __all__ subsection in %s!" % (filename ,)
412412 header , footer = match .groups ()
413- with open (filename , "w" ) as f :
413+ with open (filename , "w" , encoding = "utf-8" ) as f :
414414 f .write ("%s\n %s,\n %s" % (header , new_all , footer ))
415415
416416
@@ -431,7 +431,7 @@ def write_library_constants() -> None:
431431 import tcod .color
432432 from tcod ._libtcod import ffi , lib
433433
434- with open ("tcod/constants.py" , "w" ) as f :
434+ with open ("tcod/constants.py" , "w" , encoding = "utf-8" ) as f :
435435 all_names = []
436436 f .write (CONSTANT_MODULE_HEADER )
437437 for name in dir (lib ):
@@ -473,7 +473,7 @@ def write_library_constants() -> None:
473473 update_module_all ("tcod/__init__.py" , all_names_merged )
474474 update_module_all ("tcod/libtcodpy.py" , all_names_merged )
475475
476- with open ("tcod/event_constants.py" , "w" ) as f :
476+ with open ("tcod/event_constants.py" , "w" , encoding = "utf-8" ) as f :
477477 all_names = []
478478 f .write (EVENT_CONSTANT_MODULE_HEADER )
479479 f .write ("# --- SDL scancodes ---\n " )
@@ -490,7 +490,7 @@ def write_library_constants() -> None:
490490 all_names_merged = ",\n " .join ('"%s"' % name for name in all_names )
491491 f .write ("\n __all__ = [\n %s,\n ]\n " % (all_names_merged ,))
492492
493- with open ("tcod/event.py" , "r" ) as f :
493+ with open ("tcod/event.py" , "r" , encoding = "utf-8" ) as f :
494494 event_py = f .read ()
495495
496496 event_py = re .sub (
@@ -506,7 +506,7 @@ def write_library_constants() -> None:
506506 flags = re .DOTALL ,
507507 )
508508
509- with open ("tcod/event.py" , "w" ) as f :
509+ with open ("tcod/event.py" , "w" , encoding = "utf-8" ) as f :
510510 f .write (event_py )
511511
512512
0 commit comments