X-Recipient: archive-cygwin@delorie.com
DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id
	:list-unsubscribe:list-subscribe:list-archive:list-post
	:list-help:sender:to:from:subject:message-id:date:mime-version
	:content-type:content-transfer-encoding; q=dns; s=default; b=m/1
	XETcPcuSUdcjXzmNuxYyLsUPTutbfhbcjhXyuoKlkYQI8/ABHLiETAWjRqHsgQB1
	wcfXSCrd3ZmFpj3tL8R3N/8qTbRGvGdwEF1dZ1Tacx4o3BNenXukggkpd9O5ZJmL
	FcSxJ24T/wsavJV8hDZzMa/a9Z9M0CEyK2/8NqfI=
DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id
	:list-unsubscribe:list-subscribe:list-archive:list-post
	:list-help:sender:to:from:subject:message-id:date:mime-version
	:content-type:content-transfer-encoding; s=default; bh=j9ADRo/Va
	7x5YMXPDDg9JxBaREU=; b=eybz4HIVcKTAjf8De8uNAXnKTeo4SsclcNH92M9XD
	YvHQkZECYgva2eqgN9vn1qf6VIV2WWAS1ImupC6db1HCbsR7WPv/eQOjRb8qHieN
	H8S63ZNJ9ZsBWcaZ9lFxzOr//fqK2tmRIv0JxEvviPJpPmFUeCKeV6lcxR+hoTz/
	FU=
Mailing-List: contact cygwin-help@cygwin.com; run by ezmlm
List-Id: <cygwin.cygwin.com>
List-Subscribe: <mailto:cygwin-subscribe@cygwin.com>
List-Archive: <http://sourceware.org/ml/cygwin/>
List-Post: <mailto:cygwin@cygwin.com>
List-Help: <mailto:cygwin-help@cygwin.com>, <http://sourceware.org/ml/#faqs>
Sender: cygwin-owner@cygwin.com
Mail-Followup-To: cygwin@cygwin.com
Delivered-To: mailing list cygwin@cygwin.com
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
X-Sender-Id: wwwh|x-authuser|mitch@houseofpain.org
X-Sender-Id: wwwh|x-authuser|mitch@houseofpain.org
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
To: cygwin@cygwin.com
From: Mitch Deoudes <mitch@houseofpain.org>
Subject: cygwin python os.stat gives wrong ctime
Message-ID: <574A486B.6000506@houseofpain.org>
Date: Sat, 28 May 2016 21:39:55 -0400
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

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" <file>'), 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

