The Wayback Machine - https://web.archive.org/web/20250319115803/https://github.com/pythonnet/pythonnet/pull/2440
Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Try to be strict around non-copyability #2440

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Conversation

filmor
Copy link
Member

@filmor filmor commented Aug 22, 2024

No description provided.

@@ -103,5 +103,6 @@ public static PyFloat AsFloat(PyObject value)
public double ToDouble() => Runtime.PyFloat_AsDouble(obj);

public override TypeCode GetTypeCode() => TypeCode.Double;
public override int GetHashCode() => ((PyObject)this).GetHashCode();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks like it would just stackoverflow

@@ -232,5 +232,6 @@ public string ToString(string format, IFormatProvider formatProvider)
}

public override TypeCode GetTypeCode() => TypeCode.Int64;
public override int GetHashCode() => ((PyObject)this).GetHashCode();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same

Comment on lines +86 to +87
var free = (delegate* unmanaged[Cdecl]<ref StolenReference, void>)freePtr;
free(ref ob);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is wrong. It does not say anywhere but I'd expect tp_free to take a reference to PyObject (e.g. PyObject*), not a reference to reference to it (e.g. not a PyObject**).

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, that's probably one reason for the crashes :)

namespace NonCopyable
{
[DiagnosticAnalyzer(LanguageNames.CSharp)]
public class NonCopyableAnalyzer : DiagnosticAnalyzer
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why can't we put it into a separate repository?

Maybe use as a submodule if you don't want to reference it as a package.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's currently buggy. Once evrything works, we can move the changes to your repo again.

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.

2 participants