From: <pj...@us...> - 2009-06-04 02:50:55
|
Revision: 6446 http://jython.svn.sourceforge.net/jython/?rev=6446&view=rev Author: pjenvey Date: 2009-06-04 02:50:50 +0000 (Thu, 04 Jun 2009) Log Message: ----------- workaround lack of os.fstat Modified Paths: -------------- trunk/jython/Lib/SimpleHTTPServer.py trunk/jython/Lib/posixpath.py trunk/jython/Lib/tarfile.py trunk/jython/Lib/test/test_largefile.py Modified: trunk/jython/Lib/SimpleHTTPServer.py =================================================================== --- trunk/jython/Lib/SimpleHTTPServer.py 2009-06-04 02:38:34 UTC (rev 6445) +++ trunk/jython/Lib/SimpleHTTPServer.py 2009-06-04 02:50:50 UTC (rev 6446) @@ -91,7 +91,7 @@ return None self.send_response(200) self.send_header("Content-type", ctype) - fs = os.fstat(f.fileno()) + fs = os.fstat(f.fileno()) if hasattr(os, 'fstat') else os.stat(path) self.send_header("Content-Length", str(fs[6])) self.send_header("Last-Modified", self.date_time_string(fs.st_mtime)) self.end_headers() Modified: trunk/jython/Lib/posixpath.py =================================================================== --- trunk/jython/Lib/posixpath.py 2009-06-04 02:38:34 UTC (rev 6445) +++ trunk/jython/Lib/posixpath.py 2009-06-04 02:50:50 UTC (rev 6446) @@ -230,8 +230,8 @@ return samestat(s1, s2) -# XXX: Plain Jython lacks fstat and st_ino/st_dev -if os.name != 'java': +# XXX: Jython currently lacks fstat +if hasattr(os, 'fstat'): # Are two open files really referencing the same file? # (Not necessarily the same file descriptor!) @@ -244,6 +244,7 @@ __all__.append("sameopenfile") +# XXX: Pure Java stat lacks st_ino/st_dev if os._native_posix: # Are two stat buffers (obtained from stat, fstat or lstat) # describing the same file? Modified: trunk/jython/Lib/tarfile.py =================================================================== --- trunk/jython/Lib/tarfile.py 2009-06-04 02:38:34 UTC (rev 6445) +++ trunk/jython/Lib/tarfile.py 2009-06-04 02:50:50 UTC (rev 6446) @@ -1336,8 +1336,11 @@ statres = os.lstat(name) else: statres = os.stat(name) + elif hasattr(os, 'fstat'): + statres = os.fstat(fileobj.fileno()) else: - statres = os.fstat(fileobj.fileno()) + raise NotImplementedError('fileobj argument not supported on this ' + 'platform (no os.fstat)') linkname = "" stmd = statres.st_mode Modified: trunk/jython/Lib/test/test_largefile.py =================================================================== --- trunk/jython/Lib/test/test_largefile.py 2009-06-04 02:38:34 UTC (rev 6445) +++ trunk/jython/Lib/test/test_largefile.py 2009-06-04 02:50:50 UTC (rev 6446) @@ -75,7 +75,7 @@ f.seek(size) f.write('a') f.flush() - if not test_support.is_jython: + if hasattr(os, 'fstat'): if test_support.verbose: print 'check file size with os.fstat' expect(os.fstat(f.fileno())[stat.ST_SIZE], size+1) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |