compatibility improvements -> use reduce from functools

This commit is contained in:
Dave Halter
2014-01-14 11:31:01 +01:00
parent 8bf8985247
commit a6e49f2680
3 changed files with 6 additions and 8 deletions

View File

@@ -1,7 +1,6 @@
"""
To ensure compatibility from Python ``2.6`` - ``3.3``, a module has been
created. Clearly there is huge need to use conforming syntax. But many changes
(e.g. ``property``, ``hasattr`` in ``2.5``) can be rewritten in pure python.
created. Clearly there is huge need to use conforming syntax.
"""
import sys
import imp
@@ -147,16 +146,13 @@ class Python3Method(object):
else:
return lambda *args, **kwargs: self.func(obj, *args, **kwargs)
def use_metaclass(meta, *bases):
""" Create a class with a metaclass. """
if not bases:
bases = (object,)
return meta("HackClass", bases, {})
try:
from functools import reduce # Python 3
except ImportError:
reduce = reduce
try:
encoding = sys.stdout.encoding
@@ -165,6 +161,7 @@ try:
except AttributeError:
encoding = 'ascii'
def u(string):
"""Cast to unicode DAMMIT!
Written because Python2 repr always implicitly casts to a string, so we

View File

@@ -7,7 +7,7 @@ from __future__ import with_statement
import os
import re
from jedi._compatibility import reduce
from functools import reduce
import jedi
from jedi import refactoring

View File

@@ -101,7 +101,8 @@ import re
from ast import literal_eval
import jedi
from jedi._compatibility import unicode, reduce, StringIO, is_py3k
from functools import reduce
from jedi._compatibility import unicode, StringIO, is_py3k
TEST_COMPLETIONS = 0