[PATCH 01/15] Raise exceptions as defined in PEP 3109
Łukasz Żarnowiecki
dolohow at outlook.com
Fri May 13 07:35:41 BST 2016
On Tue, May 10, 2016 at 02:52:51AM +0200, Nicolas Sebrecht wrote:
> On Tue, May 10, 2016 at 01:18:23AM +0200, Łukasz Żarnowiecki wrote:
>
> > Signed-off-by: Łukasz Żarnowiecki <dolohow at outlook.com>
> > ---
> > offlineimap/CustomConfig.py | 4 ++--
> > offlineimap/accounts.py | 4 ++--
> > offlineimap/folder/Gmail.py | 8 ++++----
> > offlineimap/folder/GmailMaildir.py | 6 +++---
> > offlineimap/folder/IMAP.py | 7 +++----
> > offlineimap/folder/LocalStatus.py | 4 ++--
> > offlineimap/folder/LocalStatusSQLite.py | 4 ++--
> > offlineimap/folder/Maildir.py | 15 +++++++--------
> > offlineimap/folder/UIDMaps.py | 4 ++--
> > offlineimap/imaplibutil.py | 2 +-
> > offlineimap/imapserver.py | 8 ++++----
> > offlineimap/repository/IMAP.py | 5 +++--
> > offlineimap/repository/__init__.py | 10 ++++++----
> > 13 files changed, 41 insertions(+), 40 deletions(-)
> >
> > diff --git a/offlineimap/CustomConfig.py b/offlineimap/CustomConfig.py
> > index 44cfcab..71fa675 100644
> > --- a/offlineimap/CustomConfig.py
> > +++ b/offlineimap/CustomConfig.py
> > @@ -75,8 +75,8 @@ class CustomConfigParser(SafeConfigParser):
> > val = self.get(section, option).strip()
> > return re.split(separator_re, val)
> > except re.error as e:
> > - raise Error("Bad split regexp '%s': %s" % \
> > - (separator_re, e)), None, exc_info()[2]
> > + raise Error("Bad split regexp '%s': %s" %
> > + (separator_re, e)).with_traceback(exc_info()[2])
>
> I don't think this syntax is Python 2 compatible.
You are right, it is not compatible with Python2. I was not careful
enough this time. We have three possibilities here:
* Use reraise from six module[1].
* Write wrapper around raise.
I tried this one and I was successful, it is quite tricky, cause the
syntax from Python2 is not compatible with Python3, so a little
hackery is necessary. I was thinking about putting it into
offlineimap/utils/py23.py.
* Abandon Python2, most popular distributions ships with Python3
installed, but RHEL 6 not, but it is still supported.
What do you think?
[1] https://pythonhosted.org/six/#six.reraise
More information about the OfflineIMAP-project
mailing list