bpo-11063: Fix _uuid module on macOS#3855
bpo-11063: Fix _uuid module on macOS#3855vstinner merged 1 commit intopython:masterfrom vstinner:uuid_macos
Conversation
|
I tested this PR manually on macOS Sierra: test_uuid pass, and is_safe attribute is unknown as expected. Note: I hacked _netstat_getnode() in Lib/uuid.py to add "-n" option to make tests faster, to prevent slow DNS resolution. |
Modules/_uuidmodule.c
Outdated
There was a problem hiding this comment.
I'd prefer if you'd return the (out, None) tuple here.
There was a problem hiding this comment.
I prefer to have very thin wrapper for C functions, and handle differences at the Python level.
There was a problem hiding this comment.
IMO it only makes both the Python code and the C code more complicated.
There was a problem hiding this comment.
One of the annoyances with modifying uuid.py is that there are so different code paths to take care of.
Modules/_uuidmodule.c
Outdated
There was a problem hiding this comment.
There's no need to expose two different function names, IMO.
There was a problem hiding this comment.
There's no need to expose two different function names, IMO.
It's not the same API:
- _uuid.generate_time_safe() returns (uuid, is_safe).
- _uuid.generate_time() only returns the uuid
There was a problem hiding this comment.
I'm proposing that it's the same API (see above) :-)
|
I simplified my PR to not add a new function with a different name in _uuid. Instead, I modified uuid.py to decide if we have or not uuid_generate_time_safe() using sys.platform. |
|
Instead of checking sys.platform, maybe we could have a constant in _uuid? |
|
Yes, I think it's better to put this in |
On macOS, use uuid_generate_time() instead of uuid_generate_time_safe() of libuuid, since uuid_generate_time_safe() is not available.
Ok, done. I added _uuid.has_uuid_generate_time_safe (int: 1 or 0). |
|
Thank you! :-) |
|
I'd rather see a configure check for the existence of |
|
@warsaw: "I'd rather see a configure check for ..." Please, go ahead and write it :-) I began to look at AC_CHECK_HEADER() but I don't see how to pass /usr/include/uuid/ to ask to test also this directory. Then I wanted to use pkg-config, but @pitrou showed me that it doesn't exist on macOS. In short, modifying the autotools are out of my skills. I proposed a pragmatic solution to fix the _uuid module on macOS. |
|
I agree with @warsaw. This should be a configure check. |
On macOS, use uuid_generate_time() instead of
uuid_generate_time_safe() of libuuid, since uuid_generate_time_safe()
is not available.
https://bugs.python.org/issue11063