Issue1471925
Created on 2006年04月17日 19:49 by ronaldoussoren, last changed 2022年04月11日 14:56 by admin. This issue is now closed.
| Messages (8) |
|
msg50048 - (view) |
Author: Ronald Oussoren (ronaldoussoren) * (Python committer) |
Date: 2006年04月17日 19:49 |
The "itch" that is scratched by this patch is the wish to be able to use a
python binary that was build on OSX 10.4 on OSX 10.3 systems. At the
same time the binary should offer full access to OSX 10.4 API's when
running on that system.
This patch weakly links a number of functions in the posix, time and
socket modules.
I'm not quite happy with code duplication in the time and socket modules,
but don't quite know how to fix that.
|
|
msg50049 - (view) |
Author: Ronald Oussoren (ronaldoussoren) * (Python committer) |
Date: 2006年04月17日 19:50 |
Logged In: YES
user_id=580910
I should not that I haven't checked this patch on other platforms than osx 10.4/
intel.
|
|
msg50050 - (view) |
Author: Martin v. Löwis (loewis) * (Python committer) |
Date: 2006年04月17日 22:18 |
Logged In: YES
user_id=21627
The patch looks fine to me. I wonder why you are clearing
the errors from PyObject_DelAttrString, though: There
shouldn't be any errors (right?), so if that fails,
something is seriously wrong.
As for the time changes: are you saying OSX doesn't have
gettimeofday? I can find a manual page on
http://developer.apple.com/documentation/Darwin/Reference/ManPages/man2/gettimeofday.2.html
This has higher resolution than ftime, and also takes higher
precedence in timemodule.c: Why is it not used?
|
|
msg50051 - (view) |
Author: Ronald Oussoren (ronaldoussoren) * (Python committer) |
Date: 2006年04月18日 19:27 |
Logged In: YES
user_id=580910
Good points. I was clearing errors because it seemed better to ignore errors.
But you're right, if this does fail somethings is seriously wrong. I've replaced
error-checking by return statements (but have not replaced the patch).
The change to time is interesting, I added those changes because the binary
wouldn't run without the patch, without realizing that configure/timemodule
is picking up the wrong function for finding the current time. That seems to
be caused by a bug in the preprocessor code that selects the right section of
code. OSX 10.4 has both gettimeofday and ftime, and with the current set of
#if statements this means both the gettimeofday and ftime blocks get
compiled in. The ftime-bit is dead code, but present nonetheless.
I tried to rearange the #if-statements to make sure just one block gets
included, but then get compiler warnings because floattime checks for an
error-return of gettimeofday. IMHO the error-return check is rather lame,
the only reason this could fail is when the first argument of gettimeofday is
invalid (and SUS says this function will always return 0, although manpage on
darwin and linux claim otherwise), And time(2) can also return -1 to indicate
failure ;-)
If uploaded a new patch (version 2) that removes error clearing for the DelAttr
calls in posixmodule and chickens out on the ftime issue by #undef-ing
HAVE_FTIME for OSX systems that HAVE_GETTIMEOFDAY.
SUS: http://www.opengroup.org/onlinepubs/007908799/xsh/
gettimeofday.html
|
|
msg50052 - (view) |
Author: Ronald Oussoren (ronaldoussoren) * (Python committer) |
Date: 2006年04月18日 19:29 |
Logged In: YES
user_id=580910
Version 3 solves the ftime issue the other (IMO more correct) way: it ignores the
returnvalue of gettimeofday and conditionalizes the floattime code in such way
that either gettimeofday or ftime is used, but never both.
|
|
msg50053 - (view) |
Author: Martin v. Löwis (loewis) * (Python committer) |
Date: 2006年04月20日 20:44 |
Logged In: YES
user_id=21627
The patch is fine(*). Please do add a comment to the time
implementation to elaborate on the story of return values,
and why falling back should not be done (it ought not be
necessary, on systems where it is necessary, it might not
help, and it will hurt the OSX port).
One more bit on return values: gettimeofday can indeed fail
on Linux, and also when there is a TZ problem. OTOH, ftime
is implemented on top of gettimeofday (sic), and will then
fail for the same reason. I haven't looked at the time
implementation.
If you want to be really cautious, you could return 0.0 in
case the functions fail. The only caller of floattime will
then raise an IOError.
|
|
msg50054 - (view) |
Author: Ronald Oussoren (ronaldoussoren) * (Python committer) |
Date: 2006年04月20日 20:54 |
Logged In: YES
user_id=580910
Thanks for the review. I will apply this patch this weekend, including the
additional documentation in the time module.
|
|
msg50055 - (view) |
Author: Ronald Oussoren (ronaldoussoren) * (Python committer) |
Date: 2006年04月23日 11:59 |
Logged In: YES
user_id=580910
I've checked in weaklinking-2.patch with a better comment. This is the version
that #undefs HAVE_FTIME on OSX. I've checked in this version instead of the
newer one because a comment in floattime claims that gettimeofday does
actually fail on some platforms.
Checked in as revision 45660
|
|
History
|
|---|
| Date |
User |
Action |
Args |
| 2022年04月11日 14:56:16 | admin | set | github: 43230 |
| 2006年04月17日 19:49:03 | ronaldoussoren | create |