rem
stringlengths
1
322k
add
stringlengths
0
2.05M
context
stringlengths
4
228k
meta
stringlengths
156
215
return None
traceback = info[2] assert isinstance(traceback, types.TracebackType) traceback_id = id(traceback) tracebacktable[traceback_id] = traceback modified_info = (info[0], info[1], traceback_id) return modified_info
def wrap_info(info): if info is None: return None else: return None # XXX for now
f50d0f96a22c3316e023e7a1b6441baf4d54ece3 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/f50d0f96a22c3316e023e7a1b6441baf4d54ece3/RemoteDebugger.py
tb = None
if tbid is None: tb = None else: tb = tracebacktable[tbid]
def get_stack(self, fid, tbid): ##print >>sys.__stderr__, "get_stack(%s, %s)" % (`fid`, `tbid`) frame = frametable[fid] tb = None # XXX for now stack, i = self.idb.get_stack(frame, tb) ##print >>sys.__stderr__, "get_stack() ->", stack stack = [(wrap_frame(frame), k) for frame, k in stack] ##print >>sys.__stderr__, "get_stack() ->", stack return stack, i
f50d0f96a22c3316e023e7a1b6441baf4d54ece3 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/f50d0f96a22c3316e023e7a1b6441baf4d54ece3/RemoteDebugger.py
return msg
def clear_all_file_breaks(self, filename): msg = self.idb.clear_all_file_breaks(filename)
f50d0f96a22c3316e023e7a1b6441baf4d54ece3 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/f50d0f96a22c3316e023e7a1b6441baf4d54ece3/RemoteDebugger.py
def interaction(self, message, fid, iid):
def interaction(self, message, fid, modified_info):
def interaction(self, message, fid, iid): ##print "interaction: (%s, %s, %s)" % (`message`,`fid`, `iid`) frame = FrameProxy(self.conn, fid) info = None # XXX for now self.gui.interaction(message, frame, info)
f50d0f96a22c3316e023e7a1b6441baf4d54ece3 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/f50d0f96a22c3316e023e7a1b6441baf4d54ece3/RemoteDebugger.py
info = None self.gui.interaction(message, frame, info)
self.gui.interaction(message, frame, modified_info)
def interaction(self, message, fid, iid): ##print "interaction: (%s, %s, %s)" % (`message`,`fid`, `iid`) frame = FrameProxy(self.conn, fid) info = None # XXX for now self.gui.interaction(message, frame, info)
f50d0f96a22c3316e023e7a1b6441baf4d54ece3 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/f50d0f96a22c3316e023e7a1b6441baf4d54ece3/RemoteDebugger.py
def get_stack(self, frame, tb): stack, i = self.call("get_stack", frame._fid, None)
def get_stack(self, frame, tbid): stack, i = self.call("get_stack", frame._fid, tbid)
def get_stack(self, frame, tb): stack, i = self.call("get_stack", frame._fid, None) stack = [(FrameProxy(self.conn, fid), k) for fid, k in stack] return stack, i
f50d0f96a22c3316e023e7a1b6441baf4d54ece3 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/f50d0f96a22c3316e023e7a1b6441baf4d54ece3/RemoteDebugger.py
return msg
def clear_all_file_breaks(self, filename): msg = self.call("clear_all_file_breaks", filename)
f50d0f96a22c3316e023e7a1b6441baf4d54ece3 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/f50d0f96a22c3316e023e7a1b6441baf4d54ece3/RemoteDebugger.py
def powtest(type): if type != float: print " Testing 2-argument pow() function..." for i in range(-1000, 1000): if pow(type(i), 0) != 1: raise ValueError, 'pow('+str(i)+',0) != 1' if pow(type(i), 1) != type(i): raise ValueError, 'pow('+str(i)+',1) != '+str(i) if pow(type(0), 1) != type(0): raise ValueError, 'pow(0,'+str(i)+') != 0' if pow(type(1), 1) != type(1): raise ValueError, 'pow(1,'+str(i)+') != 1'
def test_main(): suite = unittest.TestSuite() suite.addTest(unittest.makeSuite(PowTest)) test.test_support.run_suite(suite)
def powtest(type): if type != float: print " Testing 2-argument pow() function..." for i in range(-1000, 1000): if pow(type(i), 0) != 1: raise ValueError, 'pow('+str(i)+',0) != 1' if pow(type(i), 1) != type(i): raise ValueError, 'pow('+str(i)+',1) != '+str(i) if pow(type(0), 1) != type(0): raise ValueError, 'pow(0,'+str(i)+') != 0' if pow(type(1), 1) != type(1): raise ValueError, 'pow(1,'+str(i)+') != 1' for i in range(-100, 100): if pow(type(i), 3) != i*i*i: raise ValueError, 'pow('+str(i)+',3) != '+str(i*i*i) pow2 = 1 for i in range(0,31): if pow(2, i) != pow2: raise ValueError, 'pow(2,'+str(i)+') != '+str(pow2) if i != 30 : pow2 = pow2*2 for othertype in int, long: for i in range(-10, 0) + range(1, 10): ii = type(i) for j in range(1, 11): jj = -othertype(j) try: pow(ii, jj) except ValueError: raise ValueError, "pow(%s, %s) failed" % (ii, jj) for othertype in int, long, float: for i in range(1, 100): zero = type(0) exp = -othertype(i/10.0) if exp == 0: continue try: pow(zero, exp) except ZeroDivisionError: pass # taking zero to any negative exponent should fail else: raise ValueError, "pow(%s, %s) did not fail" % (zero, exp) print " Testing 3-argument pow() function..." il, ih = -20, 20 jl, jh = -5, 5 kl, kh = -10, 10 compare = cmp if type == float: il = 1 compare = test_support.fcmp elif type == int: jl = 0 elif type == long: jl, jh = 0, 15 for i in range(il, ih+1): for j in range(jl, jh+1): for k in range(kl, kh+1): if k != 0: if type == float or j < 0: try: pow(type(i),j,k) except TypeError: pass else: raise ValueError, "expected TypeError from " + \ "pow%r" % ((type(i), j, k),) continue if compare(pow(type(i),j,k), pow(type(i),j)% type(k)): raise ValueError, "pow(" +str(i)+ "," +str(j)+ \ "," +str(k)+ ") != pow(" +str(i)+ "," + \ str(j)+ ") % " +str(k)
363f6d65a764ace00524e96da78055c8e2ef9cc4 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/363f6d65a764ace00524e96da78055c8e2ef9cc4/test_pow.py
for i in range(-100, 100): if pow(type(i), 3) != i*i*i: raise ValueError, 'pow('+str(i)+',3) != '+str(i*i*i) pow2 = 1 for i in range(0,31): if pow(2, i) != pow2: raise ValueError, 'pow(2,'+str(i)+') != '+str(pow2) if i != 30 : pow2 = pow2*2 for othertype in int, long: for i in range(-10, 0) + range(1, 10): ii = type(i) for j in range(1, 11): jj = -othertype(j) try: pow(ii, jj) except ValueError: raise ValueError, "pow(%s, %s) failed" % (ii, jj) for othertype in int, long, float: for i in range(1, 100): zero = type(0) exp = -othertype(i/10.0) if exp == 0: continue try: pow(zero, exp) except ZeroDivisionError: pass else: raise ValueError, "pow(%s, %s) did not fail" % (zero, exp) print " Testing 3-argument pow() function..." il, ih = -20, 20 jl, jh = -5, 5 kl, kh = -10, 10 compare = cmp if type == float: il = 1 compare = test_support.fcmp elif type == int: jl = 0 elif type == long: jl, jh = 0, 15 for i in range(il, ih+1): for j in range(jl, jh+1): for k in range(kl, kh+1): if k != 0: if type == float or j < 0: try: pow(type(i),j,k) except TypeError: pass else: raise ValueError, "expected TypeError from " + \ "pow%r" % ((type(i), j, k),) continue if compare(pow(type(i),j,k), pow(type(i),j)% type(k)): raise ValueError, "pow(" +str(i)+ "," +str(j)+ \ "," +str(k)+ ") != pow(" +str(i)+ "," + \ str(j)+ ") % " +str(k) print 'Testing integer mode...' powtest(int) print 'Testing long integer mode...' powtest(long) print 'Testing floating point mode...' powtest(float) print 'The number in both columns should match.' print `pow(3,3) % 8`, `pow(3,3,8)` print `pow(3,3) % -8`, `pow(3,3,-8)` print `pow(3,2) % -2`, `pow(3,2,-2)` print `pow(-3,3) % 8`, `pow(-3,3,8)` print `pow(-3,3) % -8`, `pow(-3,3,-8)` print `pow(5,2) % -8`, `pow(5,2,-8)` print print `pow(3L,3L) % 8`, `pow(3L,3L,8)` print `pow(3L,3L) % -8`, `pow(3L,3L,-8)` print `pow(3L,2) % -2`, `pow(3L,2,-2)` print `pow(-3L,3L) % 8`, `pow(-3L,3L,8)` print `pow(-3L,3L) % -8`, `pow(-3L,3L,-8)` print `pow(5L,2) % -8`, `pow(5L,2,-8)` print print for i in range(-10, 11): for j in range(0, 6): for k in range(-7, 11): if j >= 0 and k != 0: o = pow(i,j) % k n = pow(i,j,k) if o != n: print 'Integer mismatch:', i,j,k if j >= 0 and k != 0: o = pow(long(i),j) % k n = pow(long(i),j,k) if o != n: print 'Integer mismatch:', i,j,k class TestRpow: def __rpow__(self, other): return None None ** TestRpow()
if __name__ == "__main__": test_main()
def powtest(type): if type != float: print " Testing 2-argument pow() function..." for i in range(-1000, 1000): if pow(type(i), 0) != 1: raise ValueError, 'pow('+str(i)+',0) != 1' if pow(type(i), 1) != type(i): raise ValueError, 'pow('+str(i)+',1) != '+str(i) if pow(type(0), 1) != type(0): raise ValueError, 'pow(0,'+str(i)+') != 0' if pow(type(1), 1) != type(1): raise ValueError, 'pow(1,'+str(i)+') != 1' for i in range(-100, 100): if pow(type(i), 3) != i*i*i: raise ValueError, 'pow('+str(i)+',3) != '+str(i*i*i) pow2 = 1 for i in range(0,31): if pow(2, i) != pow2: raise ValueError, 'pow(2,'+str(i)+') != '+str(pow2) if i != 30 : pow2 = pow2*2 for othertype in int, long: for i in range(-10, 0) + range(1, 10): ii = type(i) for j in range(1, 11): jj = -othertype(j) try: pow(ii, jj) except ValueError: raise ValueError, "pow(%s, %s) failed" % (ii, jj) for othertype in int, long, float: for i in range(1, 100): zero = type(0) exp = -othertype(i/10.0) if exp == 0: continue try: pow(zero, exp) except ZeroDivisionError: pass # taking zero to any negative exponent should fail else: raise ValueError, "pow(%s, %s) did not fail" % (zero, exp) print " Testing 3-argument pow() function..." il, ih = -20, 20 jl, jh = -5, 5 kl, kh = -10, 10 compare = cmp if type == float: il = 1 compare = test_support.fcmp elif type == int: jl = 0 elif type == long: jl, jh = 0, 15 for i in range(il, ih+1): for j in range(jl, jh+1): for k in range(kl, kh+1): if k != 0: if type == float or j < 0: try: pow(type(i),j,k) except TypeError: pass else: raise ValueError, "expected TypeError from " + \ "pow%r" % ((type(i), j, k),) continue if compare(pow(type(i),j,k), pow(type(i),j)% type(k)): raise ValueError, "pow(" +str(i)+ "," +str(j)+ \ "," +str(k)+ ") != pow(" +str(i)+ "," + \ str(j)+ ") % " +str(k)
363f6d65a764ace00524e96da78055c8e2ef9cc4 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/363f6d65a764ace00524e96da78055c8e2ef9cc4/test_pow.py
"""Implements a file object on top of a regular socket object."""
"""Faux file object attached to a socket object.""" default_bufsize = 8192
_s = "def %s(self, *args): return self._sock.%s(*args)\n\n"
443fec3dd9c1a2c60b538af0504d4926e633b9b4 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/443fec3dd9c1a2c60b538af0504d4926e633b9b4/socket.py
self._mode = mode if bufsize <= 0: if bufsize == 0: bufsize = 1 else: bufsize = 8192 self._rbufsize = bufsize
self._mode = mode if bufsize < 0: bufsize = self.default_bufsize if bufsize == 0: self._rbufsize = 1 elif bufsize == 1: self._rbufsize = self.default_bufsize else: self._rbufsize = bufsize
def __init__(self, sock, mode='rb', bufsize=-1): self._sock = sock self._mode = mode if bufsize <= 0: if bufsize == 0: bufsize = 1 # Unbuffered mode else: bufsize = 8192 self._rbufsize = bufsize self._wbufsize = bufsize self._rbuf = [ ] self._wbuf = [ ]
443fec3dd9c1a2c60b538af0504d4926e633b9b4 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/443fec3dd9c1a2c60b538af0504d4926e633b9b4/socket.py
self._rbuf = [ ] self._wbuf = [ ]
self._rbuf = [] self._wbuf = []
def __init__(self, sock, mode='rb', bufsize=-1): self._sock = sock self._mode = mode if bufsize <= 0: if bufsize == 0: bufsize = 1 # Unbuffered mode else: bufsize = 8192 self._rbufsize = bufsize self._wbufsize = bufsize self._rbuf = [ ] self._wbuf = [ ]
443fec3dd9c1a2c60b538af0504d4926e633b9b4 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/443fec3dd9c1a2c60b538af0504d4926e633b9b4/socket.py
buffer = ''.join(self._wbuf)
buffer = "".join(self._wbuf) self._wbuf = []
def flush(self): if self._wbuf: buffer = ''.join(self._wbuf) self._sock.sendall(buffer) self._wbuf = [ ]
443fec3dd9c1a2c60b538af0504d4926e633b9b4 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/443fec3dd9c1a2c60b538af0504d4926e633b9b4/socket.py
self._wbuf = [ ]
def flush(self): if self._wbuf: buffer = ''.join(self._wbuf) self._sock.sendall(buffer) self._wbuf = [ ]
443fec3dd9c1a2c60b538af0504d4926e633b9b4 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/443fec3dd9c1a2c60b538af0504d4926e633b9b4/socket.py
self._wbuf.append (data) if self._wbufsize == 1: if '\n' in data: self.flush () elif self.__get_wbuf_len() >= self._wbufsize:
data = str(data) if not data: return self._wbuf.append(data) if (self._wbufsize == 0 or self._wbufsize == 1 and '\n' in data or self._get_wbuf_len() >= self._wbufsize):
def write(self, data): self._wbuf.append (data) # A _wbufsize of 1 means we're doing unbuffered IO. # Flush accordingly. if self._wbufsize == 1: if '\n' in data: self.flush () elif self.__get_wbuf_len() >= self._wbufsize: self.flush()
443fec3dd9c1a2c60b538af0504d4926e633b9b4 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/443fec3dd9c1a2c60b538af0504d4926e633b9b4/socket.py
filter(self._sock.sendall, list) self.flush() def __get_wbuf_len (self):
self._wbuf.extend(filter(None, map(str, list))) if (self._wbufsize <= 1 or self._get_wbuf_len() >= self._wbufsize): self.flush() def _get_wbuf_len(self):
def writelines(self, list): filter(self._sock.sendall, list) self.flush()
443fec3dd9c1a2c60b538af0504d4926e633b9b4 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/443fec3dd9c1a2c60b538af0504d4926e633b9b4/socket.py
for i in [len(x) for x in self._wbuf]: buf_len += i
for x in self._wbuf: buf_len += len(x)
def __get_wbuf_len (self): buf_len = 0 for i in [len(x) for x in self._wbuf]: buf_len += i return buf_len
443fec3dd9c1a2c60b538af0504d4926e633b9b4 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/443fec3dd9c1a2c60b538af0504d4926e633b9b4/socket.py
def __get_rbuf_len(self):
def _get_rbuf_len(self):
def __get_rbuf_len(self): buf_len = 0 for i in [len(x) for x in self._rbuf]: buf_len += i return buf_len
443fec3dd9c1a2c60b538af0504d4926e633b9b4 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/443fec3dd9c1a2c60b538af0504d4926e633b9b4/socket.py
for i in [len(x) for x in self._rbuf]: buf_len += i
for x in self._rbuf: buf_len += len(x)
def __get_rbuf_len(self): buf_len = 0 for i in [len(x) for x in self._rbuf]: buf_len += i return buf_len
443fec3dd9c1a2c60b538af0504d4926e633b9b4 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/443fec3dd9c1a2c60b538af0504d4926e633b9b4/socket.py
buf_len = self.__get_rbuf_len() while size < 0 or buf_len < size: recv_size = max(self._rbufsize, size - buf_len) data = self._sock.recv(recv_size) if not data: break buf_len += len(data) self._rbuf.append(data) data = ''.join(self._rbuf) self._rbuf = [ ] if buf_len > size and size >= 0:
if size < 0: if self._rbufsize <= 1: recv_size = self.default_bufsize else: recv_size = self._rbufsize while 1: data = self._sock.recv(recv_size) if not data: break self._rbuf.append(data) else: buf_len = self._get_rbuf_len() while buf_len < size: recv_size = max(self._rbufsize, size - buf_len) data = self._sock.recv(recv_size) if not data: break buf_len += len(data) self._rbuf.append(data) data = "".join(self._rbuf) self._rbuf = [] if 0 <= size < buf_len:
def read(self, size=-1): buf_len = self.__get_rbuf_len() while size < 0 or buf_len < size: recv_size = max(self._rbufsize, size - buf_len) data = self._sock.recv(recv_size) if not data: break buf_len += len(data) self._rbuf.append(data) # Clear the rbuf at the end so we're not affected by # an exception during a recv data = ''.join(self._rbuf) self._rbuf = [ ] if buf_len > size and size >= 0: self._rbuf.append(data[size:]) data = data[:size] return data
443fec3dd9c1a2c60b538af0504d4926e633b9b4 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/443fec3dd9c1a2c60b538af0504d4926e633b9b4/socket.py
index = -1 buf_len = self.__get_rbuf_len() if self._rbuf: index = min([x.find('\n') for x in self._rbuf]) while index < 0 and (size < 0 or buf_len < size): recv_size = max(self._rbufsize, size - buf_len) data = self._sock.recv(recv_size) if not data: break buf_len += len(data) self._rbuf.append(data) index = data.find('\n') data = ''.join(self._rbuf) self._rbuf = [ ] index = data.find('\n') if index >= 0: index += 1 elif buf_len > size: index = size else: index = buf_len self._rbuf.append(data[index:]) data = data[:index]
data_len = 0 for index, x in enumerate(self._rbuf): data_len += len(x) if '\n' in x or 0 <= size <= data_len: index += 1 data = "".join(self._rbuf[:index]) end = data.find('\n') if end < 0: end = len(data) else: end += 1 if 0 <= size < end: end = size data, rest = data[:end], data[end:] if rest: self._rbuf[:index] = [rest] else: del self._rbuf[:index] return data recv_size = self._rbufsize while 1: if size >= 0: recv_size = min(self._rbufsize, size - data_len) x = self._sock.recv(recv_size) if not x: break data_len += len(x) self._rbuf.append(x) if '\n' in x or 0 <= size <= data_len: break data = "".join(self._rbuf) end = data.find('\n') if end < 0: end = len(data) else: end += 1 if 0 <= size < end: end = size data, rest = data[:end], data[end:] if rest: self._rbuf = [rest] else: self._rbuf = []
def readline(self, size=-1): index = -1 buf_len = self.__get_rbuf_len() if self._rbuf: index = min([x.find('\n') for x in self._rbuf]) while index < 0 and (size < 0 or buf_len < size): recv_size = max(self._rbufsize, size - buf_len) data = self._sock.recv(recv_size) if not data: break buf_len += len(data) self._rbuf.append(data) index = data.find('\n') data = ''.join(self._rbuf) self._rbuf = [ ] index = data.find('\n') if index >= 0: index += 1 elif buf_len > size: index = size else: index = buf_len self._rbuf.append(data[index:]) data = data[:index] return data
443fec3dd9c1a2c60b538af0504d4926e633b9b4 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/443fec3dd9c1a2c60b538af0504d4926e633b9b4/socket.py
'<<run-module>>': ['<F5>'], '<<debug-module>>': ['<Control-F5>'],
'<<import-module>>': ['<F5>'], '<<run-script>>': ['<Control-F5>'],
def flush(self): pass
1f3de5d7b99190d3dda48349fa163e65e19153dc /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/1f3de5d7b99190d3dda48349fa163e65e19153dc/ScriptBinding.py
('Run module', '<<run-module>>'), ('Debug module', '<<debug-module>>'),
('Import module', '<<import-module>>'), ('Run script', '<<run-script>>'),
def flush(self): pass
1f3de5d7b99190d3dda48349fa163e65e19153dc /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/1f3de5d7b99190d3dda48349fa163e65e19153dc/ScriptBinding.py
def run_module_event(self, event, debugger=None):
def import_module_event(self, event): filename = self.getfilename() if not filename: return modname, ext = os.path.splitext(os.path.basename(filename)) if sys.modules.has_key(modname): mod = sys.modules[modname] else: mod = imp.new_module(modname) sys.modules[modname] = mod mod.__file__ = filename setattr(sys.modules['__main__'], modname, mod) dir = os.path.dirname(filename) dir = os.path.normpath(os.path.abspath(dir)) if dir not in sys.path: sys.path.insert(0, dir) flist = self.editwin.flist shell = flist.open_shell() interp = shell.interp interp.runcode("reload(%s)" % modname) def run_script_event(self, event): filename = self.getfilename() if not filename: return flist = self.editwin.flist shell = flist.open_shell() interp = shell.interp interp.execfile(filename) def getfilename(self):
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 filename = self.editwin.io.filename if not filename: tkMessageBox.showerror("No file name", "This window has no file name", master=self.editwin.text) self.editwin.text.focus_set() return modname, ext = os.path.splitext(os.path.basename(filename)) if sys.modules.has_key(modname): mod = sys.modules[modname] else: mod = imp.new_module(modname) sys.modules[modname] = mod 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() linecache.checkcache() traceback.print_exc() if not debugger and \ self.editwin.getvar("<<toggle-jit-stack-viewer>>"): from StackViewer import StackBrowser sv = StackBrowser(self.root, self.flist) finally: sys.stdout = saveout finally: sys.stderr = saveerr
1f3de5d7b99190d3dda48349fa163e65e19153dc /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/1f3de5d7b99190d3dda48349fa163e65e19153dc/ScriptBinding.py
modname, ext = os.path.splitext(os.path.basename(filename)) if sys.modules.has_key(modname): mod = sys.modules[modname] else: mod = imp.new_module(modname) sys.modules[modname] = mod 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() linecache.checkcache() traceback.print_exc() if not debugger and \ self.editwin.getvar("<<toggle-jit-stack-viewer>>"): from StackViewer import StackBrowser sv = StackBrowser(self.root, self.flist) finally: sys.stdout = saveout finally: sys.stderr = saveerr def debug_module_event(self, event): import Debugger debugger = Debugger.Debugger(self) self.run_module_event(event, debugger) def close_debugger(self): pass
return filename
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 filename = self.editwin.io.filename if not filename: tkMessageBox.showerror("No file name", "This window has no file name", master=self.editwin.text) self.editwin.text.focus_set() return modname, ext = os.path.splitext(os.path.basename(filename)) if sys.modules.has_key(modname): mod = sys.modules[modname] else: mod = imp.new_module(modname) sys.modules[modname] = mod 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() linecache.checkcache() traceback.print_exc() if not debugger and \ self.editwin.getvar("<<toggle-jit-stack-viewer>>"): from StackViewer import StackBrowser sv = StackBrowser(self.root, self.flist) finally: sys.stdout = saveout finally: sys.stderr = saveerr
1f3de5d7b99190d3dda48349fa163e65e19153dc /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/1f3de5d7b99190d3dda48349fa163e65e19153dc/ScriptBinding.py
timestamp = 1000000000 utc = FixedOffset(0, "utc", 0) expected = datetime(2001, 9, 9, 1, 46, 40) got = datetime.utcfromtimestamp(timestamp) self.failUnless(abs(got - expected) < timedelta(minutes=1)) est = FixedOffset(-5*60, "est", 0) expected -= timedelta(hours=5) got = datetime.fromtimestamp(timestamp, est).replace(tzinfo=None) self.failUnless(abs(got - expected) < timedelta(minutes=1))
timestamp = 1000000000 utcdatetime = datetime.utcfromtimestamp(timestamp) utcoffset = timedelta(hours=-15, minutes=39) tz = FixedOffset(utcoffset, "tz", 0) expected = utcdatetime + utcoffset got = datetime.fromtimestamp(timestamp, tz) self.assertEqual(expected, got.replace(tzinfo=None))
def test_tzinfo_fromtimestamp(self): import time meth = self.theclass.fromtimestamp ts = time.time() # Ensure it doesn't require tzinfo (i.e., that this doesn't blow up). base = meth(ts) # Try with and without naming the keyword. off42 = FixedOffset(42, "42") another = meth(ts, off42) again = meth(ts, tz=off42) self.failUnless(another.tzinfo is again.tzinfo) self.assertEqual(another.utcoffset(), timedelta(minutes=42)) # Bad argument with and w/o naming the keyword. self.assertRaises(TypeError, meth, ts, 16) self.assertRaises(TypeError, meth, ts, tzinfo=16) # Bad keyword name. self.assertRaises(TypeError, meth, ts, tinfo=off42) # Too many args. self.assertRaises(TypeError, meth, ts, off42, off42) # Too few args. self.assertRaises(TypeError, meth)
844076122e5d7a5aeab8089dd2fb91bfd47596a2 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/844076122e5d7a5aeab8089dd2fb91bfd47596a2/test_datetime.py
if version[:11] == '$Revision$': version = version[11:-1]
if version[:11] == '$' + 'Revision: ' and version[-1:] == '$': version = strip(version[11:-1])
def docmodule(self, object): """Produce HTML documentation for a module object.""" name = object.__name__ result = '' head = '<br><big><big><strong>&nbsp;%s</strong></big></big>' % name try: file = inspect.getsourcefile(object) filelink = '<a href="file:%s">%s</a>' % (file, file) except TypeError: filelink = '(built-in)' info = [] if hasattr(object, '__version__'): version = str(object.__version__) if version[:11] == '$Revision$': version = version[11:-1] info.append('version: %s' % self.escape(version)) if hasattr(object, '__date__'): info.append(self.escape(str(object.__date__))) if info: head = head + ' (%s)' % join(info, ', ') result = result + self.heading( head, '#ffffff', '#7799ee', '<a href=".">index</a><br>' + filelink)
40c49919fb7385d4b7e2e2647be157873f75ab26 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/40c49919fb7385d4b7e2e2647be157873f75ab26/pydoc.py
exceptions, this sets `sender' to the string that the SMTP refused
exceptions, this sets `sender' to the string that the SMTP refused.
def __init__(self, code, msg): self.smtp_code = code self.smtp_error = msg self.args = (code, msg)
d25c1b73d2c8ab561476de849026aef7bd25808e /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/d25c1b73d2c8ab561476de849026aef7bd25808e/smtplib.py
"""All recipient addresses refused.
"""All recipient addresses refused.
def __init__(self, code, msg, sender): self.smtp_code = code self.smtp_error = msg self.sender = sender self.args = (code, msg, sender)
d25c1b73d2c8ab561476de849026aef7bd25808e /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/d25c1b73d2c8ab561476de849026aef7bd25808e/smtplib.py
"""Error during connection establishment"""
"""Error during connection establishment."""
def __init__(self, recipients): self.recipients = recipients self.args = ( recipients,)
d25c1b73d2c8ab561476de849026aef7bd25808e /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/d25c1b73d2c8ab561476de849026aef7bd25808e/smtplib.py
"""The server refused our HELO reply"""
"""The server refused our HELO reply."""
def __init__(self, recipients): self.recipients = recipients self.args = ( recipients,)
d25c1b73d2c8ab561476de849026aef7bd25808e /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/d25c1b73d2c8ab561476de849026aef7bd25808e/smtplib.py
Double leading '.', and change Unix newline '\n', or Mac '\r' into
Double leading '.', and change Unix newline '\\n', or Mac '\\r' into
def quotedata(data): """Quote data for email. Double leading '.', and change Unix newline '\n', or Mac '\r' into Internet CRLF end-of-line. """ return re.sub(r'(?m)^\.', '..', re.sub(r'(?:\r\n|\n|\r(?!\n))', CRLF, data))
d25c1b73d2c8ab561476de849026aef7bd25808e /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/d25c1b73d2c8ab561476de849026aef7bd25808e/smtplib.py
This is the message given by the server in responce to the
This is the message given by the server in response to the
def quotedata(data): """Quote data for email. Double leading '.', and change Unix newline '\n', or Mac '\r' into Internet CRLF end-of-line. """ return re.sub(r'(?m)^\.', '..', re.sub(r'(?:\r\n|\n|\r(?!\n))', CRLF, data))
d25c1b73d2c8ab561476de849026aef7bd25808e /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/d25c1b73d2c8ab561476de849026aef7bd25808e/smtplib.py
This is the message given by the server in responce to the
This is the message given by the server in response to the
def quotedata(data): """Quote data for email. Double leading '.', and change Unix newline '\n', or Mac '\r' into Internet CRLF end-of-line. """ return re.sub(r'(?m)^\.', '..', re.sub(r'(?:\r\n|\n|\r(?!\n))', CRLF, data))
d25c1b73d2c8ab561476de849026aef7bd25808e /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/d25c1b73d2c8ab561476de849026aef7bd25808e/smtplib.py
will _after you do an EHLO command_, contain the names of the SMTP service extentions this server supports, and their
will _after you do an EHLO command_, contain the names of the SMTP service extensions this server supports, and their
def quotedata(data): """Quote data for email. Double leading '.', and change Unix newline '\n', or Mac '\r' into Internet CRLF end-of-line. """ return re.sub(r'(?m)^\.', '..', re.sub(r'(?:\r\n|\n|\r(?!\n))', CRLF, data))
d25c1b73d2c8ab561476de849026aef7bd25808e /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/d25c1b73d2c8ab561476de849026aef7bd25808e/smtplib.py
Note, all extention names are mapped to lower case in the
Note, all extension names are mapped to lower case in the
def quotedata(data): """Quote data for email. Double leading '.', and change Unix newline '\n', or Mac '\r' into Internet CRLF end-of-line. """ return re.sub(r'(?m)^\.', '..', re.sub(r'(?:\r\n|\n|\r(?!\n))', CRLF, data))
d25c1b73d2c8ab561476de849026aef7bd25808e /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/d25c1b73d2c8ab561476de849026aef7bd25808e/smtplib.py
For method docs, see each method's docstrings. In general, there is a method of the same name to perform each SMTP command, and there is a method called 'sendmail' that will do an entire mail transaction. """
See each method's docstrings for details. In general, there is a method of the same name to perform each SMTP command. There is also a method called 'sendmail' that will do an entire mail transaction. """
def quotedata(data): """Quote data for email. Double leading '.', and change Unix newline '\n', or Mac '\r' into Internet CRLF end-of-line. """ return re.sub(r'(?m)^\.', '..', re.sub(r'(?:\r\n|\n|\r(?!\n))', CRLF, data))
d25c1b73d2c8ab561476de849026aef7bd25808e /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/d25c1b73d2c8ab561476de849026aef7bd25808e/smtplib.py
By default, smtplib.SMTP_PORT is used. An SMTPConnectError is raised if the specified `host' doesn't respond correctly.
By default, smtplib.SMTP_PORT is used. An SMTPConnectError is raised if the specified `host' doesn't respond correctly.
def __init__(self, host = '', port = 0): """Initialize a new instance.
d25c1b73d2c8ab561476de849026aef7bd25808e /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/d25c1b73d2c8ab561476de849026aef7bd25808e/smtplib.py
one recipient. It returns a dictionary, with one entry for each recipient that was refused. Each entry contains a tuple of the SMTP error code and the accompanying error message sent by the server.
one recipient. It returns a dictionary, with one entry for each recipient that was refused. Each entry contains a tuple of the SMTP error code and the accompanying error message sent by the server.
def sendmail(self, from_addr, to_addrs, msg, mail_options=[], rcpt_options=[]): """This command performs an entire mail transaction.
d25c1b73d2c8ab561476de849026aef7bd25808e /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/d25c1b73d2c8ab561476de849026aef7bd25808e/smtplib.py
SMTPRecipientsRefused The server rejected for ALL recipients
SMTPRecipientsRefused The server rejected ALL recipients
def sendmail(self, from_addr, to_addrs, msg, mail_options=[], rcpt_options=[]): """This command performs an entire mail transaction.
d25c1b73d2c8ab561476de849026aef7bd25808e /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/d25c1b73d2c8ab561476de849026aef7bd25808e/smtplib.py
550. If all addresses are accepted, then the method will return an
550. If all addresses are accepted, then the method will return an
def sendmail(self, from_addr, to_addrs, msg, mail_options=[], rcpt_options=[]): """This command performs an entire mail transaction.
d25c1b73d2c8ab561476de849026aef7bd25808e /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/d25c1b73d2c8ab561476de849026aef7bd25808e/smtplib.py
test(r"""sre.match("\x%02x" % i, chr(i)) != None""", 1) test(r"""sre.match("\x%02x0" % i, chr(i)+"0") != None""", 1) test(r"""sre.match("\x%02xz" % i, chr(i)+"z") != None""", 1)
test(r"""sre.match(r"\x%02x" % i, chr(i)) != None""", 1) test(r"""sre.match(r"\x%02x0" % i, chr(i)+"0") != None""", 1) test(r"""sre.match(r"\x%02xz" % i, chr(i)+"z") != None""", 1)
def test(expression, result, exception=None): try: r = eval(expression) except: if exception: if not isinstance(sys.exc_value, exception): print expression, "FAILED" # display name, not actual value if exception is sre.error: print "expected", "sre.error" else: print "expected", exception.__name__ print "got", sys.exc_type.__name__, str(sys.exc_value) else: print expression, "FAILED" traceback.print_exc(file=sys.stdout) else: if exception: print expression, "FAILED" if exception is sre.error: print "expected", "sre.error" else: print "expected", exception.__name__ print "got result", repr(r) else: if r != result: print expression, "FAILED" print "expected", repr(result) print "got result", repr(r)
acee48628d6df976170c289227def0644cf2dbf5 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/acee48628d6df976170c289227def0644cf2dbf5/test_sre.py
try:
if old:
def __calc_date_time(self): # Set self.__date_time, self.__date, & self.__time by using # time.strftime().
62fe75509c905bee1181fed9b6714e0de27ff5d4 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/62fe75509c905bee1181fed9b6714e0de27ff5d4/_strptime.py
except ValueError: pass
def __calc_date_time(self): # Set self.__date_time, self.__date, & self.__time by using # time.strftime().
62fe75509c905bee1181fed9b6714e0de27ff5d4 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/62fe75509c905bee1181fed9b6714e0de27ff5d4/_strptime.py
"""Convert a list to a regex string for matching directive."""
"""Convert a list to a regex string for matching a directive."""
def __seqToRE(self, to_convert, directive): """Convert a list to a regex string for matching directive.""" def sorter(a, b): """Sort based on length.
62fe75509c905bee1181fed9b6714e0de27ff5d4 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/62fe75509c905bee1181fed9b6714e0de27ff5d4/_strptime.py
def strptime(data_string, format="%a %b %d %H:%M:%S %Y"): """Return a time struct based on the input data and the format string. The format argument may either be a regular expression object compiled by strptime(), or a format string. If False is passed in for data_string then the re object calculated for format will be returned. The re object must be used with the same locale as was used to compile the re object. """ locale_time = LocaleTime() if isinstance(format, RegexpType): if format.pattern.find(locale_time.lang) == -1: raise TypeError("re object not created with same language as " "LocaleTime instance") else: compiled_re = format else: compiled_re = TimeRE(locale_time).compile(format) if data_string is False: return compiled_re else: found = compiled_re.match(data_string) if not found: raise ValueError("time data did not match format") year = month = day = hour = minute = second = weekday = julian = tz =-1 found_dict = found.groupdict() for group_key in found_dict.iterkeys(): if group_key == 'y': year = int("%s%s" % (time.strftime("%Y")[:-2], found_dict['y'])) elif group_key == 'Y': year = int(found_dict['Y']) elif group_key == 'm': month = int(found_dict['m']) elif group_key == 'B': month = _insensitiveindex(locale_time.f_month, found_dict['B']) elif group_key == 'b': month = _insensitiveindex(locale_time.a_month, found_dict['b']) elif group_key == 'd': day = int(found_dict['d']) elif group_key is 'H': hour = int(found_dict['H']) elif group_key == 'I': hour = int(found_dict['I']) ampm = found_dict.get('p', '').lower() # If there was no AM/PM indicator, we'll treat this like AM if ampm in ('', locale_time.am_pm[0].lower()): # We're in AM so the hour is correct unless we're # looking at 12 midnight. # 12 midnight == 12 AM == hour 0 if hour == 12: hour = 0 elif ampm == locale_time.am_pm[1].lower(): # We're in PM so we need to add 12 to the hour unless # we're looking at 12 noon. # 12 noon == 12 PM == hour 12 if hour != 12: hour += 12 elif group_key == 'M': minute = int(found_dict['M']) elif group_key == 'S': second = int(found_dict['S']) elif group_key == 'A': weekday = _insensitiveindex(locale_time.f_weekday, found_dict['A']) elif group_key == 'a': weekday = _insensitiveindex(locale_time.a_weekday, found_dict['a']) elif group_key == 'w': weekday = int(found_dict['w']) if weekday == 0: weekday = 6 else: weekday -= 1 elif group_key == 'j': julian = int(found_dict['j']) elif group_key == 'Z': found_zone = found_dict['Z'].lower() if locale_time.timezone[0] == locale_time.timezone[1]: pass #Deals with bad locale setup where timezone info is # the same; first found on FreeBSD 4.4 -current elif locale_time.timezone[0].lower() == found_zone: tz = 0 elif locale_time.timezone[1].lower() == found_zone: tz = 1 elif locale_time.timezone[2].lower() == found_zone: tz = 0 #XXX <bc>: If calculating fxns are never exposed to the general # populous then just inline calculations. if julian == -1 and year != -1 and month != -1 and day != -1: julian = julianday(year, month, day) if (month == -1 or day == -1) and julian != -1 and year != -1: year, month, day = gregorian(julian, year) if weekday == -1 and year != -1 and month != -1 and day != -1: weekday = dayofweek(year, month, day) return time.struct_time( (year,month,day,hour,minute,second,weekday, julian,tz))
62fe75509c905bee1181fed9b6714e0de27ff5d4 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/62fe75509c905bee1181fed9b6714e0de27ff5d4/_strptime.py
Output("self->ob_type->tp_base->tp_dealloc((PyObject *)self);")
Output("%s.tp_dealloc((PyObject *)self);", self.basetype)
def outputDealloc(self): Output() Output("static void %s_dealloc(%s *self)", self.prefix, self.objecttype) OutLbrace() self.outputCleanupStructMembers() if self.basetype: Output("self->ob_type->tp_base->tp_dealloc((PyObject *)self);") elif hasattr(self, 'output_tp_free'): # This is a new-style object with tp_free slot Output("self->ob_type->tp_free((PyObject *)self);") else: Output("PyObject_Free((PyObject *)self);") OutRbrace()
35f82d7051093ffe3ab181a05ed61982560149be /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/35f82d7051093ffe3ab181a05ed61982560149be/bgenObjectDefinition.py
Output("if ((_self = type->tp_alloc(type, 0)) == NULL) return NULL;")
if self.basetype: Output("if (%s.tp_new)", self.basetype) OutLbrace() Output("if ( (*%s.tp_init)(_self, _args, _kwds) == NULL) return NULL;", self.basetype) Dedent() Output("} else {") Indent() Output("if ((_self = type->tp_alloc(type, 0)) == NULL) return NULL;") OutRbrace() else: Output("if ((_self = type->tp_alloc(type, 0)) == NULL) return NULL;")
def output_tp_newBody(self): Output("PyObject *_self;"); Output("%s itself;", self.itselftype); Output("char *kw[] = {\"itself\", 0};") Output() Output("if (!PyArg_ParseTupleAndKeywords(_args, _kwds, \"O&\", kw, %s_Convert, &itself)) return NULL;", self.prefix); Output("if ((_self = type->tp_alloc(type, 0)) == NULL) return NULL;") Output("((%s *)_self)->ob_itself = itself;", self.objecttype) Output("return _self;")
35f82d7051093ffe3ab181a05ed61982560149be /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/35f82d7051093ffe3ab181a05ed61982560149be/bgenObjectDefinition.py
if self.elements is XMLParser.elements: self.__fixelements()
def __init__(self): self.reset() if self.elements is XMLParser.elements: self.__fixelements()
cc2c291b7fdb2eb4a46bdce264931bd5adeaff38 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/cc2c291b7fdb2eb4a46bdce264931bd5adeaff38/xmllib.py
self.syntax_error('reference to unknown entity')
self.syntax_error("reference to unknown entity `&%s;'" % str)
def translate_references(self, data, all = 1): i = 0 while 1: res = amp.search(data, i) if res is None: return data res = ref.match(data, res.start(0)) if res is None: self.syntax_error("bogus `&'") i =i+1 continue i = res.end(0) if data[i - 1] != ';': self.syntax_error("`;' missing after entity/char reference") i = i-1 str = res.group(1) pre = data[:res.start(0)] post = data[i:] if str[0] == '#': if str[1] == 'x': str = chr(string.atoi(str[2:], 16)) else: str = chr(string.atoi(str[1:])) data = pre + str + post i = res.start(0)+len(str) elif all: if self.entitydefs.has_key(str): data = pre + self.entitydefs[str] + post i = res.start(0) # rescan substituted text else: self.syntax_error('reference to unknown entity') # can't do it, so keep the entity ref in data = pre + '&' + str + ';' + post i = res.start(0) + len(str) + 2 else: # just translating character references pass # i is already postioned correctly
cc2c291b7fdb2eb4a46bdce264931bd5adeaff38 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/cc2c291b7fdb2eb4a46bdce264931bd5adeaff38/xmllib.py
self.syntax_error('reference to unknown entity')
self.syntax_error("reference to unknown entity `&%s;'" % name)
def goahead(self, end): rawdata = self.rawdata i = 0 n = len(rawdata) while i < n: if i > 0: self.__at_start = 0 if self.nomoretags: data = rawdata[i:n] self.handle_data(data) self.lineno = self.lineno + string.count(data, '\n') i = n break res = interesting.search(rawdata, i) if res: j = res.start(0) else: j = n if i < j: data = rawdata[i:j] if self.__at_start and space.match(data) is None: self.syntax_error('illegal data at start of file') self.__at_start = 0 if not self.stack and space.match(data) is None: self.syntax_error('data not in content') if illegal.search(data): self.syntax_error('illegal character in content') self.handle_data(data) self.lineno = self.lineno + string.count(data, '\n') i = j if i == n: break if rawdata[i] == '<': if starttagopen.match(rawdata, i): if self.literal: data = rawdata[i] self.handle_data(data) self.lineno = self.lineno + string.count(data, '\n') i = i+1 continue k = self.parse_starttag(i) if k < 0: break self.__seen_starttag = 1 self.lineno = self.lineno + string.count(rawdata[i:k], '\n') i = k continue if endtagopen.match(rawdata, i): k = self.parse_endtag(i) if k < 0: break self.lineno = self.lineno + string.count(rawdata[i:k], '\n') i = k continue if commentopen.match(rawdata, i): if self.literal: data = rawdata[i] self.handle_data(data) self.lineno = self.lineno + string.count(data, '\n') i = i+1 continue k = self.parse_comment(i) if k < 0: break self.lineno = self.lineno + string.count(rawdata[i:k], '\n') i = k continue if cdataopen.match(rawdata, i): k = self.parse_cdata(i) if k < 0: break self.lineno = self.lineno + string.count(rawdata[i:i], '\n') i = k continue res = xmldecl.match(rawdata, i) if res: if not self.__at_start: self.syntax_error("<?xml?> declaration not at start of document") version, encoding, standalone = res.group('version', 'encoding', 'standalone') if version[1:-1] != '1.0': raise RuntimeError, 'only XML version 1.0 supported' if encoding: encoding = encoding[1:-1] if standalone: standalone = standalone[1:-1] self.handle_xml(encoding, standalone) i = res.end(0) continue res = procopen.match(rawdata, i) if res: k = self.parse_proc(i) if k < 0: break self.lineno = self.lineno + string.count(rawdata[i:k], '\n') i = k continue res = doctype.match(rawdata, i) if res: if self.literal: data = rawdata[i] self.handle_data(data) self.lineno = self.lineno + string.count(data, '\n') i = i+1 continue if self.__seen_doctype: self.syntax_error('multiple DOCTYPE elements') if self.__seen_starttag: self.syntax_error('DOCTYPE not at beginning of document') k = self.parse_doctype(res) if k < 0: break self.__seen_doctype = res.group('name') self.lineno = self.lineno + string.count(rawdata[i:k], '\n') i = k continue elif rawdata[i] == '&': if self.literal: data = rawdata[i] self.handle_data(data) i = i+1 continue res = charref.match(rawdata, i) if res is not None: i = res.end(0) if rawdata[i-1] != ';': self.syntax_error("`;' missing in charref") i = i-1 if not self.stack: self.syntax_error('data not in content') self.handle_charref(res.group('char')[:-1]) self.lineno = self.lineno + string.count(res.group(0), '\n') continue res = entityref.match(rawdata, i) if res is not None: i = res.end(0) if rawdata[i-1] != ';': self.syntax_error("`;' missing in entityref") i = i-1 name = res.group('name') if self.entitydefs.has_key(name): self.rawdata = rawdata = rawdata[:res.start(0)] + self.entitydefs[name] + rawdata[i:] n = len(rawdata) i = res.start(0) else: self.syntax_error('reference to unknown entity') self.unknown_entityref(name) self.lineno = self.lineno + string.count(res.group(0), '\n') continue elif rawdata[i] == ']': if self.literal: data = rawdata[i] self.handle_data(data) i = i+1 continue if n-i < 3: break if cdataclose.match(rawdata, i): self.syntax_error("bogus `]]>'") self.handle_data(rawdata[i]) i = i+1 continue else: raise RuntimeError, 'neither < nor & ??' # We get here only if incomplete matches but # nothing else break # end while if i > 0: self.__at_start = 0 if end and i < n: data = rawdata[i] self.syntax_error("bogus `%s'" % data) if illegal.search(data): self.syntax_error('illegal character in content') self.handle_data(data) self.lineno = self.lineno + string.count(data, '\n') self.rawdata = rawdata[i+1:] return self.goahead(end) self.rawdata = rawdata[i:] if end: if not self.__seen_starttag: self.syntax_error('no elements in file') if self.stack: self.syntax_error('missing end tags') while self.stack: self.finish_endtag(self.stack[-1][0])
cc2c291b7fdb2eb4a46bdce264931bd5adeaff38 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/cc2c291b7fdb2eb4a46bdce264931bd5adeaff38/xmllib.py
return getint(
return self.tk.getint(
def winfo_id(self): return getint( self.tk.call('winfo', 'id', self._w))
cef4c844df324979f25ffec172c141a5d5c4672e /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/cef4c844df324979f25ffec172c141a5d5c4672e/Tkinter.py
if hasattr(package, "__loader__"):
if (hasattr(package, "__loader__") and hasattr(package.__loader__, '_files')):
def find_package_modules(package, mask): import fnmatch if hasattr(package, "__loader__"): path = package.__name__.replace(".", os.path.sep) mask = os.path.join(path, mask) for fnm in package.__loader__._files.iterkeys(): if fnmatch.fnmatchcase(fnm, mask): yield os.path.splitext(fnm)[0].replace(os.path.sep, ".") else: path = package.__path__[0] for fnm in os.listdir(path): if fnmatch.fnmatchcase(fnm, mask): yield "%s.%s" % (package.__name__, os.path.splitext(fnm)[0])
8211297a7e4d18833b61170f65a1c47183e348c8 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/8211297a7e4d18833b61170f65a1c47183e348c8/__init__.py
print '%s == %s: OK' % (repr(a), repr(b))
print '%s == %s: OK' % (a, b)
def check(a, b): if a != b: print '*** check failed: %s != %s' % (repr(a), repr(b)) else: print '%s == %s: OK' % (repr(a), repr(b))
84cc9bf722a6261fe6603e67cde38784e533e8b9 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/84cc9bf722a6261fe6603e67cde38784e533e8b9/test_charmapcodec.py
print 'Option', opt, 'require integer argument'
print 'Option', opt, 'requires integer argument'
def main(): global debug, looping, magnify, mindelta, nowait, quiet, regen, speed global threading, xoff, yoff # Parse command line try: opts, args = getopt.getopt(sys.argv[1:], 'M:dlm:nqr:s:tx:y:') except getopt.error, msg: sys.stdout = sys.stderr print 'Error:', msg, '\n' help() sys.exit(2) # Interpret options try: for opt, arg in opts: if opt == '-M': magnify = float(eval(arg)) if opt == '-d': debug = debug + 1 if opt == '-l': looping = 1 if opt == '-m': mindelta = string.atoi(arg) if opt == '-n': nowait = 1 if opt == '-q': quiet = 1 if opt == '-r': regen = string.atoi(arg) if opt == '-s': try: speed = float(eval(arg)) except: sys.stdout = sys.stderr print 'Option -s needs float argument' sys.exit(2) if opt == '-t': try: import thread threading = 1 except ImportError: print 'Sorry, this version of Python', print 'does not support threads:', print '-t ignored' if opt == '-x': xoff = string.atoi(arg) if opt == '-y': yoff = string.atoi(arg) except string.atoi_error: sys.stdout = sys.stderr print 'Option', opt, 'require integer argument' sys.exit(2) # Check validity of certain options combinations if nowait and looping: print 'Warning: -n and -l are mutually exclusive; -n ignored' nowait = 0 if xoff <> None and yoff == None: print 'Warning: -x without -y ignored' if xoff == None and yoff <> None: print 'Warning: -y without -x ignored' # Process all files if not args: args = ['film.video'] sts = 0 for filename in args: sts = (process(filename) or sts) # Exit with proper exit status sys.exit(sts)
42e9be455952cc4fd69f8f7143cd363b58ef6b9b /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/42e9be455952cc4fd69f8f7143cd363b58ef6b9b/Vplay.py
if string.find (args[i], ' ') == -1:
if string.find (args[i], ' ') != -1:
def _nt_quote_args (args): """Obscure quoting command line arguments on NT. Simply quote every argument which contains blanks.""" # XXX this doesn't seem very robust to me -- but if the Windows guys # say it'll work, I guess I'll have to accept it. (What if an arg # contains quotes? What other magic characters, other than spaces, # have to be escaped? Is there an escaping mechanism other than # quoting?) for i in range (len (args)): if string.find (args[i], ' ') == -1: args[i] = '"%s"' % args[i]
e2a33079e9325781dcbc549921664c6ff92d86b9 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/e2a33079e9325781dcbc549921664c6ff92d86b9/spawn.py
return
def _nt_quote_args (args): """Obscure quoting command line arguments on NT. Simply quote every argument which contains blanks.""" # XXX this doesn't seem very robust to me -- but if the Windows guys # say it'll work, I guess I'll have to accept it. (What if an arg # contains quotes? What other magic characters, other than spaces, # have to be escaped? Is there an escaping mechanism other than # quoting?) for i in range (len (args)): if string.find (args[i], ' ') == -1: args[i] = '"%s"' % args[i]
e2a33079e9325781dcbc549921664c6ff92d86b9 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/e2a33079e9325781dcbc549921664c6ff92d86b9/spawn.py
+ If you continue a line via backslashing in an interactive session, or for any other reason use a backslash, you need to double the backslash in the docstring version. This is simply because you're in a string, and so the backslash must be escaped for it to survive intact. Like: >>> if "yes" == \\ ... "y" + \\ ... "es": ... print 'yes' yes
+ If you continue a line via backslashing in an interactive session, or for any other reason use a backslash, you should use a raw docstring, which will preserve your backslahses exactly as you type them: >>> def f(x): ... r'''Backslashes in a raw docstring: m\n''' >>> print f.__doc__ Backslashes in a raw docstring: m\n Otherwise, the backslash will be interpreted as part of the string. E.g., the "\n" above would be interpreted as a newline character. Alternatively, you can double each backslash in the doctest version (and not use a raw string): >>> def f(x): ... '''Backslashes in a raw docstring: m\\n''' >>> print f.__doc__ Backslashes in a raw docstring: m\n
def _test(): import doctest import sys verbose = "-v" in sys.argv for mod in modules: doctest.testmod(mod, verbose=verbose, report=0) doctest.master.summarize()
92816de18e3456f8304a1aaa6f28b151858a6e5d /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/92816de18e3456f8304a1aaa6f28b151858a6e5d/doctest.py
if (inspect.getmodule(value) or object) is object:
if (all is not None or (inspect.getmodule(value) or object) is object):
def docmodule(self, object, name=None, mod=None, *ignored): """Produce HTML documentation for a module object.""" name = object.__name__ # ignore the passed-in name try: all = object.__all__ except AttributeError: all = None parts = split(name, '.') links = [] for i in range(len(parts)-1): links.append( '<a href="%s.html"><font color="#ffffff">%s</font></a>' % (join(parts[:i+1], '.'), parts[i])) linkedname = join(links + parts[-1:], '.') head = '<big><big><strong>%s</strong></big></big>' % linkedname try: path = inspect.getabsfile(object) url = path if sys.platform == 'win32': import nturl2path url = nturl2path.pathname2url(path) filelink = '<a href="file:%s">%s</a>' % (url, path) except TypeError: filelink = '(built-in)' info = [] if hasattr(object, '__version__'): version = str(object.__version__) if version[:11] == '$' + 'Revision: ' and version[-1:] == '$': version = strip(version[11:-1]) info.append('version %s' % self.escape(version)) if hasattr(object, '__date__'): info.append(self.escape(str(object.__date__))) if info: head = head + ' (%s)' % join(info, ', ') docloc = self.getdocloc(object) if docloc is not None: docloc = '<br><a href="%(docloc)s">Module Docs</a>' % locals() else: docloc = '' result = self.heading( head, '#ffffff', '#7799ee', '<a href=".">index</a><br>' + filelink + docloc)
4c11f6088af5c2b3b97ed4352df3e39c4c7c9732 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/4c11f6088af5c2b3b97ed4352df3e39c4c7c9732/pydoc.py
if inspect.isbuiltin(value) or inspect.getmodule(value) is object:
if (all is not None or inspect.isbuiltin(value) or inspect.getmodule(value) is object):
def docmodule(self, object, name=None, mod=None, *ignored): """Produce HTML documentation for a module object.""" name = object.__name__ # ignore the passed-in name try: all = object.__all__ except AttributeError: all = None parts = split(name, '.') links = [] for i in range(len(parts)-1): links.append( '<a href="%s.html"><font color="#ffffff">%s</font></a>' % (join(parts[:i+1], '.'), parts[i])) linkedname = join(links + parts[-1:], '.') head = '<big><big><strong>%s</strong></big></big>' % linkedname try: path = inspect.getabsfile(object) url = path if sys.platform == 'win32': import nturl2path url = nturl2path.pathname2url(path) filelink = '<a href="file:%s">%s</a>' % (url, path) except TypeError: filelink = '(built-in)' info = [] if hasattr(object, '__version__'): version = str(object.__version__) if version[:11] == '$' + 'Revision: ' and version[-1:] == '$': version = strip(version[11:-1]) info.append('version %s' % self.escape(version)) if hasattr(object, '__date__'): info.append(self.escape(str(object.__date__))) if info: head = head + ' (%s)' % join(info, ', ') docloc = self.getdocloc(object) if docloc is not None: docloc = '<br><a href="%(docloc)s">Module Docs</a>' % locals() else: docloc = '' result = self.heading( head, '#ffffff', '#7799ee', '<a href=".">index</a><br>' + filelink + docloc)
4c11f6088af5c2b3b97ed4352df3e39c4c7c9732 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/4c11f6088af5c2b3b97ed4352df3e39c4c7c9732/pydoc.py
if (inspect.getmodule(value) or object) is object:
if (all is not None or (inspect.getmodule(value) or object) is object):
def docmodule(self, object, name=None, mod=None): """Produce text documentation for a given module object.""" name = object.__name__ # ignore the passed-in name synop, desc = splitdoc(getdoc(object)) result = self.section('NAME', name + (synop and ' - ' + synop))
4c11f6088af5c2b3b97ed4352df3e39c4c7c9732 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/4c11f6088af5c2b3b97ed4352df3e39c4c7c9732/pydoc.py
if inspect.isbuiltin(value) or inspect.getmodule(value) is object:
if (all is not None or inspect.isbuiltin(value) or inspect.getmodule(value) is object):
def docmodule(self, object, name=None, mod=None): """Produce text documentation for a given module object.""" name = object.__name__ # ignore the passed-in name synop, desc = splitdoc(getdoc(object)) result = self.section('NAME', name + (synop and ' - ' + synop))
4c11f6088af5c2b3b97ed4352df3e39c4c7c9732 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/4c11f6088af5c2b3b97ed4352df3e39c4c7c9732/pydoc.py
self._prepareInstall(pkg, force, recursive)
self._prepareInstall(pkg, False, recursive)
def _prepareInstall(self, package, force=0, recursive=1): """Internal routine, recursive engine for prepareInstall. Test whether the package is installed and (if not installed or if force==1) prepend it to the temporary todo list and call ourselves recursively on all prerequisites.""" if not force: status, message = package.installed() if status == "yes": return if package in self._todo or package in self._curtodo: return self._curtodo.insert(0, package) if not recursive: return prereqs = package.prerequisites() for pkg, descr in prereqs: if pkg: self._prepareInstall(pkg, force, recursive) else: self._curmessages.append("Problem with dependency: %s" % descr)
0576d0a48a5111fef529732830db2e60102406f7 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/0576d0a48a5111fef529732830db2e60102406f7/pimp.py
print "Failed", name
print "Passed", name
def confirm(outcome, name): global tests tests = tests + 1 if outcome: if verbose: print "Failed", name else: failures.append(name)
09e2cb0ba70aeb52bf6562120103573d7f65cbd6 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/09e2cb0ba70aeb52bf6562120103573d7f65cbd6/test_sax.py
try: class C(bool): pass except TypeError: pass else: raise TestFailed, "bool should not be subclassable" try: int.__new__(bool, 0) except TypeError: pass else: raise TestFailed, "should not be able to create new bool instances" fo = open(TESTFN, "wb") print >> fo, False, True fo.close() fo = open(TESTFN, "rb") vereq(fo.read(), 'False True\n') fo.close() os.remove(TESTFN) vereq(str(False), 'False') vereq(str(True), 'True') vereq(repr(False), 'False') vereq(repr(True), 'True') vereq(eval(repr(False)), False) vereq(eval(repr(True)), True) vereq(int(False), 0) verisnot(int(False), False) vereq(int(True), 1) verisnot(int(True), True) vereq(+False, 0) verisnot(+False, False) vereq(-False, 0) verisnot(-False, False) vereq(abs(False), 0) verisnot(abs(False), False) vereq(+True, 1) verisnot(+True, True) vereq(-True, -1) vereq(abs(True), 1) verisnot(abs(True), True) vereq(~False, -1) vereq(~True, -2) vereq(False+2, 2) vereq(True+2, 3) vereq(2+False, 2) vereq(2+True, 3) vereq(False+False, 0) verisnot(False+False, False) vereq(False+True, 1) verisnot(False+True, True) vereq(True+False, 1) verisnot(True+False, True) vereq(True+True, 2) vereq(True-True, 0) verisnot(True-True, False) vereq(False-False, 0) verisnot(False-False, False) vereq(True-False, 1) verisnot(True-False, True) vereq(False-True, -1) vereq(True*1, 1) vereq(False*1, 0) verisnot(False*1, False) vereq(True/1, 1) verisnot(True/1, True) vereq(False/1, 0) verisnot(False/1, False) for b in False, True: for i in 0, 1, 2: vereq(b**i, int(b)**i) verisnot(b**i, bool(int(b)**i)) for a in False, True: for b in False, True: veris(a&b, bool(int(a)&int(b))) veris(a|b, bool(int(a)|int(b))) veris(a^b, bool(int(a)^int(b))) vereq(a&int(b), int(a)&int(b)) verisnot(a&int(b), bool(int(a)&int(b))) vereq(a|int(b), int(a)|int(b)) verisnot(a|int(b), bool(int(a)|int(b))) vereq(a^int(b), int(a)^int(b)) verisnot(a^int(b), bool(int(a)^int(b))) vereq(int(a)&b, int(a)&int(b)) verisnot(int(a)&b, bool(int(a)&int(b))) vereq(int(a)|b, int(a)|int(b)) verisnot(int(a)|b, bool(int(a)|int(b))) vereq(int(a)^b, int(a)^int(b)) verisnot(int(a)^b, bool(int(a)^int(b))) veris(1==1, True) veris(1==0, False) x = [1] veris(x is x, True) veris(x is not x, False) veris(1 in x, True) veris(0 in x, False) veris(1 not in x, False) veris(0 not in x, True) veris(not True, False) veris(not False, True) veris(bool(10), True) veris(bool(1), True) veris(bool(-1), True) veris(bool(0), False) veris(bool("hello"), True) veris(bool(""), False) veris(bool(), False) veris(hasattr([], "append"), True) veris(hasattr([], "wobble"), False) veris(callable(len), True) veris(callable(1), False) veris(isinstance(True, bool), True) veris(isinstance(False, bool), True) veris(isinstance(True, int), True) veris(isinstance(False, int), True) veris(isinstance(1, bool), False) veris(isinstance(0, bool), False) veris(issubclass(bool, int), True) veris(issubclass(int, bool), False) veris({}.has_key(1), False) veris({1:1}.has_key(1), True) veris("xyz".endswith("z"), True) veris("xyz".endswith("x"), False) veris("xyz0123".isalnum(), True) veris("@ veris("xyz".isalpha(), True) veris("@ veris("0123".isdigit(), True) veris("xyz".isdigit(), False) veris("xyz".islower(), True) veris("XYZ".islower(), False) veris(" ".isspace(), True) veris("XYZ".isspace(), False) veris("X".istitle(), True) veris("x".istitle(), False) veris("XYZ".isupper(), True) veris("xyz".isupper(), False) veris("xyz".startswith("x"), True) veris("xyz".startswith("z"), False) if have_unicode: veris(unicode("xyz", 'ascii').endswith(unicode("z", 'ascii')), True) veris(unicode("xyz", 'ascii').endswith(unicode("x", 'ascii')), False) veris(unicode("xyz0123", 'ascii').isalnum(), True) veris(unicode("@ veris(unicode("xyz", 'ascii').isalpha(), True) veris(unicode("@ veris(unicode("0123", 'ascii').isdecimal(), True) veris(unicode("xyz", 'ascii').isdecimal(), False) veris(unicode("0123", 'ascii').isdigit(), True) veris(unicode("xyz", 'ascii').isdigit(), False) veris(unicode("xyz", 'ascii').islower(), True) veris(unicode("XYZ", 'ascii').islower(), False) veris(unicode("0123", 'ascii').isnumeric(), True) veris(unicode("xyz", 'ascii').isnumeric(), False) veris(unicode(" ", 'ascii').isspace(), True) veris(unicode("XYZ", 'ascii').isspace(), False) veris(unicode("X", 'ascii').istitle(), True) veris(unicode("x", 'ascii').istitle(), False) veris(unicode("XYZ", 'ascii').isupper(), True) veris(unicode("xyz", 'ascii').isupper(), False) veris(unicode("xyz", 'ascii').startswith(unicode("x", 'ascii')), True) veris(unicode("xyz", 'ascii').startswith(unicode("z", 'ascii')), False) f = file(TESTFN, "w") veris(f.closed, False) f.close() veris(f.closed, True) os.remove(TESTFN) import operator veris(operator.truth(0), False) veris(operator.truth(1), True) veris(operator.isCallable(0), False) veris(operator.isCallable(len), True) veris(operator.isNumberType(None), False) veris(operator.isNumberType(0), True) veris(operator.not_(1), False) veris(operator.not_(0), True) veris(operator.isSequenceType(0), False) veris(operator.isSequenceType([]), True) veris(operator.contains([], 1), False) veris(operator.contains([1], 1), True) veris(operator.isMappingType(1), False) veris(operator.isMappingType({}), True) veris(operator.lt(0, 0), False) veris(operator.lt(0, 1), True) import marshal veris(marshal.loads(marshal.dumps(True)), True) veris(marshal.loads(marshal.dumps(False)), False) import pickle veris(pickle.loads(pickle.dumps(True)), True) veris(pickle.loads(pickle.dumps(False)), False) veris(pickle.loads(pickle.dumps(True, True)), True) veris(pickle.loads(pickle.dumps(False, True)), False) import cPickle veris(cPickle.loads(cPickle.dumps(True)), True) veris(cPickle.loads(cPickle.dumps(False)), False) veris(cPickle.loads(cPickle.dumps(True, True)), True) veris(cPickle.loads(cPickle.dumps(False, True)), False) veris(pickle.loads(cPickle.dumps(True)), True) veris(pickle.loads(cPickle.dumps(False)), False) veris(pickle.loads(cPickle.dumps(True, True)), True) veris(pickle.loads(cPickle.dumps(False, True)), False) veris(cPickle.loads(pickle.dumps(True)), True) veris(cPickle.loads(pickle.dumps(False)), False) veris(cPickle.loads(pickle.dumps(True, True)), True) veris(cPickle.loads(pickle.dumps(False, True)), False) vereq(pickle.dumps(True), "I01\n.") vereq(pickle.dumps(False), "I00\n.") vereq(cPickle.dumps(True), "I01\n.") vereq(cPickle.dumps(False), "I00\n.") vereq(pickle.dumps(True, True), "I01\n.") vereq(pickle.dumps(False, True), "I00\n.") vereq(cPickle.dumps(True, True), "I01\n.") vereq(cPickle.dumps(False, True), "I00\n.") if verbose: print "All OK"
class BoolTest(unittest.TestCase): def assertIs(self, a, b): self.assert_(a is b) def assertIsNot(self, a, b): self.assert_(a is not b) def test_subclass(self): try: class C(bool): pass except TypeError: pass else: self.fail("bool should not be subclassable") self.assertRaises(TypeError, int.__new__, bool, 0) def test_print(self): try: fo = open(test_support.TESTFN, "wb") print >> fo, False, True fo.close() fo = open(test_support.TESTFN, "rb") self.assertEqual(fo.read(), 'False True\n') finally: fo.close() os.remove(test_support.TESTFN) def test_repr(self): self.assertEqual(repr(False), 'False') self.assertEqual(repr(True), 'True') self.assertEqual(eval(repr(False)), False) self.assertEqual(eval(repr(True)), True) def test_str(self): self.assertEqual(str(False), 'False') self.assertEqual(str(True), 'True') def test_int(self): self.assertEqual(int(False), 0) self.assertIsNot(int(False), False) self.assertEqual(int(True), 1) self.assertIsNot(int(True), True) def test_math(self): self.assertEqual(+False, 0) self.assertIsNot(+False, False) self.assertEqual(-False, 0) self.assertIsNot(-False, False) self.assertEqual(abs(False), 0) self.assertIsNot(abs(False), False) self.assertEqual(+True, 1) self.assertIsNot(+True, True) self.assertEqual(-True, -1) self.assertEqual(abs(True), 1) self.assertIsNot(abs(True), True) self.assertEqual(~False, -1) self.assertEqual(~True, -2) self.assertEqual(False+2, 2) self.assertEqual(True+2, 3) self.assertEqual(2+False, 2) self.assertEqual(2+True, 3) self.assertEqual(False+False, 0) self.assertIsNot(False+False, False) self.assertEqual(False+True, 1) self.assertIsNot(False+True, True) self.assertEqual(True+False, 1) self.assertIsNot(True+False, True) self.assertEqual(True+True, 2) self.assertEqual(True-True, 0) self.assertIsNot(True-True, False) self.assertEqual(False-False, 0) self.assertIsNot(False-False, False) self.assertEqual(True-False, 1) self.assertIsNot(True-False, True) self.assertEqual(False-True, -1) self.assertEqual(True*1, 1) self.assertEqual(False*1, 0) self.assertIsNot(False*1, False) self.assertEqual(True/1, 1) self.assertIsNot(True/1, True) self.assertEqual(False/1, 0) self.assertIsNot(False/1, False) for b in False, True: for i in 0, 1, 2: self.assertEqual(b**i, int(b)**i) self.assertIsNot(b**i, bool(int(b)**i)) for a in False, True: for b in False, True: self.assertIs(a&b, bool(int(a)&int(b))) self.assertIs(a|b, bool(int(a)|int(b))) self.assertIs(a^b, bool(int(a)^int(b))) self.assertEqual(a&int(b), int(a)&int(b)) self.assertIsNot(a&int(b), bool(int(a)&int(b))) self.assertEqual(a|int(b), int(a)|int(b)) self.assertIsNot(a|int(b), bool(int(a)|int(b))) self.assertEqual(a^int(b), int(a)^int(b)) self.assertIsNot(a^int(b), bool(int(a)^int(b))) self.assertEqual(int(a)&b, int(a)&int(b)) self.assertIsNot(int(a)&b, bool(int(a)&int(b))) self.assertEqual(int(a)|b, int(a)|int(b)) self.assertIsNot(int(a)|b, bool(int(a)|int(b))) self.assertEqual(int(a)^b, int(a)^int(b)) self.assertIsNot(int(a)^b, bool(int(a)^int(b))) self.assertIs(1==1, True) self.assertIs(1==0, False) self.assertIs(0<1, True) self.assertIs(1<0, False) self.assertIs(0<=0, True) self.assertIs(1<=0, False) self.assertIs(1>0, True) self.assertIs(1>1, False) self.assertIs(1>=1, True) self.assertIs(0>=1, False) self.assertIs(0!=1, True) self.assertIs(0!=0, False) x = [1] self.assertIs(x is x, True) self.assertIs(x is not x, False) self.assertIs(1 in x, True) self.assertIs(0 in x, False) self.assertIs(1 not in x, False) self.assertIs(0 not in x, True) x = {1: 2} self.assertIs(x is x, True) self.assertIs(x is not x, False) self.assertIs(1 in x, True) self.assertIs(0 in x, False) self.assertIs(1 not in x, False) self.assertIs(0 not in x, True) self.assertIs(not True, False) self.assertIs(not False, True) def test_convert(self): self.assertRaises(TypeError, bool, 42, 42) self.assertIs(bool(10), True) self.assertIs(bool(1), True) self.assertIs(bool(-1), True) self.assertIs(bool(0), False) self.assertIs(bool("hello"), True) self.assertIs(bool(""), False) self.assertIs(bool(), False) def test_hasattr(self): self.assertIs(hasattr([], "append"), True) self.assertIs(hasattr([], "wobble"), False) def test_callable(self): self.assertIs(callable(len), True) self.assertIs(callable(1), False) def test_isinstance(self): self.assertIs(isinstance(True, bool), True) self.assertIs(isinstance(False, bool), True) self.assertIs(isinstance(True, int), True) self.assertIs(isinstance(False, int), True) self.assertIs(isinstance(1, bool), False) self.assertIs(isinstance(0, bool), False) def test_issubclass(self): self.assertIs(issubclass(bool, int), True) self.assertIs(issubclass(int, bool), False) def test_haskey(self): self.assertIs({}.has_key(1), False) self.assertIs({1:1}.has_key(1), True) def test_string(self): self.assertIs("xyz".endswith("z"), True) self.assertIs("xyz".endswith("x"), False) self.assertIs("xyz0123".isalnum(), True) self.assertIs("@ self.assertIs("xyz".isalpha(), True) self.assertIs("@ self.assertIs("0123".isdigit(), True) self.assertIs("xyz".isdigit(), False) self.assertIs("xyz".islower(), True) self.assertIs("XYZ".islower(), False) self.assertIs(" ".isspace(), True) self.assertIs("XYZ".isspace(), False) self.assertIs("X".istitle(), True) self.assertIs("x".istitle(), False) self.assertIs("XYZ".isupper(), True) self.assertIs("xyz".isupper(), False) self.assertIs("xyz".startswith("x"), True) self.assertIs("xyz".startswith("z"), False) if have_unicode: self.assertIs(unicode("xyz", 'ascii').endswith(unicode("z", 'ascii')), True) self.assertIs(unicode("xyz", 'ascii').endswith(unicode("x", 'ascii')), False) self.assertIs(unicode("xyz0123", 'ascii').isalnum(), True) self.assertIs(unicode("@ self.assertIs(unicode("xyz", 'ascii').isalpha(), True) self.assertIs(unicode("@ self.assertIs(unicode("0123", 'ascii').isdecimal(), True) self.assertIs(unicode("xyz", 'ascii').isdecimal(), False) self.assertIs(unicode("0123", 'ascii').isdigit(), True) self.assertIs(unicode("xyz", 'ascii').isdigit(), False) self.assertIs(unicode("xyz", 'ascii').islower(), True) self.assertIs(unicode("XYZ", 'ascii').islower(), False) self.assertIs(unicode("0123", 'ascii').isnumeric(), True) self.assertIs(unicode("xyz", 'ascii').isnumeric(), False) self.assertIs(unicode(" ", 'ascii').isspace(), True) self.assertIs(unicode("XYZ", 'ascii').isspace(), False) self.assertIs(unicode("X", 'ascii').istitle(), True) self.assertIs(unicode("x", 'ascii').istitle(), False) self.assertIs(unicode("XYZ", 'ascii').isupper(), True) self.assertIs(unicode("xyz", 'ascii').isupper(), False) self.assertIs(unicode("xyz", 'ascii').startswith(unicode("x", 'ascii')), True) self.assertIs(unicode("xyz", 'ascii').startswith(unicode("z", 'ascii')), False) def test_boolean(self): self.assertEqual(True & 1, 1) self.assert_(not isinstance(True & 1, bool)) self.assertIs(True & True, True) self.assertEqual(True | 1, 1) self.assert_(not isinstance(True | 1, bool)) self.assertIs(True | True, True) self.assertEqual(True ^ 1, 0) self.assert_(not isinstance(True ^ 1, bool)) self.assertIs(True ^ True, False) def test_fileclosed(self): try: f = file(TESTFN, "w") self.assertIs(f.closed, False) f.close() self.assertIs(f.closed, True) finally: os.remove(TESTFN) def test_operator(self): import operator self.assertIs(operator.truth(0), False) self.assertIs(operator.truth(1), True) self.assertIs(operator.isCallable(0), False) self.assertIs(operator.isCallable(len), True) self.assertIs(operator.isNumberType(None), False) self.assertIs(operator.isNumberType(0), True) self.assertIs(operator.not_(1), False) self.assertIs(operator.not_(0), True) self.assertIs(operator.isSequenceType(0), False) self.assertIs(operator.isSequenceType([]), True) self.assertIs(operator.contains([], 1), False) self.assertIs(operator.contains([1], 1), True) self.assertIs(operator.isMappingType(1), False) self.assertIs(operator.isMappingType({}), True) self.assertIs(operator.lt(0, 0), False) self.assertIs(operator.lt(0, 1), True) self.assertIs(operator.is_(True, True), True) self.assertIs(operator.is_(True, False), False) self.assertIs(operator.is_not(True, True), False) self.assertIs(operator.is_not(True, False), True) def test_marshal(self): import marshal veris(marshal.loads(marshal.dumps(True)), True) veris(marshal.loads(marshal.dumps(False)), False) def test_pickle(self): import pickle self.assertIs(pickle.loads(pickle.dumps(True)), True) self.assertIs(pickle.loads(pickle.dumps(False)), False) self.assertIs(pickle.loads(pickle.dumps(True, True)), True) self.assertIs(pickle.loads(pickle.dumps(False, True)), False) def test_cpickle(self): import cPickle self.assertIs(cPickle.loads(cPickle.dumps(True)), True) self.assertIs(cPickle.loads(cPickle.dumps(False)), False) self.assertIs(cPickle.loads(cPickle.dumps(True, True)), True) self.assertIs(cPickle.loads(cPickle.dumps(False, True)), False) def test_mixedpickle(self): import pickle, cPickle self.assertIs(pickle.loads(cPickle.dumps(True)), True) self.assertIs(pickle.loads(cPickle.dumps(False)), False) self.assertIs(pickle.loads(cPickle.dumps(True, True)), True) self.assertIs(pickle.loads(cPickle.dumps(False, True)), False) self.assertIs(cPickle.loads(pickle.dumps(True)), True) self.assertIs(cPickle.loads(pickle.dumps(False)), False) self.assertIs(cPickle.loads(pickle.dumps(True, True)), True) self.assertIs(cPickle.loads(pickle.dumps(False, True)), False) def test_picklevalues(self): import pickle, cPickle self.assertEqual(pickle.dumps(True), "I01\n.") self.assertEqual(pickle.dumps(False), "I00\n.") self.assertEqual(cPickle.dumps(True), "I01\n.") self.assertEqual(cPickle.dumps(False), "I00\n.") self.assertEqual(pickle.dumps(True, True), "I01\n.") self.assertEqual(pickle.dumps(False, True), "I00\n.") self.assertEqual(cPickle.dumps(True, True), "I01\n.") self.assertEqual(cPickle.dumps(False, True), "I00\n.") def test_main(): suite = unittest.TestSuite() suite.addTest(unittest.makeSuite(BoolTest)) test_support.run_suite(suite) if __name__ == "__main__": test_main()
def verisnot(a, b): if a is b: raise TestFailed, "%r is %r" % (a, b)
dbcede5d66aee2999c16367fd4a2529fe77e91ae /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/dbcede5d66aee2999c16367fd4a2529fe77e91ae/test_bool.py
self.socket = socket.socket(self.address_family, self.socket_type) self.server_bind() self.server_activate() def server_bind(self): """Called by constructor to bind the socket. May be overridden. """ if self.allow_reuse_address: self.socket.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) self.socket.bind(self.server_address)
def __init__(self, server_address, RequestHandlerClass): """Constructor. May be extended, do not override.""" self.server_address = server_address self.RequestHandlerClass = RequestHandlerClass self.socket = socket.socket(self.address_family, self.socket_type) self.server_bind() self.server_activate()
90cb9067b82509ed4917084ffa85abc150509ff5 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/90cb9067b82509ed4917084ffa85abc150509ff5/SocketServer.py
self.socket.listen(self.request_queue_size) def fileno(self): """Return socket file number. Interface required by select(). """ return self.socket.fileno()
pass
def server_activate(self): """Called by constructor to activate the server.
90cb9067b82509ed4917084ffa85abc150509ff5 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/90cb9067b82509ed4917084ffa85abc150509ff5/SocketServer.py
def get_request(self): """Get the request and client address from the socket. May be overridden. """ return self.socket.accept()
def get_request(self): """Get the request and client address from the socket.
90cb9067b82509ed4917084ffa85abc150509ff5 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/90cb9067b82509ed4917084ffa85abc150509ff5/SocketServer.py
traceback.print_exc()
traceback.print_exc()
def handle_error(self, request, client_address): """Handle an error gracefully. May be overridden.
90cb9067b82509ed4917084ffa85abc150509ff5 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/90cb9067b82509ed4917084ffa85abc150509ff5/SocketServer.py
self.socket.close()
self.server_close()
def process_request(self, request, client_address): """Fork a new subprocess to process the request.""" self.collect_children() pid = os.fork() if pid: # Parent process if self.active_children is None: self.active_children = [] self.active_children.append(pid) return else: # Child process. # This must never return, hence os._exit()! try: self.socket.close() self.finish_request(request, client_address) os._exit(0) except: try: self.handle_error(request, client_address) finally: os._exit(1)
90cb9067b82509ed4917084ffa85abc150509ff5 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/90cb9067b82509ed4917084ffa85abc150509ff5/SocketServer.py
This is called by send_reponse().
This is called by send_response().
def log_request(self, code='-', size='-'): """Log an accepted request.
ec73cd4b1a6104461d795b6f9408bf8227e0ddde /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/ec73cd4b1a6104461d795b6f9408bf8227e0ddde/BaseHTTPServer.py
'Library', 'Python', sys.version[:3], 'site-packages')
'Library', 'Python', sys.version[:3], 'site-packages')
def _init(): import macresource import sys, os macresource.need('DITL', 468, "PythonIDE.rsrc") widgetrespathsegs = [sys.exec_prefix, "Mac", "Tools", "IDE", "Widgets.rsrc"] widgetresfile = os.path.join(*widgetrespathsegs) if not os.path.exists(widgetresfile): widgetrespathsegs = [os.pardir, "Tools", "IDE", "Widgets.rsrc"] widgetresfile = os.path.join(*widgetrespathsegs) refno = macresource.need('CURS', 468, widgetresfile) if os.environ.has_key('PYTHONIDEPATH'): # For development set this environment variable ide_path = os.environ['PYTHONIDEPATH'] elif refno: # We're not a fullblown application idepathsegs = [sys.exec_prefix, "Mac", "Tools", "IDE"] ide_path = os.path.join(*idepathsegs) if not os.path.exists(ide_path): idepathsegs = [os.pardir, "Tools", "IDE"] for p in sys.path: ide_path = os.path.join(*([p]+idepathsegs)) if os.path.exists(ide_path): break else: # We are a fully frozen application ide_path = sys.argv[0] if ide_path not in sys.path: sys.path.insert(0, ide_path)
f776dee6dd3d11f084071f52200838aeed0f4613 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/f776dee6dd3d11f084071f52200838aeed0f4613/PackageManager.py
rv = 0
rv = 0
def _quit(self):
f776dee6dd3d11f084071f52200838aeed0f4613 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/f776dee6dd3d11f084071f52200838aeed0f4613/PackageManager.py
self.packages = self.pimpdb.list()
packages = self.pimpdb.list() if show_hidden: self.packages = packages else: self.packages = [] for pkg in packages: name = pkg.fullname() if name[0] == '(' and name[-1] == ')' and not show_hidden: continue self.packages.append(pkg)
def getbrowserdata(self, show_hidden=1): self.packages = self.pimpdb.list() rv = [] for pkg in self.packages: name = pkg.fullname() if name[0] == '(' and name[-1] == ')' and not show_hidden: continue status, _ = pkg.installed() description = pkg.description() rv.append((status, name, description)) return rv
f776dee6dd3d11f084071f52200838aeed0f4613 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/f776dee6dd3d11f084071f52200838aeed0f4613/PackageManager.py
if name[0] == '(' and name[-1] == ')' and not show_hidden: continue
def getbrowserdata(self, show_hidden=1): self.packages = self.pimpdb.list() rv = [] for pkg in self.packages: name = pkg.fullname() if name[0] == '(' and name[-1] == ')' and not show_hidden: continue status, _ = pkg.installed() description = pkg.description() rv.append((status, name, description)) return rv
f776dee6dd3d11f084071f52200838aeed0f4613 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/f776dee6dd3d11f084071f52200838aeed0f4613/PackageManager.py
attrname = string.lower(attrname)
def parse_starttag(self, i):
5d68e8e312fe66450314c9cd49db9bce63cadc42 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/5d68e8e312fe66450314c9cd49db9bce63cadc42/xmllib.py
def test(args = None): import sys if not args: args = sys.argv[1:] if args and args[0] == '-s': args = args[1:] klass = XMLParser else: klass = TestXMLParser if args: file = args[0] else: file = 'test.xml' if file == '-': f = sys.stdin else: try: f = open(file, 'r') except IOError, msg: print file, ":", msg sys.exit(1) data = f.read() if f is not sys.stdin: f.close() x = klass() for c in data: x.feed(c) x.close()
5d68e8e312fe66450314c9cd49db9bce63cadc42 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/5d68e8e312fe66450314c9cd49db9bce63cadc42/xmllib.py
(typ, [data]) = <instance>.create(mailbox, who, what)
(typ, [data]) = <instance>.setacl(mailbox, who, what)
def setacl(self, mailbox, who, what): """Set a mailbox acl.
f167dc33805ad5e9c15327628969b91383eca037 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/f167dc33805ad5e9c15327628969b91383eca037/imaplib.py
name = string.join(string.split(name, '-'), '_')
name = '_'.join(name.split('-'))
def open(self, fullurl, data=None): """Use URLopener().open(file) instead of open(file, 'r').""" fullurl = unwrap(toBytes(fullurl)) if self.tempcache and self.tempcache.has_key(fullurl): filename, headers = self.tempcache[fullurl] fp = open(filename, 'rb') return addinfourl(fp, headers, fullurl) urltype, url = splittype(fullurl) if not urltype: urltype = 'file' if self.proxies.has_key(urltype): proxy = self.proxies[urltype] urltype, proxyhost = splittype(proxy) host, selector = splithost(proxyhost) url = (host, fullurl) # Signal special case to open_*() else: proxy = None name = 'open_' + urltype self.type = urltype if '-' in name: # replace - with _ name = string.join(string.split(name, '-'), '_') if not hasattr(self, name): if proxy: return self.open_unknown_proxy(proxy, fullurl, data) else: return self.open_unknown(fullurl, data) try: if data is None: return getattr(self, name)(url) else: return getattr(self, name)(url, data) except socket.error, msg: raise IOError, ('socket error', msg), sys.exc_info()[2]
b2493f855a7319ce0748bfb965253cad9c9f5a2c /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/b2493f855a7319ce0748bfb965253cad9c9f5a2c/urllib.py
if string.lower(urltype) != 'http':
if urltype.lower() != 'http':
def open_http(self, url, data=None): """Use HTTP protocol.""" import httplib user_passwd = None if type(url) is types.StringType: host, selector = splithost(url) if host: user_passwd, host = splituser(host) host = unquote(host) realhost = host else: host, selector = url urltype, rest = splittype(selector) url = rest user_passwd = None if string.lower(urltype) != 'http': realhost = None else: realhost, rest = splithost(rest) if realhost: user_passwd, realhost = splituser(realhost) if user_passwd: selector = "%s://%s%s" % (urltype, realhost, rest) #print "proxy via http:", host, selector if not host: raise IOError, ('http error', 'no host given') if user_passwd: import base64 auth = string.strip(base64.encodestring(user_passwd)) else: auth = None h = httplib.HTTP(host) if data is not None: h.putrequest('POST', selector) h.putheader('Content-type', 'application/x-www-form-urlencoded') h.putheader('Content-length', '%d' % len(data)) else: h.putrequest('GET', selector) if auth: h.putheader('Authorization', 'Basic %s' % auth) if realhost: h.putheader('Host', realhost) for args in self.addheaders: apply(h.putheader, args) h.endheaders() if data is not None: h.send(data + '\r\n') errcode, errmsg, headers = h.getreply() fp = h.getfile() if errcode == 200: return addinfourl(fp, headers, "http:" + url) else: if data is None: return self.http_error(url, fp, errcode, errmsg, headers) else: return self.http_error(url, fp, errcode, errmsg, headers, data)
b2493f855a7319ce0748bfb965253cad9c9f5a2c /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/b2493f855a7319ce0748bfb965253cad9c9f5a2c/urllib.py
auth = string.strip(base64.encodestring(user_passwd))
auth = base64.encodestring(user_passwd).strip()
def open_http(self, url, data=None): """Use HTTP protocol.""" import httplib user_passwd = None if type(url) is types.StringType: host, selector = splithost(url) if host: user_passwd, host = splituser(host) host = unquote(host) realhost = host else: host, selector = url urltype, rest = splittype(selector) url = rest user_passwd = None if string.lower(urltype) != 'http': realhost = None else: realhost, rest = splithost(rest) if realhost: user_passwd, realhost = splituser(realhost) if user_passwd: selector = "%s://%s%s" % (urltype, realhost, rest) #print "proxy via http:", host, selector if not host: raise IOError, ('http error', 'no host given') if user_passwd: import base64 auth = string.strip(base64.encodestring(user_passwd)) else: auth = None h = httplib.HTTP(host) if data is not None: h.putrequest('POST', selector) h.putheader('Content-type', 'application/x-www-form-urlencoded') h.putheader('Content-length', '%d' % len(data)) else: h.putrequest('GET', selector) if auth: h.putheader('Authorization', 'Basic %s' % auth) if realhost: h.putheader('Host', realhost) for args in self.addheaders: apply(h.putheader, args) h.endheaders() if data is not None: h.send(data + '\r\n') errcode, errmsg, headers = h.getreply() fp = h.getfile() if errcode == 200: return addinfourl(fp, headers, "http:" + url) else: if data is None: return self.http_error(url, fp, errcode, errmsg, headers) else: return self.http_error(url, fp, errcode, errmsg, headers, data)
b2493f855a7319ce0748bfb965253cad9c9f5a2c /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/b2493f855a7319ce0748bfb965253cad9c9f5a2c/urllib.py
if string.lower(urltype) != 'https':
if urltype.lower() != 'https':
def open_https(self, url, data=None): """Use HTTPS protocol.""" import httplib user_passwd = None if type(url) in types.StringTypes: host, selector = splithost(url) if host: user_passwd, host = splituser(host) host = unquote(host) realhost = host else: host, selector = url urltype, rest = splittype(selector) url = rest user_passwd = None if string.lower(urltype) != 'https': realhost = None else: realhost, rest = splithost(rest) if realhost: user_passwd, realhost = splituser(realhost) if user_passwd: selector = "%s://%s%s" % (urltype, realhost, rest) #print "proxy via https:", host, selector if not host: raise IOError, ('https error', 'no host given') if user_passwd: import base64 auth = string.strip(base64.encodestring(user_passwd)) else: auth = None h = httplib.HTTPS(host, 0, key_file=self.key_file, cert_file=self.cert_file) if data is not None: h.putrequest('POST', selector) h.putheader('Content-type', 'application/x-www-form-urlencoded') h.putheader('Content-length', '%d' % len(data)) else: h.putrequest('GET', selector) if auth: h.putheader('Authorization: Basic %s' % auth) if realhost: h.putheader('Host', realhost) for args in self.addheaders: apply(h.putheader, args) h.endheaders() if data is not None: h.send(data + '\r\n') errcode, errmsg, headers = h.getreply() fp = h.getfile() if errcode == 200: return addinfourl(fp, headers, url) else: if data is None: return self.http_error(url, fp, errcode, errmsg, headers) else: return self.http_error(url, fp, errcode, errmsg, headers, data)
b2493f855a7319ce0748bfb965253cad9c9f5a2c /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/b2493f855a7319ce0748bfb965253cad9c9f5a2c/urllib.py
auth = string.strip(base64.encodestring(user_passwd))
auth = base64.encodestring(user_passwd).strip()
def open_https(self, url, data=None): """Use HTTPS protocol.""" import httplib user_passwd = None if type(url) in types.StringTypes: host, selector = splithost(url) if host: user_passwd, host = splituser(host) host = unquote(host) realhost = host else: host, selector = url urltype, rest = splittype(selector) url = rest user_passwd = None if string.lower(urltype) != 'https': realhost = None else: realhost, rest = splithost(rest) if realhost: user_passwd, realhost = splituser(realhost) if user_passwd: selector = "%s://%s%s" % (urltype, realhost, rest) #print "proxy via https:", host, selector if not host: raise IOError, ('https error', 'no host given') if user_passwd: import base64 auth = string.strip(base64.encodestring(user_passwd)) else: auth = None h = httplib.HTTPS(host, 0, key_file=self.key_file, cert_file=self.cert_file) if data is not None: h.putrequest('POST', selector) h.putheader('Content-type', 'application/x-www-form-urlencoded') h.putheader('Content-length', '%d' % len(data)) else: h.putrequest('GET', selector) if auth: h.putheader('Authorization: Basic %s' % auth) if realhost: h.putheader('Host', realhost) for args in self.addheaders: apply(h.putheader, args) h.endheaders() if data is not None: h.send(data + '\r\n') errcode, errmsg, headers = h.getreply() fp = h.getfile() if errcode == 200: return addinfourl(fp, headers, url) else: if data is None: return self.http_error(url, fp, errcode, errmsg, headers) else: return self.http_error(url, fp, errcode, errmsg, headers, data)
b2493f855a7319ce0748bfb965253cad9c9f5a2c /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/b2493f855a7319ce0748bfb965253cad9c9f5a2c/urllib.py
return self.http_error(url, fp, errcode, errmsg, headers, data)
return self.http_error(url, fp, errcode, errmsg, headers, data)
def open_https(self, url, data=None): """Use HTTPS protocol.""" import httplib user_passwd = None if type(url) in types.StringTypes: host, selector = splithost(url) if host: user_passwd, host = splituser(host) host = unquote(host) realhost = host else: host, selector = url urltype, rest = splittype(selector) url = rest user_passwd = None if string.lower(urltype) != 'https': realhost = None else: realhost, rest = splithost(rest) if realhost: user_passwd, realhost = splituser(realhost) if user_passwd: selector = "%s://%s%s" % (urltype, realhost, rest) #print "proxy via https:", host, selector if not host: raise IOError, ('https error', 'no host given') if user_passwd: import base64 auth = string.strip(base64.encodestring(user_passwd)) else: auth = None h = httplib.HTTPS(host, 0, key_file=self.key_file, cert_file=self.cert_file) if data is not None: h.putrequest('POST', selector) h.putheader('Content-type', 'application/x-www-form-urlencoded') h.putheader('Content-length', '%d' % len(data)) else: h.putrequest('GET', selector) if auth: h.putheader('Authorization: Basic %s' % auth) if realhost: h.putheader('Host', realhost) for args in self.addheaders: apply(h.putheader, args) h.endheaders() if data is not None: h.send(data + '\r\n') errcode, errmsg, headers = h.getreply() fp = h.getfile() if errcode == 200: return addinfourl(fp, headers, url) else: if data is None: return self.http_error(url, fp, errcode, errmsg, headers) else: return self.http_error(url, fp, errcode, errmsg, headers, data)
b2493f855a7319ce0748bfb965253cad9c9f5a2c /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/b2493f855a7319ce0748bfb965253cad9c9f5a2c/urllib.py
dirs = string.splitfields(path, '/')
dirs = path.split('/')
def open_ftp(self, url): """Use FTP protocol.""" host, path = splithost(url) if not host: raise IOError, ('ftp error', 'no host given') host, port = splitport(host) user, host = splituser(host) if user: user, passwd = splitpasswd(user) else: passwd = None host = unquote(host) user = unquote(user or '') passwd = unquote(passwd or '') host = socket.gethostbyname(host) if not port: import ftplib port = ftplib.FTP_PORT else: port = int(port) path, attrs = splitattr(path) path = unquote(path) dirs = string.splitfields(path, '/') dirs, file = dirs[:-1], dirs[-1] if dirs and not dirs[0]: dirs = dirs[1:] if dirs and not dirs[0]: dirs[0] = '/' key = user, host, port, string.join(dirs, '/') # XXX thread unsafe! if len(self.ftpcache) > MAXFTPCACHE: # Prune the cache, rather arbitrarily for k in self.ftpcache.keys(): if k != key: v = self.ftpcache[k] del self.ftpcache[k] v.close() try: if not self.ftpcache.has_key(key): self.ftpcache[key] = \ ftpwrapper(user, passwd, host, port, dirs) if not file: type = 'D' else: type = 'I' for attr in attrs: attr, value = splitvalue(attr) if string.lower(attr) == 'type' and \ value in ('a', 'A', 'i', 'I', 'd', 'D'): type = string.upper(value) (fp, retrlen) = self.ftpcache[key].retrfile(file, type) if retrlen is not None and retrlen >= 0: import mimetools, StringIO headers = mimetools.Message(StringIO.StringIO( 'Content-Length: %d\n' % retrlen)) else: headers = noheaders() return addinfourl(fp, headers, "ftp:" + url) except ftperrors(), msg: raise IOError, ('ftp error', msg), sys.exc_info()[2]
b2493f855a7319ce0748bfb965253cad9c9f5a2c /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/b2493f855a7319ce0748bfb965253cad9c9f5a2c/urllib.py
key = user, host, port, string.join(dirs, '/')
key = user, host, port, '/'.join(dirs)
def open_ftp(self, url): """Use FTP protocol.""" host, path = splithost(url) if not host: raise IOError, ('ftp error', 'no host given') host, port = splitport(host) user, host = splituser(host) if user: user, passwd = splitpasswd(user) else: passwd = None host = unquote(host) user = unquote(user or '') passwd = unquote(passwd or '') host = socket.gethostbyname(host) if not port: import ftplib port = ftplib.FTP_PORT else: port = int(port) path, attrs = splitattr(path) path = unquote(path) dirs = string.splitfields(path, '/') dirs, file = dirs[:-1], dirs[-1] if dirs and not dirs[0]: dirs = dirs[1:] if dirs and not dirs[0]: dirs[0] = '/' key = user, host, port, string.join(dirs, '/') # XXX thread unsafe! if len(self.ftpcache) > MAXFTPCACHE: # Prune the cache, rather arbitrarily for k in self.ftpcache.keys(): if k != key: v = self.ftpcache[k] del self.ftpcache[k] v.close() try: if not self.ftpcache.has_key(key): self.ftpcache[key] = \ ftpwrapper(user, passwd, host, port, dirs) if not file: type = 'D' else: type = 'I' for attr in attrs: attr, value = splitvalue(attr) if string.lower(attr) == 'type' and \ value in ('a', 'A', 'i', 'I', 'd', 'D'): type = string.upper(value) (fp, retrlen) = self.ftpcache[key].retrfile(file, type) if retrlen is not None and retrlen >= 0: import mimetools, StringIO headers = mimetools.Message(StringIO.StringIO( 'Content-Length: %d\n' % retrlen)) else: headers = noheaders() return addinfourl(fp, headers, "ftp:" + url) except ftperrors(), msg: raise IOError, ('ftp error', msg), sys.exc_info()[2]
b2493f855a7319ce0748bfb965253cad9c9f5a2c /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/b2493f855a7319ce0748bfb965253cad9c9f5a2c/urllib.py
if string.lower(attr) == 'type' and \
if attr.lower() == 'type' and \
def open_ftp(self, url): """Use FTP protocol.""" host, path = splithost(url) if not host: raise IOError, ('ftp error', 'no host given') host, port = splitport(host) user, host = splituser(host) if user: user, passwd = splitpasswd(user) else: passwd = None host = unquote(host) user = unquote(user or '') passwd = unquote(passwd or '') host = socket.gethostbyname(host) if not port: import ftplib port = ftplib.FTP_PORT else: port = int(port) path, attrs = splitattr(path) path = unquote(path) dirs = string.splitfields(path, '/') dirs, file = dirs[:-1], dirs[-1] if dirs and not dirs[0]: dirs = dirs[1:] if dirs and not dirs[0]: dirs[0] = '/' key = user, host, port, string.join(dirs, '/') # XXX thread unsafe! if len(self.ftpcache) > MAXFTPCACHE: # Prune the cache, rather arbitrarily for k in self.ftpcache.keys(): if k != key: v = self.ftpcache[k] del self.ftpcache[k] v.close() try: if not self.ftpcache.has_key(key): self.ftpcache[key] = \ ftpwrapper(user, passwd, host, port, dirs) if not file: type = 'D' else: type = 'I' for attr in attrs: attr, value = splitvalue(attr) if string.lower(attr) == 'type' and \ value in ('a', 'A', 'i', 'I', 'd', 'D'): type = string.upper(value) (fp, retrlen) = self.ftpcache[key].retrfile(file, type) if retrlen is not None and retrlen >= 0: import mimetools, StringIO headers = mimetools.Message(StringIO.StringIO( 'Content-Length: %d\n' % retrlen)) else: headers = noheaders() return addinfourl(fp, headers, "ftp:" + url) except ftperrors(), msg: raise IOError, ('ftp error', msg), sys.exc_info()[2]
b2493f855a7319ce0748bfb965253cad9c9f5a2c /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/b2493f855a7319ce0748bfb965253cad9c9f5a2c/urllib.py
type = string.upper(value)
type = value.upper()
def open_ftp(self, url): """Use FTP protocol.""" host, path = splithost(url) if not host: raise IOError, ('ftp error', 'no host given') host, port = splitport(host) user, host = splituser(host) if user: user, passwd = splitpasswd(user) else: passwd = None host = unquote(host) user = unquote(user or '') passwd = unquote(passwd or '') host = socket.gethostbyname(host) if not port: import ftplib port = ftplib.FTP_PORT else: port = int(port) path, attrs = splitattr(path) path = unquote(path) dirs = string.splitfields(path, '/') dirs, file = dirs[:-1], dirs[-1] if dirs and not dirs[0]: dirs = dirs[1:] if dirs and not dirs[0]: dirs[0] = '/' key = user, host, port, string.join(dirs, '/') # XXX thread unsafe! if len(self.ftpcache) > MAXFTPCACHE: # Prune the cache, rather arbitrarily for k in self.ftpcache.keys(): if k != key: v = self.ftpcache[k] del self.ftpcache[k] v.close() try: if not self.ftpcache.has_key(key): self.ftpcache[key] = \ ftpwrapper(user, passwd, host, port, dirs) if not file: type = 'D' else: type = 'I' for attr in attrs: attr, value = splitvalue(attr) if string.lower(attr) == 'type' and \ value in ('a', 'A', 'i', 'I', 'd', 'D'): type = string.upper(value) (fp, retrlen) = self.ftpcache[key].retrfile(file, type) if retrlen is not None and retrlen >= 0: import mimetools, StringIO headers = mimetools.Message(StringIO.StringIO( 'Content-Length: %d\n' % retrlen)) else: headers = noheaders() return addinfourl(fp, headers, "ftp:" + url) except ftperrors(), msg: raise IOError, ('ftp error', msg), sys.exc_info()[2]
b2493f855a7319ce0748bfb965253cad9c9f5a2c /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/b2493f855a7319ce0748bfb965253cad9c9f5a2c/urllib.py
[type, data] = string.split(url, ',', 1)
[type, data] = url.split(',', 1)
def open_data(self, url, data=None): """Use "data" URL.""" # ignore POSTed data # # syntax of data URLs: # dataurl := "data:" [ mediatype ] [ ";base64" ] "," data # mediatype := [ type "/" subtype ] *( ";" parameter ) # data := *urlchar # parameter := attribute "=" value import StringIO, mimetools, time try: [type, data] = string.split(url, ',', 1) except ValueError: raise IOError, ('data error', 'bad data URL') if not type: type = 'text/plain;charset=US-ASCII' semi = string.rfind(type, ';') if semi >= 0 and '=' not in type[semi:]: encoding = type[semi+1:] type = type[:semi] else: encoding = '' msg = [] msg.append('Date: %s'%time.strftime('%a, %d %b %Y %T GMT', time.gmtime(time.time()))) msg.append('Content-type: %s' % type) if encoding == 'base64': import base64 data = base64.decodestring(data) else: data = unquote(data) msg.append('Content-length: %d' % len(data)) msg.append('') msg.append(data) msg = string.join(msg, '\n') f = StringIO.StringIO(msg) headers = mimetools.Message(f, 0) f.fileno = None # needed for addinfourl return addinfourl(f, headers, url)
b2493f855a7319ce0748bfb965253cad9c9f5a2c /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/b2493f855a7319ce0748bfb965253cad9c9f5a2c/urllib.py
semi = string.rfind(type, ';')
semi = type.rfind(';')
def open_data(self, url, data=None): """Use "data" URL.""" # ignore POSTed data # # syntax of data URLs: # dataurl := "data:" [ mediatype ] [ ";base64" ] "," data # mediatype := [ type "/" subtype ] *( ";" parameter ) # data := *urlchar # parameter := attribute "=" value import StringIO, mimetools, time try: [type, data] = string.split(url, ',', 1) except ValueError: raise IOError, ('data error', 'bad data URL') if not type: type = 'text/plain;charset=US-ASCII' semi = string.rfind(type, ';') if semi >= 0 and '=' not in type[semi:]: encoding = type[semi+1:] type = type[:semi] else: encoding = '' msg = [] msg.append('Date: %s'%time.strftime('%a, %d %b %Y %T GMT', time.gmtime(time.time()))) msg.append('Content-type: %s' % type) if encoding == 'base64': import base64 data = base64.decodestring(data) else: data = unquote(data) msg.append('Content-length: %d' % len(data)) msg.append('') msg.append(data) msg = string.join(msg, '\n') f = StringIO.StringIO(msg) headers = mimetools.Message(f, 0) f.fileno = None # needed for addinfourl return addinfourl(f, headers, url)
b2493f855a7319ce0748bfb965253cad9c9f5a2c /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/b2493f855a7319ce0748bfb965253cad9c9f5a2c/urllib.py
msg = string.join(msg, '\n')
msg = '\n'.join(msg)
def open_data(self, url, data=None): """Use "data" URL.""" # ignore POSTed data # # syntax of data URLs: # dataurl := "data:" [ mediatype ] [ ";base64" ] "," data # mediatype := [ type "/" subtype ] *( ";" parameter ) # data := *urlchar # parameter := attribute "=" value import StringIO, mimetools, time try: [type, data] = string.split(url, ',', 1) except ValueError: raise IOError, ('data error', 'bad data URL') if not type: type = 'text/plain;charset=US-ASCII' semi = string.rfind(type, ';') if semi >= 0 and '=' not in type[semi:]: encoding = type[semi+1:] type = type[:semi] else: encoding = '' msg = [] msg.append('Date: %s'%time.strftime('%a, %d %b %Y %T GMT', time.gmtime(time.time()))) msg.append('Content-type: %s' % type) if encoding == 'base64': import base64 data = base64.decodestring(data) else: data = unquote(data) msg.append('Content-length: %d' % len(data)) msg.append('') msg.append(data) msg = string.join(msg, '\n') f = StringIO.StringIO(msg) headers = mimetools.Message(f, 0) f.fileno = None # needed for addinfourl return addinfourl(f, headers, url)
b2493f855a7319ce0748bfb965253cad9c9f5a2c /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/b2493f855a7319ce0748bfb965253cad9c9f5a2c/urllib.py
if string.lower(scheme) == 'basic':
if scheme.lower() == 'basic':
def http_error_401(self, url, fp, errcode, errmsg, headers, data=None): """Error 401 -- authentication required. See this URL for a description of the basic authentication scheme: http://www.ics.uci.edu/pub/ietf/http/draft-ietf-http-v10-spec-00.txt""" if headers.has_key('www-authenticate'): stuff = headers['www-authenticate'] import re match = re.match('[ \t]*([^ \t]+)[ \t]+realm="([^"]*)"', stuff) if match: scheme, realm = match.groups() if string.lower(scheme) == 'basic': name = 'retry_' + self.type + '_basic_auth' if data is None: return getattr(self,name)(url, realm) else: return getattr(self,name)(url, realm, data)
b2493f855a7319ce0748bfb965253cad9c9f5a2c /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/b2493f855a7319ce0748bfb965253cad9c9f5a2c/urllib.py
i = string.find(host, '@') + 1
i = host.find('@') + 1
def retry_http_basic_auth(self, url, realm, data=None): host, selector = splithost(url) i = string.find(host, '@') + 1 host = host[i:] user, passwd = self.get_user_passwd(host, realm, i) if not (user or passwd): return None host = user + ':' + passwd + '@' + host newurl = 'http://' + host + selector if data is None: return self.open(newurl) else: return self.open(newurl, data)
b2493f855a7319ce0748bfb965253cad9c9f5a2c /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/b2493f855a7319ce0748bfb965253cad9c9f5a2c/urllib.py
i = string.find(host, '@') + 1
i = host.find('@') + 1
def retry_https_basic_auth(self, url, realm, data=None): host, selector = splithost(url) i = string.find(host, '@') + 1 host = host[i:] user, passwd = self.get_user_passwd(host, realm, i) if not (user or passwd): return None host = user + ':' + passwd + '@' + host newurl = '//' + host + selector return self.open_https(newurl)
b2493f855a7319ce0748bfb965253cad9c9f5a2c /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/b2493f855a7319ce0748bfb965253cad9c9f5a2c/urllib.py
key = realm + '@' + string.lower(host)
key = realm + '@' + host.lower()
def get_user_passwd(self, host, realm, clear_cache = 0): key = realm + '@' + string.lower(host) if self.auth_cache.has_key(key): if clear_cache: del self.auth_cache[key] else: return self.auth_cache[key] user, passwd = self.prompt_user_passwd(host, realm) if user or passwd: self.auth_cache[key] = (user, passwd) return user, passwd
b2493f855a7319ce0748bfb965253cad9c9f5a2c /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/b2493f855a7319ce0748bfb965253cad9c9f5a2c/urllib.py
if reason[:3] != '550':
if str(reason)[:3] != '550':
def retrfile(self, file, type): import ftplib self.endtransfer() if type in ('d', 'D'): cmd = 'TYPE A'; isdir = 1 else: cmd = 'TYPE ' + type; isdir = 0 try: self.ftp.voidcmd(cmd) except ftplib.all_errors: self.init() self.ftp.voidcmd(cmd) conn = None if file and not isdir: # Use nlst to see if the file exists at all try: self.ftp.nlst(file) except ftplib.error_perm, reason: raise IOError, ('ftp error', reason), sys.exc_info()[2] # Restore the transfer mode! self.ftp.voidcmd(cmd) # Try to retrieve as a file try: cmd = 'RETR ' + file conn = self.ftp.ntransfercmd(cmd) except ftplib.error_perm, reason: if reason[:3] != '550': raise IOError, ('ftp error', reason), sys.exc_info()[2] if not conn: # Set transfer mode to ASCII! self.ftp.voidcmd('TYPE A') # Try a directory listing if file: cmd = 'LIST ' + file else: cmd = 'LIST' conn = self.ftp.ntransfercmd(cmd) self.busy = 1 # Pass back both a suitably decorated object and a retrieval length return (addclosehook(conn[0].makefile('rb'), self.endtransfer), conn[1])
b2493f855a7319ce0748bfb965253cad9c9f5a2c /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/b2493f855a7319ce0748bfb965253cad9c9f5a2c/urllib.py
i = string.rfind(basepath, '/')
i = basepath.rfind('/')
def basejoin(base, url): """Utility to combine a URL with a base URL to form a new URL.""" type, path = splittype(url) if type: # if url is complete (i.e., it contains a type), return it return url host, path = splithost(path) type, basepath = splittype(base) # inherit type from base if host: # if url contains host, just inherit type if type: return type + '://' + host + path else: # no type inherited, so url must have started with // # just return it return url host, basepath = splithost(basepath) # inherit host basepath, basetag = splittag(basepath) # remove extraneous cruft basepath, basequery = splitquery(basepath) # idem if path[:1] != '/': # non-absolute path name if path[:1] in ('#', '?'): # path is just a tag or query, attach to basepath i = len(basepath) else: # else replace last component i = string.rfind(basepath, '/') if i < 0: # basepath not absolute if host: # host present, make absolute basepath = '/' else: # else keep non-absolute basepath = '' else: # remove last file component basepath = basepath[:i+1] # Interpret ../ (important because of symlinks) while basepath and path[:3] == '../': path = path[3:] i = string.rfind(basepath[:-1], '/') if i > 0: basepath = basepath[:i+1] elif i == 0: basepath = '/' break else: basepath = '' path = basepath + path if type and host: return type + '://' + host + path elif type: return type + ':' + path elif host: return '//' + host + path # don't know what this means else: return path
b2493f855a7319ce0748bfb965253cad9c9f5a2c /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/b2493f855a7319ce0748bfb965253cad9c9f5a2c/urllib.py
i = string.rfind(basepath[:-1], '/')
i = basepath[:-1].rfind('/')
def basejoin(base, url): """Utility to combine a URL with a base URL to form a new URL.""" type, path = splittype(url) if type: # if url is complete (i.e., it contains a type), return it return url host, path = splithost(path) type, basepath = splittype(base) # inherit type from base if host: # if url contains host, just inherit type if type: return type + '://' + host + path else: # no type inherited, so url must have started with // # just return it return url host, basepath = splithost(basepath) # inherit host basepath, basetag = splittag(basepath) # remove extraneous cruft basepath, basequery = splitquery(basepath) # idem if path[:1] != '/': # non-absolute path name if path[:1] in ('#', '?'): # path is just a tag or query, attach to basepath i = len(basepath) else: # else replace last component i = string.rfind(basepath, '/') if i < 0: # basepath not absolute if host: # host present, make absolute basepath = '/' else: # else keep non-absolute basepath = '' else: # remove last file component basepath = basepath[:i+1] # Interpret ../ (important because of symlinks) while basepath and path[:3] == '../': path = path[3:] i = string.rfind(basepath[:-1], '/') if i > 0: basepath = basepath[:i+1] elif i == 0: basepath = '/' break else: basepath = '' path = basepath + path if type and host: return type + '://' + host + path elif type: return type + ':' + path elif host: return '//' + host + path # don't know what this means else: return path
b2493f855a7319ce0748bfb965253cad9c9f5a2c /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/b2493f855a7319ce0748bfb965253cad9c9f5a2c/urllib.py
raise UnicodeError("URL "+repr(url)+" contains non-ASCII characters")
raise UnicodeError("URL " + repr(url) + " contains non-ASCII characters")
def toBytes(url): """toBytes(u"URL") --> 'URL'.""" # Most URL schemes require ASCII. If that changes, the conversion # can be relaxed if type(url) is types.UnicodeType: try: url = url.encode("ASCII") except UnicodeError: raise UnicodeError("URL "+repr(url)+" contains non-ASCII characters") return url
b2493f855a7319ce0748bfb965253cad9c9f5a2c /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/b2493f855a7319ce0748bfb965253cad9c9f5a2c/urllib.py
url = string.strip(url)
url = url.strip()
def unwrap(url): """unwrap('<URL:type://host/path>') --> 'type://host/path'.""" url = string.strip(url) if url[:1] == '<' and url[-1:] == '>': url = string.strip(url[1:-1]) if url[:4] == 'URL:': url = string.strip(url[4:]) return url
b2493f855a7319ce0748bfb965253cad9c9f5a2c /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/b2493f855a7319ce0748bfb965253cad9c9f5a2c/urllib.py