bugged
stringlengths
4
228k
fixed
stringlengths
0
96.3M
__index_level_0__
int64
0
481k
def _default_mime_types(): global suffix_map global encodings_map global types_map global common_types suffix_map = { '.tgz': '.tar.gz', '.taz': '.tar.gz', '.tz': '.tar.gz', '.tbz2': '.tar.bz2', } encodings_map = { '.gz': 'gzip', '.Z': 'compress', '.bz2': 'bzip2', } # Before adding new types, make sure they are eith...
def _default_mime_types(): global suffix_map global encodings_map global types_map global common_types suffix_map = { '.tgz': '.tar.gz', '.taz': '.tar.gz', '.tz': '.tar.gz', '.tbz2': '.tar.bz2', } encodings_map = { '.gz': 'gzip', '.Z': 'compress', '.bz2': 'bzip2', } # Before adding new types, make sure they are eith...
456,800
def test_wait_when_sigchild_ignored(self): # NOTE: sigchild_ignore.py may not be an effective test on all OSes. sigchild_ignore = support.findfile("sigchild_ignore.py", subdir="subprocessdata") p = subprocess.Popen([sys.executable, sigchild_ignore], stdout=subprocess.PIPE, stderr=subprocess.PIPE) stdout, stderr = p.com...
def test_wait_when_sigchild_ignored(self): # NOTE: sigchild_ignore.py may not be an effective test on all OSes. sigchild_ignore = support.findfile("sigchild_ignore.py", subdir="subprocessdata") p = subprocess.Popen([sys.executable, sigchild_ignore], stdout=subprocess.PIPE, stderr=subprocess.PIPE) stdout, stderr = p.com...
456,801
def test_execvpe_with_bad_arglist(self): self.assertRaises(ValueError, os.execvpe, 'notepad', [], None)
def test_execvpe_with_bad_arglist(self): self.assertRaises(ValueError, os.execvpe, 'notepad', [], None)
456,802
def _samefile(src, dst): # Macintosh, Unix. if hasattr(os.path,'samefile'): try: return os.path.samefile(src, dst) except OSError: return False # All other platforms: check for same pathname. return (os.path.normcase(os.path.abspath(src)) == os.path.normcase(os.path.abspath(dst)))
def _samefile(src, dst): # Macintosh, Unix. if hasattr(os.path, 'samefile'): try: return os.path.samefile(src, dst) except OSError: return False # All other platforms: check for same pathname. return (os.path.normcase(os.path.abspath(src)) == os.path.normcase(os.path.abspath(dst)))
456,803
def copyfile(src, dst): """Copy data from src to dst""" if _samefile(src, dst): raise Error, "`%s` and `%s` are the same file" % (src, dst) fsrc = None fdst = None for fn in [src, dst]: try: st = os.stat(fn) except OSError: # File most likely does not exist pass else: # XXX What about other special files? (sockets, de...
def copyfile(src, dst): """Copy data from src to dst""" if _samefile(src, dst): raise Error("`%s` and `%s` are the same file" % (src, dst)) fsrc = None fdst = None for fn in [src, dst]: try: st = os.stat(fn) except OSError: # File most likely does not exist pass else: # XXX What about other special files? (sockets, de...
456,804
def copystat(src, dst): """Copy all stat info (mode bits, atime, mtime, flags) from src to dst""" st = os.stat(src) mode = stat.S_IMODE(st.st_mode) if hasattr(os, 'utime'): os.utime(dst, (st.st_atime, st.st_mtime)) if hasattr(os, 'chmod'): os.chmod(dst, mode) if hasattr(os, 'chflags') and hasattr(st, 'st_flags'): try: ...
def copystat(src, dst): """Copy all stat info (mode bits, atime, mtime, flags) from src to dst""" st = os.stat(src) mode = stat.S_IMODE(st.st_mode) if hasattr(os, 'utime'): os.utime(dst, (st.st_atime, st.st_mtime)) if hasattr(os, 'chmod'): os.chmod(dst, mode) if hasattr(os, 'chflags') and hasattr(st, 'st_flags'): try: ...
456,805
def test_issue9324(self): handler = lambda x, y: None signal.signal(signal.SIGABRT, handler) signal.signal(signal.SIGFPE, handler) signal.signal(signal.SIGILL, handler) signal.signal(signal.SIGINT, handler) signal.signal(signal.SIGSEGV, handler) signal.signal(signal.SIGTERM, handler)
def test_issue9324(self): handler = lambda x, y: None signal.signal(signal.SIGABRT, handler) signal.signal(signal.SIGFPE, handler) signal.signal(signal.SIGILL, handler) signal.signal(signal.SIGINT, handler) signal.signal(signal.SIGSEGV, handler) signal.signal(signal.SIGTERM, handler)
456,806
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,807
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,808
def TEst_getset_charset(self): eq = self.assertEqual msg = Message() eq(msg.get_charset(), None) charset = Charset('iso-8859-1') msg.set_charset(charset) eq(msg['mime-version'], '1.0') eq(msg.get_content_type(), 'text/plain') eq(msg['content-type'], 'text/plain; charset="iso-8859-1"') eq(msg.get_param('charset'), 'iso-...
def test_getset_charset(self): eq = self.assertEqual msg = Message() eq(msg.get_charset(), None) charset = Charset('iso-8859-1') msg.set_charset(charset) eq(msg['mime-version'], '1.0') eq(msg.get_content_type(), 'text/plain') eq(msg['content-type'], 'text/plain; charset="iso-8859-1"') eq(msg.get_param('charset'), 'iso-...
456,809
def _idempotent(self, msg, data): b = BytesIO() g = email.generator.BytesGenerator(b, maxheaderlen=0) g.flatten(msg) self.assertEqual(data, b.getvalue())
def _idempotent(self, msg, data): b = BytesIO() g = email.generator.BytesGenerator(b, maxheaderlen=0) g.flatten(msg) self.assertEqual(data, b.getvalue())
456,810
def _ensure_header_written(self, datasize): if not self._datawritten: if not self._nchannels: raise Error('# channels not specified') if not self._sampwidth: raise Error('sample width not specified') if not self._framerate: raise Error('sampling rate not specified') self._write_header(datasize)
def _ensure_header_written(self, datasize): if not self._headerwritten: if not self._nchannels: raise Error('# channels not specified') if not self._sampwidth: raise Error('sample width not specified') if not self._framerate: raise Error('sampling rate not specified') self._write_header(datasize)
456,811
def _process_worker(call_queue, result_queue, shutdown): """Evaluates calls from call_queue and places the results in result_queue. This worker is run in a seperate process. Args: call_queue: A multiprocessing.Queue of _CallItems that will be read and evaluated by the worker. result_queue: A multiprocessing.Queue of ...
def _process_worker(call_queue, result_queue, shutdown): """Evaluates calls from call_queue and places the results in result_queue. This worker is run in a separate process. Args: call_queue: A multiprocessing.Queue of _CallItems that will be read and evaluated by the worker. result_queue: A multiprocessing.Queue of ...
456,812
def _copy_immutable(x): return x
def _copy_immutable(x): return x
456,813
def testOpenDir(self): this_dir = os.path.dirname(__file__) for mode in (None, "w"): try: if mode: f = open(this_dir, mode) else: f = open(this_dir) except IOError as e: self.assertEqual(e.filename, this_dir) else: self.fail("opening a directory didn't raise an IOError")
def testOpenDir(self): this_dir = os.path.dirname(__file__) or os.curdir for mode in (None, "w"): try: if mode: f = open(this_dir, mode) else: f = open(this_dir) except IOError as e: self.assertEqual(e.filename, this_dir) else: self.fail("opening a directory didn't raise an IOError")
456,814
def getproxies_registry(): """Return a dictionary of scheme -> proxy server URL mappings.
def getproxies_registry(): """Return a dictionary of scheme -> proxy server URL mappings.
456,815
def zip_open_test(self, f, compression): self.make_test_archive(f, compression)
def zip_open_test(self, f, compression): self.make_test_archive(f, compression)
456,816
def zip_open_test(self, f, compression): self.make_test_archive(f, compression)
def zip_open_test(self, f, compression): self.make_test_archive(f, compression)
456,817
def test_open_via_zip_info(self): # Create the ZIP archive with zipfile.ZipFile(TESTFN2, "w", zipfile.ZIP_STORED) as zipfp: zipfp.writestr("name", "foo") zipfp.writestr("name", "bar")
def test_open_via_zip_info(self): # Create the ZIP archive with zipfile.ZipFile(TESTFN2, "w", zipfile.ZIP_STORED) as zipfp: zipfp.writestr("name", "foo") zipfp.writestr("name", "bar")
456,818
def zip_random_open_test(self, f, compression): self.make_test_archive(f, compression)
def zip_random_open_test(self, f, compression): self.make_test_archive(f, compression)
456,819
def test_univeral_readaheads(self): f = io.BytesIO()
def test_univeral_readaheads(self): f = io.BytesIO()
456,820
def zip_readline_read_test(self, f, compression): self.make_test_archive(f, compression)
def zip_readline_read_test(self, f, compression): self.make_test_archive(f, compression)
456,821
def zip_readline_test(self, f, compression): self.make_test_archive(f, compression)
def zip_readline_test(self, f, compression): self.make_test_archive(f, compression)
456,822
def zip_readlines_test(self, f, compression): self.make_test_archive(f, compression)
def zip_readlines_test(self, f, compression): self.make_test_archive(f, compression)
456,823
def zip_iterlines_test(self, f, compression): self.make_test_archive(f, compression)
def zip_iterlines_test(self, f, compression): self.make_test_archive(f, compression)
456,824
def test_low_compression(self): """Check for cases where compressed data is larger than original.""" # Create the ZIP archive with zipfile.ZipFile(TESTFN2, "w", zipfile.ZIP_DEFLATED) as zipfp: zipfp.writestr("strfile", '12')
def test_low_compression(self): """Check for cases where compressed data is larger than original.""" # Create the ZIP archive with zipfile.ZipFile(TESTFN2, "w", zipfile.ZIP_DEFLATED) as zipfp: zipfp.writestr("strfile", '12')
456,825
def test_write_default_name(self): """Check that calling ZipFile.write without arcname specified produces the expected result.""" with zipfile.ZipFile(TESTFN2, "w") as zipfp: zipfp.write(TESTFN) self.assertEqual(zipfp.read(TESTFN), open(TESTFN, "rb").read())
def test_write_default_name(self): """Check that calling ZipFile.write without arcname specified produces the expected result.""" with zipfile.ZipFile(TESTFN2, "w") as zipfp: zipfp.write(TESTFN) self.assertEqual(zipfp.read(TESTFN), open(TESTFN, "rb").read())
456,826
def test_extract(self): with zipfile.ZipFile(TESTFN2, "w", zipfile.ZIP_STORED) as zipfp: for fpath, fdata in SMALL_TEST_DATA: zipfp.writestr(fpath, fdata)
def test_extract(self): with zipfile.ZipFile(TESTFN2, "w", zipfile.ZIP_STORED) as zipfp: for fpath, fdata in SMALL_TEST_DATA: zipfp.writestr(fpath, fdata)
456,827
def test_extract_all(self): with zipfile.ZipFile(TESTFN2, "w", zipfile.ZIP_STORED) as zipfp: for fpath, fdata in SMALL_TEST_DATA: zipfp.writestr(fpath, fdata)
def test_extract_all(self): with zipfile.ZipFile(TESTFN2, "w", zipfile.ZIP_STORED) as zipfp: for fpath, fdata in SMALL_TEST_DATA: zipfp.writestr(fpath, fdata)
456,828
def test_write_non_pyfile(self): with zipfile.PyZipFile(TemporaryFile(), "w") as zipfp: open(TESTFN, 'w').write('most definitely not a python file') self.assertRaises(RuntimeError, zipfp.writepy, TESTFN) os.remove(TESTFN)
def test_write_non_pyfile(self): with zipfile.PyZipFile(TemporaryFile(), "w") as zipfp: with open(TESTFN, 'w') as f: f.write('most definitely not a python file') self.assertRaises(RuntimeError, zipfp.writepy, TESTFN) os.remove(TESTFN)
456,829
def test_closed_zip_raises_RuntimeError(self): """Verify that testzip() doesn't swallow inappropriate exceptions.""" data = io.BytesIO() with zipfile.ZipFile(data, mode="w") as zipf: zipf.writestr("foo.txt", "O, for a Muse of Fire!")
def test_closed_zip_raises_RuntimeError(self): """Verify that testzip() doesn't swallow inappropriate exceptions.""" data = io.BytesIO() with zipfile.ZipFile(data, mode="w") as zipf: zipf.writestr("foo.txt", "O, for a Muse of Fire!")
456,830
def test_read0(self): """Check that calling read(0) on a ZipExtFile object returns an empty string and doesn't advance file pointer.""" with zipfile.ZipFile(TESTFN, mode="w") as zipf: zipf.writestr("foo.txt", "O, for a Muse of Fire!") # read the data to make sure the file is there f = zipf.open("foo.txt") for i in rang...
def test_read0(self): """Check that calling read(0) on a ZipExtFile object returns an empty string and doesn't advance file pointer.""" with zipfile.ZipFile(TESTFN, mode="w") as zipf: zipf.writestr("foo.txt", "O, for a Muse of Fire!") # read the data to make sure the file is there f = zipf.open("foo.txt") for i in rang...
456,831
def zip_open_test(self, f, compression): self.make_test_archive(f, compression)
def zip_open_test(self, f, compression): self.make_test_archive(f, compression)
456,832
def zip_open_test(self, f, compression): self.make_test_archive(f, compression)
def zip_open_test(self, f, compression): self.make_test_archive(f, compression)
456,833
def zip_random_open_test(self, f, compression): self.make_test_archive(f, compression)
def zip_random_open_test(self, f, compression): self.make_test_archive(f, compression)
456,834
def test_same_file(self): # Verify that (when the ZipFile is in control of creating file objects) # multiple open() calls can be made without interfering with each other. with zipfile.ZipFile(TESTFN2, mode="r") as zipf: zopen1 = zipf.open('ones') zopen2 = zipf.open('ones') data1 = zopen1.read(500) data2 = zopen2.read(5...
def test_same_file(self): # Verify that (when the ZipFile is in control of creating file objects) # multiple open() calls can be made without interfering with each other. with zipfile.ZipFile(TESTFN2, mode="r") as zipf: with zipf.open('ones') as zopen1, zipf.open('ones') as zopen2: data1 = zopen1.read(500) data2 = zope...
456,835
def test_different_file(self): # Verify that (when the ZipFile is in control of creating file objects) # multiple open() calls can be made without interfering with each other. with zipfile.ZipFile(TESTFN2, mode="r") as zipf: zopen1 = zipf.open('ones') zopen2 = zipf.open('twos') data1 = zopen1.read(500) data2 = zopen2.r...
def test_different_file(self): # Verify that (when the ZipFile is in control of creating file objects) # multiple open() calls can be made without interfering with each other. with zipfile.ZipFile(TESTFN2, mode="r") as zipf: with zipf.open('ones') as zopen1, zipf.open('twos') as zopen2: data1 = zopen1.read(500) data2 =...
456,836
def test_interleaved(self): # Verify that (when the ZipFile is in control of creating file objects) # multiple open() calls can be made without interfering with each other. with zipfile.ZipFile(TESTFN2, mode="r") as zipf: zopen1 = zipf.open('ones') data1 = zopen1.read(500) zopen2 = zipf.open('twos') data2 = zopen2.read...
def test_interleaved(self): # Verify that (when the ZipFile is in control of creating file objects) # multiple open() calls can be made without interfering with each other. with zipfile.ZipFile(TESTFN2, mode="r") as zipf: with zipf.open('ones') as zopen1, zipf.open('twos') as zopen2: data1 = zopen1.read(500) data2 = zo...
456,837
def readline_read_test(self, f, compression): self.make_test_archive(f, compression)
def readline_read_test(self, f, compression): self.make_test_archive(f, compression)
456,838
def readline_read_test(self, f, compression): self.make_test_archive(f, compression)
def readline_read_test(self, f, compression): self.make_test_archive(f, compression)
456,839
def run_the_test(): imp.reload(the_module)
def run_the_test(): imp.reload(the_module)
456,840
def run_the_test(): imp.reload(the_module)
def run_the_test(): imp.reload(the_module)
456,841
def test_wait_when_sigchild_ignored(self): # NOTE: sigchild_ignore.py may not be an effective test on all OSes. sigchild_ignore = support.findfile("sigchild_ignore.py", subdir="subprocessdata") p = subprocess.Popen([sys.executable, sigchild_ignore], stdout=subprocess.PIPE, stderr=subprocess.PIPE) stdout, stderr = p.com...
def test_wait_when_sigchild_ignored(self): # NOTE: sigchild_ignore.py may not be an effective test on all OSes. sigchild_ignore = support.findfile("sigchild_ignore.py", subdir="subprocessdata") p = subprocess.Popen([sys.executable, sigchild_ignore], stdout=subprocess.PIPE, stderr=subprocess.PIPE) stdout, stderr = p.com...
456,842
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,843
def check(self, name, data, digest): # test the direct constructors computed = getattr(hashlib, name)(data).hexdigest() self.assertEqual(computed, digest) # test the general new() interface computed = hashlib.new(name, data).hexdigest() self.assertEqual(computed, digest)
def check(self, name, data, digest): # test the direct constructors computed = getattr(hashlib, name)(data).hexdigest() self.assertEqual(computed, digest) # test the general new() interface computed = hashlib.new(name, data).hexdigest() self.assertEqual(computed, digest)
456,844
def check_unicode(self, algorithm_name): # Unicode objects are not allowed as input. expected = hashlib.new(algorithm_name, str(u'spam')).hexdigest() self.assertEqual(getattr(hashlib, algorithm_name)(u'spam').hexdigest(), expected) self.assertEqual(hashlib.new(algorithm_name, u'spam').hexdigest(), expected)
def check_unicode(self, algorithm_name): # Unicode objects are not allowed as input. expected = hashlib.new(algorithm_name, str(u'spam')).hexdigest() self.assertEqual(getattr(hashlib, algorithm_name)(u'spam').hexdigest(), expected) self.assertEqual(hashlib.new(algorithm_name, u'spam').hexdigest(), expected)
456,845
def urlopen(url, data=None, proxies=None): """Create a file-like object for the specified URL to read from.""" from warnings import warnpy3k warnings.warnpy3k("urllib.urlopen() has been removed in Python 3.0 in " "favor of urllib2.urlopen()", stacklevel=2) global _urlopener if proxies is not None: opener = FancyURLope...
def urlopen(url, data=None, proxies=None): """Create a file-like object for the specified URL to read from.""" from warnings import warnpy3k warnpy3k("urllib.urlopen() has been removed in Python 3.0 in " "favor of urllib2.urlopen()", stacklevel=2) global _urlopener if proxies is not None: opener = FancyURLopener(proxi...
456,846
def execvp(file, args): """execp(file, args) Execute the executable file (which is searched for along $PATH) with argument list args, replacing the current process. args may be a list or tuple of strings. """ _execvpe(file, args)
def execvp(file, args): """execvp(file, args) Execute the executable file (which is searched for along $PATH) with argument list args, replacing the current process. args may be a list or tuple of strings. """ _execvpe(file, args)
456,847
def _real_close(self): _socket.socket.close(self)
def _real_close(self): _socket.socket.close(self)
456,848
def format_mtime(mtime): if isinstance(mtime, float): return "{} ({})".format(mtime, mtime.hex()) else: return "{!r} (int)".format(mtime)
def format_mtime(mtime): if isinstance(mtime, float): return "{} ({})".format(mtime, mtime.hex()) else: return "{!r} (int)".format(mtime)
456,849
def test_main(verbose=False): if skip_expected: raise unittest.SkipTest("No SSL support") if support.verbose: plats = { 'Linux': platform.linux_distribution, 'Mac': platform.mac_ver, 'Windows': platform.win32_ver, } for name, func in plats.items(): plat = func() if plat and plat[0]: plat = '%s %r' % (name, plat) break...
def test_main(verbose=False): if skip_expected: raise unittest.SkipTest("No SSL support") if support.verbose: plats = { 'Linux': platform.linux_distribution, 'Mac': platform.mac_ver, 'Windows': platform.win32_ver, } for name, func in plats.items(): plat = func() if plat and plat[0]: plat = '%s %r' % (name, plat) break...
456,850
def test_main(verbose=False): if skip_expected: raise unittest.SkipTest("No SSL support") if support.verbose: plats = { 'Linux': platform.linux_distribution, 'Mac': platform.mac_ver, 'Windows': platform.win32_ver, } for name, func in plats.items(): plat = func() if plat and plat[0]: plat = '%s %r' % (name, plat) break...
def test_main(verbose=False): if skip_expected: raise unittest.SkipTest("No SSL support") if support.verbose: plats = { 'Linux': platform.linux_distribution, 'Mac': platform.mac_ver, 'Windows': platform.win32_ver, } for name, func in plats.items(): plat = func() if plat and plat[0]: plat = '%s %r' % (name, plat) break...
456,851
def test_main(verbose=False): if skip_expected: raise unittest.SkipTest("No SSL support") if support.verbose: plats = { 'Linux': platform.linux_distribution, 'Mac': platform.mac_ver, 'Windows': platform.win32_ver, } for name, func in plats.items(): plat = func() if plat and plat[0]: plat = '%s %r' % (name, plat) break...
def test_main(verbose=False): if skip_expected: raise unittest.SkipTest("No SSL support") if support.verbose: plats = { 'Linux': platform.linux_distribution, 'Mac': platform.mac_ver, 'Windows': platform.win32_ver, } for name, func in plats.items(): plat = func() if plat and plat[0]: plat = '%s %r' % (name, plat) break...
456,852
def __eq__(self, other): return True
def __eq__(self, other): return True
456,853
def test_bad_assignments(self): # XXX testing of T_UINT and T_ULONG temporarily disabled; # see issue 8014. integer_attributes = [ 'T_BOOL', 'T_BYTE', 'T_UBYTE', 'T_SHORT', 'T_USHORT', 'T_INT', #'T_UINT', 'T_LONG', #'T_ULONG', 'T_PYSSIZET' ]
def test_bad_assignments(self): # XXX testing of T_UINT and T_ULONG temporarily disabled; # see issue 8014. integer_attributes = [ 'T_BOOL', 'T_BYTE', 'T_UBYTE', 'T_SHORT', 'T_USHORT', 'T_INT', #'T_UINT', 'T_LONG', #'T_ULONG', 'T_PYSSIZET' ]
456,854
def test_values(self): entries = grp.getgrall()
def test_values(self): entries = grp.getgrall()
456,855
def test_values(self): entries = grp.getgrall()
def test_values(self): entries = grp.getgrall()
456,856
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,857
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 "executable=%r" % sys.executable'], ...
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,858
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 "executable=%r" % sys.executable'], ...
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 "executable=%r" % sys.executable'], ...
456,859
def _gcd_import(name, package=None, level=0): """Import and return the module based on its name, the package the call is being made from, and the level adjustment. This function represents the greatest common denominator of functionality between import_module and __import__. This includes settting __package__ if the l...
def _gcd_import(name, package=None, level=0): """Import and return the module based on its name, the package the call is being made from, and the level adjustment. This function represents the greatest common denominator of functionality between import_module and __import__. This includes settting __package__ if the l...
456,860
def _gcd_import(name, package=None, level=0): """Import and return the module based on its name, the package the call is being made from, and the level adjustment. This function represents the greatest common denominator of functionality between import_module and __import__. This includes settting __package__ if the l...
def _gcd_import(name, package=None, level=0): """Import and return the module based on its name, the package the call is being made from, and the level adjustment. This function represents the greatest common denominator of functionality between import_module and __import__. This includes settting __package__ if the l...
456,861
def test_argumentcheck(self): self.assertRaises(TypeError, self.enum) # no arguments self.assertRaises(TypeError, self.enum, 1) # wrong type (not iterable) self.assertRaises(TypeError, self.enum, 'abc', 'a') # wrong type self.assertRaises(TypeError, self.enum, 'abc', 2, 3) # too many arguments
def test_argumentcheck(self): self.assertRaises(TypeError, self.enum) # no arguments self.assertRaises(TypeError, self.enum, 1) # wrong type (not iterable) self.assertRaises(TypeError, self.enum, 'abc', 'a') # wrong type self.assertRaises(TypeError, self.enum, 'abc', 2, 3) # too many arguments
456,862
def test_range_optimization(self): x = range(1) self.assertEqual(type(reversed(x)), type(iter(x)))
def test_range_optimization(self): x = range(1) self.assertEqual(type(reversed(x)), type(iter(x)))
456,863
def _raise_error(self, condition, explanation = None, *args): """Handles an error
def _raise_error(self, condition, explanation = None, *args): """Handles an error
456,864
def __cmp__(self, other): pass
def __cmp__(self, other): pass
456,865
def __eq__(self, other): pass
def __eq__(self, other): pass
456,866
def __cmp__(self, other): pass
def __cmp__(self, other): pass
456,867
def __eq__(self, other): pass
def __eq__(self, other): pass
456,868
def test_initgroups(self): # find missing group
def test_initgroups(self): # find missing group
456,869
def test_setgroups(self): for groups in [[0], range(16)]: posix.setgroups(groups) self.assertListEqual(groups, posix.getgroups())
def test_setgroups(self): for groups in [[0], list(range(16))]: posix.setgroups(groups) self.assertListEqual(groups, posix.getgroups())
456,870
def do_longlist(self, arg): """longlist | ll List the whole source code for the current function or frame. """ filename = self.curframe.f_code.co_filename breaklist = self.get_file_breaks(filename) try: lines, lineno = inspect.getsourcelines(self.curframe) except IOError as err: self.error(err) return self._print_lines...
def do_longlist(self, arg): """longlist | ll List the whole source code for the current function or frame. """ filename = self.curframe.f_code.co_filename breaklist = self.get_file_breaks(filename) try: lines, lineno = getsourcelines(self.curframe) except IOError as err: self.error(err) return self._print_lines(lines, ...
456,871
def do_source(self, arg): """source expression Try to get source code for the given object and display it. """ try: obj = self._getval(arg) except: return try: lines, lineno = inspect.getsourcelines(obj) except (IOError, TypeError) as err: self.error(err) return self._print_lines(lines, lineno, [], -1, -1)
def do_source(self, arg): """source expression Try to get source code for the given object and display it. """ try: obj = self._getval(arg) except: return try: lines, lineno = getsourcelines(obj) except (IOError, TypeError) as err: self.error(err) return self._print_lines(lines, lineno, [], -1, -1)
456,872
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::
def assertCountEqual(self, actual, expected, msg=None): """An unordered sequence specific comparison. It asserts that actual and expected have the same element counts. Equivalent to::
456,873
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::
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,874
def patchFile(inPath, outPath): data = fileContents(inPath) data = data.replace('$FULL_VERSION', getFullVersion()) data = data.replace('$VERSION', getVersion()) data = data.replace('$MACOSX_DEPLOYMENT_TARGET', ''.join((DEPTARGET, ' or later'))) data = data.replace('$ARCHITECTURES', "i386, ppc") data = data.replace('$IN...
def patchFile(inPath, outPath): data = fileContents(inPath) data = data.replace('$FULL_VERSION', getFullVersion()) data = data.replace('$VERSION', getVersion()) data = data.replace('$MACOSX_DEPLOYMENT_TARGET', ''.join((DEPTARGET, ' or later'))) data = data.replace('$ARCHITECTURES', ", ".join(universal_opts_map[UNIVERSA...
456,875
def check(encoding, bytesfn, unicodefn): encoded = self.get_output(encoding, 'repr(os.fsencode(%a))' % unicodefn) self.assertEqual(encoded, repr(bytesfn))
def check(encoding, bytesfn, unicodefn): encoded = self.get_output(encoding, 'repr(os.fsencode(%a))' % unicodefn) self.assertEqual(encoded, repr(bytesfn))
456,876
def check(encoding, bytesfn, unicodefn): encoded = self.get_output(encoding, 'repr(os.fsencode(%a))' % unicodefn) self.assertEqual(encoded, repr(bytesfn))
def check(encoding, bytesfn, unicodefn): encoded = self.get_output(encoding, 'repr(os.fsencode(%a))' % unicodefn) self.assertEqual(encoded, repr(bytesfn))
456,877
def setUp(self): # Records changes to env vars self.env = support.EnvironmentVarGuard() # Delete all proxy related env vars for k in os.environ.keys(): if k == 'NO_PROXY': self.env.unset(k)
def setUp(self): # Records changes to env vars self.env = support.EnvironmentVarGuard() # Delete all proxy related env vars for k in list(os.environ): if 'proxy' not in k.lower(): self.env.unset(k)
456,878
def _kill(self, sig, *args): # Send a subprocess a signal (or in some cases, just an int to be # the return value) proc = subprocess.Popen(*args) time.sleep(0.5) os.kill(proc.pid, sig) self.assertEqual(proc.wait(), sig)
def _kill(self, sig, *args): # Send a subprocess a signal (or in some cases, just an int to be # the return value) proc = subprocess.Popen(*args) time.sleep(0.5) os.kill(proc.pid, sig) self.assertEqual(proc.wait(), sig)
456,879
def test_kill_sigterm(self): # SIGTERM doesn't mean anything special, but make sure it works self._kill(signal.SIGTERM, [sys.executable])
def test_kill_sigterm(self): # SIGTERM doesn't mean anything special, but make sure it works self._kill(signal.SIGTERM, [sys.executable])
456,880
def test_kill_int(self): # os.kill on Windows can take an int which gets set as the exit code self._kill(100, [sys.executable])
def test_kill_int(self): # os.kill on Windows can take an int which gets set as the exit code self._kill(100, [sys.executable])
456,881
def setUp(self): # Records changes to env vars self.env = support.EnvironmentVarGuard() # Delete all proxy related env vars for k in os.environ.keys(): if 'proxy' in k.lower(): self.env.unset(k)
def setUp(self): # Records changes to env vars self.env = support.EnvironmentVarGuard() # Delete all proxy related env vars for k in os.environ.keys(): if k == 'NO_PROXY': self.env.unset(k)
456,882
def testTanhSign(self): self.assertComplexIdentical(cmath.tanh(complex(0., .0j)), complex(0., .0j)) self.assertComplexIdentical(cmath.tanh(complex(0., -.0j)), complex(0., -.0j)) self.assertComplexIdentical(cmath.tanh(complex(-0., .0j)), complex(-0., .0j)) self.assertComplexIdentical(cmath.tanh(complex(-0., -.0j)), comp...
def testTanhSign(self): self.assertComplexIdentical(cmath.tanh(complex(0., .0j)), complex(0., .0j)) self.assertComplexIdentical(cmath.tanh(complex(0., -.0j)), complex(0., -.0j)) self.assertComplexIdentical(cmath.tanh(complex(-0., .0j)), complex(-0., .0j)) self.assertComplexIdentical(cmath.tanh(complex(-0., -.0j)), comp...
456,883
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 None or not os.path.isdir(dir) or dir in dirlist: return for i, path in enumerate(dirlist): if not os...
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 None or not os.path.isdir(dir) or dir in dirlist: return for i, path in enumerate(dirlist): if not os...
456,884
def send_signal(self, sig): """Send a signal to the process """ if sig == signal.SIGTERM: self.terminate() elif sig == signal.CTRL_C_EVENT: os.kill(self.pid, signal.CTRL_C_EVENT) elif sig == signal.CTRL_BREAK_EVENT: os.kill(self.pid, signal.CTRL_BREAK_EVENT) else: raise ValueError("Only SIGTERM is supported on Windows"...
def send_signal(self, sig): """Send a signal to the process """ if sig == signal.SIGTERM: self.terminate() elif sig == signal.CTRL_C_EVENT: os.kill(self.pid, signal.CTRL_C_EVENT) elif sig == signal.CTRL_BREAK_EVENT: os.kill(self.pid, signal.CTRL_BREAK_EVENT) else: raise ValueError("Only SIGTERM is supported on Windows"...
456,885
def _sequenceIncludes(self, node, results): """operator.contains(%s)""" return self._handle_rename(node, results, "contains")
def _sequenceIncludes(self, node, results): return self._handle_rename(node, results, "contains")
456,886
def _isCallable(self, node, results): """hasattr(%s, '__call__')""" obj = results["obj"] args = [obj.clone(), String(", "), String("'__call__'")] return Call(Name("hasattr"), args, prefix=node.prefix)
def _isCallable(self, node, results): obj = results["obj"] args = [obj.clone(), String(", "), String("'__call__'")] return Call(Name("hasattr"), args, prefix=node.prefix)
456,887
def _repeat(self, node, results): """operator.mul(%s)""" return self._handle_rename(node, results, "mul")
def _repeat(self, node, results): return self._handle_rename(node, results, "mul")
456,888
def _irepeat(self, node, results): """operator.imul(%s)""" return self._handle_rename(node, results, "imul")
def _irepeat(self, node, results): return self._handle_rename(node, results, "imul")
456,889
def _isSequenceType(self, node, results): """isinstance(%s, collections.Sequence)""" return self._handle_type2abc(node, results, "collections", "Sequence")
def _isSequenceType(self, node, results): return self._handle_type2abc(node, results, "collections", "Sequence")
456,890
def _isMappingType(self, node, results): """isinstance(%s, collections.Mapping)""" return self._handle_type2abc(node, results, "collections", "Mapping")
def _isMappingType(self, node, results): return self._handle_type2abc(node, results, "collections", "Mapping")
456,891
def _isNumberType(self, node, results): """isinstance(%s, numbers.Number)""" return self._handle_type2abc(node, results, "numbers", "Number")
def _isNumberType(self, node, results): return self._handle_type2abc(node, results, "numbers", "Number")
456,892
def test_reflection_unsupported(self): try: with CreateKey(HKEY_CURRENT_USER, test_key_name) as ck: self.assertNotEqual(ck.handle, 0)
def test_reflection_unsupported(self): try: with CreateKey(HKEY_CURRENT_USER, test_key_name) as ck: self.assertNotEqual(ck.handle, 0)
456,893
def testUndecodable(self): filename = support.TESTFN_UNENCODABLE + ".zip" z = ZipFile(filename, "w") zinfo = ZipInfo(TESTMOD + ".py", time.localtime(NOW)) zinfo.compress_type = self.compression z.writestr(zinfo, test_src) z.close() try: zipimport.zipimporter(filename) finally: os.remove(filename)
def testUnencodable(self): filename = support.TESTFN_UNENCODABLE + ".zip" z = ZipFile(filename, "w") zinfo = ZipInfo(TESTMOD + ".py", time.localtime(NOW)) zinfo.compress_type = self.compression z.writestr(zinfo, test_src) z.close() try: zipimport.zipimporter(filename) finally: os.remove(filename)
456,894
def checkEnvironment(): """ Check that we're running on a supported system. """ if platform.system() != 'Darwin': fatal("This script should be run on a Mac OS X 10.4 (or later) system") if int(platform.release().split('.')[0]) < 8: fatal("This script should be run on a Mac OS X 10.4 (or later) system") if not os.pat...
def checkEnvironment(): """ Check that we're running on a supported system. """ if platform.system() != 'Darwin': fatal("This script should be run on a Mac OS X 10.4 (or later) system") if int(platform.release().split('.')[0]) < 8: fatal("This script should be run on a Mac OS X 10.4 (or later) system") if not os.pat...
456,895
def checkEnvironment(): """ Check that we're running on a supported system. """ if platform.system() != 'Darwin': fatal("This script should be run on a Mac OS X 10.4 (or later) system") if int(platform.release().split('.')[0]) < 8: fatal("This script should be run on a Mac OS X 10.4 (or later) system") if not os.pat...
def checkEnvironment(): """ Check that we're running on a supported system. """ if platform.system() != 'Darwin': fatal("This script should be run on a Mac OS X 10.4 (or later) system") if int(platform.release().split('.')[0]) < 8: fatal("This script should be run on a Mac OS X 10.4 (or later) system") if not os.pat...
456,896
def buildPython(): print "Building a universal python for %s architectures" % UNIVERSALARCHS buildDir = os.path.join(WORKDIR, '_bld', 'python') rootDir = os.path.join(WORKDIR, '_root') if os.path.exists(buildDir): shutil.rmtree(buildDir) if os.path.exists(rootDir): shutil.rmtree(rootDir) os.mkdir(buildDir) os.mkdir(r...
def buildPython(): print "Building a universal python for %s architectures" % UNIVERSALARCHS buildDir = os.path.join(WORKDIR, '_bld', 'python') rootDir = os.path.join(WORKDIR, '_root') if os.path.exists(buildDir): shutil.rmtree(buildDir) if os.path.exists(rootDir): shutil.rmtree(rootDir) os.mkdir(buildDir) os.mkdir(r...
456,897
def test_attrgetter(self): class A: pass a = A() a.name = 'arthur' f = operator.attrgetter('name') self.assertEqual(f(a), 'arthur') f = operator.attrgetter('rank') self.assertRaises(AttributeError, f, a) f = operator.attrgetter(2) self.assertRaises(TypeError, f, a) self.assertRaises(TypeError, operator.attrgetter)
def test_attrgetter(self): class A: pass a = A() a.name = 'arthur' f = operator.attrgetter('name') self.assertEqual(f(a), 'arthur') f = operator.attrgetter('rank') self.assertRaises(AttributeError, f, a) self.assertRaises(TypeError, operator.attrgetter, 2) self.assertRaises(TypeError, operator.attrgetter)
456,898
def test_attrgetter(self): class A: pass a = A() a.name = 'arthur' f = operator.attrgetter('name') self.assertEqual(f(a), 'arthur') f = operator.attrgetter('rank') self.assertRaises(AttributeError, f, a) f = operator.attrgetter(2) self.assertRaises(TypeError, f, a) self.assertRaises(TypeError, operator.attrgetter)
def test_attrgetter(self): class A: pass a = A() a.name = 'arthur' f = operator.attrgetter('name') self.assertEqual(f(a), 'arthur') f = operator.attrgetter('rank') self.assertRaises(AttributeError, f, a) f = operator.attrgetter(2) self.assertRaises(TypeError, f, a) self.assertRaises(TypeError, operator.attrgetter)
456,899