New submission from John S. Gruber <johnsgru...@gmail.com>:

In researching a bug I was surprised that a newly created file was being 
replaced when being processed a second time (it shouldn't have been processed a 
second time). 

I tracked the surprise to diff Lib/distutils/dep_util.py @ 57642:9211a5d7d0b4 
where a comparison with a resolution of 1 second was replaced by a floating 
point comparison, though the new file was copied by file_util.py which tried to 
preserve the time using a method accurate to only 1 second (truncating the 
fraction). Since a new file with a truncated modification time looks older than 
an older file with a full precision stamp the problem resulted.

(For convenience--stat.st_mtime is floating point, stat[ST_MTIME] is integer 
seconds unless os.stat_float_times has been called to change the floating point 
behavior.

Using all floating point doesn't resolve the issue as OS timestamped files can 
have more resolution than python floating point may hold, again causing 
truncation and confusion. For reference see Python issue 10148.

In my humble opinion time setting and comparison should all be done 
consistently, and, if sub-second comparisons are desired, some fuzz should be 
used such that the comparison makes sense for the platform with the least 
amount of precision available with its floating point implementation.

I briefly looked at branches other than 2.7 and they don't seem to have the 
above change.

Probably of minor importance in most cases.

Thanks all for the good work, all. I've been learning python and I love it!

----------
assignee: tarek
components: Distutils
messages: 134526
nosy: eric.araujo, jsjgruber, tarek
priority: normal
severity: normal
status: open
title: newer() function in dep_util.py mixes up new vs. old files due 
stat.st_mtime vs stat[ST_MTIME]
type: behavior
versions: Python 2.7

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue11933>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to