Skip to content

Commit

Permalink
add option to disable warning
Browse files Browse the repository at this point in the history
  • Loading branch information
Mohamed Koubaa committed May 14, 2024
1 parent f2058b4 commit cb2f10e
Showing 1 changed file with 19 additions and 14 deletions.
33 changes: 19 additions & 14 deletions clr_loader/mono.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,11 +121,28 @@ def __call__(self, ptr, size):
return unboxed[0]


def _warn_mono_version(ver_str: str):
ver = re.match(r"^(?P<major>\d+)\.(?P<minor>\d+)\.[\d.]+", ver_str)
if ver is not None:
major = int(ver.group("major"))
minor = int(ver.group("minor"))

if major < 6 or (major == 6 and minor < 12):
import warnings

warnings.warn(
"Hosting Mono versions before v6.12 is known to be problematic. "
"If the process crashes shortly after you see this message, try "
"updating Mono to at least v6.12."
)


def initialize(
libmono: Optional[Path],
debug: bool = False,
jit_options: Optional[Sequence[str]] = None,
config_file: Optional[str] = None,
disable_warning: Optional[bool] = False,
global_config_file: Optional[str] = None,
assembly_dir: Optional[str] = None,
config_dir: Optional[str] = None,
Expand Down Expand Up @@ -168,20 +185,8 @@ def initialize(
build = _MONO.mono_get_runtime_build_info()
_check_result(build, "Failed to get Mono version")
ver_str = ffi.string(build).decode("utf8") # e.g. '6.12.0.122 (tarball)'

ver = re.match(r"^(?P<major>\d+)\.(?P<minor>\d+)\.[\d.]+", ver_str)
if ver is not None:
major = int(ver.group("major"))
minor = int(ver.group("minor"))

if major < 6 or (major == 6 and minor < 12):
import warnings

warnings.warn(
"Hosting Mono versions before v6.12 is known to be problematic. "
"If the process crashes shortly after you see this message, try "
"updating Mono to at least v6.12."
)
if not disable_warning:
_warn_mono_version(ver_str)

atexit.register(_release)
return ver_str
Expand Down

0 comments on commit cb2f10e

Please sign in to comment.