pFad - Phone/Frame/Anonymizer/Declutterfier! Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

URL: http://github.com/pythonnet/pythonnet/commit/2edd8000e49caa24b6a7feb3f192eac0fd09161b

7e.css" /> Fix broken prefix and debug leftover · pythonnet/pythonnet@2edd800 · GitHub
Skip to content

Commit 2edd800

Browse files
committed
Fix broken prefix and debug leftover
Additionally, fixes a type hint and makes sure that the new default behaviour is to use the environment variable if given.
1 parent e84731f commit 2edd800

1 file changed

Lines changed: 9 additions & 9 deletions

File tree

pythonnet/__init__.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
from typing import Dict, Optional, Union
44
import clr_loader
55

6-
__all__ = ["set_runtime", "set_default_runtime", "load"]
6+
__all__ = ["set_runtime", "set_runtime_from_env", "load"]
77

88
_RUNTIME: Optional[clr_loader.Runtime] = None
99
_LOADER_ASSEMBLY: Optional[clr_loader.wrappers.Assembly] = None
@@ -30,7 +30,7 @@ def set_runtime(runtime: Union[clr_loader.Runtime, str], **params: str) -> None:
3030
def _get_params_from_env(prefix: str) -> Dict[str, str]:
3131
from os import environ
3232

33-
full_prefix = f"PYTHONNET_{prefix.upper()}"
33+
full_prefix = f"PYTHONNET_{prefix.upper()}_"
3434
len_ = len(full_prefix)
3535

3636
env_vars = {
@@ -63,8 +63,8 @@ def _create_runtime_from_spec(
6363
raise RuntimeError(f"Invalid runtime name: '{spec}'")
6464

6565

66-
def set_default_runtime() -> None:
67-
"""Set up the default runtime
66+
def set_runtime_from_env() -> None:
67+
"""Set up the runtime using the environment
6868
6969
This will use the environment variable PYTHONNET_RUNTIME to decide the
7070
runtime to use, which may be one of netfx, coreclr or mono. The parameters
@@ -80,16 +80,13 @@ def set_default_runtime() -> None:
8080
"""
8181
from os import environ
8282

83-
print("Set default RUNTIME")
84-
raise RuntimeError("Shouldn't be called here")
85-
8683
spec = environ.get("PYTHONNET_RUNTIME", "default")
8784
runtime = _create_runtime_from_spec(spec)
8885
set_runtime(runtime)
8986

9087

9188
def load(
92-
runtime: Union[clr_loader.Runtime, str] = "default", **params: Dict[str, str]
89+
runtime: Union[clr_loader.Runtime, str, None] = None, **params: str
9390
) -> None:
9491
"""Load Python.NET in the specified runtime
9592
@@ -102,7 +99,10 @@ def load(
10299
return
103100

104101
if _RUNTIME is None:
105-
set_runtime(runtime, **params)
102+
if runtime is None:
103+
set_runtime_from_env()
104+
else:
105+
set_runtime(runtime, **params)
106106

107107
if _RUNTIME is None:
108108
raise RuntimeError("No valid runtime selected")

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad © 2024 Your Company Name. All rights reserved.





Check this box to remove all script contents from the fetched content.



Check this box to remove all images from the fetched content.


Check this box to remove all CSS styles from the fetched content.


Check this box to keep images inefficiently compressed and original size.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy