bugged
stringlengths
4
228k
fixed
stringlengths
0
96.3M
__index_level_0__
int64
0
481k
def testboth(formatstr, *args): testformat(formatstr, *args) if have_unicode: testformat(unicode(formatstr), *args)
def testboth(formatstr, *args): testformat(formatstr, *args) if have_unicode: testformat(unicode(formatstr), *args, **kwargs)
456,500
def test_format(self): global overflowok
def test_format(self): global overflowok
456,501
def test_format(self): global overflowok
def test_format(self): global overflowok
456,502
def test_format(self): global overflowok
def test_format(self): global overflowok
456,503
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,504
def check(self, name, data, digest): constructors = self.constructors_to_test[name] # 2 is for hashlib.name(...) and hashlib.new(name, ...) self.assertGreaterEqual(len(constructors), 2) for hash_object_constructor in constructors: if COMPILED_WITH_PYDEBUG: # XXX(gps): This is temporary to debug a buildbot failure. # h...
def check(self, name, data, digest): constructors = self.constructors_to_test[name] # 2 is for hashlib.name(...) and hashlib.new(name, ...) self.assertGreaterEqual(len(constructors), 2) for hash_object_constructor in constructors: if COMPILED_WITH_PYDEBUG: # XXX(gps): This is temporary to debug a buildbot failure. # h...
456,505
def has_sound(sound): """Find out if a particular event is configured with a default sound""" try: key = winreg.OpenKeyEx(_winreg.HKEY_CURRENT_USER, "AppEvents\Schemes\Apps\.Default\{0}\.Default".format(sound)) value = winreg.EnumValue(key, 0)[1] if value is not "": return True else: return False except WindowsError: r...
def has_sound(sound): """Find out if a particular event is configured with a default sound""" try: key = winreg.OpenKeyEx(winreg.HKEY_CURRENT_USER, "AppEvents\Schemes\Apps\.Default\{0}\.Default".format(sound)) value = winreg.EnumValue(key, 0)[1] if value is not "": return True else: return False except WindowsError: re...
456,506
1 -> def test_function_2(foo):
1 -> def test_function_2(foo):
456,507
def test_pdb_run_with_code_object(): """Testing run and runeval with code object as a first argument. >>> with PdbTestInput(['step','x', 'continue']): ... pdb_invoke('run', compile('x=1', '<string>', 'exec')) > <string>(1)<module>() (Pdb) step --Return-- > <string>(1)<module>()->None (Pdb) x 1 (Pdb) continue >>> ...
def test_pdb_run_with_code_object(): """Testing run and runeval with code object as a first argument. >>> with PdbTestInput(['step','x', 'continue']): ... pdb_invoke('run', compile('x=1', '<string>', 'exec')) > <string>(1)<module>() (Pdb) step --Return-- > <string>(1)<module>()->None (Pdb) x 1 (Pdb) continue >>> ...
456,508
def test_pdb_run_with_code_object(): """Testing run and runeval with code object as a first argument. >>> with PdbTestInput(['step','x', 'continue']): ... pdb_invoke('run', compile('x=1', '<string>', 'exec')) > <string>(1)<module>() (Pdb) step --Return-- > <string>(1)<module>()->None (Pdb) x 1 (Pdb) continue >>> ...
def test_pdb_run_with_code_object(): """Testing run and runeval with code object as a first argument. >>> with PdbTestInput(['step','x', 'continue']): ... pdb_invoke('run', compile('x=1', '<string>', 'exec')) > <string>(1)<module>()... (Pdb) step --Return-- > <string>(1)<module>()->None (Pdb) x 1 (Pdb) continue >...
456,509
def testProtocolSSL23(self): if test_support.verbose: sys.stdout.write("\n") try: tryProtocolCombo(ssl.PROTOCOL_SSLv23, ssl.PROTOCOL_SSLv2, True) except (SSLError, socket.error), x: # this fails on some older versions of OpenSSL (0.9.7l, for instance) if test_support.verbose: sys.stdout.write( " SSL2 client to SSL23 se...
def testProtocolSSL23(self): if test_support.verbose: sys.stdout.write("\n") try: tryProtocolCombo(ssl.PROTOCOL_SSLv23, ssl.PROTOCOL_SSLv2, True) except (ssl.SSLError, socket.error), x: # this fails on some older versions of OpenSSL (0.9.7l, for instance) if test_support.verbose: sys.stdout.write( " SSL2 client to SSL2...
456,510
def setUp(self): # Records changes to env vars self.env = test_support.EnvironmentVarGuard() # Delete all proxy related env vars for k, v in os.environ.iteritems(): if 'proxy' in k.lower(): self.env.unset(k)
def setUp(self): # Records changes to env vars self.env = test_support.EnvironmentVarGuard() # Delete all proxy related env vars for k in os.environ.keys(): if 'proxy' in k.lower(): self.env.unset(k)
456,511
def get_config_h_filename(): """Returns the path of pyconfig.h.""" if _PYTHON_BUILD: if os.name == "nt": inc_dir = os.path.join(_PROJECT_BASE, "PC") else: inc_dir = _PROJECT_BASE else: inc_dir = get_path('platinclude') return os.path.join(inc_dir, 'pyconfig.h')
def get_config_h_filename(): """Return the path of pyconfig.h.""" if _PYTHON_BUILD: if os.name == "nt": inc_dir = os.path.join(_PROJECT_BASE, "PC") else: inc_dir = _PROJECT_BASE else: inc_dir = get_path('platinclude') return os.path.join(inc_dir, 'pyconfig.h')
456,512
def get_scheme_names(): """Returns a tuple containing the schemes names.""" schemes = list(_INSTALL_SCHEMES.keys()) schemes.sort() return tuple(schemes)
def get_scheme_names(): """Return a tuple containing the schemes names.""" schemes = list(_INSTALL_SCHEMES.keys()) schemes.sort() return tuple(schemes)
456,513
def get_path_names(): """Returns a tuple containing the paths names.""" return _SCHEME_KEYS
def get_path_names(): """Return a tuple containing the paths names.""" return _SCHEME_KEYS
456,514
def get_paths(scheme=_get_default_scheme(), vars=None, expand=True): """Returns a mapping containing an install scheme. ``scheme`` is the install scheme name. If not provided, it will return the default scheme for the current platform. """ if expand: return _expand_vars(scheme, vars) else: return _INSTALL_SCHEMES[sche...
def get_paths(scheme=_get_default_scheme(), vars=None, expand=True): """Return a mapping containing an install scheme. ``scheme`` is the install scheme name. If not provided, it will return the default scheme for the current platform. """ if expand: return _expand_vars(scheme, vars) else: return _INSTALL_SCHEMES[schem...
456,515
def get_path(name, scheme=_get_default_scheme(), vars=None, expand=True): """Returns a path corresponding to the scheme. ``scheme`` is the install scheme name. """ return get_paths(scheme, vars, expand)[name]
def get_path(name, scheme=_get_default_scheme(), vars=None, expand=True): """Return a path corresponding to the scheme. ``scheme`` is the install scheme name. """ return get_paths(scheme, vars, expand)[name]
456,516
def _main(): """Displays all information sysconfig detains.""" print('Platform: "{0}"'.format(get_platform())) print('Python version: "{0}"'.format(get_python_version())) print('Current installation scheme: "{0}"'.format(_get_default_scheme())) print('') _print_dict('Paths', get_paths()) print('') _print_dict('Variable...
def _main(): """Display all information sysconfig detains.""" print('Platform: "{0}"'.format(get_platform())) print('Python version: "{0}"'.format(get_python_version())) print('Current installation scheme: "{0}"'.format(_get_default_scheme())) print('') _print_dict('Paths', get_paths()) print('') _print_dict('Variables...
456,517
def test_main(verbose=None): test_classes = (BuiltinTest, TestSorted) run_unittest(*test_classes) # verify reference counting if verbose and hasattr(sys, "gettotalrefcount"): import gc counts = [None] * 5 for i in xrange(len(counts)): run_unittest(*test_classes) gc.collect() counts[i] = sys.gettotalrefcount() print c...
def test_main(verbose=None): test_classes = (BuiltinTest, TestSorted) _run_unittest(*test_classes) # verify reference counting if verbose and hasattr(sys, "gettotalrefcount"): import gc counts = [None] * 5 for i in xrange(len(counts)): _run_unittest(*test_classes) gc.collect() counts[i] = sys.gettotalrefcount() print...
456,518
def test_main(verbose=None): test_classes = (BuiltinTest, TestSorted) run_unittest(*test_classes) # verify reference counting if verbose and hasattr(sys, "gettotalrefcount"): import gc counts = [None] * 5 for i in xrange(len(counts)): run_unittest(*test_classes) gc.collect() counts[i] = sys.gettotalrefcount() print c...
def test_main(verbose=None): test_classes = (BuiltinTest, TestSorted) _run_unittest(*test_classes) # verify reference counting if verbose and hasattr(sys, "gettotalrefcount"): import gc counts = [None] * 5 for i in xrange(len(counts)): _run_unittest(*test_classes) gc.collect() counts[i] = sys.gettotalrefcount() print...
456,519
def testAttributes(self): # verify expected attributes exist f = self.f softspace = f.softspace f.name # merely shouldn't blow up f.mode # ditto f.closed # ditto
def testAttributes(self): # verify expected attributes exist f = self.f f.name # merely shouldn't blow up f.mode # ditto f.closed # ditto
456,520
def testAttributes(self): # verify expected attributes exist f = self.f softspace = f.softspace f.name # merely shouldn't blow up f.mode # ditto f.closed # ditto
def testAttributes(self): # verify expected attributes exist f = self.f softspace = f.softspace f.name # merely shouldn't blow up f.mode # ditto f.closed # ditto
456,521
def testMethods(self): methods = ['fileno', 'flush', 'isatty', 'next', 'read', 'readinto', 'readline', 'readlines', 'seek', 'tell', 'truncate', 'write', 'xreadlines', '__iter__'] if sys.platform.startswith('atheos'): methods.remove('truncate')
def testMethods(self): methods = ['fileno', 'flush', 'isatty', 'next', 'read', 'readinto', 'readline', 'readlines', 'seek', 'tell', 'truncate', 'write', 'xreadlines', '__iter__'] if sys.platform.startswith('atheos'): methods.remove('truncate')
456,522
def testBadModeArgument(self): # verify that we get a sensible error message for bad mode argument bad_mode = "qwerty" try: f = open(TESTFN, bad_mode) except ValueError, msg: if msg[0] != 0: s = str(msg) if TESTFN in s or bad_mode not in s: self.fail("bad error message for invalid mode: %s" % s) # if msg[0] == 0, we're...
def testBadModeArgument(self): # verify that we get a sensible error message for bad mode argument bad_mode = "qwerty" try: f = open(TESTFN, bad_mode) except ValueError, msg: if msg.args[0] != 0: s = str(msg) if TESTFN in s or bad_mode not in s: self.fail("bad error message for invalid mode: %s" % s) # if msg[0] == 0, ...
456,523
def test_various_ops(self): # This takes about n/3 seconds to run (about n/3 clumps of tasks, # times about 1 second per clump). NUMTASKS = 10
def test_various_ops(self): # This takes about n/3 seconds to run (about n/3 clumps of tasks, # times about 1 second per clump). NUMTASKS = 10
456,524
def test_unquoting(self): # Make sure unquoting of all ASCII values works escape_list = [] for num in range(128): given = hexescape(chr(num)) expect = chr(num) result = urllib.parse.unquote(given) self.assertEqual(expect, result, "using unquote(): %r != %r" % (expect, result)) result = urllib.parse.unquote_plus(given) ...
def test_unquoting(self): # Make sure unquoting of all ASCII values works escape_list = [] for num in range(128): given = hexescape(chr(num)) expect = chr(num) result = urllib.parse.unquote(given) self.assertEqual(expect, result, "using unquote(): %r != %r" % (expect, result)) result = urllib.parse.unquote_plus(given) ...
456,525
def __init__(self, server, conn, addr): asynchat.async_chat.__init__(self, conn) self.smtp_server = server self.conn = conn self.addr = addr self.received_lines = [] self.smtp_state = self.COMMAND self.seen_greeting = '' self.mailfrom = None self.rcpttos = [] self.received_data = '' self.fqdn = socket.getfqdn() self.pe...
def __init__(self, server, conn, addr): asynchat.async_chat.__init__(self, conn) self.smtp_server = server self.conn = conn self.addr = addr self.received_lines = [] self.smtp_state = self.COMMAND self.seen_greeting = '' self.mailfrom = None self.rcpttos = [] self.received_data = '' self.fqdn = socket.getfqdn() try: se...
456,526
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 as err: if err.args[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)
456,527
def MDFilter(): mdContext = md5() while 1: data = sys.stdin.read(16) if not data: break mdContext.update(data) MDPrint(mdContext.digest()) print()
def MDFilter(): mdContext = md5() while 1: data = sys.stdin.read(16).encode() if not data: break mdContext.update(data) MDPrint(mdContext.digest()) print()
456,528
def test_issue_8766(self): # "import encodings" emits a warning whereas the warnings is not loaded # or not completly loaded (warnings imports indirectly encodings by # importing linecache) yet old_cwd = os.getcwd() try: cwd = tempfile.mkdtemp() try: os.chdir(cwd) os.mkdir('encodings') env = os.environ.copy() env['PYTH...
def test_issue_8766(self): # "import encodings" emits a warning whereas the warnings is not loaded # or not completly loaded (warnings imports indirectly encodings by # importing linecache) yet cwd = tempfile.mkdtemp() try: cwd = tempfile.mkdtemp() try: os.chdir(cwd) os.mkdir('encodings') env = os.environ.copy() env['P...
456,529
def test_issue_8766(self): # "import encodings" emits a warning whereas the warnings is not loaded # or not completly loaded (warnings imports indirectly encodings by # importing linecache) yet old_cwd = os.getcwd() try: cwd = tempfile.mkdtemp() try: os.chdir(cwd) os.mkdir('encodings') env = os.environ.copy() env['PYTH...
def test_issue_8766(self): # "import encodings" emits a warning whereas the warnings is not loaded # or not completly loaded (warnings imports indirectly encodings by # importing linecache) yet old_cwd = os.getcwd() try: encodings = os.path.join(cwd, 'encodings') os.mkdir(encodings) try: os.chdir(cwd) os.mkdir('encodin...
456,530
def test_issue_8766(self): # "import encodings" emits a warning whereas the warnings is not loaded # or not completly loaded (warnings imports indirectly encodings by # importing linecache) yet old_cwd = os.getcwd() try: cwd = tempfile.mkdtemp() try: os.chdir(cwd) os.mkdir('encodings') env = os.environ.copy() env['PYTH...
def test_issue_8766(self): # "import encodings" emits a warning whereas the warnings is not loaded # or not completly loaded (warnings imports indirectly encodings by # importing linecache) yet old_cwd = os.getcwd() try: cwd = tempfile.mkdtemp() try: env = os.environ.copy() env['PYTHONPATH'] = cwd
456,531
def test_issue_8766(self): # "import encodings" emits a warning whereas the warnings is not loaded # or not completly loaded (warnings imports indirectly encodings by # importing linecache) yet old_cwd = os.getcwd() try: cwd = tempfile.mkdtemp() try: os.chdir(cwd) os.mkdir('encodings') env = os.environ.copy() env['PYTH...
def test_issue_8766(self): # "import encodings" emits a warning whereas the warnings is not loaded # or not completly loaded (warnings imports indirectly encodings by # importing linecache) yet old_cwd = os.getcwd() try: cwd = tempfile.mkdtemp() try: os.chdir(cwd) os.mkdir('encodings') env = os.environ.copy() env['PYTH...
456,532
def test_issue_8766(self): # "import encodings" emits a warning whereas the warnings is not loaded # or not completly loaded (warnings imports indirectly encodings by # importing linecache) yet old_cwd = os.getcwd() try: cwd = tempfile.mkdtemp() try: os.chdir(cwd) os.mkdir('encodings') env = os.environ.copy() env['PYTH...
def test_issue_8766(self): # "import encodings" emits a warning whereas the warnings is not loaded # or not completly loaded (warnings imports indirectly encodings by # importing linecache) yet old_cwd = os.getcwd() try: cwd = tempfile.mkdtemp() try: os.chdir(cwd) os.mkdir('encodings') env = os.environ.copy() env['PYTH...
456,533
def get_platform(): """Return a string that identifies the current platform. This is used mainly to distinguish platform-specific build directories and platform-specific built distributions. Typically includes the OS name and version and the architecture (as supplied by 'os.uname()'), although the exact information i...
def get_platform(): """Return a string that identifies the current platform. This is used mainly to distinguish platform-specific build directories and platform-specific built distributions. Typically includes the OS name and version and the architecture (as supplied by 'os.uname()'), although the exact information i...
456,534
def setUp(self): self.__save = dict(os.environ) self.__saveb = dict(os.environb) for key, value in self._reference().items(): os.environ[key] = value
def setUp(self): self.__save = dict(os.environ) if os.name not in ('os2', 'nt'): self.__saveb = dict(os.environb) for key, value in self._reference().items(): os.environ[key] = value
456,535
def tearDown(self): os.environ.clear() os.environ.update(self.__save) os.environb.clear() os.environb.update(self.__saveb)
def tearDown(self): os.environ.clear() os.environ.update(self.__save) os.environb.clear() os.environb.update(self.__saveb)
456,536
def http_error_auth_reqed(self, authreq, host, req, headers): # host may be an authority (without userinfo) or a URL with an # authority # XXX could be multiple headers authreq = headers.get(authreq, None)
def http_error_auth_reqed(self, authreq, host, req, headers): # host may be an authority (without userinfo) or a URL with an # authority # XXX could be multiple headers authreq = headers.get(authreq, None)
456,537
def send(self, data): try: return super(SSLConnection, self).send(data) except ssl.SSLError, err: if err.args[0] in (ssl.SSL_ERROR_EOF, ssl.SSL_ERROR_ZERO_RETURN): return 0 raise
def send(self, data): try: return super(SSLConnection, self).send(data) except ssl.SSLError, err: if err.args[0] in (ssl.SSL_ERROR_EOF, ssl.SSL_ERROR_ZERO_RETURN, ssl.SSL_ERROR_WANT_READ, ssl.SSL_ERROR_WANT_WRITE): return 0 raise
456,538
def md5sum(data): return md5(data).hexdigest()
def md5sum(data): return md5(data).hexdigest()
456,539
def escape(pattern): "Escape all non-alphanumeric characters in pattern." if isinstance(pattern, str): alphanum = _alphanum_str s = list(pattern) for i in range(len(pattern)): c = pattern[i] if c not in alphanum: if c == "\000": s[i] = "\\000" else: s[i] = "\\" + c return "".join(s) else: alphanum = _alphanum_bytes s =...
def escape(pattern): "Escape all non-alphanumeric characters in pattern." if isinstance(pattern, str): alphanum = _alphanum_str s = list(pattern) for i in range(len(pattern)): c = pattern[i] if c not in alphanum: if c == "\000": s[i] = "\\000" else: s[i] = "\\" + c return "".join(s) else: alphanum = _alphanum_bytes s =...
456,540
def escape(pattern): "Escape all non-alphanumeric characters in pattern." if isinstance(pattern, str): alphanum = _alphanum_str s = list(pattern) for i in range(len(pattern)): c = pattern[i] if c not in alphanum: if c == "\000": s[i] = "\\000" else: s[i] = "\\" + c return "".join(s) else: alphanum = _alphanum_bytes s =...
def escape(pattern): "Escape all non-alphanumeric characters in pattern." if isinstance(pattern, str): alphanum = _alphanum_str s = list(pattern) for i in range(len(pattern)): c = pattern[i] if c not in alphanum: if c == "\000": s[i] = "\\000" else: s[i] = "\\" + c return "".join(s) else: alphanum = _alphanum_bytes s =...
456,541
def _compile_typed(type, *key): # internal: compile pattern pattern, flags = key if isinstance(pattern, _pattern_type): if flags: raise ValueError( "Cannot process flags argument with a compiled pattern") return pattern if not sre_compile.isstring(pattern): raise TypeError("first argument must be string or compiled pat...
def _compile_typed(type, *key): # internal: compile pattern if isinstance(pattern, _pattern_type): if flags: raise ValueError( "Cannot process flags argument with a compiled pattern") return pattern if not sre_compile.isstring(pattern): raise TypeError("first argument must be string or compiled pattern") return sre_com...
456,542
def _compile_typed(type, *key): # internal: compile pattern pattern, flags = key if isinstance(pattern, _pattern_type): if flags: raise ValueError( "Cannot process flags argument with a compiled pattern") return pattern if not sre_compile.isstring(pattern): raise TypeError("first argument must be string or compiled pat...
def _compile_typed(type, *key): # internal: compile pattern pattern, flags = key if isinstance(pattern, _pattern_type): if flags: raise ValueError( "Cannot process flags argument with a compiled pattern") return pattern if not sre_compile.isstring(pattern): raise TypeError("first argument must be string or compiled pat...
456,543
def _compile_repl(*key): # internal: compile replacement pattern repl, pattern = key return sre_parse.parse_template(repl, pattern)
def _compile_repl(*key): # internal: compile replacement pattern return sre_parse.parse_template(repl, pattern)
456,544
def __init__(self, localaddr, remoteaddr): self._localaddr = localaddr self._remoteaddr = remoteaddr asyncore.dispatcher.__init__(self) self.create_socket(socket.AF_INET, socket.SOCK_STREAM) # try to re-use a server port if possible self.set_reuse_addr() self.bind(localaddr) self.listen(5) print >> DEBUGSTREAM, \ '%s s...
def __init__(self, localaddr, remoteaddr): self._localaddr = localaddr self._remoteaddr = remoteaddr asyncore.dispatcher.__init__(self) self.create_socket(socket.AF_INET, socket.SOCK_STREAM) # try to re-use a server port if possible self.set_reuse_addr() self.bind(localaddr) self.listen(5) print >> DEBUGSTREAM, \ '%s s...
456,545
def test_sharedctypes(self, lock=False): if c_int is None: return
def test_sharedctypes(self, lock=False): if c_int is None: return
456,546
def test_sharedctypes(self, lock=False): if c_int is None: return
def test_sharedctypes(self, lock=False): if c_int is None: return
456,547
def _init_mac(): """Initialize the module as appropriate for Macintosh systems""" 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'] ...
def _init_mac(): """Initialize the module as appropriate for Macintosh systems""" 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'] ...
456,548
def test_executable(self): # Issue #7774: Ensure that sys.executable is an empty string if argv[0] # has been set to an non existent program name and Python is unable to # retrieve the real program name import subprocess p = subprocess.Popen( ["nonexistent", "-c", 'import sys; print repr(sys.executable)'], executable=s...
def test_executable(self): # Issue #7774: Ensure that sys.executable is an empty string if argv[0] # has been set to an non existent program name and Python is unable to # retrieve the real program name import subprocess p = subprocess.Popen( ["nonexistent", "-c", 'import sys; print repr(sys.executable)'], executable=s...
456,549
def localtrace_trace_and_count(self, frame, why, arg): if why == "line": # record the file name and line number of every trace filename = frame.f_code.co_filename lineno = frame.f_lineno key = filename, lineno self.counts[key] = self.counts.get(key, 0) + 1
def localtrace_trace_and_count(self, frame, why, arg): if why == "line": # record the file name and line number of every trace filename = frame.f_code.co_filename lineno = frame.f_lineno key = filename, lineno self.counts[key] = self.counts.get(key, 0) + 1
456,550
def localtrace_trace(self, frame, why, arg): if why == "line": # record the file name and line number of every trace filename = frame.f_code.co_filename lineno = frame.f_lineno
def localtrace_trace(self, frame, why, arg): if why == "line": # record the file name and line number of every trace filename = frame.f_code.co_filename lineno = frame.f_lineno
456,551
def detect_ctypes(self, inc_dirs, lib_dirs): self.use_system_libffi = False include_dirs = [] extra_compile_args = [] extra_link_args = [] sources = ['_ctypes/_ctypes.c', '_ctypes/callbacks.c', '_ctypes/callproc.c', '_ctypes/stgdict.c', '_ctypes/cfield.c', '_ctypes/malloc_closure.c'] depends = ['_ctypes/ctypes.h']
def detect_ctypes(self, inc_dirs, lib_dirs): self.use_system_libffi = False include_dirs = [] extra_compile_args = [] extra_link_args = [] sources = ['_ctypes/_ctypes.c', '_ctypes/callbacks.c', '_ctypes/callproc.c', '_ctypes/stgdict.c', '_ctypes/cfield.c'] depends = ['_ctypes/ctypes.h']
456,552
def test_parent_help(self): parents = [self.abcd_parent, self.wxyz_parent] parser = ErrorRaisingArgumentParser(parents=parents) parser_help = parser.format_help() self.assertEqual(parser_help, textwrap.dedent('''\ usage: test_argparse.py [-h] [-b B] [--d D] [--w W] [-y Y] a z
def test_parent_help(self): parents = [self.abcd_parent, self.wxyz_parent] parser = ErrorRaisingArgumentParser(parents=parents) parser_help = parser.format_help() self.assertEqual(parser_help, textwrap.dedent('''\ usage: test_argparse.py [-h] [-b B] [--d D] [--w W] [-y Y] a z
456,553
def test_parent_help(self): parents = [self.abcd_parent, self.wxyz_parent] parser = ErrorRaisingArgumentParser(parents=parents) parser_help = parser.format_help() self.assertEqual(parser_help, textwrap.dedent('''\ usage: test_argparse.py [-h] [-b B] [--d D] [--w W] [-y Y] a z
def test_parent_help(self): parents = [self.abcd_parent, self.wxyz_parent] parser = ErrorRaisingArgumentParser(parents=parents) parser_help = parser.format_help() self.assertEqual(parser_help, textwrap.dedent('''\ usage: test_argparse.py [-h] [-b B] [--d D] [--w W] [-y Y] a z
456,554
def test_groups_parents(self): parent = ErrorRaisingArgumentParser(add_help=False) g = parent.add_argument_group(title='g', description='gd') g.add_argument('-w') g.add_argument('-x') m = parent.add_mutually_exclusive_group() m.add_argument('-y') m.add_argument('-z') parser = ErrorRaisingArgumentParser(parents=[parent]...
def test_groups_parents(self): parent = ErrorRaisingArgumentParser(add_help=False) g = parent.add_argument_group(title='g', description='gd') g.add_argument('-w') g.add_argument('-x') m = parent.add_mutually_exclusive_group() m.add_argument('-y') m.add_argument('-z') parser = ErrorRaisingArgumentParser(parents=[parent]...
456,555
def test_groups_parents(self): parent = ErrorRaisingArgumentParser(add_help=False) g = parent.add_argument_group(title='g', description='gd') g.add_argument('-w') g.add_argument('-x') m = parent.add_mutually_exclusive_group() m.add_argument('-y') m.add_argument('-z') parser = ErrorRaisingArgumentParser(parents=[parent]...
def test_groups_parents(self): parent = ErrorRaisingArgumentParser(add_help=False) g = parent.add_argument_group(title='g', description='gd') g.add_argument('-w') g.add_argument('-x') m = parent.add_mutually_exclusive_group() m.add_argument('-y') m.add_argument('-z') parser = ErrorRaisingArgumentParser(parents=[parent]...
456,556
def test_trivial(self): # A couple trivial tests
def test_trivial(self): # A couple trivial tests
456,557
def test_trivial(self): # A couple trivial tests
def test_trivial(self): # A couple trivial tests
456,558
def test_streamwriter(self): readfuncs = ('read', 'readline', 'readlines') UTF8Reader = codecs.getreader('utf-8') for name in readfuncs: for sizehint in [None] + range(1, 33) + \ [64, 128, 256, 512, 1024]: istream = UTF8Reader(StringIO(self.tstring[1])) ostream = self.writer(StringIO()) func = getattr(istream, name) wh...
def test_streamwriter(self): readfuncs = ('read', 'readline', 'readlines') UTF8Reader = codecs.getreader('utf-8') for name in readfuncs: for sizehint in [None] + range(1, 33) + \ [64, 128, 256, 512, 1024]: istream = UTF8Reader(StringIO(self.tstring[1])) ostream = self.writer(StringIO()) func = getattr(istream, name) wh...
456,559
def _test_mapping_file_plain(self): unichrs = lambda s: u''.join(map(unichr, map(eval, s.split('+')))) urt_wa = {}
def _test_mapping_file_plain(self): _unichr = lambda c: eval("u'\\U%08x'" % int(c, 16)) unichrs = lambda s: u''.join(_unichr(c) for c in s.split('+')) urt_wa = {}
456,560
def _test_mapping_file_plain(self): unichrs = lambda s: u''.join(map(unichr, map(eval, s.split('+')))) urt_wa = {}
def _test_mapping_file_plain(self): unichrs = lambda s: u''.join(map(unichr, map(eval, s.split('+')))) urt_wa = {}
456,561
def test_tag_configure(self): # Just testing parameter passing for now self.assertRaises(TypeError, self.tv.tag_configure) self.assertRaises(Tkinter.TclError, self.tv.tag_configure, 'test', sky='blue') self.tv.tag_configure('test', foreground='blue') self.assertEqual(self.tv.tag_configure('test', 'foreground'), 'blue')...
def test_tag_configure(self): # Just testing parameter passing for now self.assertRaises(TypeError, self.tv.tag_configure) self.assertRaises(Tkinter.TclError, self.tv.tag_configure, 'test', sky='blue') self.tv.tag_configure('test', foreground='blue') self.assertEqual(str(self.tv.tag_configure('test', 'foreground')), 'b...
456,562
def test_tag_configure(self): # Just testing parameter passing for now self.assertRaises(TypeError, self.tv.tag_configure) self.assertRaises(Tkinter.TclError, self.tv.tag_configure, 'test', sky='blue') self.tv.tag_configure('test', foreground='blue') self.assertEqual(self.tv.tag_configure('test', 'foreground'), 'blue')...
def test_tag_configure(self): # Just testing parameter passing for now self.assertRaises(TypeError, self.tv.tag_configure) self.assertRaises(Tkinter.TclError, self.tv.tag_configure, 'test', sky='blue') self.tv.tag_configure('test', foreground='blue') self.assertEqual(self.tv.tag_configure('test', 'foreground'), 'blue')...
456,563
def test01_basic(self): d = db.DB()
def test01_basic(self): d = db.DB()
456,564
def test01_basic(self): d = db.DB()
def test01_basic(self): d = db.DB()
456,565
def test01_basic(self): d = db.DB()
def test01_basic(self): d = db.DB()
456,566
def test01_basic(self): d = db.DB()
def test01_basic(self): d = db.DB()
456,567
def test01_basic(self): d = db.DB()
def test01_basic(self): d = db.DB()
456,568
def parsecodes(codes, len=len, range=range): """ Converts code combinations to either a single code integer or a tuple of integers. meta-codes (in angular brackets, e.g. <LR> and <RL>) are ignored. Empty codes or illegal ones are returned as None. """ if not codes: return None l = codes.split('+') if len(l) == 1: r...
def parsecodes(codes, len=len, range=range): """ Converts code combinations to either a single code integer or a tuple of integers. meta-codes (in angular brackets, e.g. <LR> and <RL>) are ignored. Empty codes or illegal ones are returned as None. """ if not codes: return MISSING_CODE l = codes.split('+') if len(l)...
456,569
def parsecodes(codes, len=len, range=range): """ Converts code combinations to either a single code integer or a tuple of integers. meta-codes (in angular brackets, e.g. <LR> and <RL>) are ignored. Empty codes or illegal ones are returned as None. """ if not codes: return None l = codes.split('+') if len(l) == 1: r...
def parsecodes(codes, len=len, range=range): """ Converts code combinations to either a single code integer or a tuple of integers. meta-codes (in angular brackets, e.g. <LR> and <RL>) are ignored. Empty codes or illegal ones are returned as None. """ if not codes: return None l = codes.split('+') if len(l) == 1: r...
456,570
def readmap(filename): f = open(filename,'r') lines = f.readlines() f.close() enc2uni = {} identity = [] unmapped = list(range(256)) # UTC mapping tables per convention don't include the identity # mappings for code points 0x00 - 0x1F and 0x7F, unless these are # explicitly mapped to different characters or undefined...
def readmap(filename): f = open(filename,'r') lines = f.readlines() f.close() enc2uni = {} identity = [] unmapped = list(range(256)) # UTC mapping tables per convention don't include the identity # mappings for code points 0x00 - 0x1F and 0x7F, unless these are # explicitly mapped to different characters or undefined...
456,571
def python_tabledef_code(varname, map, comments=1, key_precision=2): l = [] append = l.append append('%s = (' % varname) # Analyze map and create table dict mappings = sorted(map.items()) table = {} maxkey = 0 if 'IDENTITY' in map: for key in range(256): table[key] = (key, '') maxkey = 255 del map['IDENTITY'] for map...
def python_tabledef_code(varname, map, comments=1, key_precision=2): l = [] append = l.append append('%s = (' % varname) # Analyze map and create table dict mappings = sorted(map.items()) table = {} maxkey = 0 if 'IDENTITY' in map: for key in range(256): table[key] = (key, '') maxkey = 255 del map['IDENTITY'] for map...
456,572
def python_tabledef_code(varname, map, comments=1, key_precision=2): l = [] append = l.append append('%s = (' % varname) # Analyze map and create table dict mappings = sorted(map.items()) table = {} maxkey = 0 if 'IDENTITY' in map: for key in range(256): table[key] = (key, '') maxkey = 255 del map['IDENTITY'] for map...
def python_tabledef_code(varname, map, comments=1, key_precision=2): l = [] append = l.append append('%s = (' % varname) # Analyze map and create table dict mappings = sorted(map.items()) table = {} maxkey = 0 if 'IDENTITY' in map: for key in range(256): table[key] = (key, '') maxkey = 255 del map['IDENTITY'] for map...
456,573
def python_tabledef_code(varname, map, comments=1, key_precision=2): l = [] append = l.append append('%s = (' % varname) # Analyze map and create table dict mappings = sorted(map.items()) table = {} maxkey = 0 if 'IDENTITY' in map: for key in range(256): table[key] = (key, '') maxkey = 255 del map['IDENTITY'] for map...
def python_tabledef_code(varname, map, comments=1, key_precision=2): l = [] append = l.append append('%s = (' % varname) # Analyze map and create table dict mappings = sorted(map.items()) table = {} maxkey = 0 if 'IDENTITY' in map: for key in range(256): table[key] = (key, '') maxkey = 255 del map['IDENTITY'] for map...
456,574
def assertCountEqual(self, actual_seq, expected_seq, msg=None): """An unordered sequence specific comparison. It asserts that actual_seq and expected_seq have the same element counts. Equivalent to::
def assertCountEqual(self, actual, expected, msg=None): """An unordered sequence specific comparison. It asserts that actual_seq and expected_seq have the same element counts. Equivalent to::
456,575
def assertCountEqual(self, actual_seq, expected_seq, msg=None): """An unordered sequence specific comparison. It asserts that actual_seq and expected_seq have the same element counts. Equivalent to::
def assertCountEqual(self, actual_seq, expected_seq, msg=None): """An unordered sequence specific comparison. It asserts that actual_seq and expected_seq have the same element counts. Equivalent to::
456,576
def assertCountEqual(self, actual_seq, expected_seq, msg=None): """An unordered sequence specific comparison. It asserts that actual_seq and expected_seq have the same element counts. Equivalent to::
def assertCountEqual(self, actual_seq, expected_seq, msg=None): """An unordered sequence specific comparison. It asserts that actual_seq and expected_seq have the same element counts. Equivalent to::
456,577
def assertCountEqual(self, actual_seq, expected_seq, msg=None): """An unordered sequence specific comparison. It asserts that actual_seq and expected_seq have the same element counts. Equivalent to::
def assertCountEqual(self, actual_seq, expected_seq, msg=None): """An unordered sequence specific comparison. It asserts that actual_seq and expected_seq have the same element counts. Equivalent to::
456,578
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,579
def checking_metadata(self): """Callable used for the check sub-command.
def checking_metadata(self): """Callable used for the check sub-command.
456,580
def test_update2(self): os.environ.clear() if os.path.exists("/bin/sh"): os.environ.update(HELLO="World") value = os.popen("/bin/sh -c 'echo $HELLO'").read().strip() self.assertEquals(value, "World")
def test_update2(self): os.environ.clear() if os.path.exists("/bin/sh"): os.environ.update(HELLO="World") value = os.popen("/bin/sh -c 'echo $HELLO'").read().strip() self.assertEquals(value, "World")
456,581
def test_os_popen_iter(self): if os.path.exists("/bin/sh"): popen = os.popen("/bin/sh -c 'echo \"line1\nline2\nline3\"'") it = iter(popen) self.assertEquals(next(it), "line1\n") self.assertEquals(next(it), "line2\n") self.assertEquals(next(it), "line3\n") self.assertRaises(StopIteration, next, it)
def test_os_popen_iter(self): if os.path.exists("/bin/sh"): popen = os.popen("/bin/sh -c 'echo \"line1\nline2\nline3\"'") it = iter(popen) self.assertEquals(next(it), "line1\n") self.assertEquals(next(it), "line2\n") self.assertEquals(next(it), "line3\n") self.assertRaises(StopIteration, next, it)
456,582
def test(): import sys if not sys.argv[3:]: print('usage: python makeconfig.py config.c.in outputfile', end=' ') print('modulename ...') sys.exit(2) if sys.argv[1] == '-': infp = sys.stdin else: infp = open(sys.argv[1]) if sys.argv[2] == '-': outfp = sys.stdout else: outfp = open(sys.argv[2], 'w') makeconfig(infp, outf...
def test(): if not sys.argv[3:]: print('usage: python makeconfig.py config.c.in outputfile', end=' ') print('modulename ...') sys.exit(2) if sys.argv[1] == '-': infp = sys.stdin else: infp = open(sys.argv[1]) if sys.argv[2] == '-': outfp = sys.stdout else: outfp = open(sys.argv[2], 'w') makeconfig(infp, outfp, sys.argv...
456,583
def module_funcs(stdscr): "Test module-level functions" for func in [curses.baudrate, curses.beep, curses.can_change_color, curses.cbreak, curses.def_prog_mode, curses.doupdate, curses.filter, curses.flash, curses.flushinp, curses.has_colors, curses.has_ic, curses.has_il, curses.isendwin, curses.killchar, curses.longn...
def module_funcs(stdscr): "Test module-level functions" for func in [curses.baudrate, curses.beep, curses.can_change_color, curses.cbreak, curses.def_prog_mode, curses.doupdate, curses.filter, curses.flash, curses.flushinp, curses.has_colors, curses.has_ic, curses.has_il, curses.isendwin, curses.killchar, curses.longn...
456,584
def dis(x=None): """Disassemble classes, methods, functions, or code. With no argument, disassemble the last traceback. """ if x is None: distb() return if isinstance(x, types.InstanceType): x = x.__class__ if hasattr(x, 'im_func'): x = x.im_func if hasattr(x, 'func_code'): x = x.func_code if hasattr(x, '__dict__'): ...
def dis(x=None): """Disassemble classes, methods, functions, or code. With no argument, disassemble the last traceback. """ if x is None: distb() return if isinstance(x, types.InstanceType): x = x.__class__ if hasattr(x, 'im_func'): x = x.im_func if hasattr(x, 'func_code'): x = x.func_code if hasattr(x, '__dict__'): ...
456,585
def main(argv=sys.argv): rv = 0 for filename in argv[1:]: try: with open(filename, 'rb') as f: lines = f.readlines() new_lines = [ws_re.sub(r'\1', line) for line in lines] if new_lines != lines: print('Fixing %s...' % filename) shutil.copyfile(filename, filename + '.bak') with open(filename, 'wb') as f: f.writelines(ne...
def main(argv=sys.argv): rv = 0 for filename in argv[1:]: try: with open(filename, 'rb') as f: lines = f.readlines() new_lines = [ws_re.sub(br'\1', line) for line in lines] if new_lines != lines: print('Fixing %s...' % filename) shutil.copyfile(filename, filename + '.bak') with open(filename, 'wb') as f: f.writelines(n...
456,586
def view_file(parent, title, filename, encoding=None): try: if encoding: import codecs textFile = codecs.open(filename, 'r') else: textFile = open(filename, 'r') except IOError: import tkinter.messagebox as tkMessageBox tkMessageBox.showerror(title='File Load Error', message='Unable to load file %r .' % filename, paren...
def view_file(parent, title, filename, encoding=None): try: textFile = open(filename, 'r', encoding=encoding) except IOError: import tkinter.messagebox as tkMessageBox tkMessageBox.showerror(title='File Load Error', message='Unable to load file %r .' % filename, parent=parent) else: return view_text(parent, title, text...
456,587
def test_python_builders(self): # Get the list of builders from the XMLRPC buildbot interface at # python.org. server = xmlrpclib.ServerProxy("http://www.python.org/dev/buildbot/all/xmlrpc/") try: builders = server.getAllBuilders() except socket.error as e: self.skipTest("network error: %s" % e) return
def test_python_builders(self): # Get the list of builders from the XMLRPC buildbot interface at # python.org. server = xmlrpclib.ServerProxy("http://www.python.org/dev/buildbot/all/xmlrpc/") try: builders = server.getAllBuilders() except socket.error as e: self.skipTest("network error: %s" % e) return
456,588
def recv_into(self, buffer, nbytes=None, flags=0): self._checkClosed() if buffer and (nbytes is None): nbytes = len(buffer) elif nbytes is None: nbytes = 1024 if self._sslobj: if flags != 0: raise ValueError( "non-zero flags not allowed in calls to recv_into() on %s" % self.__class__) while True: try: v = self.read(nby...
def recv_into(self, buffer, nbytes=None, flags=0): self._checkClosed() if buffer and (nbytes is None): nbytes = len(buffer) elif nbytes is None: nbytes = 1024 if self._sslobj: if flags != 0: raise ValueError( "non-zero flags not allowed in calls to recv_into() on %s" % self.__class__) return self.read(nbytes, buffer) e...
456,589
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,590
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,591
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,592
def roundtrip(filename, output=sys.stdout): source = open(filename).read() tree = compile(source, filename, "exec", _ast.PyCF_ONLY_AST) Unparser(tree, output)
def roundtrip(filename, output=sys.stdout): source = open(filename).read() tree = compile(source, filename, "exec", ast.PyCF_ONLY_AST) Unparser(tree, output)
456,593
def test_property_decorator_doc(self): base = PropertyDocBase() sub = PropertyDocSub() self.assertEqual(base.__class__.spam.__doc__, "spam spam spam") self.assertEqual(sub.__class__.spam.__doc__, "spam spam spam")
def test_property_decorator_doc(self): base = PropertyDocBase() sub = PropertyDocSub() self.assertEqual(base.__class__.spam.__doc__, "spam spam spam") self.assertEqual(sub.__class__.spam.__doc__, "spam spam spam")
456,594
def test_pdb_set_trace(): """Using pdb.set_trace from a doctest. You can use pdb.set_trace from a doctest. To do so, you must retrieve the set_trace function from the pdb module at the time you use it. The doctest module changes sys.stdout so that it can capture program output. It also temporarily replaces pdb.set_...
def test_pdb_set_trace(): """Using pdb.set_trace from a doctest. You can use pdb.set_trace from a doctest. To do so, you must retrieve the set_trace function from the pdb module at the time you use it. The doctest module changes sys.stdout so that it can capture program output. It also temporarily replaces pdb.set_...
456,595
def test_pdb_set_trace(): """Using pdb.set_trace from a doctest. You can use pdb.set_trace from a doctest. To do so, you must retrieve the set_trace function from the pdb module at the time you use it. The doctest module changes sys.stdout so that it can capture program output. It also temporarily replaces pdb.set_...
def test_pdb_set_trace(): """Using pdb.set_trace from a doctest. You can use pdb.set_trace from a doctest. To do so, you must retrieve the set_trace function from the pdb module at the time you use it. The doctest module changes sys.stdout so that it can capture program output. It also temporarily replaces pdb.set_...
456,596
def basic_test_repr(self, size): t = (0,) * size s = repr(t) # The repr of a tuple of 0's is exactly three times the tuple length. self.assertEquals(len(s), size * 3) self.assertEquals(s[:5], '(0, 0') self.assertEquals(s[-5:], '0, 0)') self.assertEquals(s.count('0'), size)
def basic_test_repr(self, size): t = (0,) * size s = repr(t) # The repr of a tuple of 0's is exactly three times the tuple length. self.assertEquals(len(s), size * 3) self.assertEquals(s[:5], '(0, 0') self.assertEquals(s[-5:], '0, 0)') self.assertEquals(s.count('0'), size)
456,597
def test_repr_small(self, size): return self.basic_test_repr(size)
def test_repr_small(self, size): return self.basic_test_repr(size)
456,598
def basic_test_repr(self, size): l = [0] * size s = repr(l) # The repr of a list of 0's is exactly three times the list length. self.assertEquals(len(s), size * 3) self.assertEquals(s[:5], '[0, 0') self.assertEquals(s[-5:], '0, 0]') self.assertEquals(s.count('0'), size)
def basic_test_repr(self, size): l = [0] * size s = repr(l) # The repr of a list of 0's is exactly three times the list length. self.assertEquals(len(s), size * 3) self.assertEquals(s[:5], '[0, 0') self.assertEquals(s[-5:], '0, 0]') self.assertEquals(s.count('0'), size)
456,599