FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Fix clr_loader version parsing for .NET 10.0.0 · pythonnet/pythonnet@c71de92 · GitHub

Repository navigation

Commit c71de92

Browse files
Fix clr_loader version parsing for .NET 10.0.0
Monkeypatch `clr_loader.util.runtime_spec.DotnetCoreRuntimeSpec` to correctly parse .NET versions with double-digit major versions (e.g., 10.0.0). The original implementation used a fixed slice `[:3]`, which truncated `10.0.0` to `10.`. The fix uses `split('.')` to robustly extract major and minor versions.
1 parent 5276ac6 commit c71de92

1 file changed

Lines changed: 16 additions & 0 deletions

File tree

‎pythonnet/__init__.py‎

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,22 @@
44
from pathlib import Path
55
from typing import Dict, Optional, Union, Any
66
import clr_loader
7+
from clr_loader.util.runtime_spec import DotnetCoreRuntimeSpec
8+
9+
# Monkeypatch clr_loader to fix .NET 10 version parsing
10+
# TODO: Remove this once clr_loader is updated
11+
def _patched_tfm(self) -> str:
12+
parts = self.version.split(".")
13+
return f"net{parts[0]}.{parts[1]}"
14+
15+
16+
def _patched_floor_version(self) -> str:
17+
parts = self.version.split(".")
18+
return f"{parts[0]}.{parts[1]}.0"
19+
20+
21+
DotnetCoreRuntimeSpec.tfm = property(_patched_tfm)
22+
DotnetCoreRuntimeSpec.floor_version = property(_patched_floor_version)
723

824
__all__ = ["set_runtime", "set_runtime_from_env", "load", "unload", "get_runtime_info"]
925

0 commit comments

Comments
 (0)

Back | FazBrowse Home | New Git URL