← Back to team overview

launchpad-reviewers team mailing list archive

[Merge] ~cjwatson/launchpad:py3only-contextlib into launchpad:master

 

Colin Watson has proposed merging ~cjwatson/launchpad:py3only-contextlib into launchpad:master.

Commit message:
Use contextlib.ExitStack directly

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)

For more details, see:
https://code.launchpad.net/~cjwatson/launchpad/+git/launchpad/+merge/406831

We no longer need the contextlib2 backport now that we require Python >= 3.5.
-- 
Your team Launchpad code reviewers is requested to review the proposed merge of ~cjwatson/launchpad:py3only-contextlib into launchpad:master.
diff --git a/lib/lp/code/model/branchmergeproposaljob.py b/lib/lp/code/model/branchmergeproposaljob.py
index d657f34..76bcb69 100644
--- a/lib/lp/code/model/branchmergeproposaljob.py
+++ b/lib/lp/code/model/branchmergeproposaljob.py
@@ -21,10 +21,7 @@ __all__ = [
     'UpdatePreviewDiffJob',
     ]
 
-try:
-    from contextlib import ExitStack
-except ImportError:
-    from contextlib2 import ExitStack
+from contextlib import ExitStack
 from datetime import (
     datetime,
     timedelta,
diff --git a/lib/lp/code/model/diff.py b/lib/lp/code/model/diff.py
index 6b3ca22..4cabfe9 100644
--- a/lib/lp/code/model/diff.py
+++ b/lib/lp/code/model/diff.py
@@ -10,10 +10,7 @@ __all__ = [
     'PreviewDiff',
     ]
 
-try:
-    from contextlib import ExitStack
-except ImportError:
-    from contextlib2 import ExitStack
+from contextlib import ExitStack
 import io
 from operator import attrgetter
 import sys
diff --git a/lib/lp/scripts/runlaunchpad.py b/lib/lp/scripts/runlaunchpad.py
index 7115a81..38225f9 100644
--- a/lib/lp/scripts/runlaunchpad.py
+++ b/lib/lp/scripts/runlaunchpad.py
@@ -4,10 +4,7 @@
 __metaclass__ = type
 __all__ = ['start_launchpad']
 
-try:
-    from contextlib import ExitStack
-except ImportError:
-    from contextlib2 import ExitStack
+from contextlib import ExitStack
 import os
 import signal
 import subprocess
diff --git a/lib/lp/scripts/utilities/importpedant.py b/lib/lp/scripts/utilities/importpedant.py
index 93e7da9..de1c5d8 100644
--- a/lib/lp/scripts/utilities/importpedant.py
+++ b/lib/lp/scripts/utilities/importpedant.py
@@ -22,8 +22,6 @@ naughty_imports = set()
 # __all__. The following dict maps from such modules to a list of attributes
 # that are allowed to be imported, whether or not they are in __all__.
 valid_imports_not_in_all = {
-    # Exported in Python 3, but missing and so not exported in Python 2.
-    'contextlib': set(['ExitStack']),
     'importlib': set(['resources']),
     'openid.fetchers': set(['Urllib2Fetcher']),
     'openid.message': set(['NamespaceAliasRegistrationError']),
diff --git a/lib/lp/services/librarianserver/librariangc.py b/lib/lp/services/librarianserver/librariangc.py
index 1a0cb30..b924409 100644
--- a/lib/lp/services/librarianserver/librariangc.py
+++ b/lib/lp/services/librarianserver/librariangc.py
@@ -5,10 +5,7 @@
 
 __metaclass__ = type
 
-try:
-    from contextlib import ExitStack
-except ImportError:
-    from contextlib2 import ExitStack
+from contextlib import ExitStack
 from datetime import (
     datetime,
     timedelta,
diff --git a/requirements/launchpad.txt b/requirements/launchpad.txt
index 603983a..09715e5 100644
--- a/requirements/launchpad.txt
+++ b/requirements/launchpad.txt
@@ -29,7 +29,6 @@ Chameleon==3.6.2
 configobj==5.0.6
 contextvars==2.4
 constantly==15.1.0
-contextlib2==0.6.0.post1
 cookies==2.2.1
 cryptography==2.7
 cssselect==0.9.1
diff --git a/setup.py b/setup.py
index 235a234..5c4f42d 100644
--- a/setup.py
+++ b/setup.py
@@ -154,7 +154,6 @@ setup(
         'boto3',
         'breezy',
         'celery',
-        'contextlib2; python_version < "3.3"',
         'cssselect',
         'cssutils',
         'defusedxml',