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

Improve loader robustness by sefgit · Pull Request #2303 · pythonnet/pythonnet · GitHub

Repository navigation

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension .cs  (1) .md  (2) All 2 file types selected
Viewed files
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Unified
Split
Hide whitespace
Diff view
Unified
Split
Hide whitespace
1 change: 1 addition & 0 deletions AUTHORS.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -86,3 +86,4 @@
- ([@gpetrou](https://github.com/gpetrou))
- Ehsan Iran-Nejad ([@eirannejad](https://github.com/eirannejad))
- ([@legomanww](https://github.com/legomanww))
- Effendi Soewono ([@sefgit](https://github.com/sefgit))
1 change: 1 addition & 0 deletions CHANGELOG.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ This document follows the conventions laid out in [Keep a CHANGELOG][].

### Fixed

- Improve loader (AddReference) robustness. Ignore and print loader error and try to continue to load if possible.

## [3.0.3](https://github.com/pythonnet/pythonnet/releases/tag/v3.0.3) - 2023-10-11

Expand Down
27 changes: 27 additions & 0 deletions src/runtime/AssemblyManager.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -414,6 +414,10 @@ internal static Type[] GetTypes(Assembly a)
catch (ReflectionTypeLoadException exc)
{
// Return all types that were successfully loaded
foreach (var item in exc.LoaderExceptions)
{
Debug.WriteLine("[pythonnet] {0}", item.Message);
}
return exc.Types.Where(x => x != null && IsExported(x)).ToArray();
}
}
Expand All @@ -425,8 +429,31 @@ internal static Type[] GetTypes(Assembly a)
}
catch (FileNotFoundException)
{
Debug.WriteLine("[pythonnet] {0} File not found", a.GetName());
return new Type[0];
}
catch (System.TypeLoadException e)
{
try
{
return a.GetTypes().Where(IsExported).ToArray();
}
catch (ReflectionTypeLoadException exc)
{
foreach (var item in exc.LoaderExceptions)
{
Debug.WriteLine("[pythonnet] {0}", item.Message);
}
// Return all types that were successfully loaded
return exc.Types.Where(x => x != null && IsExported(x)).ToArray();
}
}
catch (Exception e) // System.TypeLoadException
{
Debug.WriteLine("[pythonnet] {0} {1}", a.GetName(), e);
return new Type[0];
}

}
}

Expand Down

Back | FazBrowse Home | New Git URL