rem
stringlengths 1
322k
| add
stringlengths 0
2.05M
| context
stringlengths 4
228k
| meta
stringlengths 156
215
|
---|---|---|---|
suite.addTest(unittest.makeSuite(BasicUDPTest)) | if sys.platform != 'mac': suite.addTest(unittest.makeSuite(BasicUDPTest)) | def test_main(): suite = unittest.TestSuite() suite.addTest(unittest.makeSuite(GeneralModuleTests)) suite.addTest(unittest.makeSuite(BasicTCPTest)) suite.addTest(unittest.makeSuite(BasicUDPTest)) suite.addTest(unittest.makeSuite(NonBlockingTCPTests)) suite.addTest(unittest.makeSuite(FileObjectClassTestCase)) suite.addTest(unittest.makeSuite(UnbufferedFileObjectClassTestCase)) suite.addTest(unittest.makeSuite(LineBufferedFileObjectClassTestCase)) suite.addTest(unittest.makeSuite(SmallBufferedFileObjectClassTestCase)) test_support.run_suite(suite) | 522e7694ed5fed34b322c8882753df683f9068b2 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/522e7694ed5fed34b322c8882753df683f9068b2/test_socket.py |
self.addheaders = [('User-agent', server_version)] | self.addheaders = [('User-Agent', server_version)] | def __init__(self): server_version = "Python-urllib/%s" % __version__ self.addheaders = [('User-agent', server_version)] # manage the individual handlers self.handlers = [] self.handle_open = {} self.handle_error = {} | 96f1129de80c6cddba7a45db86eb09579221704e /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/96f1129de80c6cddba7a45db86eb09579221704e/urllib2.py |
h.putheader(*args) | if name not in req.headers: h.putheader(*args) | def do_open(self, http_class, req): host = req.get_host() if not host: raise URLError('no host given') | 96f1129de80c6cddba7a45db86eb09579221704e /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/96f1129de80c6cddba7a45db86eb09579221704e/urllib2.py |
else: MacOS.HandleEvent(event) | return MacOS.HandleEvent(event) | def lowlevelhandler(self, event): what, message, when, where, modifiers = event h, v = where if what == kHighLevelEvent: msg = "High Level Event: %s %s" % \ (`code(message)`, `code(h | (v<<16))`) try: AE.AEProcessAppleEvent(event) except AE.Error, err: print 'AE error: ', err print 'in', msg traceback.print_exc() return elif what == keyDown: c = chr(message & charCodeMask) if modifiers & cmdKey: if c == '.': raise KeyboardInterrupt, "Command-period" if c == 'q': self.quitting = 1 elif what == mouseDown: partcode, window = Win.FindWindow(where) if partcode == inMenuBar: result = Menu.MenuSelect(where) id = (result>>16) & 0xffff # Hi word item = result & 0xffff # Lo word if id == self.appleid: if item == 1: EasyDialogs.Message(self.getabouttext()) elif item > 1: name = self.applemenu.GetMenuItemText(item) Menu.OpenDeskAcc(name) elif id == self.quitid and item == 1: self.quitting = 1 Menu.HiliteMenu(0) else: # Anything not handled is passed to Python/SIOUX MacOS.HandleEvent(event) | 0c3baaf19c7d6a112a00ad36e31fe7a142b91542 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/0c3baaf19c7d6a112a00ad36e31fe7a142b91542/MiniAEFrame.py |
posix.chmod(tempname, statbuf[ST_MODE] & 0x7777) | posix.chmod(tempname, statbuf[ST_MODE] & 07777) | def fix(filename): | 7e73fd0024f82c9ecce2e75da3af116ffa760993 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/7e73fd0024f82c9ecce2e75da3af116ffa760993/classfix.py |
vereq(hash(d), id(d)) | orig_hash = hash(d) | def subclasspropagation(): if verbose: print "Testing propagation of slot functions to subclasses..." class A(object): pass class B(A): pass class C(A): pass class D(B, C): pass d = D() vereq(hash(d), id(d)) A.__hash__ = lambda self: 42 vereq(hash(d), 42) C.__hash__ = lambda self: 314 vereq(hash(d), 314) B.__hash__ = lambda self: 144 vereq(hash(d), 144) D.__hash__ = lambda self: 100 vereq(hash(d), 100) del D.__hash__ vereq(hash(d), 144) del B.__hash__ vereq(hash(d), 314) del C.__hash__ vereq(hash(d), 42) del A.__hash__ vereq(hash(d), id(d)) d.foo = 42 d.bar = 42 vereq(d.foo, 42) vereq(d.bar, 42) def __getattribute__(self, name): if name == "foo": return 24 return object.__getattribute__(self, name) A.__getattribute__ = __getattribute__ vereq(d.foo, 24) vereq(d.bar, 42) def __getattr__(self, name): if name in ("spam", "foo", "bar"): return "hello" raise AttributeError, name B.__getattr__ = __getattr__ vereq(d.spam, "hello") vereq(d.foo, 24) vereq(d.bar, 42) del A.__getattribute__ vereq(d.foo, 42) del d.foo vereq(d.foo, "hello") vereq(d.bar, 42) del B.__getattr__ try: d.foo except AttributeError: pass else: raise TestFailed, "d.foo should be undefined now" # Test a nasty bug in recurse_down_subclasses() import gc class A(object): pass class B(A): pass del B gc.collect() A.__setitem__ = lambda *a: None # crash | 171b868195d6f4ffc08a94ff3cf02fde74f6e576 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/171b868195d6f4ffc08a94ff3cf02fde74f6e576/test_descr.py |
vereq(hash(d), id(d)) | vereq(hash(d), orig_hash) | def subclasspropagation(): if verbose: print "Testing propagation of slot functions to subclasses..." class A(object): pass class B(A): pass class C(A): pass class D(B, C): pass d = D() vereq(hash(d), id(d)) A.__hash__ = lambda self: 42 vereq(hash(d), 42) C.__hash__ = lambda self: 314 vereq(hash(d), 314) B.__hash__ = lambda self: 144 vereq(hash(d), 144) D.__hash__ = lambda self: 100 vereq(hash(d), 100) del D.__hash__ vereq(hash(d), 144) del B.__hash__ vereq(hash(d), 314) del C.__hash__ vereq(hash(d), 42) del A.__hash__ vereq(hash(d), id(d)) d.foo = 42 d.bar = 42 vereq(d.foo, 42) vereq(d.bar, 42) def __getattribute__(self, name): if name == "foo": return 24 return object.__getattribute__(self, name) A.__getattribute__ = __getattribute__ vereq(d.foo, 24) vereq(d.bar, 42) def __getattr__(self, name): if name in ("spam", "foo", "bar"): return "hello" raise AttributeError, name B.__getattr__ = __getattr__ vereq(d.spam, "hello") vereq(d.foo, 24) vereq(d.bar, 42) del A.__getattribute__ vereq(d.foo, 42) del d.foo vereq(d.foo, "hello") vereq(d.bar, 42) del B.__getattr__ try: d.foo except AttributeError: pass else: raise TestFailed, "d.foo should be undefined now" # Test a nasty bug in recurse_down_subclasses() import gc class A(object): pass class B(A): pass del B gc.collect() A.__setitem__ = lambda *a: None # crash | 171b868195d6f4ffc08a94ff3cf02fde74f6e576 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/171b868195d6f4ffc08a94ff3cf02fde74f6e576/test_descr.py |
p = Parser() | p = Parser(strict=1) | def test_bogus_boundary(self): fp = openfile(findfile('msg_15.txt')) try: data = fp.read() finally: fp.close() p = Parser() # Note, under a future non-strict parsing mode, this would parse the # message into the intended message tree. self.assertRaises(Errors.BoundaryError, p.parsestr, data) | 24d45df3f2a4e549fc115a77a250a98861c06750 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/24d45df3f2a4e549fc115a77a250a98861c06750/test_email.py |
return self.fp.tell() - self.start | return self.fp.tell() - len(self.readahead) - self.start | def tell(self): if self.level > 0: return self.lastpos return self.fp.tell() - self.start | 912e56c3acadf2d68a43e126f5c42e6ca7074025 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/912e56c3acadf2d68a43e126f5c42e6ca7074025/multifile.py |
encoding = parts[2] | encoding = parts[2].lower() | def decode(s): """Return a decoded string according to RFC 2047, as a unicode string.""" rtn = [] parts = ecre.split(s, 1) while parts: # If there are less than 4 parts, it can't be encoded and we're done if len(parts) < 5: rtn.extend(parts) break # The first element is any non-encoded leading text rtn.append(parts[0]) charset = parts[1] encoding = parts[2] atom = parts[3] # The next chunk to decode should be in parts[4] parts = ecre.split(parts[4]) # The encoding must be either `q' or `b', case-insensitive if encoding.lower() == 'q': func = _qdecode elif encoding.lower() == 'b': func = _bdecode else: func = _identity # Decode and get the unicode in the charset rtn.append(unicode(func(atom), charset)) # Now that we've decoded everything, we just need to join all the parts # together into the final string. return UEMPTYSTRING.join(rtn) | c44d2c52c96e9a88cd368942f0d43d70e6ed64bf /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/c44d2c52c96e9a88cd368942f0d43d70e6ed64bf/Utils.py |
if encoding.lower() == 'q': | if encoding == 'q': | def decode(s): """Return a decoded string according to RFC 2047, as a unicode string.""" rtn = [] parts = ecre.split(s, 1) while parts: # If there are less than 4 parts, it can't be encoded and we're done if len(parts) < 5: rtn.extend(parts) break # The first element is any non-encoded leading text rtn.append(parts[0]) charset = parts[1] encoding = parts[2] atom = parts[3] # The next chunk to decode should be in parts[4] parts = ecre.split(parts[4]) # The encoding must be either `q' or `b', case-insensitive if encoding.lower() == 'q': func = _qdecode elif encoding.lower() == 'b': func = _bdecode else: func = _identity # Decode and get the unicode in the charset rtn.append(unicode(func(atom), charset)) # Now that we've decoded everything, we just need to join all the parts # together into the final string. return UEMPTYSTRING.join(rtn) | c44d2c52c96e9a88cd368942f0d43d70e6ed64bf /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/c44d2c52c96e9a88cd368942f0d43d70e6ed64bf/Utils.py |
elif encoding.lower() == 'b': | elif encoding == 'b': | def decode(s): """Return a decoded string according to RFC 2047, as a unicode string.""" rtn = [] parts = ecre.split(s, 1) while parts: # If there are less than 4 parts, it can't be encoded and we're done if len(parts) < 5: rtn.extend(parts) break # The first element is any non-encoded leading text rtn.append(parts[0]) charset = parts[1] encoding = parts[2] atom = parts[3] # The next chunk to decode should be in parts[4] parts = ecre.split(parts[4]) # The encoding must be either `q' or `b', case-insensitive if encoding.lower() == 'q': func = _qdecode elif encoding.lower() == 'b': func = _bdecode else: func = _identity # Decode and get the unicode in the charset rtn.append(unicode(func(atom), charset)) # Now that we've decoded everything, we just need to join all the parts # together into the final string. return UEMPTYSTRING.join(rtn) | c44d2c52c96e9a88cd368942f0d43d70e6ed64bf /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/c44d2c52c96e9a88cd368942f0d43d70e6ed64bf/Utils.py |
if encoding.lower() == 'q': | encoding = encoding.lower() if encoding == 'q': | def encode(s, charset='iso-8859-1', encoding='q'): """Encode a string according to RFC 2047.""" if encoding.lower() == 'q': estr = _qencode(s) elif encoding.lower() == 'b': estr = _bencode(s) else: raise ValueError, 'Illegal encoding code: ' + encoding return '=?%s?%s?%s?=' % (charset.lower(), encoding.lower(), estr) | c44d2c52c96e9a88cd368942f0d43d70e6ed64bf /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/c44d2c52c96e9a88cd368942f0d43d70e6ed64bf/Utils.py |
elif encoding.lower() == 'b': | elif encoding == 'b': | def encode(s, charset='iso-8859-1', encoding='q'): """Encode a string according to RFC 2047.""" if encoding.lower() == 'q': estr = _qencode(s) elif encoding.lower() == 'b': estr = _bencode(s) else: raise ValueError, 'Illegal encoding code: ' + encoding return '=?%s?%s?%s?=' % (charset.lower(), encoding.lower(), estr) | c44d2c52c96e9a88cd368942f0d43d70e6ed64bf /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/c44d2c52c96e9a88cd368942f0d43d70e6ed64bf/Utils.py |
return '=?%s?%s?%s?=' % (charset.lower(), encoding.lower(), estr) | return '=?%s?%s?%s?=' % (charset.lower(), encoding, estr) | def encode(s, charset='iso-8859-1', encoding='q'): """Encode a string according to RFC 2047.""" if encoding.lower() == 'q': estr = _qencode(s) elif encoding.lower() == 'b': estr = _bencode(s) else: raise ValueError, 'Illegal encoding code: ' + encoding return '=?%s?%s?%s?=' % (charset.lower(), encoding.lower(), estr) | c44d2c52c96e9a88cd368942f0d43d70e6ed64bf /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/c44d2c52c96e9a88cd368942f0d43d70e6ed64bf/Utils.py |
index = terminator.find (self.ac_in_buffer) | index = ac_in_buffer.find (self.terminator) | def handle_read (self): | a29b6222fe18ce79c8a16746bcdf2401389e4405 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/a29b6222fe18ce79c8a16746bcdf2401389e4405/asynchat.py |
def __hash__(self): """x.__hash__() <==> hash(x)""" # Decimal integers must hash the same as the ints # Non-integer decimals are normalized and hashed as strings # Normalization assures that hast(100E-1) == hash(10) if self._is_special: if self._isnan(): raise TypeError('Cannot hash a NaN value.') return hash(str(self)) i = int(self) if self == Decimal(i): return hash(i) assert self.__nonzero__() # '-0' handled by integer case return hash(str(self.normalize())) | 1fb9f528bd69efa135bacda917ec7bb166068d5d /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/1fb9f528bd69efa135bacda917ec7bb166068d5d/decimal.py |
||
testtype('u', u'\u263a') | if have_unicode: testtype('u', unicode(r'\u263a', 'unicode-escape')) | def main(): testtype('c', 'c') testtype('u', u'\u263a') for type in (['b', 'h', 'i', 'l', 'f', 'd']): testtype(type, 1) testunicode() testsubclassing() unlink(TESTFN) | 8bf46e4e7abdc6e88b1dcd680815b94c9d70184e /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/8bf46e4e7abdc6e88b1dcd680815b94c9d70184e/test_array.py |
testunicode() | if have_unicode: testunicode() | def main(): testtype('c', 'c') testtype('u', u'\u263a') for type in (['b', 'h', 'i', 'l', 'f', 'd']): testtype(type, 1) testunicode() testsubclassing() unlink(TESTFN) | 8bf46e4e7abdc6e88b1dcd680815b94c9d70184e /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/8bf46e4e7abdc6e88b1dcd680815b94c9d70184e/test_array.py |
array.array('b', u'foo') | array.array('b', unicode('foo', 'ascii')) | def testunicode(): try: array.array('b', u'foo') except TypeError: pass else: raise TestFailed("creating a non-unicode array from " "a Unicode string should fail") x = array.array('u', u'\xa0\xc2\u1234') x.fromunicode(u' ') x.fromunicode(u'') x.fromunicode(u'') x.fromunicode(u'\x11abc\xff\u1234') s = x.tounicode() if s != u'\xa0\xc2\u1234 \x11abc\xff\u1234': raise TestFailed("fromunicode()/tounicode()") s = u'\x00="\'a\\b\x80\xff\u0000\u0001\u1234' a = array.array('u', s) if verbose: print "repr of type 'u' array:", repr(a) print " expected: array('u', %r)" % s | 8bf46e4e7abdc6e88b1dcd680815b94c9d70184e /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/8bf46e4e7abdc6e88b1dcd680815b94c9d70184e/test_array.py |
x = array.array('u', u'\xa0\xc2\u1234') x.fromunicode(u' ') x.fromunicode(u'') x.fromunicode(u'') x.fromunicode(u'\x11abc\xff\u1234') | x = array.array('u', unicode(r'\xa0\xc2\u1234', 'unicode-escape')) x.fromunicode(unicode(' ', 'ascii')) x.fromunicode(unicode('', 'ascii')) x.fromunicode(unicode('', 'ascii')) x.fromunicode(unicode(r'\x11abc\xff\u1234', 'unicode-escape')) | def testunicode(): try: array.array('b', u'foo') except TypeError: pass else: raise TestFailed("creating a non-unicode array from " "a Unicode string should fail") x = array.array('u', u'\xa0\xc2\u1234') x.fromunicode(u' ') x.fromunicode(u'') x.fromunicode(u'') x.fromunicode(u'\x11abc\xff\u1234') s = x.tounicode() if s != u'\xa0\xc2\u1234 \x11abc\xff\u1234': raise TestFailed("fromunicode()/tounicode()") s = u'\x00="\'a\\b\x80\xff\u0000\u0001\u1234' a = array.array('u', s) if verbose: print "repr of type 'u' array:", repr(a) print " expected: array('u', %r)" % s | 8bf46e4e7abdc6e88b1dcd680815b94c9d70184e /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/8bf46e4e7abdc6e88b1dcd680815b94c9d70184e/test_array.py |
if s != u'\xa0\xc2\u1234 \x11abc\xff\u1234': | if s != unicode(r'\xa0\xc2\u1234 \x11abc\xff\u1234', 'unicode-escape'): | def testunicode(): try: array.array('b', u'foo') except TypeError: pass else: raise TestFailed("creating a non-unicode array from " "a Unicode string should fail") x = array.array('u', u'\xa0\xc2\u1234') x.fromunicode(u' ') x.fromunicode(u'') x.fromunicode(u'') x.fromunicode(u'\x11abc\xff\u1234') s = x.tounicode() if s != u'\xa0\xc2\u1234 \x11abc\xff\u1234': raise TestFailed("fromunicode()/tounicode()") s = u'\x00="\'a\\b\x80\xff\u0000\u0001\u1234' a = array.array('u', s) if verbose: print "repr of type 'u' array:", repr(a) print " expected: array('u', %r)" % s | 8bf46e4e7abdc6e88b1dcd680815b94c9d70184e /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/8bf46e4e7abdc6e88b1dcd680815b94c9d70184e/test_array.py |
s = u'\x00="\'a\\b\x80\xff\u0000\u0001\u1234' | s = unicode(r'\x00="\'a\\b\x80\xff\u0000\u0001\u1234', 'unicode-escape') | def testunicode(): try: array.array('b', u'foo') except TypeError: pass else: raise TestFailed("creating a non-unicode array from " "a Unicode string should fail") x = array.array('u', u'\xa0\xc2\u1234') x.fromunicode(u' ') x.fromunicode(u'') x.fromunicode(u'') x.fromunicode(u'\x11abc\xff\u1234') s = x.tounicode() if s != u'\xa0\xc2\u1234 \x11abc\xff\u1234': raise TestFailed("fromunicode()/tounicode()") s = u'\x00="\'a\\b\x80\xff\u0000\u0001\u1234' a = array.array('u', s) if verbose: print "repr of type 'u' array:", repr(a) print " expected: array('u', %r)" % s | 8bf46e4e7abdc6e88b1dcd680815b94c9d70184e /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/8bf46e4e7abdc6e88b1dcd680815b94c9d70184e/test_array.py |
sys.stderr.write(py_exc.msg) | sys.stderr.write(py_exc.msg + '\n') | def compile(file, cfile=None, dfile=None, doraise=False): """Byte-compile one Python source file to Python bytecode. Arguments: file: source filename cfile: target filename; defaults to source with 'c' or 'o' appended ('c' normally, 'o' in optimizing mode, giving .pyc or .pyo) dfile: purported filename; defaults to source (this is the filename that will show up in error messages) doraise: flag indicating whether or not an exception should be raised when a compile error is found. If an exception occurs and this flag is set to False, a string indicating the nature of the exception will be printed, and the function will return to the caller. If an exception occurs and this flag is set to True, a PyCompileError exception will be raised. Note that it isn't necessary to byte-compile Python modules for execution efficiency -- Python itself byte-compiles a module when it is loaded, and if it can, writes out the bytecode to the corresponding .pyc (or .pyo) file. However, if a Python installation is shared between users, it is a good idea to byte-compile all modules upon installation, since other users may not be able to write in the source directories, and thus they won't be able to write the .pyc/.pyo file, and then they would be byte-compiling every module each time it is loaded. This can slow down program start-up considerably. See compileall.py for a script/module that uses this module to byte-compile all installed files (or all files in selected directories). """ f = open(file, 'U') try: timestamp = long(os.fstat(f.fileno()).st_mtime) except AttributeError: timestamp = long(os.stat(file).st_mtime) codestring = f.read() f.close() if codestring and codestring[-1] != '\n': codestring = codestring + '\n' try: codeobject = __builtin__.compile(codestring, dfile or file,'exec') except Exception,err: py_exc = PyCompileError(err.__class__,err.args,dfile or file) if doraise: raise py_exc else: sys.stderr.write(py_exc.msg) return if cfile is None: cfile = file + (__debug__ and 'c' or 'o') fc = open(cfile, 'wb') fc.write('\0\0\0\0') wr_long(fc, timestamp) marshal.dump(codeobject, fc) fc.flush() fc.seek(0, 0) fc.write(MAGIC) fc.close() set_creator_type(cfile) | e537d6e93e0b5c37a96090df9ec831bd1bf8e2fb /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/e537d6e93e0b5c37a96090df9ec831bd1bf8e2fb/py_compile.py |
>>> def f(): | >>> def f(): | >>> def f(): | 77dcccca0c29fc6017b6ebef3913abd762ba0c40 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/77dcccca0c29fc6017b6ebef3913abd762ba0c40/test_generators.py |
... SyntaxError: 'return' with argument inside generator (<string>, line 2) >>> def f(): | .. SyntaxError: 'return' with argument inside generator (..., line 2) >>> def f(): | >>> def f(): | 77dcccca0c29fc6017b6ebef3913abd762ba0c40 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/77dcccca0c29fc6017b6ebef3913abd762ba0c40/test_generators.py |
... SyntaxError: 'return' with argument inside generator (<string>, line 3) | .. SyntaxError: 'return' with argument inside generator (..., line 3) | >>> def f(): | 77dcccca0c29fc6017b6ebef3913abd762ba0c40 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/77dcccca0c29fc6017b6ebef3913abd762ba0c40/test_generators.py |
>>> def f(): | >>> def f(): | >>> def f(): | 77dcccca0c29fc6017b6ebef3913abd762ba0c40 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/77dcccca0c29fc6017b6ebef3913abd762ba0c40/test_generators.py |
... SyntaxError: 'return' with argument inside generator (<string>, line 3) | .. SyntaxError: 'return' with argument inside generator (..., line 3) | >>> def f(): | 77dcccca0c29fc6017b6ebef3913abd762ba0c40 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/77dcccca0c29fc6017b6ebef3913abd762ba0c40/test_generators.py |
>>> def f(): | >>> def f(): | >>> def f(): | 77dcccca0c29fc6017b6ebef3913abd762ba0c40 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/77dcccca0c29fc6017b6ebef3913abd762ba0c40/test_generators.py |
... SyntaxError: 'yield' not allowed in a 'try' block with a 'finally' clause (<string>, line 3) >>> def f(): | .. SyntaxError: 'yield' not allowed in a 'try' block with a 'finally' clause (..., line 3) >>> def f(): | >>> def f(): | 77dcccca0c29fc6017b6ebef3913abd762ba0c40 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/77dcccca0c29fc6017b6ebef3913abd762ba0c40/test_generators.py |
SyntaxError: 'yield' not allowed in a 'try' block with a 'finally' clause (<string>, line 6) | SyntaxError: 'yield' not allowed in a 'try' block with a 'finally' clause (..., line 6) | >>> def f(): | 77dcccca0c29fc6017b6ebef3913abd762ba0c40 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/77dcccca0c29fc6017b6ebef3913abd762ba0c40/test_generators.py |
>>> def f(): | >>> def f(): | >>> def f(): | 77dcccca0c29fc6017b6ebef3913abd762ba0c40 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/77dcccca0c29fc6017b6ebef3913abd762ba0c40/test_generators.py |
SyntaxError: 'return' with argument inside generator (<string>, line 8) | SyntaxError: 'return' with argument inside generator (..., line 8) | ... def f(i): | 77dcccca0c29fc6017b6ebef3913abd762ba0c40 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/77dcccca0c29fc6017b6ebef3913abd762ba0c40/test_generators.py |
e.delta = getint(D) | try: e.delta = getint(D) except ValueError: e.delta = 0 | def _substitute(self, *args): """Internal function.""" if len(args) != len(self._subst_format): return args getboolean = self.tk.getboolean getint = int nsign, b, f, h, k, s, t, w, x, y, A, E, K, N, W, T, X, Y, D = args # Missing: (a, c, d, m, o, v, B, R) e = Event() e.serial = getint(nsign) e.num = getint(b) try: e.focus = getboolean(f) except TclError: pass e.height = getint(h) e.keycode = getint(k) # For Visibility events, event state is a string and # not an integer: try: e.state = getint(s) except ValueError: e.state = s e.time = getint(t) e.width = getint(w) e.x = getint(x) e.y = getint(y) e.char = A try: e.send_event = getboolean(E) except TclError: pass e.keysym = K e.keysym_num = getint(N) e.type = T try: e.widget = self._nametowidget(W) except KeyError: e.widget = W e.x_root = getint(X) e.y_root = getint(Y) e.delta = getint(D) return (e,) | a249f16af03ab2091b59e12faaefe642f95a85ea /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/a249f16af03ab2091b59e12faaefe642f95a85ea/Tkinter.py |
a[8] and b[17] match for 6 elements a[14] and b[23] match for 15 elements | a[8] and b[17] match for 21 elements | def _calculate_ratio(matches, length): if length: return 2.0 * matches / length return 1.0 | 43898b4f642acf182242744181143141228ca56e /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/43898b4f642acf182242744181143141228ca56e/difflib.py |
equal a[8:14] b[17:23] equal a[14:29] b[23:38] | equal a[8:29] b[17:38] | def _calculate_ratio(matches, length): if length: return 2.0 * matches / length return 1.0 | 43898b4f642acf182242744181143141228ca56e /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/43898b4f642acf182242744181143141228ca56e/difflib.py |
i and in j. | i and in j. New in Python 2.5, it's also guaranteed that if (i, j, n) and (i', j', n') are adjacent triples in the list, and the second is not the last triple in the list, then i+n != i' or j+n != j'. IOW, adjacent triples never describe adjacent equal blocks. | def get_matching_blocks(self): """Return list of triples describing matching subsequences. | 43898b4f642acf182242744181143141228ca56e /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/43898b4f642acf182242744181143141228ca56e/difflib.py |
self.matching_blocks = matching_blocks = [] | def get_matching_blocks(self): """Return list of triples describing matching subsequences. | 43898b4f642acf182242744181143141228ca56e /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/43898b4f642acf182242744181143141228ca56e/difflib.py |
|
matching_blocks.append( (la, lb, 0) ) return matching_blocks | i1 = j1 = k1 = 0 non_adjacent = [] for i2, j2, k2 in matching_blocks: if i1 + k1 == i2 and j1 + k1 == j2: k1 += k2 else: if k1: non_adjacent.append((i1, j1, k1)) i1, j1, k1 = i2, j2, k2 if k1: non_adjacent.append((i1, j1, k1)) non_adjacent.append( (la, lb, 0) ) self.matching_blocks = non_adjacent return self.matching_blocks | def get_matching_blocks(self): """Return list of triples describing matching subsequences. | 43898b4f642acf182242744181143141228ca56e /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/43898b4f642acf182242744181143141228ca56e/difflib.py |
if type(to_addrs) == types.StringType: | if isinstance(to_addrs, types.StringTypes): | def sendmail(self, from_addr, to_addrs, msg, mail_options=[], rcpt_options=[]): """This command performs an entire mail transaction. | 3356766abfbdec49e671e0e16778139fd9b0c490 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/3356766abfbdec49e671e0e16778139fd9b0c490/smtplib.py |
print >> DEBUGSTREAM, 'we got some refusals' | print >> DEBUGSTREAM, 'we got some refusals:', refused | def process_message(self, peer, mailfrom, rcpttos, data): lines = data.split('\n') # Look for the last header i = 0 for line in lines: if not line: break i += 1 lines.insert(i, 'X-Peer: %s' % peer[0]) data = NEWLINE.join(lines) refused = self._deliver(mailfrom, rcpttos, data) # TBD: what to do with refused addresses? print >> DEBUGSTREAM, 'we got some refusals' | f151625b59bcd07e35910281444aa4a5974613c7 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/f151625b59bcd07e35910281444aa4a5974613c7/smtpd.py |
print >> DEBUGSTREAM, 'we got refusals' | print >> DEBUGSTREAM, 'we got refusals:', refused | def process_message(self, peer, mailfrom, rcpttos, data): from cStringIO import StringIO from Mailman import Utils from Mailman import Message from Mailman import MailList # If the message is to a Mailman mailing list, then we'll invoke the # Mailman script directly, without going through the real smtpd. # Otherwise we'll forward it to the local proxy for disposition. listnames = [] for rcpt in rcpttos: local = rcpt.lower().split('@')[0] # We allow the following variations on the theme # listname # listname-admin # listname-owner # listname-request # listname-join # listname-leave parts = local.split('-') if len(parts) > 2: continue listname = parts[0] if len(parts) == 2: command = parts[1] else: command = '' if not Utils.list_exists(listname) or command not in ( '', 'admin', 'owner', 'request', 'join', 'leave'): continue listnames.append((rcpt, listname, command)) # Remove all list recipients from rcpttos and forward what we're not # going to take care of ourselves. Linear removal should be fine # since we don't expect a large number of recipients. for rcpt, listname, command in listnames: rcpttos.remove(rcpt) # If there's any non-list destined recipients left, print >> DEBUGSTREAM, 'forwarding recips:', ' '.join(rcpttos) if rcpttos: refused = self._deliver(mailfrom, rcpttos, data) # TBD: what to do with refused addresses? print >> DEBUGSTREAM, 'we got refusals' # Now deliver directly to the list commands mlists = {} s = StringIO(data) msg = Message.Message(s) # These headers are required for the proper execution of Mailman. All # MTAs in existance seem to add these if the original message doesn't # have them. if not msg.getheader('from'): msg['From'] = mailfrom if not msg.getheader('date'): msg['Date'] = time.ctime(time.time()) for rcpt, listname, command in listnames: print >> DEBUGSTREAM, 'sending message to', rcpt mlist = mlists.get(listname) if not mlist: mlist = MailList.MailList(listname, lock=0) mlists[listname] = mlist # dispatch on the type of command if command == '': # post msg.Enqueue(mlist, tolist=1) elif command == 'admin': msg.Enqueue(mlist, toadmin=1) elif command == 'owner': msg.Enqueue(mlist, toowner=1) elif command == 'request': msg.Enqueue(mlist, torequest=1) elif command in ('join', 'leave'): # TBD: this is a hack! if command == 'join': msg['Subject'] = 'subscribe' else: msg['Subject'] = 'unsubscribe' msg.Enqueue(mlist, torequest=1) | f151625b59bcd07e35910281444aa4a5974613c7 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/f151625b59bcd07e35910281444aa4a5974613c7/smtpd.py |
global DEBUG | def poll (timeout=0.0, map=None): global DEBUG if map is None: map = socket_map if map: r = []; w = []; e = [] for fd, obj in map.items(): if obj.readable(): r.append (fd) if obj.writable(): w.append (fd) r,w,e = select.select (r,w,e, timeout) if DEBUG: print r,w,e for fd in r: try: obj = map[fd] except KeyError: continue try: obj.handle_read_event() except ExitNow: raise ExitNow except: obj.handle_error() for fd in w: try: obj = map[fd] except KeyError: continue try: obj.handle_write_event() except ExitNow: raise ExitNow except: obj.handle_error() | fbd5797eb7aa2f2e291a11081f5c5160614fdd45 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/fbd5797eb7aa2f2e291a11081f5c5160614fdd45/asyncore.py |
|
r,w,e = select.select (r,w,e, timeout) | try: r,w,e = select.select (r,w,e, timeout) except select.error, err: if err[0] != EINTR: raise | def poll (timeout=0.0, map=None): global DEBUG if map is None: map = socket_map if map: r = []; w = []; e = [] for fd, obj in map.items(): if obj.readable(): r.append (fd) if obj.writable(): w.append (fd) r,w,e = select.select (r,w,e, timeout) if DEBUG: print r,w,e for fd in r: try: obj = map[fd] except KeyError: continue try: obj.handle_read_event() except ExitNow: raise ExitNow except: obj.handle_error() for fd in w: try: obj = map[fd] except KeyError: continue try: obj.handle_write_event() except ExitNow: raise ExitNow except: obj.handle_error() | fbd5797eb7aa2f2e291a11081f5c5160614fdd45 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/fbd5797eb7aa2f2e291a11081f5c5160614fdd45/asyncore.py |
r = pollster.poll (timeout) | try: r = pollster.poll (timeout) except select.error, err: if err[0] != EINTR: raise r = [] | def poll3 (timeout=0.0, map=None): # Use the poll() support added to the select module in Python 2.0 if map is None: map=socket_map if timeout is not None: # timeout is in milliseconds timeout = int(timeout*1000) pollster = select.poll() if map: for fd, obj in map.items(): flags = 0 if obj.readable(): flags = select.POLLIN if obj.writable(): flags = flags | select.POLLOUT if flags: pollster.register(fd, flags) r = pollster.poll (timeout) for fd, flags in r: try: obj = map[fd] except KeyError: continue try: if (flags & select.POLLIN): obj.handle_read_event() if (flags & select.POLLOUT): obj.handle_write_event() except ExitNow: raise ExitNow except: obj.handle_error() | fbd5797eb7aa2f2e291a11081f5c5160614fdd45 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/fbd5797eb7aa2f2e291a11081f5c5160614fdd45/asyncore.py |
self.__dict__['socket'] = sock | self.socket = sock | def set_socket (self, sock, map=None): self.__dict__['socket'] = sock self._fileno = sock.fileno() self.add_channel (map) | fbd5797eb7aa2f2e291a11081f5c5160614fdd45 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/fbd5797eb7aa2f2e291a11081f5c5160614fdd45/asyncore.py |
def test_strftime_bounds_checking(self): # Make sure that strftime() checks the bounds of the various parts #of the time tuple. | caebe22038d4de526ab34cfda98047f01c53fc9d /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/caebe22038d4de526ab34cfda98047f01c53fc9d/test_time.py |
||
self.assertRaises(ValueError, time.strftime, '', (1900, 0, 1, 0, 0, 0, 0, 1, -1)) | self.assertRaises(ValueError, time.strftime, '', (1900, -1, 1, 0, 0, 0, 0, 1, -1)) | def test_strftime_bounds_checking(self): # Make sure that strftime() checks the bounds of the various parts #of the time tuple. | caebe22038d4de526ab34cfda98047f01c53fc9d /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/caebe22038d4de526ab34cfda98047f01c53fc9d/test_time.py |
self.assertRaises(ValueError, time.strftime, '', (1900, 1, 0, 0, 0, 0, 0, 1, -1)) | self.assertRaises(ValueError, time.strftime, '', (1900, 1, -1, 0, 0, 0, 0, 1, -1)) | def test_strftime_bounds_checking(self): # Make sure that strftime() checks the bounds of the various parts #of the time tuple. | caebe22038d4de526ab34cfda98047f01c53fc9d /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/caebe22038d4de526ab34cfda98047f01c53fc9d/test_time.py |
def test_strftime_bounds_checking(self): # Make sure that strftime() checks the bounds of the various parts #of the time tuple. | caebe22038d4de526ab34cfda98047f01c53fc9d /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/caebe22038d4de526ab34cfda98047f01c53fc9d/test_time.py |
||
def test_strftime_bounds_checking(self): # Make sure that strftime() checks the bounds of the various parts #of the time tuple. | caebe22038d4de526ab34cfda98047f01c53fc9d /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/caebe22038d4de526ab34cfda98047f01c53fc9d/test_time.py |
||
def test_strftime_bounds_checking(self): # Make sure that strftime() checks the bounds of the various parts #of the time tuple. | caebe22038d4de526ab34cfda98047f01c53fc9d /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/caebe22038d4de526ab34cfda98047f01c53fc9d/test_time.py |
||
self.assertRaises(ValueError, time.strftime, '', (1900, 1, 1, 0, 0, 0, 0, 0, -1)) | self.assertRaises(ValueError, time.strftime, '', (1900, 1, 1, 0, 0, 0, 0, -1, -1)) | def test_strftime_bounds_checking(self): # Make sure that strftime() checks the bounds of the various parts #of the time tuple. | caebe22038d4de526ab34cfda98047f01c53fc9d /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/caebe22038d4de526ab34cfda98047f01c53fc9d/test_time.py |
def test_strftime_bounds_checking(self): # Make sure that strftime() checks the bounds of the various parts #of the time tuple. | caebe22038d4de526ab34cfda98047f01c53fc9d /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/caebe22038d4de526ab34cfda98047f01c53fc9d/test_time.py |
||
p = subprocess.Popen(cmdline, close_fds=True) | if sys.platform[:3] == 'win': p = subprocess.Popen(cmdline) else: p = subprocess.Popen(cmdline, close_fds=True) | def open(self, url, new=0, autoraise=1): cmdline = [self.name] + [arg.replace("%s", url) for arg in self.args] try: p = subprocess.Popen(cmdline, close_fds=True) return not p.wait() except OSError: return False | 2c94bf7d410b151d6e7e38275c9dda871a5e8882 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/2c94bf7d410b151d6e7e38275c9dda871a5e8882/webbrowser.py |
setsid = getattr(os, 'setsid', None) if not setsid: setsid = getattr(os, 'setpgrp', None) | def open(self, url, new=0, autoraise=1): cmdline = [self.name] + [arg.replace("%s", url) for arg in self.args] setsid = getattr(os, 'setsid', None) if not setsid: setsid = getattr(os, 'setpgrp', None) try: p = subprocess.Popen(cmdline, close_fds=True, preexec_fn=setsid) return (p.poll() is None) except OSError: return False | 2c94bf7d410b151d6e7e38275c9dda871a5e8882 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/2c94bf7d410b151d6e7e38275c9dda871a5e8882/webbrowser.py |
|
p = subprocess.Popen(cmdline, close_fds=True, preexec_fn=setsid) | if sys.platform[:3] == 'win': p = subprocess.Popen(cmdline) else: setsid = getattr(os, 'setsid', None) if not setsid: setsid = getattr(os, 'setpgrp', None) p = subprocess.Popen(cmdline, close_fds=True, preexec_fn=setsid) | def open(self, url, new=0, autoraise=1): cmdline = [self.name] + [arg.replace("%s", url) for arg in self.args] setsid = getattr(os, 'setsid', None) if not setsid: setsid = getattr(os, 'setpgrp', None) try: p = subprocess.Popen(cmdline, close_fds=True, preexec_fn=setsid) return (p.poll() is None) except OSError: return False | 2c94bf7d410b151d6e7e38275c9dda871a5e8882 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/2c94bf7d410b151d6e7e38275c9dda871a5e8882/webbrowser.py |
module = filename | module = filename or "<unknown>" | def warn_explicit(message, category, filename, lineno, module=None, registry=None): if module is None: module = filename if module[-3:].lower() == ".py": module = module[:-3] # XXX What about leading pathname? if registry is None: registry = {} if isinstance(message, Warning): text = str(message) category = message.__class__ else: text = message message = category(message) key = (text, category, lineno) # Quick test for common case if registry.get(key): return # Search the filters for item in filters: action, msg, cat, mod, ln = item if ((msg is None or msg.match(text)) and issubclass(category, cat) and (mod is None or mod.match(module)) and (ln == 0 or lineno == ln)): break else: action = defaultaction # Early exit actions if action == "ignore": registry[key] = 1 return if action == "error": raise message # Other actions if action == "once": registry[key] = 1 oncekey = (text, category) if onceregistry.get(oncekey): return onceregistry[oncekey] = 1 elif action == "always": pass elif action == "module": registry[key] = 1 altkey = (text, category, 0) if registry.get(altkey): return registry[altkey] = 1 elif action == "default": registry[key] = 1 else: # Unrecognized actions are errors raise RuntimeError( "Unrecognized action (%r) in warnings.filters:\n %s" % (action, item)) # Print message and context showwarning(message, category, filename, lineno) | 4edd989eaf5bae40f9e11424b36b22892c5ba459 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/4edd989eaf5bae40f9e11424b36b22892c5ba459/warnings.py |
else: _tryorder = filter(lambda x: _browsers.has_key(x.lower()) or x.find("%s") > -1, _tryorder) | for cmd in _tryorder: if not _browsers.has_key(cmd.lower()): if _iscommand(cmd.lower()): register(cmd.lower(), None, GenericBrowser("%s %%s" % cmd.lower())) _tryorder = filter(lambda x: _browsers.has_key(x.lower()) or x.find("%s") > -1, _tryorder) | def open_new(self, url): # Deprecated. May be removed in 2.1. self.open(url) | cdab3bf7eb0810fcda21be065868f3da330779a1 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/cdab3bf7eb0810fcda21be065868f3da330779a1/webbrowser.py |
def _init_posix(): import os import re import string import sys | def _init_posix(): import os import re import string import sys g = globals() version = sys.version[:3] config_dir = os.path.join( sys.exec_prefix, "lib", "python" + version, "config") # load the installed config.h: define_rx = re.compile("#define ([A-Z][A-Z0-9_]+) (.*)\n") undef_rx = re.compile("/[*] #undef ([A-Z][A-Z0-9_]+) [*]/\n") fp = open(os.path.join(config_dir, "config.h")) while 1: line = fp.readline() if not line: break m = define_rx.match(line) if m: n, v = m.group(1, 2) try: v = string.atoi(v) except ValueError: pass g[n] = v else: m = undef_rx.match(line) if m: g[m.group(1)] = 0 # load the installed Makefile.pre.in: variable_rx = re.compile("([a-zA-Z][a-zA-Z0-9_]+)\s*=\s*(.*)\n") done = {} notdone = {} fp = open(os.path.join(config_dir, "Makefile")) while 1: line = fp.readline() if not line: break m = variable_rx.match(line) if m: n, v = m.group(1, 2) v = string.strip(v) if "$" in v: notdone[n] = v else: try: v = string.atoi(v) except ValueError: pass done[n] = v # do variable interpolation here findvar1_rx = re.compile(r"\$\(([A-Za-z][A-Za-z0-9_]*)\)") findvar2_rx = re.compile(r"\${([A-Za-z][A-Za-z0-9_]*)}") while notdone: for name in notdone.keys(): value = notdone[name] m = findvar1_rx.search(value) if not m: m = findvar2_rx.search(value) if m: n = m.group(1) if done.has_key(n): after = value[m.end():] value = value[:m.start()] + done[n] + after if "$" in after: notdone[name] = value else: try: value = string.atoi(value) except ValueError: pass done[name] = string.strip(value) del notdone[name] elif notdone.has_key(n): # get it on a subsequent round pass else: done[n] = "" after = value[m.end():] value = value[:m.start()] + after if "$" in after: notdone[name] = value else: try: value = string.atoi(value) except ValueError: pass done[name] = string.strip(value) del notdone[name] else: # bogus variable reference; just drop it since we can't deal del notdone[name] # save the results in the global dictionary g.update(done) | 9ddaaa1a30a8a0681b60922e877f3b7d23e6bdf6 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/9ddaaa1a30a8a0681b60922e877f3b7d23e6bdf6/sysconfig.py |
|
g = globals() | def get_config_h_filename(): return os.path.join(sys.exec_prefix, "lib", "python" + sys.version[:3], "config", "config.h") | def _init_posix(): import os import re import string import sys g = globals() version = sys.version[:3] config_dir = os.path.join( sys.exec_prefix, "lib", "python" + version, "config") # load the installed config.h: define_rx = re.compile("#define ([A-Z][A-Z0-9_]+) (.*)\n") undef_rx = re.compile("/[*] #undef ([A-Z][A-Z0-9_]+) [*]/\n") fp = open(os.path.join(config_dir, "config.h")) while 1: line = fp.readline() if not line: break m = define_rx.match(line) if m: n, v = m.group(1, 2) try: v = string.atoi(v) except ValueError: pass g[n] = v else: m = undef_rx.match(line) if m: g[m.group(1)] = 0 # load the installed Makefile.pre.in: variable_rx = re.compile("([a-zA-Z][a-zA-Z0-9_]+)\s*=\s*(.*)\n") done = {} notdone = {} fp = open(os.path.join(config_dir, "Makefile")) while 1: line = fp.readline() if not line: break m = variable_rx.match(line) if m: n, v = m.group(1, 2) v = string.strip(v) if "$" in v: notdone[n] = v else: try: v = string.atoi(v) except ValueError: pass done[n] = v # do variable interpolation here findvar1_rx = re.compile(r"\$\(([A-Za-z][A-Za-z0-9_]*)\)") findvar2_rx = re.compile(r"\${([A-Za-z][A-Za-z0-9_]*)}") while notdone: for name in notdone.keys(): value = notdone[name] m = findvar1_rx.search(value) if not m: m = findvar2_rx.search(value) if m: n = m.group(1) if done.has_key(n): after = value[m.end():] value = value[:m.start()] + done[n] + after if "$" in after: notdone[name] = value else: try: value = string.atoi(value) except ValueError: pass done[name] = string.strip(value) del notdone[name] elif notdone.has_key(n): # get it on a subsequent round pass else: done[n] = "" after = value[m.end():] value = value[:m.start()] + after if "$" in after: notdone[name] = value else: try: value = string.atoi(value) except ValueError: pass done[name] = string.strip(value) del notdone[name] else: # bogus variable reference; just drop it since we can't deal del notdone[name] # save the results in the global dictionary g.update(done) | 9ddaaa1a30a8a0681b60922e877f3b7d23e6bdf6 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/9ddaaa1a30a8a0681b60922e877f3b7d23e6bdf6/sysconfig.py |
version = sys.version[:3] config_dir = os.path.join( sys.exec_prefix, "lib", "python" + version, "config") | def get_makefile_filename(): return os.path.join(sys.exec_prefix, "lib", "python" + sys.version[:3], "config", "Makefile") | def _init_posix(): import os import re import string import sys g = globals() version = sys.version[:3] config_dir = os.path.join( sys.exec_prefix, "lib", "python" + version, "config") # load the installed config.h: define_rx = re.compile("#define ([A-Z][A-Z0-9_]+) (.*)\n") undef_rx = re.compile("/[*] #undef ([A-Z][A-Z0-9_]+) [*]/\n") fp = open(os.path.join(config_dir, "config.h")) while 1: line = fp.readline() if not line: break m = define_rx.match(line) if m: n, v = m.group(1, 2) try: v = string.atoi(v) except ValueError: pass g[n] = v else: m = undef_rx.match(line) if m: g[m.group(1)] = 0 # load the installed Makefile.pre.in: variable_rx = re.compile("([a-zA-Z][a-zA-Z0-9_]+)\s*=\s*(.*)\n") done = {} notdone = {} fp = open(os.path.join(config_dir, "Makefile")) while 1: line = fp.readline() if not line: break m = variable_rx.match(line) if m: n, v = m.group(1, 2) v = string.strip(v) if "$" in v: notdone[n] = v else: try: v = string.atoi(v) except ValueError: pass done[n] = v # do variable interpolation here findvar1_rx = re.compile(r"\$\(([A-Za-z][A-Za-z0-9_]*)\)") findvar2_rx = re.compile(r"\${([A-Za-z][A-Za-z0-9_]*)}") while notdone: for name in notdone.keys(): value = notdone[name] m = findvar1_rx.search(value) if not m: m = findvar2_rx.search(value) if m: n = m.group(1) if done.has_key(n): after = value[m.end():] value = value[:m.start()] + done[n] + after if "$" in after: notdone[name] = value else: try: value = string.atoi(value) except ValueError: pass done[name] = string.strip(value) del notdone[name] elif notdone.has_key(n): # get it on a subsequent round pass else: done[n] = "" after = value[m.end():] value = value[:m.start()] + after if "$" in after: notdone[name] = value else: try: value = string.atoi(value) except ValueError: pass done[name] = string.strip(value) del notdone[name] else: # bogus variable reference; just drop it since we can't deal del notdone[name] # save the results in the global dictionary g.update(done) | 9ddaaa1a30a8a0681b60922e877f3b7d23e6bdf6 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/9ddaaa1a30a8a0681b60922e877f3b7d23e6bdf6/sysconfig.py |
def parse_config_h(fp, g=None): if g is None: g = {} | def _init_posix(): import os import re import string import sys g = globals() version = sys.version[:3] config_dir = os.path.join( sys.exec_prefix, "lib", "python" + version, "config") # load the installed config.h: define_rx = re.compile("#define ([A-Z][A-Z0-9_]+) (.*)\n") undef_rx = re.compile("/[*] #undef ([A-Z][A-Z0-9_]+) [*]/\n") fp = open(os.path.join(config_dir, "config.h")) while 1: line = fp.readline() if not line: break m = define_rx.match(line) if m: n, v = m.group(1, 2) try: v = string.atoi(v) except ValueError: pass g[n] = v else: m = undef_rx.match(line) if m: g[m.group(1)] = 0 # load the installed Makefile.pre.in: variable_rx = re.compile("([a-zA-Z][a-zA-Z0-9_]+)\s*=\s*(.*)\n") done = {} notdone = {} fp = open(os.path.join(config_dir, "Makefile")) while 1: line = fp.readline() if not line: break m = variable_rx.match(line) if m: n, v = m.group(1, 2) v = string.strip(v) if "$" in v: notdone[n] = v else: try: v = string.atoi(v) except ValueError: pass done[n] = v # do variable interpolation here findvar1_rx = re.compile(r"\$\(([A-Za-z][A-Za-z0-9_]*)\)") findvar2_rx = re.compile(r"\${([A-Za-z][A-Za-z0-9_]*)}") while notdone: for name in notdone.keys(): value = notdone[name] m = findvar1_rx.search(value) if not m: m = findvar2_rx.search(value) if m: n = m.group(1) if done.has_key(n): after = value[m.end():] value = value[:m.start()] + done[n] + after if "$" in after: notdone[name] = value else: try: value = string.atoi(value) except ValueError: pass done[name] = string.strip(value) del notdone[name] elif notdone.has_key(n): # get it on a subsequent round pass else: done[n] = "" after = value[m.end():] value = value[:m.start()] + after if "$" in after: notdone[name] = value else: try: value = string.atoi(value) except ValueError: pass done[name] = string.strip(value) del notdone[name] else: # bogus variable reference; just drop it since we can't deal del notdone[name] # save the results in the global dictionary g.update(done) | 9ddaaa1a30a8a0681b60922e877f3b7d23e6bdf6 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/9ddaaa1a30a8a0681b60922e877f3b7d23e6bdf6/sysconfig.py |
|
fp = open(os.path.join(config_dir, "config.h")) | undef_rx = re.compile("/[*] #undef ([A-Z][A-Z0-9_]+) [*]/\n") | 9ddaaa1a30a8a0681b60922e877f3b7d23e6bdf6 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/9ddaaa1a30a8a0681b60922e877f3b7d23e6bdf6/sysconfig.py |
|
def parse_makefile(fp, g=None): if g is None: g = {} | undef_rx = re.compile("/[*] #undef ([A-Z][A-Z0-9_]+) [*]/\n") | 9ddaaa1a30a8a0681b60922e877f3b7d23e6bdf6 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/9ddaaa1a30a8a0681b60922e877f3b7d23e6bdf6/sysconfig.py |
|
fp = open(os.path.join(config_dir, "Makefile")) | undef_rx = re.compile("/[*] #undef ([A-Z][A-Z0-9_]+) [*]/\n") | 9ddaaa1a30a8a0681b60922e877f3b7d23e6bdf6 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/9ddaaa1a30a8a0681b60922e877f3b7d23e6bdf6/sysconfig.py |
|
import os exec "_init_%s()" % os.name del os | def _init_posix(): g = globals() parse_config_h(open(get_config_h_filename()), g) parse_makefile(open(get_makefile_filename()), g) try: exec "_init_" + os.name except NameError: pass else: exec "_init_%s()" % os.name | undef_rx = re.compile("/[*] #undef ([A-Z][A-Z0-9_]+) [*]/\n") | 9ddaaa1a30a8a0681b60922e877f3b7d23e6bdf6 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/9ddaaa1a30a8a0681b60922e877f3b7d23e6bdf6/sysconfig.py |
posix = True | posix = False | def isdev(self): return self.type in (CHRTYPE, BLKTYPE, FIFOTYPE) | 75b9da4aaf6b1636a116f4afd5b0d11a642c4401 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/75b9da4aaf6b1636a116f4afd5b0d11a642c4401/tarfile.py |
tarinfo.size = statres.st_size | tarinfo.size = not stat.S_ISDIR(stmd) and statres.st_size or 0 | def gettarinfo(self, name=None, arcname=None, fileobj=None): """Create a TarInfo object for either the file `name' or the file object `fileobj' (using os.fstat on its file descriptor). You can modify some of the TarInfo's attributes before you add it using addfile(). If given, `arcname' specifies an alternative name for the file in the archive. """ self._check("aw") | 75b9da4aaf6b1636a116f4afd5b0d11a642c4401 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/75b9da4aaf6b1636a116f4afd5b0d11a642c4401/tarfile.py |
r = typ.__repr__ | r = getattr(typ, "__repr__", None) | def _format(self, object, stream, indent, allowance, context, level): level = level + 1 objid = _id(object) if objid in context: stream.write(_recursion(object)) self._recursive = True self._readable = False return rep = self._repr(object, context, level - 1) typ = _type(object) sepLines = _len(rep) > (self._width - 1 - indent - allowance) write = stream.write | 1b626cac734c7995849ce4b5d694edbd89e44c4a /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/1b626cac734c7995849ce4b5d694edbd89e44c4a/pprint.py |
r = typ.__repr__ | r = getattr(typ, "__repr__", None) | def _safe_repr(object, context, maxlevels, level): typ = _type(object) if typ is str: if 'locale' not in _sys.modules: return repr(object), True, False if "'" in object and '"' not in object: closure = '"' quotes = {'"': '\\"'} else: closure = "'" quotes = {"'": "\\'"} qget = quotes.get sio = _StringIO() write = sio.write for char in object: if char.isalpha(): write(char) else: write(qget(char, repr(char)[1:-1])) return ("%s%s%s" % (closure, sio.getvalue(), closure)), True, False r = typ.__repr__ if issubclass(typ, dict) and r is dict.__repr__: if not object: return "{}", True, False objid = _id(object) if maxlevels and level > maxlevels: return "{...}", False, objid in context if objid in context: return _recursion(object), False, True context[objid] = 1 readable = True recursive = False components = [] append = components.append level += 1 saferepr = _safe_repr for k, v in object.iteritems(): krepr, kreadable, krecur = saferepr(k, context, maxlevels, level) vrepr, vreadable, vrecur = saferepr(v, context, maxlevels, level) append("%s: %s" % (krepr, vrepr)) readable = readable and kreadable and vreadable if krecur or vrecur: recursive = True del context[objid] return "{%s}" % _commajoin(components), readable, recursive if (issubclass(typ, list) and r is list.__repr__) or \ (issubclass(typ, tuple) and r is tuple.__repr__): if issubclass(typ, list): if not object: return "[]", True, False format = "[%s]" elif _len(object) == 1: format = "(%s,)" else: if not object: return "()", True, False format = "(%s)" objid = _id(object) if maxlevels and level > maxlevels: return format % "...", False, objid in context if objid in context: return _recursion(object), False, True context[objid] = 1 readable = True recursive = False components = [] append = components.append level += 1 for o in object: orepr, oreadable, orecur = _safe_repr(o, context, maxlevels, level) append(orepr) if not oreadable: readable = False if orecur: recursive = True del context[objid] return format % _commajoin(components), readable, recursive rep = repr(object) return rep, (rep and not rep.startswith('<')), False | 1b626cac734c7995849ce4b5d694edbd89e44c4a /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/1b626cac734c7995849ce4b5d694edbd89e44c4a/pprint.py |
n = ((n+3)/4)*4 | n = ((n+3)//4)*4 | def pack_fstring(self, n, s): if n < 0: raise ValueError, 'fstring size must be nonnegative' data = s[:n] n = ((n+3)/4)*4 data = data + (n - len(data)) * '\0' self.__buf.write(data) | 4f564bd68a5bf3e22c81c0c74f0e781fa0d3f70a /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/4f564bd68a5bf3e22c81c0c74f0e781fa0d3f70a/xdrlib.py |
j = i + (n+3)/4*4 | j = i + (n+3)//4*4 | def unpack_fstring(self, n): if n < 0: raise ValueError, 'fstring size must be nonnegative' i = self.__pos j = i + (n+3)/4*4 if j > len(self.__buf): raise EOFError self.__pos = j return self.__buf[i:i+n] | 4f564bd68a5bf3e22c81c0c74f0e781fa0d3f70a /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/4f564bd68a5bf3e22c81c0c74f0e781fa0d3f70a/xdrlib.py |
if size < 0: size = sys.maxint | if size < 0: size = sys.maxint readsize = self.min_readsize else: readsize = size | def readline(self, size=-1): if size < 0: size = sys.maxint bufs = [] readsize = min(100, size) # Read from the file in small chunks while True: if size == 0: return "".join(bufs) # Return resulting line | d82c3105cced4ef0b8d99f1703dda4c4bf4cc0b5 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/d82c3105cced4ef0b8d99f1703dda4c4bf4cc0b5/gzip.py |
readsize = min(100, size) while True: if size == 0: return "".join(bufs) | while size != 0: | def readline(self, size=-1): if size < 0: size = sys.maxint bufs = [] readsize = min(100, size) # Read from the file in small chunks while True: if size == 0: return "".join(bufs) # Return resulting line | d82c3105cced4ef0b8d99f1703dda4c4bf4cc0b5 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/d82c3105cced4ef0b8d99f1703dda4c4bf4cc0b5/gzip.py |
if size is not None: if i==-1 and len(c) > size: i=size-1 elif size <= i: i = size -1 | if (size <= i) or (i == -1 and len(c) > size): i = size - 1 | def readline(self, size=-1): if size < 0: size = sys.maxint bufs = [] readsize = min(100, size) # Read from the file in small chunks while True: if size == 0: return "".join(bufs) # Return resulting line | d82c3105cced4ef0b8d99f1703dda4c4bf4cc0b5 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/d82c3105cced4ef0b8d99f1703dda4c4bf4cc0b5/gzip.py |
bufs.append(c[:i+1]) self._unread(c[i+1:]) return ''.join(bufs) | bufs.append(c[:i + 1]) self._unread(c[i + 1:]) break | def readline(self, size=-1): if size < 0: size = sys.maxint bufs = [] readsize = min(100, size) # Read from the file in small chunks while True: if size == 0: return "".join(bufs) # Return resulting line | d82c3105cced4ef0b8d99f1703dda4c4bf4cc0b5 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/d82c3105cced4ef0b8d99f1703dda4c4bf4cc0b5/gzip.py |
except AttrinuteError: | except AttributeError: | def do_mouseDown(self, event): (what, message, when, where, modifiers) = event partcode, window = FindWindow(where) if partname.has_key(partcode): name = "do_" + partname[partcode] else: name = "do_%d" % partcode try: handler = getattr(self, name) except AttrinuteError: handler = self.do_unknownpartcode handler(partcode, window, event) | 7a58336511b8c405e01bcda0b886b19c2947189a /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/7a58336511b8c405e01bcda0b886b19c2947189a/FrameWork.py |
print "Should close window:", window | if DEBUG: print "Should close window:", window | def do_close(self, window): print "Should close window:", window | 7a58336511b8c405e01bcda0b886b19c2947189a /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/7a58336511b8c405e01bcda0b886b19c2947189a/FrameWork.py |
print "SystemClick", event, window | MacOS.HandleEvent(event) | def do_inSysWindow(self, partcode, window, event): print "SystemClick", event, window # SystemClick(event, window) # XXX useless, window is None | 7a58336511b8c405e01bcda0b886b19c2947189a /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/7a58336511b8c405e01bcda0b886b19c2947189a/FrameWork.py |
print "inDesk" | def do_inDesk(self, partcode, window, event): print "inDesk" # XXX what to do with it? | 7a58336511b8c405e01bcda0b886b19c2947189a /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/7a58336511b8c405e01bcda0b886b19c2947189a/FrameWork.py |
|
print "FindControl(%s, %s) -> (%s, %s)" % \ | if DEBUG: print "FindControl(%s, %s) -> (%s, %s)" % \ | def do_inContent(self, partcode, window, event): (what, message, when, where, modifiers) = event local = GlobalToLocal(where) ctltype, control = FindControl(local, window) if ctltype and control: pcode = control.TrackControl(local) if pcode: self.do_controlhit(window, control, pcode, event) else: print "FindControl(%s, %s) -> (%s, %s)" % \ (local, window, ctltype, control) | 7a58336511b8c405e01bcda0b886b19c2947189a /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/7a58336511b8c405e01bcda0b886b19c2947189a/FrameWork.py |
print "control hit in", window, "on", control, "; pcode =", pcode | if DEBUG: print "control hit in", window, "on", control, "; pcode =", pcode | def do_controlhit(self, window, control, pcode, event): print "control hit in", window, "on", control, "; pcode =", pcode | 7a58336511b8c405e01bcda0b886b19c2947189a /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/7a58336511b8c405e01bcda0b886b19c2947189a/FrameWork.py |
print "Mouse down at global:", where print "\tUnknown part code:", partcode | if DEBUG: print "Mouse down at global:", where if DEBUG: print "\tUnknown part code:", partcode MacOS.HandleEvent(event) | def do_unknownpartcode(self, partcode, window, event): (what, message, when, where, modifiers) = event print "Mouse down at global:", where print "\tUnknown part code:", partcode | 7a58336511b8c405e01bcda0b886b19c2947189a /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/7a58336511b8c405e01bcda0b886b19c2947189a/FrameWork.py |
print 'Command-W without front window' | if DEBUG: print 'Command-W without front window' | def do_key(self, event): (what, message, when, where, modifiers) = event c = chr(message & charCodeMask) if modifiers & cmdKey: if c == '.': raise self else: result = MenuKey(ord(c)) id = (result>>16) & 0xffff # Hi word item = result & 0xffff # Lo word if id: self.do_rawmenu(id, item, None, event) elif c == 'w': w = FrontWindow() if w: self.do_close(w) else: print 'Command-W without front window' else: print "Command-" +`c` else: self.do_char(c, event) | 7a58336511b8c405e01bcda0b886b19c2947189a /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/7a58336511b8c405e01bcda0b886b19c2947189a/FrameWork.py |
print "Command-" +`c` | if DEBUG: print "Command-" +`c` | def do_key(self, event): (what, message, when, where, modifiers) = event c = chr(message & charCodeMask) if modifiers & cmdKey: if c == '.': raise self else: result = MenuKey(ord(c)) id = (result>>16) & 0xffff # Hi word item = result & 0xffff # Lo word if id: self.do_rawmenu(id, item, None, event) elif c == 'w': w = FrontWindow() if w: self.do_close(w) else: print 'Command-W without front window' else: print "Command-" +`c` else: self.do_char(c, event) | 7a58336511b8c405e01bcda0b886b19c2947189a /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/7a58336511b8c405e01bcda0b886b19c2947189a/FrameWork.py |
print "Character", `c` | if DEBUG: print "Character", `c` | def do_char(self, c, event): print "Character", `c` | 7a58336511b8c405e01bcda0b886b19c2947189a /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/7a58336511b8c405e01bcda0b886b19c2947189a/FrameWork.py |
print "do_update", self.printevent(event) | if DEBUG: print "do_update", self.printevent(event) | def do_updateEvt(self, event): print "do_update", self.printevent(event) window = FrontWindow() # XXX This is wrong! if window: self.do_rawupdate(window, event) else: print "no window for do_updateEvt" | 7a58336511b8c405e01bcda0b886b19c2947189a /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/7a58336511b8c405e01bcda0b886b19c2947189a/FrameWork.py |
print "no window for do_updateEvt" | MacOS.HandleEvent(event) | def do_updateEvt(self, event): print "do_update", self.printevent(event) window = FrontWindow() # XXX This is wrong! if window: self.do_rawupdate(window, event) else: print "no window for do_updateEvt" | 7a58336511b8c405e01bcda0b886b19c2947189a /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/7a58336511b8c405e01bcda0b886b19c2947189a/FrameWork.py |
print "raw update for", window | if DEBUG: print "raw update for", window | def do_rawupdate(self, window, event): print "raw update for", window window.BeginUpdate() self.do_update(window, event) DrawControls(window) window.DrawGrowIcon() window.EndUpdate() | 7a58336511b8c405e01bcda0b886b19c2947189a /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/7a58336511b8c405e01bcda0b886b19c2947189a/FrameWork.py |
print "High Level Event:", self.printevent(event) | if DEBUG: print "High Level Event:", self.printevent(event) | def do_kHighLevelEvent(self, event): (what, message, when, where, modifiers) = event print "High Level Event:", self.printevent(event) try: AEProcessAppleEvent(event) except: print "AEProcessAppleEvent error:" traceback.print_exc() | 7a58336511b8c405e01bcda0b886b19c2947189a /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/7a58336511b8c405e01bcda0b886b19c2947189a/FrameWork.py |
print "MenuBar.dispatch(%d, %d, %s, %s)" % \ | if DEBUG: print "MenuBar.dispatch(%d, %d, %s, %s)" % \ | def dispatch(self, id, item, window, event): if self.menus.has_key(id): self.menus[id].dispatch(id, item, window, event) else: print "MenuBar.dispatch(%d, %d, %s, %s)" % \ (id, item, window, event) | 7a58336511b8c405e01bcda0b886b19c2947189a /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/7a58336511b8c405e01bcda0b886b19c2947189a/FrameWork.py |
os.environ.update(env) | def run_cgi(self): """Execute a CGI script.""" dir, rest = self.cgi_info i = rest.rfind('?') if i >= 0: rest, query = rest[:i], rest[i+1:] else: query = '' i = rest.find('/') if i >= 0: script, rest = rest[:i], rest[i:] else: script, rest = rest, '' scriptname = dir + '/' + script scriptfile = self.translate_path(scriptname) if not os.path.exists(scriptfile): self.send_error(404, "No such CGI script (%s)" % `scriptname`) return if not os.path.isfile(scriptfile): self.send_error(403, "CGI script is not a plain file (%s)" % `scriptname`) return ispy = self.is_python(scriptname) if not ispy: if not (self.have_fork or self.have_popen2 or self.have_popen3): self.send_error(403, "CGI script is not a Python script (%s)" % `scriptname`) return if not self.is_executable(scriptfile): self.send_error(403, "CGI script is not executable (%s)" % `scriptname`) return | 0bd783228538b761e9b75cea3f42931c2d4ba6c6 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/0bd783228538b761e9b75cea3f42931c2d4ba6c6/CGIHTTPServer.py |
|
os.environ.update(env) | def run_cgi(self): """Execute a CGI script.""" dir, rest = self.cgi_info i = rest.rfind('?') if i >= 0: rest, query = rest[:i], rest[i+1:] else: query = '' i = rest.find('/') if i >= 0: script, rest = rest[:i], rest[i:] else: script, rest = rest, '' scriptname = dir + '/' + script scriptfile = self.translate_path(scriptname) if not os.path.exists(scriptfile): self.send_error(404, "No such CGI script (%s)" % `scriptname`) return if not os.path.isfile(scriptfile): self.send_error(403, "CGI script is not a plain file (%s)" % `scriptname`) return ispy = self.is_python(scriptname) if not ispy: if not (self.have_fork or self.have_popen2 or self.have_popen3): self.send_error(403, "CGI script is not a Python script (%s)" % `scriptname`) return if not self.is_executable(scriptfile): self.send_error(403, "CGI script is not executable (%s)" % `scriptname`) return | 0bd783228538b761e9b75cea3f42931c2d4ba6c6 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/0bd783228538b761e9b75cea3f42931c2d4ba6c6/CGIHTTPServer.py |
|
funcs = (None, lambda x: True) | funcs = (None, bool, lambda x: True) | def test_filter_subclasses(self): # test, that filter() never returns tuple, str or unicode subclasses # and that the result always go's through __getitem__ funcs = (None, lambda x: True) class tuple2(tuple): def __getitem__(self, index): return 2*tuple.__getitem__(self, index) class str2(str): def __getitem__(self, index): return 2*str.__getitem__(self, index) inputs = { tuple2: {(): (), (1, 2, 3): (2, 4, 6)}, str2: {"": "", "123": "112233"} } if have_unicode: class unicode2(unicode): def __getitem__(self, index): return 2*unicode.__getitem__(self, index) inputs[unicode2] = { unicode(): unicode(), unicode("123"): unicode("112233") } | c8cb5d9d6950bb9e3b407c6b4a8dd2831f5edee9 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/c8cb5d9d6950bb9e3b407c6b4a8dd2831f5edee9/test_builtin.py |
L2 = L | L2 = L[:] | def test_long(self): self.assertEqual(long(314), 314L) self.assertEqual(long(3.14), 3L) self.assertEqual(long(314L), 314L) # Check that conversion from float truncates towards zero self.assertEqual(long(-3.14), -3L) self.assertEqual(long(3.9), 3L) self.assertEqual(long(-3.9), -3L) self.assertEqual(long(3.5), 3L) self.assertEqual(long(-3.5), -3L) self.assertEqual(long("-3"), -3L) if have_unicode: self.assertEqual(long(unicode("-3")), -3L) # Different base: self.assertEqual(long("10",16), 16L) if have_unicode: self.assertEqual(long(unicode("10"),16), 16L) # Check conversions from string (same test set as for int(), and then some) LL = [ ('1' + '0'*20, 10L**20), ('1' + '0'*100, 10L**100) ] L2 = L if have_unicode: L2 += [ (unicode('1') + unicode('0')*20, 10L**20), (unicode('1') + unicode('0')*100, 10L**100), ] for s, v in L2 + LL: for sign in "", "+", "-": for prefix in "", " ", "\t", " \t\t ": ss = prefix + sign + s vv = v if sign == "-" and v is not ValueError: vv = -v try: self.assertEqual(long(ss), long(vv)) except v: pass | c8cb5d9d6950bb9e3b407c6b4a8dd2831f5edee9 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/c8cb5d9d6950bb9e3b407c6b4a8dd2831f5edee9/test_builtin.py |
tmp_file.close() | _sync_close(tmp_file) | def add(self, message): """Add message and return assigned key.""" tmp_file = self._create_tmp() try: self._dump_message(message, tmp_file) finally: tmp_file.close() if isinstance(message, MaildirMessage): subdir = message.get_subdir() suffix = self.colon + message.get_info() if suffix == self.colon: suffix = '' else: subdir = 'new' suffix = '' uniq = os.path.basename(tmp_file.name).split(self.colon)[0] dest = os.path.join(self._path, subdir, uniq + suffix) os.rename(tmp_file.name, dest) if isinstance(message, MaildirMessage): os.utime(dest, (os.path.getatime(dest), message.get_date())) return uniq | b5686da24f7cb7b4a7fb66d8263e5479653f5def /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/b5686da24f7cb7b4a7fb66d8263e5479653f5def/mailbox.py |
new_file.close() | _sync_close(new_file) | def flush(self): """Write any pending changes to disk.""" if not self._pending: return self._lookup() new_file = _create_temporary(self._path) try: new_toc = {} self._pre_mailbox_hook(new_file) for key in sorted(self._toc.keys()): start, stop = self._toc[key] self._file.seek(start) self._pre_message_hook(new_file) new_start = new_file.tell() while True: buffer = self._file.read(min(4096, stop - self._file.tell())) if buffer == '': break new_file.write(buffer) new_toc[key] = (new_start, new_file.tell()) self._post_message_hook(new_file) except: new_file.close() os.remove(new_file.name) raise new_file.close() self._file.close() try: os.rename(new_file.name, self._path) except OSError, e: if e.errno == errno.EEXIST or \ (os.name == 'os2' and e.errno == errno.EACCES): os.remove(self._path) os.rename(new_file.name, self._path) else: raise self._file = open(self._path, 'rb+') self._toc = new_toc self._pending = False if self._locked: _lock_file(self._file, dotlock=False) | b5686da24f7cb7b4a7fb66d8263e5479653f5def /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/b5686da24f7cb7b4a7fb66d8263e5479653f5def/mailbox.py |
self._file.close() | self._file.close() | def close(self): """Flush and close the mailbox.""" self.flush() if self._locked: self.unlock() self._file.close() | b5686da24f7cb7b4a7fb66d8263e5479653f5def /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/b5686da24f7cb7b4a7fb66d8263e5479653f5def/mailbox.py |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.