| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -117,7 +117,7 @@ public static IntPtr mp_subscript(IntPtr ob, IntPtr idx) | |||
| 117 | 117 | ||
| 118 | 118 | try | |
| 119 | 119 | { | |
| 120 | - value = items.GetValue((int[])args); | ||
| 120 | + value = items.GetValue(args); | ||
| 121 | 121 | } | |
| 122 | 122 | catch (IndexOutOfRangeException) | |
| 123 | 123 | { | |
@@ -210,7 +210,7 @@ public static int mp_ass_subscript(IntPtr ob, IntPtr idx, IntPtr v) | |||
| 210 | 210 | ||
| 211 | 211 | try | |
| 212 | 212 | { | |
| 213 | - items.SetValue(value, (int[])args); | ||
| 213 | + items.SetValue(value, args); | ||
| 214 | 214 | } | |
| 215 | 215 | catch (IndexOutOfRangeException) | |
| 216 | 216 | { | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,8 +1,8 @@ | |||
| 1 | 1 | using System; | |
| 2 | 2 | using System.Reflection; | |
| 3 | 3 | using System.Resources; | |
| 4 | - using System.Runtime.InteropServices; | ||
| 5 | 4 | using System.Runtime.CompilerServices; | |
| 5 | + using System.Runtime.InteropServices; | ||
| 6 | 6 | ||
| 7 | 7 | [assembly: AssemblyProduct("Python for .NET")] | |
| 8 | 8 | [assembly: AssemblyVersion("4.0.0.1")] | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -158,12 +158,10 @@ internal static void UpdatePath() | |||
| 158 | 158 | public static string FindAssembly(string name) | |
| 159 | 159 | { | |
| 160 | 160 | char sep = Path.DirectorySeparatorChar; | |
| 161 | - string path; | ||
| 162 | - string temp; | ||
| 163 | 161 | ||
| 164 | - for (var i = 0; i < pypath.Count; i++) | ||
| 162 | + foreach (string head in pypath) | ||
| 165 | 163 | { | |
| 166 | - string head = pypath[i]; | ||
| 164 | + string path; | ||
| 167 | 165 | if (head == null || head.Length == 0) | |
| 168 | 166 | { | |
| 169 | 167 | path = name; | |
@@ -173,11 +171,12 @@ public static string FindAssembly(string name) | |||
| 173 | 171 | path = head + sep + name; | |
| 174 | 172 | } | |
| 175 | 173 | ||
| 176 | - temp = path + ".dll"; | ||
| 174 | + string temp = path + ".dll"; | ||
| 177 | 175 | if (File.Exists(temp)) | |
| 178 | 176 | { | |
| 179 | 177 | return temp; | |
| 180 | 178 | } | |
| 179 | + | ||
| 181 | 180 | temp = path + ".exe"; | |
| 182 | 181 | if (File.Exists(temp)) | |
| 183 | 182 | { | |
@@ -233,10 +232,8 @@ public static Assembly LoadAssemblyPath(string name) | |||
| 233 | 232 | /// <summary> | |
| 234 | 233 | /// Loads an assembly using full path. | |
| 235 | 234 | /// </summary> | |
| 236 | - /// <param name="name"> | ||
| 237 | - /// </param> | ||
| 238 | - /// <returns> | ||
| 239 | - /// </returns> | ||
| 235 | + /// <param name="name"></param> | ||
| 236 | + /// <returns></returns> | ||
| 240 | 237 | public static Assembly LoadAssemblyFullPath(string name) | |
| 241 | 238 | { | |
| 242 | 239 | Assembly assembly = null; | |
@@ -252,7 +249,7 @@ public static Assembly LoadAssemblyFullPath(string name) | |||
| 252 | 249 | { | |
| 253 | 250 | assembly = Assembly.LoadFrom(name); | |
| 254 | 251 | } | |
| 255 | - catch | ||
| 252 | + catch (Exception) | ||
| 256 | 253 | { | |
| 257 | 254 | } | |
| 258 | 255 | } | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,7 +1,5 @@ | |||
| 1 | 1 | using System; | |
| 2 | 2 | using System.Collections; | |
| 3 | - using System.Reflection; | ||
| 4 | - using System.Security; | ||
| 5 | 3 | using System.Runtime.InteropServices; | |
| 6 | 4 | ||
| 7 | 5 | namespace Python.Runtime | |
@@ -27,7 +25,7 @@ internal ClassBase(Type tp) | |||
| 27 | 25 | ||
| 28 | 26 | internal virtual bool CanSubclass() | |
| 29 | 27 | { | |
| 30 | - return (!this.type.IsEnum); | ||
| 28 | + return !type.IsEnum; | ||
| 31 | 29 | } | |
| 32 | 30 | ||
| 33 | 31 | /// <summary> | |
@@ -49,12 +47,12 @@ public virtual IntPtr type_subscript(IntPtr idx) | |||
| 49 | 47 | return Exceptions.RaiseTypeError("type(s) expected"); | |
| 50 | 48 | } | |
| 51 | 49 | ||
| 52 | - Type target = GenericUtil.GenericForType(this.type, types.Length); | ||
| 50 | + Type target = GenericUtil.GenericForType(type, types.Length); | ||
| 53 | 51 | ||
| 54 | 52 | if (target != null) | |
| 55 | 53 | { | |
| 56 | 54 | Type t = target.MakeGenericType(types); | |
| 57 | - ManagedType c = (ManagedType)ClassManager.GetClass(t); | ||
| 55 | + ManagedType c = ClassManager.GetClass(t); | ||
| 58 | 56 | Runtime.XIncref(c.pyHandle); | |
| 59 | 57 | return c.pyHandle; | |
| 60 | 58 | } | |
@@ -115,10 +113,15 @@ public static IntPtr tp_richcompare(IntPtr ob, IntPtr other, int op) | |||
| 115 | 113 | co1 = GetManagedObject(ob) as CLRObject; | |
| 116 | 114 | co2 = GetManagedObject(other) as CLRObject; | |
| 117 | 115 | if (co1 == null || co2 == null) | |
| 116 | + { | ||
| 118 | 117 | return Exceptions.RaiseTypeError("Cannot get managed object"); | |
| 118 | + } | ||
| 119 | 119 | var co1Comp = co1.inst as IComparable; | |
| 120 | 120 | 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 | + } | ||
| 122 | 125 | try | |
| 123 | 126 | { | |
| 124 | 127 | int cmp = co1Comp.CompareTo(co2.inst); | |
| Back | FazBrowse Home | New Git URL |
0 commit comments