diff options
author | Mike Bayer <mike_mp@zzzcomputing.com> | 2013-04-13 21:29:57 -0400 |
---|---|---|
committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2013-04-13 21:29:57 -0400 |
commit | c16198a494de2227e05708cb4ffac4da43dc3779 (patch) | |
tree | 7aa792a5b11f94559a7eaf421a6fe4441bd79bdc /mako/compat.py | |
parent | 6c5e273c3b36606ac7267b5fe3ec77cb0c47da52 (diff) | |
download | mako-c16198a494de2227e05708cb4ffac4da43dc3779.tar.gz |
- [bug] Cleaned up all the various deprecation/
file warnings when running the tests under
various Pythons with warnings turned on.
[ticket:213]
Diffstat (limited to 'mako/compat.py')
-rw-r--r-- | mako/compat.py | 20 |
1 files changed, 17 insertions, 3 deletions
diff --git a/mako/compat.py b/mako/compat.py index 2dba143..3a4742d 100644 --- a/mako/compat.py +++ b/mako/compat.py @@ -2,7 +2,7 @@ import sys import time py3k = sys.version_info >= (3, 0) -py3kwarning = getattr(sys, 'py3kwarning', False) or py3k +py33 = sys.version_info >= (3, 3) py26 = sys.version_info >= (2, 6) py25 = sys.version_info >= (2, 5) jython = sys.platform.startswith('java') @@ -42,6 +42,21 @@ else: def octal(lit): return eval("0" + lit) + +if py33: + from importlib import machinery + def load_module(module_id, path): + return machinery.SourceFileLoader(module_id, path).load_module() +else: + import imp + def load_module(module_id, path): + fp = open(path, 'rb') + try: + return imp.load_source(module_id, path, fp) + finally: + fp.close() + + def exception_as(): return sys.exc_info()[1] @@ -120,7 +135,7 @@ except ImportError: def inspect_func_args(fn): return inspect.getargspec(fn) -if py3kwarning: +if py3k: def callable(fn): return hasattr(fn, '__call__') else: @@ -135,4 +150,3 @@ def with_metaclass(meta, base=object): return meta("%sBase" % meta.__name__, (base,), {}) ################################################ - |