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 1 commit
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
Prev Previous commit
Next Next commit
Code review adjustments
- Use `BorrowedReference` where applicable
- Readd `OperatingSystemName` and `MachineName` for now
  • Loading branch information
filmor committed May 16, 2020
commit 8e54d2686937017fc442e8e204bd84ff1fea91c1
11 changes: 9 additions & 2 deletions src/runtime/runtime.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
using System.Reflection.Emit;
using System;
using System.Diagnostics.Contracts;
using System.Runtime.InteropServices;
Expand Down Expand Up @@ -118,6 +119,12 @@ public class Runtime
{ "Linux", OperatingSystemType.Linux },
};

[Obsolete]
public static string OperatingSystemName => OperatingSystem.ToString();

[Obsolete]
public static string MachineName => Machine.ToString();

/// <summary>
/// Gets the operating system as reported by python's platform.system().
/// </summary>
Expand Down Expand Up @@ -1990,10 +1997,10 @@ internal static IntPtr PyMem_Realloc(IntPtr ptr, long size)
//====================================================================

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

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

//====================================================================
// Miscellaneous
Expand Down
12 changes: 8 additions & 4 deletions src/runtime/typemanager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -281,8 +281,8 @@ internal static IntPtr CreateSubType(IntPtr py_name, IntPtr py_base_type, IntPtr
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)
var cell = new BorrowedReference(Runtime.PyDict_GetItemString(cls_dict, "__classcell__"));
if (!cell.IsNull)
{
Runtime.PyCell_Set(cell, py_type);
Runtime.PyDict_DelItemString(cls_dict, "__classcell__");
Expand Down Expand Up @@ -625,7 +625,9 @@ int MAP_ANONYMOUS
case OperatingSystemType.Linux:
return 0x20;
default:
throw new NotImplementedException($"mmap is not supported on this operating system");
throw new NotImplementedException(
$"mmap is not supported on {Runtime.OperatingSystem}"
);
}
}
}
Expand Down Expand Up @@ -659,7 +661,9 @@ internal static IMemoryMapper CreateMemoryMapper()
case OperatingSystemType.Windows:
return new WindowsMemoryMapper();
default:
throw new NotImplementedException($"No support for this operating system");
throw new NotImplementedException(
$"No support for {Runtime.OperatingSystem}"
);
}
}

Expand Down