Commits

Sylvain Hellegouarch committed 93c8c2c

Rather than trying to workaround which symbol can or cannot be imported, I thought it'd be better to simply import the module in the helper since it's only used there. I also prevent it to be distributed with Python 2.7 as it doesn't need to

Comments (5)

  1. Sylvain Hellegouarch author

    As a follow up, I think the change on setup.py isn't the right one. Indeed, I we create the source distribution for Python 2.x using a Python 2.7, then the generated zip/tarball will not contain the _compat_subprocess.py. So that source distribution will be incomplete once deployed on Python 2.6-. I will revert the change on setup.py ony though, the rest of the fix seems fine.

Files changed (3)

cherrypy/_cpcompat.py

 
     if sys.version_info < (2, 6):
         daemon = property(__get_daemon, __set_daemon)
-
-# Use subprocess module from Python 2.7 on Python 2.3-2.6
-if sys.version_info < (2, 7):
-    import cherrypy._cpcompat_subprocess as subprocess
-else:
-    import subprocess

cherrypy/test/helper.py

 
 import cherrypy
 from cherrypy._cpcompat import basestring, copyitems, HTTPSConnection, ntob
-from cherrypy._cpcompat import subprocess
 from cherrypy.lib import httputil
 from cherrypy.lib import gctools
 from cherrypy.lib.reprconf import unrepr
 from cherrypy.test import webtest
 
+# Use subprocess module from Python 2.7 on Python 2.3-2.6
+if sys.version_info < (2, 7):
+    import cherrypy._cpcompat_subprocess as subprocess
+else:
+    import subprocess
+
 import nose
 
 _testconfig = None
         if python3:
             exclude_pattern = re.compile('wsgiserver2|ssl_pyopenssl|'
                                          '_cpcompat_subprocess')
+        elif sys.version_info < (2, 7):
+            exclude_pattern = re.compile('wsgiserver3')
         else:
-            exclude_pattern = re.compile('wsgiserver3')
+            # no need to include _cpcompat_subprocess when
+            # python already provides its own subprocess module
+            exclude_pattern = re.compile('wsgiserver3|'
+                                         '_cpcompat_subprocess')
         if exclude_pattern.match(module):
             return  # skip it
         return build_py.build_module(self, module, module_file, package)