Commit a312c3ad authored by Neal Norwitz's avatar Neal Norwitz

Remove uses of string module and stat.ST_MODE

parent ec7cf138
...@@ -2,7 +2,6 @@ ...@@ -2,7 +2,6 @@
import dis import dis
import new import new
import string
import sys import sys
import types import types
...@@ -246,7 +245,7 @@ class Block: ...@@ -246,7 +245,7 @@ class Block:
def __str__(self): def __str__(self):
insts = map(str, self.insts) insts = map(str, self.insts)
return "<block %s %d:\n%s>" % (self.label, self.bid, return "<block %s %d:\n%s>" % (self.label, self.bid,
string.join(insts, '\n')) '\n'.join(insts))
def emit(self, inst): def emit(self, inst):
op = inst[0] op = inst[0]
...@@ -713,10 +712,10 @@ class LineAddrTable: ...@@ -713,10 +712,10 @@ class LineAddrTable:
self.lastoff = self.codeOffset self.lastoff = self.codeOffset
def getCode(self): def getCode(self):
return string.join(self.code, '') return ''.join(self.code)
def getTable(self): def getTable(self):
return string.join(map(chr, self.lnotab), '') return ''.join(map(chr, self.lnotab))
class StackDepthTracker: class StackDepthTracker:
# XXX 1. need to keep track of stack depth on jumps # XXX 1. need to keep track of stack depth on jumps
......
import imp import imp
import os import os
import marshal import marshal
import stat
import string
import struct import struct
import sys import sys
import types import types
...@@ -135,7 +133,7 @@ class Module(AbstractCompileMode): ...@@ -135,7 +133,7 @@ class Module(AbstractCompileMode):
# calling the interface that would also generate a 1-byte code # calling the interface that would also generate a 1-byte code
# to indicate the type of the value. simplest way to get the # to indicate the type of the value. simplest way to get the
# same effect is to call marshal and then skip the code. # same effect is to call marshal and then skip the code.
mtime = os.stat(self.filename)[stat.ST_MTIME] mtime = os.path.getmtime(self.filename)
mtime = struct.pack('i', mtime) mtime = struct.pack('i', mtime)
return self.MAGIC + mtime return self.MAGIC + mtime
...@@ -764,7 +762,7 @@ class CodeGenerator: ...@@ -764,7 +762,7 @@ class CodeGenerator:
if VERSION > 1: if VERSION > 1:
self.emit('LOAD_CONST', None) self.emit('LOAD_CONST', None)
self.emit('IMPORT_NAME', name) self.emit('IMPORT_NAME', name)
mod = string.split(name, ".")[0] mod = name.split(".")[0]
self.storeName(alias or mod) self.storeName(alias or mod)
def visitFrom(self, node): def visitFrom(self, node):
...@@ -790,7 +788,7 @@ class CodeGenerator: ...@@ -790,7 +788,7 @@ class CodeGenerator:
self.emit('POP_TOP') self.emit('POP_TOP')
def _resolveDots(self, name): def _resolveDots(self, name):
elts = string.split(name, ".") elts = name.split(".")
if len(elts) == 1: if len(elts) == 1:
return return
for elt in elts[1:]: for elt in elts[1:]:
......
...@@ -28,7 +28,6 @@ import parser ...@@ -28,7 +28,6 @@ import parser
# 1.5.2 for code branches executed in 1.5.2 # 1.5.2 for code branches executed in 1.5.2
import symbol import symbol
import token import token
import string
import sys import sys
error = 'walker.error' error = 'walker.error'
...@@ -111,7 +110,7 @@ class Transformer: ...@@ -111,7 +110,7 @@ class Transformer:
def parsesuite(self, text): def parsesuite(self, text):
"""Return a modified parse tree for the given suite text.""" """Return a modified parse tree for the given suite text."""
# Hack for handling non-native line endings on non-DOS like OSs. # Hack for handling non-native line endings on non-DOS like OSs.
text = string.replace(text, '\x0d', '') text = text.replace('\x0d', '')
return self.transform(parser.suite(text)) return self.transform(parser.suite(text))
def parseexpr(self, text): def parseexpr(self, text):
......
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