| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 32051cb commit b112885
4 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -22,6 +22,7 @@ This document follows the conventions laid out in [Keep a CHANGELOG][]. | |||
| 22 | 22 | ### Fixed | |
| 23 | 23 | ||
| 24 | 24 | - Fixed RecursionError for reverse operators on C# operable types from python. See #2240 | |
| 25 | + - Fixed probing for assemblies in `sys.path` failing when a path in `sys.path` has invalid characters. See #2376 | ||
| 25 | 26 | ||
| 26 | 27 | ## [3.0.3](https://github.com/pythonnet/pythonnet/releases/tag/v3.0.3) - 2023-10-11 | |
| 27 | 28 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -200,6 +200,13 @@ static IEnumerable<string> FindAssemblyCandidates(string name) | |||
| 200 | 200 | } | |
| 201 | 201 | else | |
| 202 | 202 | { | |
| 203 | + int invalidCharIndex = head.IndexOfAny(Path.GetInvalidPathChars()); | ||
| 204 | + if (invalidCharIndex >= 0) | ||
| 205 | + { | ||
| 206 | + using var importWarning = Runtime.PyObject_GetAttrString(Exceptions.exceptions_module, "ImportWarning"); | ||
| 207 | + Exceptions.warn($"Path entry '{head}' has invalid char at position {invalidCharIndex}", importWarning.BorrowOrThrow()); | ||
| 208 | + continue; | ||
| 209 | + } | ||
| 203 | 210 | path = Path.Combine(head, name); | |
| 204 | 211 | } | |
| 205 | 212 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -270,7 +270,7 @@ public static void warn(string message, BorrowedReference exception, int stackle | |||
| 270 | 270 | } | |
| 271 | 271 | ||
| 272 | 272 | using var warn = Runtime.PyObject_GetAttrString(warnings_module.obj, "warn"); | |
| 273 | - Exceptions.ErrorCheck(warn.Borrow()); | ||
| 273 | + warn.BorrowOrThrow(); | ||
| 274 | 274 | ||
| 275 | 275 | using var argsTemp = Runtime.PyTuple_New(3); | |
| 276 | 276 | BorrowedReference args = argsTemp.BorrowOrThrow(); | |
@@ -283,7 +283,7 @@ public static void warn(string message, BorrowedReference exception, int stackle | |||
| 283 | 283 | Runtime.PyTuple_SetItem(args, 2, level.StealOrThrow()); | |
| 284 | 284 | ||
| 285 | 285 | using var result = Runtime.PyObject_CallObject(warn.Borrow(), args); | |
| 286 | - Exceptions.ErrorCheck(result.Borrow()); | ||
| 286 | + result.BorrowOrThrow(); | ||
| 287 | 287 | } | |
| 288 | 288 | ||
| 289 | 289 | public static void warn(string message, BorrowedReference exception) | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -344,6 +344,20 @@ def test_clr_add_reference(): | |||
| 344 | 344 | with pytest.raises(FileNotFoundException): | |
| 345 | 345 | AddReference("somethingtotallysilly") | |
| 346 | 346 | ||
| 347 | + | ||
| 348 | + def test_clr_add_reference_bad_path(): | ||
| 349 | + import sys | ||
| 350 | + from clr import AddReference | ||
| 351 | + from System.IO import FileNotFoundException | ||
| 352 | + bad_path = "hello\0world" | ||
| 353 | + sys.path.append(bad_path) | ||
| 354 | + try: | ||
| 355 | + with pytest.raises(FileNotFoundException): | ||
| 356 | + AddReference("test_clr_add_reference_bad_path") | ||
| 357 | + finally: | ||
| 358 | + sys.path.remove(bad_path) | ||
| 359 | + | ||
| 360 | + | ||
| 347 | 361 | def test_clr_get_clr_type(): | |
| 348 | 362 | """Test clr.GetClrType().""" | |
| 349 | 363 | from clr import GetClrType | |
| Back | FazBrowse Home | New Git URL |
0 commit comments