From fdd036da4efc5a0072d783c2ec1166dc1f3bc6e4 Mon Sep 17 00:00:00 2001 From: Alex Earl Date: Mon, 8 Aug 2016 15:53:10 -0700 Subject: [PATCH] Fix #1270 Fix issues that are valid for IronPython --- Languages/IronPython/IronPython.Modules/cPickle.cs | 2 +- Languages/IronPython/IronPython/Modules/Builtin.cs | 2 +- Languages/IronPython/IronPython/Modules/_ast.cs | 1 - Languages/IronPython/IronPython/Modules/imp.cs | 2 +- Languages/IronPython/IronPython/Runtime/ConversionWrappers.cs | 2 +- .../IronPython/IronPython/Runtime/Operations/PythonOps.cs | 2 +- .../IronPython/IronPython/Runtime/Operations/StringOps.cs | 2 +- .../IronPython/IronPythonTest/StringDictionaryStorage.cs | 2 +- Runtime/Microsoft.Dynamic/Debugging/DebugInfoRewriter.cs | 2 +- Runtime/Microsoft.Scripting/SourceLocation.cs | 2 +- Runtime/Tests/Metadata/Program.cs | 4 ++-- 11 files changed, 11 insertions(+), 12 deletions(-) diff --git a/Languages/IronPython/IronPython.Modules/cPickle.cs b/Languages/IronPython/IronPython.Modules/cPickle.cs index 9f64aabb9c..c144f08663 100644 --- a/Languages/IronPython/IronPython.Modules/cPickle.cs +++ b/Languages/IronPython/IronPython.Modules/cPickle.cs @@ -2196,7 +2196,7 @@ internal UnpicklerObject(CodeContext context, FileInput input) } PythonType cls = PopStack() as PythonType; - if (args == null) { + if (cls == null) { throw PythonOps.TypeError("expected new-style type as first argument to NEWOBJ, got {0}", DynamicHelpers.GetPythonType(args)); } diff --git a/Languages/IronPython/IronPython/Modules/Builtin.cs b/Languages/IronPython/IronPython/Modules/Builtin.cs index af73982ff6..e759fcc310 100644 --- a/Languages/IronPython/IronPython/Modules/Builtin.cs +++ b/Languages/IronPython/IronPython/Modules/Builtin.cs @@ -1642,7 +1642,7 @@ [NotNull]IList enumerator } object end = AttrCollectionPop(kwargs, "end", "\n"); - if (sep != null && !(sep is string)) { + if (end != null && !(end is string)) { throw PythonOps.TypeError("end must be None or str, not {0}", PythonTypeOps.GetName(end)); } diff --git a/Languages/IronPython/IronPython/Modules/_ast.cs b/Languages/IronPython/IronPython/Modules/_ast.cs index 26fba8a13a..073ae68df0 100755 --- a/Languages/IronPython/IronPython/Modules/_ast.cs +++ b/Languages/IronPython/IronPython/Modules/_ast.cs @@ -597,7 +597,6 @@ public arguments(PythonList args, [Optional]string vararg, [Optional]string kwar _args = args; _vararg = vararg; _kwarg = kwarg; - _kwarg = kwarg; _defaults = defaults; } diff --git a/Languages/IronPython/IronPython/Modules/imp.cs b/Languages/IronPython/IronPython/Modules/imp.cs index 01403cfb3b..f96dca0bd1 100644 --- a/Languages/IronPython/IronPython/Modules/imp.cs +++ b/Languages/IronPython/IronPython/Modules/imp.cs @@ -235,7 +235,7 @@ public static class PythonImport { public static object load_source(CodeContext/*!*/ context, string/*!*/ name, string/*!*/ pathname, PythonFile/*!*/ file) { if (name == null) throw PythonOps.TypeError("load_source() argument 1 must be string, not None"); if (pathname == null) throw PythonOps.TypeError("load_source() argument 2 must be string, not None"); - if (pathname == null) throw PythonOps.TypeError("load_source() argument 3 must be file, not None"); + if (file == null) throw PythonOps.TypeError("load_source() argument 3 must be file, not None"); return LoadPythonSource(PythonContext.GetContext(context), name, file, pathname); } diff --git a/Languages/IronPython/IronPython/Runtime/ConversionWrappers.cs b/Languages/IronPython/IronPython/Runtime/ConversionWrappers.cs index f9d9170123..fb74c16b97 100644 --- a/Languages/IronPython/IronPython/Runtime/ConversionWrappers.cs +++ b/Languages/IronPython/IronPython/Runtime/ConversionWrappers.cs @@ -232,7 +232,7 @@ public T Current } catch (System.InvalidCastException iex) { - throw new System.InvalidCastException(string.Format("Error in IEnumeratorOfTWrapper.Current. Could not cast: {0} in {0}", typeof(T).ToString(), enumerable.Current.GetType().ToString()), iex); + throw new System.InvalidCastException(string.Format("Error in IEnumeratorOfTWrapper.Current. Could not cast: {0} in {1}", typeof(T).ToString(), enumerable.Current.GetType().ToString()), iex); } } } diff --git a/Languages/IronPython/IronPython/Runtime/Operations/PythonOps.cs b/Languages/IronPython/IronPython/Runtime/Operations/PythonOps.cs index 409ca243c1..8db107d805 100644 --- a/Languages/IronPython/IronPython/Runtime/Operations/PythonOps.cs +++ b/Languages/IronPython/IronPython/Runtime/Operations/PythonOps.cs @@ -1235,7 +1235,7 @@ public static partial class PythonOps { } public static object IsMappingType(CodeContext/*!*/ context, object o) { - if (o is IDictionary || o is PythonDictionary || o is IDictionary || o is PythonDictionary) { + if (o is IDictionary || o is PythonDictionary || o is IDictionary) { return ScriptingRuntimeHelpers.True; } object getitem; diff --git a/Languages/IronPython/IronPython/Runtime/Operations/StringOps.cs b/Languages/IronPython/IronPython/Runtime/Operations/StringOps.cs index 5305aa2155..d4ca506116 100644 --- a/Languages/IronPython/IronPython/Runtime/Operations/StringOps.cs +++ b/Languages/IronPython/IronPython/Runtime/Operations/StringOps.cs @@ -1902,7 +1902,7 @@ static class CodecsInfo { d["cp" + encs[i].CodePage.ToString()] = d[normalizedName] = d["us"] = d["ascii"] = d["646"] = d["us_ascii"] = new AsciiEncodingInfoWrapper(); continue; case "iso_8859_1": - d["8859"] = d["latin_1"] = d["latin1"] = d["iso 8859_1"] = d["iso8859_1"] = d["cp819"] = d["819"] = d["latin"] = d["latin1"] = d["l1"] = encs[i]; + d["8859"] = d["latin_1"] = d["latin1"] = d["iso 8859_1"] = d["iso8859_1"] = d["cp819"] = d["819"] = d["latin"] = d["l1"] = encs[i]; break; case "utf_7": d["u7"] = d["unicode-1-1-utf-7"] = encs[i]; diff --git a/Languages/IronPython/IronPythonTest/StringDictionaryStorage.cs b/Languages/IronPython/IronPythonTest/StringDictionaryStorage.cs index 44d340cff3..d43bdaf635 100644 --- a/Languages/IronPython/IronPythonTest/StringDictionaryStorage.cs +++ b/Languages/IronPython/IronPythonTest/StringDictionaryStorage.cs @@ -137,7 +137,7 @@ internal class StringDictionaryStorage : DictionaryStorage { IDictionary dict; #if FEATURE_ICLONEABLE ICloneable cloneable = _dict as ICloneable; - if (_dict != null) { + if (cloneable != null) { dict = (IDictionary)cloneable.Clone(); } else #endif diff --git a/Runtime/Microsoft.Dynamic/Debugging/DebugInfoRewriter.cs b/Runtime/Microsoft.Dynamic/Debugging/DebugInfoRewriter.cs index ab22166538..424a1d7d96 100644 --- a/Runtime/Microsoft.Dynamic/Debugging/DebugInfoRewriter.cs +++ b/Runtime/Microsoft.Dynamic/Debugging/DebugInfoRewriter.cs @@ -250,7 +250,7 @@ internal class DebugInfoRewriter : MSAst.DynamicExpressionVisitor { node.Body, newFinally != null ? newFinally : node.Finally, node.Fault, - newHandlers != null ? newHandlers : newHandlers + newHandlers != null ? newHandlers : node.Handlers ); } diff --git a/Runtime/Microsoft.Scripting/SourceLocation.cs b/Runtime/Microsoft.Scripting/SourceLocation.cs index 3b1728701f..69f88f3ce4 100644 --- a/Runtime/Microsoft.Scripting/SourceLocation.cs +++ b/Runtime/Microsoft.Scripting/SourceLocation.cs @@ -154,7 +154,7 @@ public struct SourceLocation { /// 0 if the locations are equal, -1 if the left one is less than the right one, 1 otherwise. public static int Compare(SourceLocation left, SourceLocation right) { if (left < right) return -1; - if (right > left) return 1; + if (left > right) return 1; return 0; } diff --git a/Runtime/Tests/Metadata/Program.cs b/Runtime/Tests/Metadata/Program.cs index 2e516fdba8..49b58e5b60 100644 --- a/Runtime/Tests/Metadata/Program.cs +++ b/Runtime/Tests/Metadata/Program.cs @@ -265,7 +265,7 @@ select typeDef private static void DumpGenericParameters(MetadataTableView genericParams, MetadataRecord owner) { foreach (GenericParamDef gp in genericParams) { - _output.WriteLine(" generic parameter #{0}: {1}", gp.Index, gp.Name, gp.Attributes); + _output.WriteLine(" generic parameter #{0}: {1}({2})", gp.Index, gp.Name, gp.Attributes); Debug.Assert(gp.Owner.Equals(owner)); foreach (GenericParamConstraint gpc in gp.Constraints) { _output.WriteLine(" constraint {0}", TypeToString(gpc.Constraint)); @@ -431,7 +431,7 @@ select typeDef if (tables.AssemblyRefs.GetCount() > 0) { _output.WriteLine("AssemblyRefs:"); foreach (AssemblyRef a in tables.AssemblyRefs) { - _output.WriteLine(" {0} {1} {2} {3} {5}", + _output.WriteLine(" {0} {1} {2} {3} {4} {5}", a.Name, a.Version, a.Culture, a.NameFlags, BitConverter.ToString(a.GetHashValue()), BitConverter.ToString(a.GetPublicKeyOrToken()) ); }