bugged
stringlengths
4
228k
fixed
stringlengths
0
96.3M
__index_level_0__
int64
0
481k
def count(s, *args): """count(s, sub[, start[,end]]) -> int Return the number of occurrences of substring sub in string s[start:end]. Optional arguments start and end are interpreted as in slice notation. """ return _apply(s.count, args)
def count(s, *args): """count(s, sub[, start[,end]]) -> int Return the number of occurrences of substring sub in string s[start:end]. Optional arguments start and end are interpreted as in slice notation. """ return s.count(*args)
23,300
def find(s, *args): """find(s, sub [,start [,end]]) -> in Return the lowest index in s where substring sub is found, such that sub is contained within s[start,end]. Optional arguments start and end are interpreted as in slice notation. Return -1 on failure. """ return _apply(s.find, args)
def find(s, *args): """find(s, sub [,start [,end]]) -> in Return the lowest index in s where substring sub is found, such that sub is contained within s[start,end]. Optional arguments start and end are interpreted as in slice notation. Return -1 on failure. """ return s.find(*args)
23,301
def rfind(s, *args): """rfind(s, sub [,start [,end]]) -> int Return the highest index in s where substring sub is found, such that sub is contained within s[start,end]. Optional arguments start and end are interpreted as in slice notation. Return -1 on failure. """ return _apply(s.rfind, args)
def rfind(s, *args): """rfind(s, sub [,start [,end]]) -> int Return the highest index in s where substring sub is found, such that sub is contained within s[start,end]. Optional arguments start and end are interpreted as in slice notation. Return -1 on failure. """ return s.rfind(*args)
23,302
def ljust(s, width): """ljust(s, width) -> string Return a left-justified version of s, in a field of the specified width, padded with spaces as needed. The string is never truncated. """ n = width - len(s) if n <= 0: return s return s + ' '*n
def ljust(s, width): """ljust(s, width) -> string Return a left-justified version of s, in a field of the specified width, padded with spaces as needed. The string is never truncated. """ return s.ljust(width)
23,303
def rjust(s, width): """rjust(s, width) -> string Return a right-justified version of s, in a field of the specified width, padded with spaces as needed. The string is never truncated. """ n = width - len(s) if n <= 0: return s return ' '*n + s
def rjust(s, width): """rjust(s, width) -> string Return a right-justified version of s, in a field of the specified width, padded with spaces as needed. The string is never truncated. """ return s.rjust(width)
23,304
def center(s, width): """center(s, width) -> string Return a center version of s, in a field of the specified width. padded with spaces as needed. The string is never truncated. """ n = width - len(s) if n <= 0: return s half = n/2 if n%2 and width%2: # This ensures that center(center(s, i), j) = center(s, j) half =...
def center(s, width): """center(s, width) -> string Return a center version of s, in a field of the specified width. padded with spaces as needed. The string is never truncated. """ n = width - len(s) if n <= 0: return s half = n/2 if n%2 and width%2: # This ensures that center(center(s, i), j) = center(s, j) half =...
23,305
def expandtabs(s, tabsize=8): """expandtabs(s [,tabsize]) -> string Return a copy of the string s with all tab characters replaced by the appropriate number of spaces, depending on the current column, and the tabsize (default 8). """ res = line = '' for c in s: if c == '\t': c = ' '*(tabsize - len(line) % tabsize) li...
def expandtabs(s, tabsize=8): """expandtabs(s [,tabsize]) -> string Return a copy of the string s with all tab characters replaced by the appropriate number of spaces, depending on the current column, and the tabsize (default 8). """ return s.expandtabs(tabsize)
23,306
def replace(s, old, new, maxsplit=-1): """replace (str, old, new[, maxsplit]) -> string Return a copy of string str with all occurrences of substring old replaced by new. If the optional argument maxsplit is given, only the first maxsplit occurrences are replaced. """ return s.replace(old, new, maxsplit)
def replace(s, old, new, maxsplit=-1): """replace (str, old, new[, maxsplit]) -> string Return a copy of string str with all occurrences of substring old replaced by new. If the optional argument maxsplit is given, only the first maxsplit occurrences are replaced. """ return s.replace(old, new, maxsplit)
23,307
def printsum(filename, out = sys.stdout): try: fp = open(filename, rmode) except IOError, msg: sys.stderr.write('%s: Can\'t open: %s\n' % (filename, msg)) return 1 if fnfilter: filename = fnfilter(filename) sts = printsumfp(fp, filename, out) fp.close() return sts
def printsum(filename, out=sys.stdout): try: fp = open(filename, rmode) except IOError, msg: sys.stderr.write('%s: Can\'t open: %s\n' % (filename, msg)) return 1 if fnfilter: filename = fnfilter(filename) sts = printsumfp(fp, filename, out) fp.close() return sts
23,308
def printsumfp(fp, filename, out = sys.stdout): m = md5.new() try: while 1: data = fp.read(bufsize) if not data: break m.update(data) except IOError, msg: sys.stderr.write('%s: I/O error: %s\n' % (filename, msg)) return 1 out.write('%s %s\n' % (m.hexdigest(), filename)) return 0
def printsumfp(fp, filename, out=sys.stdout): m = md5.new() try: while 1: data = fp.read(bufsize) if not data: break m.update(data) except IOError, msg: sys.stderr.write('%s: I/O error: %s\n' % (filename, msg)) return 1 out.write('%s %s\n' % (m.hexdigest(), filename)) return 0
23,309
def printsumfp(fp, filename, out = sys.stdout): m = md5.new() try: while 1: data = fp.read(bufsize) if not data: break m.update(data) except IOError, msg: sys.stderr.write('%s: I/O error: %s\n' % (filename, msg)) return 1 out.write('%s %s\n' % (m.hexdigest(), filename)) return 0
def printsumfp(fp, filename, out = sys.stdout): m = md5.new() try: while 1: data = fp.read(bufsize) if not data: break m.update(data) except IOError, msg: sys.stderr.write('%s: I/O error: %s\n' % (filename, msg)) return 1 out.write('%s %s\n' % (m.hexdigest(), filename)) return 0
23,310
def main(args = sys.argv[1:], out = sys.stdout): global fnfilter, rmode, bufsize try: opts, args = getopt.getopt(args, 'blts:') except getopt.error, msg: sys.stderr.write('%s: %s\n%s' % (sys.argv[0], msg, usage)) return 2 for o, a in opts: if o == '-l': fnfilter = os.path.basename if o == '-b': rmode = 'rb' if o == '-t...
def main(args = sys.argv[1:], out=sys.stdout): global fnfilter, rmode, bufsize try: opts, args = getopt.getopt(args, 'blts:') except getopt.error, msg: sys.stderr.write('%s: %s\n%s' % (sys.argv[0], msg, usage)) return 2 for o, a in opts: if o == '-l': fnfilter = os.path.basename if o == '-b': rmode = 'rb' if o == '-t':...
23,311
def main(args = sys.argv[1:], out = sys.stdout): global fnfilter, rmode, bufsize try: opts, args = getopt.getopt(args, 'blts:') except getopt.error, msg: sys.stderr.write('%s: %s\n%s' % (sys.argv[0], msg, usage)) return 2 for o, a in opts: if o == '-l': fnfilter = os.path.basename if o == '-b': rmode = 'rb' if o == '-t...
def main(args = sys.argv[1:], out = sys.stdout): global fnfilter, rmode, bufsize try: opts, args = getopt.getopt(args, 'blts:') except getopt.error, msg: sys.stderr.write('%s: %s\n%s' % (sys.argv[0], msg, usage)) return 2 for o, a in opts: if o == '-l': fnfilter = os.path.basename elif o == '-b': rmode = 'rb' if o == '...
23,312
def main(args = sys.argv[1:], out = sys.stdout): global fnfilter, rmode, bufsize try: opts, args = getopt.getopt(args, 'blts:') except getopt.error, msg: sys.stderr.write('%s: %s\n%s' % (sys.argv[0], msg, usage)) return 2 for o, a in opts: if o == '-l': fnfilter = os.path.basename if o == '-b': rmode = 'rb' if o == '-t...
def main(args = sys.argv[1:], out = sys.stdout): global fnfilter, rmode, bufsize try: opts, args = getopt.getopt(args, 'blts:') except getopt.error, msg: sys.stderr.write('%s: %s\n%s' % (sys.argv[0], msg, usage)) return 2 for o, a in opts: if o == '-l': fnfilter = os.path.basename if o == '-b': rmode = 'rb' elif o == '...
23,313
def main(args = sys.argv[1:], out = sys.stdout): global fnfilter, rmode, bufsize try: opts, args = getopt.getopt(args, 'blts:') except getopt.error, msg: sys.stderr.write('%s: %s\n%s' % (sys.argv[0], msg, usage)) return 2 for o, a in opts: if o == '-l': fnfilter = os.path.basename if o == '-b': rmode = 'rb' if o == '-t...
def main(args = sys.argv[1:], out = sys.stdout): global fnfilter, rmode, bufsize try: opts, args = getopt.getopt(args, 'blts:') except getopt.error, msg: sys.stderr.write('%s: %s\n%s' % (sys.argv[0], msg, usage)) return 2 for o, a in opts: if o == '-l': fnfilter = os.path.basename if o == '-b': rmode = 'rb' if o == '-t...
23,314
def test_one(self, x, pack=struct.pack, unpack=struct.unpack, unhexlify=binascii.unhexlify): if verbose: print "trying std", self.formatpair, "on", x, "==", hex(x)
def test_one(self, x, pack=struct.pack, unpack=struct.unpack, unhexlify=binascii.unhexlify): if verbose: print "trying std", self.formatpair, "on", x, "==", hex(x)
23,315
def msg(str): sys.stderr.write(str + '\n')
def msg(str): sys.stderr.write(str + '\n')
23,316
def f(): for i in range(1000): yield i
def f(): for i in range(1000): yield i
23,317
def __getitem__(self, key): return str(key) + '!!!'
def __getitem__(self, key): return str(key) + '!!!'
23,318
def selfmodifyingComparison(x,y): z.append(1) return cmp(x, y)
def selfmodifyingComparison(x,y): z.append(1) return cmp(x, y)
23,319
def __getitem__(self, key): return str(key) + '!!!'
def __getitem__(self, key): return str(key) + '!!!'
23,320
def test01_join(self): if verbose: print '\n', '-=' * 30 print "Running %s.test01_join..." % \ self.__class__.__name__
def test01_join(self): if verbose: print '\n', '-=' * 30 print "Running %s.test01_join..." % \ self.__class__.__name__
23,321
def test01_join(self): if verbose: print '\n', '-=' * 30 print "Running %s.test01_join..." % \ self.__class__.__name__
def test01_join(self): if verbose: print '\n', '-=' * 30 print "Running %s.test01_join..." % \ self.__class__.__name__
23,322
def guess_type(self, path): """Guess the type of a file.
def if not mimetypes.inited: mimetypes.init() guess_type(self, if not mimetypes.inited: mimetypes.init() path): if not mimetypes.inited: mimetypes.init() """Guess if not mimetypes.inited: mimetypes.init() the if not mimetypes.inited: mimetypes.init() type if not mimetypes.inited: mimetypes.init() of if not mimetypes.in...
23,323
def is_empty (self): return self.list == []
def is_empty (self): return self.list == []
23,324
def run_test(name, thunk): if verbose: print "testing %s..." % name, try: thunk() except TestFailed: if verbose: print "failed (expected %s but got %s)" % (result, test_result) raise TestFailed, name else: if verbose: print "ok"
def run_test(name, thunk): if verbose: print "testing %s..." % name, thunk() if verbose: print "ok"
23,325
def test_list(): l = [] l.append(l) gc.collect() del l if gc.collect() != 1: raise TestFailed
def test_list(): l = [] l.append(l) gc.collect() del l expect(gc.collect(), 1, "list")
23,326
def test_dict(): d = {} d[1] = d gc.collect() del d if gc.collect() != 1: raise TestFailed
def test_dict(): d = {} d[1] = d gc.collect() del d expect(gc.collect(), 1, "dict")
23,327
def test_tuple(): # since tuples are immutable we close the loop with a list l = [] t = (l,) l.append(t) gc.collect() del t del l if gc.collect() != 2: raise TestFailed
def test_tuple(): # since tuples are immutable we close the loop with a list l = [] t = (l,) l.append(t) gc.collect() del t del l expect(gc.collect(), 2, "tuple")
23,328
def test_class(): class A: pass A.a = A gc.collect() del A if gc.collect() == 0: raise TestFailed
def test_class(): class A: pass A.a = A gc.collect() del A expect_not(gc.collect(), 0, "class")
23,329
def test_instance(): class A: pass a = A() a.a = a gc.collect() del a if gc.collect() == 0: raise TestFailed
def test_instance(): class A: pass a = A() a.a = a gc.collect() del a expect_not(gc.collect(), 0, "instance")
23,330
def __init__(self): self.init = self.__init__
def __init__(self): self.init = self.__init__
23,331
def __del__(self): pass
def __del__(self): pass
23,332
def __del__(self): pass
def __del__(self): pass
23,333
exec("def f(): pass\n") in d
exec("def f(): pass\n") in d
23,334
def f(): frame = sys._getframe()
def f(): frame = sys._getframe()
23,335
def test_saveall(): # Verify that cyclic garbage like lists show up in gc.garbage if the # SAVEALL option is enabled. debug = gc.get_debug() gc.set_debug(debug | gc.DEBUG_SAVEALL) l = [] l.append(l) id_l = id(l) del l gc.collect() try: for obj in gc.garbage: if id(obj) == id_l: del obj[:] break else: raise TestFailed g...
def test_saveall(): # Verify that cyclic garbage like lists show up in gc.garbage if the # SAVEALL option is enabled. debug = gc.get_debug() gc.set_debug(debug | gc.DEBUG_SAVEALL) l = [] l.append(l) id_l = id(l) del l gc.collect() try: for obj in gc.garbage: if id(obj) == id_l: del obj[:] break else: raise TestFailed, ...
23,336
def detect_modules(self): # Ensure that /usr/local is always used add_dir_to_list(self.compiler.library_dirs, '/usr/local/lib') add_dir_to_list(self.compiler.include_dirs, '/usr/local/include')
def detect_modules(self): # Ensure that /usr/local is always used add_dir_to_list(self.compiler.library_dirs, '/usr/local/lib') add_dir_to_list(self.compiler.include_dirs, '/usr/local/include')
23,337
def detect_modules(self): # Ensure that /usr/local is always used add_dir_to_list(self.compiler.library_dirs, '/usr/local/lib') add_dir_to_list(self.compiler.include_dirs, '/usr/local/include')
def detect_modules(self): # Ensure that /usr/local is always used add_dir_to_list(self.compiler.library_dirs, '/usr/local/lib') add_dir_to_list(self.compiler.include_dirs, '/usr/local/include')
23,338
def detect_modules(self): # Ensure that /usr/local is always used add_dir_to_list(self.compiler.library_dirs, '/usr/local/lib') add_dir_to_list(self.compiler.include_dirs, '/usr/local/include')
def detect_modules(self): # Ensure that /usr/local is always used add_dir_to_list(self.compiler.library_dirs, '/usr/local/lib') add_dir_to_list(self.compiler.include_dirs, '/usr/local/include')
23,339
def detect_modules(self): # Ensure that /usr/local is always used add_dir_to_list(self.compiler.library_dirs, '/usr/local/lib') add_dir_to_list(self.compiler.include_dirs, '/usr/local/include')
def detect_modules(self): # Ensure that /usr/local is always used add_dir_to_list(self.compiler.library_dirs, '/usr/local/lib') add_dir_to_list(self.compiler.include_dirs, '/usr/local/include')
23,340
def _parsegen(self): # Create a new message and start by parsing headers. self._new_message() headers = [] # Collect the headers, searching for a line that doesn't match the RFC # 2822 header or continuation pattern (including an empty line). for line in self._input: if line is NeedMoreData: yield NeedMoreData continue...
def _parsegen(self): # Create a new message and start by parsing headers. self._new_message() headers = [] # Collect the headers, searching for a line that doesn't match the RFC # 2822 header or continuation pattern (including an empty line). for line in self._input: if line is NeedMoreData: yield NeedMoreData continue...
23,341
def _parsegen(self): # Create a new message and start by parsing headers. self._new_message() headers = [] # Collect the headers, searching for a line that doesn't match the RFC # 2822 header or continuation pattern (including an empty line). for line in self._input: if line is NeedMoreData: yield NeedMoreData continue...
def _parsegen(self): # Create a new message and start by parsing headers. self._new_message() headers = [] # Collect the headers, searching for a line that doesn't match the RFC # 2822 header or continuation pattern (including an empty line). for line in self._input: if line is NeedMoreData: yield NeedMoreData continue...
23,342
def _checkquote(self, arg):
def _checkquote(self, arg):
23,343
def _checkquote(self, arg):
def _checkquote(self, arg):
23,344
def __init__(self, screenName=None, baseName=None, className='Tk'): Tkinter.Tk.__init__(self, screenName, baseName, className)
def __init__(self, screenName=None, baseName=None, className='Tk'): Tkinter.Tk.__init__(self, screenName, baseName, className)
23,345
def __init__(self, screenName=None, baseName=None, className='Tk'): Tkinter.Tk.__init__(self, screenName, baseName, className)
def __init__(self, screenName=None, baseName=None, className='Tk'): Tkinter.Tk.__init__(self, screenName, baseName, className)
23,346
def slaves(self): return map(self._nametowidget, self.tk.splitlist( self.tk.call( 'tixForm', 'slaves', self._w)))
def slaves(self): return map(self._nametowidget, self.tk.splitlist( self.tk.call( 'tixForm', 'slaves', self._w)))
23,347
def __init__ (self, master=None, widgetName=None,
def __init__ (self, master=None, widgetName=None,
23,348
def __getattr__(self, name):
def __getattr__(self, name):
23,349
def set_silent(self, value):
def set_silent(self, value):
23,350
def subwidget(self, name):
def subwidget(self, name):
23,351
def subwidgets_all(self):
def subwidgets_all(self):
23,352
def _subwidget_name(self,name):
def _subwidget_name(self,name):
23,353
def _subwidget_names(self):
def _subwidget_names(self):
23,354
def config_all(self, option, value):
def config_all(self, option, value):
23,355
def __init__(self, master, name,
def __init__(self, master, name,
23,356
def destroy(self):
def destroy(self):
23,357
def _lst2dict(lst): dict = {} for x in lst: dict[x[0][1:]] = (x[0][1:],) + x[1:] return dict
def _lst2dict(lst): dict = {} for x in lst: dict[x[0][1:]] = (x[0][1:],) + x[1:] return dict
23,358
def __init__(self, itemtype, cnf={}, **kw ):
def __init__(self, itemtype, cnf={}, **kw ):
23,359
def __str__(self):
def __str__(self):
23,360
def _options(self, cnf, kw ):
def _options(self, cnf, kw ):
23,361
def delete(self):
def delete(self):
23,362
def __setitem__(self,key,value):
def __setitem__(self,key,value):
23,363
def config(self, cnf={}, **kw):
def config(self, cnf={}, **kw):
23,364
def __getitem__(self,key):
def __getitem__(self,key):
23,365
def __getitem__(self,key):
def __getitem__(self,key):
23,366
def __init__(self, master=None, cnf={}, **kw):
def __init__(self, master=None, cnf={}, **kw):
23,367
def bind_widget(self, widget, cnf={}, **kw):
def bind_widget(self, widget, cnf={}, **kw):
23,368
def unbind_widget(self, widget):
def unbind_widget(self, widget):
23,369
def __init__(self, master=None, cnf={}, **kw):
def __init__(self, master=None, cnf={}, **kw):
23,370
def add(self, name, cnf={}, **kw):
def add(self, name, cnf={}, **kw):
23,371
def invoke(self, name):
def invoke(self, name):
23,372
def invoke(self, name):
def invoke(self, name):
23,373
def __init__ (self, master=None, cnf={}, **kw):
def __init__ (self, master=None, cnf={}, **kw):
23,374
def add_history(self, str):
def add_history(self, str):
23,375
def append_history(self, str):
def append_history(self, str):
23,376
def insert(self, index, str):
def insert(self, index, str):
23,377
def pick(self, index):
def pick(self, index):
23,378
def pick(self, index):
def pick(self, index):
23,379
def __init__ (self, master=None, cnf={}, **kw):
def __init__ (self, master=None, cnf={}, **kw):
23,380
def decrement(self):
def decrement(self):
23,381
def increment(self):
def increment(self):
23,382
def invoke(self):
def invoke(self):
23,383
def update(self):
def update(self):
23,384
def update(self):
def update(self):
23,385
def chdir(self, dir):
def chdir(self, dir):
23,386
def chdir(self, dir):
def chdir(self, dir):
23,387
def chdir(self, dir):
def chdir(self, dir):
23,388
def chdir(self, dir):
def chdir(self, dir):
23,389
def filter(self):
def filter(self):
23,390
def invoke(self):
def invoke(self):
23,391
def invoke(self):
def invoke(self):
23,392
def popup(self):
def popup(self):
23,393
def popdown(self):
def popdown(self):
23,394
def popdown(self):
def popdown(self):
23,395
def invoke(self):
def invoke(self):
23,396
def invoke(self):
def invoke(self):
23,397
def popup(self):
def popup(self):
23,398
def popdown(self):
def popdown(self):
23,399