bugged stringlengths 4 228k | fixed stringlengths 0 96.3M | __index_level_0__ int64 0 481k |
|---|---|---|
def test_operator(self): from operator import isCallable, sequenceIncludes | def test_operator(self): from operator import isCallable, sequenceIncludes | 456,900 |
def test_empty_presized_dict_in_freelist(self): # Bug #3537: if an empty but presized dict with a size larger # than 7 was in the freelist, it triggered an assertion failure try: d = {'a': 1/0, 'b': None, 'c': None, 'd': None, 'e': None, 'f': None, 'g': None, 'h': None} except ZeroDivisionError: pass d = {} | def test_empty_presized_dict_in_freelist(self): # Bug #3537: if an empty but presized dict with a size larger # than 7 was in the freelist, it triggered an assertion failure try: d = {'a': 1//0, 'b': None, 'c': None, 'd': None, 'e': None, 'f': None, 'g': None, 'h': None} except ZeroDivisionError: pass d = {} | 456,901 |
def test_ssl_presence(self): try: import ssl except: have_ssl = False else: has_ssl = True try: xmlrpc.client.ServerProxy('https://localhost:9999').bad_function() except NotImplementedError: self.assertFalse(has_ssl, "xmlrpc client's error with SSL support") except socket.error: self.assertTrue(has_ssl) | def test_ssl_presence(self): try: import ssl except ImportError: has_ssl = False else: has_ssl = True try: xmlrpc.client.ServerProxy('https://localhost:9999').bad_function() except NotImplementedError: self.assertFalse(has_ssl, "xmlrpc client's error with SSL support") except socket.error: self.assertTrue(has_ssl) | 456,902 |
def setUp(self): self.filename = self.__class__.__name__ + '.db' self.homeDir = get_new_environment_path() | def setUp(self): self.filename = get_new_database_path() self.homeDir = get_new_environment_path() | 456,903 |
def test_lsdir(self): if hasattr(posix, 'lsdir'): self.assertIn(support.TESTFN, posix.lsdir(os.curdir)) | def test_lsdir(self): if hasattr(posix, 'lsdir'): self.assertIn(support.TESTFN, posix.lsdir(os.curdir)) | 456,904 |
def __str__(self): return '__str__ overridden' | def __str__(self): return '__str__ overridden' | 456,905 |
def test_main(): with check_warnings(("complex divmod.., // and % are deprecated", DeprecationWarning), ("classic (int|long) division", DeprecationWarning), quiet=True): process_infix_results() # now infix_results has two lists of results for every pairing. run_unittest(CoercionTest) | def test_main(): with check_warnings(("complex divmod.., // and % are deprecated", DeprecationWarning), ("classic (int|long) division", DeprecationWarning), quiet=True): process_infix_results() # now infix_results has two lists of results for every pairing. run_unittest(CoercionTest) | 456,906 |
def testCompileLibrary(self): # A simple but large test. Compile all the code in the # standard library and its test suite. This doesn't verify # that any of the code is correct, merely the compiler is able # to generate some kind of code for it. | def testCompileLibrary(self): # A simple but large test. Compile all the code in the # standard library and its test suite. This doesn't verify # that any of the code is correct, merely the compiler is able # to generate some kind of code for it. | 456,907 |
def testRecvTimeout(self): # Test recv() timeout _timeout = 0.02 self.sock.connect(self.addr_remote) self.sock.settimeout(_timeout) | def testRecvTimeout(self): # Test recv() timeout _timeout = 0.02 self.sock.connect(self.addr_remote) self.sock.settimeout(_timeout) | 456,908 |
def open(self, url, new=0, autoraise=True): if new == 0: action = self.remote_action elif new == 1: action = self.remote_action_newwin elif new == 2: if self.remote_action_newtab is None: action = self.remote_action_newwin else: action = self.remote_action_newtab else: raise Error("Bad 'new' parameter to open(); " + "e... | defopen(self,url,new=0,autoraise=True):ifnew==0:action=self.remote_actionelifnew==1:action=self.remote_action_newwinelifnew==2:ifself.remote_action_newtabisNone:action=self.remote_action_newwinelse:action=self.remote_action_newtabelse:raiseError("Bad'new'parametertoopen();"+"expected0,1,or2,got%s"%new) | 456,909 |
def open(self, url, new=0, autoraise=True): if new == 0: action = self.remote_action elif new == 1: action = self.remote_action_newwin elif new == 2: if self.remote_action_newtab is None: action = self.remote_action_newwin else: action = self.remote_action_newtab else: raise Error("Bad 'new' parameter to open(); " + "e... | defopen(self,url,new=0,autoraise=True):ifnew==0:action=self.remote_actionelifnew==1:action=self.remote_action_newwinelifnew==2:ifself.remote_action_newtabisNone:action=self.remote_action_newwinelse:action=self.remote_action_newtabelse:raiseError("Bad'new'parametertoopen();"+"expected0,1,or2,got%s"%new) | 456,910 |
def open(self, url, new=0, autoraise=True): if new == 0: action = self.remote_action elif new == 1: action = self.remote_action_newwin elif new == 2: if self.remote_action_newtab is None: action = self.remote_action_newwin else: action = self.remote_action_newtab else: raise Error("Bad 'new' parameter to open(); " + "e... | defopen(self,url,new=0,autoraise=True):ifnew==0:action=self.remote_actionelifnew==1:action=self.remote_action_newwinelifnew==2:ifself.remote_action_newtabisNone:action=self.remote_action_newwinelse:action=self.remote_action_newtabelse:raiseError("Bad'new'parametertoopen();"+"expected0,1,or2,got%s"%new) | 456,911 |
def open(self, url, new=0, autoraise=True): if new == 0: action = self.remote_action elif new == 1: action = self.remote_action_newwin elif new == 2: if self.remote_action_newtab is None: action = self.remote_action_newwin else: action = self.remote_action_newtab else: raise Error("Bad 'new' parameter to open(); " + "e... | def open(self, url, new=0, autoraise=True): if new == 0: action = self.remote_action elif new == 1: action = self.remote_action_newwin elif new == 2: if self.remote_action_newtab is None: action = self.remote_action_newwin else: action = self.remote_action_newtab else: raise Error("Bad 'new' parameter to open(); " + "e... | 456,912 |
def main(args=None): """Compile several source files. The files named in 'args' (or on the command line, if 'args' is not specified) are compiled and the resulting bytecode is cached in the normal manner. This function does not search a directory structure to locate source files; it only compiles files named explicit... | def main(args=None): """Compile several source files. The files named in 'args' (or on the command line, if 'args' is not specified) are compiled and the resulting bytecode is cached in the normal manner. This function does not search a directory structure to locate source files; it only compiles files named explicit... | 456,913 |
def main(args=None): """Compile several source files. The files named in 'args' (or on the command line, if 'args' is not specified) are compiled and the resulting bytecode is cached in the normal manner. This function does not search a directory structure to locate source files; it only compiles files named explicit... | def main(args=None): """Compile several source files. The files named in 'args' (or on the command line, if 'args' is not specified) are compiled and the resulting bytecode is cached in the normal manner. This function does not search a directory structure to locate source files; it only compiles files named explicit... | 456,914 |
def ip2num(ipAddr): parts = ipAddr.split('.') parts = map(int, parts) if len(parts) != 4: parts = (parts + [0, 0, 0, 0])[:4] return (parts[0] << 24) | (parts[1] << 16) | (parts[2] << 8) | parts[3] | def ip2num(ipAddr): parts = ipAddr.split('.') parts = map(int, parts) if len(parts) != 4: parts = (parts + [0, 0, 0, 0])[:4] return (parts[0] << 24) | (parts[1] << 16) | (parts[2] << 8) | parts[3] | 456,915 |
def assertRunNotOK(self, *args, **env_vars): rc, out, err = script_helper.assert_python_failure( '-S', '-m', 'compileall', *args, **env_vars) return rc, out, err | def assertRunNotOK(self, *args, **env_vars): rc, out, err = script_helper.assert_python_failure( '-m', 'compileall', *args, **env_vars) return rc, out, err | 456,916 |
def cleanup_test_droppings(testname, verbose): import shutil import stat import gc # First kill any dangling references to open files etc. # This can also issue some ResourceWarnings which would otherwise get # triggered during the following test run, and possible produce failures. gc.collect() # Try to clean up junk... | def cleanup_test_droppings(testname, verbose): import shutil import stat import gc # First kill any dangling references to open files etc. # This can also issue some ResourceWarnings which would otherwise get # triggered during the following test run, and possible produce failures. gc.collect() # Try to clean up junk... | 456,917 |
def print_stats(self, *amount): for filename in self.files: print(filename, file=self.stream) if self.files: print(file=self.stream) indent = ' ' * 8 for func in self.top_level: print(indent, func_get_function_name(func), file=self.stream) | def print_stats(self, *amount): for filename in self.files: print(filename, file=self.stream) if self.files: print(file=self.stream) indent = ' ' * 8 for func in self.top_level: print(indent, func_get_function_name(func), file=self.stream) | 456,918 |
def test_quiet(self): noise = subprocess.getoutput('{} -m compileall {}'.format( sys.executable, self.pkgdir)) quiet = subprocess.getoutput(('{} -m compileall {}'.format( sys.executable, self.pkgdir))) self.assertGreater(len(noise), len(quiet)) | def test_quiet(self): noise = subprocess.getoutput('{} -m compileall {}'.format( sys.executable, self.pkgdir)) quiet = subprocess.getoutput(('{} -m compileall -f -q {}'.format( sys.executable, self.pkgdir))) self.assertGreater(len(noise), len(quiet)) | 456,919 |
def do_shell(self): pass | def do_shell(self, s): pass | 456,920 |
def test_main(verbose=None): from test import test_support, test_cmd test_support.run_doctest(test_cmd, verbose) | def test_main(verbose=None): from test import test_support, test_cmd test_support.run_doctest(test_cmd, verbose) | 456,921 |
def findCaller(self): """ Find the stack frame of the caller so that we can note the source file name, line number and function name. """ f = currentframe() #On some versions of IronPython, currentframe() returns None if #IronPython isn't run with -X:Frames. if f is not None: f = f.f_back rv = "(unknown file)", 0, "(un... | def findCaller(self): """ Find the stack frame of the caller so that we can note the source file name, line number and function name. """ f = currentframe() #On some versions of IronPython, currentframe() returns None if #IronPython isn't run with -X:Frames. if f is not None: f = f.f_back rv = "(unknown file)", 0, "(un... | 456,922 |
def enum_types(mimedb): i = 0 while True: try: ctype = _winreg.EnumKey(mimedb, i) except EnvironmentError: break else: yield ctype i += 1 | def enum_types(mimedb): i = 0 while True: try: ctype = _winreg.EnumKey(mimedb, i) except EnvironmentError: break else: yield ctype i += 1 | 456,923 |
def __init__(self, docname, lineno, issue, line): "A rule for ignoring issues" self.docname = docname # document to which this rule applies self.lineno = lineno # line number in the original source; # this rule matches only near that. # None -> don't care self.issue = issue # the markup fragment that triggered th... | def __init__(self, docname, lineno, issue, line): """A rule for ignoring issues""" self.docname = docname # document to which this rule applies self.lineno = lineno # line number in the original source; # this rule matches only near that. # None -> don't care self.issue = issue # the markup fragment that triggere... | 456,924 |
def __init__(self, docname, lineno, issue, line): "A rule for ignoring issues" self.docname = docname # document to which this rule applies self.lineno = lineno # line number in the original source; # this rule matches only near that. # None -> don't care self.issue = issue # the markup fragment that triggered th... | def __init__(self, docname, lineno, issue, line): "A rule for ignoring issues" self.docname = docname # document to which this rule applies self.lineno = lineno # line number in the original source; # this rule matches only near that. # None -> don't care self.issue = issue # the markup fragment that triggered th... | 456,925 |
def init(self): # create output file self.log_file_name = os.path.join(self.outdir, 'suspicious.csv') open(self.log_file_name, 'w').close() # load database of previously ignored issues self.load_rules(os.path.join(os.path.dirname(__file__), 'susp-ignored.csv')) | def init(self): # create output file self.log_file_name = os.path.join(self.outdir, 'suspicious.csv') open(self.log_file_name, 'w').close() # load database of previously ignored issues self.load_rules(os.path.join(os.path.dirname(__file__), 'susp-ignored.csv')) | 456,926 |
def prepare_writing(self, docnames): ### PYTHON PROJECT SPECIFIC ### for name in set(docnames): if name.split('/', 1)[0] == 'documenting': docnames.remove(name) ### PYTHON PROJECT SPECIFIC ### | def prepare_writing(self, docnames): ### PYTHON PROJECT SPECIFIC ### for name in set(docnames): if name.split('/', 1)[0] == 'documenting': docnames.remove(name) ### PYTHON PROJECT SPECIFIC ### | 456,927 |
def write_doc(self, docname, doctree): self.any_issue = False # set when any issue is encountered in this document self.docname = docname visitor = SuspiciousVisitor(doctree, self) doctree.walk(visitor) | def write_doc(self, docname, doctree): self.any_issue = False # set when any issue is encountered in this document self.docname = docname visitor = SuspiciousVisitor(doctree, self) doctree.walk(visitor) | 456,928 |
def is_ignored(self, line, lineno, issue): """Determine whether this issue should be ignored. """ docname = self.docname for rule in self.rules: if rule.docname != docname: continue if rule.issue != issue: continue # Both lines must match *exactly*. This is rather strict, # and probably should be improved. # Doing fuzz... | def is_ignored(self, line, lineno, issue): """Determine whether this issue should be ignored.""" docname = self.docname for rule in self.rules: if rule.docname != docname: continue if rule.issue != issue: continue # Both lines must match *exactly*. This is rather strict, # and probably should be improved. # Doing fuzzy... | 456,929 |
def write_log_entry(self, lineno, issue, text): f = open(self.log_file_name, 'ab') writer = csv.writer(f) writer.writerow([self.docname.encode('utf-8'), lineno, issue.encode('utf-8'), text.strip().encode('utf-8')]) del writer f.close() | def write_log_entry(self, lineno, issue, text): f = open(self.log_file_name, 'ab') writer = csv.writer(f, dialect) writer.writerow([self.docname.encode('utf-8'), lineno, issue.encode('utf-8'), text.strip().encode('utf-8')]) del writer f.close() | 456,930 |
def write_log_entry(self, lineno, issue, text): f = open(self.log_file_name, 'ab') writer = csv.writer(f) writer.writerow([self.docname.encode('utf-8'), lineno, issue.encode('utf-8'), text.strip().encode('utf-8')]) del writer f.close() | def write_log_entry(self, lineno, issue, text): f = open(self.log_file_name, 'ab') writer = csv.writer(f) writer.writerow([self.docname.encode('utf-8'), lineno, issue.encode('utf-8'), text.strip().encode('utf-8')]) f.close() | 456,931 |
def load_rules(self, filename): """Load database of previously ignored issues. | def load_rules(self, filename): """Load database of previously ignored issues. | 456,932 |
def get_lineno(node): "Obtain line number information for a node" lineno = None while lineno is None and node: node = node.parent lineno = node.line return lineno | def get_lineno(node): """Obtain line number information for a node.""" lineno = None while lineno is None and node: node = node.parent lineno = node.line return lineno | 456,933 |
def extract_line(text, index): """text may be a multiline string; extract only the line containing the given character index. >>> extract_line("abc\ndefgh\ni", 6) >>> 'defgh' >>> for i in (0, 2, 3, 4, 10): ... print extract_line("abc\ndefgh\ni", i) abc abc abc defgh defgh i """ p = text.rfind('\n', 0, index) + 1 q =... | def extract_line(text, index): """text may be a multiline string; extract only the line containing the given character index. >>> extract_line("abc\ndefgh\ni", 6) >>> 'defgh' >>> for i in (0, 2, 3, 4, 10): ... print extract_line("abc\ndefgh\ni", i) abc abc abc defgh defgh i """ p = text.rfind('\n', 0, index) + 1 q =... | 456,934 |
def default_visit(self, node): if isinstance(node, (nodes.Text, nodes.image)): # direct text containers text = node.astext() # lineno seems to go backwards sometimes (?) self.lastlineno = lineno = max(get_lineno(node) or 0, self.lastlineno) seen = set() # don't report the same issue more than only once per line for mat... | defdefault_visit(self,node):ifisinstance(node,(nodes.Text,nodes.image)):#directtextcontainerstext=node.astext()#linenoseemstogobackwardssometimes(?)self.lastlineno=lineno=max(get_lineno(node)or0,self.lastlineno)seen=set()#don'treportthesameissuemorethanonlyonceperlineformatchindetect_all(text):#importpdb;pdb.set_trace(... | 456,935 |
def _fixup_command(self, cmd): # When Python was build with --enable-shared, -L. is not good enough # to find the libpython<blah>.so. This is because regrtest runs it # under a tempdir, not in the top level where the .so lives. By the # time we've gotten here, Python's already been chdir'd to the # tempdir. # # To fu... | def _fixup_command(self, cmd): # When Python was build with --enable-shared, -L. is not good enough # to find the libpython<blah>.so. This is because regrtest runs it # under a tempdir, not in the top level where the .so lives. By the # time we've gotten here, Python's already been chdir'd to the # tempdir. # # To fu... | 456,936 |
def _check_bye(self): bye = self.untagged_responses.get('BYE') if bye: raise self.abort(bye[-1]) | def _check_bye(self): bye = self.untagged_responses.get('BYE') if bye: raise self.abort(bye[-1]) | 456,937 |
def _command_complete(self, name, tag): self._check_bye() try: typ, data = self._get_tagged_response(tag) except self.abort as val: raise self.abort('command: %s => %s' % (name, val)) except self.error as val: raise self.error('command: %s => %s' % (name, val)) self._check_bye() if typ == 'BAD': raise self.error('%s co... | def _command_complete(self, name, tag): if name != 'LOGOUT': self._check_bye() try: typ, data = self._get_tagged_response(tag) except self.abort as val: raise self.abort('command: %s => %s' % (name, val)) except self.error as val: raise self.error('command: %s => %s' % (name, val)) if name != 'LOGOUT': self._check_by... | 456,938 |
def _command_complete(self, name, tag): self._check_bye() try: typ, data = self._get_tagged_response(tag) except self.abort as val: raise self.abort('command: %s => %s' % (name, val)) except self.error as val: raise self.error('command: %s => %s' % (name, val)) self._check_bye() if typ == 'BAD': raise self.error('%s co... | def _command_complete(self, name, tag): if name != 'LOGOUT': self._check_bye() try: typ, data = self._get_tagged_response(tag) except self.abort as val: raise self.abort('command: %s => %s' % (name, val)) except self.error as val: raise self.error('command: %s => %s' % (name, val)) if name != 'LOGOUT': self._check_bye(... | 456,939 |
def jabs_op(name, op): def_op(name, op) hasjabs.append(op) | def jabs_op(name, op): def_op(name, op) hasjabs.append(op) | 456,940 |
def jabs_op(name, op): def_op(name, op) hasjabs.append(op) | def jabs_op(name, op): def_op(name, op) hasjabs.append(op) | 456,941 |
def _cleanup(self): support.rmtree(self.directory) assert sys.path[0] == self.directory, 'Missing path' del sys.path[0] | def _cleanup(self): support.rmtree(self.directory) assert sys.path[0] == self.directory, 'Missing path' del sys.path[0] | 456,942 |
def test_legacy(self): # create a new module newpackage = os.path.join(self.pkgdir, 'spam') os.mkdir(newpackage) with open(os.path.join(newpackage, '__init__.py'), 'w'): pass with open(os.path.join(newpackage, 'ham.py'), 'w'): pass sourcefile = os.path.join(newpackage, 'ham.py') | def test_legacy(self): # create a new module newpackage = os.path.join(self.pkgdir, 'spam') os.mkdir(newpackage) with open(os.path.join(newpackage, '__init__.py'), 'w'): pass with open(os.path.join(newpackage, 'ham.py'), 'w'): pass sourcefile = os.path.join(newpackage, 'ham.py') | 456,943 |
def test_quiet(self): noise = subprocess.getoutput('{} -m compileall {}'.format( sys.executable, self.pkgdir)) quiet = subprocess.getoutput(('{} -m compileall -f -q {}'.format( sys.executable, self.pkgdir))) self.assertGreater(len(noise), len(quiet)) | def test_quiet(self): noise = subprocess.check_output( [sys.executable, '-m', 'compileall', self.pkgdir], stderr=subprocess.STDOUT) quiet = subprocess.check_output( [sys.executable, '-m', 'compileall', '-f', '-q', self.pkgdir], stderr=subprocess.STDOUT) self.assertGreater(len(noise), len(quiet)) | 456,944 |
def visitModule(self, mod): self.emit(""" | def visitModule(self, mod): self.emit(""" | 456,945 |
def imag(self): """Retrieve the real component of this number. | def imag(self): """Retrieve the real component of this number. | 456,946 |
def test_ciphers(self): if not support.is_resource_enabled('network'): return remote = ("svn.python.org", 443) s = ssl.wrap_socket(socket.socket(socket.AF_INET), cert_reqs=ssl.CERT_NONE, ciphers="ALL") s.connect(remote) s = ssl.wrap_socket(socket.socket(socket.AF_INET), cert_reqs=ssl.CERT_NONE, ciphers="DEFAULT") s.con... | def test_ciphers(self): if not support.is_resource_enabled('network'): return remote = ("svn.python.org", 443) s = ssl.wrap_socket(socket.socket(socket.AF_INET), cert_reqs=ssl.CERT_NONE, ciphers="ALL") s.connect(remote) s = ssl.wrap_socket(socket.socket(socket.AF_INET), cert_reqs=ssl.CERT_NONE, ciphers="DEFAULT") s.con... | 456,947 |
def test_ciphers(self): ctx = ssl.SSLContext(ssl.PROTOCOL_TLSv1) ctx.set_ciphers("ALL") ctx.set_ciphers("DEFAULT") with self.assertRaisesRegexp(ssl.SSLError, "No cipher can be selected"): ctx.set_ciphers("^$:,;?*'dorothyx") | def test_ciphers(self): ctx = ssl.SSLContext(ssl.PROTOCOL_TLSv1) ctx.set_ciphers("ALL") ctx.set_ciphers("DEFAULT") with self.assertRaisesRegexp(ssl.SSLError, "No cipher can be selected"): ctx.set_ciphers("^$:,;?*'dorothyx") | 456,948 |
def testAbles(self): try: f = _FileIO(TESTFN, "w") self.assertEquals(f.readable(), False) self.assertEquals(f.writable(), True) self.assertEquals(f.seekable(), True) f.close() | def testAbles(self): try: f = _FileIO(TESTFN, "w") self.assertEquals(f.readable(), False) self.assertEquals(f.writable(), True) self.assertEquals(f.seekable(), True) f.close() | 456,949 |
def makelink(self, tarinfo, targetpath): """Make a (symbolic) link called targetpath. If it cannot be created (platform limitation), we try to make a copy of the referenced file instead of a link. """ try: # For systems that support symbolic and hard links. if tarinfo.issym(): os.symlink(tarinfo.linkname, targetpath) e... | def makelink(self, tarinfo, targetpath): """Make a (symbolic) link called targetpath. If it cannot be created (platform limitation), we try to make a copy of the referenced file instead of a link. """ try: # For systems that support symbolic and hard links. if tarinfo.issym(): os.symlink(tarinfo.linkname, targetpath) e... | 456,950 |
def send_signals(): os.kill(process_pid, signal.SIGUSR1) os.kill(process_pid, signal.SIGUSR2) signalled_all.release() | def send_signals(): os.kill(process_pid, signal.SIGUSR1) os.kill(process_pid, signal.SIGUSR2) signalled_all.release() | 456,951 |
def __patched_linecache_getlines(self, filename, module_globals=None): m = self.__LINECACHE_FILENAME_RE.match(filename) if m and m.group('name') == self.test.name: example = self.test.examples[int(m.group('examplenum'))] return example.source.splitlines(True) else: return self.save_linecache_getlines(filename, module_g... | def __patched_linecache_getlines(self, filename, module_globals=None): m = self.__LINECACHE_FILENAME_RE.match(filename) if m and m.group('name') == self.test.name: example = self.test.examples[int(m.group('examplenum'))] source = example.source.encode('ascii', 'backslashreplace') return source.splitlines(True) else: re... | 456,952 |
def purge(): """Clear the pattern cache""" _cache.clear() _cacheb.clear() | def purge(): """Clear the pattern cache.""" _cache.clear() _cacheb.clear() | 456,953 |
def fnmatch(name, pat): """Test whether FILENAME matches PATTERN. Patterns are Unix shell style: * matches everything ? matches any single character [seq] matches any character in seq [!seq] matches any char not in seq An initial period in FILENAME is not special. Both FILENAME and PATTERN are first c... | def fnmatch(name, pat): """Test whether FILENAME matches PATTERN. Patterns are Unix shell style: * matches everything ? matches any single character [seq] matches any character in seq [!seq] matches any char not in seq An initial period in FILENAME is not special. Both FILENAME and PATTERN are first c... | 456,954 |
def filter(names, pat): """Return the subset of the list NAMES that match PAT""" import os,posixpath result = [] pat = os.path.normcase(pat) match = _compile_pattern(pat) if os.path is posixpath: # normcase on posix is NOP. Optimize it away from the loop. for name in names: if match(name): result.append(name) else: for... | def filter(names, pat): """Return the subset of the list NAMES that match PAT.""" result = [] pat = os.path.normcase(pat) match = _compile_pattern(pat) if os.path is posixpath: # normcase on posix is NOP. Optimize it away from the loop. for name in names: if match(name): result.append(name) else: for name in names: if ... | 456,955 |
def fnmatchcase(name, pat): """Test whether FILENAME matches PATTERN, including case. This is a version of fnmatch() which doesn't case-normalize its arguments. """ match = _compile_pattern(pat) return match(name) is not None | deffnmatchcase(name,pat):"""TestwhetherFILENAMEmatchesPATTERN,includingcase.Thisisaversionoffnmatch()whichdoesn'tcase-normalizeitsarguments."""match=_compile_pattern(pat)returnmatch(name)isnotNone | 456,956 |
def test01_basic_replication(self) : master_port = test_support.find_unused_port() self.dbenvMaster.repmgr_set_local_site("127.0.0.1", master_port) client_port = test_support.find_unused_port() self.dbenvClient.repmgr_set_local_site("127.0.0.1", client_port) self.dbenvMaster.repmgr_add_remote_site("127.0.0.1", client_p... | def test01_basic_replication(self) : master_port = test_support.find_unused_port() self.dbenvMaster.repmgr_set_local_site("127.0.0.1", master_port) client_port = test_support.find_unused_port() self.dbenvClient.repmgr_set_local_site("127.0.0.1", client_port) self.dbenvMaster.repmgr_add_remote_site("127.0.0.1", client_p... | 456,957 |
def setUp(self): self.tracer = Trace(count=0, trace=0, countfuncs=1) self.filemod = my_file_and_modname() self.maxDiff = None | def setUp(self): self.tracer = Trace(count=0, trace=0, countfuncs=1) self.filemod = my_file_and_modname() self.maxDiff = None | 456,958 |
def test_issue5604(self): # Test cannot cover imp.load_compiled function. # Martin von Loewis note what shared library cannot have non-ascii # character because init_xxx function cannot be compiled # and issue never happens for dynamic modules. # But sources modified to follow generic way for processing pathes. | def test_issue5604(self): # Test cannot cover imp.load_compiled function. # Martin von Loewis note what shared library cannot have non-ascii # character because init_xxx function cannot be compiled # and issue never happens for dynamic modules. # But sources modified to follow generic way for processing pathes. | 456,959 |
def test_issue5604(self): # Test cannot cover imp.load_compiled function. # Martin von Loewis note what shared library cannot have non-ascii # character because init_xxx function cannot be compiled # and issue never happens for dynamic modules. # But sources modified to follow generic way for processing pathes. | def test_issue5604(self): # Test cannot cover imp.load_compiled function. # Martin von Loewis note what shared library cannot have non-ascii # character because init_xxx function cannot be compiled # and issue never happens for dynamic modules. # But sources modified to follow generic way for processing pathes. | 456,960 |
def test_issue5604(self): # Test cannot cover imp.load_compiled function. # Martin von Loewis note what shared library cannot have non-ascii # character because init_xxx function cannot be compiled # and issue never happens for dynamic modules. # But sources modified to follow generic way for processing pathes. | def test_issue5604(self): # Test cannot cover imp.load_compiled function. # Martin von Loewis note what shared library cannot have non-ascii # character because init_xxx function cannot be compiled # and issue never happens for dynamic modules. # But sources modified to follow generic way for processing pathes. | 456,961 |
def test_issue5604(self): # Test cannot cover imp.load_compiled function. # Martin von Loewis note what shared library cannot have non-ascii # character because init_xxx function cannot be compiled # and issue never happens for dynamic modules. # But sources modified to follow generic way for processing pathes. | def test_issue5604(self): # Test cannot cover imp.load_compiled function. # Martin von Loewis note what shared library cannot have non-ascii # character because init_xxx function cannot be compiled # and issue never happens for dynamic modules. # But sources modified to follow generic way for processing pathes. | 456,962 |
def test_issue5604(self): # Test cannot cover imp.load_compiled function. # Martin von Loewis note what shared library cannot have non-ascii # character because init_xxx function cannot be compiled # and issue never happens for dynamic modules. # But sources modified to follow generic way for processing pathes. | def test_issue5604(self): # Test cannot cover imp.load_compiled function. # Martin von Loewis note what shared library cannot have non-ascii # character because init_xxx function cannot be compiled # and issue never happens for dynamic modules. # But sources modified to follow generic way for processing pathes. | 456,963 |
def test_issue5604(self): # Test cannot cover imp.load_compiled function. # Martin von Loewis note what shared library cannot have non-ascii # character because init_xxx function cannot be compiled # and issue never happens for dynamic modules. # But sources modified to follow generic way for processing pathes. | def test_issue5604(self): # Test cannot cover imp.load_compiled function. # Martin von Loewis note what shared library cannot have non-ascii # character because init_xxx function cannot be compiled # and issue never happens for dynamic modules. # But sources modified to follow generic way for processing pathes. | 456,964 |
def test_issue5604(self): # Test cannot cover imp.load_compiled function. # Martin von Loewis note what shared library cannot have non-ascii # character because init_xxx function cannot be compiled # and issue never happens for dynamic modules. # But sources modified to follow generic way for processing pathes. | def test_issue5604(self): # Test cannot cover imp.load_compiled function. # Martin von Loewis note what shared library cannot have non-ascii # character because init_xxx function cannot be compiled # and issue never happens for dynamic modules. # But sources modified to follow generic way for processing pathes. | 456,965 |
def test_issue5604(self): # Test cannot cover imp.load_compiled function. # Martin von Loewis note what shared library cannot have non-ascii # character because init_xxx function cannot be compiled # and issue never happens for dynamic modules. # But sources modified to follow generic way for processing pathes. | def test_issue5604(self): # Test cannot cover imp.load_compiled function. # Martin von Loewis note what shared library cannot have non-ascii # character because init_xxx function cannot be compiled # and issue never happens for dynamic modules. # But sources modified to follow generic way for processing pathes. | 456,966 |
def _execute_child(self, args, executable, preexec_fn, close_fds, cwd, env, universal_newlines, startupinfo, creationflags, shell, p2cread, p2cwrite, c2pread, c2pwrite, errread, errwrite): """Execute program (MS Windows version)""" | def _execute_child(self, args, executable, preexec_fn, close_fds, cwd, env, universal_newlines, startupinfo, creationflags, shell, p2cread, p2cwrite, c2pread, c2pwrite, errread, errwrite): """Execute program (MS Windows version)""" | 456,967 |
def close(self): pass | def close(self): pass | 456,968 |
def test_main(): unit_tests = (ProcessTestCase, POSIXProcessTestCase, Win32ProcessTestCase, CommandTests, ProcessTestCaseNoPoll, HelperFunctionTests) unit_tests = (POSIXProcessTestCase,) support.run_unittest(*unit_tests) support.reap_children() | def test_main(): unit_tests = (ProcessTestCase, POSIXProcessTestCase, Win32ProcessTestCase, CommandTests, ProcessTestCaseNoPoll, HelperFunctionTests) support.run_unittest(*unit_tests) support.reap_children() | 456,969 |
def enum_types(mimedb): i = 0 while True: try: ctype = _winreg.EnumKey(mimedb, i) except EnvironmentError: break else: yield ctype i += 1 | def enum_types(mimedb): i = 0 while True: try: ctype = _winreg.EnumKey(mimedb, i) except EnvironmentError: break else: yield ctype i += 1 | 456,970 |
def test_dict_repr(self): d = {1: 10, "a": "ABC"} self.assertTrue(isinstance(repr(d), str)) self.assertTrue(isinstance(repr(d.viewitems()), str)) self.assertTrue(isinstance(repr(d.viewkeys()), str)) self.assertTrue(isinstance(repr(d.viewvalues()), str)) | def test_dict_repr(self): d = {1: 10, "a": "ABC"} self.assertTrue(isinstance(repr(d), str)) self.assertTrue(isinstance(repr(d.viewitems()), str)) self.assertTrue(isinstance(repr(d.viewkeys()), str)) self.assertTrue(isinstance(repr(d.viewvalues()), str)) | 456,971 |
def _open_with_retry(func, host, *args, **kwargs): # Connecting to remote hosts is flaky. Make it more robust # by retrying the connection several times. last_exc = None for i in range(3): try: return func(host, *args, **kwargs) except IOError as err: last_exc = err continue except: raise raise last_exc | def _open_with_retry(func, host, *args, **kwargs): # Connecting to remote hosts is flaky. Make it more robust # by retrying the connection several times. last_exc = None for i in range(3): try: return func(host, *args, **kwargs) except IOError as err: last_exc = err continue except: raise raise last_exc | 456,972 |
def testURLread(self): f = _open_with_retry(urllib.request.urlopen, "http://www.python.org/") x = f.read() | def testURLread(self): with support.transient_internet("www.python.org"): f = urllib.request.urlopen("http://www.python.org/") x = f.read() | 456,973 |
def urlopen(self, *args): return _open_with_retry(urllib.request.urlopen, *args) | def urlopen(self, *args): return _open_with_retry(urllib.request.urlopen, *args) | 456,974 |
def test_fileno(self): if sys.platform in ('win32',): # On Windows, socket handles are not file descriptors; this # test can't pass on Windows. return # Make sure fd returned by fileno is valid. open_url = self.urlopen("http://www.python.org/") fd = open_url.fileno() FILE = os.fdopen(fd, encoding='utf-8') try: self.ass... | def test_fileno(self): if sys.platform in ('win32',): # On Windows, socket handles are not file descriptors; this # test can't pass on Windows. return # Make sure fd returned by fileno is valid. open_url = self.urlopen("http://www.python.org/", timeout=None) fd = open_url.fileno() FILE = os.fdopen(fd, encoding='utf-8')... | 456,975 |
def urlretrieve(self, *args): return _open_with_retry(urllib.request.urlretrieve, *args) | def urlretrieve(self, *args): return _open_with_retry(urllib.request.urlretrieve, *args) | 456,976 |
def _command(self, name, *args): | def_command(self,name,*args): | 456,977 |
def _new_tag(self): | def _new_tag(self): | 456,978 |
def fetch_server_certificate (host, port): import re, tempfile, os, ssl def subproc(cmd): from subprocess import Popen, PIPE, STDOUT proc = Popen(cmd, stdout=PIPE, stderr=STDOUT, shell=True) status = proc.wait() output = proc.stdout.read() return status, output def strip_to_x509_cert(certfile_contents, outfile=None)... | def fetch_server_certificate (host, port): def subproc(cmd): from subprocess import Popen, PIPE, STDOUT proc = Popen(cmd, stdout=PIPE, stderr=STDOUT, shell=True) status = proc.wait() output = proc.stdout.read() return status, output def strip_to_x509_cert(certfile_contents, outfile=None): m = re.search(r"^([-]+BEGIN ... | 456,979 |
def strip_to_x509_cert(certfile_contents, outfile=None): m = re.search(r"^([-]+BEGIN CERTIFICATE[-]+[\r]*\n" r".*[\r]*^[-]+END CERTIFICATE[-]+)$", certfile_contents, re.MULTILINE | re.DOTALL) if not m: return None else: tn = tempfile.mktemp() fp = open(tn, "w") fp.write(m.group(1) + "\n") fp.close() try: tn2 = (outfile... | def strip_to_x509_cert(certfile_contents, outfile=None): m = re.search(br"^([-]+BEGIN CERTIFICATE[-]+[\r]*\n" br".*[\r]*^[-]+END CERTIFICATE[-]+)$", certfile_contents, re.MULTILINE | re.DOTALL) if not m: return None else: tn = tempfile.mktemp() fp = open(tn, "w") fp.write(m.group(1) + "\n") fp.close() try: tn2 = (outfi... | 456,980 |
def strip_to_x509_cert(certfile_contents, outfile=None): m = re.search(r"^([-]+BEGIN CERTIFICATE[-]+[\r]*\n" r".*[\r]*^[-]+END CERTIFICATE[-]+)$", certfile_contents, re.MULTILINE | re.DOTALL) if not m: return None else: tn = tempfile.mktemp() fp = open(tn, "w") fp.write(m.group(1) + "\n") fp.close() try: tn2 = (outfile... | def strip_to_x509_cert(certfile_contents, outfile=None): m = re.search(r"^([-]+BEGIN CERTIFICATE[-]+[\r]*\n" r".*[\r]*^[-]+END CERTIFICATE[-]+)$", certfile_contents, re.MULTILINE | re.DOTALL) if not m: return None else: tn = tempfile.mktemp() fp = open(tn, "wb") fp.write(m.group(1) + b"\n") fp.close() try: tn2 = (outfi... | 456,981 |
def strip_to_x509_cert(certfile_contents, outfile=None): m = re.search(r"^([-]+BEGIN CERTIFICATE[-]+[\r]*\n" r".*[\r]*^[-]+END CERTIFICATE[-]+)$", certfile_contents, re.MULTILINE | re.DOTALL) if not m: return None else: tn = tempfile.mktemp() fp = open(tn, "w") fp.write(m.group(1) + "\n") fp.close() try: tn2 = (outfile... | def strip_to_x509_cert(certfile_contents, outfile=None): m = re.search(r"^([-]+BEGIN CERTIFICATE[-]+[\r]*\n" r".*[\r]*^[-]+END CERTIFICATE[-]+)$", certfile_contents, re.MULTILINE | re.DOTALL) if not m: return None else: tn = tempfile.mktemp() fp = open(tn, "w") fp.write(m.group(1) + "\n") fp.close() try: tn2 = (outfile... | 456,982 |
def test_from_ssize(self): self.assertEqual(self.type2test(0), b'') self.assertEqual(self.type2test(1), b'\x00') self.assertEqual(self.test2test(5), b'\x00\x00\x00\x00\x00') self.assertRaises(ValueError, self.type2test, -1) | def test_from_ssize(self): self.assertEqual(self.type2test(0), b'') self.assertEqual(self.type2test(1), b'\x00') self.assertEqual(self.type2test(5), b'\x00\x00\x00\x00\x00') self.assertRaises(ValueError, self.type2test, -1) | 456,983 |
def show(self, color, options): # scan for options that can override the ctor options self.__wantspec = options.get('wantspec', self.__wantspec) dbfile = options.get('databasefile', self.__databasefile) # load the database file colordb = None if dbfile != self.__databasefile: colordb = ColorDB.get_colordb(dbfile) if no... | def show(self, color, options): # scan for options that can override the ctor options self.__wantspec = options.get('wantspec', self.__wantspec) dbfile = options.get('databasefile', self.__databasefile) # load the database file colordb = None if dbfile != self.__databasefile: colordb = ColorDB.get_colordb(dbfile) if no... | 456,984 |
def save(): global _chooser if _chooser: _chooser.save() | def save(): global _chooser if _chooser: _chooser.save() | 456,985 |
def open(self, url, new=0, autoraise=True): if new == 0: action = self.remote_action elif new == 1: action = self.remote_action_newwin elif new == 2: if self.remote_action_newtab is None: action = self.remote_action_newwin else: action = self.remote_action_newtab else: raise Error("Bad 'new' parameter to open(); " + "e... | defopen(self,url,new=0,autoraise=True):ifnew==0:action=self.remote_actionelifnew==1:action=self.remote_action_newwinelifnew==2:ifself.remote_action_newtabisNone:action=self.remote_action_newwinelse:action=self.remote_action_newtabelse:raiseError("Bad'new'parametertoopen();"+"expected0,1,or2,got%s"%new) | 456,986 |
def open(self, url, new=0, autoraise=True): if new == 0: action = self.remote_action elif new == 1: action = self.remote_action_newwin elif new == 2: if self.remote_action_newtab is None: action = self.remote_action_newwin else: action = self.remote_action_newtab else: raise Error("Bad 'new' parameter to open(); " + "e... | defopen(self,url,new=0,autoraise=True):ifnew==0:action=self.remote_actionelifnew==1:action=self.remote_action_newwinelifnew==2:ifself.remote_action_newtabisNone:action=self.remote_action_newwinelse:action=self.remote_action_newtabelse:raiseError("Bad'new'parametertoopen();"+"expected0,1,or2,got%s"%new) | 456,987 |
def open(self, url, new=0, autoraise=True): if new == 0: action = self.remote_action elif new == 1: action = self.remote_action_newwin elif new == 2: if self.remote_action_newtab is None: action = self.remote_action_newwin else: action = self.remote_action_newtab else: raise Error("Bad 'new' parameter to open(); " + "e... | defopen(self,url,new=0,autoraise=True):ifnew==0:action=self.remote_actionelifnew==1:action=self.remote_action_newwinelifnew==2:ifself.remote_action_newtabisNone:action=self.remote_action_newwinelse:action=self.remote_action_newtabelse:raiseError("Bad'new'parametertoopen();"+"expected0,1,or2,got%s"%new) | 456,988 |
def open(self, url, new=0, autoraise=True): if new == 0: action = self.remote_action elif new == 1: action = self.remote_action_newwin elif new == 2: if self.remote_action_newtab is None: action = self.remote_action_newwin else: action = self.remote_action_newtab else: raise Error("Bad 'new' parameter to open(); " + "e... | def open(self, url, new=0, autoraise=True): if new == 0: action = self.remote_action elif new == 1: action = self.remote_action_newwin elif new == 2: if self.remote_action_newtab is None: action = self.remote_action_newwin else: action = self.remote_action_newtab else: raise Error("Bad 'new' parameter to open(); " + "e... | 456,989 |
def _after_fork(): # This function is called by Python/ceval.c:PyEval_ReInitThreads which # is called from PyOS_AfterFork. Here we cleanup threading module state # that should not exist after a fork. # Reset _active_limbo_lock, in case we forked while the lock was held # by another (non-forked) thread. http://bugs.p... | def _after_fork(): # This function is called by Python/ceval.c:PyEval_ReInitThreads which # is called from PyOS_AfterFork. Here we cleanup threading module state # that should not exist after a fork. # Reset _active_limbo_lock, in case we forked while the lock was held # by another (non-forked) thread. http://bugs.p... | 456,990 |
def test_setreuid(self): if os.getuid() != 0: self.assertRaises(os.error, os.setreuid, 0, 0) self.assertRaises(OverflowError, os.setreuid, 1<<32, 0) self.assertRaises(OverflowError, os.setreuid, 0, 1<<32) os.setreuid(-1, -1) # Does nothing, but it needs to accept -1 | def test_setreuid(self): if os.getuid() != 0: self.assertRaises(os.error, os.setreuid, 0, 0) self.assertRaises(OverflowError, os.setreuid, 1<<32, 0) self.assertRaises(OverflowError, os.setreuid, 0, 1<<32) def test_setreuid_neg1(self): import subprocess subprocess.check_call([ sys.executable, '-c', 'import os,sys;os.... | 456,991 |
def test_setregid(self): if os.getuid() != 0: self.assertRaises(os.error, os.setregid, 0, 0) self.assertRaises(OverflowError, os.setregid, 1<<32, 0) self.assertRaises(OverflowError, os.setregid, 0, 1<<32) os.setregid(-1, -1) # Does nothing, but it needs to accept -1 | def test_setregid(self): if os.getuid() != 0: self.assertRaises(os.error, os.setregid, 0, 0) self.assertRaises(OverflowError, os.setregid, 1<<32, 0) self.assertRaises(OverflowError, os.setregid, 0, 1<<32) def test_setregid_neg1(self): import subprocess subprocess.check_call([ sys.executable, '-c', 'import os,sys;os.... | 456,992 |
def do_add(self, line): self.stats.add(line) return 0 | def do_add(self, line): if self.stats: self.stats.add(line) else: print("No statistics object is loaded.", file=self.stream) return 0 | 456,993 |
def do_reverse(self, line): self.stats.reverse_order() return 0 | def do_reverse(self, line): if self.stats: self.stats.reverse_order() else: print("No statistics object is loaded.", file=self.stream) return 0 | 456,994 |
def do_strip(self, line): self.stats.strip_dirs() return 0 | def do_strip(self, line): self.stats.strip_dirs() return 0 | 456,995 |
def get_enUS_locale(): global enUS_locale if sys.platform == 'darwin': import os tlocs = ("en_US.UTF-8", "en_US.ISO8859-1", "en_US") if int(os.uname()[2].split('.')[0]) < 10: # The locale test work fine on OSX 10.6, I (ronaldoussoren) # haven't had time yet to verify if tests work on OSX 10.5 # (10.4 is known to be bad... | def get_enUS_locale(): global enUS_locale if sys.platform == 'darwin': import os tlocs = ("en_US.UTF-8", "en_US.ISO8859-1", "en_US") if int(os.uname()[2].split('.')[0]) < 10: # The locale test work fine on OSX 10.6, I (ronaldoussoren) # haven't had time yet to verify if tests work on OSX 10.5 # (10.4 is known to be bad... | 456,996 |
def address_string(self): """Return the client address formatted for logging. | def address_string(self): """Return the client address formatted for logging. | 456,997 |
def test_extractall(self): # Test if extractall() correctly restores directory permissions # and times (see issue1735). tar = tarfile.open(tarname, encoding="iso8859-1") try: directories = [t for t in tar if t.isdir()] tar.extractall(TEMPDIR, directories) for tarinfo in directories: path = os.path.join(TEMPDIR, tarinfo... | def test_extractall(self): # Test if extractall() correctly restores directory permissions # and times (see issue1735). tar = tarfile.open(tarname, encoding="iso8859-1") try: directories = [t for t in tar if t.isdir()] tar.extractall(TEMPDIR, directories) for tarinfo in directories: path = os.path.join(TEMPDIR, tarinfo... | 456,998 |
def test_main(verbose=None): test_support.run_unittest(__name__) # verify reference counting if verbose and hasattr(sys, "gettotalrefcount"): counts = [None] * 5 for i in xrange(len(counts)): test_support.run_unittest(*testclasses) counts[i] = sys.gettotalrefcount() print counts | def test_main(verbose=None): test_support.run_unittest(__name__) # verify reference counting if verbose and hasattr(sys, "gettotalrefcount"): counts = [None] * 5 for i in xrange(len(counts)): test_support.run_unittest(__name__) counts[i] = sys.gettotalrefcount() print counts | 456,999 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.