mirror of
https://github.com/python/cpython.git
synced 2025-08-31 05:58:33 +00:00
Issue #15715: Ignore failed imports triggered by the use of fromlist.
When the fromlist argument is specified for __import__() and the attribute doesn't already exist, an import is attempted. If that fails (e.g. module doesn't exist), the ImportError will now be silenced (for backwards-compatibility). This *does not* affect ``from ... import ...`` statements. Thanks to Eric Snow for the patch and Simon Feltman for reporting the regression.
This commit is contained in:
parent
b391b24efe
commit
7385adc84c
4 changed files with 474 additions and 458 deletions
|
@ -334,6 +334,12 @@ class ImportTests(unittest.TestCase):
|
|||
del sys.path[0]
|
||||
remove_files(TESTFN)
|
||||
|
||||
def test_bogus_fromlist(self):
|
||||
try:
|
||||
__import__('http', fromlist=['blah'])
|
||||
except ImportError:
|
||||
self.fail("fromlist must allow bogus names")
|
||||
|
||||
|
||||
class PycRewritingTests(unittest.TestCase):
|
||||
# Test that the `co_filename` attribute on code objects always points
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue