Exception holes, again.

Andrew MacIntyre andymac at bullseye.apana.org.au
Tue Nov 6 10:44:29 CET 2001


On Mon, 5 Nov 2001, Dale Strickland-Clark wrote:

> Here's a little program to provoke an error:
>
> import win32api
> import win32con
>
> key = win32api.RegOpenKeyEx(win32con.HKEY_CURRENT_USER, "Software", 0,
>     win32con.KEY_READ)
> print win32api.RegQueryValueEx(key, 'Spam')
>
> ..and here's the traceback:
>
> Traceback (most recent call last):
>   File "I:\BATCH\tests\testreg2.py", line 6, in ?
>     print win32api.RegQueryValueEx(key, 'Spam')
> pywintypes.api_error: (2, 'RegQueryValueEx', 'The system cannot find
> the file specified.')
>
> Doesn't tell you much, does it!
>
> I've tried to find pywintypes but can't and I had a hunt through the
> Python directories to see if I could find the definition but came up
> with nothing.

I think you'll find that this exception is registered in the
initialisation of one of the win32??? extension modules.  It is standard
practice for C extensions needing "their own" exceptions to do this.

I might have expected the PythonWin documentation to note things like
exceptions.

--
Andrew I MacIntyre                     "These thoughts are mine alone..."
E-mail: andymac at bullseye.apana.org.au  | Snail: PO Box 370
        andymac at pcug.org.au            |        Belconnen  ACT  2616
Web:    http://www.andymac.org/        |        Australia





More information about the Python-list mailing list