Skip to content
This repository was archived by the owner on Jul 22, 2023. It is now read-only.

Commit 8627843

Browse files
committed
Syntax cleanup
1 parent ebbad47 commit 8627843

32 files changed

+634
-529
lines changed

src/runtime/arrayobject.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ public static IntPtr mp_subscript(IntPtr ob, IntPtr idx)
117117

118118
try
119119
{
120-
value = items.GetValue((int[])args);
120+
value = items.GetValue(args);
121121
}
122122
catch (IndexOutOfRangeException)
123123
{
@@ -210,7 +210,7 @@ public static int mp_ass_subscript(IntPtr ob, IntPtr idx, IntPtr v)
210210

211211
try
212212
{
213-
items.SetValue(value, (int[])args);
213+
items.SetValue(value, args);
214214
}
215215
catch (IndexOutOfRangeException)
216216
{

src/runtime/assemblyinfo.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
using System;
22
using System.Reflection;
33
using System.Resources;
4-
using System.Runtime.InteropServices;
54
using System.Runtime.CompilerServices;
5+
using System.Runtime.InteropServices;
66

77
[assembly: AssemblyProduct("Python for .NET")]
88
[assembly: AssemblyVersion("4.0.0.1")]

src/runtime/assemblymanager.cs

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -158,12 +158,10 @@ internal static void UpdatePath()
158158
public static string FindAssembly(string name)
159159
{
160160
char sep = Path.DirectorySeparatorChar;
161-
string path;
162-
string temp;
163161

164-
for (var i = 0; i < pypath.Count; i++)
162+
foreach (string head in pypath)
165163
{
166-
string head = pypath[i];
164+
string path;
167165
if (head == null || head.Length == 0)
168166
{
169167
path = name;
@@ -173,11 +171,12 @@ public static string FindAssembly(string name)
173171
path = head + sep + name;
174172
}
175173

176-
temp = path + ".dll";
174+
string temp = path + ".dll";
177175
if (File.Exists(temp))
178176
{
179177
return temp;
180178
}
179+
181180
temp = path + ".exe";
182181
if (File.Exists(temp))
183182
{
@@ -233,10 +232,8 @@ public static Assembly LoadAssemblyPath(string name)
233232
/// <summary>
234233
/// Loads an assembly using full path.
235234
/// </summary>
236-
/// <param name="name">
237-
/// </param>
238-
/// <returns>
239-
/// </returns>
235+
/// <param name="name"></param>
236+
/// <returns></returns>
240237
public static Assembly LoadAssemblyFullPath(string name)
241238
{
242239
Assembly assembly = null;
@@ -252,7 +249,7 @@ public static Assembly LoadAssemblyFullPath(string name)
252249
{
253250
assembly = Assembly.LoadFrom(name);
254251
}
255-
catch
252+
catch (Exception)
256253
{
257254
}
258255
}

src/runtime/classbase.cs

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
using System;
22
using System.Collections;
3-
using System.Reflection;
4-
using System.Security;
53
using System.Runtime.InteropServices;
64

75
namespace Python.Runtime
@@ -27,7 +25,7 @@ internal ClassBase(Type tp)
2725

2826
internal virtual bool CanSubclass()
2927
{
30-
return (!this.type.IsEnum);
28+
return !type.IsEnum;
3129
}
3230

3331
/// <summary>
@@ -49,12 +47,12 @@ public virtual IntPtr type_subscript(IntPtr idx)
4947
return Exceptions.RaiseTypeError("type(s) expected");
5048
}
5149

52-
Type target = GenericUtil.GenericForType(this.type, types.Length);
50+
Type target = GenericUtil.GenericForType(type, types.Length);
5351

5452
if (target != null)
5553
{
5654
Type t = target.MakeGenericType(types);
57-
ManagedType c = (ManagedType)ClassManager.GetClass(t);
55+
ManagedType c = ClassManager.GetClass(t);
5856
Runtime.XIncref(c.pyHandle);
5957
return c.pyHandle;
6058
}
@@ -115,10 +113,15 @@ public static IntPtr tp_richcompare(IntPtr ob, IntPtr other, int op)
115113
co1 = GetManagedObject(ob) as CLRObject;
116114
co2 = GetManagedObject(other) as CLRObject;
117115
if (co1 == null || co2 == null)
116+
{
118117
return Exceptions.RaiseTypeError("Cannot get managed object");
118+
}
119119
var co1Comp = co1.inst as IComparable;
120120
if (co1Comp == null)
121-
return Exceptions.RaiseTypeError("Cannot convert object of type " + co1.GetType() + " to IComparable");
121+
{
122+
Type co1Type = co1.GetType();
123+
return Exceptions.RaiseTypeError($"Cannot convert object of type {co1Type} to IComparable");
124+
}
122125
try
123126
{
124127
int cmp = co1Comp.CompareTo(co2.inst);

0 commit comments

Comments
 (0)