A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://mail.python.org/pipermail/python-dev/2006-September/068871.html below:

[Python-Dev] Exceptions and slicing

[Python-Dev] Exceptions and slicingThomas Heller theller at python.net
Wed Sep 20 22:11:58 CEST 2006
Martin v. Löwis schrieb:
> Thomas Heller schrieb:
>> 1. The __str__ of a WindowsError instance hides the 'real' windows
>> error number.  So, in 2.4 "print error_instance" would print
>> for example:
>> 
>>   [Errno 1002] Das Fenster kann die gesendete Nachricht nicht verarbeiten.
>>     
>> while in 2.5:
>> 
>>   [Error 22] Das Fenster kann die gesendete Nachricht nicht verarbeiten.
> 
> That's a bug. I changed the string deliberately from Errno to error to
> indicate that it is not an errno, but a GetLastError. Can you come up
> with a patch?

Yes, but not today.

>> 2. How would one write portable exception handling for Python 2.4 and 2.5?
>> 
> Portable code should do
> 
> def winerror(exc):
>   try:
>      return exc.winerror
>   except AttributeError: #2.4 and earlier
>      return exc.errno
> 
> and then
> 
>  try:
>      do something
>  except WindowsError, details:
>      if not winerror(details) in (TYPE_E_REGISTRYACCESS,
> YPE_E_CANTLOADLIBRARY):
>          raise

Ok (sigh ;-).


Thanks,
Thomas

More information about the Python-Dev mailing list

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4