rem
stringlengths
1
322k
add
stringlengths
0
2.05M
context
stringlengths
4
228k
meta
stringlengths
156
215
line = "%s: %s\n" % (etype, _some_str(value))
line = "%s: %s\n" % (etype, valuestr)
def _format_final_exc_line(etype, value): """Return a list of a single line -- normal case for format_exception_only""" try: printable = value is None or not str(value) except: printable = False if printable: line = "%s\n" % etype else: line = "%s: %s\n" % (etype, _some_str(value)) return line
16183631ede0656a5cfd58626419cc081d281fff /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/16183631ede0656a5cfd58626419cc081d281fff/traceback.py
try: os.rename(self.baseFilename, dfn) except (KeyboardInterrupt, SystemExit): raise except: self.handleError(record)
os.rename(self.baseFilename, dfn)
def doRollover(self): """ Do a rollover, as described in __init__(). """
6dd59f1632fd174ffdd255acca4b596a69e1a5b4 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/6dd59f1632fd174ffdd255acca4b596a69e1a5b4/handlers.py
try: os.rename(self.baseFilename, dfn) except (KeyboardInterrupt, SystemExit): raise except: self.handleError(record)
os.rename(self.baseFilename, dfn)
def doRollover(self): """ do a rollover; in this case, a date/time stamp is appended to the filename when the rollover happens. However, you want the file to be named for the start of the interval, not the current time. If there is a backup count, then we have to get a list of matching filenames, sort them and remove the one with the oldest suffix. """ self.stream.close() # get the time that this sequence started at and make it a TimeTuple t = self.rolloverAt - self.interval timeTuple = time.localtime(t) dfn = self.baseFilename + "." + time.strftime(self.suffix, timeTuple) if os.path.exists(dfn): os.remove(dfn) try: os.rename(self.baseFilename, dfn) except (KeyboardInterrupt, SystemExit): raise except: self.handleError(record) if self.backupCount > 0: # find the oldest log file and delete it s = glob.glob(self.baseFilename + ".20*") if len(s) > self.backupCount: s.sort() os.remove(s[0]) #print "%s -> %s" % (self.baseFilename, dfn) if self.encoding: self.stream = codecs.open(self.baseFilename, 'w', self.encoding) else: self.stream = open(self.baseFilename, 'w') self.rolloverAt = self.rolloverAt + self.interval
6dd59f1632fd174ffdd255acca4b596a69e1a5b4 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/6dd59f1632fd174ffdd255acca4b596a69e1a5b4/handlers.py
d = dict(items={})
d = dict({})
def dict_constructor(): if verbose: print "Testing dict constructor ..." d = dict() vereq(d, {}) d = dict({}) vereq(d, {}) d = dict(items={}) vereq(d, {}) d = dict({1: 2, 'a': 'b'}) vereq(d, {1: 2, 'a': 'b'}) vereq(d, dict(d.items())) vereq(d, dict(items=d.iteritems())) for badarg in 0, 0L, 0j, "0", [0], (0,): try: dict(badarg) except TypeError: pass except ValueError: if badarg == "0": # It's a sequence, and its elements are also sequences (gotta # love strings <wink>), but they aren't of length 2, so this # one seemed better as a ValueError than a TypeError. pass else: raise TestFailed("no TypeError from dict(%r)" % badarg) else: raise TestFailed("no TypeError from dict(%r)" % badarg) try: dict(senseless={}) except TypeError: pass else: raise TestFailed("no TypeError from dict(senseless={})") try: dict({}, {}) except TypeError: pass else: raise TestFailed("no TypeError from dict({}, {})") class Mapping: # Lacks a .keys() method; will be added later. dict = {1:2, 3:4, 'a':1j} try: dict(Mapping()) except TypeError: pass else: raise TestFailed("no TypeError from dict(incomplete mapping)") Mapping.keys = lambda self: self.dict.keys() Mapping.__getitem__ = lambda self, i: self.dict[i] d = dict(items=Mapping()) vereq(d, Mapping.dict) # Init from sequence of iterable objects, each producing a 2-sequence. class AddressBookEntry: def __init__(self, first, last): self.first = first self.last = last def __iter__(self): return iter([self.first, self.last]) d = dict([AddressBookEntry('Tim', 'Warsaw'), AddressBookEntry('Barry', 'Peters'), AddressBookEntry('Tim', 'Peters'), AddressBookEntry('Barry', 'Warsaw')]) vereq(d, {'Barry': 'Warsaw', 'Tim': 'Peters'}) d = dict(zip(range(4), range(1, 5))) vereq(d, dict([(i, i+1) for i in range(4)])) # Bad sequence lengths. for bad in [('tooshort',)], [('too', 'long', 'by 1')]: try: dict(bad) except ValueError: pass else: raise TestFailed("no ValueError from dict(%r)" % bad)
a797d8150dd6fd8336653d8e91db3c088f2c53ff /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/a797d8150dd6fd8336653d8e91db3c088f2c53ff/test_descr.py
vereq(d, dict(items=d.iteritems()))
vereq(d, dict(d.iteritems())) d = dict({'one':1, 'two':2}) vereq(d, dict(one=1, two=2)) vereq(d, dict(**d)) vereq(d, dict({"one": 1}, two=2)) vereq(d, dict([("two", 2)], one=1)) vereq(d, dict([("one", 100), ("two", 200)], **d)) verify(d is not dict(**d))
def dict_constructor(): if verbose: print "Testing dict constructor ..." d = dict() vereq(d, {}) d = dict({}) vereq(d, {}) d = dict(items={}) vereq(d, {}) d = dict({1: 2, 'a': 'b'}) vereq(d, {1: 2, 'a': 'b'}) vereq(d, dict(d.items())) vereq(d, dict(items=d.iteritems())) for badarg in 0, 0L, 0j, "0", [0], (0,): try: dict(badarg) except TypeError: pass except ValueError: if badarg == "0": # It's a sequence, and its elements are also sequences (gotta # love strings <wink>), but they aren't of length 2, so this # one seemed better as a ValueError than a TypeError. pass else: raise TestFailed("no TypeError from dict(%r)" % badarg) else: raise TestFailed("no TypeError from dict(%r)" % badarg) try: dict(senseless={}) except TypeError: pass else: raise TestFailed("no TypeError from dict(senseless={})") try: dict({}, {}) except TypeError: pass else: raise TestFailed("no TypeError from dict({}, {})") class Mapping: # Lacks a .keys() method; will be added later. dict = {1:2, 3:4, 'a':1j} try: dict(Mapping()) except TypeError: pass else: raise TestFailed("no TypeError from dict(incomplete mapping)") Mapping.keys = lambda self: self.dict.keys() Mapping.__getitem__ = lambda self, i: self.dict[i] d = dict(items=Mapping()) vereq(d, Mapping.dict) # Init from sequence of iterable objects, each producing a 2-sequence. class AddressBookEntry: def __init__(self, first, last): self.first = first self.last = last def __iter__(self): return iter([self.first, self.last]) d = dict([AddressBookEntry('Tim', 'Warsaw'), AddressBookEntry('Barry', 'Peters'), AddressBookEntry('Tim', 'Peters'), AddressBookEntry('Barry', 'Warsaw')]) vereq(d, {'Barry': 'Warsaw', 'Tim': 'Peters'}) d = dict(zip(range(4), range(1, 5))) vereq(d, dict([(i, i+1) for i in range(4)])) # Bad sequence lengths. for bad in [('tooshort',)], [('too', 'long', 'by 1')]: try: dict(bad) except ValueError: pass else: raise TestFailed("no ValueError from dict(%r)" % bad)
a797d8150dd6fd8336653d8e91db3c088f2c53ff /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/a797d8150dd6fd8336653d8e91db3c088f2c53ff/test_descr.py
try: dict(senseless={}) except TypeError: pass else: raise TestFailed("no TypeError from dict(senseless={})")
def dict_constructor(): if verbose: print "Testing dict constructor ..." d = dict() vereq(d, {}) d = dict({}) vereq(d, {}) d = dict(items={}) vereq(d, {}) d = dict({1: 2, 'a': 'b'}) vereq(d, {1: 2, 'a': 'b'}) vereq(d, dict(d.items())) vereq(d, dict(items=d.iteritems())) for badarg in 0, 0L, 0j, "0", [0], (0,): try: dict(badarg) except TypeError: pass except ValueError: if badarg == "0": # It's a sequence, and its elements are also sequences (gotta # love strings <wink>), but they aren't of length 2, so this # one seemed better as a ValueError than a TypeError. pass else: raise TestFailed("no TypeError from dict(%r)" % badarg) else: raise TestFailed("no TypeError from dict(%r)" % badarg) try: dict(senseless={}) except TypeError: pass else: raise TestFailed("no TypeError from dict(senseless={})") try: dict({}, {}) except TypeError: pass else: raise TestFailed("no TypeError from dict({}, {})") class Mapping: # Lacks a .keys() method; will be added later. dict = {1:2, 3:4, 'a':1j} try: dict(Mapping()) except TypeError: pass else: raise TestFailed("no TypeError from dict(incomplete mapping)") Mapping.keys = lambda self: self.dict.keys() Mapping.__getitem__ = lambda self, i: self.dict[i] d = dict(items=Mapping()) vereq(d, Mapping.dict) # Init from sequence of iterable objects, each producing a 2-sequence. class AddressBookEntry: def __init__(self, first, last): self.first = first self.last = last def __iter__(self): return iter([self.first, self.last]) d = dict([AddressBookEntry('Tim', 'Warsaw'), AddressBookEntry('Barry', 'Peters'), AddressBookEntry('Tim', 'Peters'), AddressBookEntry('Barry', 'Warsaw')]) vereq(d, {'Barry': 'Warsaw', 'Tim': 'Peters'}) d = dict(zip(range(4), range(1, 5))) vereq(d, dict([(i, i+1) for i in range(4)])) # Bad sequence lengths. for bad in [('tooshort',)], [('too', 'long', 'by 1')]: try: dict(bad) except ValueError: pass else: raise TestFailed("no ValueError from dict(%r)" % bad)
a797d8150dd6fd8336653d8e91db3c088f2c53ff /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/a797d8150dd6fd8336653d8e91db3c088f2c53ff/test_descr.py
d = dict(items=Mapping())
d = dict(Mapping())
def dict_constructor(): if verbose: print "Testing dict constructor ..." d = dict() vereq(d, {}) d = dict({}) vereq(d, {}) d = dict(items={}) vereq(d, {}) d = dict({1: 2, 'a': 'b'}) vereq(d, {1: 2, 'a': 'b'}) vereq(d, dict(d.items())) vereq(d, dict(items=d.iteritems())) for badarg in 0, 0L, 0j, "0", [0], (0,): try: dict(badarg) except TypeError: pass except ValueError: if badarg == "0": # It's a sequence, and its elements are also sequences (gotta # love strings <wink>), but they aren't of length 2, so this # one seemed better as a ValueError than a TypeError. pass else: raise TestFailed("no TypeError from dict(%r)" % badarg) else: raise TestFailed("no TypeError from dict(%r)" % badarg) try: dict(senseless={}) except TypeError: pass else: raise TestFailed("no TypeError from dict(senseless={})") try: dict({}, {}) except TypeError: pass else: raise TestFailed("no TypeError from dict({}, {})") class Mapping: # Lacks a .keys() method; will be added later. dict = {1:2, 3:4, 'a':1j} try: dict(Mapping()) except TypeError: pass else: raise TestFailed("no TypeError from dict(incomplete mapping)") Mapping.keys = lambda self: self.dict.keys() Mapping.__getitem__ = lambda self, i: self.dict[i] d = dict(items=Mapping()) vereq(d, Mapping.dict) # Init from sequence of iterable objects, each producing a 2-sequence. class AddressBookEntry: def __init__(self, first, last): self.first = first self.last = last def __iter__(self): return iter([self.first, self.last]) d = dict([AddressBookEntry('Tim', 'Warsaw'), AddressBookEntry('Barry', 'Peters'), AddressBookEntry('Tim', 'Peters'), AddressBookEntry('Barry', 'Warsaw')]) vereq(d, {'Barry': 'Warsaw', 'Tim': 'Peters'}) d = dict(zip(range(4), range(1, 5))) vereq(d, dict([(i, i+1) for i in range(4)])) # Bad sequence lengths. for bad in [('tooshort',)], [('too', 'long', 'by 1')]: try: dict(bad) except ValueError: pass else: raise TestFailed("no ValueError from dict(%r)" % bad)
a797d8150dd6fd8336653d8e91db3c088f2c53ff /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/a797d8150dd6fd8336653d8e91db3c088f2c53ff/test_descr.py
vereq(dict(items={1: 2}), {1: 2})
def keywords(): if verbose: print "Testing keyword args to basic type constructors ..." vereq(int(x=1), 1) vereq(float(x=2), 2.0) vereq(long(x=3), 3L) vereq(complex(imag=42, real=666), complex(666, 42)) vereq(str(object=500), '500') vereq(unicode(string='abc', errors='strict'), u'abc') vereq(tuple(sequence=range(3)), (0, 1, 2)) vereq(list(sequence=(0, 1, 2)), range(3)) vereq(dict(items={1: 2}), {1: 2}) for constructor in (int, float, long, complex, str, unicode, tuple, list, dict, file): try: constructor(bogus_keyword_arg=1) except TypeError: pass else: raise TestFailed("expected TypeError from bogus keyword " "argument to %r" % constructor)
a797d8150dd6fd8336653d8e91db3c088f2c53ff /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/a797d8150dd6fd8336653d8e91db3c088f2c53ff/test_descr.py
tuple, list, dict, file):
tuple, list, file):
def keywords(): if verbose: print "Testing keyword args to basic type constructors ..." vereq(int(x=1), 1) vereq(float(x=2), 2.0) vereq(long(x=3), 3L) vereq(complex(imag=42, real=666), complex(666, 42)) vereq(str(object=500), '500') vereq(unicode(string='abc', errors='strict'), u'abc') vereq(tuple(sequence=range(3)), (0, 1, 2)) vereq(list(sequence=(0, 1, 2)), range(3)) vereq(dict(items={1: 2}), {1: 2}) for constructor in (int, float, long, complex, str, unicode, tuple, list, dict, file): try: constructor(bogus_keyword_arg=1) except TypeError: pass else: raise TestFailed("expected TypeError from bogus keyword " "argument to %r" % constructor)
a797d8150dd6fd8336653d8e91db3c088f2c53ff /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/a797d8150dd6fd8336653d8e91db3c088f2c53ff/test_descr.py
def doc(thing, title='Python Library Documentation: '):
def doc(thing, title='Python Library Documentation: %s'):
def doc(thing, title='Python Library Documentation: '): """Display text documentation, given an object or a path to an object.""" suffix, name = '', None if type(thing) is type(''): try: object = locate(thing) except ErrorDuringImport, value: print value return if not object: print 'no Python documentation found for %s' % repr(thing) return parts = split(thing, '.') if len(parts) > 1: suffix = ' in ' + join(parts[:-1], '.') name = parts[-1] thing = object desc = describe(thing) module = inspect.getmodule(thing) if not suffix and module and module is not thing: suffix = ' in module ' + module.__name__ pager(title + desc + suffix + '\n\n' + text.document(object, name))
662469619aff9e9ef8cc61fd4b529ed34806b3f1 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/662469619aff9e9ef8cc61fd4b529ed34806b3f1/pydoc.py
pager(title + desc + suffix + '\n\n' + text.document(object, name))
pager(title % (desc + suffix) + '\n\n' + text.document(thing, name))
def doc(thing, title='Python Library Documentation: '): """Display text documentation, given an object or a path to an object.""" suffix, name = '', None if type(thing) is type(''): try: object = locate(thing) except ErrorDuringImport, value: print value return if not object: print 'no Python documentation found for %s' % repr(thing) return parts = split(thing, '.') if len(parts) > 1: suffix = ' in ' + join(parts[:-1], '.') name = parts[-1] thing = object desc = describe(thing) module = inspect.getmodule(thing) if not suffix and module and module is not thing: suffix = ' in module ' + module.__name__ pager(title + desc + suffix + '\n\n' + text.document(object, name))
662469619aff9e9ef8cc61fd4b529ed34806b3f1 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/662469619aff9e9ef8cc61fd4b529ed34806b3f1/pydoc.py
def run(self, key, callback, completer=None): key = lower(key)
def run(self, callback, key=None, completer=None): if key: key = lower(key)
def run(self, key, callback, completer=None): key = lower(key) self.quit = 0 seen = {}
662469619aff9e9ef8cc61fd4b529ed34806b3f1 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/662469619aff9e9ef8cc61fd4b529ed34806b3f1/pydoc.py
desc = split(freshimport(modname).__doc__ or '', '\n')[0] if find(lower(modname + ' - ' + desc), key) >= 0: callback(None, modname, desc)
if key is None: callback(None, modname, '') else: desc = split(freshimport(modname).__doc__ or '', '\n')[0] if find(lower(modname + ' - ' + desc), key) >= 0: callback(None, modname, desc)
def run(self, key, callback, completer=None): key = lower(key) self.quit = 0 seen = {}
662469619aff9e9ef8cc61fd4b529ed34806b3f1 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/662469619aff9e9ef8cc61fd4b529ed34806b3f1/pydoc.py
if key:
if key is None: callback(path, modname, '') else:
def run(self, key, callback, completer=None): key = lower(key) self.quit = 0 seen = {}
662469619aff9e9ef8cc61fd4b529ed34806b3f1 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/662469619aff9e9ef8cc61fd4b529ed34806b3f1/pydoc.py
else: callback(path, modname, '')
def run(self, key, callback, completer=None): key = lower(key) self.quit = 0 seen = {}
662469619aff9e9ef8cc61fd4b529ed34806b3f1 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/662469619aff9e9ef8cc61fd4b529ed34806b3f1/pydoc.py
ModuleScanner().run(key, callback)
ModuleScanner().run(callback, key)
def callback(path, modname, desc): if modname[-9:] == '.__init__': modname = modname[:-9] + ' (package)' print modname, desc and '- ' + desc
662469619aff9e9ef8cc61fd4b529ed34806b3f1 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/662469619aff9e9ef8cc61fd4b529ed34806b3f1/pydoc.py
def serve(port, callback=None, finalizer=None):
def serve(port, callback=None, completer=None):
def serve(port, callback=None, finalizer=None): import BaseHTTPServer, SocketServer, mimetools, select # Patch up mimetools.Message so it doesn't break if rfc822 is reloaded. class Message(mimetools.Message): def __init__(self, fp, seekable=1): Message = self.__class__ Message.__bases__[0].__bases__[0].__init__(self, fp, seekable) self.encodingheader = self.getheader('content-transfer-encoding') self.typeheader = self.getheader('content-type') self.parsetype() self.parseplist() class DocHandler(BaseHTTPServer.BaseHTTPRequestHandler): def send_document(self, title, contents): try: self.send_response(200) self.send_header('Content-Type', 'text/html') self.end_headers() self.wfile.write(html.page(title, contents)) except IOError: pass def do_GET(self): path = self.path if path[-5:] == '.html': path = path[:-5] if path[:1] == '/': path = path[1:] if path and path != '.': try: obj = locate(path) except ErrorDuringImport, value: self.send_document(path, html.escape(str(value))) return if obj: self.send_document(describe(obj), html.document(obj, path)) else: self.send_document(path,
662469619aff9e9ef8cc61fd4b529ed34806b3f1 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/662469619aff9e9ef8cc61fd4b529ed34806b3f1/pydoc.py
if finalizer: finalizer()
if completer: completer()
def server_activate(self): self.base.server_activate(self) if self.callback: self.callback(self)
662469619aff9e9ef8cc61fd4b529ed34806b3f1 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/662469619aff9e9ef8cc61fd4b529ed34806b3f1/pydoc.py
self.prefix = sys.prefix
self.prefix = os.path.normpath (sys.prefix)
def set_final_options (self):
c27d80025134ee2ae92557af3b9d6c5496004c88 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/c27d80025134ee2ae92557af3b9d6c5496004c88/install.py
self.exec_prefix = sys.exec_prefix
self.exec_prefix = os.path.normpath (sys.exec_prefix)
def set_final_options (self):
c27d80025134ee2ae92557af3b9d6c5496004c88 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/c27d80025134ee2ae92557af3b9d6c5496004c88/install.py
sys_prefix = sys.exec_prefix
sys_prefix = os.path.normpath (sys.exec_prefix)
def replace_sys_prefix (self, config_attr, fallback_postfix, use_exec=0): """Attempts to glean a simple pattern from an installation directory available as a 'sysconfig' attribute: if the directory name starts with the "system prefix" (the one hard-coded in the Makefile and compiled into Python), then replace it with the current installation prefix and return the "relocated" installation directory."""
c27d80025134ee2ae92557af3b9d6c5496004c88 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/c27d80025134ee2ae92557af3b9d6c5496004c88/install.py
sys_prefix = sys.prefix
sys_prefix = os.path.normpath (sys.prefix)
def replace_sys_prefix (self, config_attr, fallback_postfix, use_exec=0): """Attempts to glean a simple pattern from an installation directory available as a 'sysconfig' attribute: if the directory name starts with the "system prefix" (the one hard-coded in the Makefile and compiled into Python), then replace it with the current installation prefix and return the "relocated" installation directory."""
c27d80025134ee2ae92557af3b9d6c5496004c88 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/c27d80025134ee2ae92557af3b9d6c5496004c88/install.py
except pickle.UnpicklingError:
except pickle.PicklingError:
def putmessage(self, message): self.debug("putmessage:%d:" % message[0]) try: s = pickle.dumps(message) except pickle.UnpicklingError: print >>sys.__stderr__, "Cannot pickle:", `message` raise s = struct.pack("<i", len(s)) + s while len(s) > 0: try: n = self.sock.send(s) except (AttributeError, socket.error): # socket was closed raise IOError else: s = s[n:]
d6ab77d27dae87d7ffb66db0a411a631ce85a11d /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/d6ab77d27dae87d7ffb66db0a411a631ce85a11d/rpc.py
n = self.sock.send(s)
r, w, x = select.select([], [self.sock], []) n = self.sock.send(s[:BUFSIZE])
def putmessage(self, message): self.debug("putmessage:%d:" % message[0]) try: s = pickle.dumps(message) except pickle.UnpicklingError: print >>sys.__stderr__, "Cannot pickle:", `message` raise s = struct.pack("<i", len(s)) + s while len(s) > 0: try: n = self.sock.send(s) except (AttributeError, socket.error): # socket was closed raise IOError else: s = s[n:]
d6ab77d27dae87d7ffb66db0a411a631ce85a11d /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/d6ab77d27dae87d7ffb66db0a411a631ce85a11d/rpc.py
def ioready(self, wait): r, w, x = select.select([self.sock.fileno()], [], [], wait) return len(r)
def ioready(self, wait): r, w, x = select.select([self.sock.fileno()], [], [], wait) return len(r)
d6ab77d27dae87d7ffb66db0a411a631ce85a11d /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/d6ab77d27dae87d7ffb66db0a411a631ce85a11d/rpc.py
if not self.ioready(wait):
r, w, x = select.select([self.sock.fileno()], [], [], wait) if len(r) == 0:
def pollpacket(self, wait): self._stage0() if len(self.buffer) < self.bufneed: if not self.ioready(wait): return None try: s = self.sock.recv(BUFSIZE) except socket.error: raise EOFError if len(s) == 0: raise EOFError self.buffer += s self._stage0() return self._stage1()
d6ab77d27dae87d7ffb66db0a411a631ce85a11d /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/d6ab77d27dae87d7ffb66db0a411a631ce85a11d/rpc.py
except:
except pickle.UnpicklingError:
def pollmessage(self, wait): packet = self.pollpacket(wait) if packet is None: return None try: message = pickle.loads(packet) except: print >>sys.__stderr__, "-----------------------" print >>sys.__stderr__, "cannot unpickle packet:", `packet` traceback.print_stack(file=sys.__stderr__) print >>sys.__stderr__, "-----------------------" raise return message
d6ab77d27dae87d7ffb66db0a411a631ce85a11d /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/d6ab77d27dae87d7ffb66db0a411a631ce85a11d/rpc.py
self.write(STOP) def dump_special(self, callable, args, state = None): if type(args) is not TupleType and args is not None: raise PicklingError, "Second argument to dump_special " \ "must be a tuple" self.save_reduce(callable, args, state)
def dump(self, object): self.save(object) self.write(STOP)
d370379186e1639ff43b245c54ed56dbdc8ab96c /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/d370379186e1639ff43b245c54ed56dbdc8ab96c/pickle.py
def save_float(self, object): self.write(FLOAT + `object` + '\n')
def save_float(self, object, pack=struct.pack): if self.bin: self.write(BINFLOAT + pack('>d', object)) else: self.write(FLOAT + `object` + '\n')
def save_float(self, object): self.write(FLOAT + `object` + '\n')
d370379186e1639ff43b245c54ed56dbdc8ab96c /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/d370379186e1639ff43b245c54ed56dbdc8ab96c/pickle.py
def test_05_no_pop_tops(self): self.run_test(no_pop_tops)
## def test_05_no_pop_tops(self):
4ffedadb1032a4310e756d476310d056ad209310 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/4ffedadb1032a4310e756d476310d056ad209310/test_trace.py
list.append('%s: %s\n' % (str(stype), str(value))) return list
list.append('%s: %s\n' % (str(stype), _some_str(value))) return list def _some_str(value): try: return str(value) except: return '<unprintable %s object>' % type(value).__name__
def format_exception_only(etype, value): """Format the exception part of a traceback. The arguments are the exception type and value such as given by sys.last_type and sys.last_value. The return value is a list of strings, each ending in a newline. Normally, the list contains a single string; however, for SyntaxError exceptions, it contains several lines that (when printed) display detailed information about where the syntax error occurred. The message indicating which exception occurred is the always last string in the list.""" list = [] if type(etype) == types.ClassType: stype = etype.__name__ else: stype = etype if value is None: list.append(str(stype) + '\n') else: if etype is SyntaxError: try: msg, (filename, lineno, offset, line) = value except: pass else: if not filename: filename = "<string>" list.append(' File "%s", line %d\n' % (filename, lineno)) i = 0 while i < len(line) and \ line[i] in string.whitespace: i = i+1 list.append(' %s\n' % string.strip(line)) s = ' ' for c in line[i:offset-1]: if c in string.whitespace: s = s + c else: s = s + ' ' list.append('%s^\n' % s) value = msg list.append('%s: %s\n' % (str(stype), str(value))) return list
2823f03a56451f3187a1d85ffcef107f00f6f48e /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/2823f03a56451f3187a1d85ffcef107f00f6f48e/traceback.py
up in the table self.extensions_map, using text/plain
up in the table self.extensions_map, using application/octet-stream
def guess_type(self, path): """Guess the type of a file.
b839c1f33f842720e9592c4ef598688bed94266f /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/b839c1f33f842720e9592c4ef598688bed94266f/SimpleHTTPServer.py
exts.append( Extension('MacOS', ['macosmodule.c']) ) exts.append( Extension('icglue', ['icgluemodule.c']) ) exts.append( Extension('macfs', ['macfsmodule.c', '../Python/getapplbycreator.c']) ) exts.append( Extension('_CF', ['cf/_CFmodule.c'], extra_link_args=['-framework', 'CoreFoundation']) ) exts.append( Extension('_Res', ['res/_Resmodule.c'] ) ) exts.append( Extension('_Snd', ['snd/_Sndmodule.c']) )
exts.append( Extension('MacOS', ['macosmodule.c'], extra_link_args=['-framework', 'Carbon']) ) exts.append( Extension('icglue', ['icgluemodule.c'], extra_link_args=['-framework', 'Carbon']) ) exts.append( Extension('macfs', ['macfsmodule.c', '../Python/getapplbycreator.c'], extra_link_args=['-framework', 'Carbon']) ) exts.append( Extension('_CF', ['cf/_CFmodule.c']) ) exts.append( Extension('_Res', ['res/_Resmodule.c']) ) exts.append( Extension('_Snd', ['snd/_Sndmodule.c'], extra_link_args=['-framework', 'Carbon']) )
def detect_modules(self): # Ensure that /usr/local is always used if '/usr/local/lib' not in self.compiler.library_dirs: self.compiler.library_dirs.insert(0, '/usr/local/lib') if '/usr/local/include' not in self.compiler.include_dirs: self.compiler.include_dirs.insert(0, '/usr/local/include' )
666b1e7e2f929af06fdfd074304a727f3dc5ed12 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/666b1e7e2f929af06fdfd074304a727f3dc5ed12/setup.py
exts.append( Extension('Nav', ['Nav.c']) ) exts.append( Extension('_AE', ['ae/_AEmodule.c']) ) exts.append( Extension('_App', ['app/_Appmodule.c']) ) exts.append( Extension('_Cm', ['cm/_Cmmodule.c']) ) exts.append( Extension('_Ctl', ['ctl/_Ctlmodule.c']) ) exts.append( Extension('_Dlg', ['dlg/_Dlgmodule.c']) ) exts.append( Extension('_Drag', ['drag/_Dragmodule.c']) ) exts.append( Extension('_Evt', ['evt/_Evtmodule.c']) ) exts.append( Extension('_Fm', ['fm/_Fmmodule.c']) ) exts.append( Extension('_Icn', ['icn/_Icnmodule.c']) ) exts.append( Extension('_List', ['list/_Listmodule.c']) ) exts.append( Extension('_Menu', ['menu/_Menumodule.c']) ) exts.append( Extension('_Mlte', ['mlte/_Mltemodule.c']) ) exts.append( Extension('_Qd', ['qd/_Qdmodule.c']) ) exts.append( Extension('_Qdoffs', ['qdoffs/_Qdoffsmodule.c']) )
exts.append( Extension('Nav', ['Nav.c'], extra_link_args=['-framework', 'Carbon']) ) exts.append( Extension('_AE', ['ae/_AEmodule.c'], extra_link_args=['-framework', 'Carbon']) ) exts.append( Extension('_App', ['app/_Appmodule.c'], extra_link_args=['-framework', 'Carbon']) ) exts.append( Extension('_Cm', ['cm/_Cmmodule.c'], extra_link_args=['-framework', 'Carbon']) ) exts.append( Extension('_Ctl', ['ctl/_Ctlmodule.c'], extra_link_args=['-framework', 'Carbon']) ) exts.append( Extension('_Dlg', ['dlg/_Dlgmodule.c'], extra_link_args=['-framework', 'Carbon']) ) exts.append( Extension('_Drag', ['drag/_Dragmodule.c'], extra_link_args=['-framework', 'Carbon']) ) exts.append( Extension('_Evt', ['evt/_Evtmodule.c'], extra_link_args=['-framework', 'Carbon']) ) exts.append( Extension('_Fm', ['fm/_Fmmodule.c'], extra_link_args=['-framework', 'Carbon']) ) exts.append( Extension('_Icn', ['icn/_Icnmodule.c'], extra_link_args=['-framework', 'Carbon']) ) exts.append( Extension('_List', ['list/_Listmodule.c'], extra_link_args=['-framework', 'Carbon']) ) exts.append( Extension('_Menu', ['menu/_Menumodule.c'], extra_link_args=['-framework', 'Carbon']) ) exts.append( Extension('_Mlte', ['mlte/_Mltemodule.c'], extra_link_args=['-framework', 'Carbon']) ) exts.append( Extension('_Qd', ['qd/_Qdmodule.c'], extra_link_args=['-framework', 'Carbon']) ) exts.append( Extension('_Qdoffs', ['qdoffs/_Qdoffsmodule.c'], extra_link_args=['-framework', 'Carbon']) )
def detect_modules(self): # Ensure that /usr/local is always used if '/usr/local/lib' not in self.compiler.library_dirs: self.compiler.library_dirs.insert(0, '/usr/local/lib') if '/usr/local/include' not in self.compiler.include_dirs: self.compiler.include_dirs.insert(0, '/usr/local/include' )
666b1e7e2f929af06fdfd074304a727f3dc5ed12 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/666b1e7e2f929af06fdfd074304a727f3dc5ed12/setup.py
extra_link_args=['-framework', 'QuickTime']) )
extra_link_args=['-framework', 'QuickTime', '-framework', 'Carbon']) )
def detect_modules(self): # Ensure that /usr/local is always used if '/usr/local/lib' not in self.compiler.library_dirs: self.compiler.library_dirs.insert(0, '/usr/local/lib') if '/usr/local/include' not in self.compiler.include_dirs: self.compiler.include_dirs.insert(0, '/usr/local/include' )
666b1e7e2f929af06fdfd074304a727f3dc5ed12 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/666b1e7e2f929af06fdfd074304a727f3dc5ed12/setup.py
exts.append( Extension('_TE', ['te/_TEmodule.c']) )
exts.append( Extension('_TE', ['te/_TEmodule.c'], extra_link_args=['-framework', 'Carbon']) )
def detect_modules(self): # Ensure that /usr/local is always used if '/usr/local/lib' not in self.compiler.library_dirs: self.compiler.library_dirs.insert(0, '/usr/local/lib') if '/usr/local/include' not in self.compiler.include_dirs: self.compiler.include_dirs.insert(0, '/usr/local/include' )
666b1e7e2f929af06fdfd074304a727f3dc5ed12 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/666b1e7e2f929af06fdfd074304a727f3dc5ed12/setup.py
exts.append( Extension('_Win', ['win/_Winmodule.c']) )
exts.append( Extension('_Win', ['win/_Winmodule.c'], extra_link_args=['-framework', 'Carbon']) )
def detect_modules(self): # Ensure that /usr/local is always used if '/usr/local/lib' not in self.compiler.library_dirs: self.compiler.library_dirs.insert(0, '/usr/local/lib') if '/usr/local/include' not in self.compiler.include_dirs: self.compiler.include_dirs.insert(0, '/usr/local/include' )
666b1e7e2f929af06fdfd074304a727f3dc5ed12 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/666b1e7e2f929af06fdfd074304a727f3dc5ed12/setup.py
if hex(-16) != '0xfffffff0': raise TestFailed, 'hex(-16)'
if len(hex(-1)) != len(hex(sys.maxint)): raise TestFailed, 'len(hex(-1))' if hex(-16) not in ('0xfffffff0', '0xfffffffffffffff0'): raise TestFailed, 'hex(-16)'
def f(): pass
c1c96d1b5c5b94edc84c057278a29f4aa7a32453 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/c1c96d1b5c5b94edc84c057278a29f4aa7a32453/test_b1.py
print ("bdist.run: format=%s, command=%s, rest=%s" % (self.formats[i], cmd_name, commands[i+1:]))
def run (self):
4c7fb96b7a5e86fe23bb28cfee620ea616eec710 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/4c7fb96b7a5e86fe23bb28cfee620ea616eec710/bdist.py
makedirs(head, mode)
try: makedirs(head, mode) except OSError, e: if e.errno != EEXIST: raise
def makedirs(name, mode=0777): """makedirs(path [, mode=0777]) Super-mkdir; create a leaf directory and all intermediate ones. Works like mkdir, except that any intermediate path segment (not just the rightmost) will be created if it does not exist. This is recursive. """ head, tail = path.split(name) if not tail: head, tail = path.split(head) if head and tail and not path.exists(head): makedirs(head, mode) if tail == curdir: # xxx/newdir/. exists if xxx/newdir exists return mkdir(name, mode)
2bcf0154d5412e0d03a30cbbe8a853c47ab6bfc5 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/2bcf0154d5412e0d03a30cbbe8a853c47ab6bfc5/os.py
from errno import ENOENT, ENOTDIR
def _execvpe(file, args, env=None): from errno import ENOENT, ENOTDIR if env is not None: func = execve argrest = (args, env) else: func = execv argrest = (args,) env = environ head, tail = path.split(file) if head: func(file, *argrest) return if 'PATH' in env: envpath = env['PATH'] else: envpath = defpath PATH = envpath.split(pathsep) saved_exc = None saved_tb = None for dir in PATH: fullname = path.join(dir, file) try: func(fullname, *argrest) except error, e: tb = sys.exc_info()[2] if (e.errno != ENOENT and e.errno != ENOTDIR and saved_exc is None): saved_exc = e saved_tb = tb if saved_exc: raise error, saved_exc, saved_tb raise error, e, tb
2bcf0154d5412e0d03a30cbbe8a853c47ab6bfc5 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/2bcf0154d5412e0d03a30cbbe8a853c47ab6bfc5/os.py
except:
except OSError:
def _run_child(self, cmd): if isinstance(cmd, types.StringTypes): cmd = ['/bin/sh', '-c', cmd] for i in range(3, MAXFD): try: os.close(i) except: pass try: os.execvp(cmd[0], cmd) finally: os._exit(1)
1c90d7ab3c9a13e8578d6148cd33b5ace23f3aec /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/1c90d7ab3c9a13e8578d6148cd33b5ace23f3aec/popen2.py
import difflib a = expected.splitlines() b = output.splitlines()
a = expected.splitlines(1) b = output.splitlines(1)
def reportdiff(expected, output): print "*" * 70 import difflib a = expected.splitlines() b = output.splitlines() sm = difflib.SequenceMatcher(a=a, b=b) tuples = sm.get_opcodes() def pair(x0, x1): x0 += 1 if x0 >= x1: return str(x0) else: return "%d,%d" % (x0, x1) for op, a0, a1, b0, b1 in tuples: if op == 'equal': pass elif op == 'delete': print pair(a0, a1) + "d" + pair(b0, b1) for line in a[a0:a1]: print "<", line elif op == 'replace': print pair(a0, a1) + "c" + pair(b0, b1) for line in a[a0:a1]: print "<", line print "---" for line in b[b0:b1]: print ">", line elif op == 'insert': print str(a0) + "a" + pair(b0, b1) for line in b[b0:b1]: print ">", line else: print "get_opcodes() returned bad tuple?!?!", (op, a0, a1, b0, b1) print "*" * 70
c377b16d12ba325bb108eca575447d66f19294c0 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/c377b16d12ba325bb108eca575447d66f19294c0/regrtest.py
return str(x0) else: return "%d,%d" % (x0, x1)
return "line " + str(x0) else: return "lines %d-%d" % (x0, x1)
def pair(x0, x1): x0 += 1 if x0 >= x1: return str(x0) else: return "%d,%d" % (x0, x1)
c377b16d12ba325bb108eca575447d66f19294c0 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/c377b16d12ba325bb108eca575447d66f19294c0/regrtest.py
print pair(a0, a1) + "d" + pair(b0, b1)
print "***", pair(a0, a1), "of expected output missing:"
def pair(x0, x1): x0 += 1 if x0 >= x1: return str(x0) else: return "%d,%d" % (x0, x1)
c377b16d12ba325bb108eca575447d66f19294c0 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/c377b16d12ba325bb108eca575447d66f19294c0/regrtest.py
print "<", line
print "-", line,
def pair(x0, x1): x0 += 1 if x0 >= x1: return str(x0) else: return "%d,%d" % (x0, x1)
c377b16d12ba325bb108eca575447d66f19294c0 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/c377b16d12ba325bb108eca575447d66f19294c0/regrtest.py
print pair(a0, a1) + "c" + pair(b0, b1) for line in a[a0:a1]: print "<", line print "---"
print "*** mismatch between", pair(a0, a1), "of expected", \ "output and", pair(b0, b1), "of actual output:" for line in difflib.ndiff(a[a0:a1], b[b0:b1]): print line, elif op == 'insert': print "***", pair(b0, b1), "of actual output doesn't appear", \ "in expected output after line", str(a1)+":"
def pair(x0, x1): x0 += 1 if x0 >= x1: return str(x0) else: return "%d,%d" % (x0, x1)
c377b16d12ba325bb108eca575447d66f19294c0 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/c377b16d12ba325bb108eca575447d66f19294c0/regrtest.py
print ">", line elif op == 'insert': print str(a0) + "a" + pair(b0, b1) for line in b[b0:b1]: print ">", line
print "+", line,
def pair(x0, x1): x0 += 1 if x0 >= x1: return str(x0) else: return "%d,%d" % (x0, x1)
c377b16d12ba325bb108eca575447d66f19294c0 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/c377b16d12ba325bb108eca575447d66f19294c0/regrtest.py
return not not self.cl.methods
try: return not not self.cl.methods except AttributeError: return False
def IsExpandable(self): if self.cl: return not not self.cl.methods
0b743441a60640824360bdff15780fc5d40489d6 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/0b743441a60640824360bdff15780fc5d40489d6/ClassBrowser.py
rc = os.system("%s %s" % (self.name, url))
rc = os.system(cmd)
def _remote(self, url, action, autoraise): autoraise = int(bool(autoraise)) # always 0/1 raise_opt = self.raise_opts and self.raise_opts[autoraise] or '' cmd = "%s %s %s '%s' >/dev/null 2>&1" % (self.name, raise_opt, self.remote_cmd, action) if self.remote_background: cmd += ' &' rc = os.system(cmd) if rc: # bad return status, try again with simpler command rc = os.system("%s %s" % (self.name, url)) return not rc
1cb179e93fb0f698fdb5f215b3864c578d910d9a /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/1cb179e93fb0f698fdb5f215b3864c578d910d9a/webbrowser.py
rc = os.system(self.name + " -d '%s'" % url)
rc = os.system(self.name + " -d '%s' &" % url)
def _remote(self, url, action): # kfmclient is the new KDE way of opening URLs. cmd = "kfmclient %s >/dev/null 2>&1" % action rc = os.system(cmd) # Fall back to other variants. if rc: if _iscommand("konqueror"): rc = os.system(self.name + " --silent '%s' &" % url) elif _iscommand("kfm"): rc = os.system(self.name + " -d '%s'" % url) return not rc
1cb179e93fb0f698fdb5f215b3864c578d910d9a /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/1cb179e93fb0f698fdb5f215b3864c578d910d9a/webbrowser.py
script = _safequote('open location "%s"', url)
script = 'open location "%s"' % url.replace('"', '%22')
def open(self, url, new=0, autoraise=1): assert "'" not in url # new must be 0 or 1 new = int(bool(new)) if self.name == "default": # User called open, open_new or get without a browser parameter script = _safequote('open location "%s"', url) # opens in default browser else: # User called get and chose a browser if self.name == "OmniWeb": toWindow = "" else: # Include toWindow parameter of OpenURL command for browsers # that support it. 0 == new window; -1 == existing toWindow = "toWindow %d" % (new - 1) cmd = _safequote('OpenURL "%s"', url) script = '''tell application "%s" activate %s %s end tell''' % (self.name, cmd, toWindow) # Open pipe to AppleScript through osascript command osapipe = os.popen("osascript", "w") if osapipe is None: return False # Write script to osascript's stdin osapipe.write(script) rc = osapipe.close() return not rc
1cb179e93fb0f698fdb5f215b3864c578d910d9a /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/1cb179e93fb0f698fdb5f215b3864c578d910d9a/webbrowser.py
cmd = _safequote('OpenURL "%s"', url)
cmd = 'OpenURL "%s"' % url.replace('"', '%22')
def open(self, url, new=0, autoraise=1): assert "'" not in url # new must be 0 or 1 new = int(bool(new)) if self.name == "default": # User called open, open_new or get without a browser parameter script = _safequote('open location "%s"', url) # opens in default browser else: # User called get and chose a browser if self.name == "OmniWeb": toWindow = "" else: # Include toWindow parameter of OpenURL command for browsers # that support it. 0 == new window; -1 == existing toWindow = "toWindow %d" % (new - 1) cmd = _safequote('OpenURL "%s"', url) script = '''tell application "%s" activate %s %s end tell''' % (self.name, cmd, toWindow) # Open pipe to AppleScript through osascript command osapipe = os.popen("osascript", "w") if osapipe is None: return False # Write script to osascript's stdin osapipe.write(script) rc = osapipe.close() return not rc
1cb179e93fb0f698fdb5f215b3864c578d910d9a /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/1cb179e93fb0f698fdb5f215b3864c578d910d9a/webbrowser.py
print 'XX', dst, '->', (head, tail)
def mkdirs(dst): """Make directories leading to 'dst' if they don't exist yet""" if dst == '' or os.path.exists(dst): return head, tail = os.path.split(dst) print 'XX', dst, '->', (head, tail) # XXXX Is this a bug in os.path.split? if not ':' in head: head = head + ':' mkdirs(head) os.mkdir(dst, 0777)
880e6eb409ecf599943ed40bb87a3fe4641b0f9e /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/880e6eb409ecf599943ed40bb87a3fe4641b0f9e/macostools.py
path = sys.path
path = sys.path[:]
def main(): # overridable context prefix = None # settable with -p option exec_prefix = None # settable with -P option extensions = [] path = sys.path modargs = 0 debug = 1 odir = '' win = sys.platform[:3] == 'win' # modules that are imported by the Python runtime implicits = ["site", "exceptions"] # output files frozen_c = 'frozen.c' config_c = 'config.c' target = 'a.out' # normally derived from script name makefile = 'Makefile' subsystem = 'console' # parse command line try: opts, args = getopt.getopt(sys.argv[1:], 'deh:mo:p:P:qs:w') except getopt.error, msg: usage('getopt error: ' + str(msg)) # proces option arguments for o, a in opts: if o == '-h': print __doc__ return if o == '-d': debug = debug + 1 if o == '-e': extensions.append(a) if o == '-m': modargs = 1 if o == '-o': odir = a if o == '-p': prefix = a if o == '-P': exec_prefix = a if o == '-q': debug = 0 if o == '-w': win = not win if o == '-s': if not win: usage("-s subsystem option only on Windows") subsystem = a # default prefix and exec_prefix if not exec_prefix: if prefix: exec_prefix = prefix else: exec_prefix = sys.exec_prefix if not prefix: prefix = sys.prefix # determine whether -p points to the Python source tree ishome = os.path.exists(os.path.join(prefix, 'Include', 'pythonrun.h')) # locations derived from options version = sys.version[:3] if ishome: print "(Using Python source directory)" binlib = exec_prefix incldir = os.path.join(prefix, 'Include') config_c_in = os.path.join(prefix, 'Modules', 'config.c.in') frozenmain_c = os.path.join(prefix, 'Python', 'frozenmain.c') makefile_in = os.path.join(exec_prefix, 'Modules', 'Makefile') else: binlib = os.path.join(exec_prefix, 'lib', 'python%s' % version, 'config') incldir = os.path.join(prefix, 'include', 'python%s' % version) config_c_in = os.path.join(binlib, 'config.c.in') frozenmain_c = os.path.join(binlib, 'frozenmain.c') makefile_in = os.path.join(binlib, 'Makefile') supp_sources = [] defines = [] includes = ['-I' + incldir, '-I' + binlib] # sanity check of directories and files for dir in [prefix, exec_prefix, binlib, incldir] + extensions: if not os.path.exists(dir): usage('needed directory %s not found' % dir) if not os.path.isdir(dir): usage('%s: not a directory' % dir) if win: files = supp_sources else: files = [config_c_in, makefile_in] + supp_sources for file in supp_sources: if not os.path.exists(file): usage('needed file %s not found' % file) if not os.path.isfile(file): usage('%s: not a plain file' % file) if not win: for dir in extensions: setup = os.path.join(dir, 'Setup') if not os.path.exists(setup): usage('needed file %s not found' % setup) if not os.path.isfile(setup): usage('%s: not a plain file' % setup) # check that enough arguments are passed if not args: usage('at least one filename argument required') # check that the script name ends in ".py" if args[0][-3:] != ".py": usage('the script name must have a .py suffix') # check that file arguments exist for arg in args: if not os.path.exists(arg): usage('argument %s not found' % arg) if not os.path.isfile(arg): usage('%s: not a plain file' % arg) # process non-option arguments scriptfile = args[0] modules = args[1:] # derive target name from script name base = os.path.basename(scriptfile) base, ext = os.path.splitext(base) if base: if base != scriptfile: target = base else: target = base + '.bin' # handle -o option base_frozen_c = frozen_c base_config_c = config_c base_target = target if odir and not os.path.isdir(odir): try: os.mkdir(odir) print "Created output directory", odir except os.error, msg: usage('%s: mkdir failed (%s)' % (odir, str(msg))) if odir: frozen_c = os.path.join(odir, frozen_c) config_c = os.path.join(odir, config_c) target = os.path.join(odir, target) makefile = os.path.join(odir, makefile) # Actual work starts here... # collect all modules of the program mf = modulefinder.ModuleFinder(path, debug) for mod in implicits: mf.import_hook(mod) for mod in modules: if mod == '-m': modargs = 1 continue if modargs: if mod[-2:] == '.*': mf.import_hook(mod[:-2], None, ["*"]) else: mf.import_hook(mod) else: mf.load_file(mod) mf.run_script(scriptfile) if debug > 0: mf.report() print dict = mf.modules # generate output for frozen modules backup = frozen_c + '~' try: os.rename(frozen_c, backup) except os.error: backup = None outfp = open(frozen_c, 'w') try: makefreeze.makefreeze(outfp, dict, debug) if win and subsystem == 'windows': import winmakemakefile outfp.write(winmakemakefile.WINMAINTEMPLATE) finally: outfp.close() if backup: if cmp.cmp(backup, frozen_c): sys.stderr.write('%s not changed, not written\n' % frozen_c) os.rename(backup, frozen_c) # windows gets different treatment if win: # Taking a shortcut here... import winmakemakefile outfp = open(makefile, 'w') try: winmakemakefile.makemakefile(outfp, locals(), [frozenmain_c, frozen_c], target) finally: outfp.close() return # generate config.c and Makefile builtins = [] unknown = [] mods = dict.keys() mods.sort() for mod in mods: if dict[mod].__code__: continue if not dict[mod].__file__: builtins.append(mod) else: unknown.append(mod) addfiles = [] if unknown: addfiles, addmods = \ checkextensions.checkextensions(unknown, extensions) for mod in addmods: unknown.remove(mod) builtins = builtins + addmods if unknown: sys.stderr.write('Warning: unknown modules remain: %s\n' % string.join(unknown)) builtins.sort() infp = open(config_c_in) backup = config_c + '~' try: os.rename(config_c, backup) except os.error: backup = None outfp = open(config_c, 'w') try: makeconfig.makeconfig(infp, outfp, builtins) finally: outfp.close() infp.close() if backup: if cmp.cmp(backup, config_c): sys.stderr.write('%s not changed, not written\n' % config_c) os.rename(backup, config_c) cflags = defines + includes + ['$(OPT)'] libs = [os.path.join(binlib, 'libpython$(VERSION).a')] somevars = {} if os.path.exists(makefile_in): makevars = parsesetup.getmakevars(makefile_in) for key in makevars.keys(): somevars[key] = makevars[key] somevars['CFLAGS'] = string.join(cflags) # override files = ['$(OPT)', '$(LDFLAGS)', base_config_c, base_frozen_c] + \ supp_sources + addfiles + libs + \ ['$(MODLIBS)', '$(LIBS)', '$(SYSLIBS)'] backup = makefile + '~' try: os.rename(makefile, backup) except os.error: backup = None outfp = open(makefile, 'w') try: makemakefile.makemakefile(outfp, somevars, files, base_target) finally: outfp.close() if backup: if not cmp.cmp(backup, makefile): print 'previous Makefile saved as', backup else: sys.stderr.write('%s not changed, not written\n' % makefile) os.rename(backup, makefile) # Done! if odir: print 'Now run "make" in', odir, print 'to build the target:', base_target else: print 'Now run "make" to build the target:', base_target
1e07403bbf47e7198a735a901598cbc1eedd607f /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/1e07403bbf47e7198a735a901598cbc1eedd607f/freeze.py
if args[0][-3:] != ".py": usage('the script name must have a .py suffix')
def main(): # overridable context prefix = None # settable with -p option exec_prefix = None # settable with -P option extensions = [] path = sys.path modargs = 0 debug = 1 odir = '' win = sys.platform[:3] == 'win' # modules that are imported by the Python runtime implicits = ["site", "exceptions"] # output files frozen_c = 'frozen.c' config_c = 'config.c' target = 'a.out' # normally derived from script name makefile = 'Makefile' subsystem = 'console' # parse command line try: opts, args = getopt.getopt(sys.argv[1:], 'deh:mo:p:P:qs:w') except getopt.error, msg: usage('getopt error: ' + str(msg)) # proces option arguments for o, a in opts: if o == '-h': print __doc__ return if o == '-d': debug = debug + 1 if o == '-e': extensions.append(a) if o == '-m': modargs = 1 if o == '-o': odir = a if o == '-p': prefix = a if o == '-P': exec_prefix = a if o == '-q': debug = 0 if o == '-w': win = not win if o == '-s': if not win: usage("-s subsystem option only on Windows") subsystem = a # default prefix and exec_prefix if not exec_prefix: if prefix: exec_prefix = prefix else: exec_prefix = sys.exec_prefix if not prefix: prefix = sys.prefix # determine whether -p points to the Python source tree ishome = os.path.exists(os.path.join(prefix, 'Include', 'pythonrun.h')) # locations derived from options version = sys.version[:3] if ishome: print "(Using Python source directory)" binlib = exec_prefix incldir = os.path.join(prefix, 'Include') config_c_in = os.path.join(prefix, 'Modules', 'config.c.in') frozenmain_c = os.path.join(prefix, 'Python', 'frozenmain.c') makefile_in = os.path.join(exec_prefix, 'Modules', 'Makefile') else: binlib = os.path.join(exec_prefix, 'lib', 'python%s' % version, 'config') incldir = os.path.join(prefix, 'include', 'python%s' % version) config_c_in = os.path.join(binlib, 'config.c.in') frozenmain_c = os.path.join(binlib, 'frozenmain.c') makefile_in = os.path.join(binlib, 'Makefile') supp_sources = [] defines = [] includes = ['-I' + incldir, '-I' + binlib] # sanity check of directories and files for dir in [prefix, exec_prefix, binlib, incldir] + extensions: if not os.path.exists(dir): usage('needed directory %s not found' % dir) if not os.path.isdir(dir): usage('%s: not a directory' % dir) if win: files = supp_sources else: files = [config_c_in, makefile_in] + supp_sources for file in supp_sources: if not os.path.exists(file): usage('needed file %s not found' % file) if not os.path.isfile(file): usage('%s: not a plain file' % file) if not win: for dir in extensions: setup = os.path.join(dir, 'Setup') if not os.path.exists(setup): usage('needed file %s not found' % setup) if not os.path.isfile(setup): usage('%s: not a plain file' % setup) # check that enough arguments are passed if not args: usage('at least one filename argument required') # check that the script name ends in ".py" if args[0][-3:] != ".py": usage('the script name must have a .py suffix') # check that file arguments exist for arg in args: if not os.path.exists(arg): usage('argument %s not found' % arg) if not os.path.isfile(arg): usage('%s: not a plain file' % arg) # process non-option arguments scriptfile = args[0] modules = args[1:] # derive target name from script name base = os.path.basename(scriptfile) base, ext = os.path.splitext(base) if base: if base != scriptfile: target = base else: target = base + '.bin' # handle -o option base_frozen_c = frozen_c base_config_c = config_c base_target = target if odir and not os.path.isdir(odir): try: os.mkdir(odir) print "Created output directory", odir except os.error, msg: usage('%s: mkdir failed (%s)' % (odir, str(msg))) if odir: frozen_c = os.path.join(odir, frozen_c) config_c = os.path.join(odir, config_c) target = os.path.join(odir, target) makefile = os.path.join(odir, makefile) # Actual work starts here... # collect all modules of the program mf = modulefinder.ModuleFinder(path, debug) for mod in implicits: mf.import_hook(mod) for mod in modules: if mod == '-m': modargs = 1 continue if modargs: if mod[-2:] == '.*': mf.import_hook(mod[:-2], None, ["*"]) else: mf.import_hook(mod) else: mf.load_file(mod) mf.run_script(scriptfile) if debug > 0: mf.report() print dict = mf.modules # generate output for frozen modules backup = frozen_c + '~' try: os.rename(frozen_c, backup) except os.error: backup = None outfp = open(frozen_c, 'w') try: makefreeze.makefreeze(outfp, dict, debug) if win and subsystem == 'windows': import winmakemakefile outfp.write(winmakemakefile.WINMAINTEMPLATE) finally: outfp.close() if backup: if cmp.cmp(backup, frozen_c): sys.stderr.write('%s not changed, not written\n' % frozen_c) os.rename(backup, frozen_c) # windows gets different treatment if win: # Taking a shortcut here... import winmakemakefile outfp = open(makefile, 'w') try: winmakemakefile.makemakefile(outfp, locals(), [frozenmain_c, frozen_c], target) finally: outfp.close() return # generate config.c and Makefile builtins = [] unknown = [] mods = dict.keys() mods.sort() for mod in mods: if dict[mod].__code__: continue if not dict[mod].__file__: builtins.append(mod) else: unknown.append(mod) addfiles = [] if unknown: addfiles, addmods = \ checkextensions.checkextensions(unknown, extensions) for mod in addmods: unknown.remove(mod) builtins = builtins + addmods if unknown: sys.stderr.write('Warning: unknown modules remain: %s\n' % string.join(unknown)) builtins.sort() infp = open(config_c_in) backup = config_c + '~' try: os.rename(config_c, backup) except os.error: backup = None outfp = open(config_c, 'w') try: makeconfig.makeconfig(infp, outfp, builtins) finally: outfp.close() infp.close() if backup: if cmp.cmp(backup, config_c): sys.stderr.write('%s not changed, not written\n' % config_c) os.rename(backup, config_c) cflags = defines + includes + ['$(OPT)'] libs = [os.path.join(binlib, 'libpython$(VERSION).a')] somevars = {} if os.path.exists(makefile_in): makevars = parsesetup.getmakevars(makefile_in) for key in makevars.keys(): somevars[key] = makevars[key] somevars['CFLAGS'] = string.join(cflags) # override files = ['$(OPT)', '$(LDFLAGS)', base_config_c, base_frozen_c] + \ supp_sources + addfiles + libs + \ ['$(MODLIBS)', '$(LIBS)', '$(SYSLIBS)'] backup = makefile + '~' try: os.rename(makefile, backup) except os.error: backup = None outfp = open(makefile, 'w') try: makemakefile.makemakefile(outfp, somevars, files, base_target) finally: outfp.close() if backup: if not cmp.cmp(backup, makefile): print 'previous Makefile saved as', backup else: sys.stderr.write('%s not changed, not written\n' % makefile) os.rename(backup, makefile) # Done! if odir: print 'Now run "make" in', odir, print 'to build the target:', base_target else: print 'Now run "make" to build the target:', base_target
1e07403bbf47e7198a735a901598cbc1eedd607f /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/1e07403bbf47e7198a735a901598cbc1eedd607f/freeze.py
def abspath(p): return normpath(join(os.getcwd(), p))
abspath = os.expand
def expandvars(p): """ Expand environment variables using OS_GSTrans. """ l= 512 b= swi.block(l) return b.tostring(0, swi.swi('OS_GSTrans', 'sbi;..i', p, b, l))
1422e9dc60bd795b0bf8d8877087ce1eb6ad6942 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/1422e9dc60bd795b0bf8d8877087ce1eb6ad6942/riscospath.py
Single = any(r"[^'\\]", r'\\.') + "'" Double = any(r'[^"\\]', r'\\.') + '"' Single3 = any(r"[^'\\]",r'\\.',r"'[^'\\]",r"'\\.",r"''[^'\\]",r"''\\.") + "'''" Double3 = any(r'[^"\\]',r'\\.',r'"[^"\\]',r'"\\.',r'""[^"\\]',r'""\\.') + '"""'
Single = r"[^'\\]*(?:\\.[^'\\]*)*'" Double = r'[^"\\]*(?:\\.[^"\\]*)*"' Single3 = r"[^'\\]*(?:(?:\\.|'(?!''))[^'\\]*)*'''" Double3 = r'[^"\\]*(?:(?:\\.|"(?!""))[^"\\]*)*"""'
def maybe(*choices): return apply(group, choices) + '?'
de49583a0d59f806b88b0f6a869f470047b3cbce /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/de49583a0d59f806b88b0f6a869f470047b3cbce/tokenize.py
String = group("[rR]?'" + any(r"[^\n'\\]", r'\\.') + "'", '[rR]?"' + any(r'[^\n"\\]', r'\\.') + '"') Operator = group('\+=', '\-=', '\*=', '%=', '/=', '\*\*=', '&=', '\|=', '\^=', '>>=', '<<=', '\+', '\-', '\*\*', '\*', '\^', '~', '/', '%', '&', '\|', '<<', '>>', '==', '<=', '<>', '!=', '>=', '=', '<', '>')
String = group(r"[rR]?'[^\n'\\]*(?:\\.[^\n'\\]*)*'", r'[rR]?"[^\n"\\]*(?:\\.[^\n"\\]*)*"') Operator = group(r"\*\*=?", r">>=?", r"<<=?", r"<>", r"!=", r"[+\-*/%&|^=<>]=?", r"~")
def maybe(*choices): return apply(group, choices) + '?'
de49583a0d59f806b88b0f6a869f470047b3cbce /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/de49583a0d59f806b88b0f6a869f470047b3cbce/tokenize.py
ContStr = group("[rR]?'" + any(r'\\.', r"[^\n'\\]") + group("'", r'\\\r?\n'), '[rR]?"' + any(r'\\.', r'[^\n"\\]') + group('"', r'\\\r?\n'))
ContStr = group(r"[rR]?'[^\n'\\]*(?:\\.[^\n'\\]*)*" + group("'", r'\\\r?\n'), r'[rR]?"[^\n"\\]*(?:\\.[^\n"\\]*)*' + group('"', r'\\\r?\n'))
def maybe(*choices): return apply(group, choices) + '?'
de49583a0d59f806b88b0f6a869f470047b3cbce /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/de49583a0d59f806b88b0f6a869f470047b3cbce/tokenize.py
b = (12,) c = (6, 6) d = (4, 4, 4) e = (3, 3, 3, 3)
b = (1,) c = (1, 2) d = (1, 2, 3) e = (1, 2, 3, 4)
def test_short_tuples(self): a = () b = (12,) c = (6, 6) d = (4, 4, 4) e = (3, 3, 3, 3) for proto in 0, 1, 2: for x in a, b, c, d, e: s = self.dumps(x, proto) y = self.loads(s) self.assertEqual(x, y, (proto, x, s, y))
025bc2fe6c1d71505b95b6351795cba7724fd45f /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/025bc2fe6c1d71505b95b6351795cba7724fd45f/pickletester.py
self.addheaders = [('User-Agent', server_version)]
self.addheaders = [('User-agent', server_version)]
def __init__(self): server_version = "Python-urllib/%s" % __version__ self.addheaders = [('User-Agent', server_version)] # manage the individual handlers self.handlers = [] self.handle_open = {} self.handle_error = {}
783eaf4774006d8cb6362d4136c88e74b36a0b77 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/783eaf4774006d8cb6362d4136c88e74b36a0b77/urllib2.py
req.add_header('Proxy-Authorization', 'Basic ' + user_pass)
req.add_header('Proxy-authorization', 'Basic ' + user_pass)
def proxy_open(self, req, proxy, type): orig_type = req.get_type() type, r_type = splittype(proxy) host, XXX = splithost(r_type) if '@' in host: user_pass, host = host.split('@', 1) if ':' in user_pass: user, password = user_pass.split(':', 1) user_pass = base64.encodestring('%s:%s' % (unquote(user), unquote(password))) req.add_header('Proxy-Authorization', 'Basic ' + user_pass) host = unquote(host) req.set_proxy(host, type) if orig_type == type: # let other handlers take care of it # XXX this only makes sense if the proxy is before the # other handlers return None else: # need to start over, because the other handlers don't # grok the proxy's URL type return self.parent.open(req)
783eaf4774006d8cb6362d4136c88e74b36a0b77 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/783eaf4774006d8cb6362d4136c88e74b36a0b77/urllib2.py
auth_header = 'Proxy-Authorization'
auth_header = 'Proxy-authorization'
def http_error_401(self, req, fp, code, msg, headers): host = urlparse.urlparse(req.get_full_url())[1] return self.http_error_auth_reqed('www-authenticate', host, req, headers)
783eaf4774006d8cb6362d4136c88e74b36a0b77 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/783eaf4774006d8cb6362d4136c88e74b36a0b77/urllib2.py
for args in self.parent.addheaders: name, value = args
for name, value in self.parent.addheaders: name = name.capitalize()
def do_open(self, http_class, req): host = req.get_host() if not host: raise URLError('no host given')
783eaf4774006d8cb6362d4136c88e74b36a0b77 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/783eaf4774006d8cb6362d4136c88e74b36a0b77/urllib2.py
h.putheader(*args)
h.putheader(name, value)
def do_open(self, http_class, req): host = req.get_host() if not host: raise URLError('no host given')
783eaf4774006d8cb6362d4136c88e74b36a0b77 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/783eaf4774006d8cb6362d4136c88e74b36a0b77/urllib2.py
'Content-Type: %s\nContent-Length: %d\nLast-modified: %s\n' %
'Content-type: %s\nContent-length: %d\nLast-modified: %s\n' %
def open_local_file(self, req): host = req.get_host() file = req.get_selector() localfile = url2pathname(file) stats = os.stat(localfile) size = stats.st_size modified = rfc822.formatdate(stats.st_mtime) mtype = mimetypes.guess_type(file)[0] headers = mimetools.Message(StringIO( 'Content-Type: %s\nContent-Length: %d\nLast-modified: %s\n' % (mtype or 'text/plain', size, modified))) if host: host, port = splitport(host) if not host or \ (not port and socket.gethostbyname(host) in self.get_names()): return addinfourl(open(localfile, 'rb'), headers, 'file:'+file) raise URLError('file not on local host')
783eaf4774006d8cb6362d4136c88e74b36a0b77 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/783eaf4774006d8cb6362d4136c88e74b36a0b77/urllib2.py
headers += "Content-Type: %s\n" % mtype
headers += "Content-type: %s\n" % mtype
def ftp_open(self, req): host = req.get_host() if not host: raise IOError, ('ftp error', 'no host given') # XXX handle custom username & password try: host = socket.gethostbyname(host) except socket.error, msg: raise URLError(msg) host, port = splitport(host) if port is None: port = ftplib.FTP_PORT path, attrs = splitattr(req.get_selector()) path = unquote(path) dirs = path.split('/') dirs, file = dirs[:-1], dirs[-1] if dirs and not dirs[0]: dirs = dirs[1:] user = passwd = '' # XXX try: fw = self.connect_ftp(user, passwd, host, port, dirs) type = file and 'I' or 'D' for attr in attrs: attr, value = splitattr(attr) if attr.lower() == 'type' and \ value in ('a', 'A', 'i', 'I', 'd', 'D'): type = value.upper() fp, retrlen = fw.retrfile(file, type) headers = "" mtype = mimetypes.guess_type(req.get_full_url())[0] if mtype: headers += "Content-Type: %s\n" % mtype if retrlen is not None and retrlen >= 0: headers += "Content-Length: %d\n" % retrlen sf = StringIO(headers) headers = mimetools.Message(sf) return addinfourl(fp, headers, req.get_full_url()) except ftplib.all_errors, msg: raise IOError, ('ftp error', msg), sys.exc_info()[2]
783eaf4774006d8cb6362d4136c88e74b36a0b77 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/783eaf4774006d8cb6362d4136c88e74b36a0b77/urllib2.py
headers += "Content-Length: %d\n" % retrlen
headers += "Content-length: %d\n" % retrlen
def ftp_open(self, req): host = req.get_host() if not host: raise IOError, ('ftp error', 'no host given') # XXX handle custom username & password try: host = socket.gethostbyname(host) except socket.error, msg: raise URLError(msg) host, port = splitport(host) if port is None: port = ftplib.FTP_PORT path, attrs = splitattr(req.get_selector()) path = unquote(path) dirs = path.split('/') dirs, file = dirs[:-1], dirs[-1] if dirs and not dirs[0]: dirs = dirs[1:] user = passwd = '' # XXX try: fw = self.connect_ftp(user, passwd, host, port, dirs) type = file and 'I' or 'D' for attr in attrs: attr, value = splitattr(attr) if attr.lower() == 'type' and \ value in ('a', 'A', 'i', 'I', 'd', 'D'): type = value.upper() fp, retrlen = fw.retrfile(file, type) headers = "" mtype = mimetypes.guess_type(req.get_full_url())[0] if mtype: headers += "Content-Type: %s\n" % mtype if retrlen is not None and retrlen >= 0: headers += "Content-Length: %d\n" % retrlen sf = StringIO(headers) headers = mimetools.Message(sf) return addinfourl(fp, headers, req.get_full_url()) except ftplib.all_errors, msg: raise IOError, ('ftp error', msg), sys.exc_info()[2]
783eaf4774006d8cb6362d4136c88e74b36a0b77 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/783eaf4774006d8cb6362d4136c88e74b36a0b77/urllib2.py
chunk = Chunk().init(self._file)
try: chunk = Chunk().init(self._file) except EOFError: if formlength == 8: print 'Warning: FORM chunk size too large' formlength = 0 break raise EOFError
def initfp(self, file): self._file = file self._version = 0 self._decomp = None self._markers = [] self._soundpos = 0 form = self._file.read(4) if form != 'FORM': raise Error, 'file does not start with FORM id' formlength = _read_long(self._file) if formlength <= 0: raise Error, 'invalid FORM chunk data size' formdata = self._file.read(4) formlength = formlength - 4 if formdata == 'AIFF': self._aifc = 0 elif formdata == 'AIFC': self._aifc = 1 else: raise Error, 'not an AIFF or AIFF-C file' self._comm_chunk_read = 0 while formlength > 0: self._ssnd_seek_needed = 1 chunk = Chunk().init(self._file) formlength = formlength - 8 - chunk.chunksize if chunk.chunksize & 1: formlength = formlength - 1 if chunk.chunkname == 'COMM': self._read_comm_chunk(chunk) self._comm_chunk_read = 1 elif chunk.chunkname == 'SSND': self._ssnd_chunk = chunk dummy = chunk.read(8) self._ssnd_seek_needed = 0 elif chunk.chunkname == 'FVER': self._version = _read_long(chunk) elif chunk.chunkname == 'MARK': self._readmark(chunk) elif chunk.chunkname in _skiplist: pass else: raise Error, 'unrecognized chunk type '+chunk.chunkname if formlength > 0: chunk.skip() if not self._comm_chunk_read or not self._ssnd_chunk: raise Error, 'COMM chunk and/or SSND chunk missing' if self._aifc and self._decomp: params = [CL.ORIGINAL_FORMAT, 0, \ CL.BITS_PER_COMPONENT, 0, \ CL.FRAME_RATE, self._framerate] if self._nchannels == AL.MONO: params[1] = CL.MONO else: params[1] = CL.STEREO_INTERLEAVED if self._sampwidth == AL.SAMPLE_8: params[3] = 8 elif self._sampwidth == AL.SAMPLE_16: params[3] = 16 else: params[3] = 24 self._decomp.SetParams(params) return self
8d733a00f00c98f5627a977150c85bfa9bed6d28 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/8d733a00f00c98f5627a977150c85bfa9bed6d28/aifc.py
headers, 'file:'+file)
headers, urlfile)
def open_local_file(self, url): import mimetypes, mimetools, StringIO mtype = mimetypes.guess_type(url)[0] headers = mimetools.Message(StringIO.StringIO( 'Content-Type: %s\n' % (mtype or 'text/plain'))) host, file = splithost(url) if not host: return addinfourl(open(url2pathname(file), 'rb'), headers, 'file:'+file) host, port = splitport(host) if not port \ and socket.gethostbyname(host) in (localhost(), thishost()): return addinfourl(open(url2pathname(file), 'rb'), headers, 'file:'+file) raise IOError, ('local file error', 'not on local host')
336a201d4fed1b800029f302653e851a430a166b /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/336a201d4fed1b800029f302653e851a430a166b/urllib.py
headers, 'file:'+file)
headers, urlfile)
def open_local_file(self, url): import mimetypes, mimetools, StringIO mtype = mimetypes.guess_type(url)[0] headers = mimetools.Message(StringIO.StringIO( 'Content-Type: %s\n' % (mtype or 'text/plain'))) host, file = splithost(url) if not host: return addinfourl(open(url2pathname(file), 'rb'), headers, 'file:'+file) host, port = splitport(host) if not port \ and socket.gethostbyname(host) in (localhost(), thishost()): return addinfourl(open(url2pathname(file), 'rb'), headers, 'file:'+file) raise IOError, ('local file error', 'not on local host')
336a201d4fed1b800029f302653e851a430a166b /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/336a201d4fed1b800029f302653e851a430a166b/urllib.py
if self.tkconsole.closing: return
def poll_subprocess(self): clt = self.rpcclt if clt is None: return try: response = clt.pollresponse(self.active_seq, wait=0.05) except (EOFError, IOError, KeyboardInterrupt): # lost connection or subprocess terminated itself, restart # [the KBI is from rpc.SocketIO.handle_EOF()] if self.tkconsole.closing: return response = None self.restart_subprocess() self.tkconsole.endexecuting() if response: self.tkconsole.resetoutput() self.active_seq = None how, what = response console = self.tkconsole.console if how == "OK": if what is not None: print >>console, `what` elif how == "EXCEPTION": if self.tkconsole.getvar("<<toggle-jit-stack-viewer>>"): self.remote_stack_viewer() elif how == "ERROR": errmsg = "PyShell.ModifiedInterpreter: Subprocess ERROR:\n" print >>sys.__stderr__, errmsg, what print >>console, errmsg, what # we received a response to the currently active seq number: self.tkconsole.endexecuting() # Reschedule myself in 50 ms self.tkconsole.text.after(50, self.poll_subprocess)
88957d8d0d9bf6d45603171927aa82d921bf9697 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/88957d8d0d9bf6d45603171927aa82d921bf9697/PyShell.py
self.tkconsole.text.after(50, self.poll_subprocess)
if not self.tkconsole.closing: self.tkconsole.text.after(self.tkconsole.pollinterval, self.poll_subprocess)
def poll_subprocess(self): clt = self.rpcclt if clt is None: return try: response = clt.pollresponse(self.active_seq, wait=0.05) except (EOFError, IOError, KeyboardInterrupt): # lost connection or subprocess terminated itself, restart # [the KBI is from rpc.SocketIO.handle_EOF()] if self.tkconsole.closing: return response = None self.restart_subprocess() self.tkconsole.endexecuting() if response: self.tkconsole.resetoutput() self.active_seq = None how, what = response console = self.tkconsole.console if how == "OK": if what is not None: print >>console, `what` elif how == "EXCEPTION": if self.tkconsole.getvar("<<toggle-jit-stack-viewer>>"): self.remote_stack_viewer() elif how == "ERROR": errmsg = "PyShell.ModifiedInterpreter: Subprocess ERROR:\n" print >>sys.__stderr__, errmsg, what print >>console, errmsg, what # we received a response to the currently active seq number: self.tkconsole.endexecuting() # Reschedule myself in 50 ms self.tkconsole.text.after(50, self.poll_subprocess)
88957d8d0d9bf6d45603171927aa82d921bf9697 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/88957d8d0d9bf6d45603171927aa82d921bf9697/PyShell.py
return EditorWindow.close(self)
self.closing = True self.text.after(2 * self.pollinterval, self.close2) def close2(self): return EditorWindow.close(self)
def close(self): "Extend EditorWindow.close()" if self.executing: response = tkMessageBox.askokcancel( "Kill?", "The program is still running!\n Do you want to kill it?", default="ok", parent=self.text) if response == False: return "cancel" # interrupt the subprocess self.canceled = True if use_subprocess: self.interp.interrupt_subprocess() return "cancel" else: return EditorWindow.close(self)
88957d8d0d9bf6d45603171927aa82d921bf9697 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/88957d8d0d9bf6d45603171927aa82d921bf9697/PyShell.py
import __main__ class_ = getattr(__main__, options.classname)
classname = options.classname if "." in classname: lastdot = classname.rfind(".") mod = __import__(classname[:lastdot], globals(), locals(), [""]) classname = classname[lastdot+1:] else: import __main__ as mod print mod.__name__, dir(mod) class_ = getattr(mod, classname)
def parseargs(): global DEBUGSTREAM try: opts, args = getopt.getopt( sys.argv[1:], 'nVhc:d', ['class=', 'nosetuid', 'version', 'help', 'debug']) except getopt.error, e: usage(1, e) options = Options() for opt, arg in opts: if opt in ('-h', '--help'): usage(0) elif opt in ('-V', '--version'): print >> sys.stderr, __version__ sys.exit(0) elif opt in ('-n', '--nosetuid'): options.setuid = 0 elif opt in ('-c', '--class'): options.classname = arg elif opt in ('-d', '--debug'): DEBUGSTREAM = sys.stderr # parse the rest of the arguments if len(args) < 1: localspec = 'localhost:8025' remotespec = 'localhost:25' elif len(args) < 2: localspec = args[0] remotespec = 'localhost:25' elif len(args) < 3: localspec = args[0] remotespec = args[1] else: usage(1, 'Invalid arguments: %s' % COMMASPACE.join(args)) # split into host/port pairs i = localspec.find(':') if i < 0: usage(1, 'Bad local spec: %s' % localspec) options.localhost = localspec[:i] try: options.localport = int(localspec[i+1:]) except ValueError: usage(1, 'Bad local port: %s' % localspec) i = remotespec.find(':') if i < 0: usage(1, 'Bad remote spec: %s' % remotespec) options.remotehost = remotespec[:i] try: options.remoteport = int(remotespec[i+1:]) except ValueError: usage(1, 'Bad remote port: %s' % remotespec) return options
90e01539409c01649fab95122b61c023784d9a51 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/90e01539409c01649fab95122b61c023784d9a51/smtpd.py
name = basename(in_file)
name = os.path.basename(in_file)
def encode(in_file, out_file, name=None, mode=None): """Uuencode file""" # # If in_file is a pathname open it and change defaults # if in_file == '-': in_file = sys.stdin elif type(in_file) == type(''): if name == None: name = basename(in_file) if mode == None: try: mode = os.path.stat(in_file)[0] except AttributeError: pass in_file = open(in_file, 'rb') # # Open out_file if it is a pathname # if out_file == '-': out_file = sys.stdout elif type(out_file) == type(''): out_file = open(out_file, 'w') # # Set defaults for name and mode # if name == None: name = '-' if mode == None: mode = 0666 # # Write the data # out_file.write('begin %o %s\n' % ((mode&0777),name)) str = in_file.read(45) while len(str) > 0: out_file.write(binascii.b2a_uu(str)) str = in_file.read(45) out_file.write(' \nend\n')
5a49ffca5e229b087bea31f378420ea4c9868dea /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/5a49ffca5e229b087bea31f378420ea4c9868dea/uu.py
mode = os.path.stat(in_file)[0]
mode = os.stat(in_file)[0]
def encode(in_file, out_file, name=None, mode=None): """Uuencode file""" # # If in_file is a pathname open it and change defaults # if in_file == '-': in_file = sys.stdin elif type(in_file) == type(''): if name == None: name = basename(in_file) if mode == None: try: mode = os.path.stat(in_file)[0] except AttributeError: pass in_file = open(in_file, 'rb') # # Open out_file if it is a pathname # if out_file == '-': out_file = sys.stdout elif type(out_file) == type(''): out_file = open(out_file, 'w') # # Set defaults for name and mode # if name == None: name = '-' if mode == None: mode = 0666 # # Write the data # out_file.write('begin %o %s\n' % ((mode&0777),name)) str = in_file.read(45) while len(str) > 0: out_file.write(binascii.b2a_uu(str)) str = in_file.read(45) out_file.write(' \nend\n')
5a49ffca5e229b087bea31f378420ea4c9868dea /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/5a49ffca5e229b087bea31f378420ea4c9868dea/uu.py
doc = self.markup(value.__doc__, self.preformat)
doc = self.markup(getdoc(value), self.preformat)
def _docdescriptor(self, name, value, mod): results = [] push = results.append
bba6acc714710e7e0190e4eba300b1dc4e492ecf /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/bba6acc714710e7e0190e4eba300b1dc4e492ecf/pydoc.py
doc = getattr(value, "__doc__", None)
doc = getdoc(value)
def spilldata(msg, attrs, predicate): ok, attrs = _split_list(attrs, predicate) if ok: hr.maybe() push(msg) for name, kind, homecls, value in ok: if callable(value) or inspect.isdatadescriptor(value): doc = getattr(value, "__doc__", None) else: doc = None push(self.docother(getattr(object, name), name, mod, 70, doc) + '\n') return attrs
bba6acc714710e7e0190e4eba300b1dc4e492ecf /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/bba6acc714710e7e0190e4eba300b1dc4e492ecf/pydoc.py
pat = re.compile(r'^\s*class\s*' + name + r'\b')
pat = re.compile(r'^(\s*)class\s*' + name + r'\b') candidates = []
def findsource(object): """Return the entire source file and starting line number for an object. The argument may be a module, class, method, function, traceback, frame, or code object. The source code is returned as a list of all the lines in the file and the line number indexes a line in that list. An IOError is raised if the source code cannot be retrieved.""" file = getsourcefile(object) or getfile(object) module = getmodule(object, file) if module: lines = linecache.getlines(file, module.__dict__) else: lines = linecache.getlines(file) if not lines: raise IOError('could not get source code') if ismodule(object): return lines, 0 if isclass(object): name = object.__name__ pat = re.compile(r'^\s*class\s*' + name + r'\b') for i in range(len(lines)): if pat.match(lines[i]): return lines, i else: raise IOError('could not find class definition') if ismethod(object): object = object.im_func if isfunction(object): object = object.func_code if istraceback(object): object = object.tb_frame if isframe(object): object = object.f_code if iscode(object): if not hasattr(object, 'co_firstlineno'): raise IOError('could not find function definition') lnum = object.co_firstlineno - 1 pat = re.compile(r'^(\s*def\s)|(.*(?<!\w)lambda(:|\s))|^(\s*@)') while lnum > 0: if pat.match(lines[lnum]): break lnum = lnum - 1 return lines, lnum raise IOError('could not find code object')
fcf6696255b36efd73745d4e5e8e9a1dcbd2fd40 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/fcf6696255b36efd73745d4e5e8e9a1dcbd2fd40/inspect.py
if pat.match(lines[i]): return lines, i
match = pat.match(lines[i]) if match: if lines[i][0] == 'c': return lines, i candidates.append((match.group(1), i)) if candidates: candidates.sort() return lines, candidates[0][1]
def findsource(object): """Return the entire source file and starting line number for an object. The argument may be a module, class, method, function, traceback, frame, or code object. The source code is returned as a list of all the lines in the file and the line number indexes a line in that list. An IOError is raised if the source code cannot be retrieved.""" file = getsourcefile(object) or getfile(object) module = getmodule(object, file) if module: lines = linecache.getlines(file, module.__dict__) else: lines = linecache.getlines(file) if not lines: raise IOError('could not get source code') if ismodule(object): return lines, 0 if isclass(object): name = object.__name__ pat = re.compile(r'^\s*class\s*' + name + r'\b') for i in range(len(lines)): if pat.match(lines[i]): return lines, i else: raise IOError('could not find class definition') if ismethod(object): object = object.im_func if isfunction(object): object = object.func_code if istraceback(object): object = object.tb_frame if isframe(object): object = object.f_code if iscode(object): if not hasattr(object, 'co_firstlineno'): raise IOError('could not find function definition') lnum = object.co_firstlineno - 1 pat = re.compile(r'^(\s*def\s)|(.*(?<!\w)lambda(:|\s))|^(\s*@)') while lnum > 0: if pat.match(lines[lnum]): break lnum = lnum - 1 return lines, lnum raise IOError('could not find code object')
fcf6696255b36efd73745d4e5e8e9a1dcbd2fd40 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/fcf6696255b36efd73745d4e5e8e9a1dcbd2fd40/inspect.py
verify(2*L(3) == 6) verify(L(3)*2 == 6) verify(L(3)*L(2) == 6)
def mysetattr(self, name, value): if name == "spam": raise AttributeError return object.__setattr__(self, name, value)
e0007821cd2b8db1ecde561929f685bb356d0209 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/e0007821cd2b8db1ecde561929f685bb356d0209/test_descr.py
return encode_base64("%s\0%s\0%s" % (user, user, password), eol="")
return encode_base64("\0%s\0%s" % (user, password), eol="")
def encode_plain(user, password): return encode_base64("%s\0%s\0%s" % (user, user, password), eol="")
25946ddac90e2f69199af740cbaaa08beb13d9a9 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/25946ddac90e2f69199af740cbaaa08beb13d9a9/smtplib.py
blocknum = blocknum + 1
read += len(block) blocknum += 1
def retrieve(self, url, filename=None, reporthook=None, data=None): """retrieve(url) returns (filename, headers) for a local object or (tempfilename, headers) for a remote object.""" url = unwrap(toBytes(url)) if self.tempcache and url in self.tempcache: return self.tempcache[url] type, url1 = splittype(url) if filename is None and (not type or type == 'file'): try: fp = self.open_local_file(url1) hdrs = fp.info() del fp return url2pathname(splithost(url1)[1]), hdrs except IOError, msg: pass fp = self.open(url, data) headers = fp.info() if filename: tfp = open(filename, 'wb') else: import tempfile garbage, path = splittype(url) garbage, path = splithost(path or "") path, garbage = splitquery(path or "") path, garbage = splitattr(path or "") suffix = os.path.splitext(path)[1] (fd, filename) = tempfile.mkstemp(suffix) self.__tempfiles.append(filename) tfp = os.fdopen(fd, 'wb') result = filename, headers if self.tempcache is not None: self.tempcache[url] = result bs = 1024*8 size = -1 blocknum = 1 if reporthook: if "content-length" in headers: size = int(headers["Content-Length"]) reporthook(0, bs, size) block = fp.read(bs) if reporthook: reporthook(1, bs, size) while block: tfp.write(block) block = fp.read(bs) blocknum = blocknum + 1 if reporthook: reporthook(blocknum, bs, size) fp.close() tfp.close() del fp del tfp return result
b925602f169d47270a064cf9eb03e21706ed25c3 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/b925602f169d47270a064cf9eb03e21706ed25c3/urllib.py
def findall(pattern, string, maxsplit=0):
def findall(pattern, string):
def findall(pattern, string, maxsplit=0): """Return a list of all non-overlapping matches in the string. If one or more groups are present in the pattern, return a list of groups; this will be a list of tuples if the pattern has more than one group. Empty matches are included in the result.""" return _compile(pattern, 0).findall(string, maxsplit)
e06cbb8c56d76d5f845c4809a22fcdf99063496c /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/e06cbb8c56d76d5f845c4809a22fcdf99063496c/sre.py
return _compile(pattern, 0).findall(string, maxsplit)
return _compile(pattern, 0).findall(string)
def findall(pattern, string, maxsplit=0): """Return a list of all non-overlapping matches in the string. If one or more groups are present in the pattern, return a list of groups; this will be a list of tuples if the pattern has more than one group. Empty matches are included in the result.""" return _compile(pattern, 0).findall(string, maxsplit)
e06cbb8c56d76d5f845c4809a22fcdf99063496c /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/e06cbb8c56d76d5f845c4809a22fcdf99063496c/sre.py
imageop.mono2grey(img, x, y, 0, 255)
return imageop.mono2grey(img, x, y, 0, 255)
def mono2grey(img, x, y): imageop.mono2grey(img, x, y, 0, 255)
1e0fdd8a6bd4a094e42f0b9a8c995e98cfda5257 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/1e0fdd8a6bd4a094e42f0b9a8c995e98cfda5257/imgconv.py
alltests.addTest(module.suite())
alltests.addTest(module.test_suite())
def suite(): test_modules = [ 'test_associate', 'test_basics', 'test_compat', 'test_dbobj', 'test_dbshelve', 'test_dbtables', 'test_env_close', 'test_get_none', 'test_join', 'test_lock', 'test_misc', 'test_queue', 'test_recno', 'test_thread', ] alltests = unittest.TestSuite() for name in test_modules: module = __import__(name) alltests.addTest(module.suite()) return alltests
bce64ec086026464c14bdedc00599a837d5ad6ef /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/bce64ec086026464c14bdedc00599a837d5ad6ef/test_all.py
v = self.get(section, option) val = int(v) if val not in (0, 1):
states = {'1': 1, 'yes': 1, 'true': 1, 'on': 1, '0': 0, 'no': 0, 'false': 0, 'off': 0} v = self.get(section, option) if not states.has_key(v.lower()):
def getboolean(self, section, option): v = self.get(section, option) val = int(v) if val not in (0, 1): raise ValueError, 'Not a boolean: %s' % v return val
fb06f75c5ac24c720aaf8f221efff35543d878b6 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/fb06f75c5ac24c720aaf8f221efff35543d878b6/ConfigParser.py
return val
return states[v.lower()]
def getboolean(self, section, option): v = self.get(section, option) val = int(v) if val not in (0, 1): raise ValueError, 'Not a boolean: %s' % v return val
fb06f75c5ac24c720aaf8f221efff35543d878b6 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/fb06f75c5ac24c720aaf8f221efff35543d878b6/ConfigParser.py
try: what, tdelta, fileno, lineno = self._nextitem() except TypeError: self._reader.close() raise StopIteration()
what, tdelta, fileno, lineno = self._nextitem()
def next(self, index=0): while 1: try: what, tdelta, fileno, lineno = self._nextitem() except TypeError: # logreader().next() returns None at the end self._reader.close() raise StopIteration()
fbe36082906201210da081d71c6ac7b30f7ef1a2 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/fbe36082906201210da081d71c6ac7b30f7ef1a2/log.py
self.close()
try: self.close() except: pass
def __del__(self): self.close()
65f8cedd4a9820e5d069ece0194b7da0b1e4e33c /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/65f8cedd4a9820e5d069ece0194b7da0b1e4e33c/socket.py
wrapper = os.path.join(sys.exec_prefix, ":Mac:Tools:CGI:PythonCGISlave.py")
wrapper = "PythonCGISlave.py" if not os.path.exists("PythonCGISlave.py"): wrapper = os.path.join(sys.exec_prefix, ":Mac:Tools:CGI", wrapper)
def buildcgiapplet(): buildtools.DEBUG=1 # Find the template # (there's no point in proceeding if we can't find it) template = buildtools.findtemplate() wrapper = os.path.join(sys.exec_prefix, ":Mac:Tools:CGI:PythonCGISlave.py") # Ask for source text if not specified in sys.argv[1:] if not sys.argv[1:]: srcfss, ok = macfs.PromptGetFile('Select a CGI script:', 'TEXT', 'APPL') if not ok: return filename = srcfss.as_pathname() dstfilename = mkcgifilename(filename) dstfss, ok = macfs.StandardPutFile('Save application as:', os.path.basename(dstfilename)) if not ok: return dstfilename = dstfss.as_pathname() buildone(template, wrapper, filename, dstfilename) else: # Loop over all files to be processed for filename in sys.argv[1:]: dstfilename = mkcgifilename(filename) buildone(template, wrapper, filename, dstfilename)
c88093a90f8f5f979d291a282cfdd555c7a784b6 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/c88093a90f8f5f979d291a282cfdd555c7a784b6/BuildCGIApplet.py
try: ignore = posix.fdopen except: raise AttributeError, 'dup() method unavailable'
if not hasattr(posix, 'fdopen'): raise AttributeError, 'dup() method unavailable'
def dup(self): import posix
e9901f325e4bfb123479c706288d5c6a09bad406 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/e9901f325e4bfb123479c706288d5c6a09bad406/posixfile.py
try: ignore = posix.fdopen except: raise AttributeError, 'dup() method unavailable'
if not hasattr(posix, 'fdopen'): raise AttributeError, 'dup() method unavailable'
def dup2(self, fd): import posix
e9901f325e4bfb123479c706288d5c6a09bad406 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/e9901f325e4bfb123479c706288d5c6a09bad406/posixfile.py
test('replace', 'one!two!three!', 'one@two@three@', '!', '@', 0)
test('replace', 'one!two!three!', 'one!two!three!', '!', '@', 0)
def __getitem__(self, i): return self.seq[i]
da45d55a6ecff00ca714cbcf66fb2133621ca836 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/da45d55a6ecff00ca714cbcf66fb2133621ca836/test_strop.py
assert isinstance(req, Request)
def open(self, fullurl, data=None): # accept a URL or a Request object if isinstance(fullurl, basestring): req = Request(fullurl, data) else: req = fullurl if data is not None: req.add_data(data) assert isinstance(req, Request) # really only care about interface
24b2bc365467218ee719f6155d04b1f2962742c1 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/24b2bc365467218ee719f6155d04b1f2962742c1/urllib2.py
elif path == '' or path[-1:] in '/\\':
elif path == '' or path[-1:] in '/\\:':
def join(a, *p): """Join two or more pathname components, inserting "\\" as needed""" path = a for b in p: if isabs(b): path = b elif path == '' or path[-1:] in '/\\': path = path + b else: path = path + os.sep + b return path
0eeba5b24b0cf5297421c7bd5dbc38aff774dc5f /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/0eeba5b24b0cf5297421c7bd5dbc38aff774dc5f/ntpath.py
self.plist.CFBundleExecutable = self.name
def setup(self): if self.mainprogram is None and self.executable is None: raise TypeError, ("must specify either or both of " "'executable' and 'mainprogram'")
7fd69ad2f11c945cbe362cee4e262cec239d9f6c /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/7fd69ad2f11c945cbe362cee4e262cec239d9f6c/bundlebuilder.py