diff --git a/Src/IronPython.Modules/_collections.cs b/Src/IronPython.Modules/_collections.cs
index f0f838ba4..77067c319 100644
--- a/Src/IronPython.Modules/_collections.cs
+++ b/Src/IronPython.Modules/_collections.cs
@@ -551,20 +551,13 @@ public void __delitem__(CodeContext/*!*/ context, object index) {
}
}
- public PythonTuple __reduce__() {
- lock (_lockObj) {
- object[] items = new object[_itemCnt];
- int curItem = 0;
- WalkDeque(delegate(int curIndex) {
- items[curItem++] = _data[curIndex];
- return true;
- });
-
- return PythonTuple.MakeTuple(
- DynamicHelpers.GetPythonType(this),
- PythonTuple.MakeTuple(PythonList.FromArrayNoCopy(items))
- );
- }
+ public PythonTuple __reduce__(CodeContext context) {
+ return PythonTuple.MakeTuple(
+ DynamicHelpers.GetPythonType(this),
+ _maxLen == -1 ? PythonTuple.EMPTY : PythonTuple.MakeTuple(PythonTuple.EMPTY, maxlen),
+ GetType() == typeof(deque) ? null : PythonOps.GetBoundAttr(context, this, "__dict__"),
+ PythonOps.GetEnumeratorObject(context, this)
+ );
}
public int __len__() {
diff --git a/Src/IronPython.Modules/_ctypes/CData.cs b/Src/IronPython.Modules/_ctypes/CData.cs
index 147061c25..fc004eb53 100644
--- a/Src/IronPython.Modules/_ctypes/CData.cs
+++ b/Src/IronPython.Modules/_ctypes/CData.cs
@@ -72,8 +72,7 @@ internal void SetAddress(IntPtr address) {
internal void InitializeFromBuffer(object? data, int offset, int size) {
var bp = data as IBufferProtocol
- ?? throw PythonOps.TypeErrorForBadInstance("{0} object does not have the buffer interface", data);
- // Python 3.5: PythonOps.TypeErrorForBytesLikeTypeMismatch(data);
+ ?? throw PythonOps.TypeErrorForBytesLikeTypeMismatch(data);
IPythonBuffer buffer = bp.GetBuffer(BufferFlags.FullRO);
if (buffer.IsReadOnly) {
@@ -97,8 +96,7 @@ internal void InitializeFromBuffer(object? data, int offset, int size) {
internal void InitializeFromBufferCopy(object? data, int offset, int size) {
var bp = data as IBufferProtocol
- ?? throw PythonOps.TypeErrorForBadInstance("{0} object does not have the buffer interface", data);
- // Python 3.5: PythonOps.TypeErrorForBytesLikeTypeMismatch(data);
+ ?? throw PythonOps.TypeErrorForBytesLikeTypeMismatch(data);
using IPythonBuffer buffer = bp.GetBuffer();
var span = buffer.AsReadOnlySpan();
diff --git a/Src/IronPython.Modules/_ctypes/CFuncPtrType.cs b/Src/IronPython.Modules/_ctypes/CFuncPtrType.cs
index 4e0d81143..bb97ddc34 100644
--- a/Src/IronPython.Modules/_ctypes/CFuncPtrType.cs
+++ b/Src/IronPython.Modules/_ctypes/CFuncPtrType.cs
@@ -69,6 +69,12 @@ internal static PythonType MakeSystemType(Type underlyingSystemType) {
return PythonType.SetPythonType(underlyingSystemType, new CFuncPtrType(underlyingSystemType));
}
+ public object from_buffer(object obj)
+ => throw PythonOps.TypeError("abstract class");
+
+ public object from_buffer_copy(object obj)
+ => throw PythonOps.TypeError("abstract class");
+
///
/// Converts an object into a function call parameter.
///
diff --git a/Src/IronPython.Modules/_ctypes/PointerType.cs b/Src/IronPython.Modules/_ctypes/PointerType.cs
index 197863398..dba2709ae 100644
--- a/Src/IronPython.Modules/_ctypes/PointerType.cs
+++ b/Src/IronPython.Modules/_ctypes/PointerType.cs
@@ -47,6 +47,12 @@ private PointerType(Type underlyingSystemType)
: base(underlyingSystemType) {
}
+ public object from_buffer(object obj)
+ => throw PythonOps.TypeError("abstract class");
+
+ public object from_buffer_copy(object obj)
+ => throw PythonOps.TypeError("abstract class");
+
public object from_param([NotNone] CData obj) {
return new NativeArgument((CData)PythonCalls.Call(this, obj), "P");
}
diff --git a/Src/IronPython.Modules/_ctypes/_ctypes.cs b/Src/IronPython.Modules/_ctypes/_ctypes.cs
index 4191cf01b..2fc944378 100644
--- a/Src/IronPython.Modules/_ctypes/_ctypes.cs
+++ b/Src/IronPython.Modules/_ctypes/_ctypes.cs
@@ -101,27 +101,21 @@ private static IntPtr Cast(IntPtr data, IntPtr obj, IntPtr type) {
GCHandle typeHandle = GCHandle.FromIntPtr(type);
try {
CData cdata = objHandle.Target as CData;
- PythonType pt = (PythonType)typeHandle.Target;
+ PythonType pt = typeHandle.Target as PythonType;
- CData res = (CData)pt.CreateInstance(pt.Context.SharedContext);
- if (IsPointer(pt)) {
- res.MemHolder = new MemoryHolder(IntPtr.Size);
- if (IsPointer(DynamicHelpers.GetPythonType(cdata))) {
- res.MemHolder.WriteIntPtr(0, cdata.MemHolder.ReadIntPtr(0));
- } else {
- res.MemHolder.WriteIntPtr(0, data);
- }
+ if (!IsPointer(pt)) throw PythonOps.TypeError("cast() argument 2 must be a pointer type, not {0}", PythonOps.GetPythonTypeName(typeHandle.Target));
- if (cdata != null) {
- res.MemHolder.Objects = cdata.MemHolder.Objects;
- res.MemHolder.AddObject(IdDispenser.GetId(cdata), cdata);
- }
+ CData res = (CData)pt.CreateInstance(pt.Context.SharedContext);
+ res.MemHolder = new MemoryHolder(IntPtr.Size);
+ if (IsPointer(DynamicHelpers.GetPythonType(cdata))) {
+ res.MemHolder.WriteIntPtr(0, cdata.MemHolder.ReadIntPtr(0));
} else {
- if (cdata != null) {
- res.MemHolder = new MemoryHolder(data, ((INativeType)pt).Size, cdata.MemHolder);
- } else {
- res.MemHolder = new MemoryHolder(data, ((INativeType)pt).Size);
- }
+ res.MemHolder.WriteIntPtr(0, data);
+ }
+
+ if (cdata != null) {
+ res.MemHolder.Objects = cdata.MemHolder.Objects;
+ res.MemHolder.AddObject(IdDispenser.GetId(cdata), cdata);
}
return GCHandle.ToIntPtr(GCHandle.Alloc(res));
diff --git a/Src/IronPython.Modules/mmap.cs b/Src/IronPython.Modules/mmap.cs
index 38535165c..c85bb825b 100644
--- a/Src/IronPython.Modules/mmap.cs
+++ b/Src/IronPython.Modules/mmap.cs
@@ -727,20 +727,23 @@ public object tell() {
}
}
- public void write([BytesLike] IList s) {
+ public int write([NotNone] IBufferProtocol s) {
+ using var buffer = s.GetBuffer();
using (new MmapLocker(this)) {
EnsureWritable();
long pos = Position;
- if (_view.Capacity - pos < s.Count) {
+ if (_view.Capacity - pos < buffer.AsReadOnlySpan().Length) {
throw PythonOps.ValueError("data out of range");
}
- byte[] data = s as byte[] ?? (s is Bytes b ? b.UnsafeByteArray : s.ToArray());
- _view.WriteArray(pos, data, 0, s.Count);
+ byte[] data = buffer.AsUnsafeArray() ?? buffer.ToArray();
+ _view.WriteArray(pos, data, 0, data.Length);
- Position = pos + s.Count;
+ Position = pos + data.Length;
+
+ return data.Length;
}
}
diff --git a/Src/IronPython/Compiler/Ast/TupleExpression.cs b/Src/IronPython/Compiler/Ast/TupleExpression.cs
index eeda8c3da..82f34cebf 100644
--- a/Src/IronPython/Compiler/Ast/TupleExpression.cs
+++ b/Src/IronPython/Compiler/Ast/TupleExpression.cs
@@ -17,17 +17,10 @@ public TupleExpression(bool expandable, params Expression[] items)
}
internal override string? CheckAssign() {
- if (Items.Count == 0) {
- // TODO: remove this when we get to 3.6
- return "can't assign to ()";
- }
-
return base.CheckAssign();
}
internal override string? CheckDelete() {
- if (Items.Count == 0)
- return "can't delete ()"; // TODO: remove this when we get to 3.6
return base.CheckDelete();
}
diff --git a/Src/IronPython/Modules/Builtin.cs b/Src/IronPython/Modules/Builtin.cs
index 50a65aca7..337aae583 100644
--- a/Src/IronPython/Modules/Builtin.cs
+++ b/Src/IronPython/Modules/Builtin.cs
@@ -135,7 +135,7 @@ public static string bin(object? number) {
public static PythonType bytes => DynamicHelpers.GetPythonTypeFromType(typeof(Bytes));
- public static PythonType bytearray => DynamicHelpers.GetPythonTypeFromType(typeof(ByteArray));
+ public static PythonType bytearray => TypeCache.ByteArray;
[Documentation("callable(object) -> bool\n\nReturn whether the object is callable (i.e., some kind of function).")]
public static bool callable(CodeContext/*!*/ context, object? o) {
diff --git a/Src/IronPython/Runtime/ByteArray.cs b/Src/IronPython/Runtime/ByteArray.cs
index ef3f6a2a0..38e54bb6a 100644
--- a/Src/IronPython/Runtime/ByteArray.cs
+++ b/Src/IronPython/Runtime/ByteArray.cs
@@ -9,16 +9,16 @@
using System.Collections.Generic;
using System.Numerics;
using System.Runtime.CompilerServices;
-using System.Runtime.InteropServices;
using System.Text;
-using Microsoft.Scripting.Runtime;
-using Microsoft.Scripting.Utils;
-
using IronPython.Runtime.Exceptions;
using IronPython.Runtime.Operations;
using IronPython.Runtime.Types;
+using Microsoft.Scripting;
+using Microsoft.Scripting.Runtime;
+using Microsoft.Scripting.Utils;
+
namespace IronPython.Runtime {
///
/// bytearray(string, encoding[, errors]) -> bytearray
@@ -56,6 +56,12 @@ internal ByteArray(IEnumerable bytes) {
_bytes = new ArrayData(bytes);
}
+ [StaticExtensionMethod]
+ public static object __new__(CodeContext context, [NotNone] PythonType cls, [ParamDictionary, NotNone] IDictionary
- internal static bool TryConvertToIndex(object? value, out int index, bool throwOverflowError = true, bool throwNonInt = true) {
+ internal static bool TryConvertToIndex(object? value, out int index, bool throwOverflowError = true, bool throwTypeError = true) {
if (TryGetInt(value, out index, throwOverflowError, value)) {
return true;
}
- if (PythonTypeOps.TryInvokeUnaryOperator(DefaultContext.Default, value, "__index__", out object indexObj)) {
- if (TryGetInt(indexObj, out index, throwOverflowError, value)) {
- return true;
- }
+ if (throwTypeError) {
+ if (PythonTypeOps.TryInvokeUnaryOperator(DefaultContext.Default, value, "__index__", out object indexObj)) {
+ if (TryGetInt(indexObj, out index, throwOverflowError, value)) {
+ return true;
+ }
- if (throwNonInt) {
throw PythonOps.TypeError("__index__ returned non-int (type {0})", PythonOps.GetPythonTypeName(indexObj));
}
+ } else {
+ try {
+ return PythonTypeOps.TryInvokeUnaryOperator(DefaultContext.Default, value, "__index__", out object indexObj) &&
+ TryGetInt(indexObj, out index, throwOverflowError, value);
+ } catch (Exceptions.TypeErrorException) { }
}
return false;
}
public static int ConvertToIndex(object? value, bool throwOverflowError = false) {
- if (TryConvertToIndex(value, out int index, throwOverflowError: throwOverflowError, throwNonInt: true))
+ if (TryConvertToIndex(value, out int index, throwOverflowError: throwOverflowError))
return index;
throw PythonOps.TypeError("expected integer value, got {0}", PythonOps.GetPythonTypeName(value));
diff --git a/Src/IronPython/Runtime/Operations/BigIntegerOps.cs b/Src/IronPython/Runtime/Operations/BigIntegerOps.cs
index 0884c8ca7..696fb2253 100644
--- a/Src/IronPython/Runtime/Operations/BigIntegerOps.cs
+++ b/Src/IronPython/Runtime/Operations/BigIntegerOps.cs
@@ -924,10 +924,9 @@ public static object from_bytes(CodeContext context, PythonType type, object? by
var val = new BigInteger(bytesArr);
#endif
- // prevents a TypeError: int.__new__(bool) is not safe
- if (type == TypeCache.Boolean) return val == 0 ? ScriptingRuntimeHelpers.False : ScriptingRuntimeHelpers.True;
+ if (type == TypeCache.BigInteger) return val;
- return __new__(context, type, val);
+ return PythonTypeOps.CallParams(context, type, val);
}
#endregion
diff --git a/Src/IronPython/Runtime/Operations/PythonOps.cs b/Src/IronPython/Runtime/Operations/PythonOps.cs
index 4da2fa404..073868b35 100644
--- a/Src/IronPython/Runtime/Operations/PythonOps.cs
+++ b/Src/IronPython/Runtime/Operations/PythonOps.cs
@@ -758,7 +758,7 @@ public static object PowerMod(CodeContext/*!*/ context, object? x, object? y, ob
}
}
- throw PythonOps.TypeErrorForBinaryOp("power with modulus", x, y);
+ throw PythonOps.TypeError("unsupported operand type(s) for pow(): '{0}', '{1}', '{2}'", GetPythonTypeName(x), GetPythonTypeName(y), GetPythonTypeName(y));
}
public static long Id(object? o) {
@@ -896,10 +896,16 @@ public static int Length(object? o) {
}
internal static bool TryInvokeLengthHint(CodeContext context, object? sequence, out int hint) {
- if (PythonTypeOps.TryInvokeUnaryOperator(context, sequence, "__len__", out object len_obj) ||
- PythonTypeOps.TryInvokeUnaryOperator(context, sequence, "__length_hint__", out len_obj)) {
+ if (PythonTypeOps.TryInvokeUnaryOperator(context, sequence, "__len__", out object len_obj)) {
if (!(len_obj is NotImplementedType)) {
hint = Converter.ConvertToInt32(len_obj);
+ if (hint < 0) throw ValueError("__len__() should return >= 0");
+ return true;
+ }
+ } else if (PythonTypeOps.TryInvokeUnaryOperator(context, sequence, "__length_hint__", out len_obj)) {
+ if (!(len_obj is NotImplementedType)) {
+ hint = Converter.ConvertToInt32(len_obj);
+ if (hint < 0) throw ValueError("__length_hint__() should return >= 0");
return true;
}
}
@@ -4012,7 +4018,7 @@ internal static Exception TypeErrorForBadInstance(string template, object? insta
}
public static Exception TypeErrorForBinaryOp(string opSymbol, object? x, object? y) {
- throw PythonOps.TypeError("unsupported operand type(s) for {0}: '{1}' and '{2}'",
+ throw PythonOps.TypeError("'{0}' not supported between instances of '{1}' and '{2}'",
opSymbol, GetPythonTypeName(x), GetPythonTypeName(y));
}
diff --git a/Src/IronPython/Runtime/PythonList.cs b/Src/IronPython/Runtime/PythonList.cs
index bc7a9e6bf..1c0e6c09e 100644
--- a/Src/IronPython/Runtime/PythonList.cs
+++ b/Src/IronPython/Runtime/PythonList.cs
@@ -740,7 +740,10 @@ public void extend([NotNone] PythonTuple/*!*/ seq) {
public void extend(object? seq) {
if (PythonOps.TryInvokeLengthHint(DefaultContext.Default, seq, out int len)) {
- EnsureSize(len);
+ // CPython proceeds without resizing if the length overflows
+ if (int.MaxValue - len >= Count) {
+ EnsureSize(Count + len);
+ }
}
ExtendNoLengthCheck(seq);
diff --git a/Src/IronPython/Runtime/PythonRange.cs b/Src/IronPython/Runtime/PythonRange.cs
index 750791250..d5cde273d 100644
--- a/Src/IronPython/Runtime/PythonRange.cs
+++ b/Src/IronPython/Runtime/PythonRange.cs
@@ -83,9 +83,9 @@ public PythonTuple __reduce__() {
);
}
- public int __len__() {
- return (int)_length;
- }
+ public int __len__() => (int)_length;
+
+ public bool __bool__() => _length != 0;
public object this[int index] => this[(BigInteger)index];
diff --git a/Src/IronPython/Runtime/Types/TypeCache.Generated.cs b/Src/IronPython/Runtime/Types/TypeCache.Generated.cs
index 31185b5e0..a1c36d561 100644
--- a/Src/IronPython/Runtime/Types/TypeCache.Generated.cs
+++ b/Src/IronPython/Runtime/Types/TypeCache.Generated.cs
@@ -29,6 +29,7 @@ public static class TypeCache {
private static PythonType pythontype;
private static PythonType str;
private static PythonType bytes;
+ private static PythonType bytearray;
private static PythonType pythontuple;
private static PythonType weakreference;
private static PythonType pythonlist;
@@ -131,6 +132,13 @@ public static PythonType Bytes {
}
}
+ public static PythonType ByteArray {
+ get {
+ if (bytearray == null) bytearray = DynamicHelpers.GetPythonTypeFromType(typeof(ByteArray));
+ return bytearray;
+ }
+ }
+
public static PythonType PythonTuple {
get {
if (pythontuple == null) pythontuple = DynamicHelpers.GetPythonTypeFromType(typeof(PythonTuple));
diff --git a/Src/IronPythonTest/Cases/CPythonCasesManifest.ini b/Src/IronPythonTest/Cases/CPythonCasesManifest.ini
index 8dc0b64ae..b375bb00d 100644
--- a/Src/IronPythonTest/Cases/CPythonCasesManifest.ini
+++ b/Src/IronPythonTest/Cases/CPythonCasesManifest.ini
@@ -13,6 +13,9 @@ Ignore=true
[CPython.ctypes.test_bitfields] # IronPython.modules.type_related.test_bitfields_ctypes_stdlib
Ignore=true
+[CPython.ctypes.test_cast]
+RunCondition=NOT $(IS_POSIX) # https://github.com/IronLanguages/ironpython3/issues/1455
+
[CPython.ctypes.test_errno]
Ignore=true
Reason=Current implementation of get_last_error needs to be debugged
@@ -339,7 +342,7 @@ Ignore=true
[CPython.test_deque]
IsolationLevel=PROCESS # https://github.com/IronLanguages/ironpython3/issues/489
-RetryCount=2
+RunCondition=NOT $(IS_MONO) # https://github.com/IronLanguages/ironpython3/issues/544
[CPython.test_descr]
IsolationLevel=ENGINE
@@ -508,6 +511,9 @@ IsolationLevel=PROCESS # use app.config - https://docs.microsoft.com/en-us/dotne
RunCondition=$(IS_POSIX)
Reason=Only valid for Unix
+[CPython.test_gzip]
+IsolationLevel=PROCESS # https://github.com/IronLanguages/ironpython3/issues/1440
+
[CPython.test_heapq]
Ignore=true
Reason=TypeError: __next__() takes exactly 1 argument (1 given) # https://github.com/IronLanguages/ironpython3/issues/547
@@ -603,6 +609,7 @@ Reason=ImportError: No module named _lzma
[CPython.test_macpath]
RunCondition=NOT $(IS_MONO) # https://github.com/IronLanguages/ironpython3/issues/1102
+IsolationLevel=PROCESS # https://github.com/IronLanguages/ironpython3/issues/1440
[CPython.test_mailbox]
Ignore=true
@@ -1158,17 +1165,11 @@ RunCondition=NOT $(IS_MONO) # TODO: debug
[CPython.ctypes.test_bytes]
Ignore=true # AssertionError: 'xbd' not found in ""
-[CPython.ctypes.test_cast]
-Ignore=true # SystemError: Object reference not set to an instance of an object.
-
-[CPython.ctypes.test_frombuffer]
-Ignore=true # 2 failures
-
[CPython.ctypes.test_structures]
Ignore=true # 2 failures
[CPython.test_abc]
-Ignore=true # test_works_with_init_subclass
+Ignore=true # test_works_with_init_subclass - https://github.com/IronLanguages/ironpython3/issues/1448
[CPython.test_array]
Ignore=true # test_free_after_iterating/test_type_error
@@ -1179,9 +1180,6 @@ Ignore=true # blocking
[CPython.test_base64]
Ignore=true # https://github.com/IronLanguages/ironpython3/issues/1135
-[CPython.test_bytes]
-Ignore=true # 5 failures
-
[CPython.test_call]
Ignore=true # test_kwargs_order
@@ -1194,11 +1192,8 @@ Ignore=true # blocked by https://github.com/IronLanguages/ironpython3/issues/98
[CPython.test_csv]
Ignore=true # two failures
-[CPython.test_deque]
-Ignore=true # StackOverflowException
-
[CPython.test_fileinput]
-Ignore=true # test_errors
+Ignore=true # test_errors - https://github.com/IronLanguages/ironpython3/issues/1452
[CPython.test_genericpath]
Ignore=true # blocked by os.PathLike
@@ -1212,9 +1207,6 @@ Ignore=true # blocked by https://github.com/IronLanguages/ironpython3/issues/98
[CPython.test_grp]
Ignore=true # 2 failures
-[CPython.test_gzip]
-IsolationLevel=PROCESS # https://github.com/IronLanguages/ironpython3/issues/1440
-
[CPython.test_hashlib]
Ignore=true # AttributeError: 'module' object has no attribute 'shake_128'
@@ -1224,18 +1216,9 @@ Ignore=true # blocked by https://github.com/IronLanguages/ironpython3/issues/105
[CPython.test_linecache]
Ignore=true # two failures
-[CPython.test_list]
-Ignore=true # blocking
-
-[CPython.test_macpath]
-IsolationLevel=PROCESS # https://github.com/IronLanguages/ironpython3/issues/1440
-
[CPython.test_math]
Ignore=true # precision?
-[CPython.test_mmap]
-Ignore=true # 2 failures
-
[CPython.test_ntpath]
Ignore=true # blocked by os.PathLike
@@ -1251,15 +1234,9 @@ Ignore=true # StackOverflowException
[CPython.test_print]
Ignore=true # 7 failures
-[CPython.test_range]
-Ignore=true # OverflowError: Arithmetic operation resulted in an overflow.
-
[CPython.test_regrtest]
Ignore=true # lots of failures
-[CPython.test_richcmp]
-Ignore=true # error message changed?
-
[CPython.test_set]
Ignore=true # test_hash_effectiveness
@@ -1270,7 +1247,7 @@ Ignore=true # unittest.case.SkipTest: Cannot import name SSLSession
Ignore=true # fails on macOS
[CPython.test_string]
-Ignore=true # test_invalid_placeholders
+Ignore=true # test_invalid_placeholders - https://github.com/IronLanguages/ironpython3/issues/1419
[CPython.test_string_literals]
Ignore=true # AssertionError: DeprecationWarning not triggered
@@ -1278,17 +1255,14 @@ Ignore=true # AssertionError: DeprecationWarning not triggered
[CPython.test_support]
Ignore=true # lots of failures
-[CPython.test_unpack]
-Ignore=true # 4 failures
-
[CPython.test_userdict]
-Ignore=true # blocking
+Ignore=true # StackOverflowException
[CPython.test_userlist]
-Ignore=true # blocking
+Ignore=true # test_free_after_iterating
[CPython.test_uuid]
-Ignore=true # LookupError: unknown encoding: oem
+Ignore=true # LookupError: unknown encoding: oem - https://github.com/IronLanguages/ironpython3/issues/1451
[CPython.test_winreg]
Ignore=true # 3 failures
diff --git a/Src/IronPythonTest/Cases/IronPythonCasesManifest.ini b/Src/IronPythonTest/Cases/IronPythonCasesManifest.ini
index faea25131..43bdb268d 100644
--- a/Src/IronPythonTest/Cases/IronPythonCasesManifest.ini
+++ b/Src/IronPythonTest/Cases/IronPythonCasesManifest.ini
@@ -185,9 +185,6 @@ Ignore=true # multiple failures
[IronPython.test_codeccallbacks_stdlib]
Ignore=true # multiple failures
-[IronPython.test_complex_stdlib]
-Ignore=true # 1 failure https://github.com/IronLanguages/ironpython3/issues/105
-
[IronPython.test_datetime_stdlib]
Ignore=true # multiple failures
@@ -209,9 +206,6 @@ Ignore=true # 1 failure
[IronPython.test_itertools_stdlib]
Ignore=true # 4 failures
-[IronPython.test_long_stdlib]
-Ignore=true # 2 failures
-
[IronPython.test_re_stdlib]
Ignore=true # AssertionError: SRE module mismatch
@@ -235,9 +229,3 @@ Ignore=true # 3 failures
[IronPython.test_types_stdlib]
Ignore=true # blocked by https://github.com/IronLanguages/ironpython3/issues/98
-
-[IronPython.test_unpack]
-Ignore=true # test_assign_to_empty
-
-[IronPython.test_unicode_stdlib]
-Ignore=true # 3 failures
diff --git a/Src/Scripts/generate_typecache.py b/Src/Scripts/generate_typecache.py
index 7a9a3ae47..32eca2a36 100644
--- a/Src/Scripts/generate_typecache.py
+++ b/Src/Scripts/generate_typecache.py
@@ -45,6 +45,7 @@ def __init__(self, type, name=None, typeType='PythonType', entryName=None):
TypeData('PythonType'),
TypeData('String', 'str'),
TypeData('Bytes'),
+ TypeData('ByteArray'),
TypeData('PythonTuple'),
TypeData('WeakReference'),
TypeData('PythonList'),
diff --git a/Src/StdLib/Lib/test/test_deque.py b/Src/StdLib/Lib/test/test_deque.py
index f4c5e205f..2193885c8 100644
--- a/Src/StdLib/Lib/test/test_deque.py
+++ b/Src/StdLib/Lib/test/test_deque.py
@@ -8,7 +8,6 @@
from io import StringIO
import random
import struct
-import sys
BIG = 100000
@@ -735,7 +734,6 @@ def test_gc_doesnt_blowup(self):
d.append(1)
gc.collect()
- @unittest.skipIf(sys.implementation.name == "ironpython", "https://github.com/IronLanguages/ironpython3/issues/544")
def test_container_iterator(self):
# Bug #3680: tp_traverse was not implemented for deque iterator objects
class C(object):
diff --git a/Src/StdLib/Lib/test/test_mmap.py b/Src/StdLib/Lib/test/test_mmap.py
index 604ba7193..92a7b9840 100644
--- a/Src/StdLib/Lib/test/test_mmap.py
+++ b/Src/StdLib/Lib/test/test_mmap.py
@@ -53,7 +53,7 @@ def test_basic(self):
# Shouldn't crash on boundary (Issue #5292)
self.assertRaises(IndexError, m.__getitem__, len(m))
- self.assertRaises(IndexError, m.__setitem__, len(m), b'\0')
+ self.assertRaises(IndexError, m.__setitem__, len(m), 0)
# Modify the file's content
m[0] = b'3'[0]
diff --git a/Src/StdLib/Lib/test/test_unicode.py b/Src/StdLib/Lib/test/test_unicode.py
index 9dd8e7a90..c5e88e7ea 100644
--- a/Src/StdLib/Lib/test/test_unicode.py
+++ b/Src/StdLib/Lib/test/test_unicode.py
@@ -2456,6 +2456,7 @@ def test_free_after_iterating(self):
class CAPITest(unittest.TestCase):
# Test PyUnicode_FromFormat()
+ @support.cpython_only
def test_from_format(self):
support.import_module('ctypes')
from ctypes import (
diff --git a/Tests/test_complex_stdlib.py b/Tests/test_complex_stdlib.py
index e35aec0b2..43e698181 100644
--- a/Tests/test_complex_stdlib.py
+++ b/Tests/test_complex_stdlib.py
@@ -24,7 +24,7 @@ def load_tests(loader, standard_tests, pattern):
suite.addTest(test.test_complex.ComplexTest('test_divmod'))
suite.addTest(test.test_complex.ComplexTest('test_file'))
suite.addTest(test.test_complex.ComplexTest('test_floordiv'))
- suite.addTest(unittest.expectedFailure(test.test_complex.ComplexTest('test_format')))
+ suite.addTest(unittest.expectedFailure(test.test_complex.ComplexTest('test_format'))) # https://github.com/IronLanguages/ironpython2/issues/102
suite.addTest(test.test_complex.ComplexTest('test_getnewargs'))
suite.addTest(test.test_complex.ComplexTest('test_hash'))
suite.addTest(test.test_complex.ComplexTest('test_mod'))
@@ -39,7 +39,7 @@ def load_tests(loader, standard_tests, pattern):
suite.addTest(test.test_complex.ComplexTest('test_richcompare'))
suite.addTest(test.test_complex.ComplexTest('test_richcompare_boundaries'))
suite.addTest(test.test_complex.ComplexTest('test_truediv'))
- suite.addTest(test.test_complex.ComplexTest('test_underscores'))
+ suite.addTest(unittest.expectedFailure(test.test_complex.ComplexTest('test_underscores'))) # https://github.com/IronLanguages/ironpython3/issues/105
return suite
else:
diff --git a/Tests/test_long_stdlib.py b/Tests/test_long_stdlib.py
index c86afd04b..e2c6d5639 100644
--- a/Tests/test_long_stdlib.py
+++ b/Tests/test_long_stdlib.py
@@ -16,7 +16,7 @@
def load_tests(loader, standard_tests, pattern):
if sys.implementation.name == 'ironpython':
suite = unittest.TestSuite()
- suite.addTest(test.test_long.LongTest('test__format__'))
+ suite.addTest(unittest.expectedFailure(test.test_long.LongTest('test__format__'))) # https://github.com/IronLanguages/ironpython3/issues/105
suite.addTest(test.test_long.LongTest('test_access_to_nonexistent_digit_0'))
suite.addTest(test.test_long.LongTest('test_bit_length'))
suite.addTest(test.test_long.LongTest('test_bitop_identities'))
diff --git a/Tests/test_tuple.py b/Tests/test_tuple.py
index 61d73a2b7..30c3f27da 100644
--- a/Tests/test_tuple.py
+++ b/Tests/test_tuple.py
@@ -9,11 +9,11 @@
class TupleTest(IronPythonTestCase):
def test_assign_to_empty(self):
- """Disallow assignment to empty tuple"""
+ """Allow assignment to empty tuple (new in 3.6)"""
y = ()
- self.assertRaises(SyntaxError, compile, "() = y", "Error", "exec")
- self.assertRaises(SyntaxError, compile, "(), t = y, 0", "Error", "exec")
- self.assertRaises(SyntaxError, compile, "((()))=((y))", "Error", "exec")
+ () = y
+ (), t = y, 0
+ ((()))=((y))
del y
def test_unpack(self):
@@ -52,11 +52,11 @@ class mylong(int): pass
self.assertEqual((3, 4).__mul__(mylong(2)), (3, 4, 3, 4))
self.assertEqual((5, 6).__rmul__(mylong(2)), (5, 6, 5, 6))
self.assertEqual(mylong(2) * (7,8) , (7, 8, 7, 8))
-
+
class mylong2(int):
def __rmul__(self, other):
return 42
-
+
self.assertEqual((1,2) * mylong2(2), 42) # this one uses __rmul__
self.assertEqual((3, 4).__mul__(mylong2(2)), (3, 4, 3, 4))
self.assertEqual((5, 6).__rmul__(mylong2(2)), (5, 6, 5, 6))
@@ -71,12 +71,12 @@ def __hash__(self):
return 42
def __eq__(self, other):
return type(self) == type(other)
-
-
+
+
test = (myhashable(), myhashable(), myhashable())
-
+
hash(test)
-
+
self.assertEqual(test[0].hashcalls, 1)
self.assertEqual(test[1].hashcalls, 1)
self.assertEqual(test[2].hashcalls, 1)
@@ -94,7 +94,7 @@ def test_tuple_hash_none(self):
import clr # Make sure .GetHashCode() is available
example = (1, None)
expected = 1625286227
-
+
self.assertEqual(hash(example), expected)
self.assertEqual(hash(example), example.GetHashCode())
@@ -103,9 +103,9 @@ def test_tuple_cli_interactions(self):
# verify you can call ToString on a tuple after importing clr
import clr
a = (0,)
-
+
self.assertEqual(str(a), a.ToString())
-
+
def test_sequence_assign(self):
try:
@@ -125,7 +125,7 @@ def test_sort(self):
def test_indexing(self):
t = (2,3,4)
self.assertRaises(TypeError, lambda : t[2.0])
-
+
class mytuple(tuple):
def __getitem__(self, index):
return tuple.__getitem__(self, int(index))
@@ -145,11 +145,11 @@ def __getitem__(self):
for x in T((1,)):
self.assertEqual(x, 1)
-
+
def test_mul_subclass(self):
class subclass(tuple):
pass
-
+
u = subclass([0,1])
self.assertTrue(u is not u*1)
@@ -179,7 +179,7 @@ def test_wacky_contains(self):
class x(tuple):
def __contains__(self, other):
return retval
-
+
self.assertEqual('abc' in x(), False)
class x2(tuple):
@@ -191,10 +191,10 @@ def test_tuple_equality(self):
class x(object):
def __eq__(self, other): return False
def __ne__(self, other): return True
-
+
a = x()
self.assertEqual((a, ), (a, ))
-
+
def test_tuple_reuse(self):
t = (2,4,6)
self.assertEqual(id(t), id(tuple(t)))
@@ -206,9 +206,8 @@ def test_index_error(self):
x = ()
def delindex(): del x[42]
def setindex(): x[42] = 42
-
+
self.assertRaisesMessage(TypeError, "'tuple' object doesn't support item deletion", delindex)
self.assertRaisesMessage(TypeError, "'tuple' object does not support item assignment", setindex)
-
-run_test(__name__)
\ No newline at end of file
+run_test(__name__)
diff --git a/Tests/test_unicode_stdlib.py b/Tests/test_unicode_stdlib.py
index d150035af..b61dfa1e5 100644
--- a/Tests/test_unicode_stdlib.py
+++ b/Tests/test_unicode_stdlib.py
@@ -94,13 +94,13 @@ def load_tests(loader, standard_tests, pattern):
suite.addTest(unittest.expectedFailure(test.test_unicode.UnicodeTest('test_isprintable')))
suite.addTest(test.test_unicode.UnicodeTest('test_isspace'))
suite.addTest(unittest.expectedFailure(test.test_unicode.UnicodeTest('test_issue18183')))
- suite.addTest(test.test_unicode.UnicodeTest('test_issue28598_strsubclass_rhs'))
+ suite.addTest(unittest.expectedFailure(test.test_unicode.UnicodeTest('test_issue28598_strsubclass_rhs')))
suite.addTest(test.test_unicode.UnicodeTest('test_issue8271'))
suite.addTest(unittest.expectedFailure(test.test_unicode.UnicodeTest('test_istitle')))
suite.addTest(unittest.expectedFailure(test.test_unicode.UnicodeTest('test_isupper')))
suite.addTest(test.test_unicode.UnicodeTest('test_iterators'))
suite.addTest(unittest.expectedFailure(test.test_unicode.UnicodeTest('test_join')))
- suite.addTest(test.test_unicode.UnicodeTest('test_join_overflow'))
+ suite.addTest(unittest.expectedFailure(test.test_unicode.UnicodeTest('test_join_overflow'))) # ValueError: capacity was less than the current size.
suite.addTest(test.test_unicode.UnicodeTest('test_literals'))
suite.addTest(test.test_unicode.UnicodeTest('test_ljust'))
suite.addTest(unittest.expectedFailure(test.test_unicode.UnicodeTest('test_lower')))
@@ -122,7 +122,7 @@ def load_tests(loader, standard_tests, pattern):
suite.addTest(unittest.expectedFailure(test.test_unicode.UnicodeTest('test_rpartition')))
suite.addTest(unittest.expectedFailure(test.test_unicode.UnicodeTest('test_rsplit')))
suite.addTest(test.test_unicode.UnicodeTest('test_slice'))
- suite.addTest(unittest.expectedFailure(test.test_unicode.UnicodeTest('test_split')))
+ suite.addTest(unittest.expectedFailure(test.test_unicode.UnicodeTest('test_split'))) # https://github.com/IronLanguages/ironpython3/issues/252
suite.addTest(test.test_unicode.UnicodeTest('test_splitlines'))
suite.addTest(test.test_unicode.UnicodeTest('test_startswith'))
suite.addTest(test.test_unicode.UnicodeTest('test_startswith_endswith_errors'))
diff --git a/Tests/test_unpack.py b/Tests/test_unpack.py
index 8a6a3bda9..f1fc55a3a 100644
--- a/Tests/test_unpack.py
+++ b/Tests/test_unpack.py
@@ -22,7 +22,7 @@ def test_unpack_into_exprlist_2(self):
self.assertEqual(a, [0, 1, 2, 3])
self.assertEqual(b, 4)
self.assertEqual(c, 5)
-
+
def test_unpack_into_exprlist_3(self):
a, *b, c = range(6)
self.assertEqual(a, 0)
@@ -46,7 +46,7 @@ def test_unpack_into_exprlist_5(self):
self.assertEqual(f, [1, 2, 3])
self.assertEqual(g, 4)
self.assertEqual(h, 5)
-
+
def test_unpack_into_list_1(self):
[*a] = range(2)
self.assertEqual(a, [0, 1])
@@ -75,7 +75,7 @@ def test_unpack_into_for_target_2(self):
self.assertEqual(b, index)
self.assertEqual(a, [index])
index = index + 1
-
+
def test_unpack_into_for_target_3(self):
index = 0
expected_a = [1, 4]
@@ -120,11 +120,8 @@ def test_too_many_expressions_in_star_unpack(self):
self.assertRaisesSyntaxError(body, "too many expressions in star-unpacking assignment")
def test_assign_to_empty(self):
- if sys.version_info >= (3,6):
- exec("() = []") # TODO: remove exec once our baseline is >= 3.6
- else:
- self.assertRaisesSyntaxError('() = []', "can't assign to ()")
- [] = () # OK
+ () = [] # new in 3.6
+ [] = ()
def test_assign_trailing_comma_list_to_list(self):
[a, *b,] = [1, 2, 3]