Commit 9a59133d authored by Stefan Behnel's avatar Stefan Behnel

remove some legacy Py2.[345] code

parent a4893ddb
......@@ -3715,12 +3715,6 @@ class IndexNode(ExprNode):
buffer_entry = self.buffer_entry()
have_gil = not self.in_nogil_context
if sys.version_info < (3,):
def next_(it):
return it.next()
else:
next_ = next
have_slices = False
it = iter(self.indices)
for index in self.original_indices:
......@@ -3728,13 +3722,13 @@ class IndexNode(ExprNode):
have_slices = have_slices or is_slice
if is_slice:
if not index.start.is_none:
index.start = next_(it)
index.start = next(it)
if not index.stop.is_none:
index.stop = next_(it)
index.stop = next(it)
if not index.step.is_none:
index.step = next_(it)
index.step = next(it)
else:
next_(it)
next(it)
assert not list(it)
......
import os
from Cython.Compiler import CmdLine
from Cython.TestUtils import TransformTest
from Cython.Compiler.ParseTreeTransforms import *
from Cython.Compiler.Nodes import *
......@@ -203,18 +202,18 @@ class TestInterpretCompilerDirectives(TransformTest):
# TODO: Re-enable once they're more robust.
if sys.version_info[:2] >= (2, 5) and False:
if False:
from Cython.Debugger import DebugWriter
from Cython.Debugger.Tests.TestLibCython import DebuggerTestCase
else:
# skip test, don't let it inherit unittest.TestCase
DebuggerTestCase = object
class TestDebugTransform(DebuggerTestCase):
def elem_hasattrs(self, elem, attrs):
# we shall supporteth python 2.3 !
return all([attr in elem.attrib for attr in attrs])
return all(attr in elem.attrib for attr in attrs)
def test_debug_info(self):
try:
......
......@@ -7,7 +7,7 @@ specific descendant or a node that holds an attribute.
"""
import re
import sys
import operator
path_tokenizer = re.compile(
"("
......@@ -132,6 +132,7 @@ def handle_descendants(next, token):
return select
def handle_attribute(next, token):
token = next()
if token[0]:
......@@ -145,16 +146,7 @@ def handle_attribute(next, token):
else:
if token[0] == '=':
value = parse_path_value(next)
if sys.version_info >= (2,6) or (sys.version_info >= (2,4) and '.' not in name):
import operator
readattr = operator.attrgetter(name)
else:
name_path = name.split('.')
def readattr(node):
attr_value = node
for attr in name_path:
attr_value = getattr(attr_value, attr)
return attr_value
readattr = operator.attrgetter(name)
if value is None:
def select(result):
for node in result:
......@@ -175,6 +167,7 @@ def handle_attribute(next, token):
yield attr_value
return select
def parse_path_value(next):
token = next()
value = token[0]
......
......@@ -86,11 +86,8 @@ class _TestInfo(object):
"""
if not self.err:
return ''
if sys.version_info < (2,4):
return self.test_result._exc_info_to_string(self.err)
else:
return self.test_result._exc_info_to_string(
self.err, self.test_method)
return self.test_result._exc_info_to_string(
self.err, self.test_method)
class _XMLTestResult(_TextTestResult):
......@@ -98,8 +95,8 @@ class _XMLTestResult(_TextTestResult):
Used by XMLTestRunner.
"""
def __init__(self, stream=sys.stderr, descriptions=1, verbosity=1, \
elapsed_times=True):
def __init__(self, stream=sys.stderr, descriptions=1, verbosity=1,
elapsed_times=True):
"Create a new instance of _XMLTestResult."
_TextTestResult.__init__(self, stream, descriptions, verbosity)
self.successes = []
......
......@@ -3,7 +3,11 @@
# anywhere else in particular
#
import os, sys, re, codecs
import os
import sys
import re
import io
import codecs
modification_time = os.path.getmtime
......@@ -268,14 +272,6 @@ class NormalisedNewlineStream(object):
raise NotImplementedError
io = None
if sys.version_info >= (2,6):
try:
import io
except ImportError:
pass
def open_source_file(source_filename, mode="r",
encoding=None, error_handling=None,
require_normalised_newlines=True):
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment