Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!selfless.tophat.at!newsfeed.xs4all.nl!newsfeed5.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.001 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'int': 0.05; 'raises': 0.07; 'received:192.168.1.4': 0.07; 'though.': 0.07; 'ctypes': 0.09; 'subject:error': 0.11; '>>>': 0.12; 'am,': 0.14; 'received:209.85.214.174': 0.14; 'received:mail- iw0-f174.google.com': 0.14; 'wrote:': 0.14; 'codes,': 0.16; 'exists:': 0.16; 'hresult': 0.16; 'subtract': 0.16; 'verwendet': 0.16; 'cache': 0.16; 'traceback': 0.16; '(most': 0.16; 'convert': 0.19; 'header:In-Reply-To:1': 0.21; 'clause': 0.23; 'here?': 0.23; 'last):': 0.23; 'code': 0.24; 'subject:List': 0.26; "i'm": 0.27; 'received:209.85.214': 0.28; 'import': 0.29; 'einem': 0.30; 'to:addr:python-list': 0.33; 'too': 0.33; 'error': 0.33; 'file': 0.34; 'nicht': 0.34; 'there': 0.35; 'header:User-Agent:1': 0.35; '"",': 0.35; 'kann': 0.35; 'like:': 0.35; 'message-id:@gmail.com': 0.36; 'received:google.com': 0.37; 'something': 0.37; 'received:209.85': 0.37; 'could': 0.38; 'subject:: ': 0.38; 'received:192': 0.38; 'skip:s 20': 0.39; 'received:209': 0.39; 'map': 0.39; 'to:addr:python.org': 0.39; 'missing': 0.40; 'received:192.168.1': 0.40; 'die': 0.60; 'auf': 0.63; 'sie': 0.63; 'anderen': 0.84 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:message-id:date:from:user-agent:mime-version:to :subject:references:in-reply-to:x-enigmail-version:content-type :content-transfer-encoding; bh=cl4O2VcRsQC4CzfavpnmvDhY68+fZBH+6B9zep+8Omk=; b=iyqfdcUlkZRUos5TxF69XFsgXohNSjyI685p0lOe2s4P51ZhfjGL/nShj3PupXL1Oe uyQQrzNt+gc1yS4+HHmformqfdJjSRS5qoNyoXioSjg27XIKJhG6SCsmfblf8hX1yTzZ 4SvZl2h5SIdZEvCN1oQcHhTVlZHvFFtWcvUdQ= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:user-agent:mime-version:to:subject:references :in-reply-to:x-enigmail-version:content-type :content-transfer-encoding; b=PzwSRTLPl+P8Qfb+0aQA1LFR0sD9j5cREC4WVe6hCyWn1kUR0Ev/h6p+AO+UMT6VS0 7I1FErPlLouO4VmumTpZf9v53YgUOr331FiRRF9v4zF/R8YIsPaeMYVrUwL9hYdZpvc7 UohUnI/FnNuplQ1jLkC88SN1/OGdUNH6VfBp0= Date: Fri, 27 May 2011 04:22:48 -0500 From: Andrew Berg User-Agent: Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.2.15) Gecko/20110303 Thunderbird/3.1.9 ThunderBrowse/3.3.5 MIME-Version: 1.0 To: python-list@python.org Subject: Re: List of WindowsError error codes and meanings References: <9478c6Fr09U1@mid.individual.net> In-Reply-To: <9478c6Fr09U1@mid.individual.net> X-Enigmail-Version: 1.1.1 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 27 NNTP-Posting-Host: 82.94.164.166 X-Trace: 1306488176 news.xs4all.nl 49174 [::ffff:82.94.164.166]:43696 X-Complaints-To: abuse@xs4all.nl Xref: x330-a1.tempe.blueboxinc.net comp.lang.python:6380 On 2011.05.26 10:02 AM, Thomas Heller wrote: > On Windows, you can use ctypes.FormatError(code) to map error codes > to strings: > > >>> import ctypes > >>> ctypes.FormatError(32) > 'Der Prozess kann nicht auf die Datei zugreifen, da sie von einem > anderen Prozess verwendet wird.' > >>> > > For HRESULT codes, you (unfortunately) have to subtract 2**32-1 from > the error code: > > >>> ctypes.FormatError(0x80040005) > Traceback (most recent call last): > File "", line 1, in > OverflowError: long int too large to convert to int > >>> ctypes.FormatError(0x80040005 - (2**32-1)) > 'Kein Cache zum Verarbeiten vorhanden.' > >>> I could get that with str(sys.exc_info()[1]), though. If something raises a WindowsError, str(sys.exc_info()[1]) contains something like: [Error 183] Cannot create a file when that file already exists: sys.exc_info() is how I get the error code from inside an except clause in the first place. Or is there something I'm missing here?