Path: csiph.com!fu-berlin.de!uni-berlin.de!not-for-mail From: eryk sun Newsgroups: comp.lang.python Subject: Re: Remove directory tree without following symlinks Date: Fri, 22 Apr 2016 13:28:01 -0500 Lines: 10 Message-ID: References: <571a3ba2$0$1597$c3e8da3$5496439d@news.astraweb.com> <1461337766.365000.586700849.0DDBDB0B@webmail.messagingengine.com> <571a5be6$0$1590$c3e8da3$5496439d@news.astraweb.com> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 X-Trace: news.uni-berlin.de zbwMvHuQI6TOs7Wlca0PiQMWdELJIEvnXvdzClxOu8RA== Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.003 X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; 'handler': 0.04; 'raises': 0.07; '22,': 0.09; 'raised,': 0.09; 'url:github': 0.09; 'windowserror': 0.09; '2016': 0.16; 'fyi,': 0.16; 'received:io': 0.16; 'received:psf.io': 0.16; 'subject:Remove': 0.16; 'url:pip': 0.16; 'wrote:': 0.16; '(or': 0.23; 'help.': 0.23; 'header:In- Reply-To:1': 0.24; 'error': 0.27; 'fri,': 0.27; 'message- id:@mail.gmail.com': 0.27; "skip:' 10": 0.28; 'sure,': 0.29; 'option': 0.31; 'received:google.com': 0.35; 'dir': 0.35; 'but': 0.36; 'received:209.85': 0.36; 'to:addr:python-list': 0.36; 'pm,': 0.36; 'subject:: ': 0.37; 'received:209.85.213': 0.37; "won't": 0.38; 'received:209': 0.38; 'to:addr:python.org': 0.40; 'today': 0.65; 'improvement.': 0.66; 'subject:tree': 0.84 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to; bh=L9bv/HqQjAsT2tJSsXKc2/ZV//Pmf7Iu6X2/WnoRhUI=; b=k3/aelBy/Q5FIYJJf/B6Hz1dViI4vJ38hpskZQjbClUOVbEH67qxpk5ltI/9lUIDNb mq+zCfaVobpb2zn8QgKPA2twE/SpVBYi6iN1z8sKRsmxeLubWChzqJdSrtYj48yIkXzf VtojP2u6g2j1OCDttkxprDry6CoSXnTWhwyL97Jkzjt+2fC20hdQjFma5z/cduaobO7S Qy0VoHjx/1KuENw7YJtS0pxJ/o6BUTKq8iccpvuDt/Sw0UAskMY28qFJ/ORT5YRtNaLd ZPrMzewO+mlZR7oJ5nTeR/uKPADjBjmazDa80v0PP3ZYQdHa1TkvW1kQCRk65IL/WPn8 v3gQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to; bh=L9bv/HqQjAsT2tJSsXKc2/ZV//Pmf7Iu6X2/WnoRhUI=; b=cQIG6RKLTBRqA+pODuORO4ayOiZJCjlm233jaC8eWDusKEhSrU4hba17i+hIrAp6Nr 3nvJtuFrrA0of50xL99b/c/XvFxMeszeo3ToxBlURQLRIkYj03WMDgzz9j9WpU4p0ZbA u6WXzmIOws9zSpPIZOULaKqzakpyq3XjNLo7GjYdBg87+6KpgORceoQY++NkanpuO1bx oRaQHZY5jjkgZXU5gDujTxKUbc2M2hBpbdxUz+OSypSoRagx4akWHSR9vNV5/c1zplJd GIe4hLKyRM3FxDQdKSh4ogolajJYggBDiNYonj9xEAdi6ND1wRcd7ln1mPoOJ3nwS7vl Yv3w== X-Gm-Message-State: AOPr4FXWHpjfW7M5lC4wylivXQOoi7PJ13aVqFzKPFmCmLB5A3IdLFIVI7TNpN97I8Flp6vyALTDDjOJGO9KSQ== X-Received: by 10.50.227.131 with SMTP id sa3mr6192486igc.55.1461349721165; Fri, 22 Apr 2016 11:28:41 -0700 (PDT) In-Reply-To: X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Mailman-Original-Message-ID: X-Mailman-Original-References: <571a3ba2$0$1597$c3e8da3$5496439d@news.astraweb.com> <1461337766.365000.586700849.0DDBDB0B@webmail.messagingengine.com> <571a5be6$0$1590$c3e8da3$5496439d@news.astraweb.com> Xref: csiph.com comp.lang.python:107506 On Fri, Apr 22, 2016 at 12:39 PM, Albert-Jan Roskam wrote: > FYI, Just today I found out that shutil.rmtree raises a WindowsError if the dir is read- > only (or its contents). Using 'ignore_errors', won't help. Sure, no error is raised, but the > dir is not deleted either! A 'force' option would be a nice improvement. Use the onerror handler to call os.chmod(path, stat.S_IWRITE). For example, see pip's rmtree_errorhandler: https://github.com/pypa/pip/blob/8.1.1/pip/utils/__init__.py#L105