From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 84095 invoked by alias); 29 May 2016 01:40:54 -0000 Mailing-List: contact cygwin-help@cygwin.com; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner@cygwin.com Mail-Followup-To: cygwin@cygwin.com Received: (qmail 84071 invoked by uid 89); 29 May 2016 01:40:52 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=3.2 required=5.0 tests=AWL,BAYES_50,KAM_LAZY_DOMAIN_SECURITY,SPF_HELO_PASS autolearn=no version=3.3.2 spammy=H*RU:sk:relay.m, Hx-spam-relays-external:sk:relay.m, Birth, HX-HELO:sk:relay.m X-HELO: relay.mailchannels.net Received: from sienna.cherry.relay.mailchannels.net (HELO relay.mailchannels.net) (23.83.223.165) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-GCM-SHA384 encrypted) ESMTPS; Sun, 29 May 2016 01:40:42 +0000 X-Sender-Id: wwwh|x-authuser|mitch@houseofpain.org Received: from relay.mailchannels.net (localhost [127.0.0.1]) by relay.mailchannels.net (Postfix) with ESMTP id 1F31E2074A for ; Sun, 29 May 2016 01:40:33 +0000 (UTC) Received: from uscentral400.accountservergroup.com (ip-10-21-3-36.us-west-2.compute.internal [10.21.3.36]) by relay.mailchannels.net (Postfix) with ESMTPA id CA26520315 for ; Sun, 29 May 2016 01:40:31 +0000 (UTC) X-Sender-Id: wwwh|x-authuser|mitch@houseofpain.org Received: from uscentral400.accountservergroup.com (uscentral400.accountservergroup.com [10.21.150.52]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384) by 0.0.0.0:2500 (trex/5.6.13); Sun, 29 May 2016 01:40:32 +0000 X-MC-Relay: Neutral X-MailChannels-SenderId: wwwh|x-authuser|mitch@houseofpain.org X-MailChannels-Auth-Id: wwwh X-MC-Loop-Signature: 1464486031997:972054104 X-MC-Ingress-Time: 1464486031996 Received: from ool-4576015e.dyn.optonline.net ([69.118.1.94]:8576 helo=[127.0.0.1]) by uscentral400.accountservergroup.com with esmtpsa (TLSv1.2:ECDHE-RSA-AES128-GCM-SHA256:128) (Exim 4.87) (envelope-from ) id 1b6piR-0001q9-2b for cygwin@cygwin.com; Sat, 28 May 2016 21:40:31 -0400 To: cygwin@cygwin.com From: Mitch Deoudes Subject: cygwin python os.stat gives wrong ctime Message-ID: <574A486B.6000506@houseofpain.org> Date: Sun, 29 May 2016 10:14:00 -0000 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:38.0) Gecko/20100101 Thunderbird/38.4.0 MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit X-AuthUser: mitch@houseofpain.org X-SW-Source: 2016-05/txt/msg00369.txt.bz2 According to the python docs, os.stat() gives the following for st_ctime: "|st_ctime| - platform dependent; time of most recent metadata change on Unix, or the time of creation on Windows" To reproduce: 1) touch foo 2) wait a minute 3) touch foo 4) use python's os.stat() on the file foo cygwin's python 2.7.10 gives (me) the same number for mtime, ctime, and atime: posix.stat_result(st_mode=33276, st_ino=40532396646393057, st_dev=1079873317, st_nlink=1, st_uid=1001, st_gid=513, st_size=0, st_atime=1464482278, st_mtime=1464482278, st_ctime=1464482278) However, cygwin's built-in stat command gives (correctly) the addtional "birth time", which is different: Access: 2016-05-28 20:37:58.748977000 -0400 Modify: 2016-05-28 20:37:58.748977000 -0400 Change: 2016-05-28 20:37:58.748977000 -0400 Birth: 2016-05-28 20:36:34.514159100 -0400 The non-cygwin version of Windows python from python.org (v2.7.11) behaves correctly as per spec: nt.stat_result(st_mode=33206, st_ino=0L, st_dev=0L, st_nlink=0, st_uid=0, st_gid=0, st_size=0L, st_atime=1464482278L, st_mtime=1464482278L, st_ctime=1464482194L) Am I missing something, or is this a bug in cygwin's python? You could argue that ctime is properly "change" and not "birth", but that's not what the python spec says it should be on Windows. More importantly, is there some other way of getting the "birth" time from within cygwin's python? I'm currently calling out to the cygwin shell using os.popen('stat "%W" '), but that's not particularly efficient, and it doesn't give subsecond precision. mitch -- Problem reports: http://cygwin.com/problems.html FAQ: http://cygwin.com/faq/ Documentation: http://cygwin.com/docs.html Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple