rem
stringlengths 1
322k
| add
stringlengths 0
2.05M
| context
stringlengths 4
228k
| meta
stringlengths 156
215
|
---|---|---|---|
self.assertRaises(TypeError, setattr, X.x, "offset", 92) self.assertRaises(TypeError, setattr, X.x, "size", 92) | self.assertRaises(AttributeError, setattr, X.x, "offset", 92) self.assertRaises(AttributeError, setattr, X.x, "size", 92) | def test_fields(self): # test the offset and size attributes of Structure/Unoin fields. class X(Structure): _fields_ = [("x", c_int), ("y", c_char)] | ecc3e67b986a1eed404b528ccbc099049c149edb /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/ecc3e67b986a1eed404b528ccbc099049c149edb/test_structures.py |
Retrieves a list of addresses from a header, where each address is a tuple as returned by getaddr(). """ try: data = self[name] except KeyError: return [] a = AddrlistClass(data) | Retrieves a list of addresses from a header, where each address is a tuple as returned by getaddr(). Scans all named headers, so it works properly with multiple To: or Cc: headers for example. """ raw = [] for h in self.getallmatchingheaders(name): if h[0] in ' \t': raw.append(h) else: if raw: raw.append(', ') i = string.find(h, ':') if i > 0: addr = h[i+1:] raw.append(addr) alladdrs = string.join(raw, '') a = AddrlistClass(alladdrs) | def getaddrlist(self, name): """Get a list of addresses from a header. Retrieves a list of addresses from a header, where each address is a tuple as returned by getaddr(). """ # New, by Ben Escoto try: data = self[name] except KeyError: return [] a = AddrlistClass(data) return a.getaddrlist() | 8a578436f493251ae912bc1e1ef09abc38a10316 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/8a578436f493251ae912bc1e1ef09abc38a10316/rfc822.py |
self.CR = '\r' | self.CR = '\r\n' | def __init__(self, field): """Initialize a new instance. `field' is an unparsed address header field, containing one or more addresses. """ self.specials = '()<>@,:;.\"[]' self.pos = 0 self.LWS = ' \t' self.CR = '\r' self.atomends = self.specials + self.LWS + self.CR self.field = field self.commentlist = [] | 8a578436f493251ae912bc1e1ef09abc38a10316 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/8a578436f493251ae912bc1e1ef09abc38a10316/rfc822.py |
def __init__(self, field): """Initialize a new instance. `field' is an unparsed address header field, containing one or more addresses. """ self.specials = '()<>@,:;.\"[]' self.pos = 0 self.LWS = ' \t' self.CR = '\r' self.atomends = self.specials + self.LWS + self.CR self.field = field self.commentlist = [] | 8a578436f493251ae912bc1e1ef09abc38a10316 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/8a578436f493251ae912bc1e1ef09abc38a10316/rfc822.py |
||
def getdomain(self): """Get the complete domain name from an address.""" sdlist = [] while self.pos < len(self.field): if self.field[self.pos] in self.LWS: self.pos = self.pos + 1 elif self.field[self.pos] == '(': self.commentlist.append(self.getcomment()) elif self.field[self.pos] == '[': sdlist.append(self.getdomainliteral()) elif self.field[self.pos] == '.': self.pos = self.pos + 1 sdlist.append('.') elif self.field[self.pos] in self.atomends: break else: sdlist.append(self.getatom()) return string.join(sdlist, '') | 8a578436f493251ae912bc1e1ef09abc38a10316 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/8a578436f493251ae912bc1e1ef09abc38a10316/rfc822.py |
||
tests = [ GeneralModuleTests, BasicTCPTest ] | tests = [GeneralModuleTests, BasicTCPTest, TCPTimeoutTest, TestExceptions] | def test_main(): tests = [ GeneralModuleTests, BasicTCPTest ] if sys.platform != 'mac': tests.append(BasicUDPTest) tests.extend([ NonBlockingTCPTests, FileObjectClassTestCase, UnbufferedFileObjectClassTestCase, LineBufferedFileObjectClassTestCase, SmallBufferedFileObjectClassTestCase ]) test_support.run_unittest(*tests) | 11a35f545b39ebd09171869f9987dabd85f03254 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/11a35f545b39ebd09171869f9987dabd85f03254/test_socket.py |
tests.append(BasicUDPTest) | tests.extend([ BasicUDPTest, UDPTimeoutTest ]) | def test_main(): tests = [ GeneralModuleTests, BasicTCPTest ] if sys.platform != 'mac': tests.append(BasicUDPTest) tests.extend([ NonBlockingTCPTests, FileObjectClassTestCase, UnbufferedFileObjectClassTestCase, LineBufferedFileObjectClassTestCase, SmallBufferedFileObjectClassTestCase ]) test_support.run_unittest(*tests) | 11a35f545b39ebd09171869f9987dabd85f03254 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/11a35f545b39ebd09171869f9987dabd85f03254/test_socket.py |
def change_root (new_root, pathname): """Return 'pathname' with 'new_root' prepended. If 'pathname' is relative, this is equivalent to "os.path.join(new_root,pathname)". Otherwise, it requires making 'pathname' relative and then joining the two, which is tricky on DOS/Windows and Mac OS.""" if not abspath (pathname): return os.path.join (new_root, pathname) elif os.name == 'posix': return os.path.join (new_root, pathname[1:]) elif os.name == 'nt': (root_drive, root_path) = os.path.splitdrive (new_root) (drive, path) = os.path.splitdrive (pathname) raise RuntimeError, "I give up -- not sure how to do this on Windows" elif os.name == 'mac': raise RuntimeError, "no clue how to do this on Mac OS" else: raise DistutilsPlatformError, \ "nothing known about platform '%s'" % os.name | 4b46ef9a4f35c50eed2e0993058be0cfe71e0b3b /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/4b46ef9a4f35c50eed2e0993058be0cfe71e0b3b/util.py |
||
two, which is tricky on DOS/Windows and Mac OS.""" if not abspath (pathname): return os.path.join (new_root, pathname) elif os.name == 'posix': return os.path.join (new_root, pathname[1:]) | two, which is tricky on DOS/Windows and Mac OS. """ if os.name == 'posix': if not os.path.isabs (pathname): return os.path.join (new_root, pathname) else: return os.path.join (new_root, pathname[1:]) | def change_root (new_root, pathname): """Return 'pathname' with 'new_root' prepended. If 'pathname' is relative, this is equivalent to "os.path.join(new_root,pathname)". Otherwise, it requires making 'pathname' relative and then joining the two, which is tricky on DOS/Windows and Mac OS.""" if not abspath (pathname): return os.path.join (new_root, pathname) elif os.name == 'posix': return os.path.join (new_root, pathname[1:]) elif os.name == 'nt': (root_drive, root_path) = os.path.splitdrive (new_root) (drive, path) = os.path.splitdrive (pathname) raise RuntimeError, "I give up -- not sure how to do this on Windows" elif os.name == 'mac': raise RuntimeError, "no clue how to do this on Mac OS" else: raise DistutilsPlatformError, \ "nothing known about platform '%s'" % os.name | 4b46ef9a4f35c50eed2e0993058be0cfe71e0b3b /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/4b46ef9a4f35c50eed2e0993058be0cfe71e0b3b/util.py |
(root_drive, root_path) = os.path.splitdrive (new_root) | def change_root (new_root, pathname): """Return 'pathname' with 'new_root' prepended. If 'pathname' is relative, this is equivalent to "os.path.join(new_root,pathname)". Otherwise, it requires making 'pathname' relative and then joining the two, which is tricky on DOS/Windows and Mac OS.""" if not abspath (pathname): return os.path.join (new_root, pathname) elif os.name == 'posix': return os.path.join (new_root, pathname[1:]) elif os.name == 'nt': (root_drive, root_path) = os.path.splitdrive (new_root) (drive, path) = os.path.splitdrive (pathname) raise RuntimeError, "I give up -- not sure how to do this on Windows" elif os.name == 'mac': raise RuntimeError, "no clue how to do this on Mac OS" else: raise DistutilsPlatformError, \ "nothing known about platform '%s'" % os.name | 4b46ef9a4f35c50eed2e0993058be0cfe71e0b3b /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/4b46ef9a4f35c50eed2e0993058be0cfe71e0b3b/util.py |
|
raise RuntimeError, "I give up -- not sure how to do this on Windows" | if path[0] == '\\': path = path[1:] return os.path.join (new_root, path) | def change_root (new_root, pathname): """Return 'pathname' with 'new_root' prepended. If 'pathname' is relative, this is equivalent to "os.path.join(new_root,pathname)". Otherwise, it requires making 'pathname' relative and then joining the two, which is tricky on DOS/Windows and Mac OS.""" if not abspath (pathname): return os.path.join (new_root, pathname) elif os.name == 'posix': return os.path.join (new_root, pathname[1:]) elif os.name == 'nt': (root_drive, root_path) = os.path.splitdrive (new_root) (drive, path) = os.path.splitdrive (pathname) raise RuntimeError, "I give up -- not sure how to do this on Windows" elif os.name == 'mac': raise RuntimeError, "no clue how to do this on Mac OS" else: raise DistutilsPlatformError, \ "nothing known about platform '%s'" % os.name | 4b46ef9a4f35c50eed2e0993058be0cfe71e0b3b /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/4b46ef9a4f35c50eed2e0993058be0cfe71e0b3b/util.py |
mro_err_msg = """Cannot create class.The superclasses have conflicting inheritance trees which leave the method resolution order (MRO) undefined for bases """ | mro_err_msg = """Cannot create a consistent method resolution order (MRO) for bases """ | def consistency_with_epg(): if verbose: print "Testing consistentcy with EPG..." class Pane(object): pass class ScrollingMixin(object): pass class EditingMixin(object): pass class ScrollablePane(Pane,ScrollingMixin): pass class EditablePane(Pane,EditingMixin): pass class EditableScrollablePane(ScrollablePane,EditablePane): pass vereq(EditableScrollablePane.__mro__, (EditableScrollablePane, ScrollablePane, EditablePane, Pane, ScrollingMixin, EditingMixin, object)) | f394df47fd943d7067b5c3bedbf2c359d864923c /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/f394df47fd943d7067b5c3bedbf2c359d864923c/test_descr.py |
writer = _get_StringIO() self.writexml(writer, "", indent, newl) return writer.getvalue() | writer = _get_StringIO() self.writexml(writer, "", indent, newl) return writer.getvalue() | def toprettyxml(self, indent="\t", newl="\n"): # indent = the indentation string to prepend, per level # newl = the newline string to append writer = _get_StringIO() self.writexml(writer, "", indent, newl) return writer.getvalue() | cb67ea1d6e2dfb2680bba29144ef33fd2cc9a21a /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/cb67ea1d6e2dfb2680bba29144ef33fd2cc9a21a/minidom.py |
By default, the diff control lines (those with *** or ---) are | By default, the diff control lines (those with ---, +++, or @@) are | def unified_diff(a, b, fromfile='', tofile='', fromfiledate='', tofiledate='', n=3, lineterm='\n'): r""" Compare two sequences of lines; generate the delta as a unified diff. Unified diffs are a compact way of showing line changes and a few lines of context. The number of context lines is set by 'n' which defaults to three. By default, the diff control lines (those with *** or ---) are created with a trailing newline. This is helpful so that inputs created from file.readlines() result in diffs that are suitable for file.writelines() since both the inputs and outputs have trailing newlines. For inputs that do not have trailing newlines, set the lineterm argument to "" so that the output will be uniformly newline free. The unidiff format normally has a header for filenames and modification times. Any or all of these may be specified using strings for 'fromfile', 'tofile', 'fromfiledate', and 'tofiledate'. The modification times are normally expressed in the format returned by time.ctime(). Example: >>> for line in unified_diff('one two three four'.split(), ... 'zero one tree four'.split(), 'Original', 'Current', ... 'Sat Jan 26 23:30:50 1991', 'Fri Jun 06 10:20:52 2003', ... lineterm=''): ... print line --- Original Sat Jan 26 23:30:50 1991 +++ Current Fri Jun 06 10:20:52 2003 @@ -1,4 +1,4 @@ +zero one -two -three +tree four """ started = False for group in SequenceMatcher(None,a,b).get_grouped_opcodes(n): if not started: yield '--- %s %s%s' % (fromfile, fromfiledate, lineterm) yield '+++ %s %s%s' % (tofile, tofiledate, lineterm) started = True i1, i2, j1, j2 = group[0][1], group[-1][2], group[0][3], group[-1][4] yield "@@ -%d,%d +%d,%d @@%s" % (i1+1, i2-i1, j1+1, j2-j1, lineterm) for tag, i1, i2, j1, j2 in group: if tag == 'equal': for line in a[i1:i2]: yield ' ' + line continue if tag == 'replace' or tag == 'delete': for line in a[i1:i2]: yield '-' + line if tag == 'replace' or tag == 'insert': for line in b[j1:j2]: yield '+' + line | 0887c732e7d6e162b4b78004af8546b739c77ca7 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/0887c732e7d6e162b4b78004af8546b739c77ca7/difflib.py |
def search(self, charset, criteria): | def search(self, charset, *criteria): | def search(self, charset, criteria): """Search mailbox for matching messages. | 66d451397577a7710902b75104839afc7ca05b81 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/66d451397577a7710902b75104839afc7ca05b81/imaplib.py |
(typ, [data]) = <instance>.search(charset, criteria) | (typ, [data]) = <instance>.search(charset, criterium, ...) | def search(self, charset, criteria): """Search mailbox for matching messages. | 66d451397577a7710902b75104839afc7ca05b81 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/66d451397577a7710902b75104839afc7ca05b81/imaplib.py |
typ, dat = self._simple_command(name, charset, criteria) | typ, dat = apply(self._simple_command, (name, charset) + criteria) | def search(self, charset, criteria): """Search mailbox for matching messages. | 66d451397577a7710902b75104839afc7ca05b81 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/66d451397577a7710902b75104839afc7ca05b81/imaplib.py |
import getpass, sys host = '' if sys.argv[1:]: host = sys.argv[1] | import getopt, getpass, sys try: optlist, args = getopt.getopt(sys.argv[1:], 'd:') except getopt.error, val: pass for opt,val in optlist: if opt == '-d': Debug = int(val) if not args: args = ('',) host = args[0] | def print_log(): _mesg('last %d IMAP4 interactions:' % len(_cmd_log)) for secs,line in _cmd_log: _mesg(line, secs) | 66d451397577a7710902b75104839afc7ca05b81 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/66d451397577a7710902b75104839afc7ca05b81/imaplib.py |
('search', (None, '(TO zork)')), | ('search', (None, 'SUBJECT', 'test')), | def print_log(): _mesg('last %d IMAP4 interactions:' % len(_cmd_log)) for secs,line in _cmd_log: _mesg(line, secs) | 66d451397577a7710902b75104839afc7ca05b81 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/66d451397577a7710902b75104839afc7ca05b81/imaplib.py |
Debug = 5 M = IMAP4(host) _mesg('PROTOCOL_VERSION = %s' % M.PROTOCOL_VERSION) for cmd,args in test_seq1: run(cmd, args) for ml in run('list', ('/tmp/', 'yy%')): mo = re.match(r'.*"([^"]+)"$', ml) if mo: path = mo.group(1) else: path = string.split(ml)[-1] run('delete', (path,)) for cmd,args in test_seq2: dat = run(cmd, args) if (cmd,args) != ('uid', ('SEARCH', 'ALL')): continue uid = string.split(dat[-1]) if not uid: continue run('uid', ('FETCH', '%s' % uid[-1], '(FLAGS INTERNALDATE RFC822.SIZE RFC822.HEADER RFC822.TEXT)')) | try: M = IMAP4(host) _mesg('PROTOCOL_VERSION = %s' % M.PROTOCOL_VERSION) for cmd,args in test_seq1: run(cmd, args) for ml in run('list', ('/tmp/', 'yy%')): mo = re.match(r'.*"([^"]+)"$', ml) if mo: path = mo.group(1) else: path = string.split(ml)[-1] run('delete', (path,)) for cmd,args in test_seq2: dat = run(cmd, args) if (cmd,args) != ('uid', ('SEARCH', 'ALL')): continue uid = string.split(dat[-1]) if not uid: continue run('uid', ('FETCH', '%s' % uid[-1], '(FLAGS INTERNALDATE RFC822.SIZE RFC822.HEADER RFC822.TEXT)')) print '\nAll tests OK.' except: print '\nTests failed.' if not Debug: print ''' If you would like to see debugging output, try: %s -d5 ''' % sys.argv[0] raise | def run(cmd, args): _mesg('%s %s' % (cmd, args)) typ, dat = apply(eval('M.%s' % cmd), args) _mesg('%s => %s %s' % (cmd, typ, dat)) return dat | 66d451397577a7710902b75104839afc7ca05b81 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/66d451397577a7710902b75104839afc7ca05b81/imaplib.py |
def test_encoding_decoding(self): codecs = [('rot13', 'uryyb jbeyq'), ('base64', 'aGVsbG8gd29ybGQ=\n'), ('hex', '68656c6c6f20776f726c64'), ('uu', 'begin 666 <data>\n+:&5L;&\\@=V]R;&0 \n \nend\n')] for encoding, data in codecs: self.checkequal(data, 'hello world', 'encode', encoding) self.checkequal('hello world', data, 'decode', encoding) # zlib is optional, so we make the test optional too... try: import zlib except ImportError: pass else: data = 'x\x9c\xcbH\xcd\xc9\xc9W(\xcf/\xcaI\x01\x00\x1a\x0b\x04]' self.checkequal(data, 'hello world', 'encode', 'zlib') self.checkequal('hello world', data, 'decode', 'zlib') | 108f13751999f63c20fa9067f3fc0feb6a87718e /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/108f13751999f63c20fa9067f3fc0feb6a87718e/string_tests.py |
||
self.get_installer_filename())) | self.get_installer_filename(fullname))) | def run (self): if (sys.platform != "win32" and (self.distribution.has_ext_modules() or self.distribution.has_c_libraries())): raise DistutilsPlatformError \ ("distribution contains extensions and/or C libraries; " "must be compiled on a Windows 32 platform") | 24ff83d5f3f2afdfd22c1e5081ede2860a30ce0c /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/24ff83d5f3f2afdfd22c1e5081ede2860a30ce0c/bdist_wininst.py |
@bigmemtest(minsize=_2G // 2 + 2, memuse=8) | @bigmemtest(minsize=_2G // 2 + 2, memuse=24) | def basic_test_inplace_concat(self, size): l = [sys.stdout] * size l += l self.assertEquals(len(l), size * 2) self.failUnless(l[0] is l[-1]) self.failUnless(l[size - 1] is l[size + 1]) | 2574f5cd8bfa7d504706f1f481ede5748a64e9f3 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/2574f5cd8bfa7d504706f1f481ede5748a64e9f3/test_bigmem.py |
@bigmemtest(minsize=_2G + 2, memuse=8) | @bigmemtest(minsize=_2G + 2, memuse=24) | def test_inplace_concat_small(self, size): return self.basic_test_inplace_concat(size) | 2574f5cd8bfa7d504706f1f481ede5748a64e9f3 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/2574f5cd8bfa7d504706f1f481ede5748a64e9f3/test_bigmem.py |
(typ, [data]) = <instance>.search(charset, criterium, ...) | (typ, [data]) = <instance>.search(charset, criterion, ...) | def search(self, charset, *criteria): """Search mailbox for matching messages. | 3ae0f7a7cf8c7555a654542811509d4c17b49497 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/3ae0f7a7cf8c7555a654542811509d4c17b49497/imaplib.py |
for tagName in DESCRIPTOR_ELEMENTS: nodes = find_all_elements(doc, tagName) for node in nodes: rewrite_descriptor(doc, node) | sections = find_all_elements(doc, "section") for section in sections: find_and_fix_descriptors(doc, section) def find_and_fix_descriptors(doc, container): children = container.childNodes for child in children: if child.nodeType == xml.dom.core.ELEMENT: tagName = child.tagName if tagName in DESCRIPTOR_ELEMENTS: rewrite_descriptor(doc, child) elif tagName == "subsection": find_and_fix_descriptors(doc, child) | def fixup_descriptors(doc): for tagName in DESCRIPTOR_ELEMENTS: nodes = find_all_elements(doc, tagName) for node in nodes: rewrite_descriptor(doc, node) | 3a7ff998aca0301659bb906d3631a4e02326615d /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/3a7ff998aca0301659bb906d3631a4e02326615d/docfixer.py |
class Maildir: def __init__(self, dirname): import string self.dirname = dirname self.boxes = [] newdir = os.path.join(self.dirname, 'new') for file in os.listdir(newdir): if len(string.split(file, '.')) > 2: self.boxes.append(os.path.join(newdir, file)) curdir = os.path.join(self.dirname, 'cur') for file in os.listdir(curdir): if len(string.split(file, '.')) > 2: self.boxes.append(os.path.join(curdir, file)) def next(self): if not self.boxes: return None fn = self.boxes[0] del self.boxes[0] fp = open(os.path.join(self.dirname, fn)) return rfc822.Message(fp) | def next(self): if not self.boxes: return None fn = self.boxes[0] del self.boxes[0] fp = open(os.path.join(self.dirname, fn)) return rfc822.Message(fp) | 9a4d63730ed3d93a1f059bb10f546609e2290cfb /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/9a4d63730ed3d93a1f059bb10f546609e2290cfb/mailbox.py |
|
for key in 'MAIL', 'LOGNAME', 'USER': | for key in 'MAILDIR', 'MAIL', 'LOGNAME', 'USER': | def _test(): import time import sys import string import os args = sys.argv[1:] if not args: for key in 'MAIL', 'LOGNAME', 'USER': if os.environ.has_key(key): mbox = os.environ[key] break else: print "$MAIL, $LOGNAME nor $USER set -- who are you?" return else: mbox = args[0] if mbox[:1] == '+': mbox = os.environ['HOME'] + '/Mail/' + mbox[1:] elif not '/' in mbox: mbox = '/usr/mail/' + mbox if os.path.isdir(mbox): mb = MHMailbox(mbox) else: fp = open(mbox, 'r') mb = UnixMailbox(fp) msgs = [] while 1: msg = mb.next() if msg is None: break msgs.append(msg) msg.fp = None if len(args) > 1: num = string.atoi(args[1]) print 'Message %d body:'%num msg = msgs[num-1] msg.rewindbody() sys.stdout.write(msg.fp.read()) else: print 'Mailbox',mbox,'has',len(msgs),'messages:' for msg in msgs: f = msg.getheader('from') or "" s = msg.getheader('subject') or "" d = msg.getheader('date') or "" print '%20.20s %18.18s %-30.30s'%(f, d[5:], s) | 9a4d63730ed3d93a1f059bb10f546609e2290cfb /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/9a4d63730ed3d93a1f059bb10f546609e2290cfb/mailbox.py |
mb = MHMailbox(mbox) | if os.path.isdir(os.path.join(mbox, 'cur')): mb = Maildir(mbox) else: mb = MHMailbox(mbox) | def _test(): import time import sys import string import os args = sys.argv[1:] if not args: for key in 'MAIL', 'LOGNAME', 'USER': if os.environ.has_key(key): mbox = os.environ[key] break else: print "$MAIL, $LOGNAME nor $USER set -- who are you?" return else: mbox = args[0] if mbox[:1] == '+': mbox = os.environ['HOME'] + '/Mail/' + mbox[1:] elif not '/' in mbox: mbox = '/usr/mail/' + mbox if os.path.isdir(mbox): mb = MHMailbox(mbox) else: fp = open(mbox, 'r') mb = UnixMailbox(fp) msgs = [] while 1: msg = mb.next() if msg is None: break msgs.append(msg) msg.fp = None if len(args) > 1: num = string.atoi(args[1]) print 'Message %d body:'%num msg = msgs[num-1] msg.rewindbody() sys.stdout.write(msg.fp.read()) else: print 'Mailbox',mbox,'has',len(msgs),'messages:' for msg in msgs: f = msg.getheader('from') or "" s = msg.getheader('subject') or "" d = msg.getheader('date') or "" print '%20.20s %18.18s %-30.30s'%(f, d[5:], s) | 9a4d63730ed3d93a1f059bb10f546609e2290cfb /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/9a4d63730ed3d93a1f059bb10f546609e2290cfb/mailbox.py |
def main(): | def findtemplate(): """Locate the applet template along sys.path""" | def main(): # Find the template # (there's no point in proceeding if we can't find it) for p in sys.path: template = os.path.join(p, TEMPLATE) try: template, d1, d2 = macfs.ResolveAliasFile(template) break except (macfs.error, ValueError): continue else: die("Template %s not found on sys.path" % `TEMPLATE`) return template = template.as_pathname() print 'Using template', template # Ask for source text if not specified in sys.argv[1:] if not sys.argv[1:]: srcfss, ok = macfs.PromptGetFile('Select Python source file:', 'TEXT') if not ok: return filename = srcfss.as_pathname() tp, tf = os.path.split(filename) if tf[-3:] == '.py': tf = tf[:-3] else: tf = tf + '.applet' dstfss, ok = macfs.StandardPutFile('Save application as:', tf) if not ok: return process(template, filename, dstfss.as_pathname()) else: # Loop over all files to be processed for filename in sys.argv[1:]: process(template, filename, '') | 0f452fa557eaf41aa576f8644b0955efea8daaac /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/0f452fa557eaf41aa576f8644b0955efea8daaac/BuildApplet.py |
print "Processing", `filename`, "..." | if DEBUG: print "Processing", `filename`, "..." | def process(template, filename, output): print "Processing", `filename`, "..." # Read the source and compile it # (there's no point overwriting the destination if it has a syntax error) fp = open(filename) text = fp.read() fp.close() try: code = compile(text, filename, "exec") except (SyntaxError, EOFError): die("Syntax error in script %s" % `filename`) return # Set the destination file name if string.lower(filename[-3:]) == ".py": destname = filename[:-3] rsrcname = destname + '.rsrc' else: destname = filename + ".applet" rsrcname = filename + '.rsrc' if output: destname = output # Copy the data from the template (creating the file as well) template_fss = macfs.FSSpec(template) template_fss, d1, d2 = macfs.ResolveAliasFile(template_fss) dest_fss = macfs.FSSpec(destname) tmpl = open(template, "rb") dest = open(destname, "wb") data = tmpl.read() if data: dest.write(data) dest.close() tmpl.close() # Copy the creator of the template to the destination # unless it already got one. Set type to APPL tctor, ttype = template_fss.GetCreatorType() ctor, type = dest_fss.GetCreatorType() if type in undefs: type = 'APPL' if ctor in undefs: ctor = tctor # Open the output resource fork try: output = FSpOpenResFile(dest_fss, WRITE) except MacOS.Error: print "Creating resource fork..." CreateResFile(destname) output = FSpOpenResFile(dest_fss, WRITE) # Copy the resources from the template input = FSpOpenResFile(template_fss, READ) newctor = copyres(input, output) CloseResFile(input) if newctor: ctor = newctor # Copy the resources from the target specific resource template, if any try: input = FSpOpenResFile(rsrcname, READ) except MacOS.Error: pass else: newctor = copyres(input, output) CloseResFile(input) if newctor: ctor = newctor # Now set the creator, type and bundle bit of the destination dest_finfo = dest_fss.GetFInfo() dest_finfo.Creator = ctor dest_finfo.Type = type dest_finfo.Flags = dest_finfo.Flags | MACFS.kHasBundle dest_finfo.Flags = dest_finfo.Flags & ~MACFS.kHasBeenInited dest_fss.SetFInfo(dest_finfo) # Make sure we're manipulating the output resource file now UseResFile(output) # Delete any existing 'PYC 'resource named __main__ try: res = Get1NamedResource(RESTYPE, RESNAME) res.RemoveResource() except Error: pass # Create the raw data for the resource from the code object data = marshal.dumps(code) del code data = (MAGIC + '\0\0\0\0') + data # Create the resource and write it id = 0 while id < 128: id = Unique1ID(RESTYPE) res = Resource(data) res.AddResource(RESTYPE, id, RESNAME) res.WriteResource() res.ReleaseResource() # Close the output file CloseResFile(output) # Give positive feedback message("Applet %s created." % `destname`) | 0f452fa557eaf41aa576f8644b0955efea8daaac /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/0f452fa557eaf41aa576f8644b0955efea8daaac/BuildApplet.py |
print "Creating resource fork..." | if DEBUG: print "Creating resource fork..." | def process(template, filename, output): print "Processing", `filename`, "..." # Read the source and compile it # (there's no point overwriting the destination if it has a syntax error) fp = open(filename) text = fp.read() fp.close() try: code = compile(text, filename, "exec") except (SyntaxError, EOFError): die("Syntax error in script %s" % `filename`) return # Set the destination file name if string.lower(filename[-3:]) == ".py": destname = filename[:-3] rsrcname = destname + '.rsrc' else: destname = filename + ".applet" rsrcname = filename + '.rsrc' if output: destname = output # Copy the data from the template (creating the file as well) template_fss = macfs.FSSpec(template) template_fss, d1, d2 = macfs.ResolveAliasFile(template_fss) dest_fss = macfs.FSSpec(destname) tmpl = open(template, "rb") dest = open(destname, "wb") data = tmpl.read() if data: dest.write(data) dest.close() tmpl.close() # Copy the creator of the template to the destination # unless it already got one. Set type to APPL tctor, ttype = template_fss.GetCreatorType() ctor, type = dest_fss.GetCreatorType() if type in undefs: type = 'APPL' if ctor in undefs: ctor = tctor # Open the output resource fork try: output = FSpOpenResFile(dest_fss, WRITE) except MacOS.Error: print "Creating resource fork..." CreateResFile(destname) output = FSpOpenResFile(dest_fss, WRITE) # Copy the resources from the template input = FSpOpenResFile(template_fss, READ) newctor = copyres(input, output) CloseResFile(input) if newctor: ctor = newctor # Copy the resources from the target specific resource template, if any try: input = FSpOpenResFile(rsrcname, READ) except MacOS.Error: pass else: newctor = copyres(input, output) CloseResFile(input) if newctor: ctor = newctor # Now set the creator, type and bundle bit of the destination dest_finfo = dest_fss.GetFInfo() dest_finfo.Creator = ctor dest_finfo.Type = type dest_finfo.Flags = dest_finfo.Flags | MACFS.kHasBundle dest_finfo.Flags = dest_finfo.Flags & ~MACFS.kHasBeenInited dest_fss.SetFInfo(dest_finfo) # Make sure we're manipulating the output resource file now UseResFile(output) # Delete any existing 'PYC 'resource named __main__ try: res = Get1NamedResource(RESTYPE, RESNAME) res.RemoveResource() except Error: pass # Create the raw data for the resource from the code object data = marshal.dumps(code) del code data = (MAGIC + '\0\0\0\0') + data # Create the resource and write it id = 0 while id < 128: id = Unique1ID(RESTYPE) res = Resource(data) res.AddResource(RESTYPE, id, RESNAME) res.WriteResource() res.ReleaseResource() # Close the output file CloseResFile(output) # Give positive feedback message("Applet %s created." % `destname`) | 0f452fa557eaf41aa576f8644b0955efea8daaac /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/0f452fa557eaf41aa576f8644b0955efea8daaac/BuildApplet.py |
except MacOS.Error: | except (MacOS.Error, ValueError): print 'No resource file', rsrcname | def process(template, filename, output): print "Processing", `filename`, "..." # Read the source and compile it # (there's no point overwriting the destination if it has a syntax error) fp = open(filename) text = fp.read() fp.close() try: code = compile(text, filename, "exec") except (SyntaxError, EOFError): die("Syntax error in script %s" % `filename`) return # Set the destination file name if string.lower(filename[-3:]) == ".py": destname = filename[:-3] rsrcname = destname + '.rsrc' else: destname = filename + ".applet" rsrcname = filename + '.rsrc' if output: destname = output # Copy the data from the template (creating the file as well) template_fss = macfs.FSSpec(template) template_fss, d1, d2 = macfs.ResolveAliasFile(template_fss) dest_fss = macfs.FSSpec(destname) tmpl = open(template, "rb") dest = open(destname, "wb") data = tmpl.read() if data: dest.write(data) dest.close() tmpl.close() # Copy the creator of the template to the destination # unless it already got one. Set type to APPL tctor, ttype = template_fss.GetCreatorType() ctor, type = dest_fss.GetCreatorType() if type in undefs: type = 'APPL' if ctor in undefs: ctor = tctor # Open the output resource fork try: output = FSpOpenResFile(dest_fss, WRITE) except MacOS.Error: print "Creating resource fork..." CreateResFile(destname) output = FSpOpenResFile(dest_fss, WRITE) # Copy the resources from the template input = FSpOpenResFile(template_fss, READ) newctor = copyres(input, output) CloseResFile(input) if newctor: ctor = newctor # Copy the resources from the target specific resource template, if any try: input = FSpOpenResFile(rsrcname, READ) except MacOS.Error: pass else: newctor = copyres(input, output) CloseResFile(input) if newctor: ctor = newctor # Now set the creator, type and bundle bit of the destination dest_finfo = dest_fss.GetFInfo() dest_finfo.Creator = ctor dest_finfo.Type = type dest_finfo.Flags = dest_finfo.Flags | MACFS.kHasBundle dest_finfo.Flags = dest_finfo.Flags & ~MACFS.kHasBeenInited dest_fss.SetFInfo(dest_finfo) # Make sure we're manipulating the output resource file now UseResFile(output) # Delete any existing 'PYC 'resource named __main__ try: res = Get1NamedResource(RESTYPE, RESNAME) res.RemoveResource() except Error: pass # Create the raw data for the resource from the code object data = marshal.dumps(code) del code data = (MAGIC + '\0\0\0\0') + data # Create the resource and write it id = 0 while id < 128: id = Unique1ID(RESTYPE) res = Resource(data) res.AddResource(RESTYPE, id, RESNAME) res.WriteResource() res.ReleaseResource() # Close the output file CloseResFile(output) # Give positive feedback message("Applet %s created." % `destname`) | 0f452fa557eaf41aa576f8644b0955efea8daaac /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/0f452fa557eaf41aa576f8644b0955efea8daaac/BuildApplet.py |
print id, type, name, size, hex(attrs) | if DEBUG: print id, type, name, size, hex(attrs) | def copyres(input, output): ctor = None UseResFile(input) ntypes = Count1Types() for itype in range(1, 1+ntypes): type = Get1IndType(itype) nresources = Count1Resources(type) for ires in range(1, 1+nresources): res = Get1IndResource(type, ires) id, type, name = res.GetResInfo() lcname = string.lower(name) if (type, lcname) == (RESTYPE, RESNAME): continue # Don't copy __main__ from template if lcname == OWNERNAME: ctor = type size = res.size attrs = res.GetResAttrs() print id, type, name, size, hex(attrs) res.LoadResource() res.DetachResource() UseResFile(output) try: res2 = Get1Resource(type, id) except MacOS.Error: res2 = None if res2: print "Overwriting..." res2.RemoveResource() res.AddResource(type, id, name) res.WriteResource() attrs = attrs | res.GetResAttrs() print "New attrs =", hex(attrs) res.SetResAttrs(attrs) UseResFile(input) return ctor | 0f452fa557eaf41aa576f8644b0955efea8daaac /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/0f452fa557eaf41aa576f8644b0955efea8daaac/BuildApplet.py |
print "Overwriting..." | if DEBUG: print "Overwriting..." | def copyres(input, output): ctor = None UseResFile(input) ntypes = Count1Types() for itype in range(1, 1+ntypes): type = Get1IndType(itype) nresources = Count1Resources(type) for ires in range(1, 1+nresources): res = Get1IndResource(type, ires) id, type, name = res.GetResInfo() lcname = string.lower(name) if (type, lcname) == (RESTYPE, RESNAME): continue # Don't copy __main__ from template if lcname == OWNERNAME: ctor = type size = res.size attrs = res.GetResAttrs() print id, type, name, size, hex(attrs) res.LoadResource() res.DetachResource() UseResFile(output) try: res2 = Get1Resource(type, id) except MacOS.Error: res2 = None if res2: print "Overwriting..." res2.RemoveResource() res.AddResource(type, id, name) res.WriteResource() attrs = attrs | res.GetResAttrs() print "New attrs =", hex(attrs) res.SetResAttrs(attrs) UseResFile(input) return ctor | 0f452fa557eaf41aa576f8644b0955efea8daaac /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/0f452fa557eaf41aa576f8644b0955efea8daaac/BuildApplet.py |
print "New attrs =", hex(attrs) | if DEBUG: print "New attrs =", hex(attrs) | def copyres(input, output): ctor = None UseResFile(input) ntypes = Count1Types() for itype in range(1, 1+ntypes): type = Get1IndType(itype) nresources = Count1Resources(type) for ires in range(1, 1+nresources): res = Get1IndResource(type, ires) id, type, name = res.GetResInfo() lcname = string.lower(name) if (type, lcname) == (RESTYPE, RESNAME): continue # Don't copy __main__ from template if lcname == OWNERNAME: ctor = type size = res.size attrs = res.GetResAttrs() print id, type, name, size, hex(attrs) res.LoadResource() res.DetachResource() UseResFile(output) try: res2 = Get1Resource(type, id) except MacOS.Error: res2 = None if res2: print "Overwriting..." res2.RemoveResource() res.AddResource(type, id, name) res.WriteResource() attrs = attrs | res.GetResAttrs() print "New attrs =", hex(attrs) res.SetResAttrs(attrs) UseResFile(input) return ctor | 0f452fa557eaf41aa576f8644b0955efea8daaac /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/0f452fa557eaf41aa576f8644b0955efea8daaac/BuildApplet.py |
TixWidget.__init__(self, master, 'tixDirList', ['options'], cnf, kw) self.subwidget_list['hlist'] = _dummyHList(self, 'hlist') self.subwidget_list['shlist'] = _dummyScrolledHList(self, 'vsb') | TixWidget.__init__(self, master, 'tixListNoteBook', ['options'], cnf, kw) self.subwidget_list['pane'] = _dummyPanedWindow(self, 'pane', destroy_physically=0) self.subwidget_list['hlist'] = _dummyHList(self, 'hlist') self.subwidget_list['shlist'] = _dummyScrolledHList(self, 'vsb') | def __init__(self, master, cnf={}, **kw): TixWidget.__init__(self, master, 'tixDirList', ['options'], cnf, kw) self.subwidget_list['hlist'] = _dummyHList(self, 'hlist') self.subwidget_list['shlist'] = _dummyScrolledHList(self, 'vsb') | 01824bf50c2967c264b0fb4a13d08bb5c1d9665c /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/01824bf50c2967c264b0fb4a13d08bb5c1d9665c/Tix.py |
if os.name == "posix" and os.path.basename(sys.path[-1]) == "Modules": | if (os.name == "posix" and sys.path and os.path.basename(sys.path[-1]) == "Modules"): | def makepath(*paths): dir = os.path.abspath(os.path.join(*paths)) return dir, os.path.normcase(dir) | 7ccd30fa438ff5518752b34cadb41dd1c12d6032 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/7ccd30fa438ff5518752b34cadb41dd1c12d6032/site.py |
__all__ = ["Random","seed","random","uniform","randint","choice", | __all__ = ["Random","seed","random","uniform","randint","choice","sample", | def create_generators(num, delta, firstseed=None): ""\"Return list of num distinct generators. Each generator has its own unique segment of delta elements from Random.random()'s full period. Seed the first generator with optional arg firstseed (default is None, to seed from current time). ""\" from random import Random g = Random(firstseed) result = [g] for i in range(num - 1): laststate = g.getstate() g = Random() g.setstate(laststate) g.jumpahead(delta) result.append(g) return result | f24eb35d185c0623315cfbd9977d37c509860dcf /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/f24eb35d185c0623315cfbd9977d37c509860dcf/random.py |
def _test(N=20000): | def _test_sample(n): population = xrange(n) for k in xrange(n+1): s = sample(population, k) assert len(dict([(elem,True) for elem in s])) == len(s) == k def _sample_generator(n, k): return sample(xrange(n), k)[k//2] def _test(N=2000): | def _test(N=20000): print 'TWOPI =', TWOPI print 'LOG4 =', LOG4 print 'NV_MAGICCONST =', NV_MAGICCONST print 'SG_MAGICCONST =', SG_MAGICCONST _test_generator(N, 'random()') _test_generator(N, 'normalvariate(0.0, 1.0)') _test_generator(N, 'lognormvariate(0.0, 1.0)') _test_generator(N, 'cunifvariate(0.0, 1.0)') _test_generator(N, 'expovariate(1.0)') _test_generator(N, 'vonmisesvariate(0.0, 1.0)') _test_generator(N, 'gammavariate(0.01, 1.0)') _test_generator(N, 'gammavariate(0.1, 1.0)') _test_generator(N, 'gammavariate(0.1, 2.0)') _test_generator(N, 'gammavariate(0.5, 1.0)') _test_generator(N, 'gammavariate(0.9, 1.0)') _test_generator(N, 'gammavariate(1.0, 1.0)') _test_generator(N, 'gammavariate(2.0, 1.0)') _test_generator(N, 'gammavariate(20.0, 1.0)') _test_generator(N, 'gammavariate(200.0, 1.0)') _test_generator(N, 'gauss(0.0, 1.0)') _test_generator(N, 'betavariate(3.0, 3.0)') _test_generator(N, 'paretovariate(1.0)') _test_generator(N, 'weibullvariate(1.0, 1.0)') # Test jumpahead. s = getstate() jumpahead(N) r1 = random() # now do it the slow way setstate(s) for i in range(N): random() r2 = random() if r1 != r2: raise ValueError("jumpahead test failed " + `(N, r1, r2)`) | f24eb35d185c0623315cfbd9977d37c509860dcf /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/f24eb35d185c0623315cfbd9977d37c509860dcf/random.py |
InteractiveInterpreter.__init__(self) | locals = sys.modules['__main__'].__dict__ InteractiveInterpreter.__init__(self, locals=locals) | def __init__(self, tkconsole): self.tkconsole = tkconsole InteractiveInterpreter.__init__(self) | eeb88076e7f4a89ce76d271379ca0aced0c2d6c7 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/eeb88076e7f4a89ce76d271379ca0aced0c2d6c7/PyShell.py |
filename = self.stuffsource(source) self.more = 0 return InteractiveInterpreter.runsource(self, source, filename) def stuffsource(self, source): | def runsource(self, source): # Extend base class to stuff the source in the line cache filename = "<pyshell#%d>" % self.gid self.gid = self.gid + 1 lines = string.split(source, "\n") linecache.cache[filename] = len(source)+1, 0, lines, filename self.more = 0 return InteractiveInterpreter.runsource(self, source, filename) | eeb88076e7f4a89ce76d271379ca0aced0c2d6c7 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/eeb88076e7f4a89ce76d271379ca0aced0c2d6c7/PyShell.py |
|
self.more = 0 return InteractiveInterpreter.runsource(self, source, filename) | return filename | def runsource(self, source): # Extend base class to stuff the source in the line cache filename = "<pyshell#%d>" % self.gid self.gid = self.gid + 1 lines = string.split(source, "\n") linecache.cache[filename] = len(source)+1, 0, lines, filename self.more = 0 return InteractiveInterpreter.runsource(self, source, filename) | eeb88076e7f4a89ce76d271379ca0aced0c2d6c7 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/eeb88076e7f4a89ce76d271379ca0aced0c2d6c7/PyShell.py |
if char in string.letters + string.digits + "_": | if char and char in string.letters + string.digits + "_": | def showsyntaxerror(self, filename=None): # Extend base class to color the offending position # (instead of printing it and pointing at it with a caret) text = self.tkconsole.text stuff = self.unpackerror() if not stuff: self.tkconsole.resetoutput() InteractiveInterpreter.showsyntaxerror(self, filename) return msg, lineno, offset, line = stuff if lineno == 1: pos = "iomark + %d chars" % (offset-1) else: pos = "iomark linestart + %d lines + %d chars" % (lineno-1, offset-1) text.tag_add("ERROR", pos) text.see(pos) char = text.get(pos) if char in string.letters + string.digits + "_": text.tag_add("ERROR", pos + " wordstart", pos) self.tkconsole.resetoutput() self.write("SyntaxError: %s\n" % str(msg)) | eeb88076e7f4a89ce76d271379ca0aced0c2d6c7 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/eeb88076e7f4a89ce76d271379ca0aced0c2d6c7/PyShell.py |
ok = type == SyntaxError | ok = type is SyntaxError | def unpackerror(self): type, value, tb = sys.exc_info() ok = type == SyntaxError if ok: try: msg, (dummy_filename, lineno, offset, line) = value except: ok = 0 if ok: return msg, lineno, offset, line else: return None | eeb88076e7f4a89ce76d271379ca0aced0c2d6c7 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/eeb88076e7f4a89ce76d271379ca0aced0c2d6c7/PyShell.py |
def toggle_debugger(self, event=None): if self.executing: tkMessageBox.showerror("Don't debug now", "You can only toggle the debugger when idle", master=self.text) self.set_debugger_indicator() return "break" else: db = self.interp.getdebugger() if db: self.close_debugger() else: self.open_debugger() | eeb88076e7f4a89ce76d271379ca0aced0c2d6c7 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/eeb88076e7f4a89ce76d271379ca0aced0c2d6c7/PyShell.py |
||
sys.stdout = sys.__stdout__ sys.stderr = sys.__stderr__ sys.stdin = sys.__stdin__ | sys.stdout = self.save_stdout sys.stderr = self.save_stderr sys.stdin = self.save_stdin | def close(self): # Extend base class method if self.executing: # XXX Need to ask a question here if not tkMessageBox.askokcancel( "Kill?", "The program is still running; do you want to kill it?", default="ok", master=self.text): return "cancel" self.canceled = 1 if self.reading: self.top.quit() return "cancel" reply = PyShellEditorWindow.close(self) if reply != "cancel": self.flist.pyshell = None # Restore std streams sys.stdout = sys.__stdout__ sys.stderr = sys.__stderr__ sys.stdin = sys.__stdin__ # Break cycles self.interp = None self.console = None return reply | eeb88076e7f4a89ce76d271379ca0aced0c2d6c7 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/eeb88076e7f4a89ce76d271379ca0aced0c2d6c7/PyShell.py |
return "Python Shell" | return self.shell_title | def short_title(self): return "Python Shell" | eeb88076e7f4a89ce76d271379ca0aced0c2d6c7 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/eeb88076e7f4a89ce76d271379ca0aced0c2d6c7/PyShell.py |
opts, args = getopt.getopt(sys.argv[1:], "d") | opts, args = getopt.getopt(sys.argv[1:], "c:deist:") | def main(): debug = 0 try: opts, args = getopt.getopt(sys.argv[1:], "d") except getopt.error, msg: sys.stderr.write("Error: %s\n" % str(msg)) sys.exit(2) for o, a in opts: if o == "-d": debug = 1 global flist, root root = Tk() fixwordbreaks(root) root.withdraw() flist = PyShellFileList(root) if args: for filename in sys.argv[1:]: flist.open(filename) aPath = os.path.abspath(os.path.dirname(filename)) if not aPath in sys.path: sys.path.insert(0, aPath) else: aPath = os.getcwd() if not aPath in sys.path: sys.path.insert(0, aPath) t = PyShell(flist) flist.pyshell = t t.begin() if debug: t.open_debugger() root.mainloop() | eeb88076e7f4a89ce76d271379ca0aced0c2d6c7 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/eeb88076e7f4a89ce76d271379ca0aced0c2d6c7/PyShell.py |
if o == "-d": | if o == '-c': cmd = a if o == '-d': | def main(): debug = 0 try: opts, args = getopt.getopt(sys.argv[1:], "d") except getopt.error, msg: sys.stderr.write("Error: %s\n" % str(msg)) sys.exit(2) for o, a in opts: if o == "-d": debug = 1 global flist, root root = Tk() fixwordbreaks(root) root.withdraw() flist = PyShellFileList(root) if args: for filename in sys.argv[1:]: flist.open(filename) aPath = os.path.abspath(os.path.dirname(filename)) if not aPath in sys.path: sys.path.insert(0, aPath) else: aPath = os.getcwd() if not aPath in sys.path: sys.path.insert(0, aPath) t = PyShell(flist) flist.pyshell = t t.begin() if debug: t.open_debugger() root.mainloop() | eeb88076e7f4a89ce76d271379ca0aced0c2d6c7 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/eeb88076e7f4a89ce76d271379ca0aced0c2d6c7/PyShell.py |
if args: for filename in sys.argv[1:]: | if edit: for filename in args: | def main(): debug = 0 try: opts, args = getopt.getopt(sys.argv[1:], "d") except getopt.error, msg: sys.stderr.write("Error: %s\n" % str(msg)) sys.exit(2) for o, a in opts: if o == "-d": debug = 1 global flist, root root = Tk() fixwordbreaks(root) root.withdraw() flist = PyShellFileList(root) if args: for filename in sys.argv[1:]: flist.open(filename) aPath = os.path.abspath(os.path.dirname(filename)) if not aPath in sys.path: sys.path.insert(0, aPath) else: aPath = os.getcwd() if not aPath in sys.path: sys.path.insert(0, aPath) t = PyShell(flist) flist.pyshell = t t.begin() if debug: t.open_debugger() root.mainloop() | eeb88076e7f4a89ce76d271379ca0aced0c2d6c7 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/eeb88076e7f4a89ce76d271379ca0aced0c2d6c7/PyShell.py |
aPath = os.path.abspath(os.path.dirname(filename)) if not aPath in sys.path: sys.path.insert(0, aPath) else: aPath = os.getcwd() if not aPath in sys.path: sys.path.insert(0, aPath) t = PyShell(flist) flist.pyshell = t t.begin() | shell = PyShell(flist) interp = shell.interp flist.pyshell = shell if startup: filename = os.environ.get("IDLESTARTUP") or \ os.environ.get("PYTHONSTARTUP") if filename and os.path.isfile(filename): interp.execfile(filename) | def main(): debug = 0 try: opts, args = getopt.getopt(sys.argv[1:], "d") except getopt.error, msg: sys.stderr.write("Error: %s\n" % str(msg)) sys.exit(2) for o, a in opts: if o == "-d": debug = 1 global flist, root root = Tk() fixwordbreaks(root) root.withdraw() flist = PyShellFileList(root) if args: for filename in sys.argv[1:]: flist.open(filename) aPath = os.path.abspath(os.path.dirname(filename)) if not aPath in sys.path: sys.path.insert(0, aPath) else: aPath = os.getcwd() if not aPath in sys.path: sys.path.insert(0, aPath) t = PyShell(flist) flist.pyshell = t t.begin() if debug: t.open_debugger() root.mainloop() | eeb88076e7f4a89ce76d271379ca0aced0c2d6c7 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/eeb88076e7f4a89ce76d271379ca0aced0c2d6c7/PyShell.py |
t.open_debugger() | shell.open_debugger() if cmd: interp.execsource(cmd) elif not edit and args and args[0] != "-": interp.execfile(args[0]) shell.begin() | def main(): debug = 0 try: opts, args = getopt.getopt(sys.argv[1:], "d") except getopt.error, msg: sys.stderr.write("Error: %s\n" % str(msg)) sys.exit(2) for o, a in opts: if o == "-d": debug = 1 global flist, root root = Tk() fixwordbreaks(root) root.withdraw() flist = PyShellFileList(root) if args: for filename in sys.argv[1:]: flist.open(filename) aPath = os.path.abspath(os.path.dirname(filename)) if not aPath in sys.path: sys.path.insert(0, aPath) else: aPath = os.getcwd() if not aPath in sys.path: sys.path.insert(0, aPath) t = PyShell(flist) flist.pyshell = t t.begin() if debug: t.open_debugger() root.mainloop() | eeb88076e7f4a89ce76d271379ca0aced0c2d6c7 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/eeb88076e7f4a89ce76d271379ca0aced0c2d6c7/PyShell.py |
if self._debugging > 1: print '*put*', `line` | def _putline(self, line): #if self._debugging > 1: print '*put*', `line` self.sock.send('%s%s' % (line, CRLF)) | a16433b14edc4d4c08c97262609a3e8821ff1f6e /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/a16433b14edc4d4c08c97262609a3e8821ff1f6e/poplib.py |
|
if self._debugging: print '*cmd*', `line` | def _putcmd(self, line): #if self._debugging: print '*cmd*', `line` self._putline(line) | a16433b14edc4d4c08c97262609a3e8821ff1f6e /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/a16433b14edc4d4c08c97262609a3e8821ff1f6e/poplib.py |
|
if self._debugging > 1: print '*get*', `line` | def _getline(self): line = self.file.readline() #if self._debugging > 1: print '*get*', `line` if not line: raise error_proto('-ERR EOF') octets = len(line) # server can send any combination of CR & LF # however, 'readline()' returns lines ending in LF # so only possibilities are ...LF, ...CRLF, CR...LF if line[-2:] == CRLF: return line[:-2], octets if line[0] == CR: return line[1:-1], octets return line[:-1], octets | a16433b14edc4d4c08c97262609a3e8821ff1f6e /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/a16433b14edc4d4c08c97262609a3e8821ff1f6e/poplib.py |
|
if self._debugging > 1: print '*resp*', `resp` | def _getresp(self): resp, o = self._getline() #if self._debugging > 1: print '*resp*', `resp` c = resp[:1] if c != '+': raise error_proto(resp) return resp | a16433b14edc4d4c08c97262609a3e8821ff1f6e /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/a16433b14edc4d4c08c97262609a3e8821ff1f6e/poplib.py |
|
if self._debugging: print '*stat*', `rets` | def stat(self): """Get mailbox status. | a16433b14edc4d4c08c97262609a3e8821ff1f6e /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/a16433b14edc4d4c08c97262609a3e8821ff1f6e/poplib.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 | 75ae7e7dfa49a3e1d094d3a4f1dc2782323f347d /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/75ae7e7dfa49a3e1d094d3a4f1dc2782323f347d/fpformat.py |
pardir_fsr = Carbon.File.FSRef(fss) | pardir_fsr = Carbon.File.FSRef(pardir_fss) | def AskFileForSave(**args): default_flags = 0x07 args, tpwanted = _process_Nav_args(args, _ALLOWED_KEYS, default_flags) try: rr = Nav.NavPutFile(args) good = 1 except Nav.error, arg: if arg[0] != -128: # userCancelledErr raise Nav.error, arg return None if not rr.validRecord or not rr.selection: return None if issubclass(tpwanted, Carbon.File.FSRef): raise TypeError, "Cannot pass wanted=FSRef to AskFileForSave" if issubclass(tpwanted, Carbon.File.FSSpec): return tpwanted(rr.selection[0]) if issubclass(tpwanted, (str, unicode)): # This is gross, and probably incorrect too vrefnum, dirid, name = rr.selection[0].as_tuple() pardir_fss = Carbon.File.FSSpec((vrefnum, dirid, '')) pardir_fsr = Carbon.File.FSRef(fss) pardir_path = pardir_fsr.FSRefMakePath() # This is utf-8 name_utf8 = unicode(name, 'macroman').encode('utf8') fullpath = os.path.join(pardir_path, name_utf8) if issubclass(tpwanted, unicode): return unicode(fullpath, 'utf8') return tpwanted(fullpath) raise TypeError, "Unknown value for argument 'wanted': %s" % repr(tpwanted) | e58962af4de4ff3a331be66c4413d1609de40633 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/e58962af4de4ff3a331be66c4413d1609de40633/EasyDialogs.py |
return struct.unpack('8', data)[0] | return struct.unpack('d', data)[0] | def unpack_double(self): # XXX i = self.pos self.pos = j = i+8 data = self.buf[i:j] if len(data) < 8: raise EOFError return struct.unpack('8', data)[0] | 5b8b8cd6c08d8efb62d26ee6ec878a792a71d16f /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/5b8b8cd6c08d8efb62d26ee6ec878a792a71d16f/xdr.py |
while nl < 0: | while (nl < 0 and size > 0): | def readline(self, size=-1): """Read a line with approx. size. If size is negative, read a whole line. readline() and read() must not be mixed up (!). """ if size < 0: size = sys.maxint | c11d6f13ae2f83702f7ed8a26618eb378918c881 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/c11d6f13ae2f83702f7ed8a26618eb378918c881/tarfile.py |
if size <= 0: break | def readline(self, size=-1): """Read a line with approx. size. If size is negative, read a whole line. readline() and read() must not be mixed up (!). """ if size < 0: size = sys.maxint | c11d6f13ae2f83702f7ed8a26618eb378918c881 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/c11d6f13ae2f83702f7ed8a26618eb378918c881/tarfile.py |
|
if os.environ.has_key("MSSdk") and self.find_exe("cl.exe"): | if os.environ.has_key("DISTUTILS_USE_SDK") and os.environ.has_key("MSSdk") and self.find_exe("cl.exe"): | def initialize(self): self.__paths = [] if os.environ.has_key("MSSdk") and self.find_exe("cl.exe"): # Assume that the SDK set up everything alright; don't try to be # smarter self.cc = "cl.exe" self.linker = "link.exe" self.lib = "lib.exe" self.rc = "rc.exe" self.mc = "mc.exe" else: self.__paths = self.get_msvc_paths("path") | 8d65681e947e7c95173e0944ec6ea0277e66d591 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/8d65681e947e7c95173e0944ec6ea0277e66d591/msvccompiler.py |
text = editwin.text text.bind("<<run-module>>", self.run_module) text.bind("<<run-script>>", self.run_script) text.bind("<<new-shell>>", self.new_shell) | self.flist = self.editwin.flist self.root = self.flist.root | def __init__(self, editwin): self.editwin = editwin text = editwin.text text.bind("<<run-module>>", self.run_module) text.bind("<<run-script>>", self.run_script) text.bind("<<new-shell>>", self.new_shell) | 9f4258490726c15a37484676177913a928b35783 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/9f4258490726c15a37484676177913a928b35783/ScriptBinding.py |
def run_module(self, event=None): | def run_module_event(self, event, debugger=None): if not self.editwin.get_saved(): tkMessageBox.showerror("Not saved", "Please save first!", master=self.editwin.text) self.editwin.text.focus_set() return | def run_module(self, event=None): filename = self.editwin.io.filename if not filename: tkMessageBox.showerror("No file name", "This window has no file name", master=self.editwin.text) return modname, ext = os.path.splitext(os.path.basename(filename)) try: mod = sys.modules[modname] except KeyError: mod = imp.new_module(modname) sys.modules[modname] = mod source = self.editwin.text.get("1.0", "end") exec source in mod.__dict__ | 9f4258490726c15a37484676177913a928b35783 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/9f4258490726c15a37484676177913a928b35783/ScriptBinding.py |
try: | if sys.modules.has_key(modname): | def run_module(self, event=None): filename = self.editwin.io.filename if not filename: tkMessageBox.showerror("No file name", "This window has no file name", master=self.editwin.text) return modname, ext = os.path.splitext(os.path.basename(filename)) try: mod = sys.modules[modname] except KeyError: mod = imp.new_module(modname) sys.modules[modname] = mod source = self.editwin.text.get("1.0", "end") exec source in mod.__dict__ | 9f4258490726c15a37484676177913a928b35783 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/9f4258490726c15a37484676177913a928b35783/ScriptBinding.py |
except KeyError: | else: | def run_module(self, event=None): filename = self.editwin.io.filename if not filename: tkMessageBox.showerror("No file name", "This window has no file name", master=self.editwin.text) return modname, ext = os.path.splitext(os.path.basename(filename)) try: mod = sys.modules[modname] except KeyError: mod = imp.new_module(modname) sys.modules[modname] = mod source = self.editwin.text.get("1.0", "end") exec source in mod.__dict__ | 9f4258490726c15a37484676177913a928b35783 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/9f4258490726c15a37484676177913a928b35783/ScriptBinding.py |
source = self.editwin.text.get("1.0", "end") exec source in mod.__dict__ | mod.__file__ = filename saveout = sys.stdout saveerr = sys.stderr owin = OnDemandOutputWindow(self.editwin.flist) try: sys.stderr = PseudoFile(owin, "stderr") try: sys.stdout = PseudoFile(owin, "stdout") try: if debugger: debugger.run("execfile(%s)" % `filename`, mod.__dict__) else: execfile(filename, mod.__dict__) except: (sys.last_type, sys.last_value, sys.last_traceback) = sys.exc_info() if not debugger: from StackViewer import StackBrowser sv = StackBrowser(self.root, self.flist) finally: sys.stdout = saveout finally: sys.stderr = saveerr | def run_module(self, event=None): filename = self.editwin.io.filename if not filename: tkMessageBox.showerror("No file name", "This window has no file name", master=self.editwin.text) return modname, ext = os.path.splitext(os.path.basename(filename)) try: mod = sys.modules[modname] except KeyError: mod = imp.new_module(modname) sys.modules[modname] = mod source = self.editwin.text.get("1.0", "end") exec source in mod.__dict__ | 9f4258490726c15a37484676177913a928b35783 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/9f4258490726c15a37484676177913a928b35783/ScriptBinding.py |
def run_script(self, event=None): | def debug_module_event(self, event): import Debugger debugger = Debugger.Debugger(self) self.run_module_event(event, debugger) def close_debugger(self): | def run_script(self, event=None): pass | 9f4258490726c15a37484676177913a928b35783 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/9f4258490726c15a37484676177913a928b35783/ScriptBinding.py |
def new_shell(self, event=None): import PyShell pyshell = PyShell.PyShell(self.editwin.flist) pyshell.begin() | def run_script(self, event=None): pass | 9f4258490726c15a37484676177913a928b35783 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/9f4258490726c15a37484676177913a928b35783/ScriptBinding.py |
|
args['compiler_so'] = compiler | (ccshared,) = sysconfig.get_config_vars('CCSHARED') args['compiler_so'] = compiler + ' ' + ccshared | def build_extensions(self): | 9eb27a89d8e37504a685651963c390bf8ebf78ca /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/9eb27a89d8e37504a685651963c390bf8ebf78ca/setup.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. ''' | 884554dfe54fe4015a1ca2c0624e247dce9312f5 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/884554dfe54fe4015a1ca2c0624e247dce9312f5/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. ''' | 884554dfe54fe4015a1ca2c0624e247dce9312f5 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/884554dfe54fe4015a1ca2c0624e247dce9312f5/test_commands.py |
def putrequest(self, method, url): | def putrequest(self, method, url, skip_host=0): | def putrequest(self, method, url): """Send a request to the server. | 3921ff675ec544f3738bcaf606cca745b9a508ea /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/3921ff675ec544f3738bcaf606cca745b9a508ea/httplib.py |
if url.startswith('http:'): nil, netloc, nil, nil, nil = urlsplit(url) self.putheader('Host', netloc) elif self.port == HTTP_PORT: self.putheader('Host', netloc) else: self.putheader('Host', "%s:%s" % (self.host, self.port)) | if not skip_host: netloc = '' if url.startswith('http'): nil, netloc, nil, nil, nil = urlsplit(url) if netloc: self.putheader('Host', netloc) elif self.port == HTTP_PORT: self.putheader('Host', self.host) else: self.putheader('Host', "%s:%s" % (self.host, self.port)) | def putrequest(self, method, url): """Send a request to the server. | 3921ff675ec544f3738bcaf606cca745b9a508ea /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/3921ff675ec544f3738bcaf606cca745b9a508ea/httplib.py |
self.putrequest(method, url) | if (headers.has_key('Host') or [k for k in headers.iterkeys() if k.lower() == "host"]): self.putrequest(method, url, skip_host=1) else: self.putrequest(method, url) | def _send_request(self, method, url, body, headers): self.putrequest(method, url) | 3921ff675ec544f3738bcaf606cca745b9a508ea /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/3921ff675ec544f3738bcaf606cca745b9a508ea/httplib.py |
while not is_all_white(line): | while lineno > 0 and not is_all_white(line): | def find_paragraph(text, mark): lineno, col = map(int, string.split(mark, ".")) line = text.get("%d.0" % lineno, "%d.0 lineend" % lineno) while is_all_white(line): lineno = lineno + 1 line = text.get("%d.0" % lineno, "%d.0 lineend" % lineno) first_lineno = lineno while not is_all_white(line): lineno = lineno + 1 line = text.get("%d.0" % lineno, "%d.0 lineend" % lineno) last = "%d.0" % lineno # Search back to beginning of paragraph lineno = first_lineno - 1 line = text.get("%d.0" % lineno, "%d.0 lineend" % lineno) while not is_all_white(line): lineno = lineno - 1 line = text.get("%d.0" % lineno, "%d.0 lineend" % lineno) first = "%d.0" % (lineno+1) return first, last, text.get(first, last) | e911c3e20cfa324e95f49d033cfe636543cce8cb /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/e911c3e20cfa324e95f49d033cfe636543cce8cb/FormatParagraph.py |
c = cmp(dict1, dict2) | if random.random() < 0.5: c = cmp(dict1, dict2) else: c = dict1 == dict2 | def test_one(n): global mutate, dict1, dict2, dict1keys, dict2keys # Fill the dicts without mutating them. mutate = 0 dict1keys = fill_dict(dict1, range(n), n) dict2keys = fill_dict(dict2, range(n), n) # Enable mutation, then compare the dicts so long as they have the # same size. mutate = 1 if verbose: print "trying w/ lengths", len(dict1), len(dict2), while dict1 and len(dict1) == len(dict2): if verbose: print ".", c = cmp(dict1, dict2) if verbose: print | a22975fb35e1bae0f85fc6ede1572264a7bcd1e6 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/a22975fb35e1bae0f85fc6ede1572264a7bcd1e6/test_mutants.py |
if netloc: | if netloc or (scheme in uses_netloc and url[:2] == '//'): | def urlunparse((scheme, netloc, url, params, query, fragment)): if netloc: if url[:1] != '/': url = '/' + url url = '//' + netloc + url if scheme: url = scheme + ':' + url if params: url = url + ';' + params if query: url = url + '?' + query if fragment: url = url + '#' + fragment return url | f3963b1269a9f4fde99724524a7afe81e974aa62 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/f3963b1269a9f4fde99724524a7afe81e974aa62/urlparse.py |
url = '//' + netloc + url | url = '//' + (netloc or '') + url | def urlunparse((scheme, netloc, url, params, query, fragment)): if netloc: if url[:1] != '/': url = '/' + url url = '//' + netloc + url if scheme: url = scheme + ':' + url if params: url = url + ';' + params if query: url = url + '?' + query if fragment: url = url + '#' + fragment return url | f3963b1269a9f4fde99724524a7afe81e974aa62 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/f3963b1269a9f4fde99724524a7afe81e974aa62/urlparse.py |
if self.re._num_regs == 1: return () return apply(self.group, tuple(range(1, self.re._num_regs) ) ) | result = [] for g in range(1, self.re._num_regs): if (self.regs[g][0] == -1) or (self.regs[g][1] == -1): result.append(None) else: result.append(self.string[self.regs[g][0]:self.regs[g][1]]) return tuple(result) | def groups(self): | 2b2b3f9bcb7d1cdf97b68f825489b5abfd42cf22 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/2b2b3f9bcb7d1cdf97b68f825489b5abfd42cf22/re.py |
proxies[protocol] = '%s://%s' % (protocol, address) | type, address = splittype(address) if not type: address = '%s://%s' % (protocol, address) proxies[protocol] = address | def getproxies_registry(): """Return a dictionary of scheme -> proxy server URL mappings. | b955d6c41e80806c8390dba47323ef7fc41f05aa /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/b955d6c41e80806c8390dba47323ef7fc41f05aa/urllib.py |
class ListTestCase(unittest.TestCase): | class BaseTestCase(unittest.TestCase): | def __index__(self): return self.ind | 314861c568d4bf10af1102823e23c9efe648fa0c /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/314861c568d4bf10af1102823e23c9efe648fa0c/test_index.py |
self.seq = [0,10,20,30,40,50] | def setUp(self): self.seq = [0,10,20,30,40,50] self.o = oldstyle() self.n = newstyle() self.o2 = oldstyle() self.n2 = newstyle() | 314861c568d4bf10af1102823e23c9efe648fa0c /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/314861c568d4bf10af1102823e23c9efe648fa0c/test_index.py |
|
def test_basic(self): self.o.ind = -2 self.n.ind = 2 assert(self.seq[self.n] == 20) assert(self.seq[self.o] == 40) assert(operator.index(self.o) == -2) assert(operator.index(self.n) == 2) def test_error(self): self.o.ind = 'dumb' self.n.ind = 'bad' myfunc = lambda x, obj: obj.seq[x] self.failUnlessRaises(TypeError, operator.index, self.o) self.failUnlessRaises(TypeError, operator.index, self.n) self.failUnlessRaises(TypeError, myfunc, self.o, self) self.failUnlessRaises(TypeError, myfunc, self.n, self) def test_slice(self): self.o.ind = 1 self.o2.ind = 3 self.n.ind = 2 self.n2.ind = 4 assert(self.seq[self.o:self.o2] == self.seq[1:3]) assert(self.seq[self.n:self.n2] == self.seq[2:4]) class TupleTestCase(unittest.TestCase): def setUp(self): self.seq = (0,10,20,30,40,50) self.o = oldstyle() self.n = newstyle() self.o2 = oldstyle() self.n2 = newstyle() def test_basic(self): self.o.ind = -2 self.n.ind = 2 assert(self.seq[self.n] == 20) assert(self.seq[self.o] == 40) assert(operator.index(self.o) == -2) assert(operator.index(self.n) == 2) def test_error(self): self.o.ind = 'dumb' self.n.ind = 'bad' myfunc = lambda x, obj: obj.seq[x] self.failUnlessRaises(TypeError, operator.index, self.o) self.failUnlessRaises(TypeError, operator.index, self.n) self.failUnlessRaises(TypeError, myfunc, self.o, self) self.failUnlessRaises(TypeError, myfunc, self.n, self) def test_slice(self): self.o.ind = 1 self.o2.ind = 3 self.n.ind = 2 self.n2.ind = 4 assert(self.seq[self.o:self.o2] == self.seq[1:3]) assert(self.seq[self.n:self.n2] == self.seq[2:4]) class StringTestCase(unittest.TestCase): def setUp(self): self.seq = "this is a test" self.o = oldstyle() self.n = newstyle() self.o2 = oldstyle() self.n2 = newstyle() | def setUp(self): self.seq = [0,10,20,30,40,50] self.o = oldstyle() self.n = newstyle() self.o2 = oldstyle() self.n2 = newstyle() | 314861c568d4bf10af1102823e23c9efe648fa0c /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/314861c568d4bf10af1102823e23c9efe648fa0c/test_index.py |
|
class UnicodeTestCase(unittest.TestCase): def setUp(self): self.seq = u"this is a test" self.o = oldstyle() self.n = newstyle() self.o2 = oldstyle() self.n2 = newstyle() | def test_wrappers(self): n = self.n n.ind = 5 assert n.__index__() == 5 assert 6 .__index__() == 6 assert -7L.__index__() == -7 assert self.seq.__getitem__(n) == self.seq[5] assert self.seq.__mul__(n) == self.seq * 5 assert self.seq.__rmul__(n) == self.seq * 5 def test_infinite_recusion(self): class Trap1(int): def __index__(self): return self class Trap2(long): def __index__(self): return self self.failUnlessRaises(TypeError, operator.getitem, self.seq, Trap1()) self.failUnlessRaises(TypeError, operator.getitem, self.seq, Trap2()) | def test_slice(self): self.o.ind = 1 self.o2.ind = 3 self.n.ind = 2 self.n2.ind = 4 assert(self.seq[self.o:self.o2] == self.seq[1:3]) assert(self.seq[self.n:self.n2] == self.seq[2:4]) | 314861c568d4bf10af1102823e23c9efe648fa0c /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/314861c568d4bf10af1102823e23c9efe648fa0c/test_index.py |
def test_basic(self): | class ListTestCase(BaseTestCase): seq = [0,10,20,30,40,50] def test_setdelitem(self): | def test_basic(self): self.o.ind = -2 self.n.ind = 2 assert(self.seq[self.n] == self.seq[2]) assert(self.seq[self.o] == self.seq[-2]) assert(operator.index(self.o) == -2) assert(operator.index(self.n) == 2) | 314861c568d4bf10af1102823e23c9efe648fa0c /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/314861c568d4bf10af1102823e23c9efe648fa0c/test_index.py |
assert(self.seq[self.n] == self.seq[2]) assert(self.seq[self.o] == self.seq[-2]) assert(operator.index(self.o) == -2) assert(operator.index(self.n) == 2) | lst = list('ab!cdefghi!j') del lst[self.o] del lst[self.n] lst[self.o] = 'X' lst[self.n] = 'Y' assert lst == list('abYdefghXj') | def test_basic(self): self.o.ind = -2 self.n.ind = 2 assert(self.seq[self.n] == self.seq[2]) assert(self.seq[self.o] == self.seq[-2]) assert(operator.index(self.o) == -2) assert(operator.index(self.n) == 2) | 314861c568d4bf10af1102823e23c9efe648fa0c /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/314861c568d4bf10af1102823e23c9efe648fa0c/test_index.py |
def test_error(self): self.o.ind = 'dumb' self.n.ind = 'bad' myfunc = lambda x, obj: obj.seq[x] self.failUnlessRaises(TypeError, operator.index, self.o) self.failUnlessRaises(TypeError, operator.index, self.n) self.failUnlessRaises(TypeError, myfunc, self.o, self) self.failUnlessRaises(TypeError, myfunc, self.n, self) | lst = [5, 6, 7, 8, 9, 10, 11] lst.__setitem__(self.n, "here") assert lst == [5, 6, "here", 8, 9, 10, 11] lst.__delitem__(self.n) assert lst == [5, 6, 8, 9, 10, 11] | def test_error(self): self.o.ind = 'dumb' self.n.ind = 'bad' myfunc = lambda x, obj: obj.seq[x] self.failUnlessRaises(TypeError, operator.index, self.o) self.failUnlessRaises(TypeError, operator.index, self.n) self.failUnlessRaises(TypeError, myfunc, self.o, self) self.failUnlessRaises(TypeError, myfunc, self.n, self) | 314861c568d4bf10af1102823e23c9efe648fa0c /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/314861c568d4bf10af1102823e23c9efe648fa0c/test_index.py |
def test_slice(self): self.o.ind = 1 self.o2.ind = 3 self.n.ind = 2 self.n2.ind = 4 assert(self.seq[self.o:self.o2] == self.seq[1:3]) assert(self.seq[self.n:self.n2] == self.seq[2:4]) | def test_inplace_repeat(self): self.o.ind = 2 self.n.ind = 3 lst = [6, 4] lst *= self.o assert lst == [6, 4, 6, 4] lst *= self.n assert lst == [6, 4, 6, 4] * 3 lst = [5, 6, 7, 8, 9, 11] l2 = lst.__imul__(self.n) assert l2 is lst assert lst == [5, 6, 7, 8, 9, 11] * 3 class TupleTestCase(BaseTestCase): seq = (0,10,20,30,40,50) class StringTestCase(BaseTestCase): seq = "this is a test" class UnicodeTestCase(BaseTestCase): seq = u"this is a test" class XRangeTestCase(unittest.TestCase): def test_xrange(self): n = newstyle() n.ind = 5 assert xrange(1, 20)[n] == 6 assert xrange(1, 20).__getitem__(n) == 6 | def test_slice(self): self.o.ind = 1 self.o2.ind = 3 self.n.ind = 2 self.n2.ind = 4 assert(self.seq[self.o:self.o2] == self.seq[1:3]) assert(self.seq[self.n:self.n2] == self.seq[2:4]) | 314861c568d4bf10af1102823e23c9efe648fa0c /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/314861c568d4bf10af1102823e23c9efe648fa0c/test_index.py |
UnicodeTestCase | UnicodeTestCase, XRangeTestCase, | def test_main(): test_support.run_unittest( ListTestCase, TupleTestCase, StringTestCase, UnicodeTestCase ) | 314861c568d4bf10af1102823e23c9efe648fa0c /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/314861c568d4bf10af1102823e23c9efe648fa0c/test_index.py |
result.append('\\') result.append(char) | if char == '\000': result.append(r'\000') else: result.append('\\' + char) else: result.append(char) | def escape(pattern): "Escape all non-alphanumeric characters in pattern." result = [] alphanum=string.letters+'_'+string.digits for char in pattern: if char not in alphanum: result.append('\\') result.append(char) return string.join(result, '') | b1908846af1c70e77917d56798daa8242d80d2b5 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/b1908846af1c70e77917d56798daa8242d80d2b5/re.py |
if startupinfo == None: startupinfo = STARTUPINFO() if not None in (p2cread, c2pwrite, errwrite): startupinfo.dwFlags |= STARTF_USESTDHANDLES startupinfo.hStdInput = p2cread startupinfo.hStdOutput = c2pwrite startupinfo.hStdError = errwrite | def _execute_child(self, args, executable, preexec_fn, close_fds, cwd, env, universal_newlines, startupinfo, creationflags, shell, p2cread, p2cwrite, c2pread, c2pwrite, errread, errwrite): """Execute program (MS Windows version)""" | c1d6536d60c39475895fb8691f81510393b9737b /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/c1d6536d60c39475895fb8691f81510393b9737b/subprocess.py |
|
oparg = ord(code[i]) + ord(code[i+1])*256 | oparg = ord(code[i]) + ord(code[i+1])*256 + extended_arg extended_arg = 0 | def disassemble(co, lasti=-1): """Disassemble a code object.""" code = co.co_code labels = findlabels(code) n = len(code) i = 0 while i < n: c = code[i] op = ord(c) if op == SET_LINENO and i > 0: print # Extra blank line if i == lasti: print '-->', else: print ' ', if i in labels: print '>>', else: print ' ', print string.rjust(`i`, 4), print string.ljust(opname[op], 20), i = i+1 if op >= HAVE_ARGUMENT: oparg = ord(code[i]) + ord(code[i+1])*256 i = i+2 print string.rjust(`oparg`, 5), if op in hasconst: print '(' + `co.co_consts[oparg]` + ')', elif op in hasname: print '(' + co.co_names[oparg] + ')', elif op in hasjrel: print '(to ' + `i + oparg` + ')', elif op in haslocal: print '(' + co.co_varnames[oparg] + ')', elif op in hascompare: print '(' + cmp_op[oparg] + ')', print | ef8ace3a6f6cf8396fa92ae62352e8a29ddfca1d /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/ef8ace3a6f6cf8396fa92ae62352e8a29ddfca1d/dis.py |
def main(tests=None, testdir=None, verbose=0, quiet=0, generate=0, exclude=0, single=0, randomize=0, fromfile=None, findleaks=0, use_resources=None): | def main(tests=None, testdir=None, verbose=0, quiet=False, generate=False, exclude=False, single=False, randomize=False, fromfile=None, findleaks=False, use_resources=None, trace=False): | def main(tests=None, testdir=None, verbose=0, quiet=0, generate=0, exclude=0, single=0, randomize=0, fromfile=None, findleaks=0, use_resources=None): """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 default arguments (verbose, quiet, generate, exclude, single, randomize, findleaks, and use_resources) allow programmers calling main() directly to set the values that would normally be set by flags on the command line. """ test_support.record_original_stdout(sys.stdout) try: opts, args = getopt.getopt(sys.argv[1:], 'hvgqxsrf:lu:t:', ['help', 'verbose', 'quiet', 'generate', 'exclude', 'single', 'random', 'fromfile', 'findleaks', 'use=', 'threshold=']) except getopt.error, msg: usage(2, msg) # Defaults if use_resources is None: use_resources = [] for o, a in opts: if o in ('-h', '--help'): usage(0) elif o in ('-v', '--verbose'): verbose += 1 elif o in ('-q', '--quiet'): quiet = 1; verbose = 0 elif o in ('-g', '--generate'): generate = 1 elif o in ('-x', '--exclude'): exclude = 1 elif o in ('-s', '--single'): single = 1 elif o in ('-r', '--randomize'): randomize = 1 elif o in ('-f', '--fromfile'): fromfile = a elif o in ('-l', '--findleaks'): findleaks = 1 elif o in ('-t', '--threshold'): import gc gc.set_threshold(int(a)) elif o in ('-u', '--use'): u = [x.lower() for x in a.split(',')] for r in u: if r == 'all': use_resources[:] = RESOURCE_NAMES continue remove = False if r[0] == '-': remove = True r = r[1:] if r not in RESOURCE_NAMES: usage(1, 'Invalid -u/--use option: ' + a) if remove: if r in use_resources: use_resources.remove(r) elif r not in use_resources: use_resources.append(r) if generate and verbose: usage(2, "-g and -v don't go together!") if single and fromfile: usage(2, "-s and -f don't go together!") good = [] bad = [] skipped = [] resource_denieds = [] if findleaks: try: import gc except ImportError: print 'No GC available, disabling findleaks.' findleaks = 0 else: # Uncomment the line below to report garbage that is not # freeable by reference counting alone. By default only # garbage that is not collectable by the GC is reported. #gc.set_debug(gc.DEBUG_SAVEALL) found_garbage = [] if single: from tempfile import gettempdir filename = os.path.join(gettempdir(), 'pynexttest') try: fp = open(filename, 'r') next = fp.read().strip() tests = [next] fp.close() except IOError: pass if fromfile: tests = [] fp = open(fromfile) for line in fp: guts = line.split() # assuming no test has whitespace in its name if guts and not guts[0].startswith('#'): tests.extend(guts) fp.close() # Strip .py extensions. if args: args = map(removepy, args) if tests: tests = map(removepy, tests) 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 test_support.use_resources = use_resources save_modules = sys.modules.keys() for test in tests: if not quiet: print test sys.stdout.flush() ok = runtest(test, generate, verbose, quiet, testdir) if ok > 0: good.append(test) elif ok == 0: bad.append(test) else: skipped.append(test) if ok == -2: resource_denieds.append(test) if findleaks: gc.collect() if gc.garbage: print "Warning: test created", len(gc.garbage), print "uncollectable object(s)." # move the uncollectable objects somewhere so we don't see # them again found_garbage.extend(gc.garbage) del gc.garbage[:] # 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) # The lists won't be sorted if running with -r good.sort() bad.sort() skipped.sort() if good and not quiet: if not bad and not skipped and len(good) > 1: print "All", print count(len(good), "test"), "OK." if verbose: print "CAUTION: stdout isn't compared in verbose mode:" print "a test that passes in verbose mode may fail without it." if bad: print count(len(bad), "test"), "failed:" printlist(bad) if skipped and not quiet: print count(len(skipped), "test"), "skipped:" printlist(skipped) e = _ExpectedSkips() plat = sys.platform if e.isvalid(): surprise = set(skipped) - e.getexpected() - set(resource_denieds) if surprise: print count(len(surprise), "skip"), \ "unexpected on", plat + ":" printlist(surprise) else: print "Those skips are all expected on", plat + "." else: print "Ask someone to teach regrtest.py about which tests are" print "expected to get skipped on", plat + "." 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) sys.exit(len(bad) > 0) | 3b6d025d9bc6a0109e9a2ebd28a4864e8007193a /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/3b6d025d9bc6a0109e9a2ebd28a4864e8007193a/regrtest.py |
The other default arguments (verbose, quiet, generate, exclude, single, randomize, findleaks, and use_resources) allow programmers calling main() directly to set the values that would normally be set by flags on the command line. | The other default arguments (verbose, quiet, generate, exclude, single, randomize, findleaks, use_resources, and trace) 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, fromfile=None, findleaks=0, use_resources=None): """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 default arguments (verbose, quiet, generate, exclude, single, randomize, findleaks, and use_resources) allow programmers calling main() directly to set the values that would normally be set by flags on the command line. """ test_support.record_original_stdout(sys.stdout) try: opts, args = getopt.getopt(sys.argv[1:], 'hvgqxsrf:lu:t:', ['help', 'verbose', 'quiet', 'generate', 'exclude', 'single', 'random', 'fromfile', 'findleaks', 'use=', 'threshold=']) except getopt.error, msg: usage(2, msg) # Defaults if use_resources is None: use_resources = [] for o, a in opts: if o in ('-h', '--help'): usage(0) elif o in ('-v', '--verbose'): verbose += 1 elif o in ('-q', '--quiet'): quiet = 1; verbose = 0 elif o in ('-g', '--generate'): generate = 1 elif o in ('-x', '--exclude'): exclude = 1 elif o in ('-s', '--single'): single = 1 elif o in ('-r', '--randomize'): randomize = 1 elif o in ('-f', '--fromfile'): fromfile = a elif o in ('-l', '--findleaks'): findleaks = 1 elif o in ('-t', '--threshold'): import gc gc.set_threshold(int(a)) elif o in ('-u', '--use'): u = [x.lower() for x in a.split(',')] for r in u: if r == 'all': use_resources[:] = RESOURCE_NAMES continue remove = False if r[0] == '-': remove = True r = r[1:] if r not in RESOURCE_NAMES: usage(1, 'Invalid -u/--use option: ' + a) if remove: if r in use_resources: use_resources.remove(r) elif r not in use_resources: use_resources.append(r) if generate and verbose: usage(2, "-g and -v don't go together!") if single and fromfile: usage(2, "-s and -f don't go together!") good = [] bad = [] skipped = [] resource_denieds = [] if findleaks: try: import gc except ImportError: print 'No GC available, disabling findleaks.' findleaks = 0 else: # Uncomment the line below to report garbage that is not # freeable by reference counting alone. By default only # garbage that is not collectable by the GC is reported. #gc.set_debug(gc.DEBUG_SAVEALL) found_garbage = [] if single: from tempfile import gettempdir filename = os.path.join(gettempdir(), 'pynexttest') try: fp = open(filename, 'r') next = fp.read().strip() tests = [next] fp.close() except IOError: pass if fromfile: tests = [] fp = open(fromfile) for line in fp: guts = line.split() # assuming no test has whitespace in its name if guts and not guts[0].startswith('#'): tests.extend(guts) fp.close() # Strip .py extensions. if args: args = map(removepy, args) if tests: tests = map(removepy, tests) 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 test_support.use_resources = use_resources save_modules = sys.modules.keys() for test in tests: if not quiet: print test sys.stdout.flush() ok = runtest(test, generate, verbose, quiet, testdir) if ok > 0: good.append(test) elif ok == 0: bad.append(test) else: skipped.append(test) if ok == -2: resource_denieds.append(test) if findleaks: gc.collect() if gc.garbage: print "Warning: test created", len(gc.garbage), print "uncollectable object(s)." # move the uncollectable objects somewhere so we don't see # them again found_garbage.extend(gc.garbage) del gc.garbage[:] # 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) # The lists won't be sorted if running with -r good.sort() bad.sort() skipped.sort() if good and not quiet: if not bad and not skipped and len(good) > 1: print "All", print count(len(good), "test"), "OK." if verbose: print "CAUTION: stdout isn't compared in verbose mode:" print "a test that passes in verbose mode may fail without it." if bad: print count(len(bad), "test"), "failed:" printlist(bad) if skipped and not quiet: print count(len(skipped), "test"), "skipped:" printlist(skipped) e = _ExpectedSkips() plat = sys.platform if e.isvalid(): surprise = set(skipped) - e.getexpected() - set(resource_denieds) if surprise: print count(len(surprise), "skip"), \ "unexpected on", plat + ":" printlist(surprise) else: print "Those skips are all expected on", plat + "." else: print "Ask someone to teach regrtest.py about which tests are" print "expected to get skipped on", plat + "." 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) sys.exit(len(bad) > 0) | 3b6d025d9bc6a0109e9a2ebd28a4864e8007193a /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/3b6d025d9bc6a0109e9a2ebd28a4864e8007193a/regrtest.py |
opts, args = getopt.getopt(sys.argv[1:], 'hvgqxsrf:lu:t:', | opts, args = getopt.getopt(sys.argv[1:], 'hvgqxsrf:lu:t:T', | def main(tests=None, testdir=None, verbose=0, quiet=0, generate=0, exclude=0, single=0, randomize=0, fromfile=None, findleaks=0, use_resources=None): """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 default arguments (verbose, quiet, generate, exclude, single, randomize, findleaks, and use_resources) allow programmers calling main() directly to set the values that would normally be set by flags on the command line. """ test_support.record_original_stdout(sys.stdout) try: opts, args = getopt.getopt(sys.argv[1:], 'hvgqxsrf:lu:t:', ['help', 'verbose', 'quiet', 'generate', 'exclude', 'single', 'random', 'fromfile', 'findleaks', 'use=', 'threshold=']) except getopt.error, msg: usage(2, msg) # Defaults if use_resources is None: use_resources = [] for o, a in opts: if o in ('-h', '--help'): usage(0) elif o in ('-v', '--verbose'): verbose += 1 elif o in ('-q', '--quiet'): quiet = 1; verbose = 0 elif o in ('-g', '--generate'): generate = 1 elif o in ('-x', '--exclude'): exclude = 1 elif o in ('-s', '--single'): single = 1 elif o in ('-r', '--randomize'): randomize = 1 elif o in ('-f', '--fromfile'): fromfile = a elif o in ('-l', '--findleaks'): findleaks = 1 elif o in ('-t', '--threshold'): import gc gc.set_threshold(int(a)) elif o in ('-u', '--use'): u = [x.lower() for x in a.split(',')] for r in u: if r == 'all': use_resources[:] = RESOURCE_NAMES continue remove = False if r[0] == '-': remove = True r = r[1:] if r not in RESOURCE_NAMES: usage(1, 'Invalid -u/--use option: ' + a) if remove: if r in use_resources: use_resources.remove(r) elif r not in use_resources: use_resources.append(r) if generate and verbose: usage(2, "-g and -v don't go together!") if single and fromfile: usage(2, "-s and -f don't go together!") good = [] bad = [] skipped = [] resource_denieds = [] if findleaks: try: import gc except ImportError: print 'No GC available, disabling findleaks.' findleaks = 0 else: # Uncomment the line below to report garbage that is not # freeable by reference counting alone. By default only # garbage that is not collectable by the GC is reported. #gc.set_debug(gc.DEBUG_SAVEALL) found_garbage = [] if single: from tempfile import gettempdir filename = os.path.join(gettempdir(), 'pynexttest') try: fp = open(filename, 'r') next = fp.read().strip() tests = [next] fp.close() except IOError: pass if fromfile: tests = [] fp = open(fromfile) for line in fp: guts = line.split() # assuming no test has whitespace in its name if guts and not guts[0].startswith('#'): tests.extend(guts) fp.close() # Strip .py extensions. if args: args = map(removepy, args) if tests: tests = map(removepy, tests) 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 test_support.use_resources = use_resources save_modules = sys.modules.keys() for test in tests: if not quiet: print test sys.stdout.flush() ok = runtest(test, generate, verbose, quiet, testdir) if ok > 0: good.append(test) elif ok == 0: bad.append(test) else: skipped.append(test) if ok == -2: resource_denieds.append(test) if findleaks: gc.collect() if gc.garbage: print "Warning: test created", len(gc.garbage), print "uncollectable object(s)." # move the uncollectable objects somewhere so we don't see # them again found_garbage.extend(gc.garbage) del gc.garbage[:] # 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) # The lists won't be sorted if running with -r good.sort() bad.sort() skipped.sort() if good and not quiet: if not bad and not skipped and len(good) > 1: print "All", print count(len(good), "test"), "OK." if verbose: print "CAUTION: stdout isn't compared in verbose mode:" print "a test that passes in verbose mode may fail without it." if bad: print count(len(bad), "test"), "failed:" printlist(bad) if skipped and not quiet: print count(len(skipped), "test"), "skipped:" printlist(skipped) e = _ExpectedSkips() plat = sys.platform if e.isvalid(): surprise = set(skipped) - e.getexpected() - set(resource_denieds) if surprise: print count(len(surprise), "skip"), \ "unexpected on", plat + ":" printlist(surprise) else: print "Those skips are all expected on", plat + "." else: print "Ask someone to teach regrtest.py about which tests are" print "expected to get skipped on", plat + "." 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) sys.exit(len(bad) > 0) | 3b6d025d9bc6a0109e9a2ebd28a4864e8007193a /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/3b6d025d9bc6a0109e9a2ebd28a4864e8007193a/regrtest.py |
'findleaks', 'use=', 'threshold=']) | 'findleaks', 'use=', 'threshold=', 'trace', ]) | def main(tests=None, testdir=None, verbose=0, quiet=0, generate=0, exclude=0, single=0, randomize=0, fromfile=None, findleaks=0, use_resources=None): """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 default arguments (verbose, quiet, generate, exclude, single, randomize, findleaks, and use_resources) allow programmers calling main() directly to set the values that would normally be set by flags on the command line. """ test_support.record_original_stdout(sys.stdout) try: opts, args = getopt.getopt(sys.argv[1:], 'hvgqxsrf:lu:t:', ['help', 'verbose', 'quiet', 'generate', 'exclude', 'single', 'random', 'fromfile', 'findleaks', 'use=', 'threshold=']) except getopt.error, msg: usage(2, msg) # Defaults if use_resources is None: use_resources = [] for o, a in opts: if o in ('-h', '--help'): usage(0) elif o in ('-v', '--verbose'): verbose += 1 elif o in ('-q', '--quiet'): quiet = 1; verbose = 0 elif o in ('-g', '--generate'): generate = 1 elif o in ('-x', '--exclude'): exclude = 1 elif o in ('-s', '--single'): single = 1 elif o in ('-r', '--randomize'): randomize = 1 elif o in ('-f', '--fromfile'): fromfile = a elif o in ('-l', '--findleaks'): findleaks = 1 elif o in ('-t', '--threshold'): import gc gc.set_threshold(int(a)) elif o in ('-u', '--use'): u = [x.lower() for x in a.split(',')] for r in u: if r == 'all': use_resources[:] = RESOURCE_NAMES continue remove = False if r[0] == '-': remove = True r = r[1:] if r not in RESOURCE_NAMES: usage(1, 'Invalid -u/--use option: ' + a) if remove: if r in use_resources: use_resources.remove(r) elif r not in use_resources: use_resources.append(r) if generate and verbose: usage(2, "-g and -v don't go together!") if single and fromfile: usage(2, "-s and -f don't go together!") good = [] bad = [] skipped = [] resource_denieds = [] if findleaks: try: import gc except ImportError: print 'No GC available, disabling findleaks.' findleaks = 0 else: # Uncomment the line below to report garbage that is not # freeable by reference counting alone. By default only # garbage that is not collectable by the GC is reported. #gc.set_debug(gc.DEBUG_SAVEALL) found_garbage = [] if single: from tempfile import gettempdir filename = os.path.join(gettempdir(), 'pynexttest') try: fp = open(filename, 'r') next = fp.read().strip() tests = [next] fp.close() except IOError: pass if fromfile: tests = [] fp = open(fromfile) for line in fp: guts = line.split() # assuming no test has whitespace in its name if guts and not guts[0].startswith('#'): tests.extend(guts) fp.close() # Strip .py extensions. if args: args = map(removepy, args) if tests: tests = map(removepy, tests) 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 test_support.use_resources = use_resources save_modules = sys.modules.keys() for test in tests: if not quiet: print test sys.stdout.flush() ok = runtest(test, generate, verbose, quiet, testdir) if ok > 0: good.append(test) elif ok == 0: bad.append(test) else: skipped.append(test) if ok == -2: resource_denieds.append(test) if findleaks: gc.collect() if gc.garbage: print "Warning: test created", len(gc.garbage), print "uncollectable object(s)." # move the uncollectable objects somewhere so we don't see # them again found_garbage.extend(gc.garbage) del gc.garbage[:] # 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) # The lists won't be sorted if running with -r good.sort() bad.sort() skipped.sort() if good and not quiet: if not bad and not skipped and len(good) > 1: print "All", print count(len(good), "test"), "OK." if verbose: print "CAUTION: stdout isn't compared in verbose mode:" print "a test that passes in verbose mode may fail without it." if bad: print count(len(bad), "test"), "failed:" printlist(bad) if skipped and not quiet: print count(len(skipped), "test"), "skipped:" printlist(skipped) e = _ExpectedSkips() plat = sys.platform if e.isvalid(): surprise = set(skipped) - e.getexpected() - set(resource_denieds) if surprise: print count(len(surprise), "skip"), \ "unexpected on", plat + ":" printlist(surprise) else: print "Those skips are all expected on", plat + "." else: print "Ask someone to teach regrtest.py about which tests are" print "expected to get skipped on", plat + "." 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) sys.exit(len(bad) > 0) | 3b6d025d9bc6a0109e9a2ebd28a4864e8007193a /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/3b6d025d9bc6a0109e9a2ebd28a4864e8007193a/regrtest.py |
quiet = 1; | quiet = True; | def main(tests=None, testdir=None, verbose=0, quiet=0, generate=0, exclude=0, single=0, randomize=0, fromfile=None, findleaks=0, use_resources=None): """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 default arguments (verbose, quiet, generate, exclude, single, randomize, findleaks, and use_resources) allow programmers calling main() directly to set the values that would normally be set by flags on the command line. """ test_support.record_original_stdout(sys.stdout) try: opts, args = getopt.getopt(sys.argv[1:], 'hvgqxsrf:lu:t:', ['help', 'verbose', 'quiet', 'generate', 'exclude', 'single', 'random', 'fromfile', 'findleaks', 'use=', 'threshold=']) except getopt.error, msg: usage(2, msg) # Defaults if use_resources is None: use_resources = [] for o, a in opts: if o in ('-h', '--help'): usage(0) elif o in ('-v', '--verbose'): verbose += 1 elif o in ('-q', '--quiet'): quiet = 1; verbose = 0 elif o in ('-g', '--generate'): generate = 1 elif o in ('-x', '--exclude'): exclude = 1 elif o in ('-s', '--single'): single = 1 elif o in ('-r', '--randomize'): randomize = 1 elif o in ('-f', '--fromfile'): fromfile = a elif o in ('-l', '--findleaks'): findleaks = 1 elif o in ('-t', '--threshold'): import gc gc.set_threshold(int(a)) elif o in ('-u', '--use'): u = [x.lower() for x in a.split(',')] for r in u: if r == 'all': use_resources[:] = RESOURCE_NAMES continue remove = False if r[0] == '-': remove = True r = r[1:] if r not in RESOURCE_NAMES: usage(1, 'Invalid -u/--use option: ' + a) if remove: if r in use_resources: use_resources.remove(r) elif r not in use_resources: use_resources.append(r) if generate and verbose: usage(2, "-g and -v don't go together!") if single and fromfile: usage(2, "-s and -f don't go together!") good = [] bad = [] skipped = [] resource_denieds = [] if findleaks: try: import gc except ImportError: print 'No GC available, disabling findleaks.' findleaks = 0 else: # Uncomment the line below to report garbage that is not # freeable by reference counting alone. By default only # garbage that is not collectable by the GC is reported. #gc.set_debug(gc.DEBUG_SAVEALL) found_garbage = [] if single: from tempfile import gettempdir filename = os.path.join(gettempdir(), 'pynexttest') try: fp = open(filename, 'r') next = fp.read().strip() tests = [next] fp.close() except IOError: pass if fromfile: tests = [] fp = open(fromfile) for line in fp: guts = line.split() # assuming no test has whitespace in its name if guts and not guts[0].startswith('#'): tests.extend(guts) fp.close() # Strip .py extensions. if args: args = map(removepy, args) if tests: tests = map(removepy, tests) 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 test_support.use_resources = use_resources save_modules = sys.modules.keys() for test in tests: if not quiet: print test sys.stdout.flush() ok = runtest(test, generate, verbose, quiet, testdir) if ok > 0: good.append(test) elif ok == 0: bad.append(test) else: skipped.append(test) if ok == -2: resource_denieds.append(test) if findleaks: gc.collect() if gc.garbage: print "Warning: test created", len(gc.garbage), print "uncollectable object(s)." # move the uncollectable objects somewhere so we don't see # them again found_garbage.extend(gc.garbage) del gc.garbage[:] # 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) # The lists won't be sorted if running with -r good.sort() bad.sort() skipped.sort() if good and not quiet: if not bad and not skipped and len(good) > 1: print "All", print count(len(good), "test"), "OK." if verbose: print "CAUTION: stdout isn't compared in verbose mode:" print "a test that passes in verbose mode may fail without it." if bad: print count(len(bad), "test"), "failed:" printlist(bad) if skipped and not quiet: print count(len(skipped), "test"), "skipped:" printlist(skipped) e = _ExpectedSkips() plat = sys.platform if e.isvalid(): surprise = set(skipped) - e.getexpected() - set(resource_denieds) if surprise: print count(len(surprise), "skip"), \ "unexpected on", plat + ":" printlist(surprise) else: print "Those skips are all expected on", plat + "." else: print "Ask someone to teach regrtest.py about which tests are" print "expected to get skipped on", plat + "." 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) sys.exit(len(bad) > 0) | 3b6d025d9bc6a0109e9a2ebd28a4864e8007193a /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/3b6d025d9bc6a0109e9a2ebd28a4864e8007193a/regrtest.py |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.