
Hi Steven
On 10/04/2018 12:32 AM, Steven D'Aprano wrote:
On Wed, Oct 03, 2018 at 10:29:45PM +0200, Marcus Harnisch wrote:
When trying to import lzma on one of my machines, I was suprised to get a normal import error like for any other module. According to the docs lzma has been part of stdlib since 3.3. Further digging revealed that the error is due to the fact that xz wasn't compiled in when building Python. Since I suspect that there are other optional stdlib modules, this made me think whether the message in those cases should look a little more polished. Perhaps installing a stub module that prints some informative text before raising the relevant exception or similar.
This sounds to me like something that the various Python distributors could do, e.g. Activestate, the Linux distros, etc. Especially since they're the ones compiling Python, they can control whether or not XY is supplied or not.
I'd argue that it is Python that creates the dependency and is therefore responsible to handle this gracefully. But, I guess having this documented first is the most important step before discussing further measures.
Also, maybe add a little note in the docs, stating that despite being part of stdlib this module might not be available on all systems.
That should be uncontroversial. Raise an issue on the bug tracker for that, or a patch on Github.
Done. https://bugs.python.org/issue34895
Thanks, Marcus