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): ...@@ -3715,12 +3715,6 @@ class IndexNode(ExprNode):
buffer_entry = self.buffer_entry() buffer_entry = self.buffer_entry()
have_gil = not self.in_nogil_context have_gil = not self.in_nogil_context
if sys.version_info < (3,):
def next_(it):
return it.next()
else:
next_ = next
have_slices = False have_slices = False
it = iter(self.indices) it = iter(self.indices)
for index in self.original_indices: for index in self.original_indices:
...@@ -3728,13 +3722,13 @@ class IndexNode(ExprNode): ...@@ -3728,13 +3722,13 @@ class IndexNode(ExprNode):
have_slices = have_slices or is_slice have_slices = have_slices or is_slice
if is_slice: if is_slice:
if not index.start.is_none: if not index.start.is_none:
index.start = next_(it) index.start = next(it)
if not index.stop.is_none: if not index.stop.is_none:
index.stop = next_(it) index.stop = next(it)
if not index.step.is_none: if not index.step.is_none:
index.step = next_(it) index.step = next(it)
else: else:
next_(it) next(it)
assert not list(it) assert not list(it)
......
import os import os
from Cython.Compiler import CmdLine
from Cython.TestUtils import TransformTest from Cython.TestUtils import TransformTest
from Cython.Compiler.ParseTreeTransforms import * from Cython.Compiler.ParseTreeTransforms import *
from Cython.Compiler.Nodes import * from Cython.Compiler.Nodes import *
...@@ -203,18 +202,18 @@ class TestInterpretCompilerDirectives(TransformTest): ...@@ -203,18 +202,18 @@ class TestInterpretCompilerDirectives(TransformTest):
# TODO: Re-enable once they're more robust. # 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 import DebugWriter
from Cython.Debugger.Tests.TestLibCython import DebuggerTestCase from Cython.Debugger.Tests.TestLibCython import DebuggerTestCase
else: else:
# skip test, don't let it inherit unittest.TestCase # skip test, don't let it inherit unittest.TestCase
DebuggerTestCase = object DebuggerTestCase = object
class TestDebugTransform(DebuggerTestCase): class TestDebugTransform(DebuggerTestCase):
def elem_hasattrs(self, elem, attrs): 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): def test_debug_info(self):
try: try:
......
...@@ -7,7 +7,7 @@ specific descendant or a node that holds an attribute. ...@@ -7,7 +7,7 @@ specific descendant or a node that holds an attribute.
""" """
import re import re
import sys import operator
path_tokenizer = re.compile( path_tokenizer = re.compile(
"(" "("
...@@ -132,6 +132,7 @@ def handle_descendants(next, token): ...@@ -132,6 +132,7 @@ def handle_descendants(next, token):
return select return select
def handle_attribute(next, token): def handle_attribute(next, token):
token = next() token = next()
if token[0]: if token[0]:
...@@ -145,16 +146,7 @@ def handle_attribute(next, token): ...@@ -145,16 +146,7 @@ def handle_attribute(next, token):
else: else:
if token[0] == '=': if token[0] == '=':
value = parse_path_value(next) 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) 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
if value is None: if value is None:
def select(result): def select(result):
for node in result: for node in result:
...@@ -175,6 +167,7 @@ def handle_attribute(next, token): ...@@ -175,6 +167,7 @@ def handle_attribute(next, token):
yield attr_value yield attr_value
return select return select
def parse_path_value(next): def parse_path_value(next):
token = next() token = next()
value = token[0] value = token[0]
......
...@@ -86,9 +86,6 @@ class _TestInfo(object): ...@@ -86,9 +86,6 @@ class _TestInfo(object):
""" """
if not self.err: if not self.err:
return '' 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( return self.test_result._exc_info_to_string(
self.err, self.test_method) self.err, self.test_method)
...@@ -98,7 +95,7 @@ class _XMLTestResult(_TextTestResult): ...@@ -98,7 +95,7 @@ class _XMLTestResult(_TextTestResult):
Used by XMLTestRunner. Used by XMLTestRunner.
""" """
def __init__(self, stream=sys.stderr, descriptions=1, verbosity=1, \ def __init__(self, stream=sys.stderr, descriptions=1, verbosity=1,
elapsed_times=True): elapsed_times=True):
"Create a new instance of _XMLTestResult." "Create a new instance of _XMLTestResult."
_TextTestResult.__init__(self, stream, descriptions, verbosity) _TextTestResult.__init__(self, stream, descriptions, verbosity)
......
...@@ -3,7 +3,11 @@ ...@@ -3,7 +3,11 @@
# anywhere else in particular # anywhere else in particular
# #
import os, sys, re, codecs import os
import sys
import re
import io
import codecs
modification_time = os.path.getmtime modification_time = os.path.getmtime
...@@ -268,14 +272,6 @@ class NormalisedNewlineStream(object): ...@@ -268,14 +272,6 @@ class NormalisedNewlineStream(object):
raise NotImplementedError raise NotImplementedError
io = None
if sys.version_info >= (2,6):
try:
import io
except ImportError:
pass
def open_source_file(source_filename, mode="r", def open_source_file(source_filename, mode="r",
encoding=None, error_handling=None, encoding=None, error_handling=None,
require_normalised_newlines=True): 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