Author jaraco
Recipients FFY00, barry, brett.cannon, jaraco
Date 2021-02-14.18:01:23
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <>
For the first two errors, the issue seems to be that CPython includes tests for the ResourceReader ABC and asserts that .contents() returns an empty list as the default degenerate behavior ( It appears that the ABC in importlib_resources has for a [very long time raised FileNotFound](

Oh, this is interesting - these ABCs have diverged since their inception; here's where [both the empty list behavior and test were introduced in cpython]( and [later amended to return an iterable instead of iterator](

Brett, is this a divergence worth maintaining? Do you recall if there was a reason for changing the ABC during the port to CPython? There's no mention of 'contents' in issue32248.

My temptation is to go with the implementation as found in importlib_resources as it presents a more consistent interface for ResourceReaders (and explicitly defaults to raising FileNotFoundError when no implementation for contents is present) and thus to change the test to:

cpython master $ git diff Lib/test/test_importlib/
diff --git a/Lib/test/test_importlib/ b/Lib/test/test_importlib/
index d8b9fc89f2..d1c89c183b 100644
--- a/Lib/test/test_importlib/
+++ b/Lib/test/test_importlib/
@@ -338,7 +338,9 @@ def test_is_resource(self):
     def test_contents(self):
-        self.assertEqual([], list(self.ins.contents()))
+        with self.assertRaises(FileNotFoundError):
+            self.ins.contents()

Brett, let me know if you have concern about harmonizing the two implementations around this behavior and if you have a strong preference for harmonizing toward the CPython implementation instead. Thanks.
Date User Action Args
2021-02-14 18:01:24jaracosetrecipients: + jaraco, barry, brett.cannon, FFY00
2021-02-14 18:01:24jaracosetmessageid: <>
2021-02-14 18:01:24jaracolinkissue42129 messages
2021-02-14 18:01:23jaracocreate