[Zope-dev] SVN: Sandbox/malthe/chameleon.core/src/chameleon/core/utils.py Catch all exceptions; it's not required to be able to determine length.

Tres Seaver tseaver at palladion.com
Tue Nov 25 11:52:04 EST 2008


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Malthe Borch wrote:
> Log message for revision 93341:
>   Catch all exceptions; it's not required to be able to determine length.
> 
> Changed:
>   U   Sandbox/malthe/chameleon.core/src/chameleon/core/utils.py
> 
> -=-
> Modified: Sandbox/malthe/chameleon.core/src/chameleon/core/utils.py
> ===================================================================
> --- Sandbox/malthe/chameleon.core/src/chameleon/core/utils.py	2008-11-25 14:20:12 UTC (rev 93340)
> +++ Sandbox/malthe/chameleon.core/src/chameleon/core/utils.py	2008-11-25 14:21:04 UTC (rev 93341)
> @@ -188,7 +188,9 @@
>      def insert(self, key, iterable):
>          try:
>              length = len(iterable)
> -        except TypeError:
> +        except:
> +            # we catch all exceptions here, because it's not required
> +            # for iteration
>              length = None
>              
>          try:
> @@ -201,7 +203,9 @@
>              raise TypeError(
>                  "Can only repeat over an iterable object (%s)." % iterable)
>  
> -        self[key] = (iterator, length)
> +        if length is not None:
> +            self[key] = (iterator, length)
> +            
>          return iterator
>          
>      def __getitem__(self, key):

Hmm, some exceptions should never be caught (KeyboardInterrupt,
SystemExit, ConflictError).


Tres.
- --
===================================================================
Tres Seaver          +1 540-429-0999          tseaver at palladion.com
Palladion Software   "Excellence by Design"    http://palladion.com
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFJLC00+gerLs4ltQ4RAgTcAJ4y1O2fsJtabW9wxvVXObwKUPtzWACdFfze
aYy6uw7WkG8UXHdSlEcc9cs=
=sD/Q
-----END PGP SIGNATURE-----



More information about the Zope-Dev mailing list