8000 Python 3.8 by filmor · Pull Request #1138 · pythonnet/pythonnet · GitHub
[go: up one dir, main page]

Skip to content

Python 3.8 #1138

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

Merged
merged 8 commits into from
May 16, 2020
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ python:
- 3.5
- 3.6
- 3.7
- 3.8

env:
matrix:
Expand Down
3 changes: 3 additions & 0 deletions appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,13 @@ environment:
BUILD_OPTS: --xplat
- PYTHON_VERSION: 3.7
BUILD_OPTS: --xplat
- PYTHON_VERSION: 3.8
BUILD_OPTS: --xplat
- PYTHON_VERSION: 2.7
- PYTHON_VERSION: 3.5
- PYTHON_VERSION: 3.6
- PYTHON_VERSION: 3.7
- PYTHON_VERSION: 3.8

matrix:
allow_failures:
Expand Down
9 changes: 9 additions & 0 deletions src/runtime/runtime.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1966,6 +1966,15 @@ internal static IntPtr PyMem_Realloc(IntPtr ptr, long size)
[DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)]
internal static extern void PyErr_Print();

//====================================================================
// Cell API
//====================================================================

[DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)]
internal static extern NewReference PyCell_Get(IntPtr cell);

[DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)]
internal static extern int PyCell_Set(IntPtr cell, IntPtr value);

//====================================================================
// Miscellaneous
Expand Down
8 changes: 8 additions & 0 deletions src/runtime/typemanager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -280,6 +280,14 @@ internal static IntPtr CreateSubType(IntPtr py_name, IntPtr py_base_type, IntPtr
IntPtr cls_dict = Marshal.ReadIntPtr(py_type, TypeOffset.tp_dict);
Runtime.PyDict_Update(cls_dict, py_dict);

// Update the __classcell__ if it exists
IntPtr cell = Runtime.PyDict_GetItemString(cls_dict, "__classcell__");
if (cell != IntPtr.Zero)
{
Runtime.PyCell_Set(cell, py_type);
Runtime.PyDict_DelItemString(cls_dict, "__classcell__");
}

Copy link
Member

Choose a reason for hiding this comment

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

@filmor I can't find a test, that would cover this scenario, and I suspect there might be a problem with reference counting: if __classcell__ is present, its content is a PyType*, which might need to be DecRefed before being replaced with py_type, and py_type might need to be IncRefed before being put into the cell.

Also, I don't understand why __classcell__ is removed later. If it is removed, what is the purpose of updating its value?

Copy link
Member

Choose a reason for hiding this comment

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

return py_type;
}
catch (Exception e)
Expand Down
0