| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -16,7 +16,7 @@ def set_runtime(runtime): | |||
| 16 | 16 | ||
| 17 | 17 | ||
| 18 | 18 | def set_default_runtime() -> None: | |
| 19 | - if sys.platform == 'win32': | ||
| 19 | + if sys.platform == "win32": | ||
| 20 | 20 | set_runtime(clr_loader.get_netfx()) | |
| 21 | 21 | else: | |
| 22 | 22 | set_runtime(clr_loader.get_mono()) | |
@@ -36,22 +36,23 @@ def load(): | |||
| 36 | 36 | set_default_runtime() | |
| 37 | 37 | ||
| 38 | 38 | dll_path = join(dirname(__file__), "runtime", "Python.Runtime.dll") | |
| 39 | - | ||
| 39 | + | ||
| 40 | 40 | _LOADER_ASSEMBLY = _RUNTIME.get_assembly(dll_path) | |
| 41 | 41 | ||
| 42 | 42 | func = _LOADER_ASSEMBLY["Python.Runtime.Loader.Initialize"] | |
| 43 | - if func(''.encode("utf8")) != 0: | ||
| 43 | + if func(b"") != 0: | ||
| 44 | 44 | raise RuntimeError("Failed to initialize Python.Runtime.dll") | |
| 45 | 45 | ||
| 46 | 46 | import atexit | |
| 47 | + | ||
| 47 | 48 | atexit.register(unload) | |
| 48 | 49 | ||
| 49 | 50 | ||
| 50 | 51 | def unload(): | |
| 51 | 52 | global _RUNTIME | |
| 52 | 53 | if _LOADER_ASSEMBLY is not None: | |
| 53 | 54 | func = _LOADER_ASSEMBLY["Python.Runtime.Loader.Shutdown"] | |
| 54 | - if func(b"") != 0: | ||
| 55 | + if func(b"full_shutdown") != 0: | ||
| 55 | 56 | raise RuntimeError("Failed to call Python.NET shutdown") | |
| 56 | 57 | ||
| 57 | 58 | if _RUNTIME is not None: | |
| Back | FazBrowse Home | New Git URL |
0 commit comments