Commits

Marc Abramowitz committed 8bb6269

Tweaks to edge slightly closer to Python 3 compatibility

  • Participants
  • Parent commits 13e23ce

Comments (0)

Files changed (4)

File paste/script/util/logging_config.py

 
 def _resolve(name):
     """Resolve a dotted name to a global object."""
-    name = string.split(name, '.')
+    name = name.split('.')
     used = name.pop(0)
     found = __import__(used)
     for n in name:
     flist = cp.get("formatters", "keys")
     if not len(flist):
         return {}
-    flist = string.split(flist, ",")
+    flist = flist.split(",")
     formatters = {}
     for form in flist:
-        form = string.strip(form)
+        form = form.strip()
         sectname = "formatter_%s" % form
         opts = cp.options(sectname)
         if "format" in opts:
     hlist = cp.get("handlers", "keys")
     if not len(hlist):
         return {}
-    hlist = string.split(hlist, ",")
+    hlist = hlist.split(",")
     handlers = {}
     fixups = [] #for inter-handler references
     for hand in hlist:
-        hand = string.strip(hand)
+        hand = hand.strip()
         sectname = "handler_%s" % hand
         klass = cp.get(sectname, "class")
         opts = cp.options(sectname)
 
     # configure the root first
     llist = cp.get("loggers", "keys")
-    llist = string.split(llist, ",")
-    llist = map(lambda x: string.strip(x), llist)
+    llist = llist.split(",")
+    llist = map(lambda x: x.strip(), llist)
     llist.remove("root")
     sectname = "logger_root"
     root = logging.root
         root.removeHandler(h)
     hlist = cp.get(sectname, "handlers")
     if len(hlist):
-        hlist = string.split(hlist, ",")
+        hlist = hlist.split(",")
         for hand in hlist:
-            log.addHandler(handlers[string.strip(hand)])
+            log.addHandler(handlers[hand.strip()])
 
     #and now the others...
     #we don't want to lose the existing loggers,
         logger.disabled = 0
         hlist = cp.get(sectname, "handlers")
         if len(hlist):
-            hlist = string.split(hlist, ",")
+            hlist = hlist.split(",")
             for hand in hlist:
-                logger.addHandler(handlers[string.strip(hand)])
+                logger.addHandler(handlers[hand.strip()])
 
     #Disable any old loggers. There's no point deleting
     #them as other threads may continue to hold references
             found_news = parts[i+i]
             break
 if not found_news:
-    print 'Warning: no news for this version found'
+    print('Warning: no news for this version found')
 
 long_description="""\
 This is a pluggable command-line tool.
       },
     zip_safe=False,
     test_suite='nose.collector',
-    tests_require=['nose>=0.11', 'Cheetah', 'PasteWebKit'],
+    tests_require=['nose>=0.11', 'Cheetah'],
+    use_2to3=True,
     extras_require={
       'Templating': [],
       'Cheetah': ['Cheetah'],

File tests/test_logging_config.py

 """
 
 # config2 has a subtle configuration error that should be reported
-config2 = string.replace(config1, "sys.stdout", "sys.stbout")
+config2 = config1.replace("sys.stdout", "sys.stbout")
 
 # config3 has a less subtle configuration error
-config3 = string.replace(
-    config1, "formatter=form1", "formatter=misspelled_name")
+config3 = config1.replace(
+    "formatter=form1", "formatter=misspelled_name")
 
 # config4: support custom Handler classes
-config4 = string.replace(
-    config1, "class=StreamHandler", "class=logging.StreamHandler")
+config4 = config1.replace(
+    "class=StreamHandler", "class=logging.StreamHandler")
 
 def test4():
     for i in range(5):
 # and then run "tox" from this directory.
 
 [tox]
-envlist = py24, py25, py26, py27, py30, py31, py32, py33, pypy, jython
+envlist = py24, py25, py26, py27, py32, pypy, jython
 
 [testenv]
-commands = python setup.py test
+commands =
+    nosetests -w /tmp {toxinidir}/tests
+deps =
+    nose
+    Cheetah
+
+[testenv:py32]
+commands =
+    rm -rf tests-py3
+    cp -pr tests tests-py3
+    2to3 -w -n tests-py3
+    nosetests -w /tmp {toxinidir}/tests-py3
+deps =
+    nose