rem
stringlengths
1
322k
add
stringlengths
0
2.05M
context
stringlengths
4
228k
meta
stringlengths
156
215
The request should be stored in self.raw_request; the results
The request should be stored in self.raw_requestline; the results
def parse_request(self): """Parse a request (internal).
2d59ad198c00c2ba6eb10e8298d8b82848f1e6a2 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/2d59ad198c00c2ba6eb10e8298d8b82848f1e6a2/BaseHTTPServer.py
self.assertRaises(IndexError, s.__setitem__, -1, "bar") self.assertRaises(IndexError, s.__setitem__, 3, "bar")
self.assertRaises(IndexError, s.__delitem__, -1) self.assertRaises(IndexError, s.__delitem__, 3)
def test_delitem(self): s = self.type2test("foo") self.assertRaises(IndexError, s.__setitem__, -1, "bar") self.assertRaises(IndexError, s.__setitem__, 3, "bar") del s[0] self.assertEqual(s, "oo") del s[1] self.assertEqual(s, "o") del s[0] self.assertEqual(s, "")
5aec7106448ed1c52afbe563126386159431d94a /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/5aec7106448ed1c52afbe563126386159431d94a/test_userstring.py
verify(str(msg).find("weakly") >= 0)
verify(str(msg).find("weak reference") >= 0)
def weakrefs(): if verbose: print "Testing weak references..." import weakref class C(object): pass c = C() r = weakref.ref(c) verify(r() is c) del c verify(r() is None) del r class NoWeak(object): __slots__ = ['foo'] no = NoWeak() try: weakref.ref(no) except TypeError, msg: verify(str(msg).find("weakly") >= 0) else: verify(0, "weakref.ref(no) should be illegal") class Weak(object): __slots__ = ['foo', '__weakref__'] yes = Weak() r = weakref.ref(yes) verify(r() is yes) del yes verify(r() is None) del r
687bc3be47dc9a7c74b837ad6cc12fa73275270c /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/687bc3be47dc9a7c74b837ad6cc12fa73275270c/test_descr.py
if self.debuglevel > 0: print>>stderr, 'connect:', (host, port)
if self.debuglevel > 0: print>>stderr, 'connect:', sa
def connect(self, host='localhost', port = 0): """Connect to a host on a given port.
cebcc443ebb563ac6721add4cdb287d512a39013 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/cebcc443ebb563ac6721add4cdb287d512a39013/smtplib.py
if self.debuglevel > 0: print>>stderr, 'connect fail:', (host, port)
if self.debuglevel > 0: print>>stderr, 'connect fail:', msg
def connect(self, host='localhost', port = 0): """Connect to a host on a given port.
cebcc443ebb563ac6721add4cdb287d512a39013 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/cebcc443ebb563ac6721add4cdb287d512a39013/smtplib.py
typ, val, tb = sys.exc_info()
typ, val, tb = excinfo = sys.exc_info() sys.last_type, sys.last_value, sys.last_traceback = excinfo
def print_exception(): flush_stdout() efile = sys.stderr typ, val, tb = sys.exc_info() tbe = traceback.extract_tb(tb) print >>efile, '\nTraceback (most recent call last):' exclude = ("run.py", "rpc.py", "threading.py", "Queue.py", "RemoteDebugger.py", "bdb.py") cleanup_traceback(tbe, exclude) traceback.print_list(tbe, file=efile) lines = traceback.format_exception_only(typ, val) for line in lines: print>>efile, line,
5917f7b0da1d6afa1cd9fe4757133e6fe026d29a /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/5917f7b0da1d6afa1cd9fe4757133e6fe026d29a/run.py
def test_getitem(self): class GetItem(object):
def _getitem_helper(self, base): class GetItem(base):
def test_getitem(self): class GetItem(object): def __len__(self): return maxint def __getitem__(self, key): return key def __getslice__(self, i, j): return i, j x = GetItem() self.assertEqual(x[self.pos], self.pos) self.assertEqual(x[self.neg], self.neg) self.assertEqual(x[self.neg:self.pos], (-1, maxint)) self.assertEqual(x[self.neg:self.pos:1].indices(maxint), (0, maxint, 1))
1167a09145bd74519f7dc4b92c30b5f626753dac /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/1167a09145bd74519f7dc4b92c30b5f626753dac/test_index.py
if not _type_to_name_map:
if _type_to_name_map=={}:
def type_to_name(gtype): global _type_to_name_map if not _type_to_name_map: for name in _names: if name[:2] == 'A_': _type_to_name_map[eval(name)] = name[2:] if _type_to_name_map.has_key(gtype): return _type_to_name_map[gtype] return 'TYPE=' + `gtype`
03caa01f21f2bea5c1a2f7a1a74fbe11d731c982 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/03caa01f21f2bea5c1a2f7a1a74fbe11d731c982/gopherlib.py
self.sock.connect((host, port))
try: self.sock.connect((host, port)) except socket.error: self.close() raise
def connect(self, host='localhost', port = 0): """Connect to a host on a given port.
b8282e9de8320fb190173cc702802f953206162f /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/b8282e9de8320fb190173cc702802f953206162f/smtplib.py
print """q(uit) Quit from the debugger.
print """q(uit) or exit - Quit from the debugger.
def help_q(self): print """q(uit) Quit from the debugger.
18c1b88998192a235192bd85da7a3f352996b4f1 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/18c1b88998192a235192bd85da7a3f352996b4f1/pdb.py
- prepend _ if the result is a python keyword
- append _ if the result is a python keyword
def identify(str): """Turn any string into an identifier: - replace space by _ - replace other illegal chars by _xx_ (hex code) - prepend _ if the result is a python keyword """ if not str: return "empty_ae_name_" rv = '' ok = string.ascii_letters + '_' ok2 = ok + string.digits for c in str: if c in ok: rv = rv + c elif c == ' ': rv = rv + '_' else: rv = rv + '_%02.2x_'%ord(c) ok = ok2 if keyword.iskeyword(rv): rv = rv + '_' return rv
4dcff93ad2e82bcd1042d0d382b40973ffe5ca13 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/4dcff93ad2e82bcd1042d0d382b40973ffe5ca13/gensuitemodule.py
def tearDown(self): """Restore sys.path""" sys.path = self.sys_path
d63e121b3c5616656823c4dab5e65095a3d1cd2d /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/d63e121b3c5616656823c4dab5e65095a3d1cd2d/test_site.py
def test_init_pathinfo(self): dir_set = site._init_pathinfo() for entry in [site.makepath(path)[1] for path in sys.path if path and os.path.isdir(path)]: self.failUnless(entry in dir_set, "%s from sys.path not found in set returned " "by _init_pathinfo(): %s" % (entry, dir_set))
d63e121b3c5616656823c4dab5e65095a3d1cd2d /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/d63e121b3c5616656823c4dab5e65095a3d1cd2d/test_site.py
def test_addpackage(self): # Make sure addpackage() imports if the line starts with 'import', # otherwise add a directory combined from sitedir and 'name'. # Must also skip comment lines. dir_path, file_name, new_dir = createpth() try: site.addpackage(dir_path, file_name, set()) self.failUnless(site.makepath(os.path.join(dir_path, new_dir))[0] in sys.path) finally: cleanuppth(dir_path, file_name, new_dir)
d63e121b3c5616656823c4dab5e65095a3d1cd2d /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/d63e121b3c5616656823c4dab5e65095a3d1cd2d/test_site.py
for module in sys.modules.values():
for module in (sys, os, __builtin__):
def test_abs__file__(self): # Make sure all imported modules have their __file__ attribute # as an absolute path. # Handled by abs__file__() site.abs__file__() for module in sys.modules.values(): try: self.failUnless(os.path.isabs(module.__file__)) except AttributeError: continue
d63e121b3c5616656823c4dab5e65095a3d1cd2d /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/d63e121b3c5616656823c4dab5e65095a3d1cd2d/test_site.py
self.failUnless(os.path.isabs(module.__file__))
self.failUnless(os.path.isabs(module.__file__), `module`)
def test_abs__file__(self): # Make sure all imported modules have their __file__ attribute # as an absolute path. # Handled by abs__file__() site.abs__file__() for module in sys.modules.values(): try: self.failUnless(os.path.isabs(module.__file__)) except AttributeError: continue
d63e121b3c5616656823c4dab5e65095a3d1cd2d /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/d63e121b3c5616656823c4dab5e65095a3d1cd2d/test_site.py
from pprint import pprint print "config vars:" pprint (self.config_vars)
if DEBUG: from pprint import pprint print "config vars:" pprint (self.config_vars)
def finalize_options (self):
6fb6de4e077df187fc919e444cdbe6c1700aac4f /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/6fb6de4e077df187fc919e444cdbe6c1700aac4f/install.py
def finalize_options (self):
6fb6de4e077df187fc919e444cdbe6c1700aac4f /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/6fb6de4e077df187fc919e444cdbe6c1700aac4f/install.py
from distutils.fancy_getopt import longopt_xlate print msg + ":" for opt in self.user_options: opt_name = opt[0] if opt_name[-1] == "=": opt_name = opt_name[0:-1] opt_name = string.translate (opt_name, longopt_xlate) val = getattr (self, opt_name) print " %s: %s" % (opt_name, val)
if DEBUG: from distutils.fancy_getopt import longopt_xlate print msg + ":" for opt in self.user_options: opt_name = opt[0] if opt_name[-1] == "=": opt_name = opt_name[0:-1] opt_name = string.translate (opt_name, longopt_xlate) val = getattr (self, opt_name) print " %s: %s" % (opt_name, val)
def dump_dirs (self, msg): from distutils.fancy_getopt import longopt_xlate print msg + ":" for opt in self.user_options: opt_name = opt[0] if opt_name[-1] == "=": opt_name = opt_name[0:-1] opt_name = string.translate (opt_name, longopt_xlate) val = getattr (self, opt_name) print " %s: %s" % (opt_name, val)
6fb6de4e077df187fc919e444cdbe6c1700aac4f /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/6fb6de4e077df187fc919e444cdbe6c1700aac4f/install.py
import os, fcntl
import os try: import fcntl except ImportError: fcntl = None
def export_add(self, x, y): return x + y
4a8241c33def8f206e1361f5d95120f26fd4b45e /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/4a8241c33def8f206e1361f5d95120f26fd4b45e/SimpleXMLRPCServer.py
if hasattr(fcntl, 'FD_CLOEXEC'):
if fcntl is not None and hasattr(fcntl, 'FD_CLOEXEC'):
def __init__(self, addr, requestHandler=SimpleXMLRPCRequestHandler, logRequests=True, allow_none=False, encoding=None): self.logRequests = logRequests
4a8241c33def8f206e1361f5d95120f26fd4b45e /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/4a8241c33def8f206e1361f5d95120f26fd4b45e/SimpleXMLRPCServer.py
if self.compiler.find_library_file(lib_dirs, 'db-3.1'):
if self.compiler.find_library_file(lib_dirs, 'db-3.2'): dblib = ['db-3.2'] elif self.compiler.find_library_file(lib_dirs, 'db-3.1'):
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' )
b1a9f646e0a72645e0bcfc54fa934e4c4cf93b7b /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/b1a9f646e0a72645e0bcfc54fa934e4c4cf93b7b/setup.py
print 'Deleted breakpoint %s ' % (i,)
print 'Deleted breakpoint', i
def do_clear(self, arg): """Three possibilities, tried in this order: clear -> clear all breaks, ask for confirmation clear file:lineno -> clear all breaks at file:lineno clear bpno bpno ... -> clear breakpoints by number""" if not arg: try: reply = raw_input('Clear all breaks? ') except EOFError: reply = 'no' reply = reply.strip().lower() if reply in ('y', 'yes'): self.clear_all_breaks() return if ':' in arg: # Make sure it works for "clear C:\foo\bar.py:12" i = arg.rfind(':') filename = arg[:i] arg = arg[i+1:] try: lineno = int(arg) except: err = "Invalid line number (%s)" % arg else: err = self.clear_break(filename, lineno) if err: print '***', err return numberlist = arg.split() for i in numberlist: err = self.clear_bpbynumber(i) if err: print '***', err else: print 'Deleted breakpoint %s ' % (i,)
603e00779911f6f0ff2acb0248ec047a5e64107c /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/603e00779911f6f0ff2acb0248ec047a5e64107c/pdb.py
return result = MenuKey(ord(c)) id = (result>>16) & 0xffff item = result & 0xffff if id: self.do_rawmenu(id, item, None, event) else: if DEBUG: print "Command-" +`c`
return
def do_key(self, event): (what, message, when, where, modifiers) = event c = chr(message & charCodeMask) if modifiers & cmdKey: if c == '.': raise self else: if not self.menubar: MacOS.HandleEvent(event) return result = MenuKey(ord(c)) id = (result>>16) & 0xffff # Hi word item = result & 0xffff # Lo word if id: self.do_rawmenu(id, item, None, event)
1533db730cb4abdd474325d7fb705c40ae236e39 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/1533db730cb4abdd474325d7fb705c40ae236e39/FrameWork.py
self.menu.SetMenuItem
self.menu.SetMenuItemKeyGlyph(item, shortcut[2])
def additem(self, label, shortcut=None, callback=None, kind=None): self.menu.AppendMenu('x') # add a dummy string self.items.append(label, shortcut, callback, kind) item = len(self.items) self.menu.SetMenuItemText(item, label) # set the actual text if shortcut and type(shortcut) == type(()): modifiers, char = shortcut[:2] self.menu.SetItemCmd(item, ord(char)) self.menu.SetMenuItemModifiers(item, modifiers) if len(shortcut) > 2: self.menu.SetMenuItem elif shortcut: self.menu.SetItemCmd(item, ord(shortcut)) return item
1533db730cb4abdd474325d7fb705c40ae236e39 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/1533db730cb4abdd474325d7fb705c40ae236e39/FrameWork.py
r = typ.__repr__
r = getattr(typ, "__repr__", None)
def _format(self, object, stream, indent, allowance, context, level): level = level + 1 objid = _id(object) if objid in context: stream.write(_recursion(object)) self._recursive = True self._readable = False return rep = self._repr(object, context, level - 1) typ = _type(object) sepLines = _len(rep) > (self._width - 1 - indent - allowance) write = stream.write
08b0c0fbbd3de860b00eba399d90410866be3497 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/08b0c0fbbd3de860b00eba399d90410866be3497/pprint.py
r = typ.__repr__
r = getattr(typ, "__repr__", None)
def _safe_repr(object, context, maxlevels, level): typ = _type(object) if typ is str: if 'locale' not in _sys.modules: return repr(object), True, False if "'" in object and '"' not in object: closure = '"' quotes = {'"': '\\"'} else: closure = "'" quotes = {"'": "\\'"} qget = quotes.get sio = _StringIO() write = sio.write for char in object: if char.isalpha(): write(char) else: write(qget(char, repr(char)[1:-1])) return ("%s%s%s" % (closure, sio.getvalue(), closure)), True, False r = typ.__repr__ if issubclass(typ, dict) and r is dict.__repr__: if not object: return "{}", True, False objid = _id(object) if maxlevels and level > maxlevels: return "{...}", False, objid in context if objid in context: return _recursion(object), False, True context[objid] = 1 readable = True recursive = False components = [] append = components.append level += 1 saferepr = _safe_repr for k, v in object.iteritems(): krepr, kreadable, krecur = saferepr(k, context, maxlevels, level) vrepr, vreadable, vrecur = saferepr(v, context, maxlevels, level) append("%s: %s" % (krepr, vrepr)) readable = readable and kreadable and vreadable if krecur or vrecur: recursive = True del context[objid] return "{%s}" % _commajoin(components), readable, recursive if (issubclass(typ, list) and r is list.__repr__) or \ (issubclass(typ, tuple) and r is tuple.__repr__): if issubclass(typ, list): if not object: return "[]", True, False format = "[%s]" elif _len(object) == 1: format = "(%s,)" else: if not object: return "()", True, False format = "(%s)" objid = _id(object) if maxlevels and level > maxlevels: return format % "...", False, objid in context if objid in context: return _recursion(object), False, True context[objid] = 1 readable = True recursive = False components = [] append = components.append level += 1 for o in object: orepr, oreadable, orecur = _safe_repr(o, context, maxlevels, level) append(orepr) if not oreadable: readable = False if orecur: recursive = True del context[objid] return format % _commajoin(components), readable, recursive rep = repr(object) return rep, (rep and not rep.startswith('<')), False
08b0c0fbbd3de860b00eba399d90410866be3497 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/08b0c0fbbd3de860b00eba399d90410866be3497/pprint.py
def find_library_file (self, dirs, lib):
def find_library_file (self, dirs, lib, debug=0): if debug: try_names = [lib + "_d", lib] else: try_names = [lib]
def find_library_file (self, dirs, lib):
4ad3f7eefd00df3b4ea562c2aac82ab8183bda81 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/4ad3f7eefd00df3b4ea562c2aac82ab8183bda81/msvccompiler.py
libfile = os.path.join (dir, self.library_filename (lib)) if os.path.exists (libfile): return libfile
for name in try_names: libfile = os.path.join(dir, self.library_filename (name)) if os.path.exists(libfile): return libfile
def find_library_file (self, dirs, lib):
4ad3f7eefd00df3b4ea562c2aac82ab8183bda81 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/4ad3f7eefd00df3b4ea562c2aac82ab8183bda81/msvccompiler.py
if self.text.get("insert-1c") not in (')',']','}'):
closer = self.text.get("insert-1c") if closer not in _openers:
def paren_closed_event(self, event): # If it was a shortcut and not really a closing paren, quit. if self.text.get("insert-1c") not in (')',']','}'): return hp = HyperParser(self.editwin, "insert-1c") if not hp.is_in_code(): return indices = hp.get_surrounding_brackets(keysym_opener[event.keysym], True) if indices is None: self.warn_mismatched() return self.activate_restore() self.create_tag(indices) self.set_timeout()
ced38802c5fb24d2226c2a06c96ead6b6b575620 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/ced38802c5fb24d2226c2a06c96ead6b6b575620/ParenMatch.py
indices = hp.get_surrounding_brackets(keysym_opener[event.keysym], True)
indices = hp.get_surrounding_brackets(_openers[closer], True)
def paren_closed_event(self, event): # If it was a shortcut and not really a closing paren, quit. if self.text.get("insert-1c") not in (')',']','}'): return hp = HyperParser(self.editwin, "insert-1c") if not hp.is_in_code(): return indices = hp.get_surrounding_brackets(keysym_opener[event.keysym], True) if indices is None: self.warn_mismatched() return self.activate_restore() self.create_tag(indices) self.set_timeout()
ced38802c5fb24d2226c2a06c96ead6b6b575620 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/ced38802c5fb24d2226c2a06c96ead6b6b575620/ParenMatch.py
self.assertEqual(rem, 0) self.assertEqual(r1, r2)
self.assertEqual(rem, 0, '%s != 0 for %s' % (rem, i)) self.assertEqual(r1, r2, '%s != %s for %s' % (r1, r2, i))
def test_count(self): self.checkequal(3, 'aaa', 'count', 'a') self.checkequal(0, 'aaa', 'count', 'b') self.checkequal(3, 'aaa', 'count', 'a') self.checkequal(0, 'aaa', 'count', 'b') self.checkequal(3, 'aaa', 'count', 'a') self.checkequal(0, 'aaa', 'count', 'b') self.checkequal(0, 'aaa', 'count', 'b') self.checkequal(2, 'aaa', 'count', 'a', 1) self.checkequal(0, 'aaa', 'count', 'a', 10) self.checkequal(1, 'aaa', 'count', 'a', -1) self.checkequal(3, 'aaa', 'count', 'a', -10) self.checkequal(1, 'aaa', 'count', 'a', 0, 1) self.checkequal(3, 'aaa', 'count', 'a', 0, 10) self.checkequal(2, 'aaa', 'count', 'a', 0, -1) self.checkequal(0, 'aaa', 'count', 'a', 0, -10) self.checkequal(3, 'aaa', 'count', '', 1) self.checkequal(1, 'aaa', 'count', '', 3) self.checkequal(0, 'aaa', 'count', '', 10) self.checkequal(2, 'aaa', 'count', '', -1) self.checkequal(4, 'aaa', 'count', '', -10)
f1f66e826fbe0ac160929357a795287fd34f7166 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/f1f66e826fbe0ac160929357a795287fd34f7166/string_tests.py
if url[:2] == '//' and url[2:3] != '/':
if url[:2] == '//' and url[2:3] != '/' and url[2:12] != 'localhost/':
def open_file(self, url): """Use local file or FTP depending on form of URL.""" if url[:2] == '//' and url[2:3] != '/': return self.open_ftp(url) else: return self.open_local_file(url)
6de3155d2f0d782388371d6ab105e0fca9e38cce /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/6de3155d2f0d782388371d6ab105e0fca9e38cce/urllib.py
ra = (dir, 0, 16)
ra = (dir, 0, 2000)
def Listdir(self, dir): list = [] ra = (dir, 0, 16) while 1: (status, rest) = self.Readdir(ra) if status <> NFS_OK: break entries, eof = rest last_cookie = None for fileid, name, cookie in entries: print (fileid, name, cookie) # XXX list.append(fileid, name) last_cookie = cookie if eof or not last_cookie: break ra = (ra[0], last_cookie, ra[2]) return list
55641ecbd455a4a52d806017bb21032c88bdf84b /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/55641ecbd455a4a52d806017bb21032c88bdf84b/nfsclient.py
print (fileid, name, cookie)
def Listdir(self, dir): list = [] ra = (dir, 0, 16) while 1: (status, rest) = self.Readdir(ra) if status <> NFS_OK: break entries, eof = rest last_cookie = None for fileid, name, cookie in entries: print (fileid, name, cookie) # XXX list.append(fileid, name) last_cookie = cookie if eof or not last_cookie: break ra = (ra[0], last_cookie, ra[2]) return list
55641ecbd455a4a52d806017bb21032c88bdf84b /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/55641ecbd455a4a52d806017bb21032c88bdf84b/nfsclient.py
if eof or not last_cookie:
if eof or last_cookie == None:
def Listdir(self, dir): list = [] ra = (dir, 0, 16) while 1: (status, rest) = self.Readdir(ra) if status <> NFS_OK: break entries, eof = rest last_cookie = None for fileid, name, cookie in entries: print (fileid, name, cookie) # XXX list.append(fileid, name) last_cookie = cookie if eof or not last_cookie: break ra = (ra[0], last_cookie, ra[2]) return list
55641ecbd455a4a52d806017bb21032c88bdf84b /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/55641ecbd455a4a52d806017bb21032c88bdf84b/nfsclient.py
self.spawn ([self.rc] +
self.spawn ([self.rc] + pp_opts +
def compile(self, sources, output_dir=None, macros=None, include_dirs=None, debug=0, extra_preargs=None, extra_postargs=None, depends=None):
5c69d4705329b02b9d5696dba84b96c5ad739675 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/5c69d4705329b02b9d5696dba84b96c5ad739675/msvccompiler.py
>>> pik = pickle.dumps(x, 0) >>> dis(pik)
>>> pkl = pickle.dumps(x, 0) >>> dis(pkl)
def dis(pickle, out=None, indentlevel=4): """Produce a symbolic disassembly of a pickle. 'pickle' is a file-like object, or string, containing a (at least one) pickle. The pickle is disassembled from the current position, through the first STOP opcode encountered. Optional arg 'out' is a file-like object to which the disassembly is printed. It defaults to sys.stdout. Optional arg indentlevel is the number of blanks by which to indent a new MARK level. It defaults to 4. """ markstack = [] indentchunk = ' ' * indentlevel for opcode, arg, pos in genops(pickle): if pos is not None: print >> out, "%5d:" % pos, line = "%s %s%s" % (opcode.code, indentchunk * len(markstack), opcode.name) markmsg = None if markstack and markobject in opcode.stack_before: assert markobject not in opcode.stack_after markpos = markstack.pop() if markpos is not None: markmsg = "(MARK at %d)" % markpos if arg is not None or markmsg: # make a mild effort to align arguments line += ' ' * (10 - len(opcode.name)) if arg is not None: line += ' ' + repr(arg) if markmsg: line += ' ' + markmsg print >> out, line if markobject in opcode.stack_after: assert markobject not in opcode.stack_before markstack.append(pos)
e820e34f3bbe63e2b02c6b4a8286f7872d9c7184 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/e820e34f3bbe63e2b02c6b4a8286f7872d9c7184/pickletools.py
>>> pik = pickle.dumps(x, 1) >>> dis(pik)
>>> pkl = pickle.dumps(x, 1) >>> dis(pkl)
def dis(pickle, out=None, indentlevel=4): """Produce a symbolic disassembly of a pickle. 'pickle' is a file-like object, or string, containing a (at least one) pickle. The pickle is disassembled from the current position, through the first STOP opcode encountered. Optional arg 'out' is a file-like object to which the disassembly is printed. It defaults to sys.stdout. Optional arg indentlevel is the number of blanks by which to indent a new MARK level. It defaults to 4. """ markstack = [] indentchunk = ' ' * indentlevel for opcode, arg, pos in genops(pickle): if pos is not None: print >> out, "%5d:" % pos, line = "%s %s%s" % (opcode.code, indentchunk * len(markstack), opcode.name) markmsg = None if markstack and markobject in opcode.stack_before: assert markobject not in opcode.stack_after markpos = markstack.pop() if markpos is not None: markmsg = "(MARK at %d)" % markpos if arg is not None or markmsg: # make a mild effort to align arguments line += ' ' * (10 - len(opcode.name)) if arg is not None: line += ' ' + repr(arg) if markmsg: line += ' ' + markmsg print >> out, line if markobject in opcode.stack_after: assert markobject not in opcode.stack_before markstack.append(pos)
e820e34f3bbe63e2b02c6b4a8286f7872d9c7184 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/e820e34f3bbe63e2b02c6b4a8286f7872d9c7184/pickletools.py
49: p PUT 4 52: s SETITEM 53: b BUILD 54: a APPEND 55: g GET 1 58: a APPEND 59: . STOP
49: s SETITEM 50: b BUILD 51: a APPEND 52: g GET 1 55: a APPEND 56: . STOP
def dis(pickle, out=None, indentlevel=4): """Produce a symbolic disassembly of a pickle. 'pickle' is a file-like object, or string, containing a (at least one) pickle. The pickle is disassembled from the current position, through the first STOP opcode encountered. Optional arg 'out' is a file-like object to which the disassembly is printed. It defaults to sys.stdout. Optional arg indentlevel is the number of blanks by which to indent a new MARK level. It defaults to 4. """ markstack = [] indentchunk = ' ' * indentlevel for opcode, arg, pos in genops(pickle): if pos is not None: print >> out, "%5d:" % pos, line = "%s %s%s" % (opcode.code, indentchunk * len(markstack), opcode.name) markmsg = None if markstack and markobject in opcode.stack_before: assert markobject not in opcode.stack_after markpos = markstack.pop() if markpos is not None: markmsg = "(MARK at %d)" % markpos if arg is not None or markmsg: # make a mild effort to align arguments line += ' ' * (10 - len(opcode.name)) if arg is not None: line += ' ' + repr(arg) if markmsg: line += ' ' + markmsg print >> out, line if markobject in opcode.stack_after: assert markobject not in opcode.stack_before markstack.append(pos)
e820e34f3bbe63e2b02c6b4a8286f7872d9c7184 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/e820e34f3bbe63e2b02c6b4a8286f7872d9c7184/pickletools.py
__test__ = {'dissassembler_test': _dis_test,
__test__ = {'disassembler_test': _dis_test,
def dis(pickle, out=None, indentlevel=4): """Produce a symbolic disassembly of a pickle. 'pickle' is a file-like object, or string, containing a (at least one) pickle. The pickle is disassembled from the current position, through the first STOP opcode encountered. Optional arg 'out' is a file-like object to which the disassembly is printed. It defaults to sys.stdout. Optional arg indentlevel is the number of blanks by which to indent a new MARK level. It defaults to 4. """ markstack = [] indentchunk = ' ' * indentlevel for opcode, arg, pos in genops(pickle): if pos is not None: print >> out, "%5d:" % pos, line = "%s %s%s" % (opcode.code, indentchunk * len(markstack), opcode.name) markmsg = None if markstack and markobject in opcode.stack_before: assert markobject not in opcode.stack_after markpos = markstack.pop() if markpos is not None: markmsg = "(MARK at %d)" % markpos if arg is not None or markmsg: # make a mild effort to align arguments line += ' ' * (10 - len(opcode.name)) if arg is not None: line += ' ' + repr(arg) if markmsg: line += ' ' + markmsg print >> out, line if markobject in opcode.stack_after: assert markobject not in opcode.stack_before markstack.append(pos)
e820e34f3bbe63e2b02c6b4a8286f7872d9c7184 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/e820e34f3bbe63e2b02c6b4a8286f7872d9c7184/pickletools.py
def test_encoding_decoding(self): codecs = [('rot13', 'uryyb jbeyq'), ('base64', 'aGVsbG8gd29ybGQ=\n'), ('hex', '68656c6c6f20776f726c64'), ('uu', 'begin 666 <data>\n+:&5L;&\\@=V]R;&0 \n \nend\n')] for encoding, data in codecs: self.checkequal(data, 'hello world', 'encode', encoding) self.checkequal('hello world', data, 'decode', encoding) # zlib is optional, so we make the test optional too... try: import zlib except ImportError: pass else: data = 'x\x9c\xcbH\xcd\xc9\xc9W(\xcf/\xcaI\x01\x00\x1a\x0b\x04]' self.checkequal(data, 'hello world', 'encode', 'zlib') self.checkequal('hello world', data, 'decode', 'zlib')
d3f884d58ae7a4b1f1c8d2b7d275d33d4e3359b8 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/d3f884d58ae7a4b1f1c8d2b7d275d33d4e3359b8/string_tests.py
def getdefaultlocale(envvars=('LANGUAGE', 'LC_ALL', 'LC_CTYPE', 'LANG')):
def getdefaultlocale(envvars=('LC_ALL', 'LC_CTYPE', 'LANG', 'LANGUAGE')):
def getdefaultlocale(envvars=('LANGUAGE', 'LC_ALL', 'LC_CTYPE', 'LANG')): """ Tries to determine the default locale settings and returns them as tuple (language code, encoding). According to POSIX, a program which has not called setlocale(LC_ALL, "") runs using the portable 'C' locale. Calling setlocale(LC_ALL, "") lets it use the default locale as defined by the LANG variable. Since we don't want to interfere with the current locale setting we thus emulate the behavior in the way described above. To maintain compatibility with other platforms, not only the LANG variable is tested, but a list of variables given as envvars parameter. The first found to be defined will be used. envvars defaults to the search path used in GNU gettext; it must always contain the variable name 'LANG'. Except for the code 'C', the language code corresponds to RFC 1766. code and encoding can be None in case the values cannot be determined. """ try: # check if it's supported by the _locale module import _locale code, encoding = _locale._getdefaultlocale() except (ImportError, AttributeError): pass else: # make sure the code/encoding values are valid if sys.platform == "win32" and code and code[:2] == "0x": # map windows language identifier to language name code = windows_locale.get(int(code, 0)) # ...add other platform-specific processing here, if # necessary... return code, encoding # fall back on POSIX behaviour import os lookup = os.environ.get for variable in envvars: localename = lookup(variable,None) if localename: break else: localename = 'C' return _parse_localename(localename)
365b683b8eaaa4df0577f2b4f346d21d92ebb89f /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/365b683b8eaaa4df0577f2b4f346d21d92ebb89f/locale.py
target_version = self.target_version if not target_version: assert self.skip_build, "Should have already checked this" target_version = sys.version[0:3] plat_specifier = ".%s-%s" % (get_platform(), target_version) build = self.get_finalized_command('build') build.build_lib = os.path.join(build.build_base, 'lib' + plat_specifier)
if self.distribution.has_ext_modules(): target_version = self.target_version if not target_version: assert self.skip_build, "Should have already checked this" target_version = sys.version[0:3] plat_specifier = ".%s-%s" % (get_platform(), target_version) build = self.get_finalized_command('build') build.build_lib = os.path.join(build.build_base, 'lib' + plat_specifier)
def run (self): if (sys.platform != "win32" and (self.distribution.has_ext_modules() or self.distribution.has_c_libraries())): raise DistutilsPlatformError \ ("distribution contains extensions and/or C libraries; " "must be compiled on a Windows 32 platform")
35273a098530b427aa20c66d1ac572aaa9695987 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/35273a098530b427aa20c66d1ac572aaa9695987/bdist_wininst.py
flags = _checkflag(flag)
flags = _checkflag(flag, file)
def hashopen(file, flag='c', mode=0666, pgsize=None, ffactor=None, nelem=None, cachesize=None, lorder=None, hflags=0): flags = _checkflag(flag) e = _openDBEnv() d = db.DB(e) d.set_flags(hflags) if cachesize is not None: d.set_cachesize(0, cachesize) if pgsize is not None: d.set_pagesize(pgsize) if lorder is not None: d.set_lorder(lorder) if ffactor is not None: d.set_h_ffactor(ffactor) if nelem is not None: d.set_h_nelem(nelem) d.open(file, db.DB_HASH, flags, mode) return _DBWithCursor(d)
fa351d6367130ab630b19d72fec1727b61e0fa50 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/fa351d6367130ab630b19d72fec1727b61e0fa50/__init__.py
flags = _checkflag(flag)
flags = _checkflag(flag, file)
def btopen(file, flag='c', mode=0666, btflags=0, cachesize=None, maxkeypage=None, minkeypage=None, pgsize=None, lorder=None): flags = _checkflag(flag) e = _openDBEnv() d = db.DB(e) if cachesize is not None: d.set_cachesize(0, cachesize) if pgsize is not None: d.set_pagesize(pgsize) if lorder is not None: d.set_lorder(lorder) d.set_flags(btflags) if minkeypage is not None: d.set_bt_minkey(minkeypage) if maxkeypage is not None: d.set_bt_maxkey(maxkeypage) d.open(file, db.DB_BTREE, flags, mode) return _DBWithCursor(d)
fa351d6367130ab630b19d72fec1727b61e0fa50 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/fa351d6367130ab630b19d72fec1727b61e0fa50/__init__.py
flags = _checkflag(flag)
flags = _checkflag(flag, file)
def rnopen(file, flag='c', mode=0666, rnflags=0, cachesize=None, pgsize=None, lorder=None, rlen=None, delim=None, source=None, pad=None): flags = _checkflag(flag) e = _openDBEnv() d = db.DB(e) if cachesize is not None: d.set_cachesize(0, cachesize) if pgsize is not None: d.set_pagesize(pgsize) if lorder is not None: d.set_lorder(lorder) d.set_flags(rnflags) if delim is not None: d.set_re_delim(delim) if rlen is not None: d.set_re_len(rlen) if source is not None: d.set_re_source(source) if pad is not None: d.set_re_pad(pad) d.open(file, db.DB_RECNO, flags, mode) return _DBWithCursor(d)
fa351d6367130ab630b19d72fec1727b61e0fa50 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/fa351d6367130ab630b19d72fec1727b61e0fa50/__init__.py
def _checkflag(flag):
def _checkflag(flag, file):
def _checkflag(flag): if flag == 'r': flags = db.DB_RDONLY elif flag == 'rw': flags = 0 elif flag == 'w': flags = db.DB_CREATE elif flag == 'c': flags = db.DB_CREATE elif flag == 'n': flags = db.DB_CREATE | db.DB_TRUNCATE else: raise error, "flags should be one of 'r', 'w', 'c' or 'n'" return flags | db.DB_THREAD
fa351d6367130ab630b19d72fec1727b61e0fa50 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/fa351d6367130ab630b19d72fec1727b61e0fa50/__init__.py
flags = db.DB_CREATE | db.DB_TRUNCATE
flags = db.DB_CREATE if os.path.isfile(file): os.unlink(file)
def _checkflag(flag): if flag == 'r': flags = db.DB_RDONLY elif flag == 'rw': flags = 0 elif flag == 'w': flags = db.DB_CREATE elif flag == 'c': flags = db.DB_CREATE elif flag == 'n': flags = db.DB_CREATE | db.DB_TRUNCATE else: raise error, "flags should be one of 'r', 'w', 'c' or 'n'" return flags | db.DB_THREAD
fa351d6367130ab630b19d72fec1727b61e0fa50 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/fa351d6367130ab630b19d72fec1727b61e0fa50/__init__.py
pointer = -1
if self.cyclic: pointer = -1 else: self.text.bell() return
def history_do(self, reverse): nhist = len(self.history) pointer = self.history_pointer prefix = self.history_prefix if pointer is not None and prefix is not None: if self.text.compare("insert", "!=", "end-1c") or \ self._get_source("iomark", "end-1c") != self.history[pointer]: pointer = prefix = None if pointer is None or prefix is None: prefix = self._get_source("iomark", "end-1c") if reverse: pointer = nhist else: pointer = -1 nprefix = len(prefix) while 1: if reverse: pointer = pointer - 1 else: pointer = pointer + 1 if pointer < 0 or pointer >= nhist: self.text.bell() if self._get_source("iomark", "end-1c") != prefix: self.text.delete("iomark", "end-1c") self._put_source("iomark", prefix) pointer = prefix = None break item = self.history[pointer] if item[:nprefix] == prefix and len(item) > nprefix: self.text.delete("iomark", "end-1c") self._put_source("iomark", item) break self.text.mark_set("insert", "end-1c") self.text.see("insert") self.text.tag_remove("sel", "1.0", "end") self.history_pointer = pointer self.history_prefix = prefix
55b615749b98020a94d341ce4ef0a612643e9488 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/55b615749b98020a94d341ce4ef0a612643e9488/IdleHistory.py
if self._get_source("iomark", "end-1c") != prefix: self.text.delete("iomark", "end-1c") self._put_source("iomark", prefix) pointer = prefix = None
if not self.cyclic and pointer < 0: return else: if self._get_source("iomark", "end-1c") != prefix: self.text.delete("iomark", "end-1c") self._put_source("iomark", prefix) pointer = prefix = None
def history_do(self, reverse): nhist = len(self.history) pointer = self.history_pointer prefix = self.history_prefix if pointer is not None and prefix is not None: if self.text.compare("insert", "!=", "end-1c") or \ self._get_source("iomark", "end-1c") != self.history[pointer]: pointer = prefix = None if pointer is None or prefix is None: prefix = self._get_source("iomark", "end-1c") if reverse: pointer = nhist else: pointer = -1 nprefix = len(prefix) while 1: if reverse: pointer = pointer - 1 else: pointer = pointer + 1 if pointer < 0 or pointer >= nhist: self.text.bell() if self._get_source("iomark", "end-1c") != prefix: self.text.delete("iomark", "end-1c") self._put_source("iomark", prefix) pointer = prefix = None break item = self.history[pointer] if item[:nprefix] == prefix and len(item) > nprefix: self.text.delete("iomark", "end-1c") self._put_source("iomark", item) break self.text.mark_set("insert", "end-1c") self.text.see("insert") self.text.tag_remove("sel", "1.0", "end") self.history_pointer = pointer self.history_prefix = prefix
55b615749b98020a94d341ce4ef0a612643e9488 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/55b615749b98020a94d341ce4ef0a612643e9488/IdleHistory.py
(self.ac_out_buffer is '') and
(self.ac_out_buffer == '') and
def writable (self): "predicate for inclusion in the writable for select()" # return len(self.ac_out_buffer) or len(self.producer_fifo) or (not self.connected) # this is about twice as fast, though not as clear. return not ( (self.ac_out_buffer is '') and self.producer_fifo.is_empty() and self.connected )
a5b9589f4362f9bd6974aeb4e8e3a99f6aa46228 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/a5b9589f4362f9bd6974aeb4e8e3a99f6aa46228/asynchat.py
return t + data[9] - time.timezone
return t - data[9] - time.timezone
def mktime_tz(data): """Turn a 10-tuple as returned by parsedate_tz() into a UTC timestamp. Minor glitch: this first interprets the first 8 elements as a local time and then compensates for the timezone difference; this may yield a slight error around daylight savings time switch dates. Not enough to worry about for common use. """ t = time.mktime(data[:8] + (0,)) return t + data[9] - time.timezone
d59a4df6139825f85c7b33524d66ca129e6e0a8c /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/d59a4df6139825f85c7b33524d66ca129e6e0a8c/rfc822.py
self.tk.call('destroy', self._w)
def destroy(self): """Destroy this and all descendants widgets.""" for c in self.children.values(): c.destroy() if self.master.children.has_key(self._name): del self.master.children[self._name] self.tk.call('destroy', self._w) Misc.destroy(self)
47df10ee0222f7a68984860170833619a8a4702b /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/47df10ee0222f7a68984860170833619a8a4702b/Tkinter.py
def MultiCallIterator(results):
class MultiCallIterator:
def MultiCallIterator(results): """Iterates over the results of a multicall. Exceptions are thrown in response to xmlrpc faults.""" for i in results: if type(i) == type({}): raise Fault(i['faultCode'], i['faultString']) elif type(i) == type([]): yield i[0] else: raise ValueError,\ "unexpected type in multicall result"
966b7db4480744da47be1adf4595a30cbad7e3b8 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/966b7db4480744da47be1adf4595a30cbad7e3b8/xmlrpclib.py
for i in results: if type(i) == type({}): raise Fault(i['faultCode'], i['faultString']) elif type(i) == type([]): yield i[0]
def __init__(self, results): self.results = results def __getitem__(self, i): item = self.results[i] if type(item) == type({}): raise Fault(item['faultCode'], item['faultString']) elif type(item) == type([]): return item[0]
def MultiCallIterator(results): """Iterates over the results of a multicall. Exceptions are thrown in response to xmlrpc faults.""" for i in results: if type(i) == type({}): raise Fault(i['faultCode'], i['faultString']) elif type(i) == type([]): yield i[0] else: raise ValueError,\ "unexpected type in multicall result"
966b7db4480744da47be1adf4595a30cbad7e3b8 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/966b7db4480744da47be1adf4595a30cbad7e3b8/xmlrpclib.py
server = ServerProxy("http://betty.userland.com")
server = ServerProxy("http://time.xmlrpc.com/RPC2")
def __getattr__(self, name): # magic method dispatcher return _Method(self.__request, name)
966b7db4480744da47be1adf4595a30cbad7e3b8 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/966b7db4480744da47be1adf4595a30cbad7e3b8/xmlrpclib.py
print server.examples.getStateName(41)
print server.currentTime.getCurrentTime()
def __getattr__(self, name): # magic method dispatcher return _Method(self.__request, name)
966b7db4480744da47be1adf4595a30cbad7e3b8 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/966b7db4480744da47be1adf4595a30cbad7e3b8/xmlrpclib.py
if platform in ['cygwin', 'aix4']:
data = open('pyconfig.h').read() m = re.search(r" if m is not None:
def detect_modules(self): # Ensure that /usr/local is always used add_dir_to_list(self.compiler.library_dirs, '/usr/local/lib') add_dir_to_list(self.compiler.include_dirs, '/usr/local/include')
a4596da4f2d4b461fd6b12d533e57eee40949667 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/a4596da4f2d4b461fd6b12d533e57eee40949667/setup.py
if type(cmd) == type(''):
if isinstance(cmd, types.StringTypes):
def _run_child(self, cmd): if type(cmd) == type(''): cmd = ['/bin/sh', '-c', cmd] for i in range(3, MAXFD): try: os.close(i) except: pass try: os.execvp(cmd[0], cmd) finally: os._exit(1)
0e0aa7e74e4e91f0289a083d6637258dcb747c6b /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/0e0aa7e74e4e91f0289a083d6637258dcb747c6b/popen2.py
if verbose or generate:
if verbose:
def runtest(test, generate, verbose, quiet, testdir = None): """Run a single test. test -- the name of the test generate -- if true, generate output, instead of running the test and comparing it to a previously created output file verbose -- if true, print more messages quiet -- if true, don't print 'skipped' messages (probably redundant) testdir -- test directory """ test_support.unload(test) if not testdir: testdir = findtestdir() outputdir = os.path.join(testdir, "output") outputfile = os.path.join(outputdir, test) if verbose or generate: cfp = None else: cfp = StringIO.StringIO() try: save_stdout = sys.stdout try: if cfp: sys.stdout = cfp print test # Output file starts with test name the_module = __import__(test, globals(), locals(), []) # Most tests run to completion simply as a side-effect of # being imported. For the benefit of tests that can't run # that way (like test_threaded_import), explicitly invoke # their test_main() function (if it exists). indirect_test = getattr(the_module, "test_main", None) if indirect_test is not None: indirect_test() finally: sys.stdout = save_stdout except (ImportError, test_support.TestSkipped), msg: if not quiet: print "test", test, "skipped --", msg return -1 except KeyboardInterrupt: raise except test_support.TestFailed, msg: print "test", test, "failed --", msg return 0 except: type, value = sys.exc_info()[:2] print "test", test, "crashed --", str(type) + ":", value if verbose: traceback.print_exc(file=sys.stdout) return 0 else: if not cfp: return 1 output = cfp.getvalue() if generate: if output == test + "\n": if os.path.exists(outputfile): # Write it since it already exists (and the contents # may have changed), but let the user know it isn't # needed: print "output file", outputfile, \ "is no longer needed; consider removing it" else: # We don't need it, so don't create it. return 1 fp = open(outputfile, "w") fp.write(output) fp.close() return 1 if os.path.exists(outputfile): fp = open(outputfile, "r") expected = fp.read() fp.close() else: expected = test + "\n" if output == expected: return 1 print "test", test, "produced unexpected output:" reportdiff(expected, output) return 0
bc0687313eb3e9be12c95bde2ebf5a995628507a /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/bc0687313eb3e9be12c95bde2ebf5a995628507a/regrtest.py
raises(TypeError, "MRO conflict among bases ",
raises(TypeError, mro_err_msg,
def raises(exc, expected, callable, *args): try: callable(*args) except exc, msg: if not str(msg).startswith(expected): raise TestFailed, "Message %r, expected %r" % (str(msg), expected) else: raise TestFailed, "Expected %s" % exc
f42a988836b3d07ab416343b81e7c874dee1a65d /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/f42a988836b3d07ab416343b81e7c874dee1a65d/test_descr.py
raises(TypeError, "MRO conflict among bases ",
raises(TypeError, mro_err_msg,
def raises(exc, expected, callable, *args): try: callable(*args) except exc, msg: if not str(msg).startswith(expected): raise TestFailed, "Message %r, expected %r" % (str(msg), expected) else: raise TestFailed, "Expected %s" % exc
f42a988836b3d07ab416343b81e7c874dee1a65d /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/f42a988836b3d07ab416343b81e7c874dee1a65d/test_descr.py
raises(TypeError, "MRO conflict among bases ",
raises(TypeError, mro_err_msg,
def raises(exc, expected, callable, *args): try: callable(*args) except exc, msg: if not str(msg).startswith(expected): raise TestFailed, "Message %r, expected %r" % (str(msg), expected) else: raise TestFailed, "Expected %s" % exc
f42a988836b3d07ab416343b81e7c874dee1a65d /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/f42a988836b3d07ab416343b81e7c874dee1a65d/test_descr.py
def test_tzset(self): if not hasattr(time, "tzset"): return # Can't test this; don't want the test suite to fail
c76c215fe013317fd42034f213dc7844e465f313 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/c76c215fe013317fd42034f213dc7844e465f313/test_time.py
for tz in ('UTC','GMT','Luna/Tycho'): environ['TZ'] = 'US/Eastern' time.tzset() environ['TZ'] = tz time.tzset() self.failUnlessEqual( time.gmtime(xmas2002),time.localtime(xmas2002) ) self.failUnlessEqual(time.timezone,time.altzone) self.failUnlessEqual(time.daylight,0) self.failUnlessEqual(time.timezone,0) self.failUnlessEqual(time.altzone,0) self.failUnlessEqual(time.localtime(xmas2002).tm_isdst,0)
environ['TZ'] = eastern time.tzset() environ['TZ'] = utc time.tzset() self.failUnlessEqual( time.gmtime(xmas2002), time.localtime(xmas2002) ) self.failUnlessEqual(time.daylight, 0) self.failUnlessEqual(time.timezone, 0) self.failUnlessEqual(time.localtime(xmas2002).tm_isdst, 0)
def test_tzset(self): if not hasattr(time, "tzset"): return # Can't test this; don't want the test suite to fail
c76c215fe013317fd42034f213dc7844e465f313 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/c76c215fe013317fd42034f213dc7844e465f313/test_time.py
environ['TZ'] = 'US/Eastern'
environ['TZ'] = eastern
def test_tzset(self): if not hasattr(time, "tzset"): return # Can't test this; don't want the test suite to fail
c76c215fe013317fd42034f213dc7844e465f313 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/c76c215fe013317fd42034f213dc7844e465f313/test_time.py
self.failIfEqual(time.gmtime(xmas2002),time.localtime(xmas2002)) self.failUnlessEqual(time.tzname,('EST','EDT')) self.failUnlessEqual(len(time.tzname),2) self.failUnlessEqual(time.daylight,1) self.failUnlessEqual(time.timezone,18000) self.failUnlessEqual(time.altzone,14400) self.failUnlessEqual(time.localtime(xmas2002).tm_isdst,0) self.failUnlessEqual(len(time.tzname),2)
self.failIfEqual(time.gmtime(xmas2002), time.localtime(xmas2002)) self.failUnlessEqual(time.tzname, ('EST', 'EDT')) self.failUnlessEqual(len(time.tzname), 2) self.failUnlessEqual(time.daylight, 1) self.failUnlessEqual(time.timezone, 18000) self.failUnlessEqual(time.altzone, 14400) self.failUnlessEqual(time.localtime(xmas2002).tm_isdst, 0) self.failUnlessEqual(len(time.tzname), 2)
def test_tzset(self): if not hasattr(time, "tzset"): return # Can't test this; don't want the test suite to fail
c76c215fe013317fd42034f213dc7844e465f313 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/c76c215fe013317fd42034f213dc7844e465f313/test_time.py
environ['TZ'] = 'Australia/Melbourne'
environ['TZ'] = victoria
def test_tzset(self): if not hasattr(time, "tzset"): return # Can't test this; don't want the test suite to fail
c76c215fe013317fd42034f213dc7844e465f313 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/c76c215fe013317fd42034f213dc7844e465f313/test_time.py
self.failIfEqual(time.gmtime(xmas2002),time.localtime(xmas2002)) self.failUnless(time.tzname[0] in ('EST','AEST')) self.failUnless(time.tzname[1] in ('EST','EDT','AEDT')) self.failUnlessEqual(len(time.tzname),2) self.failUnlessEqual(time.daylight,1) self.failUnlessEqual(time.timezone,-36000) self.failUnlessEqual(time.altzone,-39600) self.failUnlessEqual(time.localtime(xmas2002).tm_isdst,1)
self.failIfEqual(time.gmtime(xmas2002), time.localtime(xmas2002)) self.failUnless(time.tzname[0] == 'AEST', str(time.tzname[0])) self.failUnless(time.tzname[1] == 'AEDT', str(time.tzname[1])) self.failUnlessEqual(len(time.tzname), 2) self.failUnlessEqual(time.daylight, 1) self.failUnlessEqual(time.timezone, -36000) self.failUnlessEqual(time.altzone, -39600) self.failUnlessEqual(time.localtime(xmas2002).tm_isdst, 1)
def test_tzset(self): if not hasattr(time, "tzset"): return # Can't test this; don't want the test suite to fail
c76c215fe013317fd42034f213dc7844e465f313 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/c76c215fe013317fd42034f213dc7844e465f313/test_time.py
del environ['TZ'] time.tzset() if time.timezone == 0: environ['TZ'] = 'US/Eastern' else: environ['TZ'] = 'UTC' time.tzset() nonlocal = time.localtime(xmas2002) del environ['TZ'] time.tzset() local = time.localtime(xmas2002) self.failIfEqual(local,nonlocal) self.failUnlessEqual(len(time.tzname),2) time.daylight time.timezone time.altzone
def test_tzset(self): if not hasattr(time, "tzset"): return # Can't test this; don't want the test suite to fail
c76c215fe013317fd42034f213dc7844e465f313 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/c76c215fe013317fd42034f213dc7844e465f313/test_time.py
vsbase = r"Software\Microsoft\VisualStudio\%s.0" % version
vsbase = r"Software\Microsoft\VisualStudio\%0.1f" % version
def load_macros(self, version): vsbase = r"Software\Microsoft\VisualStudio\%s.0" % version self.set_macro("VCInstallDir", vsbase + r"\Setup\VC", "productdir") self.set_macro("VSInstallDir", vsbase + r"\Setup\VS", "productdir") net = r"Software\Microsoft\.NETFramework" self.set_macro("FrameworkDir", net, "installroot") self.set_macro("FrameworkSDKDir", net, "sdkinstallroot")
707b559e89351210e54c4679ec1531fbd188e5af /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/707b559e89351210e54c4679ec1531fbd188e5af/msvccompiler.py
self.set_macro("FrameworkSDKDir", net, "sdkinstallroot")
if version > 7.0: self.set_macro("FrameworkSDKDir", net, "sdkinstallrootv1.1") else: self.set_macro("FrameworkSDKDir", net, "sdkinstallroot")
def load_macros(self, version): vsbase = r"Software\Microsoft\VisualStudio\%s.0" % version self.set_macro("VCInstallDir", vsbase + r"\Setup\VC", "productdir") self.set_macro("VSInstallDir", vsbase + r"\Setup\VS", "productdir") net = r"Software\Microsoft\.NETFramework" self.set_macro("FrameworkDir", net, "installroot") self.set_macro("FrameworkSDKDir", net, "sdkinstallroot")
707b559e89351210e54c4679ec1531fbd188e5af /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/707b559e89351210e54c4679ec1531fbd188e5af/msvccompiler.py
n = int(s[:-2]) if n == 12: return 6 elif n == 13: return 7
majorVersion = int(s[:-2]) - 6 minorVersion = int(s[2:3]) / 10.0 if majorVersion == 6: minorVersion = 0 if majorVersion >= 6: return majorVersion + minorVersion
def get_build_version(): """Return the version of MSVC that was used to build Python. For Python 2.3 and up, the version number is included in sys.version. For earlier versions, assume the compiler is MSVC 6. """ prefix = "MSC v." i = string.find(sys.version, prefix) if i == -1: return 6 i = i + len(prefix) s, rest = sys.version[i:].split(" ", 1) n = int(s[:-2]) if n == 12: return 6 elif n == 13: return 7 # else we don't know what version of the compiler this is return None
707b559e89351210e54c4679ec1531fbd188e5af /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/707b559e89351210e54c4679ec1531fbd188e5af/msvccompiler.py
if self.__version == 7:
if self.__version >= 7:
def __init__ (self, verbose=0, dry_run=0, force=0): CCompiler.__init__ (self, verbose, dry_run, force) self.__version = get_build_version() if self.__version == 7: self.__root = r"Software\Microsoft\VisualStudio" self.__macros = MacroExpander(self.__version) else: self.__root = r"Software\Microsoft\Devstudio" self.__paths = self.get_msvc_paths("path")
707b559e89351210e54c4679ec1531fbd188e5af /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/707b559e89351210e54c4679ec1531fbd188e5af/msvccompiler.py
if self.__version == 7: key = (r"%s\7.0\VC\VC_OBJECTS_PLATFORM_INFO\Win32\Directories" % (self.__root,))
if self.__version >= 7: key = (r"%s\%0.1f\VC\VC_OBJECTS_PLATFORM_INFO\Win32\Directories" % (self.__root, self.__version))
def get_msvc_paths(self, path, platform='x86'): """Get a list of devstudio directories (include, lib or path).
707b559e89351210e54c4679ec1531fbd188e5af /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/707b559e89351210e54c4679ec1531fbd188e5af/msvccompiler.py
if self.__version == 7:
if self.__version >= 7:
def get_msvc_paths(self, path, platform='x86'): """Get a list of devstudio directories (include, lib or path).
707b559e89351210e54c4679ec1531fbd188e5af /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/707b559e89351210e54c4679ec1531fbd188e5af/msvccompiler.py
def gen_id(self, dir, file):
def gen_id(self, file):
def gen_id(self, dir, file): logical = _logical = make_id(file) pos = 1 while logical in self.filenames: logical = "%s.%d" % (_logical, pos) pos += 1 self.filenames.add(logical) return logical
e92d02af2455263773065c2ab15400843055dece /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/e92d02af2455263773065c2ab15400843055dece/__init__.py
def append(self, full, logical):
def append(self, full, file, logical):
def append(self, full, logical): if os.path.isdir(full): return self.index += 1 self.files.append((full, logical)) return self.index, logical
e92d02af2455263773065c2ab15400843055dece /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/e92d02af2455263773065c2ab15400843055dece/__init__.py
sequence, logical = self.cab.append(absolute, logical)
sequence, logical = self.cab.append(absolute, file, logical)
def add_file(self, file, src=None, version=None, language=None): """Add a file to the current component of the directory, starting a new one one if there is no current component. By default, the file name in the source and the file table will be identical. If the src file is specified, it is interpreted relative to the current directory. Optionally, a version and a language can be specified for the entry in the File table.""" if not self.component: self.start_component(self.logical, current_feature, 0) if not src: # Allow relative paths for file if src is not specified src = file file = os.path.basename(file) absolute = os.path.join(self.absolute, src) assert not re.search(r'[\?|><:/*]"', file) # restrictions on long names if self.keyfiles.has_key(file): logical = self.keyfiles[file] else: logical = None sequence, logical = self.cab.append(absolute, logical) assert logical not in self.ids self.ids.add(logical) short = self.make_short(file) full = "%s|%s" % (short, file) filesize = os.stat(absolute).st_size # constants.msidbFileAttributesVital # Compressed omitted, since it is the database default # could add r/o, system, hidden attributes = 512 add_data(self.db, "File", [(logical, self.component, full, filesize, version, language, attributes, sequence)]) #if not version: # # Add hash if the file is not versioned # filehash = FileHash(absolute, 0) # add_data(self.db, "MsiFileHash", # [(logical, 0, filehash.IntegerData(1), # filehash.IntegerData(2), filehash.IntegerData(3), # filehash.IntegerData(4))]) # Automatically remove .pyc/.pyo files on uninstall (2) # XXX: adding so many RemoveFile entries makes installer unbelievably # slow. So instead, we have to use wildcard remove entries if file.endswith(".py"): add_data(self.db, "RemoveFile", [(logical+"c", self.component, "%sC|%sc" % (short, file), self.logical, 2), (logical+"o", self.component, "%sO|%so" % (short, file), self.logical, 2)]) return logical
e92d02af2455263773065c2ab15400843055dece /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/e92d02af2455263773065c2ab15400843055dece/__init__.py
def mapping(self, mapping, attribute):
def mapping(self, event, attribute):
def mapping(self, mapping, attribute): add_data(self.dlg.db, "EventMapping", [(self.dlg.name, self.name, event, attribute)])
e92d02af2455263773065c2ab15400843055dece /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/e92d02af2455263773065c2ab15400843055dece/__init__.py
print >> DEBUGSTREAM, 'we got some refusals'
print >> DEBUGSTREAM, 'we got some refusals:', refused
def process_message(self, peer, mailfrom, rcpttos, data): lines = data.split('\n') # Look for the last header i = 0 for line in lines: if not line: break i += 1 lines.insert(i, 'X-Peer: %s' % peer[0]) data = NEWLINE.join(lines) refused = self._deliver(mailfrom, rcpttos, data) # TBD: what to do with refused addresses? print >> DEBUGSTREAM, 'we got some refusals'
be3e352be45b63d1168727d245f93e7eecbfdba4 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/be3e352be45b63d1168727d245f93e7eecbfdba4/smtpd.py
print >> DEBUGSTREAM, 'we got refusals'
print >> DEBUGSTREAM, 'we got refusals:', refused
def process_message(self, peer, mailfrom, rcpttos, data): from cStringIO import StringIO from Mailman import Utils from Mailman import Message from Mailman import MailList # If the message is to a Mailman mailing list, then we'll invoke the # Mailman script directly, without going through the real smtpd. # Otherwise we'll forward it to the local proxy for disposition. listnames = [] for rcpt in rcpttos: local = rcpt.lower().split('@')[0] # We allow the following variations on the theme # listname # listname-admin # listname-owner # listname-request # listname-join # listname-leave parts = local.split('-') if len(parts) > 2: continue listname = parts[0] if len(parts) == 2: command = parts[1] else: command = '' if not Utils.list_exists(listname) or command not in ( '', 'admin', 'owner', 'request', 'join', 'leave'): continue listnames.append((rcpt, listname, command)) # Remove all list recipients from rcpttos and forward what we're not # going to take care of ourselves. Linear removal should be fine # since we don't expect a large number of recipients. for rcpt, listname, command in listnames: rcpttos.remove(rcpt) # If there's any non-list destined recipients left, print >> DEBUGSTREAM, 'forwarding recips:', ' '.join(rcpttos) if rcpttos: refused = self._deliver(mailfrom, rcpttos, data) # TBD: what to do with refused addresses? print >> DEBUGSTREAM, 'we got refusals' # Now deliver directly to the list commands mlists = {} s = StringIO(data) msg = Message.Message(s) # These headers are required for the proper execution of Mailman. All # MTAs in existance seem to add these if the original message doesn't # have them. if not msg.getheader('from'): msg['From'] = mailfrom if not msg.getheader('date'): msg['Date'] = time.ctime(time.time()) for rcpt, listname, command in listnames: print >> DEBUGSTREAM, 'sending message to', rcpt mlist = mlists.get(listname) if not mlist: mlist = MailList.MailList(listname, lock=0) mlists[listname] = mlist # dispatch on the type of command if command == '': # post msg.Enqueue(mlist, tolist=1) elif command == 'admin': msg.Enqueue(mlist, toadmin=1) elif command == 'owner': msg.Enqueue(mlist, toowner=1) elif command == 'request': msg.Enqueue(mlist, torequest=1) elif command in ('join', 'leave'): # TBD: this is a hack! if command == 'join': msg['Subject'] = 'subscribe' else: msg['Subject'] = 'unsubscribe' msg.Enqueue(mlist, torequest=1)
be3e352be45b63d1168727d245f93e7eecbfdba4 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/be3e352be45b63d1168727d245f93e7eecbfdba4/smtpd.py
mode = (os.stat(file)[ST_MODE]) | 0111
mode = ((os.stat(file)[ST_MODE]) | 0111) & 07777
def run (self): if not self.skip_build: self.run_command('build_scripts') self.outfiles = self.copy_tree(self.build_dir, self.install_dir) if os.name == 'posix': # Set the executable bits (owner, group, and world) on # all the scripts we just installed. for file in self.get_outputs(): if self.dry_run: self.announce("changing mode of %s" % file) else: mode = (os.stat(file)[ST_MODE]) | 0111 self.announce("changing mode of %s to %o" % (file, mode)) os.chmod(file, mode)
cb8eda5df142a9083c64dda6b82c9d69f7635b23 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/cb8eda5df142a9083c64dda6b82c9d69f7635b23/install_scripts.py
self.apply() self.cancel()
try: self.apply() finally: self.cancel()
def ok(self, event=None):
979bf97d923432c0969da7f760359818211d0c72 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/979bf97d923432c0969da7f760359818211d0c72/tkSimpleDialog.py
if sys.maxint == 2**32-1:
if sys.maxint == 2**31-1:
def test_exc(formatstr, args, exception, excmsg): try: testformat(formatstr, args) except exception, exc: if str(exc) == excmsg: if verbose: print "yes" else: if verbose: print 'no' print 'Unexpected ', exception, ':', repr(str(exc)) except: if verbose: print 'no' print 'Unexpected exception' raise else: raise TestFailed, 'did not get expected exception: %s' % excmsg
b18ad47fbd334ab2635bbf9367c5460d356aec8a /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/b18ad47fbd334ab2635bbf9367c5460d356aec8a/test_format.py
def read(self, wtd):
def read(self, totalwtd):
def read(self, wtd):
a5315e042f4b144f46c73bc05a8aa7c00b962a20 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/a5315e042f4b144f46c73bc05a8aa7c00b962a20/binhex.py
wtd = wtd - len(decdata)
wtd = totalwtd - len(decdata)
def read(self, wtd):
a5315e042f4b144f46c73bc05a8aa7c00b962a20 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/a5315e042f4b144f46c73bc05a8aa7c00b962a20/binhex.py
if filecrc != self.crc: raise Error, 'CRC error, computed %x, read %x'%(self.crc, filecrc)
def _checkcrc(self):
a5315e042f4b144f46c73bc05a8aa7c00b962a20 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/a5315e042f4b144f46c73bc05a8aa7c00b962a20/binhex.py
l = 2.0 * radius * sin(w2*self._invradian)
l = 2.0 * radius * sin(w2*self._invradian)
def circle(self, radius, extent = None): """ Draw a circle with given radius. The center is radius units left of the turtle; extent determines which part of the circle is drawn. If not given, the entire circle is drawn.
6705b686e7342f5c7e6943c7dba10a5cfd3c9d29 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/6705b686e7342f5c7e6943c7dba10a5cfd3c9d29/turtle.py
if not (self.have_fork or self.have_popen2):
if not (self.have_fork or self.have_popen2 or self.have_popen3):
def run_cgi(self): """Execute a CGI script.""" dir, rest = self.cgi_info i = rest.rfind('?') if i >= 0: rest, query = rest[:i], rest[i+1:] else: query = '' i = rest.find('/') if i >= 0: script, rest = rest[:i], rest[i:] else: script, rest = rest, '' scriptname = dir + '/' + script scriptfile = self.translate_path(scriptname) if not os.path.exists(scriptfile): self.send_error(404, "No such CGI script (%s)" % `scriptname`) return if not os.path.isfile(scriptfile): self.send_error(403, "CGI script is not a plain file (%s)" % `scriptname`) return ispy = self.is_python(scriptname) if not ispy: if not (self.have_fork or self.have_popen2): self.send_error(403, "CGI script is not a Python script (%s)" % `scriptname`) return if not self.is_executable(scriptfile): self.send_error(403, "CGI script is not executable (%s)" % `scriptname`) return
340d57e5237df8a3b0c0cbb116af2c7c60bd9afc /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/340d57e5237df8a3b0c0cbb116af2c7c60bd9afc/CGIHTTPServer.py
elif self.have_popen2:
elif self.have_popen2 or self.have_popen3:
def run_cgi(self): """Execute a CGI script.""" dir, rest = self.cgi_info i = rest.rfind('?') if i >= 0: rest, query = rest[:i], rest[i+1:] else: query = '' i = rest.find('/') if i >= 0: script, rest = rest[:i], rest[i:] else: script, rest = rest, '' scriptname = dir + '/' + script scriptfile = self.translate_path(scriptname) if not os.path.exists(scriptfile): self.send_error(404, "No such CGI script (%s)" % `scriptname`) return if not os.path.isfile(scriptfile): self.send_error(403, "CGI script is not a plain file (%s)" % `scriptname`) return ispy = self.is_python(scriptname) if not ispy: if not (self.have_fork or self.have_popen2): self.send_error(403, "CGI script is not a Python script (%s)" % `scriptname`) return if not self.is_executable(scriptfile): self.send_error(403, "CGI script is not executable (%s)" % `scriptname`) return
340d57e5237df8a3b0c0cbb116af2c7c60bd9afc /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/340d57e5237df8a3b0c0cbb116af2c7c60bd9afc/CGIHTTPServer.py
fi, fo = os.popen2(cmdline, 'b')
files = popenx(cmdline, 'b') fi = files[0] fo = files[1] if self.have_popen3: fe = files[2]
def run_cgi(self): """Execute a CGI script.""" dir, rest = self.cgi_info i = rest.rfind('?') if i >= 0: rest, query = rest[:i], rest[i+1:] else: query = '' i = rest.find('/') if i >= 0: script, rest = rest[:i], rest[i:] else: script, rest = rest, '' scriptname = dir + '/' + script scriptfile = self.translate_path(scriptname) if not os.path.exists(scriptfile): self.send_error(404, "No such CGI script (%s)" % `scriptname`) return if not os.path.isfile(scriptfile): self.send_error(403, "CGI script is not a plain file (%s)" % `scriptname`) return ispy = self.is_python(scriptname) if not ispy: if not (self.have_fork or self.have_popen2): self.send_error(403, "CGI script is not a Python script (%s)" % `scriptname`) return if not self.is_executable(scriptfile): self.send_error(403, "CGI script is not executable (%s)" % `scriptname`) return
340d57e5237df8a3b0c0cbb116af2c7c60bd9afc /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/340d57e5237df8a3b0c0cbb116af2c7c60bd9afc/CGIHTTPServer.py
if result[0] == '%':
if not result or result[0] == '%':
def strftest(now): if verbose: print "strftime test for", time.ctime(now) nowsecs = str(long(now))[:-1] gmt = time.gmtime(now) now = time.localtime(now) if now[3] < 12: ampm='AM' else: ampm='PM' jan1 = time.localtime(time.mktime((now[0], 1, 1) + (0,)*6)) try: if now[8]: tz = time.tzname[1] else: tz = time.tzname[0] except AttributeError: tz = '' if now[3] > 12: clock12 = now[3] - 12 elif now[3] > 0: clock12 = now[3] else: clock12 = 12 expectations = ( ('%a', calendar.day_abbr[now[6]], 'abbreviated weekday name'), ('%A', calendar.day_name[now[6]], 'full weekday name'), ('%b', calendar.month_abbr[now[1]], 'abbreviated month name'), ('%B', calendar.month_name[now[1]], 'full month name'), # %c see below ('%d', '%02d' % now[2], 'day of month as number (00-31)'), ('%H', '%02d' % now[3], 'hour (00-23)'), ('%I', '%02d' % clock12, 'hour (01-12)'), ('%j', '%03d' % now[7], 'julian day (001-366)'), ('%m', '%02d' % now[1], 'month as number (01-12)'), ('%M', '%02d' % now[4], 'minute, (00-59)'), ('%p', ampm, 'AM or PM as appropriate'), ('%S', '%02d' % now[5], 'seconds of current time (00-60)'), ('%U', '%02d' % ((now[7] + jan1[6])/7), 'week number of the year (Sun 1st)'), ('%w', '0?%d' % ((1+now[6]) % 7), 'weekday as a number (Sun 1st)'), ('%W', '%02d' % ((now[7] + (jan1[6] - 1)%7)/7), 'week number of the year (Mon 1st)'), # %x see below ('%X', '%02d:%02d:%02d' % (now[3], now[4], now[5]), '%H:%M:%S'), ('%y', '%02d' % (now[0]%100), 'year without century'), ('%Y', '%d' % now[0], 'year with century'), # %Z see below ('%%', '%', 'single percent sign'), ) nonstandard_expectations = ( # These are standard but don't have predictable output ('%c', fixasctime(time.asctime(now)), 'near-asctime() format'), ('%x', '%02d/%02d/%02d' % (now[1], now[2], (now[0]%100)), '%m/%d/%y %H:%M:%S'), ('%Z', '%s' % tz, 'time zone name'), # These are some platform specific extensions ('%D', '%02d/%02d/%02d' % (now[1], now[2], (now[0]%100)), 'mm/dd/yy'), ('%e', '%2d' % now[2], 'day of month as number, blank padded ( 0-31)'), ('%h', calendar.month_abbr[now[1]], 'abbreviated month name'), ('%k', '%2d' % now[3], 'hour, blank padded ( 0-23)'), ('%n', '\n', 'newline character'), ('%r', '%02d:%02d:%02d %s' % (clock12, now[4], now[5], ampm), '%I:%M:%S %p'), ('%R', '%02d:%02d' % (now[3], now[4]), '%H:%M'), ('%s', nowsecs, 'seconds since the Epoch in UCT'), ('%t', '\t', 'tab character'), ('%T', '%02d:%02d:%02d' % (now[3], now[4], now[5]), '%H:%M:%S'), ('%3y', '%03d' % (now[0]%100), 'year without century rendered using fieldwidth'), ) if verbose: print "Strftime test, platform: %s, Python version: %s" % \ (sys.platform, string.split(sys.version)[0]) for e in expectations: try: result = time.strftime(e[0], now) except ValueError, error: print "Standard '%s' format gave error:" % e[0], error continue if re.match(e[1], result): continue if result[0] == '%': print "Does not support standard '%s' format (%s)" % (e[0], e[2]) else: print "Conflict for %s (%s):" % (e[0], e[2]) print " Expected %s, but got %s" % (e[1], result) for e in nonstandard_expectations: try: result = time.strftime(e[0], now) except ValueError, result: if verbose: print "Error for nonstandard '%s' format (%s): %s" % \ (e[0], e[2], str(result)) continue if re.match(e[1], result): if verbose: print "Supports nonstandard '%s' format (%s)" % (e[0], e[2]) elif result[0] == '%': if verbose: print "Does not appear to support '%s' format (%s)" % (e[0], e[2]) else: if verbose: print "Conflict for nonstandard '%s' format (%s):" % (e[0], e[2]) print " Expected %s, but got %s" % (e[1], result)
fcbff64326f7f64b1b9dd7bd246596c41ed2ae75 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/fcbff64326f7f64b1b9dd7bd246596c41ed2ae75/test_strftime.py
sf = open(slave, 'rb')
sf = open(slave, 'r')
def compare(slave, master): try: sf = open(slave, 'rb') except IOError: sf = None try: mf = open(master, 'rb') except IOError: mf = None if not sf: if not mf: print "Not updating missing master", master return print "Creating missing slave", slave copy(master, slave, answer=create_files) return if sf and mf: if identical(sf, mf): return sft = mtime(sf) mft = mtime(mf) if mft > sft: # Master is newer -- copy master to slave sf.close() mf.close() print "Master ", master print "is newer than slave", slave copy(master, slave, answer=write_slave) return # Slave is newer -- copy slave to master # But first check what to do about CRLF mf.seek(0) fun = funnychars(mf) mf.close() sf.close() if fun: print "***UPDATING MASTER (BINARY COPY)***" copy(slave, master, "rb", answer=write_master) else: print "***UPDATING MASTER***" copy(slave, master, "r", answer=write_master)
537a688620a50a2c09ebacca4cc68fe544e676da /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/537a688620a50a2c09ebacca4cc68fe544e676da/treesync.py
print "Not updating missing master", master
print "Neither master nor slave exists", master
def compare(slave, master): try: sf = open(slave, 'rb') except IOError: sf = None try: mf = open(master, 'rb') except IOError: mf = None if not sf: if not mf: print "Not updating missing master", master return print "Creating missing slave", slave copy(master, slave, answer=create_files) return if sf and mf: if identical(sf, mf): return sft = mtime(sf) mft = mtime(mf) if mft > sft: # Master is newer -- copy master to slave sf.close() mf.close() print "Master ", master print "is newer than slave", slave copy(master, slave, answer=write_slave) return # Slave is newer -- copy slave to master # But first check what to do about CRLF mf.seek(0) fun = funnychars(mf) mf.close() sf.close() if fun: print "***UPDATING MASTER (BINARY COPY)***" copy(slave, master, "rb", answer=write_master) else: print "***UPDATING MASTER***" copy(slave, master, "r", answer=write_master)
537a688620a50a2c09ebacca4cc68fe544e676da /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/537a688620a50a2c09ebacca4cc68fe544e676da/treesync.py
fp = open(pathname, "U")
if hasattr(sys.stdout, "newlines"): fp = open(pathname, "U") else: fp = open(pathname, "r")
def run_script(self, pathname): self.msg(2, "run_script", pathname) fp = open(pathname, "U") stuff = ("", "r", imp.PY_SOURCE) self.load_module('__main__', fp, pathname, stuff)
8e41ce0c0941ba25eebbd9b2526796e610f8b239 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/8e41ce0c0941ba25eebbd9b2526796e610f8b239/modulefinder.py
fp = open(pathname, "U")
if hasattr(sys.stdout, "newlines"): fp = open(pathname, "U") else: fp = open(pathname, "r")
def load_file(self, pathname): dir, name = os.path.split(pathname) name, ext = os.path.splitext(name) fp = open(pathname, "U") stuff = (ext, "r", imp.PY_SOURCE) self.load_module(name, fp, pathname, stuff)
8e41ce0c0941ba25eebbd9b2526796e610f8b239 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/8e41ce0c0941ba25eebbd9b2526796e610f8b239/modulefinder.py
if string.find (args[i], ' ') == -1:
if string.find (args[i], ' ') != -1:
def _nt_quote_args (args): """Obscure quoting command line arguments on NT. Simply quote every argument which contains blanks.""" # XXX this doesn't seem very robust to me -- but if the Windows guys # say it'll work, I guess I'll have to accept it. (What if an arg # contains quotes? What other magic characters, other than spaces, # have to be escaped? Is there an escaping mechanism other than # quoting?) for i in range (len (args)): if string.find (args[i], ' ') == -1: args[i] = '"%s"' % args[i]
d2f6b81029ba576677d56e1660602913b433575f /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/d2f6b81029ba576677d56e1660602913b433575f/spawn.py
return
def _nt_quote_args (args): """Obscure quoting command line arguments on NT. Simply quote every argument which contains blanks.""" # XXX this doesn't seem very robust to me -- but if the Windows guys # say it'll work, I guess I'll have to accept it. (What if an arg # contains quotes? What other magic characters, other than spaces, # have to be escaped? Is there an escaping mechanism other than # quoting?) for i in range (len (args)): if string.find (args[i], ' ') == -1: args[i] = '"%s"' % args[i]
d2f6b81029ba576677d56e1660602913b433575f /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/d2f6b81029ba576677d56e1660602913b433575f/spawn.py