Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 2 additions & 13 deletions 15 pythonnet/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ def load():
if _LOADED:
return

from .find_libpython import linked_libpython
from os.path import join, dirname

if _RUNTIME is None:
Expand All @@ -38,21 +37,11 @@ def load():
set_default_runtime()

dll_path = join(dirname(__file__), "runtime", "Python.Runtime.dll")
libpython = linked_libpython()

if libpython and _FFI is None and sys.platform != "win32":
# Load and leak libpython handle s.t. the .NET runtime doesn't dlcloses
# it
import posix

import cffi
_FFI = cffi.FFI()
_FFI.dlopen(libpython, posix.RTLD_NODELETE | posix.RTLD_LOCAL)


_LOADER_ASSEMBLY = _RUNTIME.get_assembly(dll_path)

func = _LOADER_ASSEMBLY["Python.Runtime.Loader.Initialize"]
if func(f"{libpython or ''}".encode("utf8")) != 0:
if func(''.encode("utf8")) != 0:
raise RuntimeError("Failed to initialize Python.Runtime.dll")

import atexit
Expand Down
Morty Proxy This is a proxified and sanitized view of the page, visit original site.