rem
stringlengths
1
322k
add
stringlengths
0
2.05M
context
stringlengths
4
228k
meta
stringlengths
156
215
def ignorableWhitespace(self, chars, start, end): self._cont_handler.ignorableWhitespace(chars, start, end)
def ignorableWhitespace(self, chars): self._cont_handler.ignorableWhitespace(chars)
def ignorableWhitespace(self, chars, start, end): self._cont_handler.ignorableWhitespace(chars, start, end)
8b9127bd16aca63117be9739a1e5bb7295ad6e96 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/8b9127bd16aca63117be9739a1e5bb7295ad6e96/saxutils.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
ce4b99884426df4241b8bc5e63b6ecaec0d33b4c /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/ce4b99884426df4241b8bc5e63b6ecaec0d33b4c/test_extcall.py
if keys:
if random.random() < 0.2: mutate = 0 while 1: newkey = Horrid(random.randrange(100)) if newkey not in target: break target[newkey] = Horrid(random.randrange(100)) keys.append(newkey) mutate = 1 elif keys:
def maybe_mutate(): if not mutate: return if random.random() < 0.5: return if random.random() < 0.5: target, keys = dict1, dict1keys else: target, keys = dict2, dict2keys if keys: i = random.randrange(len(keys)) key = keys[i] del target[key] # CAUTION: don't use keys.remove(key) here. Or do <wink>. The # point is that .remove() would trigger more comparisons, and so # also more calls to this routine. We're mutating often enough # without that. del keys[i]
f466d7780f5662f0b79fcf3b0effd337a7c429a6 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/f466d7780f5662f0b79fcf3b0effd337a7c429a6/test_mutants.py
vesion string using the format major.minor.build (or patchlevel).
version string using the format major.minor.build (or patchlevel).
def _norm_version(version,build=''): """ Normalize the version and build strings and return a single vesion string using the format major.minor.build (or patchlevel). """ l = string.split(version,'.') if build: l.append(build) try: ints = map(int,l) except ValueError: strings = l else: strings = map(str,ints) version = string.join(strings[:3],'.') return version
3c806fd8c7c65966f9cdd6f1d4524c45eb678b29 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/3c806fd8c7c65966f9cdd6f1d4524c45eb678b29/platform.py
self.literal = 0
def goahead(self, end): rawdata = self.rawdata i = 0 n = len(rawdata) while i < n: if i > 0: self.__at_start = 0 if self.nomoretags: data = rawdata[i:n] self.handle_data(data) self.lineno = self.lineno + string.count(data, '\n') i = n break res = interesting.search(rawdata, i) if res: j = res.start(0) else: j = n if i < j: if self.__at_start: self.syntax_error('illegal data at start of file') self.__at_start = 0 data = rawdata[i:j] if not self.stack and space.match(data) is None: self.syntax_error('data not in content') if illegal.search(data): self.syntax_error('illegal character in content') self.handle_data(data) self.lineno = self.lineno + string.count(data, '\n') i = j if i == n: break if rawdata[i] == '<': if starttagopen.match(rawdata, i): if self.literal: data = rawdata[i] self.handle_data(data) self.lineno = self.lineno + string.count(data, '\n') i = i+1 continue k = self.parse_starttag(i) if k < 0: break self.__seen_starttag = 1 self.lineno = self.lineno + string.count(rawdata[i:k], '\n') i = k continue if endtagopen.match(rawdata, i): k = self.parse_endtag(i) if k < 0: break self.lineno = self.lineno + string.count(rawdata[i:k], '\n') i = k self.literal = 0 continue if commentopen.match(rawdata, i): if self.literal: data = rawdata[i] self.handle_data(data) self.lineno = self.lineno + string.count(data, '\n') i = i+1 continue k = self.parse_comment(i) if k < 0: break self.lineno = self.lineno + string.count(rawdata[i:k], '\n') i = k continue if cdataopen.match(rawdata, i): k = self.parse_cdata(i) if k < 0: break self.lineno = self.lineno + string.count(rawdata[i:i], '\n') i = k continue res = xmldecl.match(rawdata, i) if res: if not self.__at_start: self.syntax_error("<?xml?> declaration not at start of document") version, encoding, standalone = res.group('version', 'encoding', 'standalone') if version[1:-1] != '1.0': raise RuntimeError, 'only XML version 1.0 supported' if encoding: encoding = encoding[1:-1] if standalone: standalone = standalone[1:-1] self.handle_xml(encoding, standalone) i = res.end(0) continue res = procopen.match(rawdata, i) if res: k = self.parse_proc(i) if k < 0: break self.lineno = self.lineno + string.count(rawdata[i:k], '\n') i = k continue res = doctype.match(rawdata, i) if res: if self.literal: data = rawdata[i] self.handle_data(data) self.lineno = self.lineno + string.count(data, '\n') i = i+1 continue if self.__seen_doctype: self.syntax_error('multiple DOCTYPE elements') if self.__seen_starttag: self.syntax_error('DOCTYPE not at beginning of document') k = self.parse_doctype(res) if k < 0: break self.__seen_doctype = res.group('name') self.lineno = self.lineno + string.count(rawdata[i:k], '\n') i = k continue elif rawdata[i] == '&': res = charref.match(rawdata, i) if res is not None: i = res.end(0) if rawdata[i-1] != ';': self.syntax_error("`;' missing in charref") i = i-1 if not self.stack: self.syntax_error('data not in content') self.handle_charref(res.group('char')[:-1]) self.lineno = self.lineno + string.count(res.group(0), '\n') continue res = entityref.match(rawdata, i) if res is not None: i = res.end(0) if rawdata[i-1] != ';': self.syntax_error("`;' missing in entityref") i = i-1 name = res.group('name') if self.entitydefs.has_key(name): self.rawdata = rawdata = rawdata[:res.start(0)] + self.entitydefs[name] + rawdata[i:] n = len(rawdata) i = res.start(0) else: self.syntax_error('reference to unknown entity') self.unknown_entityref(name) self.lineno = self.lineno + string.count(res.group(0), '\n') continue elif rawdata[i] == ']': if n-i < 3: break if cdataclose.match(rawdata, i): self.syntax_error("bogus `]]>'") self.handle_data(rawdata[i]) i = i+1 continue else: raise RuntimeError, 'neither < nor & ??' # We get here only if incomplete matches but # nothing else break # end while if i > 0: self.__at_start = 0 if end and i < n: data = rawdata[i] self.syntax_error("bogus `%s'" % data) if illegal.search(data): self.syntax_error('illegal character in content') self.handle_data(data) self.lineno = self.lineno + string.count(data, '\n') self.rawdata = rawdata[i+1:] return self.goahead(end) self.rawdata = rawdata[i:] if end: if not self.__seen_starttag: self.syntax_error('no elements in file') if self.stack: self.syntax_error('missing end tags') while self.stack: self.finish_endtag(self.stack[-1])
6b6939b832e17eff3a8d5dc9654536dfa5340dd2 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/6b6939b832e17eff3a8d5dc9654536dfa5340dd2/xmllib.py
if self.fp and not self._filePassed: self.fp.close() self.fp = None
self.close()
def __del__(self): """Call the "close()" method in case the user forgot.""" if self.fp and not self._filePassed: self.fp.close() self.fp = None
d3370159b022d9ee4f2d8e790fdcb3451a5fbe0a /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/d3370159b022d9ee4f2d8e790fdcb3451a5fbe0a/zipfile.py
sys.stderr.write(py_exc.msg)
sys.stderr.write(py_exc.msg + '\n')
def compile(file, cfile=None, dfile=None, doraise=False): """Byte-compile one Python source file to Python bytecode. Arguments: file: source filename cfile: target filename; defaults to source with 'c' or 'o' appended ('c' normally, 'o' in optimizing mode, giving .pyc or .pyo) dfile: purported filename; defaults to source (this is the filename that will show up in error messages) doraise: flag indicating whether or not an exception should be raised when a compile error is found. If an exception occurs and this flag is set to False, a string indicating the nature of the exception will be printed, and the function will return to the caller. If an exception occurs and this flag is set to True, a PyCompileError exception will be raised. Note that it isn't necessary to byte-compile Python modules for execution efficiency -- Python itself byte-compiles a module when it is loaded, and if it can, writes out the bytecode to the corresponding .pyc (or .pyo) file. However, if a Python installation is shared between users, it is a good idea to byte-compile all modules upon installation, since other users may not be able to write in the source directories, and thus they won't be able to write the .pyc/.pyo file, and then they would be byte-compiling every module each time it is loaded. This can slow down program start-up considerably. See compileall.py for a script/module that uses this module to byte-compile all installed files (or all files in selected directories). """ f = open(file, 'U') try: timestamp = long(os.fstat(f.fileno()).st_mtime) except AttributeError: timestamp = long(os.stat(file).st_mtime) codestring = f.read() f.close() if codestring and codestring[-1] != '\n': codestring = codestring + '\n' try: codeobject = __builtin__.compile(codestring, dfile or file,'exec') except Exception,err: py_exc = PyCompileError(err.__class__,err.args,dfile or file) if doraise: raise py_exc else: sys.stderr.write(py_exc.msg) return if cfile is None: cfile = file + (__debug__ and 'c' or 'o') fc = open(cfile, 'wb') fc.write('\0\0\0\0') wr_long(fc, timestamp) marshal.dump(codeobject, fc) fc.flush() fc.seek(0, 0) fc.write(MAGIC) fc.close() set_creator_type(cfile)
937d95e15115155d11a5a130e7a4b1c2fc737801 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/937d95e15115155d11a5a130e7a4b1c2fc737801/py_compile.py
all = self.db.guess_all_extensions('text/plain', strict=True) all.sort() eq(all, ['.bat', '.c', '.h', '.ksh', '.pl', '.txt'])
unless = self.failUnless all = Set(self.db.guess_all_extensions('text/plain', strict=True)) unless(all >= Set(['.bat', '.c', '.h', '.ksh', '.pl', '.txt']))
def test_guess_all_types(self): eq = self.assertEqual # First try strict all = self.db.guess_all_extensions('text/plain', strict=True) all.sort() eq(all, ['.bat', '.c', '.h', '.ksh', '.pl', '.txt']) # And now non-strict all = self.db.guess_all_extensions('image/jpg', strict=False) all.sort() eq(all, ['.jpg']) # And now for no hits all = self.db.guess_all_extensions('image/jpg', strict=True) eq(all, [])
555743164917b1292f01f2d1ede56ac40922d179 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/555743164917b1292f01f2d1ede56ac40922d179/test_mimetypes.py
'tk' + version )
lib_prefix + 'tk' + version)
def detect_tkinter(self, inc_dirs, lib_dirs): # The _tkinter module.
8b8fd376985b066da901a32834f43edf285e1020 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/8b8fd376985b066da901a32834f43edf285e1020/setup.py
'tcl' + version )
lib_prefix + 'tcl' + version)
def detect_tkinter(self, inc_dirs, lib_dirs): # The _tkinter module.
8b8fd376985b066da901a32834f43edf285e1020 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/8b8fd376985b066da901a32834f43edf285e1020/setup.py
if platform == 'cygwin': x11_inc = find_file('X11/Xlib.h', [], inc_dirs) if x11_inc is None: return
def detect_tkinter(self, inc_dirs, lib_dirs): # The _tkinter module.
8b8fd376985b066da901a32834f43edf285e1020 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/8b8fd376985b066da901a32834f43edf285e1020/setup.py
libs.append('tk'+version) libs.append('tcl'+version)
libs.append(lib_prefix + 'tk'+ version) libs.append(lib_prefix + 'tcl'+ version)
def detect_tkinter(self, inc_dirs, lib_dirs): # The _tkinter module.
8b8fd376985b066da901a32834f43edf285e1020 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/8b8fd376985b066da901a32834f43edf285e1020/setup.py
elif 'r' in how: l_type = FCNTL.F_WRLCK
elif 'r' in how: l_type = FCNTL.F_RDLCK
def lock(self, how, *args):
7587a7b1dc1a9f75b80be752a51ab4f10bee3f1d /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/7587a7b1dc1a9f75b80be752a51ab4f10bee3f1d/posixfile.py
def test_getstatus(self): # This pattern should match 'ls -ld /.' on any posix # system, however perversely configured. pat = r'''d......... # It is a directory. \s+\d+ # It has some number of links. \s+\w+\s+\w+ # It has a user and group, which may # be named anything. \s+\d+ # It has a size. [^/]* # Skip the date. /\. # and end with the name of the file. '''
d9604439c0135981bfa31ed293f5a09af7011ea2 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/d9604439c0135981bfa31ed293f5a09af7011ea2/test_commands.py
\s+\w+\s+\w+ \s+\d+ [^/]*
[^/]*
def test_getstatus(self): # This pattern should match 'ls -ld /.' on any posix # system, however perversely configured. pat = r'''d......... # It is a directory. \s+\d+ # It has some number of links. \s+\w+\s+\w+ # It has a user and group, which may # be named anything. \s+\d+ # It has a size. [^/]* # Skip the date. /\. # and end with the name of the file. '''
d9604439c0135981bfa31ed293f5a09af7011ea2 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/d9604439c0135981bfa31ed293f5a09af7011ea2/test_commands.py
def find_module(self, name, path): if name in self.excludes: self.msgout(3, "find_module -> Excluded") raise ImportError, name
f76d2492b70d1f6611db7cb5cfdcbd539957f4e9 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/f76d2492b70d1f6611db7cb5cfdcbd539957f4e9/modulefinder.py
import _winreg from _winreg import HKEY_LOCAL_MACHINE try: pathname = _winreg.QueryValueEx(HKEY_LOCAL_MACHINE, \ "Software\\Python\\PythonCore\\%s\\Modules\\%s" % (sys.winver, name)) fp = open(pathname, "rb") stuff = "", "rb", imp.C_EXTENSION return fp, pathname, stuff except _winreg.error: pass
result = _try_registry(name) if result: return result
def find_module(self, name, path): if name in self.excludes: self.msgout(3, "find_module -> Excluded") raise ImportError, name
f76d2492b70d1f6611db7cb5cfdcbd539957f4e9 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/f76d2492b70d1f6611db7cb5cfdcbd539957f4e9/modulefinder.py
def fixupOrderForward(self, blocks, default_next): """Make sure all JUMP_FORWARDs jump forward""" index = {} chains = [] cur = [] for b in blocks: index[b] = len(chains) cur.append(b) if b.next and b.next[0] == default_next: chains.append(cur) cur = [] chains.append(cur)
c28bade7b0bdd22a6f0ae207b9a140ad8bc308b9 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/c28bade7b0bdd22a6f0ae207b9a140ad8bc308b9/pyassem.py
self.stacksize = findDepth(self.insts)
def flattenGraph(self): """Arrange the blocks in order and resolve jumps""" assert self.stage == RAW self.insts = insts = [] pc = 0 begin = {} end = {} for b in self.getBlocksInOrder(): begin[b] = pc for inst in b.getInstructions(): insts.append(inst) if len(inst) == 1: pc = pc + 1 else: # arg takes 2 bytes pc = pc + 3 end[b] = pc pc = 0 for i in range(len(insts)): inst = insts[i] if len(inst) == 1: pc = pc + 1 else: pc = pc + 3 opname = inst[0] if self.hasjrel.has_elt(opname): oparg = inst[1] offset = begin[oparg] - pc insts[i] = opname, offset elif self.hasjabs.has_elt(opname): insts[i] = opname, begin[inst[1]] self.stacksize = findDepth(self.insts) self.stage = FLAT
c28bade7b0bdd22a6f0ae207b9a140ad8bc308b9 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/c28bade7b0bdd22a6f0ae207b9a140ad8bc308b9/pyassem.py
def findDepth(self, insts):
def findDepth(self, insts, debug=0):
def findDepth(self, insts): depth = 0 maxDepth = 0 for i in insts: opname = i[0] delta = self.effect.get(opname, 0) if delta > 1: depth = depth + delta elif delta < 0: if depth > maxDepth: maxDepth = depth depth = depth + delta else: if depth > maxDepth: maxDepth = depth # now check patterns for pat, pat_delta in self.patterns: if opname[:len(pat)] == pat: delta = pat_delta depth = depth + delta break # if we still haven't found a match if delta == 0: meth = getattr(self, opname, None) if meth is not None: depth = depth + meth(i[1]) if depth < 0: depth = 0 return maxDepth
c28bade7b0bdd22a6f0ae207b9a140ad8bc308b9 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/c28bade7b0bdd22a6f0ae207b9a140ad8bc308b9/pyassem.py
delta = self.effect.get(opname, 0) if delta > 1: depth = depth + delta elif delta < 0: if depth > maxDepth: maxDepth = depth
if debug: print i, delta = self.effect.get(opname, None) if delta is not None:
def findDepth(self, insts): depth = 0 maxDepth = 0 for i in insts: opname = i[0] delta = self.effect.get(opname, 0) if delta > 1: depth = depth + delta elif delta < 0: if depth > maxDepth: maxDepth = depth depth = depth + delta else: if depth > maxDepth: maxDepth = depth # now check patterns for pat, pat_delta in self.patterns: if opname[:len(pat)] == pat: delta = pat_delta depth = depth + delta break # if we still haven't found a match if delta == 0: meth = getattr(self, opname, None) if meth is not None: depth = depth + meth(i[1]) if depth < 0: depth = 0 return maxDepth
c28bade7b0bdd22a6f0ae207b9a140ad8bc308b9 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/c28bade7b0bdd22a6f0ae207b9a140ad8bc308b9/pyassem.py
if depth > maxDepth: maxDepth = depth
def findDepth(self, insts): depth = 0 maxDepth = 0 for i in insts: opname = i[0] delta = self.effect.get(opname, 0) if delta > 1: depth = depth + delta elif delta < 0: if depth > maxDepth: maxDepth = depth depth = depth + delta else: if depth > maxDepth: maxDepth = depth # now check patterns for pat, pat_delta in self.patterns: if opname[:len(pat)] == pat: delta = pat_delta depth = depth + delta break # if we still haven't found a match if delta == 0: meth = getattr(self, opname, None) if meth is not None: depth = depth + meth(i[1]) if depth < 0: depth = 0 return maxDepth
c28bade7b0bdd22a6f0ae207b9a140ad8bc308b9 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/c28bade7b0bdd22a6f0ae207b9a140ad8bc308b9/pyassem.py
if delta == 0:
if delta is None:
def findDepth(self, insts): depth = 0 maxDepth = 0 for i in insts: opname = i[0] delta = self.effect.get(opname, 0) if delta > 1: depth = depth + delta elif delta < 0: if depth > maxDepth: maxDepth = depth depth = depth + delta else: if depth > maxDepth: maxDepth = depth # now check patterns for pat, pat_delta in self.patterns: if opname[:len(pat)] == pat: delta = pat_delta depth = depth + delta break # if we still haven't found a match if delta == 0: meth = getattr(self, opname, None) if meth is not None: depth = depth + meth(i[1]) if depth < 0: depth = 0 return maxDepth
c28bade7b0bdd22a6f0ae207b9a140ad8bc308b9 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/c28bade7b0bdd22a6f0ae207b9a140ad8bc308b9/pyassem.py
if depth < 0: depth = 0
if depth > maxDepth: maxDepth = depth if debug: print depth, maxDepth
def findDepth(self, insts): depth = 0 maxDepth = 0 for i in insts: opname = i[0] delta = self.effect.get(opname, 0) if delta > 1: depth = depth + delta elif delta < 0: if depth > maxDepth: maxDepth = depth depth = depth + delta else: if depth > maxDepth: maxDepth = depth # now check patterns for pat, pat_delta in self.patterns: if opname[:len(pat)] == pat: delta = pat_delta depth = depth + delta break # if we still haven't found a match if delta == 0: meth = getattr(self, opname, None) if meth is not None: depth = depth + meth(i[1]) if depth < 0: depth = 0 return maxDepth
c28bade7b0bdd22a6f0ae207b9a140ad8bc308b9 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/c28bade7b0bdd22a6f0ae207b9a140ad8bc308b9/pyassem.py
return lo + hi * 2
return -(lo + hi * 2)
def CALL_FUNCTION(self, argc): hi, lo = divmod(argc, 256) return lo + hi * 2
c28bade7b0bdd22a6f0ae207b9a140ad8bc308b9 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/c28bade7b0bdd22a6f0ae207b9a140ad8bc308b9/pyassem.py
return self.CALL_FUNCTION(argc)+1
return self.CALL_FUNCTION(argc)-1
def CALL_FUNCTION_VAR(self, argc): return self.CALL_FUNCTION(argc)+1
c28bade7b0bdd22a6f0ae207b9a140ad8bc308b9 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/c28bade7b0bdd22a6f0ae207b9a140ad8bc308b9/pyassem.py
return self.CALL_FUNCTION(argc)+1
return self.CALL_FUNCTION(argc)-1
def CALL_FUNCTION_KW(self, argc): return self.CALL_FUNCTION(argc)+1
c28bade7b0bdd22a6f0ae207b9a140ad8bc308b9 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/c28bade7b0bdd22a6f0ae207b9a140ad8bc308b9/pyassem.py
return self.CALL_FUNCTION(argc)+2
return self.CALL_FUNCTION(argc)-2
def CALL_FUNCTION_VAR_KW(self, argc): return self.CALL_FUNCTION(argc)+2
c28bade7b0bdd22a6f0ae207b9a140ad8bc308b9 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/c28bade7b0bdd22a6f0ae207b9a140ad8bc308b9/pyassem.py
self.file.write(delim + line)
self.file.write(odelim + line)
def read_lines_to_outerboundary(self):
b2b6e27667246133e42681eaa8399798b5f33929 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/b2b6e27667246133e42681eaa8399798b5f33929/cgi.py
displayname = linkname = name = cgi.escape(name)
displayname = linkname = name
def list_directory(self, path): """Helper to produce a directory listing (absent index.html).
09d9e4a43bb57b6d94e7dd9efec81017c2b168cc /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/09d9e4a43bb57b6d94e7dd9efec81017c2b168cc/SimpleHTTPServer.py
f.write('<li><a href="%s">%s</a>\n' % (linkname, displayname))
f.write('<li><a href="%s">%s</a>\n' % (urllib.quote(linkname), cgi.escape(displayname)))
def list_directory(self, path): """Helper to produce a directory listing (absent index.html).
09d9e4a43bb57b6d94e7dd9efec81017c2b168cc /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/09d9e4a43bb57b6d94e7dd9efec81017c2b168cc/SimpleHTTPServer.py
def external_entity_ref(self, context, base, sysid, pubid): if not self._external_ges: return 1 source = self._ent_handler.resolveEntity(pubid, sysid) source = saxutils.prepare_input_source(source, self._source.getSystemId() or "")
1e527bfc3732e2e0cfeda9c5ad2e0ab13cee25f9 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/1e527bfc3732e2e0cfeda9c5ad2e0ab13cee25f9/expatreader.py
return id(self)
return hash(id(self))
def __hash__(self, *args): print "__hash__:", args return id(self)
49132036bfc8bdf0a863ea780eae93d0e458e99e /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/49132036bfc8bdf0a863ea780eae93d0e458e99e/test_class.py
>>> old = _unittest_reportflags >>> set_unittest_reportflags(REPORT_NDIFF |
>>> import doctest >>> old = doctest._unittest_reportflags >>> doctest.set_unittest_reportflags(REPORT_NDIFF |
def set_unittest_reportflags(flags): """Sets the unittest option flags. The old flag is returned so that a runner could restore the old value if it wished to: >>> old = _unittest_reportflags >>> set_unittest_reportflags(REPORT_NDIFF | ... REPORT_ONLY_FIRST_FAILURE) == old True >>> import doctest >>> doctest._unittest_reportflags == (REPORT_NDIFF | ... REPORT_ONLY_FIRST_FAILURE) True Only reporting flags can be set: >>> set_unittest_reportflags(ELLIPSIS) Traceback (most recent call last): ... ValueError: ('Only reporting flags allowed', 8) >>> set_unittest_reportflags(old) == (REPORT_NDIFF | ... REPORT_ONLY_FIRST_FAILURE) True """ global _unittest_reportflags if (flags & REPORTING_FLAGS) != flags: raise ValueError("Only reporting flags allowed", flags) old = _unittest_reportflags _unittest_reportflags = flags return old
b42cca9e880de5e1b077521211e87fe1d97b94bd /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/b42cca9e880de5e1b077521211e87fe1d97b94bd/doctest.py
>>> import doctest
def set_unittest_reportflags(flags): """Sets the unittest option flags. The old flag is returned so that a runner could restore the old value if it wished to: >>> old = _unittest_reportflags >>> set_unittest_reportflags(REPORT_NDIFF | ... REPORT_ONLY_FIRST_FAILURE) == old True >>> import doctest >>> doctest._unittest_reportflags == (REPORT_NDIFF | ... REPORT_ONLY_FIRST_FAILURE) True Only reporting flags can be set: >>> set_unittest_reportflags(ELLIPSIS) Traceback (most recent call last): ... ValueError: ('Only reporting flags allowed', 8) >>> set_unittest_reportflags(old) == (REPORT_NDIFF | ... REPORT_ONLY_FIRST_FAILURE) True """ global _unittest_reportflags if (flags & REPORTING_FLAGS) != flags: raise ValueError("Only reporting flags allowed", flags) old = _unittest_reportflags _unittest_reportflags = flags return old
b42cca9e880de5e1b077521211e87fe1d97b94bd /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/b42cca9e880de5e1b077521211e87fe1d97b94bd/doctest.py
>>> set_unittest_reportflags(ELLIPSIS)
>>> doctest.set_unittest_reportflags(ELLIPSIS)
def set_unittest_reportflags(flags): """Sets the unittest option flags. The old flag is returned so that a runner could restore the old value if it wished to: >>> old = _unittest_reportflags >>> set_unittest_reportflags(REPORT_NDIFF | ... REPORT_ONLY_FIRST_FAILURE) == old True >>> import doctest >>> doctest._unittest_reportflags == (REPORT_NDIFF | ... REPORT_ONLY_FIRST_FAILURE) True Only reporting flags can be set: >>> set_unittest_reportflags(ELLIPSIS) Traceback (most recent call last): ... ValueError: ('Only reporting flags allowed', 8) >>> set_unittest_reportflags(old) == (REPORT_NDIFF | ... REPORT_ONLY_FIRST_FAILURE) True """ global _unittest_reportflags if (flags & REPORTING_FLAGS) != flags: raise ValueError("Only reporting flags allowed", flags) old = _unittest_reportflags _unittest_reportflags = flags return old
b42cca9e880de5e1b077521211e87fe1d97b94bd /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/b42cca9e880de5e1b077521211e87fe1d97b94bd/doctest.py
>>> set_unittest_reportflags(old) == (REPORT_NDIFF |
>>> doctest.set_unittest_reportflags(old) == (REPORT_NDIFF |
def set_unittest_reportflags(flags): """Sets the unittest option flags. The old flag is returned so that a runner could restore the old value if it wished to: >>> old = _unittest_reportflags >>> set_unittest_reportflags(REPORT_NDIFF | ... REPORT_ONLY_FIRST_FAILURE) == old True >>> import doctest >>> doctest._unittest_reportflags == (REPORT_NDIFF | ... REPORT_ONLY_FIRST_FAILURE) True Only reporting flags can be set: >>> set_unittest_reportflags(ELLIPSIS) Traceback (most recent call last): ... ValueError: ('Only reporting flags allowed', 8) >>> set_unittest_reportflags(old) == (REPORT_NDIFF | ... REPORT_ONLY_FIRST_FAILURE) True """ global _unittest_reportflags if (flags & REPORTING_FLAGS) != flags: raise ValueError("Only reporting flags allowed", flags) old = _unittest_reportflags _unittest_reportflags = flags return old
b42cca9e880de5e1b077521211e87fe1d97b94bd /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/b42cca9e880de5e1b077521211e87fe1d97b94bd/doctest.py
print >> sys.stderr, """\ WARNING: an attempt to connect to %r timed out, in test_timeout. That may be legitimate, but is not the outcome we hoped for. If this message is seen often, test_timeout should be changed to use a more reliable address.""" % (ADDR,)
error_msg('timed out')
def test_timeout(): test_support.requires('network') if test_support.verbose: print "test_timeout ..." # A service which issues a welcome banner (without need to write # anything). # XXX ("gmail.org", 995) has been unreliable so far, from time to time # XXX non-responsive for hours on end (& across all buildbot slaves, # XXX so that's not just a local thing). ADDR = "gmail.org", 995 s = socket.socket() s.settimeout(30.0) try: s.connect(ADDR) except socket.timeout: print >> sys.stderr, """\ WARNING: an attempt to connect to %r timed out, in test_timeout. That may be legitimate, but is not the outcome we hoped for. If this message is seen often, test_timeout should be changed to use a more reliable address.""" % (ADDR,) return except socket.error, exc: # In case connection is refused. if exc.args[0] == errno.ECONNREFUSED: print "Connection refused when connecting to", ADDR return else: raise ss = socket.ssl(s) # Read part of return welcome banner twice. ss.read(1) ss.read(1) s.close()
521c62d04ded60d8ddb42d326a8b224a11c461e5 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/521c62d04ded60d8ddb42d326a8b224a11c461e5/test_socket_ssl.py
print "Connection refused when connecting to", ADDR
error_msg('was refused')
def test_timeout(): test_support.requires('network') if test_support.verbose: print "test_timeout ..." # A service which issues a welcome banner (without need to write # anything). # XXX ("gmail.org", 995) has been unreliable so far, from time to time # XXX non-responsive for hours on end (& across all buildbot slaves, # XXX so that's not just a local thing). ADDR = "gmail.org", 995 s = socket.socket() s.settimeout(30.0) try: s.connect(ADDR) except socket.timeout: print >> sys.stderr, """\ WARNING: an attempt to connect to %r timed out, in test_timeout. That may be legitimate, but is not the outcome we hoped for. If this message is seen often, test_timeout should be changed to use a more reliable address.""" % (ADDR,) return except socket.error, exc: # In case connection is refused. if exc.args[0] == errno.ECONNREFUSED: print "Connection refused when connecting to", ADDR return else: raise ss = socket.ssl(s) # Read part of return welcome banner twice. ss.read(1) ss.read(1) s.close()
521c62d04ded60d8ddb42d326a8b224a11c461e5 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/521c62d04ded60d8ddb42d326a8b224a11c461e5/test_socket_ssl.py
self.transient(parent)
if parent.winfo_viewable(): self.transient(parent)
def __init__(self, parent, title = None):
874576ede7e22304799cd1a57de9de10cd1e6596 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/874576ede7e22304799cd1a57de9de10cd1e6596/tkSimpleDialog.py
co_name = frame.f_code.co_name
def user_line(self, frame):
6e32b75f62441a41718948765227cdcb1e9b95c5 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/6e32b75f62441a41718948765227cdcb1e9b95c5/Debugger.py
try: func = frame.f_locals[co_name] if getattr(func, "DebuggerStepThrough", 0): print "XXXX DEBUGGER STEPPING THROUGH"
exclude = ('rpc.py', 'threading.py', '<string>') for rpcfile in exclude: if co_filename.count(rpcfile):
def user_line(self, frame):
6e32b75f62441a41718948765227cdcb1e9b95c5 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/6e32b75f62441a41718948765227cdcb1e9b95c5/Debugger.py
except: pass if co_filename in (r'.\rpc.py', 'rpc.py','<string>'): self.set_step() return if co_filename.endswith('threading.py'): self.set_step() return
def user_line(self, frame):
6e32b75f62441a41718948765227cdcb1e9b95c5 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/6e32b75f62441a41718948765227cdcb1e9b95c5/Debugger.py
apply(self.cb, self.cb_arg)
apply(self.cb, (self.cb_arg,))
def poll(self): if not self.async: raise error, 'Can only call poll() in async mode' if not self.busy_cmd: return if self.testready(): if self.cb: apply(self.cb, self.cb_arg)
7d7384d00581f822cc9c3002eed9d462bd8edf07 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/7d7384d00581f822cc9c3002eed9d462bd8edf07/VCR.py
return s[:colon-1], s[colon:]
path, file = s[:colon-1], s[colon:] if path and not ':' in path: path = path + ':' return path, file
def split(s): if ':' not in s: return '', s colon = 0 for i in range(len(s)): if s[i] == ':': colon = i+1 return s[:colon-1], s[colon:]
ab809a28c351a20cd76b813affa4db788b495e59 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/ab809a28c351a20cd76b813affa4db788b495e59/macpath.py
def set(self, *args): """Set the fractional values of the slider position (upper and lower ends as value between 0 and 1).""" self.tk.call((self._w, 'set') + args)
3fa798441945f3bd3b30ef87ecab782f2ef21b3c /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/3fa798441945f3bd3b30ef87ecab782f2ef21b3c/Tkinter.py
return From(fromname, [('*', None)])
return From(fromname, [('*', None)], lineno=nodelist[0][2])
def import_from(self, nodelist): # import_from: 'from' dotted_name 'import' ('*' | # '(' import_as_names ')' | import_as_names) assert nodelist[0][1] == 'from' assert nodelist[1][0] == symbol.dotted_name assert nodelist[2][1] == 'import' fromname = self.com_dotted_name(nodelist[1]) if nodelist[3][0] == token.STAR: # TODO(jhylton): where is the lineno? return From(fromname, [('*', None)]) else: node = nodelist[3 + (nodelist[3][0] == token.LPAR)] return From(fromname, self.com_import_as_names(node), lineno=nodelist[0][2])
8d490a4df00dbaaa5078d272bac5ba8e0528c522 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/8d490a4df00dbaaa5078d272bac5ba8e0528c522/transformer.py
d[types.CodeType] = _deepcopy_atomic
try: d[types.CodeType] = _deepcopy_atomic except AttributeError: pass
def _deepcopy_atomic(x, memo): return x
2c1466b357f2c129f4a6a59d0c97620c4637e1f1 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/2c1466b357f2c129f4a6a59d0c97620c4637e1f1/copy.py
return Falso
return False
def ignored(self, file): if os.path.isdir(file): return True for pat in self.IgnoreList: if fnmatch.fnmatch(file, pat): return True return Falso
db029bdb649001f92aabeef01d4d7bbd07af4d40 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/db029bdb649001f92aabeef01d4d7bbd07af4d40/cvslib.py
TESTFN = '@test'
import os if os.name !='riscos': TESTFN = '@test' else: TESTFN = 'test' del os
def fcmp(x, y): # fuzzy comparison function if type(x) == type(0.0) or type(y) == type(0.0): try: x, y = coerce(x, y) fuzz = (abs(x) + abs(y)) * FUZZ if abs(x-y) <= fuzz: return 0 except: pass elif type(x) == type(y) and type(x) in (type(()), type([])): for i in range(min(len(x), len(y))): outcome = fcmp(x[i], y[i]) if outcome != 0: return outcome return cmp(len(x), len(y)) return cmp(x, y)
bb5bc8e734aed84d8d8bbb1b520e97a69bf79261 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/bb5bc8e734aed84d8d8bbb1b520e97a69bf79261/test_support.py
if exppart: expo = eval(exppart[1:])
if exppart: expo = int(exppart[1:])
def extract(s): res = decoder.match(s) if res is None: raise NotANumber, s sign, intpart, fraction, exppart = res.group(1,2,3,4) if sign == '+': sign = '' if fraction: fraction = fraction[1:] if exppart: expo = eval(exppart[1:]) else: expo = 0 return sign, intpart, fraction, expo
249de2ef26a6c4592288977f94511c7219aabdf9 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/249de2ef26a6c4592288977f94511c7219aabdf9/fpformat.py
extra_postargs.extend(extra_postargs)
pp_args.extend(extra_postargs)
def preprocess (self, source, output_file=None, macros=None, include_dirs=None, extra_preargs=None, extra_postargs=None):
9f4b5ad49ee147c29efa7c7c34c101929e58c4db /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/9f4b5ad49ee147c29efa7c7c34c101929e58c4db/unixccompiler.py
if self.force or (output_file and newer(source, output_file)):
if self.force or output_file is None or newer(source, output_file)):
def preprocess (self, source, output_file=None, macros=None, include_dirs=None, extra_preargs=None, extra_postargs=None):
9f4b5ad49ee147c29efa7c7c34c101929e58c4db /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/9f4b5ad49ee147c29efa7c7c34c101929e58c4db/unixccompiler.py
class IncrementalDecoder(codecs.IncrementalDecoder): def decode(self, input, final=False): return codecs.mbcs_decode(input,self.errors)[0]
class IncrementalDecoder(codecs.BufferedIncrementalDecoder): def _buffer_decode(self, input, errors, final): return codecs.mbcs_decode(input,self.errors,final)
def encode(self, input, final=False): return codecs.mbcs_encode(input,self.errors)[0]
6e386cfca86987473e519fd1ec387db25148ccc1 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/6e386cfca86987473e519fd1ec387db25148ccc1/mbcs.py
if (PyArg_Parse(v, "(O&l)", PyMac_GetOSType, &(out->eventClass), &(out->eventKind)))
if (PyArg_Parse(v, "(O&l)", PyMac_GetOSType, &(out->eventClass), &(out->eventKind)))
#ifdef WITHOUT_FRAMEWORKS
4b5a605c959323b2e4dad49697b293cef4a45750 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/4b5a605c959323b2e4dad49697b293cef4a45750/CarbonEvtsupport.py
retValue = PyObject_CallFunction((PyObject *)outPyObject, "O&O&", EventHandlerCallRef_New, handlerRef, EventRef_New, event);
retValue = PyObject_CallFunction((PyObject *)outPyObject, "O&O&", EventHandlerCallRef_New, handlerRef, EventRef_New, event);
#ifdef WITHOUT_FRAMEWORKS
4b5a605c959323b2e4dad49697b293cef4a45750 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/4b5a605c959323b2e4dad49697b293cef4a45750/CarbonEvtsupport.py
if os.sep != '/': paths = string.split (pathname, '/') return apply (os.path.join, paths) else: return pathname
paths = string.split(pathname, '/') return apply(os.path.join, paths)
def convert_path (pathname): """Return 'pathname' as a name that will work on the native filesystem, i.e. split it on '/' and put it back together again using the current directory separator. Needed because filenames in the setup script are always supplied in Unix style, and have to be converted to the local convention before we can actually use them in the filesystem. Raises ValueError if 'pathname' is absolute (starts with '/') or contains local directory separators (unless the local separator is '/', of course).""" if pathname[0] == '/': raise ValueError, "path '%s' cannot be absolute" % pathname if pathname[-1] == '/': raise ValueError, "path '%s' cannot end with '/'" % pathname if os.sep != '/': paths = string.split (pathname, '/') return apply (os.path.join, paths) else: return pathname
d023509d6a9e72c7f8af2458d6f55aa7f2c7b8be /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/d023509d6a9e72c7f8af2458d6f55aa7f2c7b8be/util.py
tmp = [] def callit(func=func, args=args, self=self, tmp=tmp):
def callit():
def after(self, ms, func=None, *args): """Call function once after given time.
d567003a566ee9c051fb73a828a18db88339f9c8 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/d567003a566ee9c051fb73a828a18db88339f9c8/Tkinter.py
self.deletecommand(tmp[0])
self.deletecommand(name)
def callit(func=func, args=args, self=self, tmp=tmp): try: func(*args) finally: try: self.deletecommand(tmp[0]) except TclError: pass
d567003a566ee9c051fb73a828a18db88339f9c8 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/d567003a566ee9c051fb73a828a18db88339f9c8/Tkinter.py
tmp.append(name)
def callit(func=func, args=args, self=self, tmp=tmp): try: func(*args) finally: try: self.deletecommand(tmp[0]) except TclError: pass
d567003a566ee9c051fb73a828a18db88339f9c8 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/d567003a566ee9c051fb73a828a18db88339f9c8/Tkinter.py
self.rfile = self.connection.makefile('rb', 0) self.wfile = self.connection.makefile('wb', 0)
self.rfile = self.connection.makefile('rb', self.rbufsize) self.wfile = self.connection.makefile('wb', self.wbufsize)
def setup(self): self.connection = self.request self.rfile = self.connection.makefile('rb', 0) self.wfile = self.connection.makefile('wb', 0)
1877a56de58e30c20917ffa61cda49186661e05a /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/1877a56de58e30c20917ffa61cda49186661e05a/SocketServer.py
return apply(getattr(self.mod, self.name).%s, args)
return apply(getattr(self.mod, self.name).%s, args)
def %s(self, *args): return apply(getattr(self.mod, self.name).%s, args)
ce7c76df1b92a89c9b48d025af1313d1dcf28c4f /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/ce7c76df1b92a89c9b48d025af1313d1dcf28c4f/rexec.py
def __init__(self, mod, name): self.mod = mod self.name = name for m in FileBase.ok_file_methods + ('close',): exec TEMPLATE % (m, m)
def __init__(self, mod, name): self.mod = mod self.name = name for m in FileBase.ok_file_methods + ('close',): exec TEMPLATE % (m, m)
def __init__(self, mod, name): self.mod = mod self.name = name
ce7c76df1b92a89c9b48d025af1313d1dcf28c4f /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/ce7c76df1b92a89c9b48d025af1313d1dcf28c4f/rexec.py
verbose = 0 rexec = None if args and type(args[-1]) == type(0): verbose = args[-1] args = args[:-1] if args and hasattr(args[0], '__class__'): rexec = args[0] args = args[1:] if args: raise TypeError, "too many arguments" ihooks.Hooks.__init__(self, verbose) self.rexec = rexec
verbose = 0 rexec = None if args and type(args[-1]) == type(0): verbose = args[-1] args = args[:-1] if args and hasattr(args[0], '__class__'): rexec = args[0] args = args[1:] if args: raise TypeError, "too many arguments" ihooks.Hooks.__init__(self, verbose) self.rexec = rexec
def __init__(self, *args):
ce7c76df1b92a89c9b48d025af1313d1dcf28c4f /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/ce7c76df1b92a89c9b48d025af1313d1dcf28c4f/rexec.py
self.rexec = rexec
self.rexec = rexec
def set_rexec(self, rexec):
ce7c76df1b92a89c9b48d025af1313d1dcf28c4f /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/ce7c76df1b92a89c9b48d025af1313d1dcf28c4f/rexec.py
return self.rexec.is_builtin(name)
return self.rexec.is_builtin(name)
def is_builtin(self, name):
ce7c76df1b92a89c9b48d025af1313d1dcf28c4f /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/ce7c76df1b92a89c9b48d025af1313d1dcf28c4f/rexec.py
m = __import__(name) return self.rexec.copy_except(m, ())
m = __import__(name) return self.rexec.copy_except(m, ())
def init_builtin(self, name):
ce7c76df1b92a89c9b48d025af1313d1dcf28c4f /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/ce7c76df1b92a89c9b48d025af1313d1dcf28c4f/rexec.py
return self.rexec.load_dynamic(name, filename, file)
return self.rexec.load_dynamic(name, filename, file)
def load_dynamic(self, name, filename, file):
ce7c76df1b92a89c9b48d025af1313d1dcf28c4f /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/ce7c76df1b92a89c9b48d025af1313d1dcf28c4f/rexec.py
return self.rexec.add_module(name)
return self.rexec.add_module(name)
def add_module(self, name):
ce7c76df1b92a89c9b48d025af1313d1dcf28c4f /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/ce7c76df1b92a89c9b48d025af1313d1dcf28c4f/rexec.py
return self.rexec.modules
return self.rexec.modules
def modules_dict(self):
ce7c76df1b92a89c9b48d025af1313d1dcf28c4f /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/ce7c76df1b92a89c9b48d025af1313d1dcf28c4f/rexec.py
return self.rexec.modules['sys'].path
return self.rexec.modules['sys'].path
def default_path(self):
ce7c76df1b92a89c9b48d025af1313d1dcf28c4f /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/ce7c76df1b92a89c9b48d025af1313d1dcf28c4f/rexec.py
head, tail = os.path.split(module.__filename__) path = [os.path.join(head, '')]
head, tail = os.path.split(module.__filename__) path = [os.path.join(head, '')]
def reload(self, module, path=None): if path is None and hasattr(module, '__filename__'): head, tail = os.path.split(module.__filename__) path = [os.path.join(head, '')] return ihooks.ModuleImporter.reload(self, module, path)
ce7c76df1b92a89c9b48d025af1313d1dcf28c4f /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/ce7c76df1b92a89c9b48d025af1313d1dcf28c4f/rexec.py
ok_path = tuple(sys.path)
ok_path = tuple(sys.path)
def reload(self, module, path=None): if path is None and hasattr(module, '__filename__'): head, tail = os.path.split(module.__filename__) path = [os.path.join(head, '')] return ihooks.ModuleImporter.reload(self, module, path)
ce7c76df1b92a89c9b48d025af1313d1dcf28c4f /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/ce7c76df1b92a89c9b48d025af1313d1dcf28c4f/rexec.py
'cmath', 'errno', 'imageop', 'marshal', 'math', 'md5', 'operator', 'parser', 'regex', 'pcre', 'rotor', 'select', 'strop', 'struct', 'time')
'cmath', 'errno', 'imageop', 'marshal', 'math', 'md5', 'operator', 'parser', 'regex', 'pcre', 'rotor', 'select', 'strop', 'struct', 'time')
def reload(self, module, path=None): if path is None and hasattr(module, '__filename__'): head, tail = os.path.split(module.__filename__) path = [os.path.join(head, '')] return ihooks.ModuleImporter.reload(self, module, path)
ce7c76df1b92a89c9b48d025af1313d1dcf28c4f /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/ce7c76df1b92a89c9b48d025af1313d1dcf28c4f/rexec.py
'stat', 'times', 'uname', 'getpid', 'getppid', 'getcwd', 'getuid', 'getgid', 'geteuid', 'getegid')
'stat', 'times', 'uname', 'getpid', 'getppid', 'getcwd', 'getuid', 'getgid', 'geteuid', 'getegid')
def reload(self, module, path=None): if path is None and hasattr(module, '__filename__'): head, tail = os.path.split(module.__filename__) path = [os.path.join(head, '')] return ihooks.ModuleImporter.reload(self, module, path)
ce7c76df1b92a89c9b48d025af1313d1dcf28c4f /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/ce7c76df1b92a89c9b48d025af1313d1dcf28c4f/rexec.py
'platform', 'exit', 'maxint')
'platform', 'exit', 'maxint')
def reload(self, module, path=None): if path is None and hasattr(module, '__filename__'): head, tail = os.path.split(module.__filename__) path = [os.path.join(head, '')] return ihooks.ModuleImporter.reload(self, module, path)
ce7c76df1b92a89c9b48d025af1313d1dcf28c4f /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/ce7c76df1b92a89c9b48d025af1313d1dcf28c4f/rexec.py
ihooks._Verbose.__init__(self, verbose) self.hooks = hooks or RHooks(verbose) self.hooks.set_rexec(self) self.modules = {} self.ok_dynamic_modules = self.ok_builtin_modules list = [] for mname in self.ok_builtin_modules: if mname in sys.builtin_module_names: list.append(mname) self.ok_builtin_modules = tuple(list) self.set_trusted_path() self.make_builtin() self.make_initial_modules() self.make_sys() self.loader = RModuleLoader(self.hooks, verbose) self.importer = RModuleImporter(self.loader, verbose)
ihooks._Verbose.__init__(self, verbose) self.hooks = hooks or RHooks(verbose) self.hooks.set_rexec(self) self.modules = {} self.ok_dynamic_modules = self.ok_builtin_modules list = [] for mname in self.ok_builtin_modules: if mname in sys.builtin_module_names: list.append(mname) self.ok_builtin_modules = tuple(list) self.set_trusted_path() self.make_builtin() self.make_initial_modules() self.make_sys() self.loader = RModuleLoader(self.hooks, verbose) self.importer = RModuleImporter(self.loader, verbose)
def __init__(self, hooks = None, verbose = 0):
ce7c76df1b92a89c9b48d025af1313d1dcf28c4f /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/ce7c76df1b92a89c9b48d025af1313d1dcf28c4f/rexec.py
self.trusted_path = filter(os.path.isabs, sys.path)
self.trusted_path = filter(os.path.isabs, sys.path)
def set_trusted_path(self):
ce7c76df1b92a89c9b48d025af1313d1dcf28c4f /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/ce7c76df1b92a89c9b48d025af1313d1dcf28c4f/rexec.py
if name not in self.ok_dynamic_modules: raise ImportError, "untrusted dynamic module: %s" % name if sys.modules.has_key(name): src = sys.modules[name] else: import imp src = imp.load_dynamic(name, filename, file) dst = self.copy_except(src, []) return dst
if name not in self.ok_dynamic_modules: raise ImportError, "untrusted dynamic module: %s" % name if sys.modules.has_key(name): src = sys.modules[name] else: import imp src = imp.load_dynamic(name, filename, file) dst = self.copy_except(src, []) return dst
def load_dynamic(self, name, filename, file):
ce7c76df1b92a89c9b48d025af1313d1dcf28c4f /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/ce7c76df1b92a89c9b48d025af1313d1dcf28c4f/rexec.py
self.make_main() self.make_osname()
self.make_main() self.make_osname()
def make_initial_modules(self):
ce7c76df1b92a89c9b48d025af1313d1dcf28c4f /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/ce7c76df1b92a89c9b48d025af1313d1dcf28c4f/rexec.py
return mname in self.ok_builtin_modules
return mname in self.ok_builtin_modules
def is_builtin(self, mname):
ce7c76df1b92a89c9b48d025af1313d1dcf28c4f /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/ce7c76df1b92a89c9b48d025af1313d1dcf28c4f/rexec.py
m = self.copy_except(__builtin__, self.nok_builtin_names) m.__import__ = self.r_import m.reload = self.r_reload m.open = self.r_open
m = self.copy_except(__builtin__, self.nok_builtin_names) m.__import__ = self.r_import m.reload = self.r_reload m.open = self.r_open
def make_builtin(self):
ce7c76df1b92a89c9b48d025af1313d1dcf28c4f /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/ce7c76df1b92a89c9b48d025af1313d1dcf28c4f/rexec.py
m = self.add_module('__main__')
m = self.add_module('__main__')
def make_main(self):
ce7c76df1b92a89c9b48d025af1313d1dcf28c4f /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/ce7c76df1b92a89c9b48d025af1313d1dcf28c4f/rexec.py
osname = os.name src = __import__(osname) dst = self.copy_only(src, self.ok_posix_names) dst.environ = e = {} for key, value in os.environ.items(): e[key] = value
osname = os.name src = __import__(osname) dst = self.copy_only(src, self.ok_posix_names) dst.environ = e = {} for key, value in os.environ.items(): e[key] = value
def make_osname(self):
ce7c76df1b92a89c9b48d025af1313d1dcf28c4f /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/ce7c76df1b92a89c9b48d025af1313d1dcf28c4f/rexec.py
m = self.copy_only(sys, self.ok_sys_names) m.modules = self.modules m.argv = ['RESTRICTED'] m.path = map(None, self.ok_path) m = self.modules['sys'] l = self.modules.keys() + list(self.ok_builtin_modules) l.sort() m.builtin_module_names = tuple(l)
m = self.copy_only(sys, self.ok_sys_names) m.modules = self.modules m.argv = ['RESTRICTED'] m.path = map(None, self.ok_path) m = self.modules['sys'] l = self.modules.keys() + list(self.ok_builtin_modules) l.sort() m.builtin_module_names = tuple(l)
def make_sys(self):
ce7c76df1b92a89c9b48d025af1313d1dcf28c4f /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/ce7c76df1b92a89c9b48d025af1313d1dcf28c4f/rexec.py
dst = self.copy_none(src) for name in dir(src): setattr(dst, name, getattr(src, name)) for name in exceptions: try: delattr(dst, name) except AttributeError: pass return dst
dst = self.copy_none(src) for name in dir(src): setattr(dst, name, getattr(src, name)) for name in exceptions: try: delattr(dst, name) except AttributeError: pass return dst
def copy_except(self, src, exceptions):
ce7c76df1b92a89c9b48d025af1313d1dcf28c4f /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/ce7c76df1b92a89c9b48d025af1313d1dcf28c4f/rexec.py
dst = self.copy_none(src) for name in names: try: value = getattr(src, name) except AttributeError: continue setattr(dst, name, value) return dst
dst = self.copy_none(src) for name in names: try: value = getattr(src, name) except AttributeError: continue setattr(dst, name, value) return dst
def copy_only(self, src, names):
ce7c76df1b92a89c9b48d025af1313d1dcf28c4f /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/ce7c76df1b92a89c9b48d025af1313d1dcf28c4f/rexec.py
return self.add_module(src.__name__)
return self.add_module(src.__name__)
def copy_none(self, src):
ce7c76df1b92a89c9b48d025af1313d1dcf28c4f /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/ce7c76df1b92a89c9b48d025af1313d1dcf28c4f/rexec.py
if self.modules.has_key(mname): return self.modules[mname] self.modules[mname] = m = self.hooks.new_module(mname) m.__builtins__ = self.modules['__builtin__'] return m
if self.modules.has_key(mname): return self.modules[mname] self.modules[mname] = m = self.hooks.new_module(mname) m.__builtins__ = self.modules['__builtin__'] return m
def add_module(self, mname):
ce7c76df1b92a89c9b48d025af1313d1dcf28c4f /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/ce7c76df1b92a89c9b48d025af1313d1dcf28c4f/rexec.py
m = self.add_module('__main__') exec code in m.__dict__
m = self.add_module('__main__') exec code in m.__dict__
def r_exec(self, code):
ce7c76df1b92a89c9b48d025af1313d1dcf28c4f /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/ce7c76df1b92a89c9b48d025af1313d1dcf28c4f/rexec.py
m = self.add_module('__main__') return eval(code, m.__dict__)
m = self.add_module('__main__') return eval(code, m.__dict__)
def r_eval(self, code):
ce7c76df1b92a89c9b48d025af1313d1dcf28c4f /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/ce7c76df1b92a89c9b48d025af1313d1dcf28c4f/rexec.py
m = self.add_module('__main__') return execfile(file, m.__dict__)
m = self.add_module('__main__') return execfile(file, m.__dict__)
def r_execfile(self, file):
ce7c76df1b92a89c9b48d025af1313d1dcf28c4f /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/ce7c76df1b92a89c9b48d025af1313d1dcf28c4f/rexec.py
return self.importer.import_module(mname, globals, locals, fromlist)
return self.importer.import_module(mname, globals, locals, fromlist)
def r_import(self, mname, globals={}, locals={}, fromlist=[]):
ce7c76df1b92a89c9b48d025af1313d1dcf28c4f /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/ce7c76df1b92a89c9b48d025af1313d1dcf28c4f/rexec.py
self.delegate_stdin = FileDelegate(s, 'stdin') self.delegate_stdout = FileDelegate(s, 'stdout') self.delegate_stderr = FileDelegate(s, 'stderr')
self.delegate_stdin = FileDelegate(s, 'stdin') self.delegate_stdout = FileDelegate(s, 'stdout') self.delegate_stderr = FileDelegate(s, 'stderr')
def make_delegate_files(self): s = self.modules['sys']
ce7c76df1b92a89c9b48d025af1313d1dcf28c4f /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/ce7c76df1b92a89c9b48d025af1313d1dcf28c4f/rexec.py
if not hasattr(self, 'save_stdin'): self.save_files() if not hasattr(self, 'delegate_stdin'): self.make_delegate_files()
if not hasattr(self, 'save_stdin'): self.save_files() if not hasattr(self, 'delegate_stdin'): self.make_delegate_files()
def set_files(self):
ce7c76df1b92a89c9b48d025af1313d1dcf28c4f /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/ce7c76df1b92a89c9b48d025af1313d1dcf28c4f/rexec.py
s.stdin = self.restricted_stdin s.stdout = self.restricted_stdout s.stderr = self.restricted_stderr sys.stdin = self.delegate_stdin sys.stdout = self.delegate_stdout sys.stderr = self.delegate_stderr
s.stdin = self.restricted_stdin s.stdout = self.restricted_stdout s.stderr = self.restricted_stderr sys.stdin = self.delegate_stdin sys.stdout = self.delegate_stdout sys.stderr = self.delegate_stderr
def set_files(self):
ce7c76df1b92a89c9b48d025af1313d1dcf28c4f /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/ce7c76df1b92a89c9b48d025af1313d1dcf28c4f/rexec.py
self.restore_files()
self.restore_files()
def reset_files(self):
ce7c76df1b92a89c9b48d025af1313d1dcf28c4f /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/ce7c76df1b92a89c9b48d025af1313d1dcf28c4f/rexec.py
self.restricted_stdin = s.stdin self.restricted_stdout = s.stdout self.restricted_stderr = s.stderr
self.restricted_stdin = s.stdin self.restricted_stdout = s.stdout self.restricted_stderr = s.stderr
def reset_files(self):
ce7c76df1b92a89c9b48d025af1313d1dcf28c4f /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/ce7c76df1b92a89c9b48d025af1313d1dcf28c4f/rexec.py
sys.stdin = self.save_stdin sys.stdout = self.save_stdout sys.stderr = self.save_stderr
sys.stdin = self.save_stdin sys.stdout = self.save_stdout sys.stderr = self.save_stderr
def restore_files(self):
ce7c76df1b92a89c9b48d025af1313d1dcf28c4f /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/ce7c76df1b92a89c9b48d025af1313d1dcf28c4f/rexec.py
self.save_files() try: self.set_files() if kw: r = apply(func, args, kw) else: r = apply(func, args)
self.save_files() try: self.set_files() if kw: r = apply(func, args, kw) else: r = apply(func, args)
def s_apply(self, func, args=(), kw=None):
ce7c76df1b92a89c9b48d025af1313d1dcf28c4f /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12029/ce7c76df1b92a89c9b48d025af1313d1dcf28c4f/rexec.py