Commits

Andriy Kornatskyy committed e6908b7

Fixed compatibility issue with python3.

Comments (0)

Files changed (1)

demos/template/src/config.py

 """
 
 import os
+import sys
 
 from datetime import timedelta
 
-try:  # pragma: nocover
+
+PY3 = sys.version_info[0] >= 3
+
+if PY3:  # pragma: nocover
+    from configparser import ConfigParser
+    config = ConfigParser(strict=False)
+else:  # pragma: nocover
     from ConfigParser import ConfigParser
     config = ConfigParser()
-except ImportError:  # pragma: nocover
-    from configparser import ConfigParser
-    config = ConfigParser(strict=False)
 
 from wheezy.caching import MemoryCache
 from wheezy.core.collections import defaultdict
             directories=directories,
             cache_factory=cache_factory,
             default_filters=[],
-            imports=['s = unicode'],
+            imports=[PY3 and 's=str' or 's=unicode'],
             preprocessor=[
                 inline_preprocessor(directories, enabled=config.getboolean(
                     'mako', 'inline-preprocessor-enabled')),