D2939: fsmonitor: layer on another hack in bser.c for os.stat() compat (issue5811)

durin42 (Augie Fackler) phabricator at mercurial-scm.org
Mon Mar 26 15:19:29 EDT 2018


durin42 added inline comments.

INLINE COMMENTS

> spectral wrote in bser.c:106
> My system pythons (2.7.13 and 3.5.3) have the following behaviors:
> 
> ≻ python -c 'from __future__ import print_function; import os, sys, stat; print(sys.version); s=os.stat("."); print(s.st_mtime, s[stat.ST_MTIME], type(s.st_mtime), type(s[stat.ST_MTIME]), stat.ST_MTIME)'
> 2.7.13 (default, Nov 24 2017, 17:33:09) 
> [GCC 6.3.0 20170516]
> 1522089418.2 1522089418 <type 'float'> <type 'int'> 8
> 
> ≻ python3 -c 'from __future__ import print_function; import os, sys, stat; print(sys.version); s=os.stat("."); print(s.st_mtime, s[stat.ST_MTIME], type(s.st_mtime), type(s[stat.ST_MTIME]), stat.ST_MTIME)' 
> 3.5.3 (default, Jan 19 2017, 14:11:04) 
> [GCC 6.3.0 20170118]
> 1522089422.693618 1522089422 <class 'float'> <class 'int'> 8
> 
> Seems like we could just use int(os.stat().st_mtime) instead of os.stat()[stat.ST_MTIME]  (if we really need an int instead of a float), and avoid most of the issues with attempting to access a stat_result that isn't the official one (like the one we create in cext/osutil.c, or I know other extensions create...)
> 
> I have no idea if that would solve this actual problem though, bser might be a separate problem from what I'm thinking of.

We used to do int(...st_mtime) and had to stop because of rounding issues: https://bz.mercurial-scm.org/show_bug.cgi?id=4836

REPOSITORY
  rHG Mercurial

REVISION DETAIL
  https://phab.mercurial-scm.org/D2939

To: durin42, #hg-reviewers, indygreg
Cc: spectral, indygreg, mercurial-devel


More information about the Mercurial-devel mailing list