This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author chris.jerdonek
Recipients Arfrever, Guido.van.Rossum, asvetlov, barry, brett.cannon, chris.jerdonek, cvrebert, cwg, eric.snow, ezio.melotti, gvanrossum, jcea, pitrou, python-dev, serhiy.storchaka, theller
Date 2018-02-27.11:27:27
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <>
Eric touched on the use when he said the following above:

> It's nice to be able to distinguish between the failure to *find* the module during import from other uses of ImportError.

To make up one example, you might want to use a fallback module if a package isn't installed:

        from fancy_parser import NewParser as HTMLParser
    except ModuleNotFoundError:
        from html.parser import HTMLParser

But you might still want an error if the package is installed, though incorrectly (e.g. fancy_parser is installed, but an old version that doesn't have NewParser). Catching ImportError would swallow this error, whereas ModuleNotFoundError would let it bubble up.
Date User Action Args
2018-02-27 11:27:27chris.jerdoneksetrecipients: + chris.jerdonek, gvanrossum, barry, brett.cannon, theller, jcea, pitrou, ezio.melotti, Arfrever, cvrebert, asvetlov, python-dev, eric.snow, serhiy.storchaka, Guido.van.Rossum, cwg
2018-02-27 11:27:27chris.jerdoneksetmessageid: <>
2018-02-27 11:27:27chris.jerdoneklinkissue15767 messages
2018-02-27 11:27:27chris.jerdonekcreate