Domain reload test cases fixes by BadSingleton · Pull Request #1287 · pythonnet/pythonnet
Repository navigation
Domain reload test cases fixes - #1287
Merged
lostmsu merged 62 commits into pythonnet:master from Unity-Technologies:domain-reload-test-cases-fixes Jan 7, 2021
Merged
Domain reload test cases fixes #1287 lostmsu merged 62 commits into pythonnet:master from Unity-Technologies:domain-reload-test-cases-fixes
Conversation
BadSingleton commented Nov 19, 2020
Copy link Copy Markdown
Contributor
What does this implement/fix? Explain your changes.
This PR adds the fixes for the xfail tests in #1275 .
Serialization of System.Type, MemberInfo and MethodBase is now string based. At de-serialization, use reflection to attempt to recreate the object, which now fails safely instead of throwing a SerializationException during the de-serialization of the whole data stream. Appropriate Exceptions will now be raised when the Maybe*'s Value property is accessed.
Does this close any currently open issues?
This addresses #957 and #1250 and offers an answer to #1268 .
Any other comments?
TODO: add changelog entries once the fixes are approved. Also, add docs on best practices with domain reloads.
Checklist
Check all those that are applicable and complete.
- Make sure to include one or more tests for your change
- If an enhancement PR, please create docs and at best an example
- Add yourself to
AUTHORS - Updated the
CHANGELOG
Adds test cases for member changes during a domain reload
fc7da1d
The tests are marked as expected failures for now.
!fixup add the project to the solution files
72fafdd
Add more test cases
20861b2
Merge remote-tracking branch 'upstream/master' into domain-reload-tes...
2253ef3
...t-cases
Make the tests run as netcoreapp
635edac
Even though it tests nothing.
Remove stray colon
0ee931e
lostmsu
requested changes
Nov 19, 2020
View reviewed changes
Comment thread src/runtime/maybeserialize.cs
Outdated
| string[] types = new string[p.Length]; | ||
| for (int i = 0; i < p.Length; i++) | ||
| { | ||
| types[i] = p[i].ParameterType.AssemblyQualifiedName; |
Outdated
Comment on lines +350 to +352
| // Trying to remove a key that's not in the dictionary may | ||
| // raise an error. We don't care about it. | ||
| Runtime.PyErr_Clear(); |
Outdated
Comment on lines +80 to +81
| var _cache = new Dictionary<MaybeType, IntPtr>(); | ||
| storage.GetValue("cache", out _cache); |
Outdated
Comment on lines +89 to +87
| catch | ||
| { | ||
| Runtime.XDecref(entry.Value); | ||
| continue; | ||
| } |
Rework the serialization of reflected types
3dad96e
Serialization of System.Type, MemberInfo and MethodBase is now string based. At deserialization, use reflection to attempt to recreate the object, which may fail safely instead of throwing a SerializaitonException during the deserialization of the whoie data stream. Appropriate Exceptions will now be raised when the Maybe*'s Value property. ClasseBase objects are now de-initialized and re-initialized in Reload mode so that it's tp_dict picks up newly added members and removed members no longer linger. ModuleObject clears it's cache and remove cached members from it's tp_dict. Minor refactoring and modernization of MethodObject and MethodBinderBadSingleton force-pushed the domain-reload-test-cases-fixes branch from
946107f to
3dad96e
Compare
November 20, 2020 17:17 Félix Bourbonnais added 6 commits November 20, 2020 15:37
Call PyType_Modified after modifying the type
90a81f3
Changing a type's attribute causes problem with it's cache. Force the type to refresh itself when modifying it.
Some code review changes
10276f1
* Revert line endings change in Python.Runtime.csproj * Split maybe serialize into respective class files * Name changes for consistency
fixup! Some code review changes
4d0e2ce
Remove hungarian notation from Maybe* types
02fa245
Check the type of the exception before ignoring it
91c881c
Check for validity, don't throw
284e8e1
codecov-io commented Nov 23, 2020 · edited Loading
Copy link Copy Markdown
Codecov Report
@@ Coverage Diff @@ ## master #1287 +/- ## ======================================= Coverage 74.04% 74.04% ======================================= Files 1 1 Lines 289 289 ======================================= Hits 214 214 Misses 75 75
Flags with carried forward coverage won't be shown. Click here to find out more. Continue to review full report at Codecov .
|
Refactor the member binding logic of ClassManager
fe96781
So that we can use that same logic when deserializing Maybe* types
Include info about why deserialization failed in Maybe*
6ff9e0b
BadSingleton
commented
Nov 23, 2020
View reviewed changes
Comment thread src/runtime/StateSerialization/MaybeMemberInfo.cs
| // based on it's setter/getter (which is a method | ||
| // info) visibility and events based on their | ||
| // AddMethod visibility. | ||
| static bool ShouldBindMember(MemberInfo mi) |
improve deserialization resolution of ref, out and in parameters
4d2d05b
Also add a test
Clean up the project and solution files
5f061bc
Merge branch 'master' into domain-reload-test-cases
3adc559
Rework the serialization of reflected types
e8543cf
Serialization of System.Type, MemberInfo and MethodBase is now string based. At deserialization, use reflection to attempt to recreate the object, which may fail safely instead of throwing a SerializaitonException during the deserialization of the whoie data stream. Appropriate Exceptions will now be raised when the Maybe*'s Value property. ClasseBase objects are now de-initialized and re-initialized in Reload mode so that it's tp_dict picks up newly added members and removed members no longer linger. ModuleObject clears it's cache and remove cached members from it's tp_dict. Minor refactoring and modernization of MethodObject and MethodBinder
Call PyType_Modified after modifying the type
61b0d8c
Changing a type's attribute causes problem with it's cache. Force the type to refresh itself when modifying it.
Some code review changes
c8bacf3
* Revert line endings change in Python.Runtime.csproj * Split maybe serialize into respective class files * Name changes for consistency
fixup! Some code review changes
cde5c23
Remove hungarian notation from Maybe* types
a956773
Check the type of the exception before ignoring it
ee3b391
Check for validity, don't throw
9b4d5f9
Refactor the member binding logic of ClassManager
a2f3294
So that we can use that same logic when deserializing Maybe* typesFélix Bourbonnais and others added 9 commits December 18, 2020 13:45
Test runner docs fixes
59e81e2
Skip the domain reload tests on macos
1383b5a
Because it can't find the python library
fixup! Skip the domain reload tests on macos
fbc06ef
Update ISSUE_TEMPLATE.md
b3e86da
refactoring in CreateSubType
0b027c6
allocate space for GCHandle in instances of CLR Metatype (which are t...
b4533c4
...ypes themselves)
classderived: handle tp_dealloc called after tp_clear
0a3f044
Because tp_clear sets tpHandle to NULL, it can't be used. Fortunately, we can simply read object's type from pyHandle.
a few extra assertions
639236a
fixed crash in finalizer of CLR types defined in Python, that survive...
3069285
... engine shutdown (pythonnet#1260) pythonnet#1256 pythonnet#1256 During engine shutdown all links from Python to .NET instances are severed. If an instance of CLR class defined in Python survives the shutdown (for example, a reference is stored in static field) and later gets finalized, it will attempt to severe link again, which is an invalid operation. The fix is to check if the link has already been severed and skip that step during finalization.BadSingleton force-pushed the domain-reload-test-cases-fixes branch from
8639f09 to
3069285
Compare
December 18, 2020 18:45
Merge branch 'master' into domain-reload-test-cases-fixes
5c14aad
BadSingleton commented Dec 18, 2020
Copy link Copy Markdown
Contributor
Author
|
Build failures are due to NuGet hiccups
|
View reviewed changes
Comment thread src/domain_tests/TestRunner.cs
| }} | ||
| }} | ||
| "; | ||
| readonly static string PythonDllLocation = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Python.Runtime.dll"); |
Outdated
| File.Delete(tempFolderPython); | ||
| } | ||
|
|
||
| File.Copy(PythonDllLocation, tempFolderPython); |
Outdated
| CompilerParameters parameters = new CompilerParameters(); | ||
| parameters.GenerateExecutable = exe; | ||
| var assemblyName = name; | ||
| var assemblyFullPath = Path.Combine(Path.GetTempPath(), assemblyName); |
| if (mi == null) | ||
| { | ||
| return -1; | ||
| } | ||
|
|
Outdated
| } | ||
|
|
||
| private void _MethodObject(Type type, string name, MethodInfo[] info) | ||
| // `allow_threads = true`: True being the default value of MethodBinder.allow_threads |
BadSingleton commented Dec 18, 2020
Copy link Copy Markdown
Contributor
Author
|
I'll be on holidays for two weeks, I'll fix that when back in office |
Merge branch 'master' into domain-reload-test-cases-fixes
00c19d5
Fix break introduced by merge
833e836
Code review fixes
62ae107
BadSingleton
requested a review
from lostmsu
January 4, 2021 21:04
lostmsu
reviewed
Jan 4, 2021
View reviewed changes
Comment thread src/domain_tests/TestRunner.cs
Outdated
|
|
||
| static void SetupTestFolder(string testCaseName) | ||
| { | ||
| TestPath = Path.Combine(Path.GetTempPath(), $"Python.TestRunner.{testCaseName}"); |
Merge remote-tracking branch 'upstream/master' into domain-reload-tes...
eedbae5
...t-cases-fixesBadSingleton requested a review from lostmsu January 5, 2021 16:40 BadSingleton force-pushed the domain-reload-test-cases-fixes branch from
ac877c2 to
5779d5f
Compare
January 6, 2021 18:42
Add the PID of the test runner
73f39bc
To the test folder nameBadSingleton force-pushed the domain-reload-test-cases-fixes branch from
5779d5f to
73f39bc
Compare
January 6, 2021 20:04 lostmsu approved these changes Jan 7, 2021
View reviewed changes
lostmsu merged commit
d6c0081
into
pythonnet : master
Jan 7, 2021
BadSingleton
mentioned this pull request
Jan 8, 2021
Add more more tests for in, out and ref parameters
#1349
Merged
2 of 4 tasks
This was referenced Jan 19, 2021
What should reload reload?
#1268
Closed
Soft reload throws in deserialization in a common workflow
#1250
Closed
C-SELLERS
mentioned this pull request
Mar 4, 2021
ClassManager Cache Performance Impact
#1407
Open
Sign up for free
to join this conversation on GitHub .
Already have an account?
Sign in to comment