rem stringlengths 0 322k | add stringlengths 0 2.05M | context stringlengths 8 228k |
|---|---|---|
Message("Thank you,\n%s" % `s`) | s2 = AskPassword("Okay %s, tell us your nickname"%s, s, cancel="None") if not s2: Message("%s has no secret nickname"%s) else: Message("Hello everybody!!\nThe secret nickname of %s is %s!!!"%(s, s2)) | def test(): import time Message("Testing EasyDialogs.") ok = AskYesNoCancel("Do you want to proceed?") ok = AskYesNoCancel("Do you want to identify?", yes="Indentify", no="Don't identify") if ok > 0: s = AskString("Enter your first name", "Joe") Message("Thank you,\n%s" % `s`) text = ( "Working Hard...", "Hardly Worki... |
if not _urandomfd: | if _urandomfd is None: | def urandom(n): """urandom(n) -> str |
pos = [-42] def negposreturn(exc): pos[0] += 1 return (u"?", pos[0]) codecs.register_error("test.negposreturn", negposreturn) "\xff".decode("ascii", "test.negposreturn") def hugeposreturn(exc): return (u"?", 424242) codecs.register_error("test.hugeposreturn", hugeposreturn) "\xff".decode("ascii", "test.hugeposreturn")... | handler = PosReturn() codecs.register_error("test.posreturn", handler.handle) handler.pos = -1 self.assertEquals("\xff0".decode("ascii", "test.posreturn"), u"<?>0") handler.pos = -2 self.assertEquals("\xff0".decode("ascii", "test.posreturn"), u"<?><?>") handler.pos = -3 self.assertRaises(IndexError, "\xff0".decod... | def baddecodereturn2(exc): return (u"?", None) |
pos = [-42] def negposreturn(exc): pos[0] += 1 return (u"?", pos[0]) codecs.register_error("test.negposreturn", negposreturn) u"\xff".encode("ascii", "test.negposreturn") def hugeposreturn(exc): return (u"?", 424242) codecs.register_error("test.hugeposreturn", hugeposreturn) u"\xff".encode("ascii", "test.hugeposreturn... | handler = PosReturn() codecs.register_error("test.posreturn", handler.handle) handler.pos = -1 self.assertEquals(u"\xff0".encode("ascii", "test.posreturn"), "<?>0") handler.pos = -2 self.assertEquals(u"\xff0".encode("ascii", "test.posreturn"), "<?><?>") handler.pos = -3 self.assertRaises(IndexError, u"\xff0".enco... | def badencodereturn2(exc): return (u"?", None) |
for err in ("strict", "replace", "xmlcharrefreplace", "backslashreplace", "test.hugeposreturn"): | for err in ("strict", "replace", "xmlcharrefreplace", "backslashreplace", "test.posreturn"): | def __getitem__(self, key): raise ValueError |
class String: x = '' def __str__(self): return self.x o = String() o.x = 'abc' verify(unicode(o) == u'abc') verify(str(o) == 'abc') o.x = u'abc' verify(unicode(o) == u'abc') verify(str(o) == 'abc') for obj in (123, 123.45, 123L): verify(unicode(obj) == unicode(str(obj))) | def test_fixup(s): s2 = u'\ud800\udc01' test_lecmp(s, s2) s2 = u'\ud900\udc01' test_lecmp(s, s2) s2 = u'\uda00\udc01' test_lecmp(s, s2) s2 = u'\udb00\udc01' test_lecmp(s, s2) s2 = u'\ud800\udd01' test_lecmp(s, s2) s2 = u'\ud900\udd01' test_lecmp(s, s2) s2 = u'\uda00\udd01' test_lecmp(s, s2) s2 = u'\udb00\udd01' test_le... | |
if c == ESCAPE: return ESCAPE * 2 else: i = ord(c) return ESCAPE + HEX[i/16] + HEX[i%16] | i = ord(c) return ESCAPE + HEX[i/16] + HEX[i%16] | def quote(c): """Quote a single character.""" if c == ESCAPE: return ESCAPE * 2 else: i = ord(c) return ESCAPE + HEX[i/16] + HEX[i%16] |
""+ _LegalCharsPatt +"+" | ""+ _LegalCharsPatt +"+?" | def OutputString(self, attrs=None): # Build up our result # result = [] RA = result.append |
if sys.platform == 'win32': | if sys.platform == 'win32' or sys.platform.startswith('os2'): | def getpager(): """Decide what method to use for paging through text.""" if type(sys.stdout) is not types.FileType: return plainpager if not sys.stdin.isatty() or not sys.stdout.isatty(): return plainpager if os.environ.get('TERM') in ['dumb', 'emacs']: return plainpager if os.environ.has_key('PAGER'): if sys.platform ... |
initialcolor = None, | def __init__(self, master = None, initialcolor = None, databasefile = None, initfile = None, ignore = None, wantspec = None): self.__master = master self.__initialcolor = initialcolor self.__databasefile = databasefile self.__initfile = initfile or os.path.expanduser('~/.pynche') self.__ignore = ignore self.__pw = None... | |
self.__initialcolor = initialcolor | def __init__(self, master = None, initialcolor = None, databasefile = None, initfile = None, ignore = None, wantspec = None): self.__master = master self.__initialcolor = initialcolor self.__databasefile = databasefile self.__initfile = initfile or os.path.expanduser('~/.pynche') self.__ignore = ignore self.__pw = None... | |
def show(self): | def show(self, color=None): if not self.__master: from Tkinter import Tk self.__master = Tk() | def show(self): if not self.__pw: self.__pw, self.__sb = \ Main.build(master = self.__master, initialcolor = self.__initialcolor, initfile = self.__initfile, ignore = self.__ignore) Main.run(self.__pw, self.__sb) rgbtuple = self.__sb.current_rgb() self.__pw.withdraw() # check to see if the cancel button was pushed if s... |
initialcolor = self.__initialcolor, | def show(self): if not self.__pw: self.__pw, self.__sb = \ Main.build(master = self.__master, initialcolor = self.__initialcolor, initfile = self.__initfile, ignore = self.__ignore) Main.run(self.__pw, self.__sb) rgbtuple = self.__sb.current_rgb() self.__pw.withdraw() # check to see if the cancel button was pushed if s... | |
colordb = self.__sb.colordb() | def show(self): if not self.__pw: self.__pw, self.__sb = \ Main.build(master = self.__master, initialcolor = self.__initialcolor, initfile = self.__initfile, ignore = self.__ignore) Main.run(self.__pw, self.__sb) rgbtuple = self.__sb.current_rgb() self.__pw.withdraw() # check to see if the cancel button was pushed if s... | |
return apply(Chooser, (), options).show() | global _chooser if not _chooser: _chooser = apply(Chooser, (), options) return _chooser.show(color) | def askcolor(color = None, **options): """Ask for a color""" return apply(Chooser, (), options).show() |
exts.append( Extension('_locale', ['_localemodule.c']) ) | if platform in ['cygwin']: locale_libs = ['intl'] else: locale_libs = [] exts.append( Extension('_locale', ['_localemodule.c'], libraries=locale_libs ) ) | 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') |
if sys.platform == 'darwin' and g.has_key('CONFIGURE_MACOSX_DEPLOYMENT_TARGET'): cfg_target = g['CONFIGURE_MACOSX_DEPLOYMENT_TARGET'] cur_target = os.getenv('MACOSX_DEPLOYMENT_TARGET', '') if cfg_target != cur_target: my_msg = ('$MACOSX_DEPLOYMENT_TARGET mismatch: now "%s" but "%s" during configure' % (cur_target, cfg_... | def _init_posix(): """Initialize the module as appropriate for POSIX systems.""" g = {} # load the installed Makefile: try: filename = get_makefile_filename() parse_makefile(filename, g) except IOError, msg: my_msg = "invalid Python installation: unable to open %s" % filename if hasattr(msg, "strerror"): my_msg = my_ms... | |
rounding = context.rounding | def __pow__(self, n, modulo = None, context=None): """Return self ** n (mod modulo) | |
shouldround = context._rounding_decision == ALWAYS_ROUND | def __pow__(self, n, modulo = None, context=None): """Return self ** n (mod modulo) | |
if shouldround: | if context._rounding_decision == ALWAYS_ROUND: | def __pow__(self, n, modulo = None, context=None): """Return self ** n (mod modulo) |
out = 0 | def _rescale(self, exp, rounding=None, context=None, watchexp=1): """Rescales so that the exponent is exp. | |
prevexact = context.flags[Inexact] | def _rescale(self, exp, rounding=None, context=None, watchexp=1): """Rescales so that the exponent is exp. | |
count = 1 | def sqrt(self, context=None): """Return the square root of self. | |
context._rounding_decision == ALWAYS_ROUND return ans._fix(context) | if context._rounding_decision == ALWAYS_ROUND: return ans._fix(context) return ans | def max(self, other, context=None): """Returns the larger value. |
context._rounding_decision == ALWAYS_ROUND return ans._fix(context) | if context._rounding_decision == ALWAYS_ROUND: return ans._fix(context) return ans | def min(self, other, context=None): """Returns the smaller value. |
if c not in '123': raise error_proto, resp return resp | raise error_proto, resp | def getresp(self): resp = self.getmultiline() if self.debugging: print '*resp*', self.sanitize(resp) self.lastresp = resp[:3] c = resp[:1] if c == '4': raise error_temp, resp if c == '5': raise error_perm, resp if c not in '123': raise error_proto, resp return resp |
if resp[:3] <> '229': | if resp[:3] != '229': | def parse229(resp, peer): '''Parse the '229' response for a EPSV request. Raises error_proto if it does not contain '(|||port|)' Return ('host.addr.as.numbers', port#) tuple.''' if resp[:3] <> '229': raise error_reply, resp left = resp.find('(') if left < 0: raise error_proto, resp right = resp.find(')', left + 1) if ... |
if resp[left + 1] <> resp[right - 1]: | if resp[left + 1] != resp[right - 1]: | def parse229(resp, peer): '''Parse the '229' response for a EPSV request. Raises error_proto if it does not contain '(|||port|)' Return ('host.addr.as.numbers', port#) tuple.''' if resp[:3] <> '229': raise error_reply, resp left = resp.find('(') if left < 0: raise error_proto, resp right = resp.find(')', left + 1) if ... |
if len(parts) <> 5: | if len(parts) != 5: | def parse229(resp, peer): '''Parse the '229' response for a EPSV request. Raises error_proto if it does not contain '(|||port|)' Return ('host.addr.as.numbers', port#) tuple.''' if resp[:3] <> '229': raise error_reply, resp left = resp.find('(') if left < 0: raise error_proto, resp right = resp.find(')', left + 1) if ... |
Usage: ftp [-d] [-r[file]] host [-l[dir]] [-d[dir]] [-p] [file] ...''' | Usage: ftp [-d] [-r[file]] host [-l[dir]] [-d[dir]] [-p] [file] ... -d dir -l list -p password ''' if len(sys.argv) < 2: print test.__doc__ sys.exit(0) | def test(): '''Test program. Usage: ftp [-d] [-r[file]] host [-l[dir]] [-d[dir]] [-p] [file] ...''' debugging = 0 rcfile = None while sys.argv[1] == '-d': debugging = debugging+1 del sys.argv[1] if sys.argv[1][:2] == '-r': # get name of alternate ~/.netrc file: rcfile = sys.argv[1][2:] del sys.argv[1] host = sys.argv[... |
archive_basename = os.path.join(self.bdist_dir, "%s.win32" % fullname) | def run (self): if (sys.platform != "win32" and (self.distribution.has_ext_modules() or self.distribution.has_c_libraries())): raise DistutilsPlatformError \ ("distribution contains extensions and/or C libraries; " "must be compiled on a Windows 32 platform") | |
if audioop.lin2ulaw(data[0], 1) != '\377\347\333' or \ audioop.lin2ulaw(data[1], 2) != '\377\377\377' or \ audioop.lin2ulaw(data[2], 4) != '\377\377\377': | if audioop.lin2ulaw(data[0], 1) != '\xff\xe7\xdb' or \ audioop.lin2ulaw(data[1], 2) != '\xff\xff\xff' or \ audioop.lin2ulaw(data[2], 4) != '\xff\xff\xff': | def testlin2ulaw(data): if verbose: print 'lin2ulaw' if audioop.lin2ulaw(data[0], 1) != '\377\347\333' or \ audioop.lin2ulaw(data[1], 2) != '\377\377\377' or \ audioop.lin2ulaw(data[2], 4) != '\377\377\377': return 0 return 1 |
testme[:42] testme[:42] = "The Answer" del testme[:42] | import sys if sys.platform[:4] != 'java': testme[:42] testme[:42] = "The Answer" del testme[:42] else: print "__getitem__: (slice(0, 42, None),)" print "__setitem__: (slice(0, 42, None), 'The Answer')" print "__delitem__: (slice(0, 42, None),)" | exec """def __%(method)s__(self, *args): print "__%(method)s__:", args |
int(testme) long(testme) float(testme) oct(testme) hex(testme) | if sys.platform[:4] != 'java': int(testme) long(testme) float(testme) oct(testme) hex(testme) else: print "__int__: ()" print "__long__: ()" print "__float__: ()" print "__oct__: ()" print "__hex__: ()" | exec """def __%(method)s__(self, *args): print "__%(method)s__:", args |
if sys.platform[:4] == 'java': import java java.lang.System.gc() | exec """def __%(method)s__(self, *args): print "__%(method)s__:", args | |
raise DistutilsFileErorr, \ | raise DistutilsFileError, \ | def check_package (self, package, package_dir): |
if self._debugging > 1: print '*put*', `line` | def _putline(self, line): #if self._debugging > 1: print '*put*', `line` self.sock.send('%s%s' % (line, CRLF)) | |
if self._debugging: print '*cmd*', `line` | def _putcmd(self, line): #if self._debugging: print '*cmd*', `line` self._putline(line) | |
if self._debugging > 1: print '*get*', `line` | def _getline(self): line = self.file.readline() #if self._debugging > 1: print '*get*', `line` if not line: raise error_proto('-ERR EOF') octets = len(line) # server can send any combination of CR & LF # however, 'readline()' returns lines ending in LF # so only possibilities are ...LF, ...CRLF, CR...LF if line[-2:] ==... | |
if self._debugging > 1: print '*resp*', `resp` | def _getresp(self): resp, o = self._getline() #if self._debugging > 1: print '*resp*', `resp` c = resp[:1] if c != '+': raise error_proto(resp) return resp | |
if self._debugging: print '*stat*', `rets` | def stat(self): """Get mailbox status. | |
self.assertRaises(OverflowError, xrange, 1e100, 1e101, 1e101) | self.assertRaises(TypeError, xrange, 0.0, 2, 1) self.assertRaises(TypeError, xrange, 1, 2.0, 1) self.assertRaises(TypeError, xrange, 1, 2, 1.0) self.assertRaises(TypeError, xrange, 1e100, 1e101, 1e101) | def test_xrange(self): self.assertEqual(list(xrange(3)), [0, 1, 2]) self.assertEqual(list(xrange(1, 5)), [1, 2, 3, 4]) self.assertEqual(list(xrange(0)), []) self.assertEqual(list(xrange(-3)), []) self.assertEqual(list(xrange(1, 10, 3)), [1, 4, 7]) self.assertEqual(list(xrange(5, -5, -3)), [5, 2, -1, -4]) |
self.ldflags_shared_debug = [ '/DLL', '/nologo', '/INCREMENTAL:no', '/pdb:None', '/DEBUG' ] | if self.__version >= 7: self.ldflags_shared_debug = [ '/DLL', '/nologo', '/INCREMENTAL:no', '/DEBUG' ] else: self.ldflags_shared_debug = [ '/DLL', '/nologo', '/INCREMENTAL:no', '/pdb:None', '/DEBUG' ] | def __init__ (self, verbose=0, dry_run=0, force=0): CCompiler.__init__ (self, verbose, dry_run, force) self.__version = get_build_version() if self.__version >= 7: self.__root = r"Software\Microsoft\VisualStudio" self.__macros = MacroExpander(self.__version) else: self.__root = r"Software\Microsoft\Devstudio" self.__pa... |
return codecs.mbs_encode(input,self.errors)[0] | return codecs.mbcs_encode(input,self.errors)[0] | def encode(self, input, final=False): return codecs.mbs_encode(input,self.errors)[0] |
return codecs.mbs_decode(input,self.errors)[0] | return codecs.mbcs_decode(input,self.errors)[0] | def decode(self, input, final=False): return codecs.mbs_decode(input,self.errors)[0] |
delimiter string. If maxsplit is given, splits into at most maxsplit words. If sep is not specified, any whitespace string is a separator. | delimiter string. If maxsplit is given, splits at no more than maxsplit places (resulting in at most maxsplit+1 words). If sep is not specified, any whitespace string is a separator. | def split(s, sep=None, maxsplit=-1): """split(s [,sep [,maxsplit]]) -> list of strings Return a list of the words in the string s, using sep as the delimiter string. If maxsplit is given, splits into at most maxsplit words. If sep is not specified, any whitespace string is a separator. (split and splitfields are sy... |
suffixes_map). | suffix_map). | def guess_type(url): """Guess the type of a file based on its URL. Return value is a tuple (type, encoding) where type is None if the type can't be guessed (no or unknown suffix) or a string of the form type/subtype, usable for a MIME Content-type header; and encoding is None for no encoding or the name of the program... |
def __init__(self, sock): | def __init__(self, sock, debuglevel=0): | def __init__(self, sock): self.fp = sock.makefile('rb', 0) |
if self.length == 0: self.close() | def begin(self): if self.msg is not None: # we've already started reading the response return | |
if self.length == 0 or len(s) < amt: self.close() | def read(self, amt=None): if self.fp is None: return '' | |
response = self.response_class(self.sock) | if self.debuglevel > 0: response = self.response_class(self.sock, self.debuglevel) else: response = self.response_class(self.sock) | def getresponse(self): "Get the response from the server." |
"The class no longer supports the debuglevel." pass | self._conn.set_debuglevel(debuglevel) | def set_debuglevel(self, debuglevel): "The class no longer supports the debuglevel." pass |
if __debug__: class Foo: version = 1 class Foo: version = 2 class Foo: version = 3 def execfunc(x): exec x in y | def get_namespace(self): """Returns the single namespace bound to this name. | |
def writeln(self, *args): if args: self.write(*args) | def writeln(self, arg=None): if arg: self.write(arg) | def writeln(self, *args): if args: self.write(*args) self.write('\n') # text-mode streams translate to \r\n if needed |
return encode_base64("%s\0%s\0%s" % (user, user, password), eol="") | return encode_base64("\0%s\0%s" % (user, password), eol="") | def encode_plain(user, password): return encode_base64("%s\0%s\0%s" % (user, user, password), eol="") |
fp = open(temp_filename, 'wt') | mode = 'w' if sys.platform not in ['cygwin']: mode += 't' fp = open(temp_filename, mode) | def setUp (self): fp = open(temp_filename, 'wt') fp.write(TEST_NETRC) fp.close() self.netrc = netrc.netrc(temp_filename) |
del dirs_in_sys_path | def addpackage(sitedir, name): fullname = os.path.join(sitedir, name) try: f = open(fullname) except IOError: return while 1: dir = f.readline() if not dir: break if dir[0] == '#': continue if dir.startswith("import"): exec dir continue if dir[-1] == '\n': dir = dir[:-1] dir, dircase = makepath(sitedir, dir) if not dir... | |
data = self.rfile.read(int(self.headers["content-length"])) | max_chunk_size = 10*1024*1024 size_remaining = int(self.headers["content-length"]) L = [] while size_remaining: chunk_size = min(size_remaining, max_chunk_size) L.append(self.rfile.read(chunk_size)) size_remaining -= len(L[-1]) data = ''.join(L) | def do_POST(self): """Handles the HTTP POST request. |
elif _isfunction(v) or _isclass(v): | elif _isfunction(v) or _isclass(v) or _ismethod(v): | def run__test__(self, d, name): """d, name -> Treat dict d like module.__test__. |
"dict must be strings, functions " | "dict must be strings, functions, methods, " | def run__test__(self, d, name): """d, name -> Treat dict d like module.__test__. |
if verbose: print "compiling string with syntax error" | def test_complex_args(self): | exec 'def f(a, a): pass' |
try: compile("1+*3", "filename", "exec") except SyntaxError, detail: if not detail.filename == "filename": raise TestFailed, "expected 'filename', got %r" % detail.filename | def comp_args((a, b)): return a,b self.assertEqual(comp_args((1, 2)), (1, 2)) | exec 'def f(a, a): pass' |
try: exec 'def f(a = 0, a = 1): pass' raise TestFailed, "duplicate keyword arguments" except SyntaxError: pass | def comp_args((a, b)=(3, 4)): return a, b self.assertEqual(comp_args((1, 2)), (1, 2)) self.assertEqual(comp_args(), (3, 4)) | exec 'def f(a, a): pass' |
try: exec 'def f(a): global a; a = 1' raise TestFailed, "variable is global and local" except SyntaxError: pass | def comp_args(a, (b, c)): return a, b, c self.assertEqual(comp_args(1, (2, 3)), (1, 2, 3)) | exec 'def f(a = 0, a = 1): pass' |
if verbose: print "testing complex args" | def comp_args(a=2, (b, c)=(3, 4)): return a, b, c self.assertEqual(comp_args(1, (2, 3)), (1, 2, 3)) self.assertEqual(comp_args(), (2, 3, 4)) | exec 'def f(a): global a; a = 1' |
def comp_args((a, b)): print a,b | def test_argument_order(self): try: exec 'def f(a=1, (b, c)): pass' self.fail("non-default args after default") except SyntaxError: pass | def comp_args((a, b)): print a,b |
comp_args((1, 2)) | def test_float_literals(self): self.assertRaises(SyntaxError, eval, "2e") self.assertRaises(SyntaxError, eval, "2.0e+") self.assertRaises(SyntaxError, eval, "1e-") self.assertRaises(SyntaxError, eval, "3-4e/21") | def comp_args((a, b)): print a,b |
def comp_args((a, b)=(3, 4)): print a, b comp_args((1, 2)) comp_args() def comp_args(a, (b, c)): print a, b, c comp_args(1, (2, 3)) def comp_args(a=2, (b, c)=(3, 4)): print a, b, c comp_args(1, (2, 3)) comp_args() try: exec 'def f(a=1, (b, c)): pass' raise TestFailed, "non-default args after default" except Synta... | def test_indentation(self): s = """ | def comp_args((a, b)=(3, 4)): print a, b |
compile(s, "<string>", "exec") | compile(s, "<string>", "exec") def test_literals_with_leading_zeroes(self): for arg in ["077787", "0xj", "0x.", "0e", "090000000000000", "080000000000000", "000000000000009", "000000000000008"]: self.assertRaises(SyntaxError, eval, arg) self.assertEqual(eval("0777"), 511) self.assertEqual(eval("0777L"), 511) self.as... | def expect_error(s): try: eval(s) raise TestFailed("%r accepted" % s) except SyntaxError: pass |
if verbose: print "testing literals with leading zeroes" | def test_main(): test_support.run_unittest(TestSpecifics) | def expect_error(s): try: eval(s) raise TestFailed("%r accepted" % s) except SyntaxError: pass |
def expect_same(test_source, expected): got = eval(test_source) if got != expected: raise TestFailed("eval(%r) gave %r, but expected %r" % (test_source, got, expected)) expect_error("077787") expect_error("0xj") expect_error("0x.") expect_error("0e") expect_same("0777", 511) expect_same("0777L", 511) expect_same("0007... | if __name__ == "__main__": test_main() | def expect_same(test_source, expected): got = eval(test_source) if got != expected: raise TestFailed("eval(%r) gave %r, but expected %r" % (test_source, got, expected)) |
import warnings warnings.warn("cookielib bug!", stacklevel=2) import traceback traceback.print_exc() | import warnings, traceback, StringIO f = StringIO.StringIO() traceback.print_exc(None, f) msg = f.getvalue() warnings.warn("cookielib bug!\n%s" % msg, stacklevel=2) | def reraise_unmasked_exceptions(unmasked=()): # There are a few catch-all except: statements in this module, for # catching input that's bad in unexpected ways. # This function re-raises some exceptions we don't want to trap. unmasked = unmasked + (KeyboardInterrupt, SystemExit, MemoryError) etype = sys.exc_info()[0] i... |
if timeout is None: waiter.acquire() if __debug__: self._note("%s.wait(): got it", self) else: endtime = _time() + timeout delay = 0.000001 while 1: gotit = waiter.acquire(0) if gotit or _time() >= endtime: break _sleep(delay) if delay < 1.0: delay = delay * 2.0 if not gotit: | try: if timeout is None: waiter.acquire() | def wait(self, timeout=None): me = currentThread() assert self._is_owned(), "wait() of un-acquire()d lock" waiter = _allocate_lock() waiter.acquire() self.__waiters.append(waiter) saved_state = self._release_save() if timeout is None: waiter.acquire() if __debug__: self._note("%s.wait(): got it", self) else: endtime = ... |
self._note("%s.wait(%s): timed out", self, timeout) try: self.__waiters.remove(waiter) except ValueError: pass | self._note("%s.wait(): got it", self) | def wait(self, timeout=None): me = currentThread() assert self._is_owned(), "wait() of un-acquire()d lock" waiter = _allocate_lock() waiter.acquire() self.__waiters.append(waiter) saved_state = self._release_save() if timeout is None: waiter.acquire() if __debug__: self._note("%s.wait(): got it", self) else: endtime = ... |
if __debug__: self._note("%s.wait(%s): got it", self, timeout) self._acquire_restore(saved_state) | endtime = _time() + timeout delay = 0.000001 while 1: gotit = waiter.acquire(0) if gotit or _time() >= endtime: break _sleep(delay) if delay < 1.0: delay = delay * 2.0 if not gotit: if __debug__: self._note("%s.wait(%s): timed out", self, timeout) try: self.__waiters.remove(waiter) except ValueError: pass else: if __de... | def wait(self, timeout=None): me = currentThread() assert self._is_owned(), "wait() of un-acquire()d lock" waiter = _allocate_lock() waiter.acquire() self.__waiters.append(waiter) saved_state = self._release_save() if timeout is None: waiter.acquire() if __debug__: self._note("%s.wait(): got it", self) else: endtime = ... |
"".join(map(lambda i: "0123456789ABCDEF"[i], digits)) + "L" | "".join(map(lambda i: "0123456789abcdef"[i], digits)) + "L" | def slow_format(self, x, base): if (x, base) == (0, 8): # this is an oddball! return "0L" digits = [] sign = 0 if x < 0: sign, x = 1, -x while x: x, r = divmod(x, base) digits.append(int(r)) digits.reverse() digits = digits or [0] return '-'[:sign] + \ {8: '0', 10: '', 16: '0x'}[base] + \ "".join(map(lambda i: "0123456... |
def flush(self): | def flush(self,zlib_mode=zlib.Z_SYNC_FLUSH): if self.mode == WRITE: self.fileobj.write(self.compress.flush(zlib_mode)) | def flush(self): self.fileobj.flush() |
(?: \s+ | ( [^\s[\](){} )+ | [^[\](){} | def dump(*stuff): sys.__stdout__.write(string.join(map(str, stuff), " ") + "\n") |
i = m.end(1) - 1 | p = m.end() i = p-1 while i >= 0 and str[i] in " \t\n": i = i-1 | def _study2(self, _rfind=string.rfind, _find=string.find, _ws=string.whitespace): if self.study_level >= 2: return self._study1() self.study_level = 2 |
p = m.end() | def _study2(self, _rfind=string.rfind, _find=string.find, _ws=string.whitespace): if self.study_level >= 2: return self._study1() self.study_level = 2 | |
prefix = PREFIX prefix_len = len(prefix) | def main(): rcfile = os.path.join(os.path.dirname(refcounts.__file__), os.pardir, "api", "refcounts.dat") outfile = "-" opts, args = getopt.getopt(sys.argv[1:], "o:r:", ["output=", "refcounts="]) for opt, arg in opts: if opt in ("-o", "--output"): outfile = arg elif opt in ("-r", "--refcounts"): rcfile = arg rcdict = r... | |
if line[:prefix_len] == prefix: s = string.split(line[prefix_len:], '}', 1)[0] | prefix = None if line.startswith(PREFIX_1): prefix = PREFIX_1 elif line.startswith(PREFIX_2): prefix = PREFIX_2 if prefix: s = line[len(prefix):].split('}', 1)[0] | def main(): rcfile = os.path.join(os.path.dirname(refcounts.__file__), os.pardir, "api", "refcounts.dat") outfile = "-" opts, args = getopt.getopt(sys.argv[1:], "o:r:", ["output=", "refcounts="]) for opt, arg in opts: if opt in ("-o", "--output"): outfile = arg elif opt in ("-r", "--refcounts"): rcfile = arg rcdict = r... |
+ line[prefix_len:] | + line[len(prefix):] | def main(): rcfile = os.path.join(os.path.dirname(refcounts.__file__), os.pardir, "api", "refcounts.dat") outfile = "-" opts, args = getopt.getopt(sys.argv[1:], "o:r:", ["output=", "refcounts="]) for opt, arg in opts: if opt in ("-o", "--output"): outfile = arg elif opt in ("-r", "--refcounts"): rcfile = arg rcdict = r... |
seq, request = rpc.request_queue.get(0) | seq, request = rpc.request_queue.get(block=True, timeout=0.05) | def main(del_exitfunc=False): """Start the Python execution server in a subprocess In the Python subprocess, RPCServer is instantiated with handlerclass MyHandler, which inherits register/unregister methods from RPCHandler via the mix-in class SocketIO. When the RPCServer 'server' is instantiated, the TCPServer initi... |
time.sleep(0.05) | def main(del_exitfunc=False): """Start the Python execution server in a subprocess In the Python subprocess, RPCServer is instantiated with handlerclass MyHandler, which inherits register/unregister methods from RPCHandler via the mix-in class SocketIO. When the RPCServer 'server' is instantiated, the TCPServer initi... | |
if len(result) > 1: | if use_all or len(result) > 1: | def group(self, *groups): |
if (type!=float): | if type != float: | def powtest(type): if (type!=float): print " Testing 2-argument pow() function..." for i in range(-1000, 1000): if (pow(type(i),0)!=1): raise ValueError, 'pow('+str(i)+',0) != 1' if (pow(type(i),1)!=type(i)): raise ValueError, 'pow('+str(i)+',1) != '+str(i) if (pow(type(0),1)!=type(0)): raise ValueError, 'pow(0,'+st... |
if (pow(type(i),0)!=1): | if pow(type(i), 0) != 1: | def powtest(type): if (type!=float): print " Testing 2-argument pow() function..." for i in range(-1000, 1000): if (pow(type(i),0)!=1): raise ValueError, 'pow('+str(i)+',0) != 1' if (pow(type(i),1)!=type(i)): raise ValueError, 'pow('+str(i)+',1) != '+str(i) if (pow(type(0),1)!=type(0)): raise ValueError, 'pow(0,'+st... |
if (pow(type(i),1)!=type(i)): | if pow(type(i), 1) != type(i): | def powtest(type): if (type!=float): print " Testing 2-argument pow() function..." for i in range(-1000, 1000): if (pow(type(i),0)!=1): raise ValueError, 'pow('+str(i)+',0) != 1' if (pow(type(i),1)!=type(i)): raise ValueError, 'pow('+str(i)+',1) != '+str(i) if (pow(type(0),1)!=type(0)): raise ValueError, 'pow(0,'+st... |
if (pow(type(0),1)!=type(0)): | if pow(type(0), 1) != type(0): | def powtest(type): if (type!=float): print " Testing 2-argument pow() function..." for i in range(-1000, 1000): if (pow(type(i),0)!=1): raise ValueError, 'pow('+str(i)+',0) != 1' if (pow(type(i),1)!=type(i)): raise ValueError, 'pow('+str(i)+',1) != '+str(i) if (pow(type(0),1)!=type(0)): raise ValueError, 'pow(0,'+st... |
if (pow(type(1),1)!=type(1)): | if pow(type(1), 1) != type(1): | def powtest(type): if (type!=float): print " Testing 2-argument pow() function..." for i in range(-1000, 1000): if (pow(type(i),0)!=1): raise ValueError, 'pow('+str(i)+',0) != 1' if (pow(type(i),1)!=type(i)): raise ValueError, 'pow('+str(i)+',1) != '+str(i) if (pow(type(0),1)!=type(0)): raise ValueError, 'pow(0,'+st... |
if (pow(type(i),3)!=i*i*i): | if pow(type(i), 3) != i*i*i: | def powtest(type): if (type!=float): print " Testing 2-argument pow() function..." for i in range(-1000, 1000): if (pow(type(i),0)!=1): raise ValueError, 'pow('+str(i)+',0) != 1' if (pow(type(i),1)!=type(i)): raise ValueError, 'pow('+str(i)+',1) != '+str(i) if (pow(type(0),1)!=type(0)): raise ValueError, 'pow(0,'+st... |
if (pow(2,i)!=pow2): | if pow(2, i) != pow2: | def powtest(type): if (type!=float): print " Testing 2-argument pow() function..." for i in range(-1000, 1000): if (pow(type(i),0)!=1): raise ValueError, 'pow('+str(i)+',0) != 1' if (pow(type(i),1)!=type(i)): raise ValueError, 'pow('+str(i)+',1) != '+str(i) if (pow(type(0),1)!=type(0)): raise ValueError, 'pow(0,'+st... |
if (i!=30): pow2=pow2*2 | if i != 30 : pow2 = pow2*2 for othertype in int, long: for i in range(-10, 0) + range(1, 10): ii = type(i) for j in range(1, 11): jj = -othertype(j) try: pow(ii, jj) except ValueError: pass else: raise ValueError, "pow(%s, %s) did not fail" % (ii, jj) for othertype in int, long, float: for i in range(1, 100): zero = ... | def powtest(type): if (type!=float): print " Testing 2-argument pow() function..." for i in range(-1000, 1000): if (pow(type(i),0)!=1): raise ValueError, 'pow('+str(i)+',0) != 1' if (pow(type(i),1)!=type(i)): raise ValueError, 'pow('+str(i)+',1) != '+str(i) if (pow(type(0),1)!=type(0)): raise ValueError, 'pow(0,'+st... |
if (type==float): il=1 | if type == float: il = 1 | def powtest(type): if (type!=float): print " Testing 2-argument pow() function..." for i in range(-1000, 1000): if (pow(type(i),0)!=1): raise ValueError, 'pow('+str(i)+',0) != 1' if (pow(type(i),1)!=type(i)): raise ValueError, 'pow('+str(i)+',1) != '+str(i) if (pow(type(0),1)!=type(0)): raise ValueError, 'pow(0,'+st... |
elif (type==int): jl=0 elif (type==long): jl,jh = 0, 15 | elif type == int: jl = 0 elif type == long: jl, jh = 0, 15 | def powtest(type): if (type!=float): print " Testing 2-argument pow() function..." for i in range(-1000, 1000): if (pow(type(i),0)!=1): raise ValueError, 'pow('+str(i)+',0) != 1' if (pow(type(i),1)!=type(i)): raise ValueError, 'pow('+str(i)+',1) != '+str(i) if (pow(type(0),1)!=type(0)): raise ValueError, 'pow(0,'+st... |
if (k!=0): | if k != 0: | def powtest(type): if (type!=float): print " Testing 2-argument pow() function..." for i in range(-1000, 1000): if (pow(type(i),0)!=1): raise ValueError, 'pow('+str(i)+',0) != 1' if (pow(type(i),1)!=type(i)): raise ValueError, 'pow('+str(i)+',1) != '+str(i) if (pow(type(0),1)!=type(0)): raise ValueError, 'pow(0,'+st... |
if (j>=0 and k!=0): o=pow(i,j) % k n=pow(i,j,k) if (o!=n): print 'Integer mismatch:', i,j,k if (j>=0 and k<>0): o=pow(long(i),j) % k n=pow(long(i),j,k) if (o!=n): print 'Long mismatch:', i,j,k if (i>=0 and k<>0): o=pow(float(i),j) % k n=pow(float(i),j,k) if (o!=n): print 'Float mismatch:', i,j,k | if j >= 0 and k != 0: o = pow(i,j) % k n = pow(i,j,k) if o != n: print 'Integer mismatch:', i,j,k if j >= 0 and k <> 0: o = pow(long(i),j) % k n = pow(long(i),j,k) if o != n: print 'Long mismatch:', i,j,k if i >= 0 and k <> 0: o = pow(float(i),j) % k n = pow(float(i),j,k) if o != n: print 'Float mismatch:', i,j,k | def powtest(type): if (type!=float): print " Testing 2-argument pow() function..." for i in range(-1000, 1000): if (pow(type(i),0)!=1): raise ValueError, 'pow('+str(i)+',0) != 1' if (pow(type(i),1)!=type(i)): raise ValueError, 'pow('+str(i)+',1) != '+str(i) if (pow(type(0),1)!=type(0)): raise ValueError, 'pow(0,'+st... |
self.file = self.sock.makefile('rb') | if self.file is None: self.file = self.sock.makefile('rb') | def getreply(self): """Get a reply from the server. Returns a tuple consisting of: |
try: errcode = string.atoi(code) except ValueError: errcode = -1 break | def getreply(self): """Get a reply from the server. Returns a tuple consisting of: |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.