bugged stringlengths 4 228k | fixed stringlengths 0 96.3M | __index_level_0__ int64 0 481k |
|---|---|---|
def __init__(self, start = 0, end = 0): if start > end or start < 0 or end < 0: gterror("range error: start > end!") super(Range, self).__init__(start, end) | def __init__(self, start = 0, end = 0): if start > end or start < 0 or end < 0: gterror("range error: start > end!") super(Range, self).__init__(start, end) | 456,200 |
def start(self): return self.w_start | def start(self): return self.w_start | 456,201 |
def start(self, val): if val > self.end or not val >= 0: gterror("Invalid range start component: %d" % val) self.w_start = val | def start(self, val): if val > self.end or not val >= 0: gterror("Invalid range start component: %d" % val) self.w_start = val | 456,202 |
def end(self): return self.w_end | def end(self): return self.w_end | 456,203 |
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,204 |
def test_main(): if sys.platform == "win32": support.run_unittest(WindowsSignalTests) else: support.run_unittest(BasicSignalTests, InterProcessSignalTests, WakeupSignalTests, SiginterruptTest, ItimerTest) | def test_main(): support.run_unittest(BasicSignalTests, InterProcessSignalTests, WakeupSignalTests, SiginterruptTest, ItimerTest, WindowsSignalTests) | 456,205 |
def check_node(self, node, source): individual_group_bit = (node >> 40L) & 1 universal_local_bit = (node >> 40L) & 2 message = "%012x doesn't look like a real MAC address" % node self.assertEqual(individual_group_bit, 0, message) self.assertEqual(universal_local_bit, 0, message) self.assertNotEqual(node, 0, message) se... | def check_node(self, node, source): message = "%012x is not an RFC 4122 node ID" % node self.assertTrue(0 < node, message) self.assertTrue(node < (1L << 48), message) | 456,206 |
def test_ifconfig_getnode(self): import sys print >>sys.__stdout__, \ | def test_ifconfig_getnode(self): import sys print >>sys.__stdout__, \ | 456,207 |
def test_random_getnode(self): node = uuid._random_getnode() self.assertTrue(0 <= node) self.assertTrue(node < (1L <<48)) | def test_random_getnode(self): node = uuid._random_getnode() self.assertTrue(0 <= node) self.assertTrue(node < (1L <<48)) | 456,208 |
def test_unixdll_getnode(self): import sys print >>sys.__stdout__, \ | def test_unixdll_getnode(self): import sys print >>sys.__stdout__, \ | 456,209 |
def test_unixdll_getnode(self): import sys print >>sys.__stdout__, \ | def test_unixdll_getnode(self): import sys print >>sys.__stdout__, \ | 456,210 |
def test_getnode(self): import sys print >>sys.__stdout__, \ | def test_getnode(self): import sys print >>sys.__stdout__, \ | 456,211 |
def query_vcvarsall(version, arch="x86"): """Launch vcvarsall.bat and read the settings from its environment """ vcvarsall = find_vcvarsall(version) interesting = set(("include", "lib", "libpath", "path")) result = {} if vcvarsall is None: raise DistutilsPlatformError("Unable to find vcvarsall.bat") log.debug("Calling... | def query_vcvarsall(version, arch="x86"): """Launch vcvarsall.bat and read the settings from its environment """ vcvarsall = find_vcvarsall(version) interesting = set(("include", "lib", "libpath", "path")) result = {} if vcvarsall is None: raise DistutilsPlatformError("Unable to find vcvarsall.bat") log.debug("Calling... | 456,212 |
def set_continue(self): # Don't stop except at breakpoints or when finished self._set_stopinfo(self.botframe, None, -1) if not self.breaks and not self.watching: # no breakpoints; run without debugger overhead sys.settrace(None) frame = sys._getframe().f_back while frame and frame is not self.botframe: del frame.f_trac... | def set_continue(self): # Don't stop except at breakpoints or when finished self._set_stopinfo(self.botframe, None, -1) if not self.breaks: # no breakpoints; run without debugger overhead sys.settrace(None) frame = sys._getframe().f_back while frame and frame is not self.botframe: del frame.f_trace frame = frame.f_back | 456,213 |
def CheckPragmaAutocommit(self): """ Verifies that running a PRAGMA statement that does an autocommit does work. This did not work in 2.5.3/2.5.4. """ con = sqlite.connect(":memory:") cur = con.cursor() cur.execute("create table foo(bar)") cur.execute("insert into foo(bar) values (5)") | def CheckPragmaAutocommit(self): """ Verifies that running a PRAGMA statement that does an autocommit does work. This did not work in 2.5.3/2.5.4. """ cur = self.con.cursor() cur.execute("create table foo(bar)") cur.execute("insert into foo(bar) values (5)") | 456,214 |
def __hash__(self): raise TypeError() | def __hash__(self): raise TypeError() | 456,215 |
def test_stat_attributes(self): if not hasattr(os, "stat"): return | def check_stat_attributes(self, fname): if not hasattr(os, "stat"): return | 456,216 |
def test_stat_attributes(self): if not hasattr(os, "stat"): return | def test_stat_attributes(self): if not hasattr(os, "stat"): return | 456,217 |
def test_getgroups(self): with os.popen('id -G') as idg: groups = idg.read().strip() | def test_getgroups(self): with os.popen('id -G') as idg: groups = idg.read().strip() | 456,218 |
def eval_file(self, file): global skip_expected if skip_expected: raise unittest.SkipTest return for line in open(file).xreadlines(): line = line.replace('\r\n', '').replace('\n', '') #print line try: t = self.eval_line(line) except DecimalException, exception: #Exception raised where there shoudn't have been one. self... | def eval_file(self, file): global skip_expected if skip_expected: raise unittest.SkipTest return for line in open(file): line = line.replace('\r\n', '').replace('\n', '') #print line try: t = self.eval_line(line) except DecimalException, exception: #Exception raised where there shoudn't have been one. self.fail('Except... | 456,219 |
def FixQuotes(val): val = val.replace("''", 'SingleQuote').replace('""', 'DoubleQuote') val = val.replace("'", '').replace('"', '') val = val.replace('SingleQuote', "'").replace('DoubleQuote', '"') return val | def FixQuotes(val): val = val.replace("''", 'SingleQuote').replace('""', 'DoubleQuote') val = val.replace("'", '').replace('"', '') val = val.replace('SingleQuote', "'").replace('DoubleQuote', '"') return val | 456,220 |
def FixQuotes(val): val = val.replace("''", 'SingleQuote').replace('""', 'DoubleQuote') val = val.replace("'", '').replace('"', '') val = val.replace('SingleQuote', "'").replace('DoubleQuote', '"') return val | def FixQuotes(val): val = val.replace("''", 'SingleQuote').replace('""', 'DoubleQuote') val = val.replace("'", '').replace('"', '') val = val.replace('SingleQuote', "'").replace('DoubleQuote', '"') return val | 456,221 |
def __ne__(self, other): return 'ne ' + str(other) | def __ne__(self, other): return 'ne ' + str(other) | 456,222 |
def test_comparison_operators(self): | def test_comparison_operators(self): | 456,223 |
def test_flags_irrelevant(self): # check that the result (numeric result + flags raised) of an # arithmetic operation doesn't depend on the current flags | def test_flags_irrelevant(self): # check that the result (numeric result + flags raised) of an # arithmetic operation doesn't depend on the current flags | 456,224 |
def test_flags_irrelevant(self): # check that the result (numeric result + flags raised) of an # arithmetic operation doesn't depend on the current flags | def test_flags_irrelevant(self): # check that the result (numeric result + flags raised) of an # arithmetic operation doesn't depend on the current flags | 456,225 |
def test_flags_irrelevant(self): # check that the result (numeric result + flags raised) of an # arithmetic operation doesn't depend on the current flags | def test_flags_irrelevant(self): # check that the result (numeric result + flags raised) of an # arithmetic operation doesn't depend on the current flags | 456,226 |
def setUp(self): BaseTestCase.setUp(self) self.cwd = os.getcwd() self.parent_dir = tempfile.mkdtemp() self.cgi_dir = os.path.join(self.parent_dir, 'cgi-bin') os.mkdir(self.cgi_dir) self.file1_path = None self.file2_path = None | def setUp(self): BaseTestCase.setUp(self) self.cwd = os.getcwd() self.parent_dir = tempfile.mkdtemp() self.cgi_dir = os.path.join(self.parent_dir, 'cgi-bin') os.mkdir(self.cgi_dir) self.file1_path = None self.file2_path = None | 456,227 |
def tearDown(self): for inst in popen2._active: inst.wait() popen2._cleanup() self.assertFalse(popen2._active, "_active not empty") reap_children() | def tearDown(self): for inst in popen2._active: inst.wait() popen2._cleanup() self.assertFalse(popen2._active, "popen2._active not empty") import subprocess for inst in subprocess._active: inst.wait() subprocess._cleanup() self.assertFalse(subprocess._active, "subprocess._active not empty") reap_children() | 456,228 |
def __init__(self, modules = None, dirs = None): self._mods = modules or [] self._dirs = dirs or [] | def __init__(self, modules = None, dirs = None): self._mods = modules or [] self._dirs = dirs or [] | 456,229 |
def mkpath(name, mode=0o777, verbose=1, dry_run=0): """Create a directory and any missing ancestor directories. If the directory already exists (or if 'name' is the empty string, which means the current directory, which of course exists), then do nothing. Raise DistutilsFileError if unable to create some directory alo... | def mkpath(name, mode=0o777, verbose=1, dry_run=0): """Create a directory and any missing ancestor directories. If the directory already exists (or if 'name' is the empty string, which means the current directory, which of course exists), then do nothing. Raise DistutilsFileError if unable to create some directory alo... | 456,230 |
def mkpath(name, mode=0o777, verbose=1, dry_run=0): """Create a directory and any missing ancestor directories. If the directory already exists (or if 'name' is the empty string, which means the current directory, which of course exists), then do nothing. Raise DistutilsFileError if unable to create some directory alo... | def mkpath(name, mode=0o777, verbose=1, dry_run=0): """Create a directory and any missing ancestor directories. If the directory already exists (or if 'name' is the empty string, which means the current directory, which of course exists), then do nothing. Raise DistutilsFileError if unable to create some directory alo... | 456,231 |
def check_match(self, filename, pattern, should_match=1): if should_match: self.assertTrue(fnmatch(filename, pattern), "expected %r to match pattern %r" % (filename, pattern)) else: self.assertTrue(not fnmatch(filename, pattern), "expected %r not to match pattern %r" % (filename, pattern)) | def check_match(self, filename, pattern, should_match=1, fn=fnmatch): if should_match: self.assertTrue(fnmatch(filename, pattern), "expected %r to match pattern %r" % (filename, pattern)) else: self.assertTrue(not fnmatch(filename, pattern), "expected %r not to match pattern %r" % (filename, pattern)) | 456,232 |
def check_match(self, filename, pattern, should_match=1): if should_match: self.assertTrue(fnmatch(filename, pattern), "expected %r to match pattern %r" % (filename, pattern)) else: self.assertTrue(not fnmatch(filename, pattern), "expected %r not to match pattern %r" % (filename, pattern)) | def check_match(self, filename, pattern, should_match=1): if should_match: self.assertTrue(fn(filename, pattern), "expected %r to match pattern %r" % (filename, pattern)) else: self.assertTrue(not fnmatch(filename, pattern), "expected %r not to match pattern %r" % (filename, pattern)) | 456,233 |
def check_match(self, filename, pattern, should_match=1): if should_match: self.assertTrue(fnmatch(filename, pattern), "expected %r to match pattern %r" % (filename, pattern)) else: self.assertTrue(not fnmatch(filename, pattern), "expected %r not to match pattern %r" % (filename, pattern)) | def check_match(self, filename, pattern, should_match=1): if should_match: self.assertTrue(fnmatch(filename, pattern), "expected %r to match pattern %r" % (filename, pattern)) else: self.assertTrue(not fn(filename, pattern), "expected %r not to match pattern %r" % (filename, pattern)) | 456,234 |
def test_fnmatchcase(self): check = self.check_match check('AbC', 'abc', 0) check('abc', 'AbC', 0) | def test_fnmatchcase(self): check = self.check_match check('AbC', 'abc', 0) check('abc', 'AbC', 0) | 456,235 |
def close(self): self._sock = _closedsocket() dummy = self._sock._dummy for method in _delegate_methods: setattr(self, method, dummy) | def close(self, _closedsocket=_closedsocket, _delegate_methods=_delegate_methods, setattr=setattr): self._sock = _closedsocket() dummy = self._sock._dummy for method in _delegate_methods: setattr(self, method, dummy) | 456,236 |
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 u"": return True else: return False except WindowsError: ... | 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... | 456,237 |
def ssl(self): """Return SSLObject instance used to communicate with the IMAP4 server. | def ssl(self): """Return SSLObject instance used to communicate with the IMAP4 server. | 456,238 |
def setUp(self): self.test_dir = tempfile.mkdtemp() sys.path.append(self.test_dir) self.package_dir = os.path.join(self.test_dir, self.package_name) os.mkdir(self.package_dir) open(os.path.join(self.package_dir, '__init__.py'), 'w') self.module_path = os.path.join(self.package_dir, 'foo.py') | def setUp(self): self.test_dir = tempfile.mkdtemp() sys.path.append(self.test_dir) self.package_dir = os.path.join(self.test_dir, self.package_name) os.mkdir(self.package_dir) open(os.path.join(self.package_dir, '__init__.py'), 'w').close() self.module_path = os.path.join(self.package_dir, 'foo.py') | 456,239 |
def makeAddPair((a, b)): def addPair((c, d)): return (a + c, b + d) return addPair | def makeAddPair((a, b)): def addPair((c, d)): return (a + c, b + d) return addPair | 456,240 |
def h(z): return y + z | def h(z): return y + z | 456,241 |
def test_main(): run_unittest(ScopeTests) | def test_main(): with check_warnings(("import \* only allowed at module level", SyntaxWarning)): run_unittest(ScopeTests) | 456,242 |
def readwrite(obj, flags): try: if flags & select.POLLIN: obj.handle_read_event() if flags & select.POLLOUT: obj.handle_write_event() if flags & (select.POLLHUP | select.POLLERR | select.POLLNVAL): obj.handle_close() if flags & select.POLLPRI: obj.handle_expt_event() except _reraised_exceptions: raise except: obj.handl... | def readwrite(obj, flags): try: if flags & select.POLLIN: obj.handle_read_event() if flags & select.POLLOUT: obj.handle_write_event() if flags & (select.POLLHUP | select.POLLERR | select.POLLNVAL): obj.handle_close() except socket.error, e: if e.args[0] not in (EBADF, ECONNRESET, ENOTCONN, ESHUTDOWN, ECONNABORTED): obj... | 456,243 |
def remove_duplicates(lst): """remove_duplicates([2,2,2,1,3,3]) => [3,1,2] Returns a copy of a list without duplicates. Every list item must be hashable and the order of the items in the resulting list is not defined. """ u = {} for x in lst: u[x] = 1 return u.keys() | def remove_duplicates(lst): """remove_duplicates([2,2,2,1,3,3]) => [3,1,2] Returns a copy of a list without duplicates. Every list item must be hashable and the order of the items in the resulting list is not defined. """ u = {} for x in lst: u[x] = 1 return u.keys() | 456,244 |
def _testFamily(self): self.cli = socket.create_connection((HOST, self.port), timeout=30) self.assertEqual(self.cli.family, 2) | def _testFamily(self): self.cli = socket.create_connection((HOST, self.port), timeout=30) self.assertEqual(self.cli.family, 2) | 456,245 |
def _testSourcePort(self): self.cli = socket.create_connection((HOST, self.port), timeout=30, source_address=('', self.source_port)) self.assertEqual(self.cli.getsockname()[1], self.source_port) | def _testSourcePort(self): self.cli = socket.create_connection((HOST, self.port), timeout=30, source_address=('', self.source_port)) self.assertEqual(self.cli.getsockname()[1], self.source_port) | 456,246 |
def test_decompressobj_badflush(self): # verify failure on calling decompressobj.flush with bad params self.assertRaises(ValueError, zlib.decompressobj().flush, 0) self.assertRaises(ValueError, zlib.decompressobj().flush, -1) | def test_decompressobj_badflush(self): # verify failure on calling decompressobj.flush with bad params self.assertRaises(ValueError, zlib.decompressobj().flush, 0) self.assertRaises(ValueError, zlib.decompressobj().flush, -1) | 456,247 |
def test_speech128(self): # compress more data data = HAMLET_SCENE * 128 x = zlib.compress(data) self.assertEqual(zlib.decompress(x), data) | def test_speech128(self): # compress more data data = HAMLET_SCENE * 128 x = zlib.compress(data) self.assertEqual(zlib.decompress(x), data) | 456,248 |
def _terminate_pool(cls, taskqueue, inqueue, outqueue, pool, worker_handler, task_handler, result_handler, cache): # this is guaranteed to only be called once debug('finalizing pool') | def _terminate_pool(cls, taskqueue, inqueue, outqueue, pool, worker_handler, task_handler, result_handler, cache): # this is guaranteed to only be called once debug('finalizing pool') | 456,249 |
def _open_generic_http(self, connection_factory, url, data): """Make an HTTP connection using connection_class. | def _open_generic_http(self, connection_factory, url, data): """Make an HTTP connection using connection_class. | 456,250 |
def _open_generic_http(self, connection_factory, url, data): """Make an HTTP connection using connection_class. | def _open_generic_http(self, connection_factory, url, data): """Make an HTTP connection using connection_class. | 456,251 |
def test_format(self): testboth("%.1d", (1,), "1") testboth("%.*d", (sys.maxint,1), overflowok = True) # expect overflow testboth("%.100d", (1,), '00000000000000000000000000000000000000' '000000000000000000000000000000000000000000000000000000' '00000001', overflowok = True) testboth("%#.117x", (1,), '0x000000000000000... | def test_format(self): testboth("%.1d", (1,), "1") testboth("%.*d", (sys.maxint,1), overflowok=True) # expect overflow testboth("%.100d", (1,), '00000000000000000000000000000000000000' '000000000000000000000000000000000000000000000000000000' '00000001', overflowok = True) testboth("%#.117x", (1,), '0x00000000000000000... | 456,252 |
def test_format(self): testboth("%.1d", (1,), "1") testboth("%.*d", (sys.maxint,1), overflowok = True) # expect overflow testboth("%.100d", (1,), '00000000000000000000000000000000000000' '000000000000000000000000000000000000000000000000000000' '00000001', overflowok = True) testboth("%#.117x", (1,), '0x000000000000000... | def test_format(self): testboth("%.1d", (1,), "1") testboth("%.*d", (sys.maxint,1), overflowok = True) # expect overflow testboth("%.100d", (1,), '00000000000000000000000000000000000000' '000000000000000000000000000000000000000000000000000000' '00000001', overflowok=True) testboth("%#.117x", (1,), '0x00000000000000000... | 456,253 |
def test_format(self): testboth("%.1d", (1,), "1") testboth("%.*d", (sys.maxint,1), overflowok = True) # expect overflow testboth("%.100d", (1,), '00000000000000000000000000000000000000' '000000000000000000000000000000000000000000000000000000' '00000001', overflowok = True) testboth("%#.117x", (1,), '0x000000000000000... | def test_format(self): testboth("%.1d", (1,), "1") testboth("%.*d", (sys.maxint,1), overflowok=True) # expect overflow testboth("%.100d", (1,), '00000000000000000000000000000000000000' '000000000000000000000000000000000000000000000000000000' '00000001', overflowok=True) testboth("%#.117x", (1,), '0x0000000000000000000... | 456,254 |
def test_format(self): testboth("%.1d", (1,), "1") testboth("%.*d", (sys.maxint,1), overflowok = True) # expect overflow testboth("%.100d", (1,), '00000000000000000000000000000000000000' '000000000000000000000000000000000000000000000000000000' '00000001', overflowok = True) testboth("%#.117x", (1,), '0x000000000000000... | def test_format(self): testboth("%.1d", (1,), "1") testboth("%.*d", (sys.maxint,1), overflowok=True) # expect overflow testboth("%.100d", (1,), '00000000000000000000000000000000000000' '000000000000000000000000000000000000000000000000000000' '00000001', overflowok=True) testboth("%#.117x", (1,), '0x0000000000000000000... | 456,255 |
def encode(in_file, out_file, name=None, mode=None): """Uuencode file""" # # If in_file is a pathname open it and change defaults # if in_file == '-': in_file = sys.stdin.buffer elif isinstance(in_file, str): if name is None: name = os.path.basename(in_file) if mode is None: try: mode = os.stat(in_file).st_mode except ... | def encode(in_file, out_file, name=None, mode=None): """Uuencode file""" # # If in_file is a pathname open it and change defaults # opened_files = [] try: if in_file == '-': in_file = sys.stdin.buffer elif isinstance(in_file, str): if name is None: name = os.path.basename(in_file) if mode is None: try: mode = os.stat(i... | 456,256 |
def encode(in_file, out_file, name=None, mode=None): """Uuencode file""" # # If in_file is a pathname open it and change defaults # if in_file == '-': in_file = sys.stdin.buffer elif isinstance(in_file, str): if name is None: name = os.path.basename(in_file) if mode is None: try: mode = os.stat(in_file).st_mode except ... | def encode(in_file, out_file, name=None, mode=None): """Uuencode file""" # # If in_file is a pathname open it and change defaults # if in_file == '-': in_file = sys.stdin.buffer elif isinstance(in_file, str): if name is None: name = '-' if mode is None: try: mode = os.stat(in_file).st_mode except AttributeError: pass i... | 456,257 |
def encode(in_file, out_file, name=None, mode=None): """Uuencode file""" # # If in_file is a pathname open it and change defaults # if in_file == '-': in_file = sys.stdin.buffer elif isinstance(in_file, str): if name is None: name = os.path.basename(in_file) if mode is None: try: mode = os.stat(in_file).st_mode except ... | def encode(in_file, out_file, name=None, mode=None): """Uuencode file""" # # If in_file is a pathname open it and change defaults # if in_file == '-': in_file = sys.stdin.buffer elif isinstance(in_file, str): if name is None: name = os.path.basename(in_file) if mode is None: try: mode = os.stat(in_file).st_mode except ... | 456,258 |
def encode(in_file, out_file, name=None, mode=None): """Uuencode file""" # # If in_file is a pathname open it and change defaults # if in_file == '-': in_file = sys.stdin.buffer elif isinstance(in_file, str): if name is None: name = os.path.basename(in_file) if mode is None: try: mode = os.stat(in_file).st_mode except ... | def encode(in_file, out_file, name=None, mode=None): """Uuencode file""" # # If in_file is a pathname open it and change defaults # if in_file == '-': in_file = sys.stdin.buffer elif isinstance(in_file, str): if name is None: name = os.path.basename(in_file) if mode is None: try: mode = os.stat(in_file).st_mode except ... | 456,259 |
def encode_plain(user, password): s = "\0%s\0%s" % (user, password) return encode_base64(s.encode('ascii'), eol='') | def encode_plain(user, password): s = "\0%s\0%s" % (user, password) return encode_base64(s.encode('ascii'), eol='') | 456,260 |
def encode_plain(user, password): s = "\0%s\0%s" % (user, password) return encode_base64(s.encode('ascii'), eol='') | def encode_plain(user, password): s = "\0%s\0%s" % (user, password) return encode_base64(s.encode('ascii'), eol='') | 456,261 |
def encode_plain(user, password): s = "\0%s\0%s" % (user, password) return encode_base64(s.encode('ascii'), eol='') | def encode_plain(user, password): s = "\0%s\0%s" % (user, password) return encode_base64(s.encode('ascii'), eol='') | 456,262 |
def encode_plain(user, password): s = "\0%s\0%s" % (user, password) return encode_base64(s.encode('ascii'), eol='') | def encode_plain(user, password): s = "\0%s\0%s" % (user, password) return encode_base64(s.encode('ascii'), eol='') | 456,263 |
def main(): # turn off warnings when deprecated modules are imported import warnings warnings.filterwarnings("ignore",category=DeprecationWarning) setup(# PyPI Metadata (PEP 301) name = "Python", version = sys.version.split()[0], url = "http://www.python.org/%s" % sys.version[:3], maintainer = "Guido van Rossum and the... | def main(): # turn off warnings when deprecated modules are imported import warnings warnings.filterwarnings("ignore",category=DeprecationWarning) setup(# PyPI Metadata (PEP 301) name = "Python", version = sys.version.split()[0], url = "http://www.python.org/%s" % sys.version[:3], maintainer = "Guido van Rossum and the... | 456,264 |
def main(): silent = 0 verbose = 0 if sys.argv[1:]: if sys.argv[1] == '-v': verbose = 1 elif sys.argv[1] == '-s': silent = 1 MAGIC = imp.get_magic() if not silent: print('Using MAGIC word', repr(MAGIC)) for dirname in sys.path: try: names = os.listdir(dirname) except os.error: print('Cannot list directory', repr(dirnam... | def main(): if len(sys.argv) > 1: verbose = (sys.argv[1] == '-v') silent = (sys.argv[1] == '-s') else: verbose = silent = False MAGIC = imp.get_magic() if not silent: print('Using MAGIC word', repr(MAGIC)) for dirname in sys.path: try: names = os.listdir(dirname) except os.error: print('Cannot list directory', repr(dir... | 456,265 |
def main(): silent = 0 verbose = 0 if sys.argv[1:]: if sys.argv[1] == '-v': verbose = 1 elif sys.argv[1] == '-s': silent = 1 MAGIC = imp.get_magic() if not silent: print('Using MAGIC word', repr(MAGIC)) for dirname in sys.path: try: names = os.listdir(dirname) except os.error: print('Cannot list directory', repr(dirnam... | def main(): silent = 0 verbose = 0 if sys.argv[1:]: if sys.argv[1] == '-v': verbose = 1 elif sys.argv[1] == '-s': silent = 1 MAGIC = imp.get_magic() if not silent: print('Using MAGIC word', repr(MAGIC)) for dirname in sys.path: try: names = os.listdir(dirname) except os.error: print('Cannot list directory', repr(dirnam... | 456,266 |
def main(): silent = 0 verbose = 0 if sys.argv[1:]: if sys.argv[1] == '-v': verbose = 1 elif sys.argv[1] == '-s': silent = 1 MAGIC = imp.get_magic() if not silent: print('Using MAGIC word', repr(MAGIC)) for dirname in sys.path: try: names = os.listdir(dirname) except os.error: print('Cannot list directory', repr(dirnam... | def main(): silent = 0 verbose = 0 if sys.argv[1:]: if sys.argv[1] == '-v': verbose = 1 elif sys.argv[1] == '-s': silent = 1 MAGIC = imp.get_magic() if not silent: print('Using MAGIC word', repr(MAGIC)) for dirname in sys.path: try: names = os.listdir(dirname) except os.error: print('Cannot list directory', repr(dirnam... | 456,267 |
def main(): silent = 0 verbose = 0 if sys.argv[1:]: if sys.argv[1] == '-v': verbose = 1 elif sys.argv[1] == '-s': silent = 1 MAGIC = imp.get_magic() if not silent: print('Using MAGIC word', repr(MAGIC)) for dirname in sys.path: try: names = os.listdir(dirname) except os.error: print('Cannot list directory', repr(dirnam... | def main(): silent = 0 verbose = 0 if sys.argv[1:]: if sys.argv[1] == '-v': verbose = 1 elif sys.argv[1] == '-s': silent = 1 MAGIC = imp.get_magic() if not silent: print('Using MAGIC word', repr(MAGIC)) for dirname in sys.path: try: names = os.listdir(dirname) except os.error: print('Cannot list directory', repr(dirnam... | 456,268 |
def main(): silent = 0 verbose = 0 if sys.argv[1:]: if sys.argv[1] == '-v': verbose = 1 elif sys.argv[1] == '-s': silent = 1 MAGIC = imp.get_magic() if not silent: print('Using MAGIC word', repr(MAGIC)) for dirname in sys.path: try: names = os.listdir(dirname) except os.error: print('Cannot list directory', repr(dirnam... | def main(): silent = 0 verbose = 0 if sys.argv[1:]: if sys.argv[1] == '-v': verbose = 1 elif sys.argv[1] == '-s': silent = 1 MAGIC = imp.get_magic() if not silent: print('Using MAGIC word', repr(MAGIC)) for dirname in sys.path: try: names = os.listdir(dirname) except os.error: print('Cannot list directory', repr(dirnam... | 456,269 |
def main(): silent = 0 verbose = 0 if sys.argv[1:]: if sys.argv[1] == '-v': verbose = 1 elif sys.argv[1] == '-s': silent = 1 MAGIC = imp.get_magic() if not silent: print('Using MAGIC word', repr(MAGIC)) for dirname in sys.path: try: names = os.listdir(dirname) except os.error: print('Cannot list directory', repr(dirnam... | def main(): silent = 0 verbose = 0 if sys.argv[1:]: if sys.argv[1] == '-v': verbose = 1 elif sys.argv[1] == '-s': silent = 1 MAGIC = imp.get_magic() if not silent: print('Using MAGIC word', repr(MAGIC)) for dirname in sys.path: try: names = os.listdir(dirname) except os.error: print('Cannot list directory', repr(dirnam... | 456,270 |
def get_long(s): if len(s) != 4: return -1 return ord(s[0]) + (ord(s[1])<<8) + (ord(s[2])<<16) + (ord(s[3])<<24) | def get_long(s): if len(s) != 4: return -1 return s[0] + (s[1] << 8) + (s[2] << 16) + (s[3] << 24) | 456,271 |
def test_send_signal(self): p = subprocess.Popen([sys.executable, "-c", "input()"]) | def test_send_signal(self): p = subprocess.Popen([sys.executable, "-c", "input()"]) | 456,272 |
def test_send_signal(self): p = subprocess.Popen([sys.executable, "-c", "input()"]) | def test_send_signal(self): p = subprocess.Popen([sys.executable, "-c", "input()"]) | 456,273 |
def test_kill(self): p = subprocess.Popen([sys.executable, "-c", "input()"]) | def test_kill(self): p = subprocess.Popen([sys.executable, "-c", "input()"]) | 456,274 |
def test_terminate(self): p = subprocess.Popen([sys.executable, "-c", "input()"]) | def test_terminate(self): p = subprocess.Popen([sys.executable, "-c", "input()"]) | 456,275 |
def latin(s): return s.encode('latin') | def latin(s): return s.encode('latin') | 456,276 |
def _test(self, values): for sv, cv in zip(values, self.codes_values): sv.value = cv[2] | def _test(self, values): for sv, cv in zip(values, self.codes_values): sv.value = cv[2] | 456,277 |
def test_value(self, raw=False): if raw: values = [self.RawValue(code, value) for code, value, _ in self.codes_values] else: values = [self.Value(code, value) for code, value, _ in self.codes_values] | def test_value(self, raw=False): if raw: values = [self.RawValue(code, value) for code, value, _ in self.codes_values] else: values = [self.Value(code, value) for code, value, _ in self.codes_values] | 456,278 |
def test_rawvalue(self): self.test_value(raw=True) | def test_rawvalue(self): self.test_value(raw=True) | 456,279 |
def _double(self, x, y, foo, arr, string): x.value *= 2 y.value *= 2 foo.x *= 2 foo.y *= 2 string.value *= 2 for i in range(len(arr)): arr[i] *= 2 | def _double(self, x, y, foo, arr, string): x.value *= 2 y.value *= 2 foo.x *= 2 foo.y *= 2 string.value *= 2 for i in range(len(arr)): arr[i] *= 2 | 456,280 |
def test_sharedctypes(self, lock=False): x = Value('i', 7, lock=lock) y = Value(c_double, 1.0/3.0, lock=lock) foo = Value(_Foo, 3, 2, lock=lock) arr = self.Array('d', list(range(10)), lock=lock) string = self.Array('c', 20, lock=lock) string.value = 'hello' | def test_sharedctypes(self, lock=False): x = Value('i', 7, lock=lock) y = Value(c_double, 1.0/3.0, lock=lock) foo = Value(_Foo, 3, 2, lock=lock) arr = self.Array('d', list(range(10)), lock=lock) string = self.Array('c', 20, lock=lock) string.value = 'hello' | 456,281 |
def test_sharedctypes(self, lock=False): x = Value('i', 7, lock=lock) y = Value(c_double, 1.0/3.0, lock=lock) foo = Value(_Foo, 3, 2, lock=lock) arr = self.Array('d', list(range(10)), lock=lock) string = self.Array('c', 20, lock=lock) string.value = 'hello' | def test_sharedctypes(self, lock=False): x = Value('i', 7, lock=lock) y = Value(c_double, 1.0/3.0, lock=lock) foo = Value(_Foo, 3, 2, lock=lock) arr = self.Array('d', list(range(10)), lock=lock) string = self.Array('c', 20, lock=lock) string.value = 'hello' | 456,282 |
def test_synchronize(self): self.test_sharedctypes(lock=True) | def test_synchronize(self): self.test_sharedctypes(lock=True) | 456,283 |
def test_copy(self): foo = _Foo(2, 5.0) bar = ctypes_copy(foo) foo.x = 0 foo.y = 0 self.assertEqual(bar.x, 2) self.assertAlmostEqual(bar.y, 5.0) | def test_copy(self): foo = _Foo(2, 5.0) bar = copy(foo) foo.x = 0 foo.y = 0 self.assertEqual(bar.x, 2) self.assertAlmostEqual(bar.y, 5.0) | 456,284 |
def test_constructor_type_errors(self): self.assertRaises(TypeError, self.type2test, 0.0) class C: pass # allowed in 2.6 #self.assertRaises(TypeError, self.type2test, ["0"]) self.assertRaises(TypeError, self.type2test, [0.0]) self.assertRaises(TypeError, self.type2test, [None]) self.assertRaises(TypeError, self.type2te... | def test_constructor_type_errors(self): self.assertRaises(TypeError, self.type2test, 0.0) class C: pass # allowed in 2.6 #self.assertRaises(TypeError, self.type2test, ["0"]) self.assertRaises(TypeError, self.type2test, [0.0]) self.assertRaises(TypeError, self.type2test, [None]) self.assertRaises(TypeError, self.type2te... | 456,285 |
def test_index(self): b = self.type2test(b'parrot') self.assertEqual(b.index('p'), 0) self.assertEqual(b.index('rr'), 2) self.assertEqual(b.index('t'), 5) self.assertRaises(ValueError, lambda: b.index('w')) | def test_index(self): b = self.type2test(b'parrot') self.assertEqual(b.index('p'), 0) self.assertEqual(b.index('rr'), 2) self.assertEqual(b.index('t'), 5) self.assertRaises(ValueError, lambda: b.index('w')) | 456,286 |
def test_rsplit_unicodewhitespace(self): b = self.type2test(b"\x09\x0A\x0B\x0C\x0D\x1C\x1D\x1E\x1F") self.assertEqual(b.split(), [b'\x1c\x1d\x1e\x1f']) self.assertEqual(b.rsplit(), [b'\x1c\x1d\x1e\x1f']) | def test_rsplit_unicodewhitespace(self): b = self.type2test(b"\x09\x0A\x0B\x0C\x0D\x1C\x1D\x1E\x1F") self.assertEqual(b.rsplit(), [b'\x1c\x1d\x1e\x1f']) | 456,287 |
def test_partition(self): b = self.type2test(b'mississippi') self.assertEqual(b.partition(b'ss'), (b'mi', b'ss', b'issippi')) self.assertEqual(b.rpartition(b'w'), (b'', b'', b'mississippi')) | def test_partition(self): b = self.type2test(b'mississippi') self.assertEqual(b.partition(b'ss'), (b'mi', b'ss', b'issippi')) self.assertEqual(b.rpartition(b'w'), (b'', b'', b'mississippi')) | 456,288 |
def XXXtest_strip_bytearray(self): # XXX memoryview not available self.assertEqual(self.type2test(b'abc').strip(memoryview(b'ac')), b'b') self.assertEqual(self.type2test(b'abc').lstrip(memoryview(b'ac')), b'bc') self.assertEqual(self.type2test(b'abc').rstrip(memoryview(b'ac')), b'ab') | def XXXtest_strip_bytearray(self): # XXX memoryview not available self.assertEqual(self.type2test(b'abc').strip(memoryview(b'ac')), b'b') self.assertEqual(self.type2test(b'abc').lstrip(memoryview(b'ac')), b'bc') self.assertEqual(self.type2test(b'abc').rstrip(memoryview(b'ac')), b'ab') | 456,289 |
def test_insert(self): b = bytearray(b'msssspp') b.insert(1, ord('i')) b.insert(4, ord('i')) b.insert(-2, ord('i')) b.insert(1000, ord('i')) self.assertEqual(b, b'mississippi') # allowed in 2.6 #self.assertRaises(TypeError, lambda: b.insert(0, b'1')) b = bytearray() b.insert(0, Indexable(ord('A'))) self.assertEqual(b, ... | def test_insert(self): b = bytearray(b'msssspp') b.insert(1, ord('i')) b.insert(4, ord('i')) b.insert(-2, ord('i')) b.insert(1000, ord('i')) self.assertEqual(b, b'mississippi') # allowed in 2.6 #self.assertRaises(TypeError, lambda: b.insert(0, b'1')) b = bytearray() b.insert(0, Indexable(ord('A'))) self.assertEqual(b, ... | 456,290 |
def test_partition_bytearray_doesnt_share_nullstring(self): a, b, c = bytearray(b"x").partition(b"y") self.assertEqual(b, b"") self.assertEqual(c, b"") self.assertTrue(b is not c) b += b"!" self.assertEqual(c, b"") a, b, c = bytearray(b"x").partition(b"y") self.assertEqual(b, b"") self.assertEqual(c, b"") # Same for rp... | def test_partition_bytearray_doesnt_share_nullstring(self): a, b, c = bytearray(b"x").partition(b"y") self.assertEqual(b, b"") self.assertEqual(c, b"") self.assertTrue(b is not c) b += b"!" self.assertEqual(c, b"") a, b, c = bytearray(b"x").partition(b"y") self.assertEqual(b, b"") self.assertEqual(c, b"") # Same for rp... | 456,291 |
def test_baddecompressobj(self): # verify failure on building decompress object with bad params self.assertRaises(ValueError, zlib.decompressobj, 0) | def test_baddecompressobj(self): # verify failure on building decompress object with bad params self.assertRaises(ValueError, zlib.decompressobj, 0) | 456,292 |
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,293 |
def add(self, *arg_list): if not arg_list: return self if len(arg_list) > 1: self.add(*arg_list[1:]) other = arg_list[0] if type(self) != type(other): other = Stats(other) self.files += other.files self.total_calls += other.total_calls self.prim_calls += other.prim_calls self.total_tt += other.total_tt for func in othe... | def add(self, *arg_list): if not arg_list: return self if len(arg_list) > 1: self.add(*arg_list[1:]) other = arg_list[0] if type(self) != type(other) or self.__class__ != other.__class__: other = Stats(other) self.files += other.files self.total_calls += other.total_calls self.prim_calls += other.prim_calls self.total_... | 456,294 |
def sort_stats(self, *field): if not field: self.fcn_list = 0 return self if len(field) == 1 and isinstance(field[0], int): # Be compatible with old profiler field = [ {-1: "stdname", 0: "calls", 1: "time", 2: "cumulative"}[field[0]] ] | def sort_stats(self, *field): if not field: self.fcn_list = 0 return self if len(field) == 1 and isinstance(field[0], (int, long)): # Be compatible with old profiler field = [ {-1: "stdname", 0: "calls", 1: "time", 2: "cumulative"}[field[0]] ] | 456,295 |
def eval_print_amount(self, sel, list, msg): new_list = list if isinstance(sel, str): try: rex = re.compile(sel) except re.error: msg += " <Invalid regular expression %r>\n" % sel return new_list, msg new_list = [] for func in list: if rex.search(func_std_string(func)): new_list.append(func) else: count = len(list) i... | def eval_print_amount(self, sel, list, msg): new_list = list if isinstance(sel, basestring): try: rex = re.compile(sel) except re.error: msg += " <Invalid regular expression %r>\n" % sel return new_list, msg new_list = [] for func in list: if rex.search(func_std_string(func)): new_list.append(func) else: count = len(... | 456,296 |
def eval_print_amount(self, sel, list, msg): new_list = list if isinstance(sel, str): try: rex = re.compile(sel) except re.error: msg += " <Invalid regular expression %r>\n" % sel return new_list, msg new_list = [] for func in list: if rex.search(func_std_string(func)): new_list.append(func) else: count = len(list) i... | def eval_print_amount(self, sel, list, msg): new_list = list if isinstance(sel, str): try: rex = re.compile(sel) except re.error: msg += " <Invalid regular expression %r>\n" % sel return new_list, msg new_list = [] for func in list: if rex.search(func_std_string(func)): new_list.append(func) else: count = len(list) i... | 456,297 |
def get_print_list(self, sel_list): width = self.max_name_len if self.fcn_list: stat_list = self.fcn_list[:] msg = " Ordered by: " + self.sort_type + '\n' else: stat_list = list(self.stats.keys()) msg = " Random listing order was used\n" | def get_print_list(self, sel_list): width = self.max_name_len if self.fcn_list: stat_list = self.fcn_list[:] msg = " Ordered by: " + self.sort_type + '\n' else: stat_list = self.stats.keys() msg = " Random listing order was used\n" | 456,298 |
def main(): global new_interpreter usage = ('usage: %s -i /interpreter file-or-directory ...\n' % sys.argv[0]) try: opts, args = getopt.getopt(sys.argv[1:], 'i:') except getopt.error as msg: err(msg + '\n') err(usage) sys.exit(2) for o, a in opts: if o == '-i': new_interpreter = a.encode() if not new_interpreter or not... | def main(): global new_interpreter global preserve_timestamps usage = ('usage: %s -i /interpreter -p file-or-directory ...\n' % sys.argv[0]) try: opts, args = getopt.getopt(sys.argv[1:], 'i:') except getopt.error as msg: err(msg + '\n') err(usage) sys.exit(2) for o, a in opts: if o == '-i': new_interpreter = a.encode()... | 456,299 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.