bugged
stringlengths
4
228k
fixed
stringlengths
0
96.3M
__index_level_0__
int64
0
481k
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,600
def close(self): ssl_want_read_or_write = False try: if isinstance(self.socket, ssl.SSLSocket): if self.socket._sslobj is not None: try: self.socket.unwrap() except ssl.SSLError, err: if err.args[0] in (ssl.SSL_ERROR_WANT_READ, ssl.SSL_ERROR_WANT_WRITE): ssl_want_read_or_write = True else: raise finally: if not ssl_wan...
def close(self): try: if isinstance(self.socket, ssl.SSLSocket): if self.socket._sslobj is not None: try: self.socket.unwrap() except ssl.SSLError, err: if err.args[0] in (ssl.SSL_ERROR_WANT_READ, ssl.SSL_ERROR_WANT_WRITE): ssl_want_read_or_write = True else: raise finally: if not ssl_want_read_or_write: super(SSLConne...
456,601
def close(self): ssl_want_read_or_write = False try: if isinstance(self.socket, ssl.SSLSocket): if self.socket._sslobj is not None: try: self.socket.unwrap() except ssl.SSLError, err: if err.args[0] in (ssl.SSL_ERROR_WANT_READ, ssl.SSL_ERROR_WANT_WRITE): ssl_want_read_or_write = True else: raise finally: if not ssl_wan...
def close(self): ssl_want_read_or_write = False try: if isinstance(self.socket, ssl.SSLSocket): if self.socket._sslobj is not None: self.socket.unwrap() finally: if not ssl_want_read_or_write: super(SSLConnection, self).close()
456,602
def close(self): ssl_want_read_or_write = False try: if isinstance(self.socket, ssl.SSLSocket): if self.socket._sslobj is not None: try: self.socket.unwrap() except ssl.SSLError, err: if err.args[0] in (ssl.SSL_ERROR_WANT_READ, ssl.SSL_ERROR_WANT_WRITE): ssl_want_read_or_write = True else: raise finally: if not ssl_wan...
def close(self): ssl_want_read_or_write = False try: if isinstance(self.socket, ssl.SSLSocket): if self.socket._sslobj is not None: try: self.socket.unwrap() except ssl.SSLError, err: if err.args[0] in (ssl.SSL_ERROR_WANT_READ, ssl.SSL_ERROR_WANT_WRITE): ssl_want_read_or_write = True else: raise finally: if not ssl_wan...
456,603
def test_alias_asterisk(self): if not has_sound("SystemAsterisk"): print "No default SystemAsterisk" return if _have_soundcard(): winsound.PlaySound('SystemAsterisk', winsound.SND_ALIAS) else: self.assertRaises( RuntimeError, winsound.PlaySound, 'SystemAsterisk', winsound.SND_ALIAS )
def test_alias_asterisk(self): if not has_sound("SystemAsterisk"): return if _have_soundcard(): winsound.PlaySound('SystemAsterisk', winsound.SND_ALIAS) else: self.assertRaises( RuntimeError, winsound.PlaySound, 'SystemAsterisk', winsound.SND_ALIAS )
456,604
def test_alias_exclamation(self): if not has_sound("SystemExclamation"): print "No default SystemExclamation" return if _have_soundcard(): winsound.PlaySound('SystemExclamation', winsound.SND_ALIAS) else: self.assertRaises( RuntimeError, winsound.PlaySound, 'SystemExclamation', winsound.SND_ALIAS )
def test_alias_exclamation(self): if not has_sound("SystemExclamation"): return if _have_soundcard(): winsound.PlaySound('SystemExclamation', winsound.SND_ALIAS) else: self.assertRaises( RuntimeError, winsound.PlaySound, 'SystemExclamation', winsound.SND_ALIAS )
456,605
def test_alias_exit(self): if not has_sound("SystemExit"): print "No default SystemExit" return if _have_soundcard(): winsound.PlaySound('SystemExit', winsound.SND_ALIAS) else: self.assertRaises( RuntimeError, winsound.PlaySound, 'SystemExit', winsound.SND_ALIAS )
def test_alias_exit(self): if not has_sound("SystemExit"): return if _have_soundcard(): winsound.PlaySound('SystemExit', winsound.SND_ALIAS) else: self.assertRaises( RuntimeError, winsound.PlaySound, 'SystemExit', winsound.SND_ALIAS )
456,606
def test_alias_hand(self): if not has_sound("SystemHand"): print "No default SystemHand" return if _have_soundcard(): winsound.PlaySound('SystemHand', winsound.SND_ALIAS) else: self.assertRaises( RuntimeError, winsound.PlaySound, 'SystemHand', winsound.SND_ALIAS )
def test_alias_hand(self): if not has_sound("SystemHand"): return if _have_soundcard(): winsound.PlaySound('SystemHand', winsound.SND_ALIAS) else: self.assertRaises( RuntimeError, winsound.PlaySound, 'SystemHand', winsound.SND_ALIAS )
456,607
def test_alias_question(self): if not has_sound("SystemQuestion"): print "No default SystemQuestion" return if _have_soundcard(): winsound.PlaySound('SystemQuestion', winsound.SND_ALIAS) else: self.assertRaises( RuntimeError, winsound.PlaySound, 'SystemQuestion', winsound.SND_ALIAS )
def test_alias_question(self): if not has_sound("SystemQuestion"): return if _have_soundcard(): winsound.PlaySound('SystemQuestion', winsound.SND_ALIAS) else: self.assertRaises( RuntimeError, winsound.PlaySound, 'SystemQuestion', winsound.SND_ALIAS )
456,608
def _connect_unixsocket(self, address): self.socket = socket.socket(socket.AF_UNIX, socket.SOCK_DGRAM) # syslog may require either DGRAM or STREAM sockets try: self.socket.connect(address) except socket.error: self.socket.close() self.socket = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) self.socket.connect(addres...
def _connect_unixsocket(self, address): self.socket = socket.socket(socket.AF_UNIX, socket.SOCK_DGRAM) # syslog may require either DGRAM or STREAM sockets try: self.socket.connect(address) except socket.error: self.socket.close() self.socket = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) self.socket.connect(addres...
456,609
def emit(self, record): """ Emit a record.
def emit(self, record): """ Emit a record.
456,610
def _EndRecData64(fpin, offset, endrec): """ Read the ZIP64 end-of-archive records and use that to update endrec """ try: fpin.seek(offset - sizeEndCentDir64Locator, 2) except IOError: # If the seek fails, the file is not large enough to contain a ZIP64 # end-of-archive record, so just return the end record we were giv...
def _EndRecData64(fpin, offset, endrec): """ Read the ZIP64 end-of-archive records and use that to update endrec """ try: fpin.seek(offset - sizeEndCentDir64Locator, 2) except IOError: # If the seek fails, the file is not large enough to contain a ZIP64 # end-of-archive record, so just return the end record we were giv...
456,611
def _kill(self, sig): # Start sys.executable as a subprocess and communicate from the # subprocess to the parent that the interpreter is ready. When it # becomes ready, send *sig* via os.kill to the subprocess and check # that the return code is equal to *sig*. import ctypes from ctypes import wintypes import msvcrt
def _kill(self, sig): # Start sys.executable as a subprocess and communicate from the # subprocess to the parent that the interpreter is ready. When it # becomes ready, send *sig* via os.kill to the subprocess and check # that the return code is equal to *sig*. import ctypes from ctypes import wintypes import msvcrt
456,612
def test_cw_strings(self): from ctypes import byref, sizeof try: from ctypes import c_wchar, c_wchar_p except ImportError:
def test_cw_strings(self): from ctypes import byref try: from ctypes import c_wchar, c_wchar_p except ImportError:
456,613
def test_cw_strings(self): from ctypes import byref, sizeof try: from ctypes import c_wchar, c_wchar_p except ImportError:
def test_cw_strings(self): from ctypes import byref, sizeof try: from ctypes import c_wchar_p except ImportError:
456,614
def test_cw_strings(self): from ctypes import byref, sizeof try: from ctypes import c_wchar, c_wchar_p except ImportError:
def test_cw_strings(self): from ctypes import byref, sizeof try: from ctypes import c_wchar, c_wchar_p except ImportError:
456,615
def poll(self, flag=os.WNOHANG): if self.returncode is None: pid, sts = os.waitpid(self.pid, flag) if pid == self.pid: if os.WIFSIGNALED(sts): self.returncode = -os.WTERMSIG(sts) else: assert os.WIFEXITED(sts) self.returncode = os.WEXITSTATUS(sts) return self.returncode
def poll(self, flag=os.WNOHANG): if self.returncode is None: try: pid, sts = os.waitpid(self.pid, flag) except os.error: return None if pid == self.pid: if os.WIFSIGNALED(sts): self.returncode = -os.WTERMSIG(sts) else: assert os.WIFEXITED(sts) self.returncode = os.WEXITSTATUS(sts) return self.returncode
456,616
def set_data(self, path, data): """Write bytes data to a file.""" parent, _, filename = path.rpartition(path_sep) path_parts = [] # Figure out what directories are missing. while parent and not _path_isdir(parent): parent, _, part = parent.rpartition(path_sep) path_parts.append(part) # Create needed directories. for pa...
def set_data(self, path, data): """Write bytes data to a file.""" parent, _, filename = path.rpartition(path_sep) path_parts = [] # Figure out what directories are missing. while parent and not _path_isdir(parent): parent, _, part = parent.rpartition(path_sep) path_parts.append(part) # Create needed directories. for pa...
456,617
def test_single(self): self.writerAssertEqual([['abc']], 'abc\r\n')
def test_single_writer(self): self.writerAssertEqual([['abc']], 'abc\r\n')
456,618
def test_simple(self): self.writerAssertEqual([[1, 2, 'abc', 3, 4]], '1,2,abc,3,4\r\n')
def test_simple_writer(self): self.writerAssertEqual([[1, 2, 'abc', 3, 4]], '1,2,abc,3,4\r\n')
456,619
def _default_mime_types(): global suffix_map global encodings_map global types_map global common_types suffix_map = { '.svgz': '.svg.gz', '.tgz': '.tar.gz', '.taz': '.tar.gz', '.tz': '.tar.gz', '.tbz2': '.tar.bz2', } encodings_map = { '.gz': 'gzip', '.Z': 'compress', '.bz2': 'bzip2', } # Before adding new types, mak...
def _default_mime_types(): global suffix_map global encodings_map global types_map global common_types suffix_map = { '.svgz': '.svg.gz', '.tgz': '.tar.gz', '.taz': '.tar.gz', '.tz': '.tar.gz', '.tbz2': '.tar.bz2', } encodings_map = { '.gz': 'gzip', '.Z': 'compress', '.bz2': 'bzip2', } # Before adding new types, mak...
456,620
def mt_interact(self): """Multithreaded version of interact().""" import _thread _thread.start_new_thread(self.listener, ()) while 1: line = sys.stdin.readline() if not line: break self.write(line)
def mt_interact(self): """Multithreaded version of interact().""" import _thread _thread.start_new_thread(self.listener, ()) while 1: line = sys.stdin.readline() if not line: break self.write(line)
456,621
def listener(self): """Helper for mt_interact() -- this executes in the other thread.""" while 1: try: data = self.read_eager() except EOFError: print('*** Connection closed by remote host ***') return if data: sys.stdout.write(data) else: sys.stdout.flush()
def listener(self): """Helper for mt_interact() -- this executes in the other thread.""" while 1: try: data = self.read_eager() except EOFError: print('*** Connection closed by remote host ***') return if data: sys.stdout.write(data.decode('ascii')) else: sys.stdout.flush()
456,622
def b32decode(s, casefold=False, map01=None): """Decode a Base32 encoded byte string. s is the byte string to decode. Optional casefold is a flag specifying whether a lowercase alphabet is acceptable as input. For security purposes, the default is False. RFC 3548 allows for optional mapping of the digit 0 (zero) to ...
def b32decode(s, casefold=False, map01=None): """Decode a Base32 encoded byte string. s is the byte string to decode. Optional casefold is a flag specifying whether a lowercase alphabet is acceptable as input. For security purposes, the default is False. RFC 3548 allows for optional mapping of the digit 0 (zero) to ...
456,623
def samefile(f1, f2): "Test whether two pathnames reference the same actual file" try: from nt import _getfinalpathname return _getfinalpathname(f1) == _getfinalpathname(f2) except (NotImplementedError, ImportError): # On Windows XP and earlier, two files are the same if their # absolute pathnames are the same. # Also...
def samefile(f1, f2): "Test whether two pathnames reference the same actual file" try: from nt import _getfinalpathname return _getfinalpathname(f1) == _getfinalpathname(f2) except (NotImplementedError, ImportError): # On Windows XP and earlier, two files are the same if their # absolute pathnames are the same. # Also...
456,624
def check_exit_message(code, expected): process = subprocess.Popen([sys.executable, "-c", code], stderr=subprocess.PIPE) stdout, stderr = process.communicate() self.assertEqual(process.returncode, 1) self.assertTrue(stderr.startswith(expected), "%r doesn't start with %r" % (stderr, expected))
def check_exit_message(code, expected): process = subprocess.Popen([sys.executable, "-c", code], stderr=subprocess.PIPE) stdout, stderr = process.communicate() self.assertEqual(process.returncode, 1) self.assertTrue(stderr.startswith(expected), "%r doesn't start with %r" % (stderr, expected))
456,625
def test_main_invalid_unicode(self): import locale non_decodable = b"\xff" encoding = locale.getpreferredencoding() try: non_decodable.decode(encoding) except UnicodeDecodeError: pass else: self.skipTest('%r is decodable with encoding %s' % (non_decodable, encoding)) code = b'print("' + non_decodable + b'")' p = subpro...
def test_main_invalid_unicode(self): import locale non_decodable = b"\xff" encoding = locale.getpreferredencoding() try: non_decodable.decode(encoding) except UnicodeDecodeError: pass else: self.skipTest('%r is decodable with encoding %s' % (non_decodable, encoding)) code = b'print("' + non_decodable + b'")' p = subpro...
456,626
def mac_ver(release='',versioninfo=('','',''),machine=''): """ Get MacOS version information and return it as tuple (release, versioninfo, machine) with versioninfo being a tuple (version, dev_stage, non_release_version). Entries which cannot be determined are set to the paramter values which default to ''. All tuple...
def mac_ver(release='',versioninfo=('','',''),machine=''): """ Get MacOS version information and return it as tuple (release, versioninfo, machine) with versioninfo being a tuple (version, dev_stage, non_release_version). Entries which cannot be determined are set to the paramter values which default to ''. All tuple...
456,627
def mac_ver(release='',versioninfo=('','',''),machine=''): """ Get MacOS version information and return it as tuple (release, versioninfo, machine) with versioninfo being a tuple (version, dev_stage, non_release_version). Entries which cannot be determined are set to the paramter values which default to ''. All tuple...
def mac_ver(release='',versioninfo=('','',''),machine=''): """ Get MacOS version information and return it as tuple (release, versioninfo, machine) with versioninfo being a tuple (version, dev_stage, non_release_version). Entries which cannot be determined are set to the paramter values which default to ''. All tuple...
456,628
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,629
def __pow__(self, other, modulo=None, context=None): """Return self ** other [ % modulo].
def __pow__(self, other, modulo=None, context=None): """Return self ** other [ % modulo].
456,630
def test_deep_copy(self): dup = copy.deepcopy(self.set) ##print type(dup), repr(dup) dup_list = list(dup); dup_list.sort() set_list = list(self.set); set_list.sort() self.assertEqual(len(dup_list), len(set_list)) for i in range(len(dup_list)): self.assertEqual(dup_list[i], set_list[i])
def test_deep_copy(self): dup = copy.deepcopy(self.set) ##print type(dup), repr(dup) with test_support.check_warnings(): dup_list = sorted(dup) set_list = sorted(self.set) self.assertEqual(len(dup_list), len(set_list)) for i in range(len(dup_list)): self.assertEqual(dup_list[i], set_list[i])
456,631
def pkg_recipes(): result = [ dict( name="PythonFramework", long_name="Python Framework", source="/Library/Frameworks/Python.framework", readme="""\ This package installs Python.framework, that is the python interpreter and the standard library. This also includes Python wrappers for lots of Mac OS X API's. """, postfl...
def pkg_recipes(): result = [ dict( name="PythonFramework", long_name="Python Framework", source="/Library/Frameworks/Python.framework", readme="""\ This package installs Python.framework, that is the python interpreter and the standard library. This also includes Python wrappers for lots of Mac OS X API's. """, postfl...
456,632
def _parse_makefile(filename, vars=None): """Parse a Makefile-style file. A dictionary containing name/value pairs is returned. If an optional dictionary is passed in as the second argument, it is used instead of a new dictionary. """ import re # Regexes needed for parsing Makefile (and similar syntaxes, # like old-s...
def _parse_makefile(filename, vars=None): """Parse a Makefile-style file. A dictionary containing name/value pairs is returned. If an optional dictionary is passed in as the second argument, it is used instead of a new dictionary. """ import re # Regexes needed for parsing Makefile (and similar syntaxes, # like old-s...
456,633
def test_getstatus(self): # This pattern should match 'ls -ld /.' on any posix # system, however perversely configured. Even on systems # (e.g., Cygwin) where user and group names can have spaces: # drwxr-xr-x 15 Administ Domain U 4096 Aug 12 12:50 / # drwxr-xr-x 15 Joe User My Group 4096 Aug 12 12...
def test_getstatus(self): # This pattern should match 'ls -ld /.' on any posix # system, however perversely configured. Even on systems # (e.g., Cygwin) where user and group names can have spaces: # drwxr-xr-x 15 Administ Domain U 4096 Aug 12 12:50 / # drwxr-xr-x 15 Joe User My Group 4096 Aug 12 12...
456,634
def test_uname_win32_ARCHITEW6432(self): # Issue 7860: make sure we get architecture from the correct variable # on 64 bit Windows: if PROCESSOR_ARCHITEW6432 exists we should be # using it, per # http://blogs.msdn.com/david.wang/archive/2006/03/26/HOWTO-Detect-Process-Bitness.aspx try: with test_support.EnvironmentVarG...
def test_uname_win32_ARCHITEW6432(self): # Issue 7860: make sure we get architecture from the correct variable # on 64 bit Windows: if PROCESSOR_ARCHITEW6432 exists we should be # using it, per # http://blogs.msdn.com/david.wang/archive/2006/03/26/HOWTO-Detect-Process-Bitness.aspx try: with support.EnvironmentVarGuard(...
456,635
def gen_db_minor_ver_nums(major): if major == 4: for x in range(max_db_ver[1]+1): if allow_db_ver((4, x)): yield x elif major == 3: for x in (3,): if allow_db_ver((3, x)): yield x else: raise ValueError("unknown major BerkeleyDB version", major)
def gen_db_minor_ver_nums(major): if major == 4: for x in range(max_db_ver[1]+1): if allow_db_ver((4, x)): yield x elif major == 3: for x in (3,): if allow_db_ver((3, x)): yield x else: raise ValueError("unknown major BerkeleyDB version", major)
456,636
def configure_ctypes(self, ext): if not self.use_system_libffi: if sys.platform == 'darwin': return self.configure_ctypes_darwin(ext)
def configure_ctypes(self, ext): if not self.use_system_libffi: if sys.platform == 'darwin': return self.configure_ctypes_darwin(ext)
456,637
def configure_ctypes(self, ext): if not self.use_system_libffi: if sys.platform == 'darwin': return self.configure_ctypes_darwin(ext)
def configure_ctypes(self, ext): if not self.use_system_libffi: if sys.platform == 'darwin': return self.configure_ctypes_darwin(ext)
456,638
def configure_ctypes(self, ext): if not self.use_system_libffi: if sys.platform == 'darwin': return self.configure_ctypes_darwin(ext)
def configure_ctypes(self, ext): if not self.use_system_libffi: if sys.platform == 'darwin': return self.configure_ctypes_darwin(ext)
456,639
def test_abspath_issue3426(self): # Check that abspath returns unicode when the arg is unicode # with both ASCII and non-ASCII cwds. abspath = self.pathmodule.abspath for path in ('', 'fuu', 'f\xf9\xf9', '/fuu', 'U:\\'): self.assertIsInstance(abspath(path), str)
def test_abspath_issue3426(self): # Check that abspath returns unicode when the arg is unicode # with both ASCII and non-ASCII cwds. abspath = self.pathmodule.abspath for path in ('', 'fuu', 'f\xf9\xf9', '/fuu', 'U:\\'): self.assertIsInstance(abspath(path), str)
456,640
def __init__(self, master=None, **kw): self.frame = Frame(master) self.vbar = Scrollbar(self.frame) self.vbar.pack(side=RIGHT, fill=Y)
def __init__(self, master=None, **kw): self.frame = Frame(master) self.vbar = Scrollbar(self.frame) self.vbar.pack(side=RIGHT, fill=Y)
456,641
def example(): import __main__ from tkinter.constants import END stext = ScrolledText(bg='white', height=10) stext.insert(END, __main__.__doc__) stext.pack(fill=BOTH, side=LEFT, expand=True) stext.focus_set() stext.mainloop()
def example(): from tkinter.constants import END stext = ScrolledText(bg='white', height=10) stext.insert(END, __main__.__doc__) stext.pack(fill=BOTH, side=LEFT, expand=True) stext.focus_set() stext.mainloop()
456,642
def example(): import __main__ from tkinter.constants import END stext = ScrolledText(bg='white', height=10) stext.insert(END, __main__.__doc__) stext.pack(fill=BOTH, side=LEFT, expand=True) stext.focus_set() stext.mainloop()
def example(): import __main__ from tkinter.constants import END stext = ScrolledText(bg='white', height=10) stext.insert(END, __doc__) stext.pack(fill=BOTH, side=LEFT, expand=True) stext.focus_set() stext.mainloop()
456,643
def help_exec(self): """(!) statement Execute the (one-line) statement in the context of the current stack frame. The exclamation point can be omitted unless the first word of the statement resembles a debugger command. To assign to a global variable you must always prefix the command with a 'global' command, e.g.: (...
def help_exec(self): """(!) statement Execute the (one-line) statement in the context of the current stack frame. The exclamation point can be omitted unless the first word of the statement resembles a debugger command. To assign to a global variable you must always prefix the command with a 'global' command, e.g.: (...
456,644
def _runscript(self, filename): # The script has to run in __main__ namespace (or imports from # __main__ will break). # # So we clear up the __main__ and set several special variables # (this gets rid of pdb's globals and cleans old variables on restarts). import __main__ __main__.__dict__.clear() __main__.__dict__.up...
def _runscript(self, filename): # The script has to run in __main__ namespace (or imports from # __main__ will break). # # So we clear up the __main__ and set several special variables # (this gets rid of pdb's globals and cleans old variables on restarts). import __main__ __main__.__dict__.clear() __main__.__dict__.up...
456,645
def run(self): self.running = True if not self.server.starttls_server: if not self.wrap_conn(): return while self.running: try: msg = self.read() stripped = msg.strip() if not stripped: # eof, so quit this handler self.running = False self.close() elif stripped == b'over': if support.verbose and self.server.connectionc...
def run(self): self.running = True if not self.server.starttls_server: if not self.wrap_conn(): return while self.running: try: msg = self.read() stripped = msg.strip() if not stripped: # eof, so quit this handler self.running = False self.close() elif stripped == b'over': if support.verbose and self.server.connectionc...
456,646
def run(self): self.running = True if not self.server.starttls_server: if not self.wrap_conn(): return while self.running: try: msg = self.read() stripped = msg.strip() if not stripped: # eof, so quit this handler self.running = False self.close() elif stripped == b'over': if support.verbose and self.server.connectionc...
def run(self): self.running = True if not self.server.starttls_server: if not self.wrap_conn(): return while self.running: try: msg = self.read() stripped = msg.strip() if not stripped: # eof, so quit this handler self.running = False self.close() elif stripped == b'over': if support.verbose and self.server.connectionc...
456,647
def _find_exe_version(cmd): """Find the version of an executable by running `cmd` in the shell. If the command is not found, or the output does not match `RE_VERSION`, returns None. """ executable = cmd.split()[0] if find_executable(executable) is None: return None out = Popen(cmd, shell=True, stdout=PIPE).stdout try:...
def _find_exe_version(cmd): """Find the version of an executable by running `cmd` in the shell. If the command is not found, or the output does not match `RE_VERSION`, returns None. """ executable = cmd.split()[0] if find_executable(executable) is None: return None out = Popen(cmd, shell=True, stdout=PIPE).stdout try:...
456,648
def close(self): self.sync() try: self.dict.close() except AttributeError: pass # _ClosedDict can be None when close is called from __del__ during shutdown if _ClosedDict is None: self.dict = None else: self.dict = _ClosedDict()
def close(self): self.sync() try: self.dict.close() except AttributeError: pass # _ClosedDict can be None when close is called from __del__ during shutdown try: self.dict = _ClosedDict() except (NameError, TypeError): self.dict = None else: self.dict = _ClosedDict()
456,649
def close(self): self.sync() try: self.dict.close() except AttributeError: pass # _ClosedDict can be None when close is called from __del__ during shutdown if _ClosedDict is None: self.dict = None else: self.dict = _ClosedDict()
def close(self): self.sync() try: self.dict.close() except AttributeError: pass # _ClosedDict can be None when close is called from __del__ during shutdown if _ClosedDict is None: self.dict = None else: self.dict = _ClosedDict()
456,650
def test_context(self): self.client.quit() ctx = ssl.SSLContext(ssl.PROTOCOL_TLSv1) self.assertRaises(ValueError, ftplib.FTP_TLS, keyfile=CERTFILE, context=ctx) self.assertRaises(ValueError, ftplib.FTP_TLS, certfile=CERTFILE, context=ctx) self.assertRaises(ValueError, ftplib.FTP_TLS, certfile=CERTFILE, keyfile=CERTFILE...
def test_context(self): self.client.quit() ctx = ssl.SSLContext(ssl.PROTOCOL_TLSv1) self.assertRaises(ValueError, ftplib.FTP_TLS, keyfile=CERTFILE, context=ctx) self.assertRaises(ValueError, ftplib.FTP_TLS, certfile=CERTFILE, context=ctx) self.assertRaises(ValueError, ftplib.FTP_TLS, certfile=CERTFILE, keyfile=CERTFILE...
456,651
def recv(self, buflen=1024, flags=0): if self._sslobj: if flags != 0: raise ValueError( "non-zero flags not allowed in calls to sendall() on %s" % self.__class__) while True: try: return self.read(buflen) except SSLError, x: if x.args[0] == SSL_ERROR_WANT_READ: continue else: raise x else: return socket.recv(self, bufl...
def recv(self, buflen=1024, flags=0): if self._sslobj: if flags != 0: raise ValueError( "non-zero flags not allowed in calls to recv() on %s" % self.__class__) while True: try: return self.read(buflen) except SSLError, x: if x.args[0] == SSL_ERROR_WANT_READ: continue else: raise x else: return socket.recv(self, buflen,...
456,652
def recv(self, buflen=1024, flags=0): if self._sslobj: if flags != 0: raise ValueError( "non-zero flags not allowed in calls to sendall() on %s" % self.__class__) while True: try: return self.read(buflen) except SSLError, x: if x.args[0] == SSL_ERROR_WANT_READ: continue else: raise x else: return socket.recv(self, bufl...
def recv(self, buflen=1024, flags=0): if self._sslobj: if flags != 0: raise ValueError( "non-zero flags not allowed in calls to sendall() on %s" % self.__class__) return self.read(buflen) else: return socket.recv(self, buflen, flags)
456,653
def recv_into(self, buffer, nbytes=None, flags=0): 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: tmp_buffer = self.read(nbytes) v = le...
def recv_into(self, buffer, nbytes=None, flags=0): 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__) tmp_buffer = self.read(nbytes) v = len(tmp_buffer) buf...
456,654
def processinginstruction(): """ Test ProcessingInstruction directly >>> ET.tostring(ET.ProcessingInstruction('test', 'instruction')) '<?test instruction?>' >>> ET.tostring(ET.PI('test', 'instruction')) '<?test instruction?>' Issue #2746 >>> ET.tostring(ET.PI('test', '<testing&>')) '<?test <testing&>?>' >>> ET.tostr...
def processinginstruction(): """ Test ProcessingInstruction directly >>> ET.tostring(ET.ProcessingInstruction('test', 'instruction')) '<?test instruction?>' >>> ET.tostring(ET.PI('test', 'instruction')) '<?test instruction?>' Issue #2746 >>> ET.tostring(ET.PI('test', '<testing&>')) '<?test <testing&>?>' >>> ET.tostr...
456,655
def test_main(module_name='xml.etree.ElementTree'): import warnings from test import test_xml_etree def ignore(message, category=DeprecationWarning): warnings.filterwarnings("ignore", message, category) # The same doctests are used for both the Python and the C implementations assert test_xml_etree.ET.__name__ == modu...
def test_main(module_name='xml.etree.ElementTree'): from test import test_xml_etree def ignore(message, category=DeprecationWarning): warnings.filterwarnings("ignore", message, category) # The same doctests are used for both the Python and the C implementations assert test_xml_etree.ET.__name__ == module_name with wa...
456,656
def ignore(message, category=DeprecationWarning): warnings.filterwarnings("ignore", message, category)
def ignore(message, category=DeprecationWarning): warnings.filterwarnings("ignore", message, category)
456,657
def ignore(message, category=DeprecationWarning): warnings.filterwarnings("ignore", message, category)
def ignore(message, category=DeprecationWarning): warnings.filterwarnings("ignore", message, category)
456,658
def strip_to_x509_cert(certfile_contents, outfile=None): m = re.search(br"^([-]+BEGIN CERTIFICATE[-]+[\r]*\n" br".*[\r]*^[-]+END CERTIFICATE[-]+)$", certfile_contents, re.MULTILINE | re.DOTALL) if not m: return None else: tn = tempfile.mktemp() fp = open(tn, "wb") fp.write(m.group(1) + b"\n") fp.close() try: tn2 = (out...
def strip_to_x509_cert(certfile_contents, outfile=None): m = re.search(br"^([-]+BEGIN CERTIFICATE[-]+[\r]*\n" br".*[\r]*^[-]+END CERTIFICATE[-]+)$", certfile_contents, re.MULTILINE | re.DOTALL) if not m: return None else: tn = tempfile.mktemp() fp = open(tn, "wb") fp.write(m.group(1) + b"\n") fp.close() try: tn2 = (out...
456,659
def strip_to_x509_cert(certfile_contents, outfile=None): m = re.search(br"^([-]+BEGIN CERTIFICATE[-]+[\r]*\n" br".*[\r]*^[-]+END CERTIFICATE[-]+)$", certfile_contents, re.MULTILINE | re.DOTALL) if not m: return None else: tn = tempfile.mktemp() fp = open(tn, "wb") fp.write(m.group(1) + b"\n") fp.close() try: tn2 = (out...
def strip_to_x509_cert(certfile_contents, outfile=None): m = re.search(br"^([-]+BEGIN CERTIFICATE[-]+[\r]*\n" br".*[\r]*^[-]+END CERTIFICATE[-]+)$", certfile_contents, re.MULTILINE | re.DOTALL) if not m: return None else: tn = tempfile.mktemp() fp = open(tn, "wb") fp.write(m.group(1) + b"\n") fp.close() try: tn2 = (out...
456,660
def do_list(self, arg): self.lastcmd = 'list' last = None if arg: try: x = eval(arg, {}, {}) if type(x) == type(()): first, last = x first = int(first) last = int(last) if last < first: # Assume it's a count last = first + last else: first = max(1, int(x) - 5) except: print('*** Error in argument:', repr(arg), file=sel...
def do_list(self, arg): self.lastcmd = 'list' last = None if arg and arg != '.': try: x = eval(arg, {}, {}) if type(x) == type(()): first, last = x first = int(first) last = int(last) if last < first: # Assume it's a count last = first + last else: first = max(1, int(x) - 5) except: print('*** Error in argument:', repr...
456,661
def do_list(self, arg): self.lastcmd = 'list' last = None if arg: try: x = eval(arg, {}, {}) if type(x) == type(()): first, last = x first = int(first) last = int(last) if last < first: # Assume it's a count last = first + last else: first = max(1, int(x) - 5) except: print('*** Error in argument:', repr(arg), file=sel...
def do_list(self, arg): self.lastcmd = 'list' last = None if arg: try: x = eval(arg, {}, {}) if type(x) == type(()): first, last = x first = int(first) last = int(last) if last < first: # Assume it's a count last = first + last else: first = max(1, int(x) - 5) except: print('*** Error in argument:', repr(arg), file=sel...
456,662
def test_main(): py_warnings.onceregistry.clear() c_warnings.onceregistry.clear() support.run_unittest(CFilterTests, PyFilterTests, CWarnTests, PyWarnTests, CWCmdLineTests, PyWCmdLineTests, _WarningsTests, CWarningsDisplayTests, PyWarningsDisplayTests, CCatchWarningTests, PyCatchWarningTests, CEnvironmentVariableTests,...
def test_main(): py_warnings.onceregistry.clear() c_warnings.onceregistry.clear() support.run_unittest( CFilterTests, PyFilterTests, CWarnTests, PyWarnTests, CWCmdLineTests, PyWCmdLineTests, _WarningsTests, CWarningsDisplayTests, PyWarningsDisplayTests, CCatchWarningTests, PyCatchWarningTests, CEnvironmentVariableTests...
456,663
def gen_db_minor_ver_nums(major): if major == 4: for x in range(max_db_ver[1]+1): if allow_db_ver((4, x)): yield x elif major == 3: for x in (3,): if allow_db_ver((3, x)): yield x else: raise ValueError("unknown major BerkeleyDB version", major)
def gen_db_minor_ver_nums(major): if major == 4: for x in range(max_db_ver[1]+1): if allow_db_ver((4, x)): yield x elif major == 3: for x in (3,): if allow_db_ver((3, x)): yield x else: raise ValueError("unknown major BerkeleyDB version", major)
456,664
def run(self): self.function(*self.args)
def run(self): self.function(*self.args)
456,665
def getdocloc(self, object): """Return the location of module docs or None"""
def getdocloc(self, object): """Return the location of module docs or None"""
456,666
def testUnoptimizedNamespaces(self):
def testUnoptimizedNamespaces(self):
456,667
def inner(): return y
def inner(): return y
456,668
def testScopeOfGlobalStmt(self):
def testScopeOfGlobalStmt(self):
456,669
def testClassAndGlobal(self):
def testClassAndGlobal(self):
456,670
CODE = """def f():
CODE = """def f():
456,671
def h(): return y + 1
def h(): return y + 1
456,672
def main(tests=None, testdir=None, verbose=0, quiet=False, exclude=False, single=False, randomize=False, fromfile=None, findleaks=False, use_resources=None, trace=False, coverdir='coverage', runleaks=False, huntrleaks=False, verbose2=False, print_slow=False, random_seed=None, use_mp=None, verbose3=False, forever=False)...
def main(tests=None, testdir=None, verbose=0, quiet=False, exclude=False, single=False, randomize=False, fromfile=None, findleaks=False, use_resources=None, trace=False, coverdir='coverage', runleaks=False, huntrleaks=False, verbose2=False, print_slow=False, random_seed=None, use_mp=None, verbose3=False, forever=False)...
456,673
def main(tests=None, testdir=None, verbose=0, quiet=False, exclude=False, single=False, randomize=False, fromfile=None, findleaks=False, use_resources=None, trace=False, coverdir='coverage', runleaks=False, huntrleaks=False, verbose2=False, print_slow=False, random_seed=None, use_mp=None, verbose3=False, forever=False)...
def main(tests=None, testdir=None, verbose=0, quiet=False, exclude=False, single=False, randomize=False, fromfile=None, findleaks=False, use_resources=None, trace=False, coverdir='coverage', runleaks=False, huntrleaks=False, verbose2=False, print_slow=False, random_seed=None, use_mp=None, verbose3=False, forever=False)...
456,674
def getexpected(self): """Return set of test names we expect to skip on current platform.
def getexpected(self): """Return set of test names we expect to skip on current platform.
456,675
def getexpected(self): """Return set of test names we expect to skip on current platform.
def getexpected(self): """Return set of test names we expect to skip on current platform.
456,676
def add_dir_to_list(dirlist, dir): """Add the directory 'dir' to the list 'dirlist' (at the front) if 1) 'dir' is not already in 'dirlist' 2) 'dir' actually exists, and is a directory.""" if dir is not None and os.path.isdir(dir) and dir not in dirlist: dirlist.insert(0, dir)
def add_dir_to_list(dirlist, dir): """Add the directory 'dir' to the list 'dirlist' (after any relative directories) if: 1) 'dir' is not already in 'dirlist' 2) 'dir' actually exists, and is a directory.""" if dir is not None and os.path.isdir(dir) and dir not in dirlist: dirlist.insert(0, dir)
456,677
def add_dir_to_list(dirlist, dir): """Add the directory 'dir' to the list 'dirlist' (at the front) if 1) 'dir' is not already in 'dirlist' 2) 'dir' actually exists, and is a directory.""" if dir is not None and os.path.isdir(dir) and dir not in dirlist: dirlist.insert(0, dir)
def add_dir_to_list(dirlist, dir): """Add the directory 'dir' to the list 'dirlist' (at the front) if 1) 'dir' is not already in 'dirlist' 2) 'dir' actually exists, and is a directory. """ if dir is None or not os.path.isdir(dir) or dir in dirlist: return for i, path in enumerate(dirlist): if not os.path.isabs(path): d...
456,678
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')
456,679
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')
456,680
def test_undecodable_env(self): for key, value in (('test', 'abc\uDCFF'), ('test\uDCFF', '42')): value_repr = repr(value).encode("ascii")
def test_undecodable_env(self): for key, value in (('test', 'abc\uDCFF'), ('test\uDCFF', '42')): value_repr = repr(value).encode("ascii")
456,681
def test_write_simple_dict(self): fd, name = tempfile.mkstemp() fileobj = os.fdopen(fd, "w+b") try: writer = csv.DictWriter(fileobj, fieldnames = ["f1", "f2", "f3"]) writer.writeheader() fileobj.seek(0) self.assertEqual(fileobj.readline(), "f1,f2,f3\r\n") writer.writerow({"f1": 10, "f3": "abc"}) fileobj.seek(0) fileobj...
def test_write_simple_dict(self): fd, name = tempfile.mkstemp() fileobj = io.open(fd, 'w+b') try: writer = csv.DictWriter(fileobj, fieldnames = ["f1", "f2", "f3"]) writer.writeheader() fileobj.seek(0) self.assertEqual(fileobj.readline(), "f1,f2,f3\r\n") writer.writerow({"f1": 10, "f3": "abc"}) fileobj.seek(0) fileobj.r...
456,682
def test_event(self): event = self.Event() wait = TimingWrapper(event.wait)
def test_event(self): event = self.Event() wait = TimingWrapper(event.wait)
456,683
def test_heap(self): iterations = 5000 maxblocks = 50 blocks = []
def test_heap(self): iterations = 5000 maxblocks = 50 blocks = []
456,684
def test_font_eq(self): font1 = font.nametofont("system") font2 = font.nametofont("system") self.assertIsNot(font1, font2) self.assertEqual(font1, font2) self.assertNotEqual(font1, font1.copy()) self.assertNotEqual(font1, 0)
def test_font_eq(self): font1 = font.nametofont("TkDefaultFont") font2 = font.nametofont("TkDefaultFont") self.assertIsNot(font1, font2) self.assertEqual(font1, font2) self.assertNotEqual(font1, font1.copy()) self.assertNotEqual(font1, 0)
456,685
def test_checkcache(self): getline = linecache.getline try: # Create a source file and cache its contents source_name = support.TESTFN + '.py' with open(source_name, 'w') as source: source.write(SOURCE_1) source.close() getline(source_name, 1)
def test_checkcache(self): getline = linecache.getline try: # Create a source file and cache its contents source_name = support.TESTFN + '.py' with open(source_name, 'w') as source: source.write(SOURCE_1) source.close() getline(source_name, 1)
456,686
def test_checkcache(self): getline = linecache.getline try: # Create a source file and cache its contents source_name = support.TESTFN + '.py' with open(source_name, 'w') as source: source.write(SOURCE_1) source.close() getline(source_name, 1)
def test_checkcache(self): getline = linecache.getline try: # Create a source file and cache its contents source_name = support.TESTFN + '.py' with open(source_name, 'w') as source: source.write(SOURCE_1) source.close() getline(source_name, 1)
456,687
def test_checkcache(self): getline = linecache.getline try: # Create a source file and cache its contents source_name = support.TESTFN + '.py' with open(source_name, 'w') as source: source.write(SOURCE_1) source.close() getline(source_name, 1)
def test_checkcache(self): getline = linecache.getline try: # Create a source file and cache its contents source_name = support.TESTFN + '.py' with open(source_name, 'w') as source: source.write(SOURCE_1) getline(source_name, 1)
456,688
def test_checkcache(self): getline = linecache.getline try: # Create a source file and cache its contents source_name = support.TESTFN + '.py' with open(source_name, 'w') as source: source.write(SOURCE_1) source.close() getline(source_name, 1)
def test_checkcache(self): getline = linecache.getline try: # Create a source file and cache its contents source_name = support.TESTFN + '.py' with open(source_name, 'w') as source: source.write(SOURCE_1) source.close() getline(source_name, 1)
456,689
def test_checkcache(self): getline = linecache.getline try: # Create a source file and cache its contents source_name = support.TESTFN + '.py' with open(source_name, 'w') as source: source.write(SOURCE_1) source.close() getline(source_name, 1)
def test_checkcache(self): getline = linecache.getline try: # Create a source file and cache its contents source_name = support.TESTFN + '.py' with open(source_name, 'w') as source: source.write(SOURCE_1) getline(source_name, 1)
456,690
def test_checkcache(self): getline = linecache.getline try: # Create a source file and cache its contents source_name = support.TESTFN + '.py' with open(source_name, 'w') as source: source.write(SOURCE_1) source.close() getline(source_name, 1)
def test_checkcache(self): getline = linecache.getline try: # Create a source file and cache its contents source_name = support.TESTFN + '.py' with open(source_name, 'w') as source: source.write(SOURCE_1) source.close() getline(source_name, 1)
456,691
def test_checkcache(self): getline = linecache.getline try: # Create a source file and cache its contents source_name = support.TESTFN + '.py' with open(source_name, 'w') as source: source.write(SOURCE_1) source.close() getline(source_name, 1)
def test_checkcache(self): getline = linecache.getline try: # Create a source file and cache its contents source_name = support.TESTFN + '.py' with open(source_name, 'w') as source: source.write(SOURCE_1) source.close() getline(source_name, 1)
456,692
def test_checkcache(self): getline = linecache.getline try: # Create a source file and cache its contents source_name = support.TESTFN + '.py' with open(source_name, 'w') as source: source.write(SOURCE_1) source.close() getline(source_name, 1)
def test_checkcache(self): getline = linecache.getline try: # Create a source file and cache its contents source_name = support.TESTFN + '.py' with open(source_name, 'w') as source: source.write(SOURCE_1) source.close() getline(source_name, 1)
456,693
def test_issue10254(self): # Crash reported in #10254 a = u'C\u0338' * 20 + 'C\u0327' b = u'C\u0338' * 20 + '\xC7' self.assertEqual(self.db.normalize('NFC', a), b)
def test_issue10254(self): # Crash reported in #10254 a = u'C\u0338' * 20 + u'C\u0327' b = u'C\u0338' * 20 + u'\xC7' self.assertEqual(self.db.normalize('NFC', a), b)
456,694
def test_decode(self): with open(support.TESTFN, 'wb') as fp: fp.write(b'Yf9iCg==') output = self.get_output('-d', support.TESTFN) self.assertEquals(output, b'a\xffb\n')
def test_decode(self): with open(support.TESTFN, 'wb') as fp: fp.write(b'Yf9iCg==') output = self.get_output('-d', support.TESTFN) self.assertEquals(output, b'a\xffb\n')
456,695
def isleap(year): """Return 1 for leap years, 0 for non-leap years.""" return year % 4 == 0 and (year % 100 != 0 or year % 400 == 0)
def isleap(year): """Return True for leap years, False for non-leap years.""" return year % 4 == 0 and (year % 100 != 0 or year % 400 == 0)
456,696
def show(caps): print("Mailcap files:") for fn in listmailcapfiles(): print("\t" + fn) print() if not caps: caps = getcaps() print("Mailcap entries:") print() ckeys = caps.keys() ckeys.sort() for type in ckeys: print(type) entries = caps[type] for e in entries: keys = e.keys() keys.sort() for k in keys: print(" %-15s"...
def show(caps): print("Mailcap files:") for fn in listmailcapfiles(): print("\t" + fn) print() if not caps: caps = getcaps() print("Mailcap entries:") print() ckeys = sorted(caps) for type in ckeys: print(type) entries = caps[type] for e in entries: keys = e.keys() keys.sort() for k in keys: print(" %-15s" % k, e[k]) ...
456,697
def show(caps): print("Mailcap files:") for fn in listmailcapfiles(): print("\t" + fn) print() if not caps: caps = getcaps() print("Mailcap entries:") print() ckeys = caps.keys() ckeys.sort() for type in ckeys: print(type) entries = caps[type] for e in entries: keys = e.keys() keys.sort() for k in keys: print(" %-15s"...
def show(caps): print("Mailcap files:") for fn in listmailcapfiles(): print("\t" + fn) print() if not caps: caps = getcaps() print("Mailcap entries:") print() ckeys = caps.keys() ckeys.sort() for type in ckeys: print(type) entries = caps[type] for e in entries: keys = sorted(e) for k in keys: print(" %-15s" % k, e[k])...
456,698
def fact(n): result = 1 for i in range(1, int(n)+1): result *= i return result
def fact(n): result = 1 for i in range(1, int(n)+1): result *= i return result
456,699