rem
stringlengths
1
322k
add
stringlengths
0
2.05M
context
stringlengths
4
228k
meta
stringlengths
156
215
def run (self):
ed8a0e0f21360abbe907a3b80e47c854a443eb13 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/ed8a0e0f21360abbe907a3b80e47c854a443eb13/install_lib.py
out_fn = string.replace (f, '.py', '.pyc')
out_fn = f + (__debug__ and "c" or "o") compile_msg = "byte-compiling %s to %s" % \ (f, os.path.basename (out_fn)) skip_msg = "byte-compilation of %s skipped" % f
def run (self):
ed8a0e0f21360abbe907a3b80e47c854a443eb13 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/ed8a0e0f21360abbe907a3b80e47c854a443eb13/install_lib.py
"byte-compiling %s" % f, "byte-compilation of %s skipped" % f)
compile_msg, skip_msg)
def run (self):
ed8a0e0f21360abbe907a3b80e47c854a443eb13 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/ed8a0e0f21360abbe907a3b80e47c854a443eb13/install_lib.py
def append(self, s, charset=None): """Append a string to the MIME header.
0c358258c9c4b61659867f7feb140a6ac0e54ed1 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/0c358258c9c4b61659867f7feb140a6ac0e54ed1/Header.py
def _encode_chunks(self): """MIME-encode a header with many different charsets and/or encodings. Given a list of pairs (string, charset), return a MIME-encoded string suitable for use in a header field. Each pair may have different charsets and/or encodings, and the resulting header will accurately reflect each setting. Each encoding can be email.Utils.QP (quoted-printable, for ASCII-like character sets like iso-8859-1), email.Utils.BASE64 (Base64, for non-ASCII like character sets like KOI8-R and iso-2022-jp), or None (no encoding). Each pair will be represented on a separate line; the resulting string will be in the format: "=?charset1?q?Mar=EDa_Gonz=E1lez_Alonso?=\n =?charset2?b?SvxyZ2VuIEL2aW5n?=" """
def _encode_chunks(self, newchunks):
def _encode_chunks(self): """MIME-encode a header with many different charsets and/or encodings.
0c358258c9c4b61659867f7feb140a6ac0e54ed1 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/0c358258c9c4b61659867f7feb140a6ac0e54ed1/Header.py
for header, charset in self._chunks:
for header, charset in newchunks:
def _encode_chunks(self): """MIME-encode a header with many different charsets and/or encodings.
0c358258c9c4b61659867f7feb140a6ac0e54ed1 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/0c358258c9c4b61659867f7feb140a6ac0e54ed1/Header.py
self._chunks = newchunks return self._encode_chunks()
return self._encode_chunks(newchunks)
def encode(self): """Encode a message header into an RFC-compliant format.
0c358258c9c4b61659867f7feb140a6ac0e54ed1 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/0c358258c9c4b61659867f7feb140a6ac0e54ed1/Header.py
self.local_hostname = local_hostname
self.local_hostname = local_hostname
def __init__(self, host = '', port = 0, local_hostname = None): """Initialize a new instance.
13e34f7a192d6f262a5bc000a3547c1d5ce59bee /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/13e34f7a192d6f262a5bc000a3547c1d5ce59bee/smtplib.py
self.local_hostname = socket.getfqdn()
fqdn = socket.getfqdn() if '.' in fqdn: self.local_hostname = fqdn else: addr = socket.gethostbyname(socket.gethostname()) self.local_hostname = '[%s]' % addr
def __init__(self, host = '', port = 0, local_hostname = None): """Initialize a new instance.
13e34f7a192d6f262a5bc000a3547c1d5ce59bee /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/13e34f7a192d6f262a5bc000a3547c1d5ce59bee/smtplib.py
return url2pathname(splithost(url1)[1]), None
return url2pathname(splithost(url1)[1]), hdrs
def retrieve(self, url, filename=None): url = unwrap(url) if self.tempcache and self.tempcache.has_key(url): return self.tempcache[url] type, url1 = splittype(url) if not filename and (not type or type == 'file'): try: fp = self.open_local_file(url1) del fp return url2pathname(splithost(url1)[1]), None except IOError, msg: pass fp = self.open(url) headers = fp.info() if not filename: import tempfile filename = tempfile.mktemp() self.__tempfiles.append(filename) result = filename, headers if self.tempcache is not None: self.tempcache[url] = result tfp = open(filename, 'wb') bs = 1024*8 block = fp.read(bs) while block: tfp.write(block) block = fp.read(bs) fp.close() tfp.close() del fp del tfp return result
b5916ab065408111cec262e12dbecbce58daf6ec /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/b5916ab065408111cec262e12dbecbce58daf6ec/urllib.py
filename = tempfile.mktemp()
garbage, path = splittype(url) print (garbage, path) garbage, path = splithost(path or "") print (garbage, path) path, garbage = splitquery(path or "") print (path, garbage) path, garbage = splitattr(path or "") print (path, garbage) suffix = os.path.splitext(path)[1] filename = tempfile.mktemp(suffix)
def retrieve(self, url, filename=None): url = unwrap(url) if self.tempcache and self.tempcache.has_key(url): return self.tempcache[url] type, url1 = splittype(url) if not filename and (not type or type == 'file'): try: fp = self.open_local_file(url1) del fp return url2pathname(splithost(url1)[1]), None except IOError, msg: pass fp = self.open(url) headers = fp.info() if not filename: import tempfile filename = tempfile.mktemp() self.__tempfiles.append(filename) result = filename, headers if self.tempcache is not None: self.tempcache[url] = result tfp = open(filename, 'wb') bs = 1024*8 block = fp.read(bs) while block: tfp.write(block) block = fp.read(bs) fp.close() tfp.close() del fp del tfp return result
b5916ab065408111cec262e12dbecbce58daf6ec /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/b5916ab065408111cec262e12dbecbce58daf6ec/urllib.py
noheaders(), 'file:'+file)
headers, 'file:'+file)
def open_local_file(self, url): host, file = splithost(url) if not host: return addinfourl( open(url2pathname(file), 'rb'), noheaders(), 'file:'+file) host, port = splitport(host) if not port and socket.gethostbyname(host) in ( localhost(), thishost()): file = unquote(file) return addinfourl( open(url2pathname(file), 'rb'), noheaders(), 'file:'+file) raise IOError, ('local file error', 'not on local host')
b5916ab065408111cec262e12dbecbce58daf6ec /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/b5916ab065408111cec262e12dbecbce58daf6ec/urllib.py
noheaders(), 'file:'+file)
headers, 'file:'+file)
def open_local_file(self, url): host, file = splithost(url) if not host: return addinfourl( open(url2pathname(file), 'rb'), noheaders(), 'file:'+file) host, port = splitport(host) if not port and socket.gethostbyname(host) in ( localhost(), thishost()): file = unquote(file) return addinfourl( open(url2pathname(file), 'rb'), noheaders(), 'file:'+file) raise IOError, ('local file error', 'not on local host')
b5916ab065408111cec262e12dbecbce58daf6ec /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/b5916ab065408111cec262e12dbecbce58daf6ec/urllib.py
{'message' : 'foo', 'args' : ('foo',)}),
{'message' : 'foo', 'args' : ('foo',), 'filename' : None, 'errno' : None, 'strerror' : None}),
def testAttributes(self): # test that exception attributes are happy
506cc189a97a468180ee18e4c4cd1b4e81242222 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/506cc189a97a468180ee18e4c4cd1b4e81242222/test_exceptions.py
{'message' : '', 'args' : ('foo', 'bar')}),
{'message' : '', 'args' : ('foo', 'bar'), 'filename' : None, 'errno' : 'foo', 'strerror' : 'bar'}),
def testAttributes(self): # test that exception attributes are happy
506cc189a97a468180ee18e4c4cd1b4e81242222 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/506cc189a97a468180ee18e4c4cd1b4e81242222/test_exceptions.py
{'message' : '', 'args' : ('foo', 'bar')}),
{'message' : '', 'args' : ('foo', 'bar'), 'filename' : 'baz', 'errno' : 'foo', 'strerror' : 'bar'}), (IOError, ('foo', 'bar', 'baz', 'quux'), {'message' : '', 'args' : ('foo', 'bar', 'baz', 'quux')}),
def testAttributes(self): # test that exception attributes are happy
506cc189a97a468180ee18e4c4cd1b4e81242222 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/506cc189a97a468180ee18e4c4cd1b4e81242222/test_exceptions.py
if module not in save_modules:
if module not in save_modules and module.startswith("test."):
def main(tests=None, testdir=None): """Execute a test suite. This also parses command-line options and modifies its behaviour accordingly. tests -- a list of strings containing test names (optional) testdir -- the directory in which to look for tests (optional) Users other than the Python test suite will certainly want to specify testdir; if it's omitted, the directory containing the Python test suite is searched for. If the tests argument is omitted, the tests listed on the command-line will be used. If that's empty, too, then all *.py files beginning with test_ will be used. """ try: opts, args = getopt.getopt(sys.argv[1:], 'vgqxs') except getopt.error, msg: print msg print __doc__ return 2 verbose = 0 quiet = 0 generate = 0 exclude = 0 single = 0 for o, a in opts: if o == '-v': verbose = verbose+1 if o == '-q': quiet = 1; verbose = 0 if o == '-g': generate = 1 if o == '-x': exclude = 1 if o == '-s': single = 1 if generate and verbose: print "-g and -v don't go together!" return 2 good = [] bad = [] skipped = [] if single: from tempfile import gettempdir filename = os.path.join(gettempdir(), 'pynexttest') try: fp = open(filename, 'r') next = string.strip(fp.read()) tests = [next] fp.close() except IOError: pass for i in range(len(args)): # Strip trailing ".py" from arguments if args[i][-3:] == '.py': args[i] = args[i][:-3] stdtests = STDTESTS[:] nottests = NOTTESTS[:] if exclude: for arg in args: if arg in stdtests: stdtests.remove(arg) nottests[:0] = args args = [] tests = tests or args or findtests(testdir, stdtests, nottests) if single: tests = tests[:1] test_support.verbose = verbose # Tell tests to be moderately quiet save_modules = sys.modules.keys() for test in tests: if not quiet: print test ok = runtest(test, generate, verbose, testdir) if ok > 0: good.append(test) elif ok == 0: bad.append(test) else: if not quiet: print "test", test, print "skipped -- an optional feature could not be imported" skipped.append(test) # Unload the newly imported modules (best effort finalization) for module in sys.modules.keys(): if module not in save_modules: test_support.unload(module) if good and not quiet: if not bad and not skipped and len(good) > 1: print "All", print count(len(good), "test"), "OK." if bad: print count(len(bad), "test"), "failed:", print string.join(bad) if skipped and not quiet: print count(len(skipped), "test"), "skipped:", print string.join(skipped) if single: alltests = findtests(testdir, stdtests, nottests) for i in range(len(alltests)): if tests[0] == alltests[i]: if i == len(alltests) - 1: os.unlink(filename) else: fp = open(filename, 'w') fp.write(alltests[i+1] + '\n') fp.close() break else: os.unlink(filename) return len(bad) > 0
51931144427faa001a6db3cfc37380526be256b6 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/51931144427faa001a6db3cfc37380526be256b6/regrtest.py
input = text_file.TextFile('Modules/Setup', join_lines=1)
def build_extensions(self):
e08fa29d0e5bf02006ae30d79c31a6fd02d62068 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/e08fa29d0e5bf02006ae30d79c31a6fd02d62068/setup.py
while 1: line = input.readline() if not line: break line = line.split() remove_modules.append( line[0] ) input.close()
for filename in ('Modules/Setup', 'Modules/Setup.local'): input = text_file.TextFile(filename, join_lines=1) while 1: line = input.readline() if not line: break line = line.split() remove_modules.append(line[0]) input.close()
def build_extensions(self):
e08fa29d0e5bf02006ae30d79c31a6fd02d62068 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/e08fa29d0e5bf02006ae30d79c31a6fd02d62068/setup.py
'HTTPS'))
'HTTPS', 'HTTP11'))
def test_others(self): cm = self.checkModule
547a3167be9a49ce1199be00544011707d367d6f /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/547a3167be9a49ce1199be00544011707d367d6f/test_pyclbr.py
usage(2, msg)
usage(msg) return 2
def main(): try: opts, args = getopt.getopt(sys.argv[1:], "h") except getopt.error, msg: usage(2, msg) for o, a in opts: if o == "-h": help() if not args: usage(2, "at least one file argument is required") if args[1:]: sys.stderr.write("%s: extra file arguments ignored\n", sys.argv[0]) readwarnings(args[0])
13c51ecb8c5b70f83f746db9af759b9d6a590769 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/13c51ecb8c5b70f83f746db9af759b9d6a590769/fixdiv.py
help()
print __doc__ return
def main(): try: opts, args = getopt.getopt(sys.argv[1:], "h") except getopt.error, msg: usage(2, msg) for o, a in opts: if o == "-h": help() if not args: usage(2, "at least one file argument is required") if args[1:]: sys.stderr.write("%s: extra file arguments ignored\n", sys.argv[0]) readwarnings(args[0])
13c51ecb8c5b70f83f746db9af759b9d6a590769 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/13c51ecb8c5b70f83f746db9af759b9d6a590769/fixdiv.py
usage(2, "at least one file argument is required")
usage("at least one file argument is required") return 2
def main(): try: opts, args = getopt.getopt(sys.argv[1:], "h") except getopt.error, msg: usage(2, msg) for o, a in opts: if o == "-h": help() if not args: usage(2, "at least one file argument is required") if args[1:]: sys.stderr.write("%s: extra file arguments ignored\n", sys.argv[0]) readwarnings(args[0])
13c51ecb8c5b70f83f746db9af759b9d6a590769 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/13c51ecb8c5b70f83f746db9af759b9d6a590769/fixdiv.py
readwarnings(args[0]) def usage(exit, msg=None): if msg: sys.stderr.write("%s: %s\n" % (sys.argv[0], msg))
warnings = readwarnings(args[0]) if warnings is None: return 1 files = warnings.keys() if not files: print "No classic division warnings read from", args[0] return files.sort() exit = None for file in files: x = process(file, warnings[file]) exit = exit or x return exit def usage(msg): sys.stderr.write("%s: %s\n" % (sys.argv[0], msg))
def main(): try: opts, args = getopt.getopt(sys.argv[1:], "h") except getopt.error, msg: usage(2, msg) for o, a in opts: if o == "-h": help() if not args: usage(2, "at least one file argument is required") if args[1:]: sys.stderr.write("%s: extra file arguments ignored\n", sys.argv[0]) readwarnings(args[0])
13c51ecb8c5b70f83f746db9af759b9d6a590769 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/13c51ecb8c5b70f83f746db9af759b9d6a590769/fixdiv.py
sys.exit(exit) def help(): print __doc__ sys.exit(0)
PATTERN = ("^(.+?):(\d+): DeprecationWarning: " "classic (int|long|float|complex) division$")
def usage(exit, msg=None): if msg: sys.stderr.write("%s: %s\n" % (sys.argv[0], msg)) sys.stderr.write("Usage: %s warnings\n" % sys.argv[0]) sys.stderr.write("Try `%s -h' for more information.\n" % sys.argv[0]) sys.exit(exit)
13c51ecb8c5b70f83f746db9af759b9d6a590769 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/13c51ecb8c5b70f83f746db9af759b9d6a590769/fixdiv.py
pat = re.compile( "^(.+?):(\d+): DeprecationWarning: classic ([a-z]+) division$")
prog = re.compile(PATTERN)
def readwarnings(warningsfile): pat = re.compile( "^(.+?):(\d+): DeprecationWarning: classic ([a-z]+) division$") try: f = open(warningsfile) except IOError, msg: sys.stderr.write("can't open: %s\n" % msg) return warnings = {} while 1: line = f.readline() if not line: break m = pat.match(line) if not m: if line.find("division") >= 0: sys.stderr.write("Warning: ignored input " + line) continue file, lineno, what = m.groups() list = warnings.get(file) if list is None: warnings[file] = list = [] list.append((int(lineno), intern(what))) f.close() files = warnings.keys() files.sort() for file in files: process(file, warnings[file])
13c51ecb8c5b70f83f746db9af759b9d6a590769 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/13c51ecb8c5b70f83f746db9af759b9d6a590769/fixdiv.py
m = pat.match(line)
m = prog.match(line)
def readwarnings(warningsfile): pat = re.compile( "^(.+?):(\d+): DeprecationWarning: classic ([a-z]+) division$") try: f = open(warningsfile) except IOError, msg: sys.stderr.write("can't open: %s\n" % msg) return warnings = {} while 1: line = f.readline() if not line: break m = pat.match(line) if not m: if line.find("division") >= 0: sys.stderr.write("Warning: ignored input " + line) continue file, lineno, what = m.groups() list = warnings.get(file) if list is None: warnings[file] = list = [] list.append((int(lineno), intern(what))) f.close() files = warnings.keys() files.sort() for file in files: process(file, warnings[file])
13c51ecb8c5b70f83f746db9af759b9d6a590769 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/13c51ecb8c5b70f83f746db9af759b9d6a590769/fixdiv.py
files = warnings.keys() files.sort() for file in files: process(file, warnings[file])
return warnings
def readwarnings(warningsfile): pat = re.compile( "^(.+?):(\d+): DeprecationWarning: classic ([a-z]+) division$") try: f = open(warningsfile) except IOError, msg: sys.stderr.write("can't open: %s\n" % msg) return warnings = {} while 1: line = f.readline() if not line: break m = pat.match(line) if not m: if line.find("division") >= 0: sys.stderr.write("Warning: ignored input " + line) continue file, lineno, what = m.groups() list = warnings.get(file) if list is None: warnings[file] = list = [] list.append((int(lineno), intern(what))) f.close() files = warnings.keys() files.sort() for file in files: process(file, warnings[file])
13c51ecb8c5b70f83f746db9af759b9d6a590769 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/13c51ecb8c5b70f83f746db9af759b9d6a590769/fixdiv.py
if not list: sys.stderr.write("no division warnings for %s\n" % file) return
assert list
def process(file, list): print "-"*70 if not list: sys.stderr.write("no division warnings for %s\n" % file) return try: fp = open(file) except IOError, msg: sys.stderr.write("can't open: %s\n" % msg) return print "Processing:", file f = FileContext(fp) list.sort() index = 0 # list[:index] has been processed, list[index:] is still to do orphans = [] # subset of list for which no / operator was found unknown = [] # lines with / operators for which no warnings were seen g = tokenize.generate_tokens(f.readline) while 1: startlineno, endlineno, slashes = lineinfo = scanline(g) if startlineno is None: break assert startlineno <= endlineno is not None while index < len(list) and list[index][0] < startlineno: orphans.append(list[index]) index += 1 warnings = [] while index < len(list) and list[index][0] <= endlineno: warnings.append(list[index]) index += 1 if not slashes and not warnings: pass elif slashes and not warnings: report(slashes, "Unexecuted code") elif warnings and not slashes: reportphantomwarnings(warnings, f) else: if len(slashes) > 1: report(slashes, "More than one / operator") else: (row, col), line = slashes[0] line = chop(line) if line[col:col+1] != "/": print "*** Can't find the / operator in line %d:" % row print "*", line continue intlong = [] floatcomplex = [] bad = [] for lineno, what in warnings: if what in ("int", "long"): intlong.append(what) elif what in ("float", "complex"): floatcomplex.append(what) else: bad.append(what) if bad: print "*** Bad warning for line %d:" % row, bad print "*", line elif intlong and not floatcomplex: print "%dc%d" % (row, row) print "<", line print "---" print ">", line[:col] + "/" + line[col:] elif floatcomplex and not intlong: print "True division / operator at line %d:" % row print "=", line fp.close()
13c51ecb8c5b70f83f746db9af759b9d6a590769 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/13c51ecb8c5b70f83f746db9af759b9d6a590769/fixdiv.py
return print "Processing:", file
return 1 print "Index:", file
def process(file, list): print "-"*70 if not list: sys.stderr.write("no division warnings for %s\n" % file) return try: fp = open(file) except IOError, msg: sys.stderr.write("can't open: %s\n" % msg) return print "Processing:", file f = FileContext(fp) list.sort() index = 0 # list[:index] has been processed, list[index:] is still to do orphans = [] # subset of list for which no / operator was found unknown = [] # lines with / operators for which no warnings were seen g = tokenize.generate_tokens(f.readline) while 1: startlineno, endlineno, slashes = lineinfo = scanline(g) if startlineno is None: break assert startlineno <= endlineno is not None while index < len(list) and list[index][0] < startlineno: orphans.append(list[index]) index += 1 warnings = [] while index < len(list) and list[index][0] <= endlineno: warnings.append(list[index]) index += 1 if not slashes and not warnings: pass elif slashes and not warnings: report(slashes, "Unexecuted code") elif warnings and not slashes: reportphantomwarnings(warnings, f) else: if len(slashes) > 1: report(slashes, "More than one / operator") else: (row, col), line = slashes[0] line = chop(line) if line[col:col+1] != "/": print "*** Can't find the / operator in line %d:" % row print "*", line continue intlong = [] floatcomplex = [] bad = [] for lineno, what in warnings: if what in ("int", "long"): intlong.append(what) elif what in ("float", "complex"): floatcomplex.append(what) else: bad.append(what) if bad: print "*** Bad warning for line %d:" % row, bad print "*", line elif intlong and not floatcomplex: print "%dc%d" % (row, row) print "<", line print "---" print ">", line[:col] + "/" + line[col:] elif floatcomplex and not intlong: print "True division / operator at line %d:" % row print "=", line fp.close()
13c51ecb8c5b70f83f746db9af759b9d6a590769 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/13c51ecb8c5b70f83f746db9af759b9d6a590769/fixdiv.py
orphans = [] unknown = []
def process(file, list): print "-"*70 if not list: sys.stderr.write("no division warnings for %s\n" % file) return try: fp = open(file) except IOError, msg: sys.stderr.write("can't open: %s\n" % msg) return print "Processing:", file f = FileContext(fp) list.sort() index = 0 # list[:index] has been processed, list[index:] is still to do orphans = [] # subset of list for which no / operator was found unknown = [] # lines with / operators for which no warnings were seen g = tokenize.generate_tokens(f.readline) while 1: startlineno, endlineno, slashes = lineinfo = scanline(g) if startlineno is None: break assert startlineno <= endlineno is not None while index < len(list) and list[index][0] < startlineno: orphans.append(list[index]) index += 1 warnings = [] while index < len(list) and list[index][0] <= endlineno: warnings.append(list[index]) index += 1 if not slashes and not warnings: pass elif slashes and not warnings: report(slashes, "Unexecuted code") elif warnings and not slashes: reportphantomwarnings(warnings, f) else: if len(slashes) > 1: report(slashes, "More than one / operator") else: (row, col), line = slashes[0] line = chop(line) if line[col:col+1] != "/": print "*** Can't find the / operator in line %d:" % row print "*", line continue intlong = [] floatcomplex = [] bad = [] for lineno, what in warnings: if what in ("int", "long"): intlong.append(what) elif what in ("float", "complex"): floatcomplex.append(what) else: bad.append(what) if bad: print "*** Bad warning for line %d:" % row, bad print "*", line elif intlong and not floatcomplex: print "%dc%d" % (row, row) print "<", line print "---" print ">", line[:col] + "/" + line[col:] elif floatcomplex and not intlong: print "True division / operator at line %d:" % row print "=", line fp.close()
13c51ecb8c5b70f83f746db9af759b9d6a590769 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/13c51ecb8c5b70f83f746db9af759b9d6a590769/fixdiv.py
report(slashes, "Unexecuted code")
report(slashes, "No conclusive evidence")
def process(file, list): print "-"*70 if not list: sys.stderr.write("no division warnings for %s\n" % file) return try: fp = open(file) except IOError, msg: sys.stderr.write("can't open: %s\n" % msg) return print "Processing:", file f = FileContext(fp) list.sort() index = 0 # list[:index] has been processed, list[index:] is still to do orphans = [] # subset of list for which no / operator was found unknown = [] # lines with / operators for which no warnings were seen g = tokenize.generate_tokens(f.readline) while 1: startlineno, endlineno, slashes = lineinfo = scanline(g) if startlineno is None: break assert startlineno <= endlineno is not None while index < len(list) and list[index][0] < startlineno: orphans.append(list[index]) index += 1 warnings = [] while index < len(list) and list[index][0] <= endlineno: warnings.append(list[index]) index += 1 if not slashes and not warnings: pass elif slashes and not warnings: report(slashes, "Unexecuted code") elif warnings and not slashes: reportphantomwarnings(warnings, f) else: if len(slashes) > 1: report(slashes, "More than one / operator") else: (row, col), line = slashes[0] line = chop(line) if line[col:col+1] != "/": print "*** Can't find the / operator in line %d:" % row print "*", line continue intlong = [] floatcomplex = [] bad = [] for lineno, what in warnings: if what in ("int", "long"): intlong.append(what) elif what in ("float", "complex"): floatcomplex.append(what) else: bad.append(what) if bad: print "*** Bad warning for line %d:" % row, bad print "*", line elif intlong and not floatcomplex: print "%dc%d" % (row, row) print "<", line print "---" print ">", line[:col] + "/" + line[col:] elif floatcomplex and not intlong: print "True division / operator at line %d:" % row print "=", line fp.close()
13c51ecb8c5b70f83f746db9af759b9d6a590769 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/13c51ecb8c5b70f83f746db9af759b9d6a590769/fixdiv.py
def scanline(g): slashes = [] startlineno = None endlineno = None for type, token, start, end, line in g: endlineno = end[0] if startlineno is None: startlineno = endlineno if token in ("/", "/="): slashes.append((start, line)) ## if type in (tokenize.NEWLINE, tokenize.NL, tokenize.COMMENT): if type == tokenize.NEWLINE: break return startlineno, endlineno, slashes
13c51ecb8c5b70f83f746db9af759b9d6a590769 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/13c51ecb8c5b70f83f746db9af759b9d6a590769/fixdiv.py
main()
sys.exit(main())
def chop(line): if line.endswith("\n"): return line[:-1] else: return line
13c51ecb8c5b70f83f746db9af759b9d6a590769 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/13c51ecb8c5b70f83f746db9af759b9d6a590769/fixdiv.py
__slots__ = ['_hash']
__slots__ = ['_hashcode']
def _compute_hash(self): # Calculate hash code for a set by xor'ing the hash codes of # the elements. This algorithm ensures that the hash code # does not depend on the order in which elements are added to # the code. This is not called __hash__ because a BaseSet # should not be hashable; only an ImmutableSet is hashable. result = 0 for elt in self: result ^= hash(elt) return result
0b650d756572e33c923eb4998224da2d95dffaac /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/0b650d756572e33c923eb4998224da2d95dffaac/sets.py
def buffer_inherit(): import binascii if verbose: print "Testing that buffer interface is inherited ..." class MyStr(str): pass base = 'abc' m = MyStr(base) vereq(binascii.b2a_hex(m), binascii.b2a_hex(base)) class MyUni(unicode): pass base = u'abc' m = MyUni(base) vereq(binascii.b2a_hex(m), binascii.b2a_hex(base)) class MyInt(int): pass m = MyInt(42) try: binascii.b2a_hex(m) raise TestFailed('subclass of int should not have a buffer interface') except TypeError: pass
def __getattr__(self, name): if name in ("spam", "foo", "bar"): return "hello" raise AttributeError, name
fc57ccb98248b4a8f4ba4debdf3791970b136c4d /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/fc57ccb98248b4a8f4ba4debdf3791970b136c4d/test_descr.py
Technically, only a <mailbox> is allowed. In addition, email addresses without a domain are permitted. Addresses will not be modified if they are already quoted (actually if they begin with '<' and end with '>'.""" if re.match('(?s)\A<.*>\Z', addr):
Should be able to handle anything rfc822.parseaddr can handle.""" m=None try: m=rfc822.parseaddr(addr)[1] except AttributeError: pass if not m:
def quoteaddr(addr): """Quote a subset of the email addresses defined by RFC 821. Technically, only a <mailbox> is allowed. In addition, email addresses without a domain are permitted. Addresses will not be modified if they are already quoted (actually if they begin with '<' and end with '>'.""" if re.match('(?s)\A<.*>\Z', addr): return addr localpart = None domain = '' try: at = string.rindex(addr, '@') localpart = addr[:at] domain = addr[at:] except ValueError: localpart = addr pat = re.compile(r'([<>()\[\]\\,;:@\"\001-\037\177])') return '<%s%s>' % (pat.sub(r'\\\1', localpart), domain)
fcfb6323fb0030467d67b071654b342b7725727f /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/fcfb6323fb0030467d67b071654b342b7725727f/smtplib.py
localpart = None domain = '' try: at = string.rindex(addr, '@') localpart = addr[:at] domain = addr[at:] except ValueError: localpart = addr pat = re.compile(r'([<>()\[\]\\,;:@\"\001-\037\177])') return '<%s%s>' % (pat.sub(r'\\\1', localpart), domain)
else: return "<%s>" % m
def quoteaddr(addr): """Quote a subset of the email addresses defined by RFC 821. Technically, only a <mailbox> is allowed. In addition, email addresses without a domain are permitted. Addresses will not be modified if they are already quoted (actually if they begin with '<' and end with '>'.""" if re.match('(?s)\A<.*>\Z', addr): return addr localpart = None domain = '' try: at = string.rindex(addr, '@') localpart = addr[:at] domain = addr[at:] except ValueError: localpart = addr pat = re.compile(r'([<>()\[\]\\,;:@\"\001-\037\177])') return '<%s%s>' % (pat.sub(r'\\\1', localpart), domain)
fcfb6323fb0030467d67b071654b342b7725727f /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/fcfb6323fb0030467d67b071654b342b7725727f/smtplib.py
Double leading '.', and change Unix newline '\n' into
Double leading '.', and change Unix newline '\n', or Mac '\r' into
def quotedata(data): """Quote data for email. Double leading '.', and change Unix newline '\n' into Internet CRLF end-of-line.""" return re.sub(r'(?m)^\.', '..', re.sub(r'\r?\n', CRLF, data))
fcfb6323fb0030467d67b071654b342b7725727f /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/fcfb6323fb0030467d67b071654b342b7725727f/smtplib.py
re.sub(r'\r?\n', CRLF, data))
re.sub(r'(?:\r\n|\n|\r(?!\n))', CRLF, data))
def quotedata(data): """Quote data for email. Double leading '.', and change Unix newline '\n' into Internet CRLF end-of-line.""" return re.sub(r'(?m)^\.', '..', re.sub(r'\r?\n', CRLF, data))
fcfb6323fb0030467d67b071654b342b7725727f /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/fcfb6323fb0030467d67b071654b342b7725727f/smtplib.py
"""This class manages a connection to an SMTP or ESMTP server."""
"""This class manages a connection to an SMTP or ESMTP server. SMTP Objects: SMTP objects have the following attributes: helo_resp This is the message given by the server in responce to the most recent HELO command. ehlo_resp This is the message given by the server in responce to the most recent EHLO command. This is usually multiline. does_esmtp This is a True value _after you do an EHLO command_, if the server supports ESMTP. esmtp_features This is a dictionary, which, if the server supports ESMTP, will _after you do an EHLO command_, contain the names of the SMTP service extentions this server supports, and their parameters (if any). Note, all extention names are mapped to lower case in the dictionary. For method docs, see each method's docstrings. In general, there is a method of the same name to preform each SMTP comand, and there is a method called 'sendmail' that will do an entiere mail transaction."""
def quotedata(data): """Quote data for email. Double leading '.', and change Unix newline '\n' into Internet CRLF end-of-line.""" return re.sub(r'(?m)^\.', '..', re.sub(r'\r?\n', CRLF, data))
fcfb6323fb0030467d67b071654b342b7725727f /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/fcfb6323fb0030467d67b071654b342b7725727f/smtplib.py
esmtp_features = []
does_esmtp = 0
def quotedata(data): """Quote data for email. Double leading '.', and change Unix newline '\n' into Internet CRLF end-of-line.""" return re.sub(r'(?m)^\.', '..', re.sub(r'\r?\n', CRLF, data))
fcfb6323fb0030467d67b071654b342b7725727f /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/fcfb6323fb0030467d67b071654b342b7725727f/smtplib.py
def verify(self, address): """ SMTP 'verify' command. Checks for address validity. """ self.putcmd("vrfy", address) return self.getreply()
def verify(self, address): """ SMTP 'verify' command. Checks for address validity. """ self.putcmd("vrfy", address) return self.getreply()
fcfb6323fb0030467d67b071654b342b7725727f /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/fcfb6323fb0030467d67b071654b342b7725727f/smtplib.py
that suffix will be stripped off and the number interpreted as the port number to use.
and there is no port specified, that suffix will be stripped off and the number interpreted as the port number to use.
def connect(self, host='localhost', port = 0): """Connect to a host on a given port.
fcfb6323fb0030467d67b071654b342b7725727f /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/fcfb6323fb0030467d67b071654b342b7725727f/smtplib.py
self.sock.send(str)
try: self.sock.send(str) except socket.error: raise SMTPServerDisconnected
def send(self, str): """Send `str' to the server.""" if self.debuglevel > 0: print 'send:', `str` if self.sock: self.sock.send(str) else: raise SMTPServerDisconnected
fcfb6323fb0030467d67b071654b342b7725727f /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/fcfb6323fb0030467d67b071654b342b7725727f/smtplib.py
def getreply(self, linehook=None):
def getreply(self):
def getreply(self, linehook=None): """Get a reply from the server. Returns a tuple consisting of: - server response code (e.g. '250', or such, if all goes well) Note: returns -1 if it can't read response code. - server response string corresponding to response code (note : multiline responses converted to a single, multiline string) """ resp=[] self.file = self.sock.makefile('rb') while 1: line = self.file.readline() if self.debuglevel > 0: print 'reply:', `line` resp.append(string.strip(line[4:])) code=line[:3] #check if multiline resp if line[3:4]!="-": break elif linehook: linehook(line) try: errcode = string.atoi(code) except(ValueError): errcode = -1
fcfb6323fb0030467d67b071654b342b7725727f /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/fcfb6323fb0030467d67b071654b342b7725727f/smtplib.py
elif linehook: linehook(line)
def getreply(self, linehook=None): """Get a reply from the server. Returns a tuple consisting of: - server response code (e.g. '250', or such, if all goes well) Note: returns -1 if it can't read response code. - server response string corresponding to response code (note : multiline responses converted to a single, multiline string) """ resp=[] self.file = self.sock.makefile('rb') while 1: line = self.file.readline() if self.debuglevel > 0: print 'reply:', `line` resp.append(string.strip(line[4:])) code=line[:3] #check if multiline resp if line[3:4]!="-": break elif linehook: linehook(line) try: errcode = string.atoi(code) except(ValueError): errcode = -1
fcfb6323fb0030467d67b071654b342b7725727f /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/fcfb6323fb0030467d67b071654b342b7725727f/smtplib.py
defaults to the FQDN of the local host """
defaults to the FQDN of the local host. """
def ehlo(self, name=''): """ SMTP 'ehlo' command. Hostname to send for this command defaults to the FQDN of the local host """ name=string.strip(name) if len(name)==0: name=socket.gethostbyaddr(socket.gethostname())[0] self.putcmd("ehlo",name) (code,msg)=self.getreply(self.ehlo_hook) self.ehlo_resp=msg return code
fcfb6323fb0030467d67b071654b342b7725727f /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/fcfb6323fb0030467d67b071654b342b7725727f/smtplib.py
(code,msg)=self.getreply(self.ehlo_hook)
(code,msg)=self.getreply() if code == -1 and len(msg) == 0: raise SMTPServerDisconnected
def ehlo(self, name=''): """ SMTP 'ehlo' command. Hostname to send for this command defaults to the FQDN of the local host """ name=string.strip(name) if len(name)==0: name=socket.gethostbyaddr(socket.gethostname())[0] self.putcmd("ehlo",name) (code,msg)=self.getreply(self.ehlo_hook) self.ehlo_resp=msg return code
fcfb6323fb0030467d67b071654b342b7725727f /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/fcfb6323fb0030467d67b071654b342b7725727f/smtplib.py
def ehlo_hook(self, line): if line[4] in string.uppercase+string.digits: self.esmtp_features.append(string.lower(string.strip(line)[4:])) def has_option(self, opt): """Does the server support a given SMTP option?""" return opt in self.esmtp_features
def has_extn(self, opt): """Does the server support a given SMTP service extension?""" return self.esmtp_features.has_key(string.lower(opt))
def ehlo_hook(self, line): # Interpret EHLO response lines if line[4] in string.uppercase+string.digits: self.esmtp_features.append(string.lower(string.strip(line)[4:]))
fcfb6323fb0030467d67b071654b342b7725727f /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/fcfb6323fb0030467d67b071654b342b7725727f/smtplib.py
if options: options = " " + string.joinfields(options, ' ') else: options = '' self.putcmd("mail", "from:" + quoteaddr(sender) + options)
optionlist = '' if options and self.does_esmtp: optionlist = string.join(options, ' ') self.putcmd("mail", "FROM:%s %s" % (quoteaddr(sender) ,optionlist))
def mail(self,sender,options=[]): """ SMTP 'mail' command. Begins mail xfer session. """ if options: options = " " + string.joinfields(options, ' ') else: options = '' self.putcmd("mail", "from:" + quoteaddr(sender) + options) return self.getreply()
fcfb6323fb0030467d67b071654b342b7725727f /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/fcfb6323fb0030467d67b071654b342b7725727f/smtplib.py
def rcpt(self,recip):
def rcpt(self,recip,options=[]):
def rcpt(self,recip): """ SMTP 'rcpt' command. Indicates 1 recipient for this mail. """ self.putcmd("rcpt","to:%s" % quoteaddr(recip)) return self.getreply()
fcfb6323fb0030467d67b071654b342b7725727f /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/fcfb6323fb0030467d67b071654b342b7725727f/smtplib.py
self.putcmd("rcpt","to:%s" % quoteaddr(recip))
optionlist = '' if options and self.does_esmtp: optionlist = string.join(options, ' ') self.putcmd("rcpt","TO:%s %s" % (quoteaddr(recip),optionlist))
def rcpt(self,recip): """ SMTP 'rcpt' command. Indicates 1 recipient for this mail. """ self.putcmd("rcpt","to:%s" % quoteaddr(recip)) return self.getreply()
fcfb6323fb0030467d67b071654b342b7725727f /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/fcfb6323fb0030467d67b071654b342b7725727f/smtplib.py
def sendmail(self,from_addr,to_addrs,msg,options=[]):
def sendmail(self,from_addr,to_addrs,msg,mail_options=[],rcpt_options=[]):
def sendmail(self,from_addr,to_addrs,msg,options=[]): """ This command performs an entire mail transaction. The arguments are: - from_addr : The address sending this mail. - to_addrs : a list of addresses to send this mail to - msg : the message to send. - encoding : list of ESMTP options (such as 8bitmime)
fcfb6323fb0030467d67b071654b342b7725727f /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/fcfb6323fb0030467d67b071654b342b7725727f/smtplib.py
- encoding : list of ESMTP options (such as 8bitmime)
- mail_options : list of ESMTP options (such as 8bitmime) for the mail command - rcpt_options : List of ESMTP options (such as DSN commands) for all the rcpt commands
def sendmail(self,from_addr,to_addrs,msg,options=[]): """ This command performs an entire mail transaction. The arguments are: - from_addr : The address sending this mail. - to_addrs : a list of addresses to send this mail to - msg : the message to send. - encoding : list of ESMTP options (such as 8bitmime)
fcfb6323fb0030467d67b071654b342b7725727f /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/fcfb6323fb0030467d67b071654b342b7725727f/smtplib.py
size and each of the specified options will be passed to it (if the option is in the feature set the server advertises). If EHLO fails, HELO will be tried and ESMTP options suppressed.
size and each of the specified options will be passed to it. If EHLO fails, HELO will be tried and ESMTP options suppressed.
def sendmail(self,from_addr,to_addrs,msg,options=[]): """ This command performs an entire mail transaction. The arguments are: - from_addr : The address sending this mail. - to_addrs : a list of addresses to send this mail to - msg : the message to send. - encoding : list of ESMTP options (such as 8bitmime)
fcfb6323fb0030467d67b071654b342b7725727f /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/fcfb6323fb0030467d67b071654b342b7725727f/smtplib.py
if self.esmtp_features: self.esmtp_features.append('7bit')
def sendmail(self,from_addr,to_addrs,msg,options=[]): """ This command performs an entire mail transaction. The arguments are: - from_addr : The address sending this mail. - to_addrs : a list of addresses to send this mail to - msg : the message to send. - encoding : list of ESMTP options (such as 8bitmime)
fcfb6323fb0030467d67b071654b342b7725727f /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/fcfb6323fb0030467d67b071654b342b7725727f/smtplib.py
if 'size' in self.esmtp_features: esmtp_opts.append("size=" + `len(msg)`) for option in options: if option in self.esmtp_features:
if self.does_esmtp: if self.has_extn('size'): esmtp_opts.append("size=" + `len(msg)`) for option in mail_options:
def sendmail(self,from_addr,to_addrs,msg,options=[]): """ This command performs an entire mail transaction. The arguments are: - from_addr : The address sending this mail. - to_addrs : a list of addresses to send this mail to - msg : the message to send. - encoding : list of ESMTP options (such as 8bitmime)
fcfb6323fb0030467d67b071654b342b7725727f /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/fcfb6323fb0030467d67b071654b342b7725727f/smtplib.py
(code,resp)=self.rcpt(each)
(code,resp)=self.rcpt(each, rcpt_options)
def sendmail(self,from_addr,to_addrs,msg,options=[]): """ This command performs an entire mail transaction. The arguments are: - from_addr : The address sending this mail. - to_addrs : a list of addresses to send this mail to - msg : the message to send. - encoding : list of ESMTP options (such as 8bitmime)
fcfb6323fb0030467d67b071654b342b7725727f /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/fcfb6323fb0030467d67b071654b342b7725727f/smtplib.py
c = cmp(dict1, dict2)
if random.random() < 0.5: c = cmp(dict1, dict2) else: c = dict1 == dict2
def test_one(n): global mutate, dict1, dict2, dict1keys, dict2keys # Fill the dicts without mutating them. mutate = 0 dict1keys = fill_dict(dict1, range(n), n) dict2keys = fill_dict(dict2, range(n), n) # Enable mutation, then compare the dicts so long as they have the # same size. mutate = 1 if verbose: print "trying w/ lengths", len(dict1), len(dict2), while dict1 and len(dict1) == len(dict2): if verbose: print ".", c = cmp(dict1, dict2) if verbose: print
d3da7d394a64f3894b625842da4e5cc2f13bac08 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/d3da7d394a64f3894b625842da4e5cc2f13bac08/test_mutants.py
all, scheme, rfc, selfdot, name = match.groups()
all, scheme, rfc, pep, selfdot, name = match.groups()
def markup(self, text, escape=None, funcs={}, classes={}, methods={}): """Mark up some plain text, given a context of symbols to look for. Each context dictionary maps object names to anchor names.""" escape = escape or self.escape results = [] here = 0 pattern = re.compile(r'\b((http|ftp)://\S+[\w/]|' r'RFC[- ]?(\d+)|' r'(self\.)?(\w+))\b') while 1: match = pattern.search(text, here) if not match: break start, end = match.span() results.append(escape(text[here:start]))
f78a81b47baa04c78ca29ff4f4a8236297e852a0 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/f78a81b47baa04c78ca29ff4f4a8236297e852a0/pydoc.py
url = 'http://www.rfc-editor.org/rfc/rfc%s.txt' % rfc
url = 'http://www.rfc-editor.org/rfc/rfc%d.txt' % int(rfc) results.append('<a href="%s">%s</a>' % (url, escape(all))) elif pep: url = 'http://www.python.org/peps/pep-%04d.html' % int(pep)
def markup(self, text, escape=None, funcs={}, classes={}, methods={}): """Mark up some plain text, given a context of symbols to look for. Each context dictionary maps object names to anchor names.""" escape = escape or self.escape results = [] here = 0 pattern = re.compile(r'\b((http|ftp)://\S+[\w/]|' r'RFC[- ]?(\d+)|' r'(self\.)?(\w+))\b') while 1: match = pattern.search(text, here) if not match: break start, end = match.span() results.append(escape(text[here:start]))
f78a81b47baa04c78ca29ff4f4a8236297e852a0 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/f78a81b47baa04c78ca29ff4f4a8236297e852a0/pydoc.py
if cache.has_key(path) and cache[path] != info: module = reload(module)
if cache.get(path) == info: continue module = reload(module)
def freshimport(name, cache={}): """Import a module, reloading it if the source file has changed.""" topmodule = __import__(name) module = None for component in split(name, '.'): if module == None: module = topmodule path = split(name, '.')[0] else: module = getattr(module, component) path = path + '.' + component if hasattr(module, '__file__'): file = module.__file__ if os.path.exists(file): info = (file, os.path.getmtime(file), os.path.getsize(file)) if cache.has_key(path) and cache[path] != info: module = reload(module) file = module.__file__ if os.path.exists(file): info = (file, os.path.getmtime(file), os.path.getsize(file)) cache[path] = info return module
f78a81b47baa04c78ca29ff4f4a8236297e852a0 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/f78a81b47baa04c78ca29ff4f4a8236297e852a0/pydoc.py
return '''To get help on a Python object, call help(object).
return '''Welcome to Python %s! To get help on a Python object, call help(object).
def __repr__(self): return '''To get help on a Python object, call help(object).
f78a81b47baa04c78ca29ff4f4a8236297e852a0 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/f78a81b47baa04c78ca29ff4f4a8236297e852a0/pydoc.py
help(module) or call help('modulename').'''
help(module) or call help('modulename').''' % sys.version[:3]
def __repr__(self): return '''To get help on a Python object, call help(object).
f78a81b47baa04c78ca29ff4f4a8236297e852a0 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/f78a81b47baa04c78ca29ff4f4a8236297e852a0/pydoc.py
if platform not in ['cygwin']: exts.append( Extension('resource', ['resource.c']) )
exts.append( Extension('resource', ['resource.c']) )
def detect_modules(self): # Ensure that /usr/local is always used if '/usr/local/lib' not in self.compiler.library_dirs: self.compiler.library_dirs.insert(0, '/usr/local/lib') if '/usr/local/include' not in self.compiler.include_dirs: self.compiler.include_dirs.insert(0, '/usr/local/include' )
fda3c3ddae776dc23e55327e481d3bd5bec0536a /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/fda3c3ddae776dc23e55327e481d3bd5bec0536a/setup.py
last = last + 1
last = min(self.maxx, last+1)
def _end_of_line(self, y): "Go to the location of the first blank on the given line." last = self.maxx while 1: if ascii.ascii(self.win.inch(y, last)) != ascii.SP: last = last + 1 break elif last == 0: break last = last - 1 return last
76276177dea7d3e1412390e36a2c260f3f8107cb /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/76276177dea7d3e1412390e36a2c260f3f8107cb/textpad.py
def get_python_inc(plat_specific=0):
def get_python_inc(plat_specific=0, prefix=None):
def get_python_inc(plat_specific=0): """Return the directory containing installed Python header files. If 'plat_specific' is false (the default), this is the path to the non-platform-specific header files, i.e. Python.h and so on; otherwise, this is the path to platform-specific header files (namely config.h). """ prefix = (plat_specific and EXEC_PREFIX or PREFIX) if os.name == "posix": return os.path.join(prefix, "include", "python" + sys.version[:3]) elif os.name == "nt": return os.path.join(prefix, "Include") # include or Include? elif os.name == "mac": return os.path.join(prefix, "Include") else: raise DistutilsPlatformError, \ ("I don't know where Python installs its C header files " + "on platform '%s'") % os.name
d38e6f763797bec120ba110cd6e416d903c071b9 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/d38e6f763797bec120ba110cd6e416d903c071b9/sysconfig.py
prefix = (plat_specific and EXEC_PREFIX or PREFIX)
if prefix is None: prefix = (plat_specific and EXEC_PREFIX or PREFIX)
def get_python_inc(plat_specific=0): """Return the directory containing installed Python header files. If 'plat_specific' is false (the default), this is the path to the non-platform-specific header files, i.e. Python.h and so on; otherwise, this is the path to platform-specific header files (namely config.h). """ prefix = (plat_specific and EXEC_PREFIX or PREFIX) if os.name == "posix": return os.path.join(prefix, "include", "python" + sys.version[:3]) elif os.name == "nt": return os.path.join(prefix, "Include") # include or Include? elif os.name == "mac": return os.path.join(prefix, "Include") else: raise DistutilsPlatformError, \ ("I don't know where Python installs its C header files " + "on platform '%s'") % os.name
d38e6f763797bec120ba110cd6e416d903c071b9 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/d38e6f763797bec120ba110cd6e416d903c071b9/sysconfig.py
def get_python_lib(plat_specific=0, standard_lib=0):
def get_python_lib(plat_specific=0, standard_lib=0, prefix=None):
def get_python_lib(plat_specific=0, standard_lib=0): """Return the directory containing the Python library (standard or site additions). If 'plat_specific' is true, return the directory containing platform-specific modules, i.e. any module from a non-pure-Python module distribution; otherwise, return the platform-shared library directory. If 'standard_lib' is true, return the directory containing standard Python library modules; otherwise, return the directory for site-specific modules. """ prefix = (plat_specific and EXEC_PREFIX or PREFIX) if os.name == "posix": libpython = os.path.join(prefix, "lib", "python" + sys.version[:3]) if standard_lib: return libpython else: return os.path.join(libpython, "site-packages") elif os.name == "nt": if standard_lib: return os.path.join(PREFIX, "Lib") else: return prefix elif os.name == "mac": if platform_specific: if standard_lib: return os.path.join(EXEC_PREFIX, "Mac", "Plugins") else: raise DistutilsPlatformError, \ "OK, where DO site-specific extensions go on the Mac?" else: if standard_lib: return os.path.join(PREFIX, "Lib") else: raise DistutilsPlatformError, \ "OK, where DO site-specific modules go on the Mac?" else: raise DistutilsPlatformError, \ ("I don't know where Python installs its library " + "on platform '%s'") % os.name
d38e6f763797bec120ba110cd6e416d903c071b9 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/d38e6f763797bec120ba110cd6e416d903c071b9/sysconfig.py
prefix = (plat_specific and EXEC_PREFIX or PREFIX)
if prefix is None: prefix = (plat_specific and EXEC_PREFIX or PREFIX)
def get_python_lib(plat_specific=0, standard_lib=0): """Return the directory containing the Python library (standard or site additions). If 'plat_specific' is true, return the directory containing platform-specific modules, i.e. any module from a non-pure-Python module distribution; otherwise, return the platform-shared library directory. If 'standard_lib' is true, return the directory containing standard Python library modules; otherwise, return the directory for site-specific modules. """ prefix = (plat_specific and EXEC_PREFIX or PREFIX) if os.name == "posix": libpython = os.path.join(prefix, "lib", "python" + sys.version[:3]) if standard_lib: return libpython else: return os.path.join(libpython, "site-packages") elif os.name == "nt": if standard_lib: return os.path.join(PREFIX, "Lib") else: return prefix elif os.name == "mac": if platform_specific: if standard_lib: return os.path.join(EXEC_PREFIX, "Mac", "Plugins") else: raise DistutilsPlatformError, \ "OK, where DO site-specific extensions go on the Mac?" else: if standard_lib: return os.path.join(PREFIX, "Lib") else: raise DistutilsPlatformError, \ "OK, where DO site-specific modules go on the Mac?" else: raise DistutilsPlatformError, \ ("I don't know where Python installs its library " + "on platform '%s'") % os.name
d38e6f763797bec120ba110cd6e416d903c071b9 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/d38e6f763797bec120ba110cd6e416d903c071b9/sysconfig.py
p = subprocess.Popen([sys.executable, "-c", "import os; os.abort()"])
old_limit = self._suppress_core_files() try: p = subprocess.Popen([sys.executable, "-c", "import os; os.abort()"]) finally: self._unsuppress_core_files(old_limit)
def test_run_abort(self): # returncode handles signal termination p = subprocess.Popen([sys.executable, "-c", "import os; os.abort()"]) p.wait() self.assertEqual(-p.returncode, signal.SIGABRT)
86e1e38059c7f2a1d8bdc4123a1600bc7b7a0f79 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/86e1e38059c7f2a1d8bdc4123a1600bc7b7a0f79/test_subprocess.py
f(1, 2, 3, *UserList([4, 5])
f(1, 2, 3, *UserList([4, 5]))
def h(j=1, a=2, h=3): print j, a, h
003663d78372a33ddbc57594d0176fa39996a84d /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/003663d78372a33ddbc57594d0176fa39996a84d/test_extcall.py
addr = socket.gethostbyname(socket.gethostname())
addr = '127.0.0.1' try: addr = socket.gethostbyname(socket.gethostname()) except socket.gaierror: pass
def __init__(self, host = '', port = 0, local_hostname = None): """Initialize a new instance.
dcdfd22bb411ebf0d58bba135455c4abf2bc9ce1 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/dcdfd22bb411ebf0d58bba135455c4abf2bc9ce1/smtplib.py
class BadException:
class BadException(Exception):
def ckmsg(src, msg): try: compile(src, '<fragment>', 'exec') except SyntaxError, e: print e.msg if e.msg == msg: print "ok" else: print "expected:", msg else: print "failed to get expected SyntaxError"
303de6a25b4dc4874eded29c34c719a3bd6a4f40 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/303de6a25b4dc4874eded29c34c719a3bd6a4f40/test_exceptions.py
def grid_location(self, x, y): """Return a tuple of column and row which identify the cell at which the pixel at position X and Y inside the master widget is located.""" return self._getints( self.tk.call( 'grid', 'location', self._w, x, y)) or None location = grid_location
location = grid_location = Misc.grid_location
def grid_location(self, x, y): """Return a tuple of column and row which identify the cell at which the pixel at position X and Y inside the master widget is located.""" return self._getints( self.tk.call( 'grid', 'location', self._w, x, y)) or None
dc5790932335cebb5a9baa03b46e52e06d4bb24a /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/dc5790932335cebb5a9baa03b46e52e06d4bb24a/Tkinter.py
xid = self.unpack_uint(xid)
xid = self.unpack_uint()
def unpack_callheader(self): xid = self.unpack_uint(xid) temp = self.unpack_enum() if temp <> CALL: raise BadRPCFormat, 'no CALL but %r' % (temp,) temp = self.unpack_uint() if temp <> RPCVERSION: raise BadRPCVerspion, 'bad RPC version %r' % (temp,) prog = self.unpack_uint() vers = self.unpack_uint() proc = self.unpack_uint() cred = self.unpack_auth() verf = self.unpack_auth() return xid, prog, vers, proc, cred, verf # Caller must add procedure-specific part of call
c672f8c377b9befd49fed010441b025deace386a /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/c672f8c377b9befd49fed010441b025deace386a/rpc.py
if temp <> CALL:
if temp != CALL:
def unpack_callheader(self): xid = self.unpack_uint(xid) temp = self.unpack_enum() if temp <> CALL: raise BadRPCFormat, 'no CALL but %r' % (temp,) temp = self.unpack_uint() if temp <> RPCVERSION: raise BadRPCVerspion, 'bad RPC version %r' % (temp,) prog = self.unpack_uint() vers = self.unpack_uint() proc = self.unpack_uint() cred = self.unpack_auth() verf = self.unpack_auth() return xid, prog, vers, proc, cred, verf # Caller must add procedure-specific part of call
c672f8c377b9befd49fed010441b025deace386a /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/c672f8c377b9befd49fed010441b025deace386a/rpc.py
if temp <> RPCVERSION: raise BadRPCVerspion, 'bad RPC version %r' % (temp,)
if temp != RPCVERSION: raise BadRPCVersion, 'bad RPC version %r' % (temp,)
def unpack_callheader(self): xid = self.unpack_uint(xid) temp = self.unpack_enum() if temp <> CALL: raise BadRPCFormat, 'no CALL but %r' % (temp,) temp = self.unpack_uint() if temp <> RPCVERSION: raise BadRPCVerspion, 'bad RPC version %r' % (temp,) prog = self.unpack_uint() vers = self.unpack_uint() proc = self.unpack_uint() cred = self.unpack_auth() verf = self.unpack_auth() return xid, prog, vers, proc, cred, verf # Caller must add procedure-specific part of call
c672f8c377b9befd49fed010441b025deace386a /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/c672f8c377b9befd49fed010441b025deace386a/rpc.py
if mtype <> REPLY:
if mtype != REPLY:
def unpack_replyheader(self): xid = self.unpack_uint() mtype = self.unpack_enum() if mtype <> REPLY: raise RuntimeError, 'no REPLY but %r' % (mtype,) stat = self.unpack_enum() if stat == MSG_DENIED: stat = self.unpack_enum() if stat == RPC_MISMATCH: low = self.unpack_uint() high = self.unpack_uint() raise RuntimeError, \ 'MSG_DENIED: RPC_MISMATCH: %r' % ((low, high),) if stat == AUTH_ERROR: stat = self.unpack_uint() raise RuntimeError, \ 'MSG_DENIED: AUTH_ERROR: %r' % (stat,) raise RuntimeError, 'MSG_DENIED: %r' % (stat,) if stat <> MSG_ACCEPTED: raise RuntimeError, \ 'Neither MSG_DENIED nor MSG_ACCEPTED: %r' % (stat,) verf = self.unpack_auth() stat = self.unpack_enum() if stat == PROG_UNAVAIL: raise RuntimeError, 'call failed: PROG_UNAVAIL' if stat == PROG_MISMATCH: low = self.unpack_uint() high = self.unpack_uint() raise RuntimeError, \ 'call failed: PROG_MISMATCH: %r' % ((low, high),) if stat == PROC_UNAVAIL: raise RuntimeError, 'call failed: PROC_UNAVAIL' if stat == GARBAGE_ARGS: raise RuntimeError, 'call failed: GARBAGE_ARGS' if stat <> SUCCESS: raise RuntimeError, 'call failed: %r' % (stat,) return xid, verf # Caller must get procedure-specific part of reply
c672f8c377b9befd49fed010441b025deace386a /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/c672f8c377b9befd49fed010441b025deace386a/rpc.py
if stat <> MSG_ACCEPTED:
if stat != MSG_ACCEPTED:
def unpack_replyheader(self): xid = self.unpack_uint() mtype = self.unpack_enum() if mtype <> REPLY: raise RuntimeError, 'no REPLY but %r' % (mtype,) stat = self.unpack_enum() if stat == MSG_DENIED: stat = self.unpack_enum() if stat == RPC_MISMATCH: low = self.unpack_uint() high = self.unpack_uint() raise RuntimeError, \ 'MSG_DENIED: RPC_MISMATCH: %r' % ((low, high),) if stat == AUTH_ERROR: stat = self.unpack_uint() raise RuntimeError, \ 'MSG_DENIED: AUTH_ERROR: %r' % (stat,) raise RuntimeError, 'MSG_DENIED: %r' % (stat,) if stat <> MSG_ACCEPTED: raise RuntimeError, \ 'Neither MSG_DENIED nor MSG_ACCEPTED: %r' % (stat,) verf = self.unpack_auth() stat = self.unpack_enum() if stat == PROG_UNAVAIL: raise RuntimeError, 'call failed: PROG_UNAVAIL' if stat == PROG_MISMATCH: low = self.unpack_uint() high = self.unpack_uint() raise RuntimeError, \ 'call failed: PROG_MISMATCH: %r' % ((low, high),) if stat == PROC_UNAVAIL: raise RuntimeError, 'call failed: PROC_UNAVAIL' if stat == GARBAGE_ARGS: raise RuntimeError, 'call failed: GARBAGE_ARGS' if stat <> SUCCESS: raise RuntimeError, 'call failed: %r' % (stat,) return xid, verf # Caller must get procedure-specific part of reply
c672f8c377b9befd49fed010441b025deace386a /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/c672f8c377b9befd49fed010441b025deace386a/rpc.py
if stat <> SUCCESS:
if stat != SUCCESS:
def unpack_replyheader(self): xid = self.unpack_uint() mtype = self.unpack_enum() if mtype <> REPLY: raise RuntimeError, 'no REPLY but %r' % (mtype,) stat = self.unpack_enum() if stat == MSG_DENIED: stat = self.unpack_enum() if stat == RPC_MISMATCH: low = self.unpack_uint() high = self.unpack_uint() raise RuntimeError, \ 'MSG_DENIED: RPC_MISMATCH: %r' % ((low, high),) if stat == AUTH_ERROR: stat = self.unpack_uint() raise RuntimeError, \ 'MSG_DENIED: AUTH_ERROR: %r' % (stat,) raise RuntimeError, 'MSG_DENIED: %r' % (stat,) if stat <> MSG_ACCEPTED: raise RuntimeError, \ 'Neither MSG_DENIED nor MSG_ACCEPTED: %r' % (stat,) verf = self.unpack_auth() stat = self.unpack_enum() if stat == PROG_UNAVAIL: raise RuntimeError, 'call failed: PROG_UNAVAIL' if stat == PROG_MISMATCH: low = self.unpack_uint() high = self.unpack_uint() raise RuntimeError, \ 'call failed: PROG_MISMATCH: %r' % ((low, high),) if stat == PROC_UNAVAIL: raise RuntimeError, 'call failed: PROC_UNAVAIL' if stat == GARBAGE_ARGS: raise RuntimeError, 'call failed: GARBAGE_ARGS' if stat <> SUCCESS: raise RuntimeError, 'call failed: %r' % (stat,) return xid, verf # Caller must get procedure-specific part of reply
c672f8c377b9befd49fed010441b025deace386a /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/c672f8c377b9befd49fed010441b025deace386a/rpc.py
if errno <> 114:
if errno != 114:
def bindresvport(sock, host): global last_resv_port_tried FIRST, LAST = 600, 1024 # Range of ports to try if last_resv_port_tried == None: import os last_resv_port_tried = FIRST + os.getpid() % (LAST-FIRST) for i in range(last_resv_port_tried, LAST) + \ range(FIRST, last_resv_port_tried): last_resv_port_tried = i try: sock.bind((host, i)) return last_resv_port_tried except socket.error, (errno, msg): if errno <> 114: raise socket.error, (errno, msg) raise RuntimeError, 'can\'t assign reserved port'
c672f8c377b9befd49fed010441b025deace386a /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/c672f8c377b9befd49fed010441b025deace386a/rpc.py
if xid <> self.lastxid:
if xid != self.lastxid:
def do_call(self): call = self.packer.get_buf() sendrecord(self.sock, call) reply = recvrecord(self.sock) u = self.unpacker u.reset(reply) xid, verf = u.unpack_replyheader() if xid <> self.lastxid: # Can't really happen since this is TCP... raise RuntimeError, 'wrong xid in reply %r instead of %r' % ( xid, self.lastxid)
c672f8c377b9befd49fed010441b025deace386a /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/c672f8c377b9befd49fed010441b025deace386a/rpc.py
if xid <> self.lastxid:
if xid != self.lastxid:
def do_call(self): call = self.packer.get_buf() self.sock.send(call) try: from select import select except ImportError: print 'WARNING: select not found, RPC may hang' select = None BUFSIZE = 8192 # Max UDP buffer size timeout = 1 count = 5 while 1: r, w, x = [self.sock], [], [] if select: r, w, x = select(r, w, x, timeout) if self.sock not in r: count = count - 1 if count < 0: raise RuntimeError, 'timeout' if timeout < 25: timeout = timeout *2
c672f8c377b9befd49fed010441b025deace386a /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/c672f8c377b9befd49fed010441b025deace386a/rpc.py
if xid <> self.lastxid:
if xid != self.lastxid:
def dummy(): pass
c672f8c377b9befd49fed010441b025deace386a /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/c672f8c377b9befd49fed010441b025deace386a/rpc.py
if temp <> CALL:
if temp != CALL:
def handle(self, call): # Don't use unpack_header but parse the header piecewise # XXX I have no idea if I am using the right error responses! self.unpacker.reset(call) self.packer.reset() xid = self.unpacker.unpack_uint() self.packer.pack_uint(xid) temp = self.unpacker.unpack_enum() if temp <> CALL: return None # Not worthy of a reply self.packer.pack_uint(REPLY) temp = self.unpacker.unpack_uint() if temp <> RPCVERSION: self.packer.pack_uint(MSG_DENIED) self.packer.pack_uint(RPC_MISMATCH) self.packer.pack_uint(RPCVERSION) self.packer.pack_uint(RPCVERSION) return self.packer.get_buf() self.packer.pack_uint(MSG_ACCEPTED) self.packer.pack_auth((AUTH_NULL, make_auth_null())) prog = self.unpacker.unpack_uint() if prog <> self.prog: self.packer.pack_uint(PROG_UNAVAIL) return self.packer.get_buf() vers = self.unpacker.unpack_uint() if vers <> self.vers: self.packer.pack_uint(PROG_MISMATCH) self.packer.pack_uint(self.vers) self.packer.pack_uint(self.vers) return self.packer.get_buf() proc = self.unpacker.unpack_uint() methname = 'handle_' + repr(proc) try: meth = getattr(self, methname) except AttributeError: self.packer.pack_uint(PROC_UNAVAIL) return self.packer.get_buf() cred = self.unpacker.unpack_auth() verf = self.unpacker.unpack_auth() try: meth() # Unpack args, call turn_around(), pack reply except (EOFError, GarbageArgs): # Too few or too many arguments self.packer.reset() self.packer.pack_uint(xid) self.packer.pack_uint(REPLY) self.packer.pack_uint(MSG_ACCEPTED) self.packer.pack_auth((AUTH_NULL, make_auth_null())) self.packer.pack_uint(GARBAGE_ARGS) return self.packer.get_buf()
c672f8c377b9befd49fed010441b025deace386a /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/c672f8c377b9befd49fed010441b025deace386a/rpc.py
if temp <> RPCVERSION:
if temp != RPCVERSION:
def handle(self, call): # Don't use unpack_header but parse the header piecewise # XXX I have no idea if I am using the right error responses! self.unpacker.reset(call) self.packer.reset() xid = self.unpacker.unpack_uint() self.packer.pack_uint(xid) temp = self.unpacker.unpack_enum() if temp <> CALL: return None # Not worthy of a reply self.packer.pack_uint(REPLY) temp = self.unpacker.unpack_uint() if temp <> RPCVERSION: self.packer.pack_uint(MSG_DENIED) self.packer.pack_uint(RPC_MISMATCH) self.packer.pack_uint(RPCVERSION) self.packer.pack_uint(RPCVERSION) return self.packer.get_buf() self.packer.pack_uint(MSG_ACCEPTED) self.packer.pack_auth((AUTH_NULL, make_auth_null())) prog = self.unpacker.unpack_uint() if prog <> self.prog: self.packer.pack_uint(PROG_UNAVAIL) return self.packer.get_buf() vers = self.unpacker.unpack_uint() if vers <> self.vers: self.packer.pack_uint(PROG_MISMATCH) self.packer.pack_uint(self.vers) self.packer.pack_uint(self.vers) return self.packer.get_buf() proc = self.unpacker.unpack_uint() methname = 'handle_' + repr(proc) try: meth = getattr(self, methname) except AttributeError: self.packer.pack_uint(PROC_UNAVAIL) return self.packer.get_buf() cred = self.unpacker.unpack_auth() verf = self.unpacker.unpack_auth() try: meth() # Unpack args, call turn_around(), pack reply except (EOFError, GarbageArgs): # Too few or too many arguments self.packer.reset() self.packer.pack_uint(xid) self.packer.pack_uint(REPLY) self.packer.pack_uint(MSG_ACCEPTED) self.packer.pack_auth((AUTH_NULL, make_auth_null())) self.packer.pack_uint(GARBAGE_ARGS) return self.packer.get_buf()
c672f8c377b9befd49fed010441b025deace386a /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/c672f8c377b9befd49fed010441b025deace386a/rpc.py
if prog <> self.prog:
if prog != self.prog:
def handle(self, call): # Don't use unpack_header but parse the header piecewise # XXX I have no idea if I am using the right error responses! self.unpacker.reset(call) self.packer.reset() xid = self.unpacker.unpack_uint() self.packer.pack_uint(xid) temp = self.unpacker.unpack_enum() if temp <> CALL: return None # Not worthy of a reply self.packer.pack_uint(REPLY) temp = self.unpacker.unpack_uint() if temp <> RPCVERSION: self.packer.pack_uint(MSG_DENIED) self.packer.pack_uint(RPC_MISMATCH) self.packer.pack_uint(RPCVERSION) self.packer.pack_uint(RPCVERSION) return self.packer.get_buf() self.packer.pack_uint(MSG_ACCEPTED) self.packer.pack_auth((AUTH_NULL, make_auth_null())) prog = self.unpacker.unpack_uint() if prog <> self.prog: self.packer.pack_uint(PROG_UNAVAIL) return self.packer.get_buf() vers = self.unpacker.unpack_uint() if vers <> self.vers: self.packer.pack_uint(PROG_MISMATCH) self.packer.pack_uint(self.vers) self.packer.pack_uint(self.vers) return self.packer.get_buf() proc = self.unpacker.unpack_uint() methname = 'handle_' + repr(proc) try: meth = getattr(self, methname) except AttributeError: self.packer.pack_uint(PROC_UNAVAIL) return self.packer.get_buf() cred = self.unpacker.unpack_auth() verf = self.unpacker.unpack_auth() try: meth() # Unpack args, call turn_around(), pack reply except (EOFError, GarbageArgs): # Too few or too many arguments self.packer.reset() self.packer.pack_uint(xid) self.packer.pack_uint(REPLY) self.packer.pack_uint(MSG_ACCEPTED) self.packer.pack_auth((AUTH_NULL, make_auth_null())) self.packer.pack_uint(GARBAGE_ARGS) return self.packer.get_buf()
c672f8c377b9befd49fed010441b025deace386a /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/c672f8c377b9befd49fed010441b025deace386a/rpc.py
if vers <> self.vers:
if vers != self.vers:
def handle(self, call): # Don't use unpack_header but parse the header piecewise # XXX I have no idea if I am using the right error responses! self.unpacker.reset(call) self.packer.reset() xid = self.unpacker.unpack_uint() self.packer.pack_uint(xid) temp = self.unpacker.unpack_enum() if temp <> CALL: return None # Not worthy of a reply self.packer.pack_uint(REPLY) temp = self.unpacker.unpack_uint() if temp <> RPCVERSION: self.packer.pack_uint(MSG_DENIED) self.packer.pack_uint(RPC_MISMATCH) self.packer.pack_uint(RPCVERSION) self.packer.pack_uint(RPCVERSION) return self.packer.get_buf() self.packer.pack_uint(MSG_ACCEPTED) self.packer.pack_auth((AUTH_NULL, make_auth_null())) prog = self.unpacker.unpack_uint() if prog <> self.prog: self.packer.pack_uint(PROG_UNAVAIL) return self.packer.get_buf() vers = self.unpacker.unpack_uint() if vers <> self.vers: self.packer.pack_uint(PROG_MISMATCH) self.packer.pack_uint(self.vers) self.packer.pack_uint(self.vers) return self.packer.get_buf() proc = self.unpacker.unpack_uint() methname = 'handle_' + repr(proc) try: meth = getattr(self, methname) except AttributeError: self.packer.pack_uint(PROC_UNAVAIL) return self.packer.get_buf() cred = self.unpacker.unpack_auth() verf = self.unpacker.unpack_auth() try: meth() # Unpack args, call turn_around(), pack reply except (EOFError, GarbageArgs): # Too few or too many arguments self.packer.reset() self.packer.pack_uint(xid) self.packer.pack_uint(REPLY) self.packer.pack_uint(MSG_ACCEPTED) self.packer.pack_auth((AUTH_NULL, make_auth_null())) self.packer.pack_uint(GARBAGE_ARGS) return self.packer.get_buf()
c672f8c377b9befd49fed010441b025deace386a /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/c672f8c377b9befd49fed010441b025deace386a/rpc.py
if reply <> None:
if reply != None:
def session(self): call, host_port = self.sock.recvfrom(8192) reply = self.handle(call) if reply <> None: self.sock.sendto(reply, host_port)
c672f8c377b9befd49fed010441b025deace386a /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/c672f8c377b9befd49fed010441b025deace386a/rpc.py
np = lambda *f: norm(self.tempdir, *f)
def test_glob_literal(self): eq = self.assertSequencesEqual_noorder np = lambda *f: norm(self.tempdir, *f) eq(self.glob('a'), [self.norm('a')]) eq(self.glob('a', 'D'), [self.norm('a', 'D')]) eq(self.glob('aab'), [self.norm('aab')]) eq(self.glob('zymurgy'), [])
d4e48b7f61a767dd32195ccc91949017bbef5a05 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/d4e48b7f61a767dd32195ccc91949017bbef5a05/test_glob.py
np = lambda *f: norm(self.tempdir, *f)
def test_glob_one_directory(self): eq = self.assertSequencesEqual_noorder np = lambda *f: norm(self.tempdir, *f) eq(self.glob('a*'), map(self.norm, ['a', 'aab', 'aaa'])) eq(self.glob('*a'), map(self.norm, ['a', 'aaa'])) eq(self.glob('aa?'), map(self.norm, ['aaa', 'aab'])) eq(self.glob('aa[ab]'), map(self.norm, ['aaa', 'aab'])) eq(self.glob('*q'), [])
d4e48b7f61a767dd32195ccc91949017bbef5a05 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/d4e48b7f61a767dd32195ccc91949017bbef5a05/test_glob.py
np = lambda *f: norm(self.tempdir, *f)
def test_glob_nested_directory(self): eq = self.assertSequencesEqual_noorder np = lambda *f: norm(self.tempdir, *f) if os.path.normcase("abCD") == "abCD": # case-sensitive filesystem eq(self.glob('a', 'bcd', 'E*'), [self.norm('a', 'bcd', 'EF')]) else: # case insensitive filesystem eq(self.glob('a', 'bcd', 'E*'), [self.norm('a', 'bcd', 'EF'), self.norm('a', 'bcd', 'efg')]) eq(self.glob('a', 'bcd', '*g'), [self.norm('a', 'bcd', 'efg')])
d4e48b7f61a767dd32195ccc91949017bbef5a05 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/d4e48b7f61a767dd32195ccc91949017bbef5a05/test_glob.py
np = lambda *f: norm(self.tempdir, *f)
def test_glob_directory_names(self): eq = self.assertSequencesEqual_noorder np = lambda *f: norm(self.tempdir, *f) eq(self.glob('*', 'D'), [self.norm('a', 'D')]) eq(self.glob('*', '*a'), []) eq(self.glob('a', '*', '*', '*a'), [self.norm('a', 'bcd', 'efg', 'ha')]) eq(self.glob('?a?', '*F'), map(self.norm, [os.path.join('aaa', 'zzzF'), os.path.join('aab', 'F')]))
d4e48b7f61a767dd32195ccc91949017bbef5a05 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/d4e48b7f61a767dd32195ccc91949017bbef5a05/test_glob.py
The 'quotetabs' flag indicates whether tabs should be quoted.""" if c == '\t': return not quotetabs return c == ESCAPE or not(' ' <= c <= '~')
The 'quotetabs' flag indicates whether embedded tabs and spaces should be quoted. Note that line-ending tabs and spaces are always encoded, as per RFC 1521. """ if c in ' \t': return quotetabs return c == ESCAPE or not (' ' <= c <= '~')
def needsquoting(c, quotetabs): """Decide whether a particular character needs to be quoted. The 'quotetabs' flag indicates whether tabs should be quoted.""" if c == '\t': return not quotetabs return c == ESCAPE or not(' ' <= c <= '~')
9b630a50200e44e16acfe3dee4052b3d0b0677e4 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/9b630a50200e44e16acfe3dee4052b3d0b0677e4/quopri.py
The 'quotetabs' flag indicates whether tabs should be quoted. """
The 'quotetabs' flag indicates whether embedded tabs and spaces should be quoted. Note that line-ending tabs and spaces are always encoded, as per RFC 1521. """ def write(s, output=output, lineEnd='\n'): if s and s[-1:] in ' \t': output.write(s[:-1] + quote(s[-1]) + lineEnd) else: output.write(s + lineEnd) prevline = None linelen = 0
def encode(input, output, quotetabs): """Read 'input', apply quoted-printable encoding, and write to 'output'. 'input' and 'output' are files with readline() and write() methods. The 'quotetabs' flag indicates whether tabs should be quoted. """ while 1: line = input.readline() if not line: break new = '' last = line[-1:] if last == '\n': line = line[:-1] else: last = '' prev = '' for c in line: if needsquoting(c, quotetabs): c = quote(c) if len(new) + len(c) >= MAXLINESIZE: output.write(new + ESCAPE + '\n') new = '' new = new + c prev = c if prev in (' ', '\t'): output.write(new + ESCAPE + '\n\n') else: output.write(new + '\n')
9b630a50200e44e16acfe3dee4052b3d0b0677e4 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/9b630a50200e44e16acfe3dee4052b3d0b0677e4/quopri.py
new = '' last = line[-1:] if last == '\n':
outline = [] stripped = '' if line[-1:] == '\n':
def encode(input, output, quotetabs): """Read 'input', apply quoted-printable encoding, and write to 'output'. 'input' and 'output' are files with readline() and write() methods. The 'quotetabs' flag indicates whether tabs should be quoted. """ while 1: line = input.readline() if not line: break new = '' last = line[-1:] if last == '\n': line = line[:-1] else: last = '' prev = '' for c in line: if needsquoting(c, quotetabs): c = quote(c) if len(new) + len(c) >= MAXLINESIZE: output.write(new + ESCAPE + '\n') new = '' new = new + c prev = c if prev in (' ', '\t'): output.write(new + ESCAPE + '\n\n') else: output.write(new + '\n')
9b630a50200e44e16acfe3dee4052b3d0b0677e4 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/9b630a50200e44e16acfe3dee4052b3d0b0677e4/quopri.py
else: last = '' prev = ''
stripped = '\n'
def encode(input, output, quotetabs): """Read 'input', apply quoted-printable encoding, and write to 'output'. 'input' and 'output' are files with readline() and write() methods. The 'quotetabs' flag indicates whether tabs should be quoted. """ while 1: line = input.readline() if not line: break new = '' last = line[-1:] if last == '\n': line = line[:-1] else: last = '' prev = '' for c in line: if needsquoting(c, quotetabs): c = quote(c) if len(new) + len(c) >= MAXLINESIZE: output.write(new + ESCAPE + '\n') new = '' new = new + c prev = c if prev in (' ', '\t'): output.write(new + ESCAPE + '\n\n') else: output.write(new + '\n')
9b630a50200e44e16acfe3dee4052b3d0b0677e4 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/9b630a50200e44e16acfe3dee4052b3d0b0677e4/quopri.py
if len(new) + len(c) >= MAXLINESIZE: output.write(new + ESCAPE + '\n') new = '' new = new + c prev = c if prev in (' ', '\t'): output.write(new + ESCAPE + '\n\n') else: output.write(new + '\n')
if linelen + len(c) >= MAXLINESIZE: if prevline is not None: write(prevline) prevline = EMPTYSTRING.join(outline) linelen = 0 outline = [] outline.append(c) linelen += len(c) if prevline is not None: write(prevline) prevline = EMPTYSTRING.join(outline) linelen = 0 outline = [] if prevline is not None: write(prevline, lineEnd=stripped) def encodestring(s, quotetabs=0): from cStringIO import StringIO infp = StringIO(s) outfp = StringIO() encode(infp, outfp, quotetabs) return outfp.getvalue()
def encode(input, output, quotetabs): """Read 'input', apply quoted-printable encoding, and write to 'output'. 'input' and 'output' are files with readline() and write() methods. The 'quotetabs' flag indicates whether tabs should be quoted. """ while 1: line = input.readline() if not line: break new = '' last = line[-1:] if last == '\n': line = line[:-1] else: last = '' prev = '' for c in line: if needsquoting(c, quotetabs): c = quote(c) if len(new) + len(c) >= MAXLINESIZE: output.write(new + ESCAPE + '\n') new = '' new = new + c prev = c if prev in (' ', '\t'): output.write(new + ESCAPE + '\n\n') else: output.write(new + '\n')
9b630a50200e44e16acfe3dee4052b3d0b0677e4 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/9b630a50200e44e16acfe3dee4052b3d0b0677e4/quopri.py