[Zope3-checkins] SVN: Zope3/trunk/src/zope/configuration/xmlconfig.pyFixed the "unbound local" error if a different IOError is raised.

Phil Ruggera pruggera at san.rr.com
Sun Aug 8 16:59:04 EDT 2004


That Fixed it.

Thanks.

Phil
> -----Original Message-----
> From: Steve Alexander [mailto:steve at z3u.com]
> Sent: Friday, August 06, 2004 11:55 PM
> To: Phil Ruggera
> Cc: zope3-checkins at zope.org
> Subject: Re: [Zope3-checkins] SVN:
> Zope3/trunk/src/zope/configuration/xmlconfig.pyFixed the "unbound local"
> error if a different IOError is raised.
>
>
> Phil Ruggera wrote:
> > In W2K the unit tests give me:
> >
> > Failure in test openInOrPlain (zope.configuration.xmlconfig)
> > Traceback (most recent call last):
> >   File "G:\Python\Dev\zope\src\zope\testing\doctestunit.py", line 71, in
> > runTest
> >     raise self.failureException(self.format_failure(new.getvalue()))
> > AssertionError: Failed doctest test for
> > zope.configuration.xmlconfig.openInOrPlain
> >   File
> "G:\Python\Dev\zope\src\zope\configuration\xmlconfig.py", line 251,
> > in openInOrPlain
> >
> > *****************************************************************
> > Failure in example: f = openInOrPlain('.')
> > from line #30 of zope.configuration.xmlconfig.openInOrPlain
> > Expected: IOError: [Errno 21] Is a directory
> > Got: IOError: [Errno 13] Permission denied: '.'
>
> Thanks!  I've checked in the following fix, which should work on both
> Linux and Windows 2000.
>
>
> Index: src/zope/configuration/xmlconfig.py
> ===================================================================
> --- src/zope/configuration/xmlconfig.py (revision 26948)
> +++ src/zope/configuration/xmlconfig.py (working copy)
> @@ -276,12 +276,18 @@
>       >>> f.name[-11:]
>       'foo.zcml.in'
>
> -    Make sure other IOErrors are re-raised:
> +    Make sure other IOErrors are re-raised.  We need to do this in a
> +    try-except block because different errors are raised on Windows and
> +    on Linux.
>
> -    >>> f = openInOrPlain('.')
> -    Traceback (most recent call last):
> +    >>> try:
> +    ...     f = openInOrPlain('.')
> +    ... except IOError:
> +    ...     print "passed"
> +    ... else:
> +    ...     print "failed"
>       ...
> -    IOError: [Errno 21] Is a directory
> +    passed
>
>       """
>       try:
>
> --
> Steve Alexander



More information about the Zope3-Checkins mailing list