← Back to team overview

launchpad-reviewers team mailing list archive

[Merge] ~cjwatson/launchpad:py3-avoid-cvs-import into launchpad:master

 

Colin Watson has proposed merging ~cjwatson/launchpad:py3-avoid-cvs-import into launchpad:master.

Commit message:
Avoid importing CVS at module level

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)

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

cscvs hasn't been ported to Python 3 yet.  Until it has, avoid importing from it at module level.  validate_cvs_root will still fail on Python 3, but we can at least import lp.code.interfaces.codeimport without running into that.
-- 
Your team Launchpad code reviewers is requested to review the proposed merge of ~cjwatson/launchpad:py3-avoid-cvs-import into launchpad:master.
diff --git a/lib/lp/code/interfaces/codeimport.py b/lib/lp/code/interfaces/codeimport.py
index 3a54c3a..534be78 100644
--- a/lib/lp/code/interfaces/codeimport.py
+++ b/lib/lp/code/interfaces/codeimport.py
@@ -12,10 +12,6 @@ __all__ = [
 
 import re
 
-from CVS.protocol import (
-    CVSRoot,
-    CvsRootError,
-    )
 from lazr.restful.declarations import (
     call_with,
     export_write_operation,
@@ -52,6 +48,12 @@ from lp.services.fields import (
 
 
 def validate_cvs_root(cvsroot):
+    # XXX cjwatson 2020-08-12: Move these imports back up to the top level
+    # once they work on Python 3.
+    from CVS.protocol import (
+        CVSRoot,
+        CvsRootError,
+        )
     try:
         root = CVSRoot(cvsroot)
     except CvsRootError as e: