From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 99203 invoked by alias); 2 Dec 2015 15:31:57 -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 99194 invoked by uid 89); 2 Dec 2015 15:31:56 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.6 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_LOW,SPF_PASS autolearn=ham version=3.3.2 X-HELO: mail-wm0-f44.google.com Received: from mail-wm0-f44.google.com (HELO mail-wm0-f44.google.com) (74.125.82.44) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-GCM-SHA256 encrypted) ESMTPS; Wed, 02 Dec 2015 15:31:54 +0000 Received: by wmec201 with SMTP id c201so258910315wme.0 for ; Wed, 02 Dec 2015 07:31:51 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:date:from:to:subject:message-id:references :mime-version:content-type:content-disposition:in-reply-to :user-agent; bh=TQIKldf+EDZLoava1OW8FmYU3KmmdkyCS4Wov0CWSaE=; b=QOEaGgF+hJDZ4FxVyXFD/foOoqr5tr/s/Yehe9QDQoiLV8+DxyfAckwkVugfgITWTM UhxdmqR77sH20tGeQP5rlXahHde77cRM7h0HsD/tpk8E4G3CVNLG1msCDO2zyYrLtSAu WuijmG8NDOd5A2zs2UjoBb0/KeVbTa59XS3uvM5Xoy2UBjL88OjIiQxtIqlHD5Isa6KV k1waWE3XcebWADZma6F6lr1OZ9VDQAHC1z6K8KxHlLIq400EvKg+ccC1WJeW3RRsJQ/K ziOHYVDGOE0qDBO+/bpZW9LEN3k/PMyA1xI4KyqyGEohAzmW6K7HRiDGU1amAd3FKIwL kcwg== X-Gm-Message-State: ALoCoQnnqkDy1Yp+t2gBgLBkCUKaNn+l9cxWirTNLXQxUCGf98uieWVoJUxvh0JHqKsegPPa4g21 X-Received: by 10.194.24.226 with SMTP id x2mr5485047wjf.43.1449070311349; Wed, 02 Dec 2015 07:31:51 -0800 (PST) Received: from dinwoodie.org ([2001:ba8:0:1c0::9:1]) by smtp.gmail.com with ESMTPSA id q77sm3670914wmd.22.2015.12.02.07.31.50 for (version=TLS1_2 cipher=AES128-SHA bits=128/128); Wed, 02 Dec 2015 07:31:50 -0800 (PST) Date: Wed, 02 Dec 2015 15:31:00 -0000 From: Adam Dinwoodie To: cygwin@cygwin.com Subject: Re: Incorrect Python errors when using os.remove to delete a directory Message-ID: <20151202153148.GJ14466@dinwoodie.org> References: <20151127145105.GG14466@dinwoodie.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.21 (2010-09-15) X-IsSubscribed: yes X-SW-Source: 2015-12/txt/msg00020.txt.bz2 On Fri, Nov 27, 2015 at 04:09:52PM +0100, Michael Wild wrote: > On Fri, Nov 27, 2015 at 3:51 PM, Adam Dinwoodie wrote: > > If I use os.remove in Python to remove a directory, I expect it to fail > > with an OSError on Python2 or a IsADirectoryError on Python3. On > > Python2, I get OSError, but with the wrong error code, whereas on > > Python3 I get completely the wrong exception. > > This is a bug in Python itself, and not Cygwin specific. At least I > get the same behavior with my Anaconda installation. So, having dug a bit more, the problem here is that Python is calling unlink, which is setting errno to EPERM. On Linux systems, it's set to EISDIR instead, but Cygwin's unlink conforms to POSIX[0], and the POSIX standard specifies the errno in this case should be EPERM.[1] So, depending on your perspective, the bug is either (a) that Cygwin conforms to POSIX and not some other standard, (b) that Python3 doesn't correctly distinguish between the different reasons a POSIX-compliant "unlink" might return EPERM, or (c) there is no bug, and per [1] the calling code should handle both exceptions ("Applications written for portability to both POSIX.1-2008 and the LSB should be prepared to handle either error code."). I think claiming (a) is not going to achieve much, and distinguishing between (b) and (c) is something to take upstream to the Python mailing lists or similar. [0]: https://cygwin.com/cygwin-api/compatibility.html#std-susv4 [1]: http://pubs.opengroup.org/onlinepubs/9699919799/functions/unlink.html -- 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