@@ -503,20 +503,20 @@ def add_function_file(
503503 # Read current __init__.py content if it exists
504504 init_content = ""
505505 if os .path .exists (init_path ):
506- with open (init_path , "r" ) as f :
506+ with open (init_path , "r" , encoding = 'utf-8' ) as f :
507507 init_content = f .read ()
508508
509509 # Prepare new content to append to __init__.py
510510 new_init_content = init_content + f"\n \n from . import { func_namespace } \n \n { func_str } "
511511
512512 # Use temporary files for atomic writes
513513 # Write to __init__.py atomically
514- with tempfile .NamedTemporaryFile (mode = "w" , delete = False , dir = full_path , suffix = ".tmp" ) as temp_init :
514+ with tempfile .NamedTemporaryFile (mode = "w" , delete = False , dir = full_path , suffix = ".tmp" , encoding = 'utf-8' ) as temp_init :
515515 temp_init .write (new_init_content )
516516 temp_init_path = temp_init .name
517517
518518 # Write to function file atomically
519- with tempfile .NamedTemporaryFile (mode = "w" , delete = False , dir = full_path , suffix = ".tmp" ) as temp_func :
519+ with tempfile .NamedTemporaryFile (mode = "w" , delete = False , dir = full_path , suffix = ".tmp" , encoding = 'utf-8' ) as temp_func :
520520 temp_func .write (func_type_defs )
521521 temp_func_path = temp_func .name
522522
0 commit comments