◐ Shell
clean mode source ↗

Remove Utf8Marshaler, set PyScope base class to PyObject, added PyModule by lostmsu · Pull Request #1391 · pythonnet/pythonnet

Expand Up @@ -95,24 +95,21 @@ internal static Exception ToException(IntPtr ob) /// </remarks> public static class Exceptions { internal static IntPtr warnings_module; internal static IntPtr exceptions_module; internal static PyModule warnings_module; internal static PyModule exceptions_module;
/// <summary> /// Initialization performed on startup of the Python runtime. /// </summary> internal static void Initialize() { string exceptionsModuleName = "builtins"; exceptions_module = Runtime.PyImport_ImportModule(exceptionsModuleName);
Exceptions.ErrorCheck(exceptions_module); warnings_module = Runtime.PyImport_ImportModule("warnings"); Exceptions.ErrorCheck(warnings_module); exceptions_module = PyModule.Import(exceptionsModuleName); warnings_module = PyModule.Import("warnings"); Type type = typeof(Exceptions); foreach (FieldInfo fi in type.GetFields(BindingFlags.Public | BindingFlags.Static)) { IntPtr op = Runtime.PyObject_GetAttrString(exceptions_module, fi.Name); IntPtr op = Runtime.PyObject_GetAttrString(exceptions_module.obj, fi.Name); if (op != IntPtr.Zero) { fi.SetValue(type, op); Expand Down Expand Up @@ -147,8 +144,8 @@ internal static void Shutdown() Runtime.XDecref(op); fi.SetValue(null, IntPtr.Zero); } Runtime.Py_CLEAR(ref exceptions_module); Runtime.Py_CLEAR(ref warnings_module); exceptions_module.Dispose(); warnings_module.Dispose(); }
/// <summary> Expand Down Expand Up @@ -348,9 +345,7 @@ public static void warn(string message, IntPtr exception, int stacklevel) Exceptions.RaiseTypeError("Invalid exception"); }
Runtime.XIncref(warnings_module); IntPtr warn = Runtime.PyObject_GetAttrString(warnings_module, "warn"); Runtime.XDecref(warnings_module); IntPtr warn = Runtime.PyObject_GetAttrString(warnings_module.obj, "warn"); Exceptions.ErrorCheck(warn);
IntPtr args = Runtime.PyTuple_New(3); Expand Down