[PATCH] correctly reraise errors with six

Łukasz Żarnowiecki dolohow at outlook.com
Tue Jul 5 22:17:32 BST 2016


On Wed, Jun 29, 2016 at 03:45:01AM +0200, Nicolas Sebrecht wrote:
> @@ -16,9 +16,8 @@
>  
>  import os
>  import re
> -from sys import exc_info
> -
>  import six
> +from sys import exc_info
>  
>  try:
>      from ConfigParser import SafeConfigParser, Error
> @@ -77,8 +76,10 @@ class CustomConfigParser(SafeConfigParser):
>              val = self.get(section, option).strip()
>              return re.split(separator_re, val)
>          except re.error as e:
> -            six.reraise(Error("Bad split regexp '%s': %s" % \
> -              (separator_re, e)), None, exc_info()[2])
> +            six.reraise(Error,
> +                        Error("Bad split regexp '%s': %s"%
> +                            (separator_re, e)),
> +                        exc_info()[2])

Those lines definitely look more uglier that it was before, the
parenthesis could be aligned in a row at least.

>  class MappedIMAPFolder(IMAPFolder):
>      """IMAP class to map between Folder() instances where both side assign a uid
> @@ -63,8 +64,11 @@ class MappedIMAPFolder(IMAPFolder):
>                  try:
>                      line = line.strip()
>                  except ValueError:
> -                    six.reraise(Exception("Corrupt line '%s' in UID mapping file '%s'"%
> -                        (line, mapfilename)), None, exc_info()[2])
> +                    six.reraise(Exception,
> +                            Exception(
> +                                "Corrupt line '%s' in UID mapping file '%s'"%
> +                                (line, mapfilename)),
> +                            exc_info()[2])

I am not a fan of this patch.  It makes thing looks more uglier that it
was before.  But that just my opinion




More information about the OfflineIMAP-project mailing list