X-Recipient: archive-cygwin AT delorie DOT 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:date:from:to:subject:message-id:references :mime-version:content-type:in-reply-to; q=dns; s=default; b=R6Y3 /jvuAzsXF/XkvLvEQMFksHhCk/hQiUowbYPZRjPBxN4TdJ/VKVchPrdGNry79ntd Tn2LLjBOz5KHkudcxVEdOi+PHWdqs57bcz7N6QVsVy7G6kiW4itbTZjWvnJ+HjTj MVJtLFOv2LkKPkvoUShuGS1tarPqAsO+JcyjdMk= 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:date:from:to:subject:message-id:references :mime-version:content-type:in-reply-to; s=default; bh=kx+NsELBE4 5EDADh9tjT6WvdUnU=; b=mWtPVBJ1f6HEduxBO++8yrpwqX+W1hdep5ArQAqKXp yNam5r/1XzrdkhCsZ/+4IQkEQNpeNo3r7rHhLjcJ2bo6QZt29NQCC8TXcGvN21vC VIuvwSepkA2bV9WeBZhL2s9OJjZFLyly9UqNysYa2StJ31fG0xrpuBqQlYUxEGlY A= Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner AT cygwin DOT com Mail-Followup-To: cygwin AT cygwin DOT com Delivered-To: mailing list cygwin AT cygwin DOT com 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 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) Date: Wed, 2 Dec 2015 15:31:48 +0000 From: Adam Dinwoodie To: cygwin AT cygwin DOT com Subject: Re: Incorrect Python errors when using os.remove to delete a directory Message-ID: <20151202153148.GJ14466@dinwoodie.org> References: <20151127145105 DOT GG14466 AT dinwoodie DOT 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 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