Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix issues after merge #1823

Merged
merged 2 commits into from
Dec 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 7 additions & 5 deletions Src/IronPython.Modules/_operator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ namespace IronPython.Modules {
public static class PythonOperator {
public const string __doc__ = "Provides programmatic access to various operators (addition, accessing members, etc...)";

[PythonType]
public sealed class attrgetter : ICodeFormattable {
private readonly object[] _names;

Expand All @@ -40,31 +41,32 @@ public attrgetter([NotNone] params object[] attrs) {
public PythonTuple __reduce__() => PythonTuple.MakeTuple(DynamicHelpers.GetPythonType(this), PythonTuple.MakeTuple(_names));

[SpecialName]
public object Call(CodeContext context, object param) {
public object? Call(CodeContext context, object? param) {
if (_names.Length == 1) {
return GetOneAttr(context, param, _names[0]);
}

object[] res = new object[_names.Length];
object?[] res = new object[_names.Length];
for (int i = 0; i < _names.Length; i++) {
res[i] = GetOneAttr(context, param, _names[i]);
}
return PythonTuple.MakeTuple(res);
}

private static object GetOneAttr(CodeContext context, object param, object val) {
private static object? GetOneAttr(CodeContext context, object? param, object val) {
if (val is not string s) {
throw PythonOps.TypeError("attribute name must be string");
}
int dotPos = s.IndexOf('.');
if (dotPos >= 0) {
object nextParam = GetOneAttr(context, param, s.Substring(0, dotPos));
object? nextParam = GetOneAttr(context, param, s.Substring(0, dotPos));
return GetOneAttr(context, nextParam, s.Substring(dotPos + 1));
}
return PythonOps.GetBoundAttr(context, param, s);
}
}

[PythonType]
public sealed class itemgetter : ICodeFormattable {
private readonly object?[] _items;

Expand All @@ -82,7 +84,7 @@ public itemgetter([NotNone] params object?[] items) {
public PythonTuple __reduce__() => PythonTuple.MakeTuple(DynamicHelpers.GetPythonType(this), PythonTuple.MakeTuple(_items));

[SpecialName]
public object Call(CodeContext/*!*/ context, object param) {
public object? Call(CodeContext/*!*/ context, object? param) {
if (_items.Length == 1) {
return PythonOps.GetIndex(context, param, _items[0]);
}
Expand Down
3 changes: 0 additions & 3 deletions Src/IronPythonTest/Cases/CPythonCasesManifest.ini
Original file line number Diff line number Diff line change
Expand Up @@ -181,9 +181,6 @@ Ignore=true
Ignore=true
Reason=ImportError: No module named audioop

[CPython.test_base64] # IronPython.test_base64_stdlib
Ignore=true

[CPython.test_bdb] # new in 3.6
Ignore=true

Expand Down
28 changes: 0 additions & 28 deletions Tests/test_base64_stdlib.py

This file was deleted.

66 changes: 52 additions & 14 deletions Tests/test_io_stdlib.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,29 +22,20 @@ def load_tests(loader, standard_tests, pattern):
test.test_io.CIOTest('test_TextIOBase_destructor'), # AssertionError: Lists differ: [1, 2, 3, 2] != [1, 2, 3]
test.test_io.CIOTest('test_destructor'), # AssertionError: Lists differ: [2, 3, 1, 2] != [1, 2, 3]
test.test_io.CIOTest('test_flush_error_on_close'), # AssertionError: OSError not raised by close
test.test_io.CIOTest('test_garbage_collection'), # AssertionError: filter ('', ResourceWarning) did not catch any warning
test.test_io.CIOTest('test_invalid_operations'), # OSError: can't do nonzero cur-relative seeks
test.test_io.CIOTest('test_open_handles_NUL_chars'), # ValueError: Illegal characters in path.
test.test_io.PyIOTest('test_destructor'), # AssertionError: Lists differ: [2, 3, 1, 2] != [1, 2, 3]
test.test_io.PyIOTest('test_flush_error_on_close'), # AssertionError: OSError not raised by close
test.test_io.PyIOTest('test_garbage_collection'), # AssertionError: filter ('', ResourceWarning) did not catch any warning
test.test_io.PyIOTest('test_open_handles_NUL_chars'), # ValueError: Illegal characters in path.
test.test_io.CBufferedReaderTest('test_args_error'), # AssertionError: "BufferedReader" does not match "__init__() takes at most 2 arguments (4 given)"
test.test_io.CBufferedReaderTest('test_buffering'), # TypeError: BufferedReader() takes at least 0 arguments (2 given)
test.test_io.CBufferedReaderTest('test_close_error_on_close'), # AssertionError: None is not an instance of <class 'OSError'>
test.test_io.CBufferedReaderTest('test_garbage_collection'), # AssertionError: filter ('', ResourceWarning) did not catch any warning
test.test_io.CBufferedReaderTest('test_initialization'), # AssertionError: ValueError not raised by read
test.test_io.CBufferedReaderTest('test_misbehaved_io_read'), # AssertionError: OSError not raised by read
test.test_io.CBufferedReaderTest('test_nonnormalized_close_error_on_close'), # AssertionError: None is not an instance of <class 'NameError'>
test.test_io.CBufferedReaderTest('test_override_destructor'), # AssertionError: Lists differ: [1, 2, 3, 2] != [1, 2, 3]
test.test_io.CBufferedReaderTest('test_read_non_blocking'), # AssertionError: b'' is not None
test.test_io.CBufferedReaderTest('test_read_on_closed'), # AssertionError: ValueError not raised by read1
test.test_io.CBufferedReaderTest('test_readonly_attributes'), # AssertionError: AttributeError not raised
test.test_io.CBufferedReaderTest('test_uninitialized'), # AssertionError: (<class 'ValueError'>, <class 'AttributeError'>) not raised by read
test.test_io.PyBufferedReaderTest('test_nonnormalized_close_error_on_close'), # AssertionError: None is not an instance of <class 'NameError'>
test.test_io.PyBufferedReaderTest('test_read_on_closed'), # AssertionError: ValueError not raised by read1
test.test_io.CBufferedWriterTest('test_close_error_on_close'), # AssertionError: None is not an instance of <class 'OSError'>
test.test_io.CBufferedWriterTest('test_garbage_collection'), # AssertionError: filter ('', ResourceWarning) did not catch any warning
test.test_io.CBufferedWriterTest('test_initialization'), # AssertionError: ValueError not raised by write
test.test_io.CBufferedWriterTest('test_max_buffer_size_removal'), # AssertionError: TypeError not raised
test.test_io.CBufferedWriterTest('test_nonnormalized_close_error_on_close'), # AssertionError: None is not an instance of <class 'NameError'>
Expand All @@ -58,7 +49,6 @@ def load_tests(loader, standard_tests, pattern):
test.test_io.CBufferedRWPairTest('test_uninitialized'), # TypeError: BufferedRWPair() takes at least 2 arguments (0 given)
test.test_io.PyBufferedRWPairTest('test_reader_writer_close_error_on_close'), # AssertionError: None is not an instance of <class 'NameError'>
test.test_io.CBufferedRandomTest('test_close_error_on_close'), # AssertionError: None is not an instance of <class 'OSError'>
test.test_io.CBufferedRandomTest('test_garbage_collection'), # AssertionError: filter ('', ResourceWarning) did not catch any warning
test.test_io.CBufferedRandomTest('test_max_buffer_size_removal'), # AssertionError: TypeError not raised
test.test_io.CBufferedRandomTest('test_nonnormalized_close_error_on_close'), # AssertionError: None is not an instance of <class 'NameError'>
test.test_io.CBufferedRandomTest('test_read_non_blocking'), # AssertionError: b'' is not None
Expand All @@ -74,7 +64,6 @@ def load_tests(loader, standard_tests, pattern):
test.test_io.CTextIOWrapperTest('test_close_error_on_close'), # AssertionError: OSError not raised
test.test_io.CTextIOWrapperTest('test_encoded_writes'), # UnicodeEncodeError
test.test_io.CTextIOWrapperTest('test_flush_error_on_close'), # AssertionError: OSError not raised by close
test.test_io.CTextIOWrapperTest('test_garbage_collection'), # AssertionError: filter ('', ResourceWarning) did not catch any warning
test.test_io.CTextIOWrapperTest('test_initialization'), # AssertionError: ValueError not raised by read
test.test_io.CTextIOWrapperTest('test_non_text_encoding_codecs_are_rejected'), # AssertionError: LookupError not raised
test.test_io.CTextIOWrapperTest('test_nonnormalized_close_error_on_close'), # AssertionError: NameError not raised
Expand All @@ -93,25 +82,74 @@ def load_tests(loader, standard_tests, pattern):
test.test_io.CMiscIOTest('test_readinto_buffer_overflow'), # IndexError: Index was outside the bounds of the array.
test.test_io.CMiscIOTest('test_warn_on_dealloc'), # AssertionError: ResourceWarning not triggered
test.test_io.CMiscIOTest('test_warn_on_dealloc_fd'), # AssertionError: ResourceWarning not triggered
test.test_io.PyMiscIOTest('test_io_after_close'), # AttributeError: 'FileIO' object has no attribute 'read1'
test.test_io.PyMiscIOTest('test_nonblock_pipe_write_bigbuf'), # AttributeError: 'module' object has no attribute 'fcntl'
test.test_io.PyMiscIOTest('test_nonblock_pipe_write_smallbuf'), # AttributeError: 'module' object has no attribute 'fcntl'
test.test_io.PyMiscIOTest('test_pickling'), # AssertionError: TypeError not raised by _dumps
test.test_io.PyMiscIOTest('test_warn_on_dealloc'), # AssertionError: ResourceWarning not triggered
test.test_io.PyMiscIOTest('test_warn_on_dealloc_fd'), # AssertionError: ResourceWarning not triggered

# BufferError: memoryview: invalid buffer exported from object of type EmptyStruct
test.test_io.CIOTest('test_buffered_file_io'),
test.test_io.CIOTest('test_raw_bytes_io'),
test.test_io.CIOTest('test_raw_file_io'),
test.test_io.PyIOTest('test_buffered_file_io'),
test.test_io.PyIOTest('test_raw_bytes_io'),
test.test_io.PyIOTest('test_raw_file_io'),
test.test_io.CBufferedRWPairTest('test_readinto'),
test.test_io.PyBufferedRWPairTest('test_readinto'),

# TODO: these are new in 3.6
test.test_io.CIOTest('test_BufferedIOBase_readinto'),
test.test_io.CIOTest('test_buffered_readinto_mixin'),
test.test_io.CIOTest('test_next_nonsizeable'),
test.test_io.CIOTest('test_optional_abilities'),
test.test_io.PyIOTest('test_buffered_readinto_mixin'),
test.test_io.PyIOTest('test_optional_abilities'),
test.test_io.APIMismatchTest('test_RawIOBase_io_in_pyio_match'),
test.test_io.APIMismatchTest('test_RawIOBase_pyio_in_io_match'),
test.test_io.CBufferedReaderTest('test_readinto1'),
test.test_io.CBufferedReaderTest('test_readinto1_array'),
test.test_io.CBufferedReaderTest('test_readinto_array'),
test.test_io.CBufferedRandomTest('test_readinto1'),
test.test_io.CBufferedRandomTest('test_readinto1_array'),
test.test_io.CBufferedRandomTest('test_readinto_array'),
test.test_io.CTextIOWrapperTest('test_illegal_encoder'),
test.test_io.CTextIOWrapperTest('test_issue25862'),
test.test_io.CTextIOWrapperTest('test_read_byteslike'),
test.test_io.PyTextIOWrapperTest('test_illegal_encoder'),
test.test_io.PyTextIOWrapperTest('test_read_byteslike'),
]

if is_mono:
failing_tests += [
test.test_io.CBufferedRandomTest('test_destructor'), # IndexError: index out of range: 0
test.test_io.PyMiscIOTest('test_create_fail'),
]

skip_tests = [
test.test_io.CBufferedReaderTest('test_override_destructor'), # StackOverflowException
test.test_io.CBufferedWriterTest('test_override_destructor'), # StackOverflowException
test.test_io.CBufferedRandomTest('test_override_destructor'), # StackOverflowException
test.test_io.CTextIOWrapperTest('test_bufio_write_through'), # StackOverflowException
test.test_io.CTextIOWrapperTest('test_override_destructor'), # StackOverflowException

# failure prevents files from closing
test.test_io.CIOTest('test_garbage_collection'), # AssertionError: filter ('', ResourceWarning) did not catch any warning
test.test_io.PyIOTest('test_garbage_collection'), # AssertionError: filter ('', ResourceWarning) did not catch any warning
test.test_io.CBufferedReaderTest('test_garbage_collection'), # AssertionError: filter ('', ResourceWarning) did not catch any warning
test.test_io.CBufferedWriterTest('test_garbage_collection'), # AssertionError: filter ('', ResourceWarning) did not catch any warning
test.test_io.CBufferedRandomTest('test_garbage_collection'), # AssertionError: filter ('', ResourceWarning) did not catch any warning
test.test_io.CTextIOWrapperTest('test_garbage_collection'), # AssertionError: filter ('', ResourceWarning) did not catch any warning
test.test_io.PyIOTest('test_destructor'), # AssertionError: Lists differ: [2, 3, 1, 2] != [1, 2, 3]

# StackOverflowException
test.test_io.CBufferedReaderTest('test_recursive_repr'),
test.test_io.PyBufferedReaderTest('test_recursive_repr'),
test.test_io.CBufferedWriterTest('test_recursive_repr'),
test.test_io.PyBufferedWriterTest('test_recursive_repr'),
test.test_io.CBufferedRandomTest('test_recursive_repr'),
test.test_io.PyBufferedRandomTest('test_recursive_repr'),
test.test_io.CTextIOWrapperTest('test_recursive_repr'),
test.test_io.PyTextIOWrapperTest('test_recursive_repr'),

# __del__ not getting called on shutdown?
test.test_io.CTextIOWrapperTest('test_create_at_shutdown_with_encoding'),
test.test_io.CTextIOWrapperTest('test_create_at_shutdown_without_encoding'),
Expand Down
Loading