rem
stringlengths
1
322k
add
stringlengths
0
2.05M
context
stringlengths
4
228k
meta
stringlengths
156
215
return re.sub (r'\.(c|C|cc|cxx)$', SO)
return re.sub (r'\.(c|C|cc|cxx|cpp)$', self._shared_lib_ext)
def shared_object_filename (self, source_filename): return re.sub (r'\.(c|C|cc|cxx)$', SO)
65f4a3b1738dbe7c32a3fd4bad84c7c4d4a30d45 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/65f4a3b1738dbe7c32a3fd4bad84c7c4d4a30d45/unixccompiler.py
return "lib%s.a" % libname
return "lib%s%s" % (libname, self._static_lib_ext )
def library_filename (self, libname): return "lib%s.a" % libname
65f4a3b1738dbe7c32a3fd4bad84c7c4d4a30d45 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/65f4a3b1738dbe7c32a3fd4bad84c7c4d4a30d45/unixccompiler.py
return "lib%s.so" % libname
return "lib%s%s" % (libname, self._shared_lib_ext )
def shared_library_filename (self, libname): return "lib%s.so" % libname
65f4a3b1738dbe7c32a3fd4bad84c7c4d4a30d45 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/65f4a3b1738dbe7c32a3fd4bad84c7c4d4a30d45/unixccompiler.py
file = mod.get_file() self.assertEquals(file, os.path.join(TEMP_ZIP, os.sep.join(modules) + expected_ext))
if expected_ext: file = mod.get_file() self.assertEquals(file, os.path.join(TEMP_ZIP, os.sep.join(modules) + expected_ext))
def doTest(self, expected_ext, files, *modules): z = ZipFile(TEMP_ZIP, "w") try: for name, (mtime, data) in files.items(): zinfo = ZipInfo(name, time.localtime(mtime)) zinfo.compress_type = self.compression z.writestr(zinfo, data) z.close() sys.path.insert(0, TEMP_ZIP)
9a3129c14866f21ce3cee053c085db374cb61b78 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/9a3129c14866f21ce3cee053c085db374cb61b78/test_zipimport.py
raise self.failureException, (msg or '%s != %s' % (first, second))
raise self.failureException, \ (msg or '%s != %s' % (`first`, `second`))
def failUnlessEqual(self, first, second, msg=None): """Fail if the two objects are unequal as determined by the '!=' operator. """ if first != second: raise self.failureException, (msg or '%s != %s' % (first, second))
ca9aaf36e19598abb1969d43d3ede8b42c13195b /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/ca9aaf36e19598abb1969d43d3ede8b42c13195b/unittest.py
raise self.failureException, (msg or '%s == %s' % (first, second))
raise self.failureException, \ (msg or '%s == %s' % (`first`, `second`))
def failIfEqual(self, first, second, msg=None): """Fail if the two objects are equal as determined by the '==' operator. """ if first == second: raise self.failureException, (msg or '%s == %s' % (first, second))
ca9aaf36e19598abb1969d43d3ede8b42c13195b /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/ca9aaf36e19598abb1969d43d3ede8b42c13195b/unittest.py
if err[0] is KeyboardInterrupt: self.shouldStop = 1
def addError(self, test, err): TestResult.addError(self, test, err) if self.showAll: self.stream.writeln("ERROR") elif self.dots: self.stream.write('E') if err[0] is KeyboardInterrupt: self.shouldStop = 1
ca9aaf36e19598abb1969d43d3ede8b42c13195b /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/ca9aaf36e19598abb1969d43d3ede8b42c13195b/unittest.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]
4c02fecf9c1f8a890b04ed3501aa68a636050e38 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/4c02fecf9c1f8a890b04ed3501aa68a636050e38/test_mutants.py
- port: port to connect to (default the standard NNTP port)"""
- port: port to connect to (default the standard NNTP port) - user: username to authenticate with - password: password to use with username - readermode: if true, send 'mode reader' command after connecting. readermode is sometimes necessary if you are connecting to an NNTP server on the local machine and intend to call reader-specific comamnds, such as `group'. If you get unexpected NNTPPermanentErrors, you might need to set readermode. """
def __init__(self, host, port = NNTP_PORT, user=None, password=None): """Initialize an instance. Arguments: - host: hostname to connect to - port: port to connect to (default the standard NNTP port)"""
9dd78729459478023a46401d8f04e2dc3bf974e5 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/9dd78729459478023a46401d8f04e2dc3bf974e5/nntplib.py
raise error_reply, resp
raise NNTPReplyError(resp)
def __init__(self, host, port = NNTP_PORT, user=None, password=None): """Initialize an instance. Arguments: - host: hostname to connect to - port: port to connect to (default the standard NNTP port)"""
9dd78729459478023a46401d8f04e2dc3bf974e5 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/9dd78729459478023a46401d8f04e2dc3bf974e5/nntplib.py
raise error_perm, resp
raise NNTPPermanentError(resp)
def __init__(self, host, port = NNTP_PORT, user=None, password=None): """Initialize an instance. Arguments: - host: hostname to connect to - port: port to connect to (default the standard NNTP port)"""
9dd78729459478023a46401d8f04e2dc3bf974e5 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/9dd78729459478023a46401d8f04e2dc3bf974e5/nntplib.py
raise error_temp, resp
raise NNTPTemporaryError(resp)
def getresp(self): """Internal: get a response from the server. Raise various errors if the response indicates an error.""" resp = self.getline() if self.debugging: print '*resp*', `resp` c = resp[:1] if c == '4': raise error_temp, resp if c == '5': raise error_perm, resp if c not in '123': raise error_proto, resp return resp
9dd78729459478023a46401d8f04e2dc3bf974e5 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/9dd78729459478023a46401d8f04e2dc3bf974e5/nntplib.py
raise error_perm, resp
raise NNTPPermanentError(resp)
def getresp(self): """Internal: get a response from the server. Raise various errors if the response indicates an error.""" resp = self.getline() if self.debugging: print '*resp*', `resp` c = resp[:1] if c == '4': raise error_temp, resp if c == '5': raise error_perm, resp if c not in '123': raise error_proto, resp return resp
9dd78729459478023a46401d8f04e2dc3bf974e5 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/9dd78729459478023a46401d8f04e2dc3bf974e5/nntplib.py
raise error_proto, resp
raise NNTPProtocolError(resp)
def getresp(self): """Internal: get a response from the server. Raise various errors if the response indicates an error.""" resp = self.getline() if self.debugging: print '*resp*', `resp` c = resp[:1] if c == '4': raise error_temp, resp if c == '5': raise error_perm, resp if c not in '123': raise error_proto, resp return resp
9dd78729459478023a46401d8f04e2dc3bf974e5 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/9dd78729459478023a46401d8f04e2dc3bf974e5/nntplib.py
raise error_reply, resp
raise NNTPReplyError(resp)
def getlongresp(self): """Internal: get a response plus following text from the server. Raise various errors if the response indicates an error.""" resp = self.getresp() if resp[:3] not in LONGRESP: raise error_reply, resp list = [] while 1: line = self.getline() if line == '.': break if line[:2] == '..': line = line[1:] list.append(line) return resp, list
9dd78729459478023a46401d8f04e2dc3bf974e5 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/9dd78729459478023a46401d8f04e2dc3bf974e5/nntplib.py
raise error_reply, resp
raise NNTPReplyError(resp)
def group(self, name): """Process a GROUP command. Argument: - group: the group name Returns: - resp: server response if succesful - count: number of articles (string) - first: first article number (string) - last: last article number (string) - name: the group name"""
9dd78729459478023a46401d8f04e2dc3bf974e5 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/9dd78729459478023a46401d8f04e2dc3bf974e5/nntplib.py
raise error_reply, resp
raise NNTPReplyError(resp)
def statparse(self, resp): """Internal: parse the response of a STAT, NEXT or LAST command.""" if resp[:2] <> '22': raise error_reply, resp words = string.split(resp) nr = 0 id = '' n = len(words) if n > 1: nr = words[1] if n > 2: id = words[2] return resp, nr, id
9dd78729459478023a46401d8f04e2dc3bf974e5 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/9dd78729459478023a46401d8f04e2dc3bf974e5/nntplib.py
raise error_data,line
raise NNTPDataError(line)
def xover(self,start,end): """Process an XOVER command (optional server extension) Arguments: - start: start of range - end: end of range Returns: - resp: server response if succesful - list: list of (art-nr, subject, poster, date, id, references, size, lines)"""
9dd78729459478023a46401d8f04e2dc3bf974e5 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/9dd78729459478023a46401d8f04e2dc3bf974e5/nntplib.py
raise error_reply, resp
raise NNTPReplyError(resp)
def xpath(self,id): """Process an XPATH command (optional server extension) Arguments: - id: Message id of article Returns: resp: server response if succesful path: directory path to article"""
9dd78729459478023a46401d8f04e2dc3bf974e5 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/9dd78729459478023a46401d8f04e2dc3bf974e5/nntplib.py
raise error_reply, resp
raise NNTPReplyError(resp)
def xpath(self,id): """Process an XPATH command (optional server extension) Arguments: - id: Message id of article Returns: resp: server response if succesful path: directory path to article"""
9dd78729459478023a46401d8f04e2dc3bf974e5 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/9dd78729459478023a46401d8f04e2dc3bf974e5/nntplib.py
raise error_reply, resp
raise NNTPReplyError(resp)
def date (self): """Process the DATE command. Arguments: None Returns: resp: server response if succesful date: Date suitable for newnews/newgroups commands etc. time: Time suitable for newnews/newgroups commands etc."""
9dd78729459478023a46401d8f04e2dc3bf974e5 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/9dd78729459478023a46401d8f04e2dc3bf974e5/nntplib.py
raise error_data, resp
raise NNTPDataError(resp)
def date (self): """Process the DATE command. Arguments: None Returns: resp: server response if succesful date: Date suitable for newnews/newgroups commands etc. time: Time suitable for newnews/newgroups commands etc."""
9dd78729459478023a46401d8f04e2dc3bf974e5 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/9dd78729459478023a46401d8f04e2dc3bf974e5/nntplib.py
raise error_data, resp
raise NNTPDataError(resp)
def date (self): """Process the DATE command. Arguments: None Returns: resp: server response if succesful date: Date suitable for newnews/newgroups commands etc. time: Time suitable for newnews/newgroups commands etc."""
9dd78729459478023a46401d8f04e2dc3bf974e5 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/9dd78729459478023a46401d8f04e2dc3bf974e5/nntplib.py
raise error_reply, resp
raise NNTPReplyError(resp)
def post(self, f): """Process a POST command. Arguments: - f: file containing the article Returns: - resp: server response if succesful"""
9dd78729459478023a46401d8f04e2dc3bf974e5 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/9dd78729459478023a46401d8f04e2dc3bf974e5/nntplib.py
raise error_reply, resp
raise NNTPReplyError(resp)
def ihave(self, id, f): """Process an IHAVE command. Arguments: - id: message-id of the article - f: file containing the article Returns: - resp: server response if succesful Note that if the server refuses the article an exception is raised."""
9dd78729459478023a46401d8f04e2dc3bf974e5 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/9dd78729459478023a46401d8f04e2dc3bf974e5/nntplib.py
s = NNTP('news')
s = NNTP('news', readermode='reader')
def _test(): """Minimal test function.""" s = NNTP('news') resp, count, first, last, name = s.group('comp.lang.python') print resp print 'Group', name, 'has', count, 'articles, range', first, 'to', last resp, subs = s.xhdr('subject', first + '-' + last) print resp for item in subs: print "%7s %s" % item resp = s.quit() print resp
9dd78729459478023a46401d8f04e2dc3bf974e5 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/9dd78729459478023a46401d8f04e2dc3bf974e5/nntplib.py
... t = tree("ABCDEFGHIJKLMNOPQRSTUVWXYZ") ... ... for x in t:
>>> t = tree("ABCDEFGHIJKLMNOPQRSTUVWXYZ") >>> >>> for x in t:
>>> def inorder(t):
103d26e851e781c17c03b711b39ab03f683346a9 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/103d26e851e781c17c03b711b39ab03f683346a9/test_generators.py
exclude=0, single=0, randomize=0):
exclude=0, single=0, randomize=0, leakdebug=0):
def main(tests=None, testdir=None, verbose=0, quiet=0, generate=0, exclude=0, single=0, randomize=0): """Execute a test suite. This also parses command-line options and modifies its behavior accordingly. tests -- a list of strings containing test names (optional) testdir -- the directory in which to look for tests (optional) Users other than the Python test suite will certainly want to specify testdir; if it's omitted, the directory containing the Python test suite is searched for. If the tests argument is omitted, the tests listed on the command-line will be used. If that's empty, too, then all *.py files beginning with test_ will be used. The other six default arguments (verbose, quiet, generate, exclude, single, and randomize) allow programmers calling main() directly to set the values that would normally be set by flags on the command line. """ try: opts, args = getopt.getopt(sys.argv[1:], 'vgqxsr') except getopt.error, msg: print msg print __doc__ return 2 for o, a in opts: if o == '-v': verbose = verbose+1 if o == '-q': quiet = 1; verbose = 0 if o == '-g': generate = 1 if o == '-x': exclude = 1 if o == '-s': single = 1 if o == '-r': randomize = 1 if generate and verbose: print "-g and -v don't go together!" return 2 good = [] bad = [] skipped = [] if single: from tempfile import gettempdir filename = os.path.join(gettempdir(), 'pynexttest') try: fp = open(filename, 'r') next = string.strip(fp.read()) tests = [next] fp.close() except IOError: pass for i in range(len(args)): # Strip trailing ".py" from arguments if args[i][-3:] == '.py': args[i] = args[i][:-3] stdtests = STDTESTS[:] nottests = NOTTESTS[:] if exclude: for arg in args: if arg in stdtests: stdtests.remove(arg) nottests[:0] = args args = [] tests = tests or args or findtests(testdir, stdtests, nottests) if single: tests = tests[:1] if randomize: random.shuffle(tests) test_support.verbose = verbose # Tell tests to be moderately quiet save_modules = sys.modules.keys() for test in tests: if not quiet: print test ok = runtest(test, generate, verbose, testdir) if ok > 0: good.append(test) elif ok == 0: bad.append(test) else: if not quiet: print "test", test, print "skipped -- an optional feature could not be imported" skipped.append(test) # Unload the newly imported modules (best effort finalization) for module in sys.modules.keys(): if module not in save_modules and module.startswith("test."): test_support.unload(module) if good and not quiet: if not bad and not skipped and len(good) > 1: print "All", print count(len(good), "test"), "OK." if bad: print count(len(bad), "test"), "failed:", print string.join(bad) if skipped and not quiet: print count(len(skipped), "test"), "skipped:", print string.join(skipped) if single: alltests = findtests(testdir, stdtests, nottests) for i in range(len(alltests)): if tests[0] == alltests[i]: if i == len(alltests) - 1: os.unlink(filename) else: fp = open(filename, 'w') fp.write(alltests[i+1] + '\n') fp.close() break else: os.unlink(filename) return len(bad) > 0
a873b03ebb24076b3664ba694eeed4ab07d176d9 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/a873b03ebb24076b3664ba694eeed4ab07d176d9/regrtest.py
The other six default arguments (verbose, quiet, generate, exclude, single, and randomize) allow programmers calling main() directly to set the values that would normally be set by flags on the command line.
The other seven default arguments (verbose, quiet, generate, exclude, single, randomize, and leakdebug) allow programmers calling main() directly to set the values that would normally be set by flags on the command line.
def main(tests=None, testdir=None, verbose=0, quiet=0, generate=0, exclude=0, single=0, randomize=0): """Execute a test suite. This also parses command-line options and modifies its behavior accordingly. tests -- a list of strings containing test names (optional) testdir -- the directory in which to look for tests (optional) Users other than the Python test suite will certainly want to specify testdir; if it's omitted, the directory containing the Python test suite is searched for. If the tests argument is omitted, the tests listed on the command-line will be used. If that's empty, too, then all *.py files beginning with test_ will be used. The other six default arguments (verbose, quiet, generate, exclude, single, and randomize) allow programmers calling main() directly to set the values that would normally be set by flags on the command line. """ try: opts, args = getopt.getopt(sys.argv[1:], 'vgqxsr') except getopt.error, msg: print msg print __doc__ return 2 for o, a in opts: if o == '-v': verbose = verbose+1 if o == '-q': quiet = 1; verbose = 0 if o == '-g': generate = 1 if o == '-x': exclude = 1 if o == '-s': single = 1 if o == '-r': randomize = 1 if generate and verbose: print "-g and -v don't go together!" return 2 good = [] bad = [] skipped = [] if single: from tempfile import gettempdir filename = os.path.join(gettempdir(), 'pynexttest') try: fp = open(filename, 'r') next = string.strip(fp.read()) tests = [next] fp.close() except IOError: pass for i in range(len(args)): # Strip trailing ".py" from arguments if args[i][-3:] == '.py': args[i] = args[i][:-3] stdtests = STDTESTS[:] nottests = NOTTESTS[:] if exclude: for arg in args: if arg in stdtests: stdtests.remove(arg) nottests[:0] = args args = [] tests = tests or args or findtests(testdir, stdtests, nottests) if single: tests = tests[:1] if randomize: random.shuffle(tests) test_support.verbose = verbose # Tell tests to be moderately quiet save_modules = sys.modules.keys() for test in tests: if not quiet: print test ok = runtest(test, generate, verbose, testdir) if ok > 0: good.append(test) elif ok == 0: bad.append(test) else: if not quiet: print "test", test, print "skipped -- an optional feature could not be imported" skipped.append(test) # Unload the newly imported modules (best effort finalization) for module in sys.modules.keys(): if module not in save_modules and module.startswith("test."): test_support.unload(module) if good and not quiet: if not bad and not skipped and len(good) > 1: print "All", print count(len(good), "test"), "OK." if bad: print count(len(bad), "test"), "failed:", print string.join(bad) if skipped and not quiet: print count(len(skipped), "test"), "skipped:", print string.join(skipped) if single: alltests = findtests(testdir, stdtests, nottests) for i in range(len(alltests)): if tests[0] == alltests[i]: if i == len(alltests) - 1: os.unlink(filename) else: fp = open(filename, 'w') fp.write(alltests[i+1] + '\n') fp.close() break else: os.unlink(filename) return len(bad) > 0
a873b03ebb24076b3664ba694eeed4ab07d176d9 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/a873b03ebb24076b3664ba694eeed4ab07d176d9/regrtest.py
opts, args = getopt.getopt(sys.argv[1:], 'vgqxsr')
opts, args = getopt.getopt(sys.argv[1:], 'vgqxsrl')
def main(tests=None, testdir=None, verbose=0, quiet=0, generate=0, exclude=0, single=0, randomize=0): """Execute a test suite. This also parses command-line options and modifies its behavior accordingly. tests -- a list of strings containing test names (optional) testdir -- the directory in which to look for tests (optional) Users other than the Python test suite will certainly want to specify testdir; if it's omitted, the directory containing the Python test suite is searched for. If the tests argument is omitted, the tests listed on the command-line will be used. If that's empty, too, then all *.py files beginning with test_ will be used. The other six default arguments (verbose, quiet, generate, exclude, single, and randomize) allow programmers calling main() directly to set the values that would normally be set by flags on the command line. """ try: opts, args = getopt.getopt(sys.argv[1:], 'vgqxsr') except getopt.error, msg: print msg print __doc__ return 2 for o, a in opts: if o == '-v': verbose = verbose+1 if o == '-q': quiet = 1; verbose = 0 if o == '-g': generate = 1 if o == '-x': exclude = 1 if o == '-s': single = 1 if o == '-r': randomize = 1 if generate and verbose: print "-g and -v don't go together!" return 2 good = [] bad = [] skipped = [] if single: from tempfile import gettempdir filename = os.path.join(gettempdir(), 'pynexttest') try: fp = open(filename, 'r') next = string.strip(fp.read()) tests = [next] fp.close() except IOError: pass for i in range(len(args)): # Strip trailing ".py" from arguments if args[i][-3:] == '.py': args[i] = args[i][:-3] stdtests = STDTESTS[:] nottests = NOTTESTS[:] if exclude: for arg in args: if arg in stdtests: stdtests.remove(arg) nottests[:0] = args args = [] tests = tests or args or findtests(testdir, stdtests, nottests) if single: tests = tests[:1] if randomize: random.shuffle(tests) test_support.verbose = verbose # Tell tests to be moderately quiet save_modules = sys.modules.keys() for test in tests: if not quiet: print test ok = runtest(test, generate, verbose, testdir) if ok > 0: good.append(test) elif ok == 0: bad.append(test) else: if not quiet: print "test", test, print "skipped -- an optional feature could not be imported" skipped.append(test) # Unload the newly imported modules (best effort finalization) for module in sys.modules.keys(): if module not in save_modules and module.startswith("test."): test_support.unload(module) if good and not quiet: if not bad and not skipped and len(good) > 1: print "All", print count(len(good), "test"), "OK." if bad: print count(len(bad), "test"), "failed:", print string.join(bad) if skipped and not quiet: print count(len(skipped), "test"), "skipped:", print string.join(skipped) if single: alltests = findtests(testdir, stdtests, nottests) for i in range(len(alltests)): if tests[0] == alltests[i]: if i == len(alltests) - 1: os.unlink(filename) else: fp = open(filename, 'w') fp.write(alltests[i+1] + '\n') fp.close() break else: os.unlink(filename) return len(bad) > 0
a873b03ebb24076b3664ba694eeed4ab07d176d9 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/a873b03ebb24076b3664ba694eeed4ab07d176d9/regrtest.py
cantset(f, "func_name", "f") cantset(f, "__name__", "f")
f.__name__ = "g" verify(f.__name__ == "g") verify(f.func_name == "g") f.func_name = "h" verify(f.__name__ == "h") verify(f.func_name == "h") cantset(f, "func_globals", 1) cantset(f, "__name__", 1)
def f(): pass
5e897959db37752da4c6b476903cdc5e1357093c /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/5e897959db37752da4c6b476903cdc5e1357093c/test_funcattrs.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]
d825143be1118ba7e320661b3a71d8822ae5d600 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/d825143be1118ba7e320661b3a71d8822ae5d600/mbcs.py
list.append('%s: %s\n' % (str(stype), _some_str(value)))
s = _some_str(value) if s: list.append('%s: %s\n' % (str(stype), s)) else: list.append('%s\n' % str(stype))
def format_exception_only(etype, value): """Format the exception part of a traceback. The arguments are the exception type and value such as given by sys.last_type and sys.last_value. The return value is a list of strings, each ending in a newline. Normally, the list contains a single string; however, for SyntaxError exceptions, it contains several lines that (when printed) display detailed information about where the syntax error occurred. The message indicating which exception occurred is the always last string in the list.""" list = [] if type(etype) == types.ClassType: stype = etype.__name__ else: stype = etype if value is None: list.append(str(stype) + '\n') else: if etype is SyntaxError: try: msg, (filename, lineno, offset, line) = value except: pass else: if not filename: filename = "<string>" list.append(' File "%s", line %d\n' % (filename, lineno)) i = 0 while i < len(line) and \ line[i] in string.whitespace: i = i+1 list.append(' %s\n' % string.strip(line)) s = ' ' for c in line[i:offset-1]: if c in string.whitespace: s = s + c else: s = s + ' ' list.append('%s^\n' % s) value = msg list.append('%s: %s\n' % (str(stype), _some_str(value))) return list
3ad167ae34f47328c9054cea33edea3d5b2011bd /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/3ad167ae34f47328c9054cea33edea3d5b2011bd/traceback.py
return map(self._nametowidget, self.tk.splitlist(self.tk.call( 'winfo', 'children', self._w)))
result = [] for child in self.tk.splitlist( self.tk.call('winfo', 'children', self._w)): try: result.append(self._nametowidget(child)) except KeyError: pass return result
def winfo_children(self): """Return a list of all widgets which are children of this widget.""" return map(self._nametowidget, self.tk.splitlist(self.tk.call( 'winfo', 'children', self._w)))
f2041b8aa6a451f8602dc5ee4cd4db838d467519 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/f2041b8aa6a451f8602dc5ee4cd4db838d467519/Tkinter.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)
3ec38f0ee48b31c80510c60b3df0e6bc4dfb89f9 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/3ec38f0ee48b31c80510c60b3df0e6bc4dfb89f9/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
3ec38f0ee48b31c80510c60b3df0e6bc4dfb89f9 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/3ec38f0ee48b31c80510c60b3df0e6bc4dfb89f9/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):
3ec38f0ee48b31c80510c60b3df0e6bc4dfb89f9 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/3ec38f0ee48b31c80510c60b3df0e6bc4dfb89f9/rexec.py
self.rexec = rexec
self.rexec = rexec
def set_rexec(self, rexec):
3ec38f0ee48b31c80510c60b3df0e6bc4dfb89f9 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/3ec38f0ee48b31c80510c60b3df0e6bc4dfb89f9/rexec.py
return self.rexec.is_builtin(name)
return self.rexec.is_builtin(name)
def is_builtin(self, name):
3ec38f0ee48b31c80510c60b3df0e6bc4dfb89f9 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/3ec38f0ee48b31c80510c60b3df0e6bc4dfb89f9/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):
3ec38f0ee48b31c80510c60b3df0e6bc4dfb89f9 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/3ec38f0ee48b31c80510c60b3df0e6bc4dfb89f9/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):
3ec38f0ee48b31c80510c60b3df0e6bc4dfb89f9 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/3ec38f0ee48b31c80510c60b3df0e6bc4dfb89f9/rexec.py
return self.rexec.add_module(name)
return self.rexec.add_module(name)
def add_module(self, name):
3ec38f0ee48b31c80510c60b3df0e6bc4dfb89f9 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/3ec38f0ee48b31c80510c60b3df0e6bc4dfb89f9/rexec.py
return self.rexec.modules
return self.rexec.modules
def modules_dict(self):
3ec38f0ee48b31c80510c60b3df0e6bc4dfb89f9 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/3ec38f0ee48b31c80510c60b3df0e6bc4dfb89f9/rexec.py
return self.rexec.modules['sys'].path
return self.rexec.modules['sys'].path
def default_path(self):
3ec38f0ee48b31c80510c60b3df0e6bc4dfb89f9 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/3ec38f0ee48b31c80510c60b3df0e6bc4dfb89f9/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)
3ec38f0ee48b31c80510c60b3df0e6bc4dfb89f9 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/3ec38f0ee48b31c80510c60b3df0e6bc4dfb89f9/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)
3ec38f0ee48b31c80510c60b3df0e6bc4dfb89f9 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/3ec38f0ee48b31c80510c60b3df0e6bc4dfb89f9/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)
3ec38f0ee48b31c80510c60b3df0e6bc4dfb89f9 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/3ec38f0ee48b31c80510c60b3df0e6bc4dfb89f9/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)
3ec38f0ee48b31c80510c60b3df0e6bc4dfb89f9 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/3ec38f0ee48b31c80510c60b3df0e6bc4dfb89f9/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)
3ec38f0ee48b31c80510c60b3df0e6bc4dfb89f9 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/3ec38f0ee48b31c80510c60b3df0e6bc4dfb89f9/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):
3ec38f0ee48b31c80510c60b3df0e6bc4dfb89f9 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/3ec38f0ee48b31c80510c60b3df0e6bc4dfb89f9/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):
3ec38f0ee48b31c80510c60b3df0e6bc4dfb89f9 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/3ec38f0ee48b31c80510c60b3df0e6bc4dfb89f9/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):
3ec38f0ee48b31c80510c60b3df0e6bc4dfb89f9 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/3ec38f0ee48b31c80510c60b3df0e6bc4dfb89f9/rexec.py
self.make_main() self.make_osname()
self.make_main() self.make_osname()
def make_initial_modules(self):
3ec38f0ee48b31c80510c60b3df0e6bc4dfb89f9 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/3ec38f0ee48b31c80510c60b3df0e6bc4dfb89f9/rexec.py
return mname in self.ok_builtin_modules
return mname in self.ok_builtin_modules
def is_builtin(self, mname):
3ec38f0ee48b31c80510c60b3df0e6bc4dfb89f9 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/3ec38f0ee48b31c80510c60b3df0e6bc4dfb89f9/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):
3ec38f0ee48b31c80510c60b3df0e6bc4dfb89f9 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/3ec38f0ee48b31c80510c60b3df0e6bc4dfb89f9/rexec.py
m = self.add_module('__main__')
m = self.add_module('__main__')
def make_main(self):
3ec38f0ee48b31c80510c60b3df0e6bc4dfb89f9 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/3ec38f0ee48b31c80510c60b3df0e6bc4dfb89f9/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):
3ec38f0ee48b31c80510c60b3df0e6bc4dfb89f9 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/3ec38f0ee48b31c80510c60b3df0e6bc4dfb89f9/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):
3ec38f0ee48b31c80510c60b3df0e6bc4dfb89f9 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/3ec38f0ee48b31c80510c60b3df0e6bc4dfb89f9/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):
3ec38f0ee48b31c80510c60b3df0e6bc4dfb89f9 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/3ec38f0ee48b31c80510c60b3df0e6bc4dfb89f9/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):
3ec38f0ee48b31c80510c60b3df0e6bc4dfb89f9 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/3ec38f0ee48b31c80510c60b3df0e6bc4dfb89f9/rexec.py
return self.add_module(src.__name__)
return self.add_module(src.__name__)
def copy_none(self, src):
3ec38f0ee48b31c80510c60b3df0e6bc4dfb89f9 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/3ec38f0ee48b31c80510c60b3df0e6bc4dfb89f9/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):
3ec38f0ee48b31c80510c60b3df0e6bc4dfb89f9 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/3ec38f0ee48b31c80510c60b3df0e6bc4dfb89f9/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):
3ec38f0ee48b31c80510c60b3df0e6bc4dfb89f9 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/3ec38f0ee48b31c80510c60b3df0e6bc4dfb89f9/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):
3ec38f0ee48b31c80510c60b3df0e6bc4dfb89f9 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/3ec38f0ee48b31c80510c60b3df0e6bc4dfb89f9/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):
3ec38f0ee48b31c80510c60b3df0e6bc4dfb89f9 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/3ec38f0ee48b31c80510c60b3df0e6bc4dfb89f9/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=[]):
3ec38f0ee48b31c80510c60b3df0e6bc4dfb89f9 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/3ec38f0ee48b31c80510c60b3df0e6bc4dfb89f9/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']
3ec38f0ee48b31c80510c60b3df0e6bc4dfb89f9 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/3ec38f0ee48b31c80510c60b3df0e6bc4dfb89f9/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):
3ec38f0ee48b31c80510c60b3df0e6bc4dfb89f9 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/3ec38f0ee48b31c80510c60b3df0e6bc4dfb89f9/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):
3ec38f0ee48b31c80510c60b3df0e6bc4dfb89f9 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/3ec38f0ee48b31c80510c60b3df0e6bc4dfb89f9/rexec.py
self.restore_files()
self.restore_files()
def reset_files(self):
3ec38f0ee48b31c80510c60b3df0e6bc4dfb89f9 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/3ec38f0ee48b31c80510c60b3df0e6bc4dfb89f9/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):
3ec38f0ee48b31c80510c60b3df0e6bc4dfb89f9 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/3ec38f0ee48b31c80510c60b3df0e6bc4dfb89f9/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):
3ec38f0ee48b31c80510c60b3df0e6bc4dfb89f9 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/3ec38f0ee48b31c80510c60b3df0e6bc4dfb89f9/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):
3ec38f0ee48b31c80510c60b3df0e6bc4dfb89f9 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/3ec38f0ee48b31c80510c60b3df0e6bc4dfb89f9/rexec.py
self.restore_files()
self.restore_files()
def s_apply(self, func, args=(), kw=None):
3ec38f0ee48b31c80510c60b3df0e6bc4dfb89f9 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/3ec38f0ee48b31c80510c60b3df0e6bc4dfb89f9/rexec.py
try: try: s = raw_input('>>> ') except EOFError: print break if s and s[0] != ' s = s + '\n' c = compile(s, '<stdin>', 'single') r.r_exec(c) except SystemExit, n: sys.exit(n) except: traceback.print_exc()
try: try: s = raw_input('>>> ') except EOFError: print break if s and s[0] != ' s = s + '\n' c = compile(s, '<stdin>', 'single') r.r_exec(c) except SystemExit, n: sys.exit(n) except: traceback.print_exc()
def test(): import traceback r = RExec(verbose=('-v' in sys.argv[1:])) print "*** RESTRICTED *** Python", sys.version print sys.copyright while 1: try: try: s = raw_input('>>> ') except EOFError: print break if s and s[0] != '#': s = s + '\n' c = compile(s, '<stdin>', 'single') r.r_exec(c) except SystemExit, n: sys.exit(n) except: traceback.print_exc()
3ec38f0ee48b31c80510c60b3df0e6bc4dfb89f9 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/3ec38f0ee48b31c80510c60b3df0e6bc4dfb89f9/rexec.py
def cmp(f1, f2, shallow=1,use_statcache=0): """Compare two files. Arguments: f1 -- First file name f2 -- Second file name shallow -- Just check stat signature (do not read the files). defaults to 1. use_statcache -- Do not stat() each file directly: go through the statcache module for more efficiency. Return value: integer -- 1 if the files are the same, 0 otherwise. This function uses a cache for past comparisons and the results, with a cache invalidation mechanism relying on stale signatures. Of course, if 'use_statcache' is true, this mechanism is defeated, and the cache will never grow stale. """ stat_function = (os.stat, statcache.stat)[use_statcache] s1, s2 = _sig(stat_function(f1)), _sig(stat_function(f2)) if s1[0]!=stat.S_IFREG or s2[0]!=stat.S_IFREG: return 0 if shallow and s1 == s2: return 1 if s1[1]!=s2[1]: return 0 result = _cache.get((f1, f2)) if result and (s1, s2)==result[:2]: return result[2] outcome = _do_cmp(f1, f2) _cache[f1, f2] = s1, s2, outcome return outcome
def cmp(f1, f2, shallow=1,use_statcache=0): """Compare two files. Arguments: f1 -- First file name f2 -- Second file name shallow -- Just check stat signature (do not read the files). defaults to 1. use_statcache -- Do not stat() each file directly: go through the statcache module for more efficiency. Return value: integer -- 1 if the files are the same, 0 otherwise. This function uses a cache for past comparisons and the results, with a cache invalidation mechanism relying on stale signatures. Of course, if 'use_statcache' is true, this mechanism is defeated, and the cache will never grow stale. """ stat_function = (os.stat, statcache.stat)[use_statcache] s1, s2 = _sig(stat_function(f1)), _sig(stat_function(f2)) if s1[0]!=stat.S_IFREG or s2[0]!=stat.S_IFREG: return 0 if shallow and s1 == s2: return 1 if s1[1]!=s2[1]: return 0 result = _cache.get((f1, f2)) if result and (s1, s2)==result[:2]: return result[2] outcome = _do_cmp(f1, f2) _cache[f1, f2] = s1, s2, outcome return outcome
def cmp(f1, f2, shallow=1,use_statcache=0): """Compare two files. Arguments: f1 -- First file name f2 -- Second file name shallow -- Just check stat signature (do not read the files). defaults to 1. use_statcache -- Do not stat() each file directly: go through the statcache module for more efficiency. Return value: integer -- 1 if the files are the same, 0 otherwise. This function uses a cache for past comparisons and the results, with a cache invalidation mechanism relying on stale signatures. Of course, if 'use_statcache' is true, this mechanism is defeated, and the cache will never grow stale. """ stat_function = (os.stat, statcache.stat)[use_statcache] s1, s2 = _sig(stat_function(f1)), _sig(stat_function(f2)) if s1[0]!=stat.S_IFREG or s2[0]!=stat.S_IFREG: return 0 if shallow and s1 == s2: return 1 if s1[1]!=s2[1]: return 0 result = _cache.get((f1, f2)) if result and (s1, s2)==result[:2]: return result[2] outcome = _do_cmp(f1, f2) _cache[f1, f2] = s1, s2, outcome return outcome
43265beff993bd07f7d685394c02fd55433004f1 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/43265beff993bd07f7d685394c02fd55433004f1/filecmp.py
return (stat.S_IFMT(st[stat.ST_MODE]), st[stat.ST_SIZE], st[stat.ST_MTIME])
return (stat.S_IFMT(st[stat.ST_MODE]), st[stat.ST_SIZE], st[stat.ST_MTIME])
def _sig(st): return (stat.S_IFMT(st[stat.ST_MODE]), st[stat.ST_SIZE], st[stat.ST_MTIME])
43265beff993bd07f7d685394c02fd55433004f1 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/43265beff993bd07f7d685394c02fd55433004f1/filecmp.py
if value is not None and value != 'C':
if value not in (None, '', 'C'):
def setlocale(category, value=None): """ setlocale(integer,string=None) -> string. Activates/queries locale processing. """ if value is not None and value != 'C': raise Error, '_locale emulation only supports "C" locale' return 'C'
103d6e7a3c9feed2ef54d51c77f0daa614dc936a /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/103d6e7a3c9feed2ef54d51c77f0daa614dc936a/locale.py
if froms == '*': froms = theMod.__dict__.keys() for item in froms: (envLocals or envGlobals)[item] = theMod.__dict__[item]
while froms: item = froms[0]; del froms[0] if item == '*': froms = theMod.__dict__.keys() + froms else: try: (envLocals or envGlobals)[item] = theMod.__dict__[item] except KeyError: raise ImportError, ("name '%s' not found in module %s" % (item, theMod.__name__))
def import_module(name, envLocals=None, envGlobals=None, froms=None, inPkg=None): """Primary service routine implementing 'import' with package nesting.""" # The job is divided into a few distinct steps: # # - Look for either an already loaded module or a file to be loaded. # * if neither loaded module nor prospect file is found, raise an error. # - If we have a file, not an already loaded module: # - Load the file into a module. # - Register the new module and intermediate package stubs. # (We have a module at this point...) # - Bind requested syms (module or specified 'from' defs) in calling env. # - Return the appropriate component. note("import_module: seeking '%s'%s" % (name, ((inPkg and ' (in package %s)' % inPkg.__name__) or ''))) # We need callers environment dict for local path and resulting module # binding. if not (envLocals or envGlobals): envLocals, envGlobals = exterior() modList = theMod = absNm = container = None # Get module obj if one already established, or else module file if not: if inPkg: # We've been invoked with a specific containing package: pkg, pkgPath, pkgNm = inPkg, inPkg.__dict__[PKG_PATH], inPkg.__name__ relNm = name absNm = pkgNm + '.' + name elif name[:PKG_SHORT_NM_LEN+1] != PKG_SHORT_NM + '.': # name is NOT '__.something' - setup to seek according to specified # absolute name. pkg = __python__ pkgPath = sys.path absNm = name relNm = absNm else: # name IS '__.' + something - setup to seek according to relative name, # in current package. relNm = name[len(PKG_SHORT_NM)+1:] # Relative portion of name. try: pkg = envGlobals[PKG_NM] # The immediately containing package. pkgPath = pkg.__dict__[PKG_PATH] if pkg == __python__: # At outermost package. absNm = relNm else: absNm = (pkg.__name__ + '.' + relNm) except KeyError: # Missing package, path, or name. note("Can't identify parent package, package name, or pkgpath") pass # ==v # Try to find existing module: if sys.modules.has_key(absNm): note('found ' + absNm + ' already imported') theMod = sys.modules[absNm] else: # Try for builtin or frozen first: theMod = imp.init_builtin(absNm) if theMod: note('found builtin ' + absNm) else: theMod = imp.init_frozen(absNm) if theMod: note('found frozen ' + absNm) if not theMod: if type(pkgPath) == types.StringType: pkgPath = [pkgPath] modList = find_module(relNm, pkgPath, absNm) if not modList: raise ImportError, "module '%s' not found" % absNm # ===X # We have a list of successively nested files leading to the # module, register them as stubs: container = register_module_nesting(modList, pkg) # Load from file if necessary and possible: modNm, modf, path, ty = modList[-1] note('found type ' + modes[ty[2]] + ' - ' + absNm) # Do the load: theMod = load_module(absNm, ty[2], modf, inPkg) # Loaded successfully - promote module to full module status: register_module(theMod, theMod.__name__, pkgPath, pkg) # Have a loaded module, impose designated components, and return # appropriate thing - according to guido: # "Note that for "from spam.ham import bacon" your function should # return the object denoted by 'spam.ham', while for "import # spam.ham" it should return the object denoted by 'spam' -- the # STORE instructions following the import statement expect it this # way." if not froms: # Establish the module defs in the importing name space: (envLocals or envGlobals)[name] = theMod return (container or theMod) else: # Implement 'from': Populate immediate env with module defs: if froms == '*': froms = theMod.__dict__.keys() # resolve '*' for item in froms: (envLocals or envGlobals)[item] = theMod.__dict__[item] return theMod
b1c1315ba309b00625f19f2cf24c0cbd27b88ca5 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/b1c1315ba309b00625f19f2cf24c0cbd27b88ca5/newimp.py
print e.__dict__
def update(self): self.prepare() for file in self.rcsfiles: e = self.preparedetails(file) if e.lsum == e.sum == e.rsum: print '=', file continue if e.sum == e.rsum: if e.rev != e.rrev: print '%s: %s -> %s w/o change' % \ (file, e.rev, e.rrev) e.rev = e.rrev if e.lsum != e.sum: if e.lsum is None: print '%s: file was lost' % \ (file,) self.get(e) elif e.new: print 'A', file else: print 'M', file continue if e.lsum == e.sum: if e.rev == e.rrev: print '%s: no new revision' % file print 'U', file, sys.stdout.flush() self.get(e) print continue if e.lsum == e.rsum: print 'c', file print e.__dict__ e.rev = e.rrev e.sum = e.rsum e.new = e.sum is None and e.lsum is not None if e.sum: e.mtime, e.ctime = os.stat(e.file)[-2:] print e.__dict__ self.entries[file] = e continue print 'C', file, '(not resolved)' self.writeentries() self.writesums()
68abf54d71224efaa9967a13a1a60380c66b4533 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/68abf54d71224efaa9967a13a1a60380c66b4533/rcvs.py
print e.__dict__
def update(self): self.prepare() for file in self.rcsfiles: e = self.preparedetails(file) if e.lsum == e.sum == e.rsum: print '=', file continue if e.sum == e.rsum: if e.rev != e.rrev: print '%s: %s -> %s w/o change' % \ (file, e.rev, e.rrev) e.rev = e.rrev if e.lsum != e.sum: if e.lsum is None: print '%s: file was lost' % \ (file,) self.get(e) elif e.new: print 'A', file else: print 'M', file continue if e.lsum == e.sum: if e.rev == e.rrev: print '%s: no new revision' % file print 'U', file, sys.stdout.flush() self.get(e) print continue if e.lsum == e.rsum: print 'c', file print e.__dict__ e.rev = e.rrev e.sum = e.rsum e.new = e.sum is None and e.lsum is not None if e.sum: e.mtime, e.ctime = os.stat(e.file)[-2:] print e.__dict__ self.entries[file] = e continue print 'C', file, '(not resolved)' self.writeentries() self.writesums()
68abf54d71224efaa9967a13a1a60380c66b4533 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/68abf54d71224efaa9967a13a1a60380c66b4533/rcvs.py
j = string.index(rawdata, '>', i) except string.index_error: return -1 attrs = [] tagfind = regex.compile('[a-zA-Z][a-zA-Z0-9]*') attrfind = regex.compile( '[ \t\n]+\([a-zA-Z_][a-zA-Z_0-9]*\)' + '\([ \t\n]*=[ \t\n]*' + '\(\'[^\']*\'\|"[^"]*"\|[-a-zA-Z0-9./:+*%?!()_ k = tagfind.match(rawdata, i+1) if k < 0: raise RuntimeError, 'unexpected call to parse_starttag' k = i+1+k tag = string.lower(rawdata[i+1:k]) while k < j: l = attrfind.match(rawdata, k) if l < 0: break attrname, rest, attrvalue = attrfind.group(1, 2, 3) if not rest: attrvalue = attrname elif attrvalue[:1] == '\'' == attrvalue[-1:] or \ attrvalue[:1] == '"' == attrvalue[-1:]: attrvalue = attrvalue[1:-1] attrs.append((string.lower(attrname), attrvalue)) k = k + l j = j+1 try: method = getattr(self, 'start_' + tag)
method = getattr(self, 'end_' + tag)
def parse_starttag(self, i): rawdata = self.rawdata try: j = string.index(rawdata, '>', i) except string.index_error: return -1 # Now parse the data between i+1 and j into a tag and attrs attrs = [] tagfind = regex.compile('[a-zA-Z][a-zA-Z0-9]*') attrfind = regex.compile( '[ \t\n]+\([a-zA-Z_][a-zA-Z_0-9]*\)' + '\([ \t\n]*=[ \t\n]*' + '\(\'[^\']*\'\|"[^"]*"\|[-a-zA-Z0-9./:+*%?!()_#]*\)\)?') k = tagfind.match(rawdata, i+1) if k < 0: raise RuntimeError, 'unexpected call to parse_starttag' k = i+1+k tag = string.lower(rawdata[i+1:k]) while k < j: l = attrfind.match(rawdata, k) if l < 0: break attrname, rest, attrvalue = attrfind.group(1, 2, 3) if not rest: attrvalue = attrname elif attrvalue[:1] == '\'' == attrvalue[-1:] or \ attrvalue[:1] == '"' == attrvalue[-1:]: attrvalue = attrvalue[1:-1] attrs.append((string.lower(attrname), attrvalue)) k = k + l j = j+1 try: method = getattr(self, 'start_' + tag) except AttributeError: try: method = getattr(self, 'do_' + tag) except AttributeError: self.unknown_starttag(tag, attrs) return j-i method(attrs) return j-i self.stack.append(tag) method(attrs) return j-i
48766512a0b438b66e97dfdfcb933cd104baeffe /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/48766512a0b438b66e97dfdfcb933cd104baeffe/sgmllib.py
try: method = getattr(self, 'do_' + tag) except AttributeError: self.unknown_starttag(tag, attrs) return j-i method(attrs) return j-i self.stack.append(tag) method(attrs) return j-i def parse_endtag(self, data): if data[:2] <> '</' or data[-1:] <> '>': raise RuntimeError, 'unexpected call to parse_endtag' tag = string.lower(string.strip(data[2:-1])) try: method = getattr(self, 'end_' + tag) except AttributeError: self.unknown_endtag(tag) return if self.stack and self.stack[-1] == tag: del self.stack[-1] else: self.report_unbalanced(tag) found = None for i in range(len(self.stack)): if self.stack[i] == tag: found = i if found <> None: del self.stack[found:] method() def report_unbalanced(self, tag): if self.verbose: print '*** Unbalanced </' + tag + '>' print '*** Stack:', self.stack def handle_charref(self, name): try: n = string.atoi(name) except string.atoi_error: self.unknown_charref(name) return if not 0 <= n <= 255: self.unknown_charref(name) return self.handle_data(chr(n)) entitydefs = \ {'lt': '<', 'gt': '>', 'amp': '&', 'quot': '"', 'apos': '\''} def handle_entityref(self, name): table = self.entitydefs if table.has_key(name): self.handle_data(table[name]) else: self.unknown_entityref(name) return def handle_data(self, data): pass def handle_comment(self, data): pass def unknown_starttag(self, tag, attrs): pass def unknown_endtag(self, tag): pass def unknown_charref(self, ref): pass def unknown_entityref(self, ref): pass class TestSGML(SGMLParser): def handle_data(self, data): r = repr(data) if len(r) > 72: r = r[:35] + '...' + r[-35:] print 'data:', r def handle_comment(self, data): r = repr(data) if len(r) > 68: r = r[:32] + '...' + r[-32:] print 'comment:', r def unknown_starttag(self, tag, attrs): print 'start tag: <' + tag, for name, value in attrs: print name + '=' + '"' + value + '"', print '>' def unknown_endtag(self, tag): print 'end tag: </' + tag + '>' def unknown_entityref(self, ref): print '*** unknown entity ref: &' + ref + ';' def unknown_charref(self, ref): print '*** unknown char ref: & def test():
self.unknown_endtag(tag) return found = len(self.stack) for i in range(found): if self.stack[i] == tag: found = i while len(self.stack) > found: tag = self.stack[-1] try: method = getattr(self, 'end_' + tag) except AttributeError: method = None if method: self.handle_endtag(tag, method) else: self.unknown_endtag(tag) del self.stack[-1] def handle_starttag(self, tag, method, attrs): method(attrs) def handle_endtag(self, tag, method): method() def report_unbalanced(self, tag): if self.verbose: print '*** Unbalanced </' + tag + '>' print '*** Stack:', self.stack def handle_charref(self, name): try: n = string.atoi(name) except string.atoi_error: self.unknown_charref(name) return if not 0 <= n <= 255: self.unknown_charref(name) return self.handle_data(chr(n)) entitydefs = \ {'lt': '<', 'gt': '>', 'amp': '&', 'quot': '"', 'apos': '\''} def handle_entityref(self, name): table = self.entitydefs if table.has_key(name): self.handle_data(table[name]) else: self.unknown_entityref(name) return def handle_data(self, data): pass def handle_comment(self, data): pass def unknown_starttag(self, tag, attrs): pass def unknown_endtag(self, tag): pass def unknown_charref(self, ref): pass def unknown_entityref(self, ref): pass class TestSGMLParser(SGMLParser): def __init__(self, verbose=0): self.testdata = "" SGMLParser.__init__(self, verbose) def handle_data(self, data): self.testdata = self.testdata + data if len(`self.testdata`) >= 70: self.flush() def flush(self): data = self.testdata if data: self.testdata = "" print 'data:', `data` def handle_comment(self, data): self.flush() r = `data` if len(r) > 68: r = r[:32] + '...' + r[-32:] print 'comment:', r def unknown_starttag(self, tag, attrs): self.flush() if not attrs: print 'start tag: <' + tag + '>' else: print 'start tag: <' + tag, for name, value in attrs: print name + '=' + '"' + value + '"', print '>' def unknown_endtag(self, tag): self.flush() print 'end tag: </' + tag + '>' def unknown_entityref(self, ref): self.flush() print '*** unknown entity ref: &' + ref + ';' def unknown_charref(self, ref): self.flush() print '*** unknown char ref: & def close(self): SGMLParser.close(self) self.flush() def test(args = None): import sys if not args: args = sys.argv[1:] if args and args[0] == '-s': args = args[1:] klass = SGMLParser else: klass = TestSGMLParser if args: file = args[0] else:
def parse_starttag(self, i): rawdata = self.rawdata try: j = string.index(rawdata, '>', i) except string.index_error: return -1 # Now parse the data between i+1 and j into a tag and attrs attrs = [] tagfind = regex.compile('[a-zA-Z][a-zA-Z0-9]*') attrfind = regex.compile( '[ \t\n]+\([a-zA-Z_][a-zA-Z_0-9]*\)' + '\([ \t\n]*=[ \t\n]*' + '\(\'[^\']*\'\|"[^"]*"\|[-a-zA-Z0-9./:+*%?!()_#]*\)\)?') k = tagfind.match(rawdata, i+1) if k < 0: raise RuntimeError, 'unexpected call to parse_starttag' k = i+1+k tag = string.lower(rawdata[i+1:k]) while k < j: l = attrfind.match(rawdata, k) if l < 0: break attrname, rest, attrvalue = attrfind.group(1, 2, 3) if not rest: attrvalue = attrname elif attrvalue[:1] == '\'' == attrvalue[-1:] or \ attrvalue[:1] == '"' == attrvalue[-1:]: attrvalue = attrvalue[1:-1] attrs.append((string.lower(attrname), attrvalue)) k = k + l j = j+1 try: method = getattr(self, 'start_' + tag) except AttributeError: try: method = getattr(self, 'do_' + tag) except AttributeError: self.unknown_starttag(tag, attrs) return j-i method(attrs) return j-i self.stack.append(tag) method(attrs) return j-i
48766512a0b438b66e97dfdfcb933cd104baeffe /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/48766512a0b438b66e97dfdfcb933cd104baeffe/sgmllib.py
f = open(file, 'r') x = TestSGML() while 1: line = f.readline() if not line: x.close() break x.feed(line)
if file == '-': f = sys.stdin else: try: f = open(file, 'r') except IOError, msg: print file, ":", msg sys.exit(1) data = f.read() if f is not sys.stdin: f.close() x = klass() for c in data: x.feed(c) x.close()
def test(): file = 'test.html' f = open(file, 'r') x = TestSGML() while 1: line = f.readline() if not line: x.close() break x.feed(line)
48766512a0b438b66e97dfdfcb933cd104baeffe /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/48766512a0b438b66e97dfdfcb933cd104baeffe/sgmllib.py
test()
test()
def test(): file = 'test.html' f = open(file, 'r') x = TestSGML() while 1: line = f.readline() if not line: x.close() break x.feed(line)
48766512a0b438b66e97dfdfcb933cd104baeffe /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/48766512a0b438b66e97dfdfcb933cd104baeffe/sgmllib.py
inc_dir = get_python_inc(plat_specific=1)
if python_build: inc_dir = '.' else: inc_dir = get_python_inc(plat_specific=1)
def get_config_h_filename(): """Return full pathname of installed config.h file.""" inc_dir = get_python_inc(plat_specific=1) return os.path.join(inc_dir, "config.h")
c14fa303e109bd8dee7ef9c6a127fbd1fa1c5113 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/c14fa303e109bd8dee7ef9c6a127fbd1fa1c5113/sysconfig.py
scheme = urllib.splittype(url)
scheme, path = urllib.splittype(url)
def getpage(self, url_pair): # Incoming argument name is a (URL, fragment) pair. # The page may have been cached in the name_table variable. url, fragment = url_pair if self.name_table.has_key(url): return self.name_table[url]
566c0c737fc8f8029f8231b1c777da2dc0fdec40 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/566c0c737fc8f8029f8231b1c777da2dc0fdec40/webchecker.py
return self.inner(it, self.timer)
gcold = gc.isenabled() gc.disable() timing = self.inner(it, self.timer) if gcold: gc.enable() return timing
def timeit(self, number=default_number): """Time 'number' executions of the main statement.
816ed1b0bdd3f50375bef334a41e5f20d58910f9 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/816ed1b0bdd3f50375bef334a41e5f20d58910f9/timeit.py
assert "'" not in action cmd = "kfmclient '%s' >/dev/null 2>&1" % action
cmd = "kfmclient %s >/dev/null 2>&1" % action
def _remote(self, action): assert "'" not in action cmd = "kfmclient '%s' >/dev/null 2>&1" % action rc = os.system(cmd) if rc: import time if self.basename == "konqueror": os.system(self.name + " --silent &") else: os.system(self.name + " -d &") time.sleep(PROCESS_CREATION_DELAY) rc = os.system(cmd) return not rc
520cdf733aa8bfff48369822802a2df913851fcb /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/520cdf733aa8bfff48369822802a2df913851fcb/webbrowser.py
def get(self, key, default):
def get(self, key, default=None):
def get(self, key, default): try: ref = self.data[key] except KeyError: return default else: o = ref() if o is None: # This should only happen return default else: return o
1d9e4b7de3d15007d5b9e7ac4b38f5e158d3c840 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/1d9e4b7de3d15007d5b9e7ac4b38f5e158d3c840/weakref.py
L.append(key, ref(o, remove))
L.append((key, ref(o, remove)))
def remove(o, data=d, key=key): del data[key]
1d9e4b7de3d15007d5b9e7ac4b38f5e158d3c840 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/1d9e4b7de3d15007d5b9e7ac4b38f5e158d3c840/weakref.py
def get(self, key, default):
def get(self, key, default=None):
def get(self, key, default): return self.data.get(ref(key),default)
1d9e4b7de3d15007d5b9e7ac4b38f5e158d3c840 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/1d9e4b7de3d15007d5b9e7ac4b38f5e158d3c840/weakref.py
L.append(ref(key, self._remove), value)
L.append((ref(key, self._remove), value))
def update(self, dict): d = self.data L = [] for key, value in dict.items(): L.append(ref(key, self._remove), value) for key, r in L: d[key] = r
1d9e4b7de3d15007d5b9e7ac4b38f5e158d3c840 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/1d9e4b7de3d15007d5b9e7ac4b38f5e158d3c840/weakref.py
self._parsing = 0
def reset(self): if self._namespaces: self._parser = expat.ParserCreate(None, " ") self._parser.StartElementHandler = self.start_element_ns self._parser.EndElementHandler = self.end_element_ns else: self._parser = expat.ParserCreate() self._parser.StartElementHandler = self.start_element self._parser.EndElementHandler = self.end_element
3a361f4f8bbcac72edcb387cd431c28f42252008 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/3a361f4f8bbcac72edcb387cd431c28f42252008/expatreader.py
if nodelist[3][0] != symbol.except_clause: return self.com_try_finally(nodelist) return self.com_try_except(nodelist)
return self.com_try_except_finally(nodelist)
def try_stmt(self, nodelist): # 'try' ':' suite (except_clause ':' suite)+ ['else' ':' suite] # | 'try' ':' suite 'finally' ':' suite if nodelist[3][0] != symbol.except_clause: return self.com_try_finally(nodelist)
ad29e637d882cb0daee2073a3fe9b9a7e6e8d776 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/ad29e637d882cb0daee2073a3fe9b9a7e6e8d776/transformer.py
def com_try_finally(self, nodelist): return TryFinally(self.com_node(nodelist[2]), self.com_node(nodelist[5]), lineno=nodelist[0][2]) def com_try_except(self, nodelist):
def com_try_except_finally(self, nodelist): if nodelist[3][0] == token.NAME: return TryFinally(self.com_node(nodelist[2]), self.com_node(nodelist[5]), lineno=nodelist[0][2])
def com_try_finally(self, nodelist): # try_fin_stmt: "try" ":" suite "finally" ":" suite return TryFinally(self.com_node(nodelist[2]), self.com_node(nodelist[5]), lineno=nodelist[0][2])
ad29e637d882cb0daee2073a3fe9b9a7e6e8d776 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/ad29e637d882cb0daee2073a3fe9b9a7e6e8d776/transformer.py
stmt = self.com_node(nodelist[2])
def com_try_except(self, nodelist): # try_except: 'try' ':' suite (except_clause ':' suite)* ['else' suite] #tryexcept: [TryNode, [except_clauses], elseNode)] stmt = self.com_node(nodelist[2]) clauses = [] elseNode = None for i in range(3, len(nodelist), 3): node = nodelist[i] if node[0] == symbol.except_clause: # except_clause: 'except' [expr [',' expr]] */ if len(node) > 2: expr1 = self.com_node(node[2]) if len(node) > 4: expr2 = self.com_assign(node[4], OP_ASSIGN) else: expr2 = None else: expr1 = expr2 = None clauses.append((expr1, expr2, self.com_node(nodelist[i+2])))
ad29e637d882cb0daee2073a3fe9b9a7e6e8d776 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/ad29e637d882cb0daee2073a3fe9b9a7e6e8d776/transformer.py
elseNode = self.com_node(nodelist[i+2]) return TryExcept(self.com_node(nodelist[2]), clauses, elseNode, lineno=nodelist[0][2])
if node[1] == 'else': elseNode = self.com_node(nodelist[i+2]) elif node[1] == 'finally': finallyNode = self.com_node(nodelist[i+2]) try_except = TryExcept(self.com_node(nodelist[2]), clauses, elseNode, lineno=nodelist[0][2]) if finallyNode: return TryFinally(try_except, finallyNode, lineno=nodelist[0][2]) else: return try_except
def com_try_except(self, nodelist): # try_except: 'try' ':' suite (except_clause ':' suite)* ['else' suite] #tryexcept: [TryNode, [except_clauses], elseNode)] stmt = self.com_node(nodelist[2]) clauses = [] elseNode = None for i in range(3, len(nodelist), 3): node = nodelist[i] if node[0] == symbol.except_clause: # except_clause: 'except' [expr [',' expr]] */ if len(node) > 2: expr1 = self.com_node(node[2]) if len(node) > 4: expr2 = self.com_assign(node[4], OP_ASSIGN) else: expr2 = None else: expr1 = expr2 = None clauses.append((expr1, expr2, self.com_node(nodelist[i+2])))
ad29e637d882cb0daee2073a3fe9b9a7e6e8d776 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/ad29e637d882cb0daee2073a3fe9b9a7e6e8d776/transformer.py
WalkTests
WalkTests, MakedirTests,
def test_main(): test_support.run_unittest( TemporaryFileTests, StatAttributeTests, EnvironTests, WalkTests )
b386f6a50993f49fb62180c5a1e2a562a97cb368 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/b386f6a50993f49fb62180c5a1e2a562a97cb368/test_os.py
self.assertRaises(TypeError, u'hello'.count, 42)
self.assertRaises(TypeError, u'hello'.title, 42)
def test_title(self): self.checkmethod('title', u' hello ', u' Hello ') self.checkmethod('title', u'Hello ', u'Hello ') self.checkmethod('title', u'hello ', u'Hello ') self.checkmethod('title', u"fOrMaT thIs aS titLe String", u'Format This As Title String') self.checkmethod('title', u"fOrMaT,thIs-aS*titLe;String", u'Format,This-As*Title;String') self.checkmethod('title', u"getInt", u'Getint')
74640247d40d192d9e672ebe5275a0bc510c6028 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/74640247d40d192d9e672ebe5275a0bc510c6028/test_unicode.py