Skip to content
This repository has been archived by the owner on Sep 14, 2018. It is now read-only.

Commit

Permalink
Fix #1270
Browse files Browse the repository at this point in the history
Fix issues that are valid for IronPython
  • Loading branch information
Alex Earl committed Aug 8, 2016
1 parent dbace13 commit fdd036d
Show file tree
Hide file tree
Showing 11 changed files with 11 additions and 12 deletions.
2 changes: 1 addition & 1 deletion Languages/IronPython/IronPython.Modules/cPickle.cs
Expand Up @@ -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));
}

Expand Down
2 changes: 1 addition & 1 deletion Languages/IronPython/IronPython/Modules/Builtin.cs
Expand Up @@ -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));
}

Expand Down
1 change: 0 additions & 1 deletion Languages/IronPython/IronPython/Modules/_ast.cs
Expand Up @@ -597,7 +597,6 @@ public arguments(PythonList args, [Optional]string vararg, [Optional]string kwar
_args = args;
_vararg = vararg;
_kwarg = kwarg;
_kwarg = kwarg;
_defaults = defaults;
}

Expand Down
2 changes: 1 addition & 1 deletion Languages/IronPython/IronPython/Modules/imp.cs
Expand Up @@ -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);
}
Expand Down
Expand Up @@ -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);
}
}
}
Expand Down
Expand Up @@ -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<object, object> || o is PythonDictionary) {
if (o is IDictionary || o is PythonDictionary || o is IDictionary<object, object>) {
return ScriptingRuntimeHelpers.True;
}
object getitem;
Expand Down
Expand Up @@ -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];
Expand Down
Expand Up @@ -137,7 +137,7 @@ internal class StringDictionaryStorage : DictionaryStorage {
IDictionary<string, object> dict;
#if FEATURE_ICLONEABLE
ICloneable cloneable = _dict as ICloneable;
if (_dict != null) {
if (cloneable != null) {
dict = (IDictionary<string, object>)cloneable.Clone();
} else
#endif
Expand Down
2 changes: 1 addition & 1 deletion Runtime/Microsoft.Dynamic/Debugging/DebugInfoRewriter.cs
Expand Up @@ -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

This comment has been minimized.

Copy link
@slozier

slozier Aug 9, 2016

Contributor

@slide This is giving me a compile error. Seems to be missing a cast (IEnumerable<MSAst.CatchBlock>).

This comment has been minimized.

Copy link
@slide

slide Aug 9, 2016

Contributor

I need to remember to clean before building when applying patches. Should be fixed in a685165

);
}

Expand Down
2 changes: 1 addition & 1 deletion Runtime/Microsoft.Scripting/SourceLocation.cs
Expand Up @@ -154,7 +154,7 @@ public struct SourceLocation {
/// <returns>0 if the locations are equal, -1 if the left one is less than the right one, 1 otherwise.</returns>
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;
}
Expand Down
4 changes: 2 additions & 2 deletions Runtime/Tests/Metadata/Program.cs
Expand Up @@ -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));
Expand Down Expand Up @@ -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())
);
}
Expand Down

0 comments on commit fdd036d

Please sign in to comment.