From 9b7dbae876ad11334ba259fc83debf0a08d3174b Mon Sep 17 00:00:00 2001 From: Victor Nova Date: Fri, 1 Oct 2021 16:36:58 -0700 Subject: [PATCH 1/2] fixed nullability annotation on ConverterExtension.ToPython --- src/runtime/converter.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/runtime/converter.cs b/src/runtime/converter.cs index 4ef7ca46d..2b79caf39 100644 --- a/src/runtime/converter.cs +++ b/src/runtime/converter.cs @@ -937,7 +937,7 @@ private static bool ToArray(IntPtr value, Type obType, out object? result, bool public static class ConverterExtension { - public static PyObject ToPython(this object o) + public static PyObject ToPython(this object? o) { if (o is null) return Runtime.None; return new PyObject(Converter.ToPython(o, o.GetType())); From ca2e789268006a8247ef979dfc70c0efdb3d1166 Mon Sep 17 00:00:00 2001 From: Victor Nova Date: Fri, 1 Oct 2021 16:46:01 -0700 Subject: [PATCH 2/2] expose PyType.Get --- src/runtime/pytype.cs | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/src/runtime/pytype.cs b/src/runtime/pytype.cs index b144d09c3..9a0b34724 100644 --- a/src/runtime/pytype.cs +++ b/src/runtime/pytype.cs @@ -15,13 +15,18 @@ public PyType(TypeSpec spec, PyTuple? bases = null) : base(FromSpec(spec, bases) /// Wraps an existing type object. public PyType(PyObject o) : base(FromObject(o)) { } + internal PyType(PyType o) + : base(o is not null ? o.Reference : throw new ArgumentNullException(nameof(o))) + { + } + internal PyType(BorrowedReference reference) : base(reference) { if (!Runtime.PyType_Check(this.Handle)) throw new ArgumentException("object is not a type"); } - internal PyType(StolenReference reference) : base(EnsureIsType(in reference)) + internal PyType(in StolenReference reference) : base(EnsureIsType(in reference)) { } @@ -69,17 +74,15 @@ internal static bool IsType(BorrowedReference value) /// /// Gets , which represents the specified CLR type. - /// Must be called after the CLR type was mapped to its Python type. /// - internal static PyType Get(Type clrType) + public static PyType Get(Type clrType) { - if (clrType == null) + if (clrType is null) { throw new ArgumentNullException(nameof(clrType)); } - ClassBase pyClass = ClassManager.GetClass(clrType); - return new PyType(pyClass.ObjectReference); + return new PyType(TypeManager.GetType(clrType)); } internal BorrowedReference BaseReference pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy