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

Commitffae7e1

Browse files
committed
Non-delegate types should not be callable
1 parent50d947f commitffae7e1

File tree

2 files changed

+10
-31
lines changed

2 files changed

+10
-31
lines changed

‎src/runtime/classobject.cs

Lines changed: 0 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -278,36 +278,5 @@ public static int mp_ass_subscript(IntPtr ob, IntPtr idx, IntPtr v)
278278

279279
return0;
280280
}
281-
282-
283-
/// <summary>
284-
/// This is a hack. Generally, no managed class is considered callable
285-
/// from Python - with the exception of System.Delegate. It is useful
286-
/// to be able to call a System.Delegate instance directly, especially
287-
/// when working with multicast delegates.
288-
/// </summary>
289-
publicstaticIntPtrtp_call(IntPtrob,IntPtrargs,IntPtrkw)
290-
{
291-
//ManagedType self = GetManagedObject(ob);
292-
IntPtrtp=Runtime.PyObject_TYPE(ob);
293-
varcb=(ClassBase)GetManagedObject(tp);
294-
295-
if(cb.type!=typeof(Delegate))
296-
{
297-
Exceptions.SetError(Exceptions.TypeError,"object is not callable");
298-
returnIntPtr.Zero;
299-
}
300-
301-
varco=(CLRObject)GetManagedObject(ob);
302-
vard=co.instasDelegate;
303-
BindingFlagsflags=BindingFlags.Public|
304-
BindingFlags.NonPublic|
305-
BindingFlags.Instance|
306-
BindingFlags.Static;
307-
308-
MethodInfomethod=d.GetType().GetMethod("Invoke",flags);
309-
varbinder=newMethodBinder(method);
310-
returnbinder.Invoke(ob,args,kw);
311-
}
312281
}
313282
}

‎src/tests/test_class.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -315,3 +315,13 @@ def test_method_inheritance():
315315

316316
assertbase.IsBase()==True
317317
assertderived.IsBase()==False
318+
319+
320+
deftest_callable():
321+
"""Test that only delegate subtypes are callable"""
322+
323+
deffoo():
324+
pass
325+
326+
assertcallable(System.String("foo"))==False
327+
assertcallable(System.Action(foo))==True

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp