@@ -12,7 +12,7 @@ from godot.hazmat.gdapi cimport *
1212from godot.hazmat.extension_class cimport *
1313from godot.hazmat cimport gdptrs
1414from godot.builtins cimport *
15- from godot.classes cimport _load_class, _load_singleton, _cleanup_loaded_classes_and_singletons
15+ from godot.classes cimport _load_class, _load_singleton, _cleanup_loaded_classes_and_singletons, BaseGDObject
1616
1717include " _pythonscript_editor.pxi"
1818include " _pythonscript_extension_class_language.pxi"
@@ -147,12 +147,12 @@ cdef void _unregister_pythonscript_classes():
147147
148148cdef void _customize_config():
149149 import sys
150- ProjectSettings = _load_singleton(" ProjectSettings" )
151- OS = _load_singleton(" OS" )
150+ cdef BaseGDObject ProjectSettings = < BaseGDObject > _load_singleton(" ProjectSettings" )
151+ cdef BaseGDObject OS = < BaseGDObject > _load_singleton(" OS" )
152152
153153 # Provide argv arguments
154154
155- args = OS.get_cmdline_args()
155+ cdef PackedStringArray args = < PackedStringArray? > OS.get_cmdline_args()
156156 sys.argv = [" godot" ]
157157 # TODO: iteration on `PackedStringArray` not supported yet !
158158 for i in range (args.size()):
@@ -178,12 +178,13 @@ cdef void _customize_config():
178178cdef object _initialize_callback = None
179179cdef object _initialize_callback_hook(int p_level):
180180 global _initialize_callback
181+ cdef GDString config
181182
182183 if _initialize_callback is None :
183- config = _setup_config_entry( " python/initialize_callback " , " " )
184-
185- if not isinstance (config, GDString) :
186- raise ValueError (" Invalid value for config `python/initialize_callback`: expected a string in format `<module>:<function>`" )
184+ try :
185+ config = < GDString? > _setup_config_entry( " python/initialize_callback " , " " )
186+ except TypeError as exc :
187+ raise ValueError (" Invalid value for config `python/initialize_callback`: expected a string in format `<module>:<function>`" ) from exc
187188
188189 if config.is_empty():
189190 _initialize_callback = lambda _level : None # Dummy callback
@@ -213,12 +214,13 @@ cdef object _initialize_callback_hook(int p_level):
213214cdef object _deinitialize_callback = None
214215cdef object _deinitialize_callback_hook(int p_level):
215216 global _deinitialize_callback
217+ cdef GDString config
216218
217219 if _deinitialize_callback is None :
218- config = _setup_config_entry( " python/deinitialize_callback " , " " )
219-
220- if not isinstance (config, GDString) :
221- raise ValueError (" Invalid value for config `python/deinitialize_callback`: expected a string in format `<module>:<function>`" )
220+ try :
221+ config = < GDString? > _setup_config_entry( " python/deinitialize_callback " , " " )
222+ except TypeError as exc :
223+ raise ValueError (" Invalid value for config `python/deinitialize_callback`: expected a string in format `<module>:<function>`" ) from exc
222224
223225 if config.is_empty():
224226 _deinitialize_callback = lambda _level : None # Dummy callback
0 commit comments