Skip to content

Commit ac336a8

Browse files
committed
remove unused PythonMethodAttribute
fixes #1604
1 parent 58df35b commit ac336a8

File tree

3 files changed

+0
-94
lines changed

3 files changed

+0
-94
lines changed

src/runtime/interop.cs

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
using System.Diagnostics;
55
using System.Runtime.InteropServices;
66
using System.Reflection;
7-
using System.Text;
87

98
namespace Python.Runtime
109
{
@@ -31,15 +30,6 @@ public string DocString
3130
private string docStr;
3231
}
3332

34-
[Serializable]
35-
[AttributeUsage(AttributeTargets.Method | AttributeTargets.Delegate)]
36-
internal class PythonMethodAttribute : Attribute
37-
{
38-
public PythonMethodAttribute()
39-
{
40-
}
41-
}
42-
4333
[Serializable]
4434
[AttributeUsage(AttributeTargets.Method | AttributeTargets.Delegate)]
4535
internal class ModuleFunctionAttribute : Attribute

src/runtime/typemanager.cs

Lines changed: 0 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -208,8 +208,6 @@ internal static unsafe PyType CreateType(Type impl)
208208
Runtime.PyDict_SetItem(dict, PyIdentifier.__module__, mod);
209209
mod.Dispose();
210210

211-
InitMethods(dict, impl);
212-
213211
dict.Dispose();
214212

215213
// The type has been modified after PyType_Ready has been called
@@ -806,43 +804,6 @@ static void InitializeSlot(IntPtr type, int slotOffset, ThunkInfo thunk, SlotsHo
806804
}
807805
}
808806

809-
/// <summary>
810-
/// Given a dict of a newly allocated Python type object and a managed Type that
811-
/// implements it, initialize any methods defined by the Type that need
812-
/// to appear in the Python type __dict__ (based on custom attribute).
813-
/// </summary>
814-
private static void InitMethods(BorrowedReference typeDict, Type type)
815-
{
816-
Type marker = typeof(PythonMethodAttribute);
817-
818-
BindingFlags flags = BindingFlags.Public | BindingFlags.Static;
819-
var addedMethods = new HashSet<string>();
820-
821-
while (type != null)
822-
{
823-
MethodInfo[] methods = type.GetMethods(flags);
824-
foreach (MethodInfo method in methods)
825-
{
826-
if (!addedMethods.Contains(method.Name))
827-
{
828-
object[] attrs = method.GetCustomAttributes(marker, false);
829-
if (attrs.Length > 0)
830-
{
831-
string method_name = method.Name;
832-
var mi = new MethodInfo[1];
833-
mi[0] = method;
834-
MethodObject m = new TypeMethod(type, method_name, mi);
835-
Runtime.PyDict_SetItemString(typeDict, method_name, m.ObjectReference);
836-
m.DecrRefCount();
837-
addedMethods.Add(method_name);
838-
}
839-
}
840-
}
841-
type = type.BaseType;
842-
}
843-
}
844-
845-
846807
/// <summary>
847808
/// Utility method to copy slots from a given type to another type.
848809
/// </summary>

src/runtime/typemethod.cs

Lines changed: 0 additions & 45 deletions
This file was deleted.

0 commit comments

Comments
 (0)