Skip to content

Multiple inheritance finalize bug fix#3

Draft
rmadsen-ks wants to merge 95 commits into
masterfrom
multipleInheritanceFinalizeBugFix
Draft

Multiple inheritance finalize bug fix#3
rmadsen-ks wants to merge 95 commits into
masterfrom
multipleInheritanceFinalizeBugFix

Conversation

@rmadsen-ks

Copy link
Copy Markdown
Owner

What does this implement/fix? Explain your changes.

...

Does this close any currently open issues?

...

Any other comments?

...

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
  • Ensure you have signed the .NET Foundation CLA
  • Add yourself to AUTHORS
  • Updated the CHANGELOG

filmor and others added 30 commits October 15, 2022 21:41
…s when target type is System.Object

useful to be able to change what numpy.float64 is converted to

related to pythonnet#1957

this is an alternative to pythonnet#1958
Allow decoders to decode Python types derived from primitives
BigInteger constructor uses the sign bit in the first byte. Since we explicitly handle the sign, the fix is to prepend a zero byte to the number, which does not change it, but ensures sign bit is zero.

fixes pythonnet#1990
Fix positive `PyInt` converted to negative `BigInteger`
since RuntimeMethodHandle does not encode generic arguments, I had to supply RuntimeTypeHandle of the declaring type to be able to get fully specified method
…erface

Fix implementing a generic interface with a Python class
…nnet#2026)

- If a method is virtual AND generic, it cannot be overridden by the python class. Hence the method call is deferred to the base class.
- Added a unit test which verifies this behavior is now working.

NOTE: The test causes crash when run from `PythonTestRunner`. See pythonnet#2035
…r testing

upgrade caused InvalidVersion: Invalid version: '0.23ubuntu1' on Ubuntu due to setuptools dropping support for that version format
BadSingleton and others added 30 commits May 10, 2024 10:35
* Expose an API for users to specify their own formatter

Adds post-serialization and pre-deserialization hooks for additional
customization.

* Add API for capsuling data when serializing

* Add NoopFormatter and fall back to it if BinaryFormatter is not available

---------

Co-authored-by: Benedikt Reinartz <filmor@gmail.com>
When nulling the GC handles on shutdown the reference count of all objects pointed to by the IntPtr in the `CLRObject.reflectedObjects` are zero.
This caused an exception in some scenarios because `Runtime.PyObject_TYPE(reflectedClrObject)` is called while the reference counter is at zero.

After `TypeManager.RemoveTypes();` is called in the `Runtime.Shutdown()` method, reference count decrements to zero do not invoke `ClassBase.tp_clear` for managed objects anymore which normally is responsible for removing references from `CLRObject.reflectedObjects`. Collecting objects referenced in `CLRObject.reflectedObjects` only after leads to an unstable state in which the reference count for these object addresses is zero while still maintaining them to be used for further pseudo-cleanup. In that time, the memory could have been reclaimed already which leads to the exception.
Otherwise, collecting all at this earlier point results in corrupt memory for derived types.
* Use non-BOM encodings

* Copy potential BOM to the output of PyString_FromString

The documentation of the used `PyUnicode_DecodeUTF16` states that not
passing `*byteorder` or passing a 0 results in the first two bytes, if
they are the BOM (U+FEFF, zero-width no-break space), to be interpreted
and skipped, which is incorrect when we convert a known "non BOM"
string, which all strings from C# are.

* Default to UTF8 for StrPtr
…or some other internal errors (pythonnet#2409)

* not all events have Add method

fixes pythonnet#2405

* give users some idea of why we might be unable to reflect .NET types to Python for them

* mentioned event Add method crash fix in changelog
Otherwise if you have a Python object that needs to temporarily create a .NET object in its destructor (for instance write log summary to a file), its destructor will fail if it happens to be freed on the second iteration of loop breaking.
…on-gc

Fix access violation exception on shutdown
Was only used in the console and might not be available in some
embedding scenarios.
Verified them locally, but there is an issue with the Github workflow
image that can hopefully be resolved later by using a full venv
instead of relying on the system environment.
Fixed issue that multiple levels of inheritance causes pyFinalize to get called multiple times on the same object.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.