◐ Shell
clean mode source ↗

Issue 39203: python3 time module misses attributes in Mac installers

The issue: AttributeError: module 'time' has no attribute 'clock_gettime'. It probably missed other attributes as well.

The problem only appeared with using installers to install python. While Homebrew installed python does not have the issue.

The issue occurred in versions, 3.7.1, 3.7.3, 3.7.4, 3.8.1, as I observed.
This is a duplicate of Issue34597.

The Pythons provided by the python.org macOS installers are built to run on a range of operating system versions.  The current practice is to build installers that work on any macOS version from 10.9 on.  To safely provide that functionality, the installers are built using a 10.9 ABI.  As noted in the time module documentation, "Although this module is always available, not all functions are available on all platforms."  And, as noted in

   man 3 clock_gettime 

For current macOS releases: "These functions first appeared in Mac OSX 10.12".

So since those functions are not available in macOS 10.9, they are not available in the current python.org macOS Pythons.  There are some other examples of this.

To remove this restriction and still allow builds that support a range of versions, we would need to identify the system interfaces that have been added in new releases and then add code to use weak linking to test at runtime to gracefully handle missing interfaces, rather than segfaulting.  It would be desirable to support that but it's a fair amount of work including adding tests and no one has volunteered to do that work - yet.