From 88fbaecec25731c543e92080cb4f1e8e9e21951d Mon Sep 17 00:00:00 2001 From: Stefan Behnel Date: Sat, 4 Jul 2009 08:08:08 +0200 Subject: [PATCH] Py3 code fixes --- Cython/Compiler/Parsing.py | 5 ++--- Cython/Plex/Errors.py | 4 +--- Cython/Plex/Machines.py | 3 +-- Cython/Plex/Regexps.py | 2 +- Cython/Plex/Transitions.py | 11 +++++------ 5 files changed, 10 insertions(+), 15 deletions(-) diff --git a/Cython/Compiler/Parsing.py b/Cython/Compiler/Parsing.py index 3566347c..44bc6774 100644 --- a/Cython/Compiler/Parsing.py +++ b/Cython/Compiler/Parsing.py @@ -10,7 +10,6 @@ cython.declare(Nodes=object, ExprNodes=object, EncodedString=object) import os import re import sys -from types import ListType, TupleType from Cython.Compiler.Scanning import PyrexScanner, FileSourceDescriptor import Nodes import ExprNodes @@ -2617,7 +2616,7 @@ def print_parse_tree(f, node, level, key = None): if key: f.write("%s: " % key) t = type(node) - if t == TupleType: + if t is tuple: f.write("(%s @ %s\n" % (node[0], node[1])) for i in xrange(2, len(node)): print_parse_tree(f, node[i], level+1) @@ -2633,7 +2632,7 @@ def print_parse_tree(f, node, level, key = None): if name != 'tag' and name != 'pos': print_parse_tree(f, value, level+1, name) return - elif t == ListType: + elif t is list: f.write("[\n") for i in xrange(len(node)): print_parse_tree(f, node[i], level+1) diff --git a/Cython/Plex/Errors.py b/Cython/Plex/Errors.py index ae033672..3c134735 100644 --- a/Cython/Plex/Errors.py +++ b/Cython/Plex/Errors.py @@ -6,9 +6,7 @@ # #======================================================================= -import exceptions - -class PlexError(exceptions.Exception): +class PlexError(Exception): message = "" class PlexTypeError(PlexError, TypeError): diff --git a/Cython/Plex/Machines.py b/Cython/Plex/Machines.py index 7bb068ef..ff8a14fb 100644 --- a/Cython/Plex/Machines.py +++ b/Cython/Plex/Machines.py @@ -8,7 +8,6 @@ import sys from sys import maxint -from types import TupleType from Transitions import TransitionMap @@ -169,7 +168,7 @@ class FastMachine(object): self.initial_states[name] = state def add_transitions(self, state, event, new_state): - if type(event) == TupleType: + if type(event) is tuple: code0, code1 = event if code0 == -maxint: state['else'] = new_state diff --git a/Cython/Plex/Regexps.py b/Cython/Plex/Regexps.py index cee03dbf..dea66b6e 100644 --- a/Cython/Plex/Regexps.py +++ b/Cython/Plex/Regexps.py @@ -8,7 +8,7 @@ import array import types -from sys import maxint +from sys import maxint as maxint import Errors diff --git a/Cython/Plex/Transitions.py b/Cython/Plex/Transitions.py index 66f7a316..6caff5ed 100644 --- a/Cython/Plex/Transitions.py +++ b/Cython/Plex/Transitions.py @@ -6,8 +6,7 @@ # from copy import copy -from sys import maxint -from types import TupleType +from sys import maxint as maxint class TransitionMap(object): """ @@ -50,11 +49,11 @@ class TransitionMap(object): #self.check() ### def add(self, event, new_state, - TupleType = TupleType): + TupleType = tuple): """ Add transition to |new_state| on |event|. """ - if type(event) == TupleType: + if type(event) is TupleType: code0, code1 = event i = self.split(code0) j = self.split(code1) @@ -66,11 +65,11 @@ class TransitionMap(object): self.get_special(event)[new_state] = 1 def add_set(self, event, new_set, - TupleType = TupleType): + TupleType = tuple): """ Add transitions to the states in |new_set| on |event|. """ - if type(event) == TupleType: + if type(event) is TupleType: code0, code1 = event i = self.split(code0) j = self.split(code1) -- 2.26.2