Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitd821b35

Browse files
committed
property descriptor made visible on the reflected class for instance properties
1 parentd3c6942 commitd821b35

File tree

2 files changed

+38
-4
lines changed

2 files changed

+38
-4
lines changed

‎src/embed_tests/Inspect.cs

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
usingSystem;
2+
usingSystem.Collections.Generic;
3+
4+
usingNUnit.Framework;
5+
6+
usingPython.Runtime;
7+
8+
namespacePython.EmbeddingTest
9+
{
10+
publicclassInspect
11+
{
12+
[OneTimeSetUp]
13+
publicvoidSetUp()
14+
{
15+
PythonEngine.Initialize();
16+
}
17+
18+
[OneTimeTearDown]
19+
publicvoidDispose()
20+
{
21+
PythonEngine.Shutdown();
22+
}
23+
24+
[Test]
25+
publicvoidInstancePropertiesVisibleOnClass()
26+
{
27+
varuri=newUri("http://example.org").ToPython();
28+
varuriClass=uri.GetPythonType();
29+
varproperty=uriClass.GetAttr(nameof(Uri.AbsoluteUri));
30+
varpyProp=(PropertyObject)ManagedType.GetManagedObject(property.Reference);
31+
Assert.AreEqual(nameof(Uri.AbsoluteUri),pyProp.info.Value.Name);
32+
}
33+
}
34+
}

‎src/runtime/propertyobject.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ namespace Python.Runtime
1111
[Serializable]
1212
internalclassPropertyObject:ExtensionType
1313
{
14-
privateMaybeMemberInfo<PropertyInfo>info;
14+
internalMaybeMemberInfo<PropertyInfo>info;
1515
privateMaybeMethodInfogetter;
1616
privateMaybeMethodInfosetter;
1717

@@ -50,9 +50,9 @@ public static IntPtr tp_descr_get(IntPtr ds, IntPtr ob, IntPtr tp)
5050
{
5151
if(!getter.IsStatic)
5252
{
53-
Exceptions.SetError(Exceptions.TypeError,
54-
"instanceproperty must be accessed through a class instance");
55-
returnIntPtr.Zero;
53+
Runtime.XIncref(ds);
54+
// unboundproperty
55+
returnds;
5656
}
5757

5858
try

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp