From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 5414 invoked by alias); 23 Jan 2012 18:41:09 -0000 Received: (qmail 5404 invoked by uid 22791); 23 Jan 2012 18:41:08 -0000 X-SWARE-Spam-Status: No, hits=-6.8 required=5.0 tests=AWL,BAYES_00,RCVD_IN_DNSWL_HI,SPF_HELO_PASS,TW_SF,T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Mon, 23 Jan 2012 18:40:51 +0000 Received: from int-mx02.intmail.prod.int.phx2.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id q0NIeTxp026514 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Mon, 23 Jan 2012 13:40:29 -0500 Received: from [127.0.0.1] (ovpn01.gateway.prod.ext.phx2.redhat.com [10.5.9.1]) by int-mx02.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id q0NIeSFe009747; Mon, 23 Jan 2012 13:40:28 -0500 Message-ID: <4F1DA99C.8030607@redhat.com> Date: Mon, 23 Jan 2012 19:57:00 -0000 From: Pedro Alves User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:9.0) Gecko/20111222 Thunderbird/9.0 MIME-Version: 1.0 To: Jan Kratochvil CC: Joel Brobecker , gdb-patches@sourceware.org Subject: Re: [patch] Do not open Python scripts twice #2 [Re: [RFC] Crash sourcing Python script on Windows] References: <1317251996-12146-1-git-send-email-brobecker@adacore.com> <20120123181125.GA26683@host2.jankratochvil.net> In-Reply-To: <20120123181125.GA26683@host2.jankratochvil.net> Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org X-SW-Source: 2012-01/txt/msg00791.txt.bz2 Does anyone know if there's a way to create a PyFile from an open Windows file HANDLE (that is, an hypothetical PyFile_from_HANDLE function)? If there is, we could do something like: static PyObject * PyFile_from_FILE (FILE *file, const char *filename, char *mode) { #ifdef _WIN32 HANDLE h = _get_osfhandle (fileno (file)); return PyFile_from_HANDLE (h, ...); #else return PyFile_FromFile(file, filename, mode, ...); } Unlike libc objects, HANDLEs are common to all loaded libcs, given that they live in the common Win32/NT layer beneath libc, so that would work around the multiple libc's problem, and, would plug the race on Windows too. _get_osfhandle: http://msdn.microsoft.com/en-us/library/ks2530z6.aspx -- Pedro Alves