Skip to content

Commit 35a5718

Browse files
committed
Resolve circular dependency on ClrError
1 parent ce982e4 commit 35a5718

File tree

5 files changed

+23
-24
lines changed

5 files changed

+23
-24
lines changed

clr_loader/ffi/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ def load_netfx():
5050
arch = "amd64"
5151
else:
5252
arch = "x86"
53-
53+
5454
path = os.path.join(dirname, arch, "ClrLoader.dll")
5555

5656
return ffi.dlopen(path)

clr_loader/util/__init__.py

Lines changed: 3 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,6 @@
1-
class ClrError(Exception):
2-
def __init__(self, hresult, name=None, message=None, comment=None):
3-
self.hresult = hresult
4-
self.name = name
5-
self.message = message
6-
self.comment = comment
7-
8-
def __str__(self):
9-
if self.message:
10-
return f"{hex(self.hresult)}: {self.name} => {self.message}"
11-
elif self.name:
12-
return f"{hex(self.hresult)}: {self.name}"
13-
else:
14-
return f"{hex(self.hresult)}"
15-
16-
def __repr__(self):
17-
return f"<ClrError {str(self)}>"
1+
from .clr_error import ClrError
2+
from .coreclr_errors import get_coreclr_error
3+
from .hostfxr_errors import get_hostfxr_error
184

195

206
def check_result(err_code):
@@ -29,7 +15,3 @@ def check_result(err_code):
2915
error = ClrError(hresult)
3016

3117
raise error
32-
33-
34-
from .coreclr_errors import get_coreclr_error
35-
from .hostfxr_errors import get_hostfxr_error

clr_loader/util/clr_error.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
class ClrError(Exception):
2+
def __init__(self, hresult, name=None, message=None, comment=None):
3+
self.hresult = hresult
4+
self.name = name
5+
self.message = message
6+
self.comment = comment
7+
8+
def __str__(self):
9+
if self.message:
10+
return f"{hex(self.hresult)}: {self.name} => {self.message}"
11+
elif self.name:
12+
return f"{hex(self.hresult)}: {self.name}"
13+
else:
14+
return f"{hex(self.hresult)}"
15+
16+
def __repr__(self):
17+
return f"<ClrError {str(self)}>"

clr_loader/util/coreclr_errors.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from . import ClrError
1+
from .clr_error import ClrError
22

33

44
def get_coreclr_error(hresult):

clr_loader/util/hostfxr_errors.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from . import ClrError
1+
from .clr_error import ClrError
22

33
__all__ = ["get_hostfxr_error"]
44

0 commit comments

Comments
 (0)