bugged
stringlengths
4
228k
fixed
stringlengths
0
96.3M
__index_level_0__
int64
0
481k
def test_main(): support.run_unittest(StrTest)
def test_main(): support.run_unittest(BytesTest, StrTest)
457,100
def win32_ver(release='',version='',csd='',ptype=''): """ Get additional version information from the Windows Registry and return a tuple (version,csd,ptype) referring to version number, CSD level and OS type (multi/single processor). As a hint: ptype returns 'Uniprocessor Free' on single processor NT machines and 'M...
def win32_ver(release='',version='',csd='',ptype=''): """ Get additional version information from the Windows Registry and return a tuple (version,csd,ptype) referring to version number, CSD level and OS type (multi/single processor). As a hint: ptype returns 'Uniprocessor Free' on single processor NT machines and 'M...
457,101
def win32_ver(release='',version='',csd='',ptype=''): """ Get additional version information from the Windows Registry and return a tuple (version,csd,ptype) referring to version number, CSD level and OS type (multi/single processor). As a hint: ptype returns 'Uniprocessor Free' on single processor NT machines and 'M...
def win32_ver(release='',version='',csd='',ptype=''): """ Get additional version information from the Windows Registry and return a tuple (version,csd,ptype) referring to version number, CSD level and OS type (multi/single processor). As a hint: ptype returns 'Uniprocessor Free' on single processor NT machines and 'M...
457,102
def win32_ver(release='',version='',csd='',ptype=''): """ Get additional version information from the Windows Registry and return a tuple (version,csd,ptype) referring to version number, CSD level and OS type (multi/single processor). As a hint: ptype returns 'Uniprocessor Free' on single processor NT machines and 'M...
def win32_ver(release='',version='',csd='',ptype=''): """ Get additional version information from the Windows Registry and return a tuple (version,csd,ptype) referring to version number, CSD level and OS type (multi/single processor). As a hint: ptype returns 'Uniprocessor Free' on single processor NT machines and 'M...
457,103
def win32_ver(release='',version='',csd='',ptype=''): """ Get additional version information from the Windows Registry and return a tuple (version,csd,ptype) referring to version number, CSD level and OS type (multi/single processor). As a hint: ptype returns 'Uniprocessor Free' on single processor NT machines and 'M...
def win32_ver(release='',version='',csd='',ptype=''): """ Get additional version information from the Windows Registry and return a tuple (version,csd,ptype) referring to version number, CSD level and OS type (multi/single processor). As a hint: ptype returns 'Uniprocessor Free' on single processor NT machines and 'M...
457,104
def _create_file(self): self.f = open(self.filename, "w+")
def _create_file(self): self.f = open(self.filename, "w+")
457,105
def test_bad_magic(self): # IOErrors (eg. file doesn't exist) are allowed to propagate filename = test.support.TESTFN for cookiejar_class in LWPCookieJar, MozillaCookieJar: c = cookiejar_class() try: c.load(filename="for this test to work, a file with this " "filename should not exist") except IOError as exc: # exactly...
def test_bad_magic(self): # IOErrors (eg. file doesn't exist) are allowed to propagate filename = test.support.TESTFN for cookiejar_class in LWPCookieJar, MozillaCookieJar: c = cookiejar_class() try: c.load(filename="for this test to work, a file with this " "filename should not exist") except IOError as exc: # exactly...
457,106
def get_gdb_repr(self, source, cmds_after_breakpoint=None, import_site=False): # Given an input python source representation of data, # run "python -c'print DATA'" under gdb with a breakpoint on # PyObject_Print and scrape out gdb's representation of the "op" # parameter, and verify that the gdb displays the same strin...
def get_gdb_repr(self, source, cmds_after_breakpoint=None, import_site=False): # Given an input python source representation of data, # run "python -c'print DATA'" under gdb with a breakpoint on # PyObject_Print and scrape out gdb's representation of the "op" # parameter, and verify that the gdb displays the same strin...
457,107
def get_gdb_repr(self, source, cmds_after_breakpoint=None, import_site=False): # Given an input python source representation of data, # run "python -c'print DATA'" under gdb with a breakpoint on # PyObject_Print and scrape out gdb's representation of the "op" # parameter, and verify that the gdb displays the same strin...
defif not m: self.fail('Unexpected gdb output: %r\n%s' % (gdb_output, gdb_output)) get_gdb_repr(self,if not m: self.fail('Unexpected gdb output: %r\n%s' % (gdb_output, gdb_output)) source,if not m: self.fail('Unexpected gdb output: %r\n%s' % (gdb_output, gdb_output)) cmds_after_breakpoint=None,if not m: self.fail('Unex...
457,108
def test_NULL_ptr(self): 'Ensure that a NULL PyObject* is handled gracefully' gdb_repr, gdb_output = ( self.get_gdb_repr('print 42', cmds_after_breakpoint=['set variable op=0', 'backtrace']) )
def test_NULL_ptr(self): 'Ensure that a NULL PyObject* is handled gracefully' gdb_repr, gdb_output = ( self.get_gdb_repr('print 42', cmds_after_breakpoint=['set variable op=0', 'backtrace']) )
457,109
def test_truncation(self): 'Verify that very long output is truncated' gdb_repr, gdb_output = self.get_gdb_repr('print range(1000)') self.assertEquals(gdb_repr, "\n [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, " "14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, " "27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38,...
def test_truncation(self): 'Verify that very long output is truncated' gdb_repr, gdb_output = self.get_gdb_repr('print range(1000)') self.assertEquals(gdb_repr, "[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, " "14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, " "27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, "...
457,110
def test_truncation(self): 'Verify that very long output is truncated' gdb_repr, gdb_output = self.get_gdb_repr('print range(1000)') self.assertEquals(gdb_repr, "\n [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, " "14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, " "27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38,...
def test_truncation(self): 'Verify that very long output is truncated' gdb_repr, gdb_output = self.get_gdb_repr('print range(1000)') self.assertEquals(gdb_repr, "\n [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, " "14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, " "27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38,...
457,111
def foo(a, b, c): pass
def foo(a, b, c): pass
457,112
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')
457,113
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')
457,114
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')
457,115
def test_undecodable_code(self): # Raise SkipTest() if sys.executable is not encodable to ascii test.support.workaroundIssue8611()
def test_undecodable_code(self): # Raise SkipTest() if sys.executable is not encodable to ascii test.support.workaroundIssue8611()
457,116
def get_fsencoding(env): output = subprocess.check_output( [sys.executable, "-c", "import sys; print(sys.getfilesystemencoding())"], env=env) return output.rstrip().decode('ascii')
def get_fsencoding(env): output = subprocess.check_output( [sys.executable, "-c", "import sys; print(sys.getfilesystemencoding())"], env=env) return output.rstrip().decode('ascii')
457,117
def get_fsencoding(env): output = subprocess.check_output( [sys.executable, "-c", "import sys; print(sys.getfilesystemencoding())"], env=env) return output.rstrip().decode('ascii')
def get_fsencoding(env): output = subprocess.check_output( [sys.executable, "-c", "import sys; print(sys.getfilesystemencoding())"], env=env) return output.rstrip().decode('ascii')
457,118
def _get_source_filename(): srcdir = sysconfig.get_config_var('srcdir') if srcdir is None: # local fallback return os.path.join(os.path.dirname(__file__), 'xxmodule.c') return os.path.join(srcdir, 'Modules', 'xxmodule.c')
def _get_source_filename(): srcdir = sysconfig.get_config_var('srcdir') if srcdir is None: # local fallbackreturn fallback_path locations = (srcdir, os.path.dirname(sys.executable)) for location in locations: path = os.path.join(location, 'Modules', 'xxmodule.c') if os.path.exists(path): return path return fallback_pat...
457,119
def tearDown(self): # Get everything back to normal test_support.unload('xx') sys.path = self.sys_path # XXX on Windows the test leaves a directory with xx module in TEMP shutil.rmtree(self.tmp_dir, os.name == 'nt' or sys.platform == 'cygwin') super(BuildExtTestCase, self).tearDown()
def tearDown(self): # Get everything back to normal test_support.unload('xx') sys.path[:] = self.sys_path # XXX on Windows the test leaves a directory with xx module in TEMP shutil.rmtree(self.tmp_dir, os.name == 'nt' or sys.platform == 'cygwin') super(BuildExtTestCase, self).tearDown()
457,120
def test_setuptools_compat(self): from setuptools_build_ext import build_ext as setuptools_build_ext from setuptools_extension import Extension
def test_setuptools_compat(self): from setuptools_build_ext import build_ext as setuptools_build_ext from setuptools_extension import Extension
457,121
def test_suite(): src = _get_source_filename() if not os.path.exists(src): if test_support.verbose: print ('test_build_ext: Cannot find source code (test' ' must run in python build dir)') return unittest.TestSuite() else: return unittest.makeSuite(BuildExtTestCase)
def test_suite(): return unittest.makeSuite(BuildExtTestCase)
457,122
def test_parse_errors(self): cf = self.newconfig() self.parse_error(cf, configparser.ParsingError, "[Foo]\n" "{}val-without-opt-name\n".format(self.delimiters[0])) self.parse_error(cf, configparser.ParsingError, "[Foo]\n" "{}val-without-opt-name\n".format(self.delimiters[1])) e = self.parse_error(cf, configparser.Missi...
def test_parse_errors(self): cf = self.newconfig() self.parse_error(cf, configparser.ParsingError, "[Foo]\n" "{}val-without-opt-name\n".format(self.delimiters[0])) self.parse_error(cf, configparser.ParsingError, "[Foo]\n" "{}val-without-opt-name\n".format(self.delimiters[1])) e = self.parse_error(cf, configparser.Missi...
457,123
def setUp(self): self.file1 = support.TESTFN self.file2 = os.path.join(support.TESTFN + "2")
def setUp(self): self.file1 = support.TESTFN self.file2 = os.path.join(support.TESTFN + "2")
457,124
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)"""
457,125
def test_case_md5_huge(self, size): if size == _4G + 5: try: self.check('md5', 'A'*size, 'c9af2dff37468ce5dfee8f2cfc0a9c6d') except OverflowError: pass # 32-bit arch
def test_case_md5_huge(self, size): if size == _4G + 5: try: self.check('md5', b'A'*size, 'c9af2dff37468ce5dfee8f2cfc0a9c6d') except OverflowError: pass # 32-bit arch
457,126
def test_case_md5_uintmax(self, size): if size == _4G - 1: try: self.check('md5', 'A'*size, '28138d306ff1b8281f1a9067e1a1a2b3') except OverflowError: pass # 32-bit arch
def test_case_md5_uintmax(self, size): if size == _4G - 1: try: self.check('md5', b'A'*size, '28138d306ff1b8281f1a9067e1a1a2b3') except OverflowError: pass # 32-bit arch
457,127
def add(self, *arg_list): if not arg_list: return self if len(arg_list) > 1: self.add(*arg_list[1:]) other = arg_list[0] if type(self) != type(other) or self.__class__ != other.__class__: other = Stats(other) self.files += other.files self.total_calls += other.total_calls self.prim_calls += other.prim_calls self.total_...
def add(self, *arg_list): if not arg_list: return self if len(arg_list) > 1: self.add(*arg_list[1:]) other = arg_list[0] if type(self) != type(other): other = Stats(other) self.files += other.files self.total_calls += other.total_calls self.prim_calls += other.prim_calls self.total_tt += other.total_tt for func in othe...
457,128
def sort_stats(self, *field): if not field: self.fcn_list = 0 return self if len(field) == 1 and type(field[0]) == type(1): # Be compatible with old profiler field = [ {-1: "stdname", 0:"calls", 1:"time", 2: "cumulative" } [ field[0] ] ]
def sort_stats(self, *field): if not field: self.fcn_list = 0 return self if len(field) == 1 and isinstance(field[0], int): # Be compatible with old profiler field = [ {-1: "stdname", 0:"calls", 1:"time", 2: "cumulative" } [ field[0] ] ]
457,129
def sort_stats(self, *field): if not field: self.fcn_list = 0 return self if len(field) == 1 and type(field[0]) == type(1): # Be compatible with old profiler field = [ {-1: "stdname", 0:"calls", 1:"time", 2: "cumulative" } [ field[0] ] ]
def sort_stats(self, *field): if not field: self.fcn_list = 0 return self if len(field) == 1 and type(field[0]) == type(1): # Be compatible with old profiler field = [ {-1: "stdname", 0:"calls", 1:"time", 2: "cumulative" } [ field[0] ] ]
457,130
def eval_print_amount(self, sel, list, msg): new_list = list if type(sel) == type(""): new_list = [] for func in list: if re.search(sel, func_std_string(func)): new_list.append(func) else: count = len(list) if type(sel) == type(1.0) and 0.0 <= sel < 1.0: count = int(count * sel + .5) new_list = list[:count] elif type(s...
def eval_print_amount(self, sel, list, msg): new_list = list if isinstance(sel, str): try: rex = re.compile(sel) except re.error: msg += " <Invalid regular expression %r>\n" % sel return new_list, msg new_list = [] for func in list: if re.search(sel, func_std_string(func)): new_list.append(func) else: count = len(lis...
457,131
def eval_print_amount(self, sel, list, msg): new_list = list if type(sel) == type(""): new_list = [] for func in list: if re.search(sel, func_std_string(func)): new_list.append(func) else: count = len(list) if type(sel) == type(1.0) and 0.0 <= sel < 1.0: count = int(count * sel + .5) new_list = list[:count] elif type(s...
def eval_print_amount(self, sel, list, msg): new_list = list if type(sel) == type(""): new_list = [] for func in list: if rex.search(func_std_string(func)): new_list.append(func) else: count = len(list) if type(sel) == type(1.0) and 0.0 <= sel < 1.0: count = int(count * sel + .5) new_list = list[:count] elif type(sel) ...
457,132
def eval_print_amount(self, sel, list, msg): new_list = list if type(sel) == type(""): new_list = [] for func in list: if re.search(sel, func_std_string(func)): new_list.append(func) else: count = len(list) if type(sel) == type(1.0) and 0.0 <= sel < 1.0: count = int(count * sel + .5) new_list = list[:count] elif type(s...
def eval_print_amount(self, sel, list, msg): new_list = list if type(sel) == type(""): new_list = [] for func in list: if re.search(sel, func_std_string(func)): new_list.append(func) else: count = len(list) if isinstance(sel, float) and 0.0 <= sel < 1.0: count = int(count * sel + .5) new_list = list[:count] elif type(s...
457,133
def eval_print_amount(self, sel, list, msg): new_list = list if type(sel) == type(""): new_list = [] for func in list: if re.search(sel, func_std_string(func)): new_list.append(func) else: count = len(list) if type(sel) == type(1.0) and 0.0 <= sel < 1.0: count = int(count * sel + .5) new_list = list[:count] elif type(s...
def eval_print_amount(self, sel, list, msg): new_list = list if type(sel) == type(""): new_list = [] for func in list: if re.search(sel, func_std_string(func)): new_list.append(func) else: count = len(list) if type(sel) == type(1.0) and 0.0 <= sel < 1.0: count = int(count * sel + .5) new_list = list[:count] elif isinst...
457,134
def eval_print_amount(self, sel, list, msg): new_list = list if type(sel) == type(""): new_list = [] for func in list: if re.search(sel, func_std_string(func)): new_list.append(func) else: count = len(list) if type(sel) == type(1.0) and 0.0 <= sel < 1.0: count = int(count * sel + .5) new_list = list[:count] elif type(s...
def eval_print_amount(self, sel, list, msg): new_list = list if type(sel) == type(""): new_list = [] for func in list: if re.search(sel, func_std_string(func)): new_list.append(func) else: count = len(list) if type(sel) == type(1.0) and 0.0 <= sel < 1.0: count = int(count * sel + .5) new_list = list[:count] elif type(s...
457,135
def get_print_list(self, sel_list): width = self.max_name_len if self.fcn_list: list = self.fcn_list[:] msg = " Ordered by: " + self.sort_type + '\n' else: list = self.stats.keys() msg = " Random listing order was used\n"
def get_print_list(self, sel_list): width = self.max_name_len if self.fcn_list: stat_list = self.fcn_list[:] msg = " Ordered by: " + self.sort_type + '\n' else: list = self.stats.keys() msg = " Random listing order was used\n"
457,136
def get_print_list(self, sel_list): width = self.max_name_len if self.fcn_list: list = self.fcn_list[:] msg = " Ordered by: " + self.sort_type + '\n' else: list = self.stats.keys() msg = " Random listing order was used\n"
def get_print_list(self, sel_list): width = self.max_name_len if self.fcn_list: list = self.fcn_list[:] msg = " Ordered by: " + self.sort_type + '\n' else: stat_list = list(self.stats.keys()) msg = " Random listing order was used\n"
457,137
def get_print_list(self, sel_list): width = self.max_name_len if self.fcn_list: list = self.fcn_list[:] msg = " Ordered by: " + self.sort_type + '\n' else: list = self.stats.keys() msg = " Random listing order was used\n"
def get_print_list(self, sel_list): width = self.max_name_len if self.fcn_list: list = self.fcn_list[:] msg = " Ordered by: " + self.sort_type + '\n' else: list = self.stats.keys() msg = " Random listing order was used\n"
457,138
def get_print_list(self, sel_list): width = self.max_name_len if self.fcn_list: list = self.fcn_list[:] msg = " Ordered by: " + self.sort_type + '\n' else: list = self.stats.keys() msg = " Random listing order was used\n"
def get_print_list(self, sel_list): width = self.max_name_len if self.fcn_list: list = self.fcn_list[:] msg = " Ordered by: " + self.sort_type + '\n' else: list = self.stats.keys() msg = " Random listing order was used\n"
457,139
def get_print_list(self, sel_list): width = self.max_name_len if self.fcn_list: list = self.fcn_list[:] msg = " Ordered by: " + self.sort_type + '\n' else: list = self.stats.keys() msg = " Random listing order was used\n"
def get_print_list(self, sel_list): width = self.max_name_len if self.fcn_list: list = self.fcn_list[:] msg = " Ordered by: " + self.sort_type + '\n' else: list = self.stats.keys() msg = " Random listing order was used\n"
457,140
def __init__(self, profile=None): cmd.Cmd.__init__(self) self.prompt = "% " if profile is not None: self.stats = Stats(profile) self.stream = self.stats.stream else: self.stats = None self.stream = sys.stdout
def __init__(self, profile=None): cmd.Cmd.__init__(self) self.prompt = "% " if profile is not None: self.stats = Stats(profile) self.stream = self.stats.stream else: self.stats = None self.stream = sys.stdout
457,141
def get_parse_out_err(p): return [b.splitlines() for b in p.communicate()]
def get_parse_out_err(p): return [b.splitlines() for b in p.communicate()]
457,142
def get_parse_out_err(p): return [b.splitlines() for b in p.communicate()]
def get_parse_out_err(p): return [b.splitlines() for b in p.communicate()]
457,143
def get_parse_out_err(p): return [b.splitlines() for b in p.communicate()]
def get_parse_out_err(p): return [b.splitlines() for b in p.communicate()]
457,144
def task(N, done, done_tasks, errors): try: # We don't use modulefinder but still import it in order to stress # importing of different modules from several threads. if len(done_tasks) % 2: import modulefinder import random else: import random import modulefinder # This will fail if random is not completely initialized...
def task(N, done, done_tasks, errors): try: # We don't use modulefinder but still import it in order to stress # importing of different modules from several threads. if len(done_tasks) % 2: import modulefinder import random else: import random import modulefinder # This will fail if random is not completely initialized...
457,145
def check_parallel_module_init(self): if imp.lock_held(): # This triggers on, e.g., from test import autotest. raise unittest.SkipTest("can't run when import lock is held")
def check_parallel_module_init(self): if imp.lock_held(): # This triggers on, e.g., from test import autotest. raise unittest.SkipTest("can't run when import lock is held")
457,146
def check_parallel_module_init(self): if imp.lock_held(): # This triggers on, e.g., from test import autotest. raise unittest.SkipTest("can't run when import lock is held")
def check_parallel_module_init(self): if imp.lock_held(): # This triggers on, e.g., from test import autotest. raise unittest.SkipTest("can't run when import lock is held")
457,147
def check_parallel_module_init(self): if imp.lock_held(): # This triggers on, e.g., from test import autotest. raise unittest.SkipTest("can't run when import lock is held")
def check_parallel_module_init(self): if imp.lock_held(): # This triggers on, e.g., from test import autotest. raise unittest.SkipTest("can't run when import lock is held")
457,148
def emit(self, record): """ Emit a record.
def emit(self, record): """ Emit a record.
457,149
def emit(self, record): """ Emit a record.
def emit(self, record): """ Emit a record.
457,150
def main(argv=None): import getopt if argv is None: argv = sys.argv try: opts, prog_argv = getopt.getopt(argv[1:], "tcrRf:d:msC:lTg", ["help", "version", "trace", "count", "report", "no-report", "summary", "file=", "missing", "ignore-module=", "ignore-dir=", "coverdir=", "listfuncs", "trackcalls", "timing"]) except g...
def main(argv=None): import getopt if argv is None: argv = sys.argv try: opts, prog_argv = getopt.getopt(argv[1:], "tcrRf:d:msC:lTg", ["help", "version", "trace", "count", "report", "no-report", "summary", "file=", "missing", "ignore-module=", "ignore-dir=", "coverdir=", "listfuncs", "trackcalls", "timing"]) except g...
457,151
def test_invalid_placeholders(self): raises = self.assertRaises s = Template('$who likes $') raises(ValueError, s.substitute, dict(who='tim')) s = Template('$who likes ${what)') raises(ValueError, s.substitute, dict(who='tim')) s = Template('$who likes $100') raises(ValueError, s.substitute, dict(who='tim'))
def test_invalid_placeholders(self): raises = self.assertRaises s = Template('$who likes $') raises(ValueError, s.substitute, dict(who='tim')) s = Template('$who likes ${what)') raises(ValueError, s.substitute, dict(who='tim')) s = Template('$who likes $100') raises(ValueError, s.substitute, dict(who='tim'))
457,152
def interface(): """ Test element tree interface. >>> element = ET.Element("tag") >>> check_element(element) >>> tree = ET.ElementTree(element) >>> check_element(tree.getroot()) >>> element = ET.Element("tag", key="value") >>> tree = ET.ElementTree(element) >>> repr(element) # doctest: +ELLIPSIS "<Element 'tag' at ...
def interface(): r""" Test element tree interface. >>> element = ET.Element("tag") >>> check_element(element) >>> tree = ET.ElementTree(element) >>> check_element(tree.getroot()) >>> element = ET.Element("tag", key="value") >>> tree = ET.ElementTree(element) >>> repr(element) # doctest: +ELLIPSIS "<Element 'tag' at...
457,153
def interface(): """ Test element tree interface. >>> element = ET.Element("tag") >>> check_element(element) >>> tree = ET.ElementTree(element) >>> check_element(tree.getroot()) >>> element = ET.Element("tag", key="value") >>> tree = ET.ElementTree(element) >>> repr(element) # doctest: +ELLIPSIS "<Element 'tag' at ...
def interface(): """ Test element tree interface. >>> element = ET.Element("tag") >>> check_element(element) >>> tree = ET.ElementTree(element) >>> check_element(tree.getroot()) >>> element = ET.Element("t\xe4g", key="value") >>> tree = ET.ElementTree(element) >>> repr(element) # doctest: +ELLIPSIS "<Element 'tag' ...
457,154
def interface(): """ Test element tree interface. >>> element = ET.Element("tag") >>> check_element(element) >>> tree = ET.ElementTree(element) >>> check_element(tree.getroot()) >>> element = ET.Element("tag", key="value") >>> tree = ET.ElementTree(element) >>> repr(element) # doctest: +ELLIPSIS "<Element 'tag' at ...
def interface(): """ Test element tree interface. >>> element = ET.Element("tag") >>> check_element(element) >>> tree = ET.ElementTree(element) >>> check_element(tree.getroot()) >>> element = ET.Element("tag", key="value") >>> tree = ET.ElementTree(element) >>> repr(element) # doctest: +ELLIPSIS "<Element 't\\xe4g'...
457,155
def get_python_inc(plat_specific=0, prefix=None): """Return the directory containing installed Python header files. If 'plat_specific' is false (the default), this is the path to the non-platform-specific header files, i.e. Python.h and so on; otherwise, this is the path to platform-specific header files (namely pycon...
def get_python_inc(plat_specific=0, prefix=None): """Return the directory containing installed Python header files. If 'plat_specific' is false (the default), this is the path to the non-platform-specific header files, i.e. Python.h and so on; otherwise, this is the path to platform-specific header files (namely pycon...
457,156
def get_makefile_filename(): """Return full pathname of installed Makefile from the Python build.""" if python_build: return os.path.join(os.path.dirname(sys.executable), "Makefile") lib_dir = get_python_lib(plat_specific=1, standard_lib=1) return os.path.join(lib_dir, "config", "Makefile")
def get_makefile_filename(): """Return full pathname of installed Makefile from the Python build.""" if python_build: return os.path.join(os.path.dirname(os.path.realpath(sys.executable)), "Makefile") lib_dir = get_python_lib(plat_specific=1, standard_lib=1) return os.path.join(lib_dir, "config", "Makefile")
457,157
def _init_nt(): """Initialize the module as appropriate for NT""" g = {} # set basic install directories g['LIBDEST'] = get_python_lib(plat_specific=0, standard_lib=1) g['BINLIBDEST'] = get_python_lib(plat_specific=1, standard_lib=1) # XXX hmmm.. a normal install puts include files here g['INCLUDEPY'] = get_python_inc...
def _init_nt(): """Initialize the module as appropriate for NT""" g = {} # set basic install directories g['LIBDEST'] = get_python_lib(plat_specific=0, standard_lib=1) g['BINLIBDEST'] = get_python_lib(plat_specific=1, standard_lib=1) # XXX hmmm.. a normal install puts include files here g['INCLUDEPY'] = get_python_inc...
457,158
def __init__(self, args, bufsize=0, executable=None, stdin=None, stdout=None, stderr=None, preexec_fn=None, close_fds=False, shell=False, cwd=None, env=None, universal_newlines=False, startupinfo=None, creationflags=0, restore_signals=True, start_new_session=False): """Create new Popen instance.""" _cleanup()
def __init__(self, args, bufsize=0, executable=None, stdin=None, stdout=None, stderr=None, preexec_fn=None, close_fds=False, shell=False, cwd=None, env=None, universal_newlines=False, startupinfo=None, creationflags=0, restore_signals=True, start_new_session=False): """Create new Popen instance.""" _cleanup()
457,159
def __init__(self, args, bufsize=0, executable=None, stdin=None, stdout=None, stderr=None, preexec_fn=None, close_fds=False, shell=False, cwd=None, env=None, universal_newlines=False, startupinfo=None, creationflags=0, restore_signals=True, start_new_session=False): """Create new Popen instance.""" _cleanup()
def __init__(self, args, bufsize=0, executable=None, stdin=None, stdout=None, stderr=None, preexec_fn=None, close_fds=False, shell=False, cwd=None, env=None, universal_newlines=False, startupinfo=None, creationflags=0, restore_signals=True, start_new_session=False): """Create new Popen instance.""" _cleanup()
457,160
def __init__(self, args, bufsize=0, executable=None, stdin=None, stdout=None, stderr=None, preexec_fn=None, close_fds=False, shell=False, cwd=None, env=None, universal_newlines=False, startupinfo=None, creationflags=0, restore_signals=True, start_new_session=False): """Create new Popen instance.""" _cleanup()
def __init__(self, args, bufsize=0, executable=None, stdin=None, stdout=None, stderr=None, preexec_fn=None, close_fds=False, shell=False, cwd=None, env=None, universal_newlines=False, startupinfo=None, creationflags=0, restore_signals=True, start_new_session=False): """Create new Popen instance.""" _cleanup()
457,161
def _execute_child(self, args, executable, preexec_fn, close_fds, cwd, env, universal_newlines, startupinfo, creationflags, shell, p2cread, p2cwrite, c2pread, c2pwrite, errread, errwrite, unused_restore_signals, unused_start_new_session): """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, unused_restore_signals, unused_start_new_session): """Execute program (MS Windows version)"""
457,162
def _execute_child(self, args, executable, preexec_fn, close_fds, cwd, env, universal_newlines, startupinfo, creationflags, shell, p2cread, p2cwrite, c2pread, c2pwrite, errread, errwrite, unused_restore_signals, unused_start_new_session): """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, unused_restore_signals, unused_start_new_session): """Execute program (MS Windows version)"""
457,163
def _execute_child(self, args, executable, preexec_fn, close_fds, cwd, env, universal_newlines, startupinfo, creationflags, shell, p2cread, p2cwrite, c2pread, c2pwrite, errread, errwrite, unused_restore_signals, unused_start_new_session): """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, unused_restore_signals, unused_start_new_session): """Execute program (MS Windows version)"""
457,164
def __init__(self, server, conn, addr): asynchat.async_chat.__init__(self, conn) self.__server = server self.__conn = conn self.__addr = addr self.__line = [] self.__state = self.COMMAND self.__greeting = 0 self.__mailfrom = None self.__rcpttos = [] self.__data = '' self.__fqdn = socket.getfqdn() self.__peer = conn.get...
def __init__(self, server, conn, addr): asynchat.async_chat.__init__(self, conn) self.__server = server self.__conn = conn self.__addr = addr self.__line = [] self.__state = self.COMMAND self.__greeting = 0 self.__mailfrom = None self.__rcpttos = [] self.__data = '' self.__fqdn = socket.getfqdn() try: self.__peer = con...
457,165
def handle_accept(self): conn, addr = self.accept() print >> DEBUGSTREAM, 'Incoming connection from %s' % repr(addr) channel = SMTPChannel(self, conn, addr)
def handle_accept(self): try: conn, addr = self.accept() except TypeError: return except socket.error as err: if err.args[0] != errno.ECONNABORTED: raise return else: if addr == None: return print >> DEBUGSTREAM, 'Incoming connection from %s' % repr(addr) channel = SMTPChannel(self, conn, addr)
457,166
def test_data(self): for filename, expected in ( ('sndhdr.8svx', ('8svx', 0, 1, 0, 8)), ('sndhdr.aifc', ('aifc', 44100, 2, 5, 16)), ('sndhdr.aiff', ('aiff', 44100, 2, 5, 16)), ('sndhdr.au', ('au', 44100, 2, 5.0, 16)), ('sndhdr.hcom', ('hcom', 22050.0, 1, -1, 8)), ('sndhdr.sndt', ('sndt', 44100, 1, 5, 8)), ('sndhdr.voc'...
def test_data(self): for filename, expected in ( ('sndhdr.8svx', ('8svx', 0, 1, 0, 8)), ('sndhdr.aifc', ('aifc', 44100, 2, 5, 16)), ('sndhdr.aiff', ('aiff', 44100, 2, 5, 16)), ('sndhdr.au', ('au', 44100, 2, 5.0, 16)), ('sndhdr.hcom', ('hcom', 22050.0, 1, -1, 8)), ('sndhdr.sndt', ('sndt', 44100, 1, 5, 8)), ('sndhdr.voc'...
457,167
def abort(self): '''Abort a file transfer. Uses out-of-band data. This does not follow the procedure from the RFC to send Telnet IP and Synch; that doesn't seem to work with the servers I've tried. Instead, just send the ABOR command as OOB data.''' line = 'ABOR' + CRLF if self.debugging > 1: print('*put urgent*', se...
def abort(self): '''Abort a file transfer. Uses out-of-band data. This does not follow the procedure from the RFC to send Telnet IP and Synch; that doesn't seem to work with the servers I've tried. Instead, just send the ABOR command as OOB data.''' line = 'ABOR' + CRLF if self.debugging > 1: print('*put urgent*', se...
457,168
def flush(self,zlib_mode=zlib.Z_SYNC_FLUSH): if self.mode == WRITE: # Ensure the compressor's buffer is flushed self.fileobj.write(self.compress.flush(zlib_mode)) self.fileobj.flush()
def flush(self,zlib_mode=zlib.Z_SYNC_FLUSH): if self.mode == WRITE: # Ensure the compressor's buffer is flushed self.fileobj.write(self.compress.flush(zlib_mode)) self.fileobj.flush()
457,169
def runtest_inner(test, verbose, quiet, testdir=None, huntrleaks=False, debug=False): support.unload(test) testdir = findtestdir(testdir) if verbose: capture_stdout = None else: capture_stdout = io.StringIO() test_time = 0.0 refleak = False # True if the test leaked references. try: if test.startswith('test.'): abste...
def runtest_inner(test, verbose, quiet, testdir=None, huntrleaks=False, debug=False): support.unload(test) testdir = findtestdir(testdir) if verbose: capture_stdout = None else: capture_stdout = io.StringIO() test_time = 0.0 refleak = False # True if the test leaked references. try: if test.startswith('test.'): abste...
457,170
def runtest_inner(test, verbose, quiet, testdir=None, huntrleaks=False, debug=False): support.unload(test) testdir = findtestdir(testdir) if verbose: capture_stdout = None else: capture_stdout = io.StringIO() test_time = 0.0 refleak = False # True if the test leaked references. try: if test.startswith('test.'): abste...
def runtest_inner(test, verbose, quiet, testdir=None, huntrleaks=False, debug=False): support.unload(test) testdir = findtestdir(testdir) if verbose: capture_stdout = None else: capture_stdout = io.StringIO() test_time = 0.0 refleak = False # True if the test leaked references. try: if test.startswith('test.'): abste...
457,171
def runtest_inner(test, verbose, quiet, testdir=None, huntrleaks=False, debug=False): support.unload(test) testdir = findtestdir(testdir) if verbose: capture_stdout = None else: capture_stdout = io.StringIO() test_time = 0.0 refleak = False # True if the test leaked references. try: if test.startswith('test.'): abste...
def runtest_inner(test, verbose, quiet, testdir=None, huntrleaks=False, debug=False): support.unload(test) testdir = findtestdir(testdir) if verbose: capture_stdout = None else: capture_stdout = io.StringIO() test_time = 0.0 refleak = False # True if the test leaked references. try: if test.startswith('test.'): abste...
457,172
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 = list(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]
457,173
def logical_and(self, a, b): """Applies the logical operation 'and' between each operand's digits.
def logical_and(self, a, b): """Applies the logical operation 'and' between each operand's digits.
457,174
def logical_or(self, a, b): """Applies the logical operation 'or' between each operand's digits.
def logical_or(self, a, b): """Applies the logical operation 'or' between each operand's digits.
457,175
def logical_xor(self, a, b): """Applies the logical operation 'xor' between each operand's digits.
def logical_xor(self, a, b): """Applies the logical operation 'xor' between each operand's digits.
457,176
def detect_modules(self): try: belibs = os.environ['BELIBRARIES'].split(';') except KeyError: belibs = ['/boot/beos/system/lib'] belibs.append('/boot/home/config/lib') self.compiler.library_dirs.append('/boot/home/config/lib') try: beincl = os.environ['BEINCLUDES'].split(';') except KeyError: beincl = [] beincl.append(...
def detect_modules(self): try: belibs = os.environ['BELIBRARIES'].split(';') except KeyError: belibs = ['/boot/beos/system/lib'] belibs.append('/boot/home/config/lib') self.compiler.library_dirs.append('/boot/home/config/lib') try: beincl = os.environ['BEINCLUDES'].split(';') except KeyError: beincl = [] beincl.append(...
457,177
def test_threaded_hashing(self): if not threading: raise unittest.SkipTest('No threading module.')
def test_threaded_hashing(self): if not threading: raise unittest.SkipTest('No threading module.')
457,178
def hash_in_chunks(chunk_size, event): index = 0 while index < len(data): hasher.update(data[index:index+chunk_size]) index += chunk_size event.set()
def hash_in_chunks(chunk_size, event): index = 0 while index < len(data): hasher.update(data[index:index+chunk_size]) index += chunk_size event.set()
457,179
def start(self): if not self.__initialized: raise RuntimeError("thread.__init__() not called") if self.__started.is_set(): raise RuntimeError("thread already started") if __debug__: self._note("%s.start(): starting thread", self) with _active_limbo_lock: _limbo[self] = self try: _start_new_thread(self.__bootstrap, ()) ...
def start(self): if not self.__initialized: raise RuntimeError("thread.__init__() not called") if self.__started.is_set(): raise RuntimeError("threads can only be started once") if __debug__: self._note("%s.start(): starting thread", self) with _active_limbo_lock: _limbo[self] = self try: _start_new_thread(self.__boots...
457,180
def test_mbcs_name(self): self.file1 += "\u65e5\u672c" self.file2 = self.file1 + "2" self._test_link(self.file1, self.file2)
def test_mbcs_name(self): try: chars = os.fsencode("\u65e5\u672c") except UnicodeError: raise unittest.SkipTest("Unable to encode for this platform.") self.file1 += chars self.file2 = self.file1 + "2" self._test_link(self.file1, self.file2)
457,181
def setUp(self): # Records changes to env vars self.env = support.EnvironmentVarGuard() # Delete all proxy related env vars for k in os.environ.keys(): if 'proxy' in k.lower(): self.env.unset(k)
def setUp(self): # Records changes to env vars self.env = support.EnvironmentVarGuard() # Delete all proxy related env vars for k in os.environ.keys(): if k == 'NO_PROXY': self.env.unset(k)
457,182
def handle_accept(self): conn, addr = self.accept() print('Incoming connection from %s' % repr(addr), file=DEBUGSTREAM) channel = self.channel_class(self, conn, addr)
def handle_accept(self) try: conn, addr = self.accept() except TypeError: return except socket.error, err: if err[0] != errno.ECONNABORTED: raise return else: if addr == None: return print('Incoming connection from %s' % repr(addr), file=DEBUGSTREAM) channel = self.channel_class(self, conn, addr)
457,183
def test_connection_attributes(self): server = TCPServer() client = BaseClient(server.address)
def test_connection_attributes(self): server = TCPServer() client = BaseClient(server.address)
457,184
def __index__(self): """index(self)""" return int(self)
def __index__(self): """someobject[self]""" return int(self)
457,185
def http_error_401(self, url, fp, errcode, errmsg, headers, data=None): """Error 401 -- authentication required. This function supports Basic authentication only.""" if not 'www-authenticate' in headers: URLopener.http_error_default(self, url, fp, errcode, errmsg, headers) stuff = headers['www-authenticate'] import re ...
def http_error_401(self, url, fp, errcode, errmsg, headers, data=None, retry=False): """Error 401 -- authentication required. This function supports Basic authentication only.""" if not 'www-authenticate' in headers: URLopener.http_error_default(self, url, fp, errcode, errmsg, headers) stuff = headers['www-authenticate...
457,186
def http_error_407(self, url, fp, errcode, errmsg, headers, data=None): """Error 407 -- proxy authentication required. This function supports Basic authentication only.""" if not 'proxy-authenticate' in headers: URLopener.http_error_default(self, url, fp, errcode, errmsg, headers) stuff = headers['proxy-authenticate'] ...
def http_error_407(self, url, fp, errcode, errmsg, headers, data=None, retry=False): """Error 407 -- proxy authentication required. This function supports Basic authentication only.""" if not 'proxy-authenticate' in headers: URLopener.http_error_default(self, url, fp, errcode, errmsg, headers) stuff = headers['proxy-au...
457,187
def total_ordering(cls): 'Class decorator that fills-in missing ordering methods' convert = { '__lt__': [('__gt__', lambda self, other: other < self), ('__le__', lambda self, other: not other < self), ('__ge__', lambda self, other: not self < other)], '__le__': [('__ge__', lambda self, other: other <= self), ('__lt__',...
def total_ordering(cls): """Class decorator that fills in missing ordering methods""" convert = { '__lt__': [('__gt__', lambda self, other: other < self), ('__le__', lambda self, other: not other < self), ('__ge__', lambda self, other: not self < other)], '__le__': [('__ge__', lambda self, other: other <= self), ('__lt...
457,188
def check_big_compress_buffer(self, size, compress_func): _1M = 1024 * 1024 fmt = "%%0%dx" % (2 * _1M) # Generate 10MB worth of random, and expand it by repeating it. # The assumption is that zlib's memory is not big enough to exploit # such spread out redundancy. data = b''.join([random.getrandbits(8 * _1M).to_bytes(_...
def check_big_compress_buffer(self, size, compress_func): _1M = 1024 * 1024 fmt = "%%0%dx" % (2 * _1M) # Generate 10MB worth of random, and expand it by repeating it. # The assumption is that zlib's memory is not big enough to exploit # such spread out redundancy. data = b''.join([binascii.a2b_hex(fmt % random.getrandb...
457,189
def test1(self): xml = "\0\r\n" parser = expat.ParserCreate() try: parser.Parse(xml, True) self.fail() except expat.ExpatError as e: self.assertEquals(str(e), 'no element found: line 2, column 1')
def test1(self): xml = "\0\r\n" parser = expat.ParserCreate() try: parser.Parse(xml, True) self.fail() except expat.ExpatError as e: self.assertEquals(str(e), 'no element found: line 2, column 1')
457,190
def test_setfilesystemencoding(self): old = sys.getfilesystemencoding() sys.setfilesystemencoding("iso-8859-1") self.assertEqual(sys.getfilesystemencoding(), "iso-8859-1") self.assertRaises(LookupError, sys.setfilesystemencoding, "xxx") sys.setfilesystemencoding(old)
def test_setfilesystemencoding(self): old = sys.getfilesystemencoding() sys.setfilesystemencoding("iso-8859-1") self.assertEqual(sys.getfilesystemencoding(), "iso-8859-1") self.assertRaises(LookupError, sys.setfilesystemencoding, "xxx") sys.setfilesystemencoding(old)
457,191
def test_misc(self):
def test_misc(self):
457,192
def test_misc(self):
def test_misc(self):
457,193
def __init__(self, value): if isinstance(value, (int, long)): self.n = value self.d = 1 elif isinstance(value, float): # Convert to exact rational equivalent. f, e = math.frexp(abs(value)) assert f == 0 or 0.5 <= f < 1.0 # |value| = f * 2**e exactly
def __init__(self, value): if isinstance(value, (int, long)): self.n = value self.d = 1 elif isinstance(value, float): # Convert to exact rational equivalent. f, e = math.frexp(abs(value)) assert f == 0 or 0.5 <= f < 1.0 # |value| = f * 2**e exactly
457,194
def test_single_warning(self): newenv = os.environ.copy() newenv["PYTHONWARNINGS"] = "ignore::DeprecationWarning" p = subprocess.Popen([sys.executable, "-c", "import sys; sys.stdout.write(str(sys.warnoptions))"], stdout=subprocess.PIPE, env=newenv) self.assertEqual(p.stdout.read(), "['ignore::DeprecationWarning']")
def test_single_warning(self): newenv = os.environ.copy() newenv["PYTHONWARNINGS"] = "ignore::DeprecationWarning" p = subprocess.Popen([sys.executable, "-c", "import sys; sys.stdout.write(str(sys.warnoptions))"], stdout=subprocess.PIPE, env=newenv) self.assertEqual(p.stdout.read(), "['ignore::DeprecationWarning']")
457,195
def test_comma_separated_warnings(self): newenv = os.environ.copy() newenv["PYTHONWARNINGS"] = ("ignore::DeprecationWarning," "ignore::UnicodeWarning") p = subprocess.Popen([sys.executable, "-c", "import sys; sys.stdout.write(str(sys.warnoptions))"], stdout=subprocess.PIPE, env=newenv) self.assertEqual(p.stdout.read(),...
def test_comma_separated_warnings(self): newenv = os.environ.copy() newenv["PYTHONWARNINGS"] = ("ignore::DeprecationWarning," "ignore::UnicodeWarning") p = subprocess.Popen([sys.executable, "-c", "import sys; sys.stdout.write(str(sys.warnoptions))"], stdout=subprocess.PIPE, env=newenv) self.assertEqual(p.communicate()[...
457,196
def test_envvar_and_command_line(self): newenv = os.environ.copy() newenv["PYTHONWARNINGS"] = "ignore::DeprecationWarning" p = subprocess.Popen([sys.executable, "-W" "ignore::UnicodeWarning", "-c", "import sys; sys.stdout.write(str(sys.warnoptions))"], stdout=subprocess.PIPE, env=newenv) self.assertEqual(p.stdout.read(...
def test_envvar_and_command_line(self): newenv = os.environ.copy() newenv["PYTHONWARNINGS"] = "ignore::DeprecationWarning" p = subprocess.Popen([sys.executable, "-W" "ignore::UnicodeWarning", "-c", "import sys; sys.stdout.write(str(sys.warnoptions))"], stdout=subprocess.PIPE, env=newenv) self.assertEqual(p.communicate(...
457,197
def _internal_poll(self, _deadstate=None, _WaitForSingleObject=WaitForSingleObject, _WAIT_OBJECT_0=WAIT_OBJECT_0, _GetExitCodeProcess=GetExitCodeProcess): """Check if child process has terminated. Returns returncode attribute.
def _internal_poll(self, _deadstate=None, _WaitForSingleObject=_subprocess.WaitForSingleObject, _WAIT_OBJECT_0=_subprocess.WAIT_OBJECT_0, _GetExitCodeProcess=_subprocess.GetExitCodeProcess): """Check if child process has terminated. Returns returncode attribute.
457,198
def finalize_options(self): from distutils import sysconfig
def finalize_options(self): from distutils import sysconfig
457,199