rem
stringlengths
1
322k
add
stringlengths
0
2.05M
context
stringlengths
4
228k
meta
stringlengths
156
215
_cache[alias] = entry
if not aliases.aliases.has_key(alias): aliases.aliases[alias] = modname
def search_function(encoding): # Cache lookup entry = _cache.get(encoding,_unknown) if entry is not _unknown: return entry # Import the module modname = encoding.replace('-', '_') modname = aliases.aliases.get(modname,modname) try: mod = __import__(modname,globals(),locals(),'*') except ImportError,why: _cache[encoding] = None return None # Now ask the module for the registry entry try: entry = tuple(mod.getregentry()) except AttributeError: entry = () if len(entry) != 4: raise SystemError,\ 'module "%s.%s" failed to register' % \ (__name__,modname) for obj in entry: if not callable(obj): raise SystemError,\ 'incompatible codecs in module "%s.%s"' % \ (__name__,modname) # Cache the encoding and its aliases _cache[encoding] = entry try: codecaliases = mod.getaliases() except AttributeError: pass else: for alias in codecaliases: _cache[alias] = entry return entry
988ad2bdff836665f004c285fb09182c35775fd6 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/988ad2bdff836665f004c285fb09182c35775fd6/__init__.py
if do_copy: macostools.copy(os.path.join(sys.exec_prefix, src), dst) else: macostools.mkalias(os.path.join(sys.exec_prefix, src), dst)
try: if do_copy: macostools.copy(os.path.join(sys.exec_prefix, src), dst) else: macostools.mkalias(os.path.join(sys.exec_prefix, src), dst) except IOError: return 0
def mkcorealias(src, altsrc): import string import macostools version = string.split(sys.version)[0] dst = getextensiondirfile(src+ ' ' + version) if not dst: return 0 if not os.path.exists(os.path.join(sys.exec_prefix, src)): if not os.path.exists(os.path.join(sys.exec_prefix, altsrc)): return 0 src = altsrc try: os.unlink(dst) except os.error: pass do_copy = ask_copy() if do_copy: macostools.copy(os.path.join(sys.exec_prefix, src), dst) else: macostools.mkalias(os.path.join(sys.exec_prefix, src), dst) return 1
2a42c3a8d3b9989aacc2d7bfcdcae4bdd97649e5 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/2a42c3a8d3b9989aacc2d7bfcdcae4bdd97649e5/ConfigurePython.py
ad = self.getaddress() if ad: return ad + self.getaddrlist() else: return []
result = [] while 1: ad = self.getaddress() if ad: result += ad else: break return result
def getaddrlist(self): """Parse all addresses.
f1fd282f137952644a8c2a0330e3379e27a40582 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/f1fd282f137952644a8c2a0330e3379e27a40582/rfc822.py
version_number = float(version.split('/', 1)[1]) except ValueError:
base_version_number = version.split('/', 1)[1] version_number = base_version_number.split(".") if len(version_number) != 2: raise ValueError version_number = int(version_number[0]), int(version_number[1]) except (ValueError, IndexError):
def parse_request(self): """Parse a request (internal).
2de97d398d5a66307228b1269812da94e65e20a3 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/2de97d398d5a66307228b1269812da94e65e20a3/BaseHTTPServer.py
if version_number >= 1.1 and self.protocol_version >= "HTTP/1.1":
if version_number >= (1, 1) and self.protocol_version >= "HTTP/1.1":
def parse_request(self): """Parse a request (internal).
2de97d398d5a66307228b1269812da94e65e20a3 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/2de97d398d5a66307228b1269812da94e65e20a3/BaseHTTPServer.py
if version_number >= 2.0:
if version_number >= (2, 0):
def parse_request(self): """Parse a request (internal).
2de97d398d5a66307228b1269812da94e65e20a3 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/2de97d398d5a66307228b1269812da94e65e20a3/BaseHTTPServer.py
"Invalid HTTP Version (%f)" % version_number)
"Invalid HTTP Version (%s)" % base_version_number)
def parse_request(self): """Parse a request (internal).
2de97d398d5a66307228b1269812da94e65e20a3 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/2de97d398d5a66307228b1269812da94e65e20a3/BaseHTTPServer.py
def simple_err(func, *args): try: apply(func, args) except struct.error: pass else: raise TestFailed, "%s%s did not raise struct.error" % ( func.__name__, args)
7a3bfc3a472dafc42d20845389eb79db8af0b046 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/7a3bfc3a472dafc42d20845389eb79db8af0b046/test_struct.py
simple_err(struct.pack, "Q", -1)
any_err(struct.pack, "Q", -1)
def simple_err(func, *args): try: apply(func, args) except struct.error: pass else: raise TestFailed, "%s%s did not raise struct.error" % ( func.__name__, args)
7a3bfc3a472dafc42d20845389eb79db8af0b046 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/7a3bfc3a472dafc42d20845389eb79db8af0b046/test_struct.py
chars = list(value) chars.reverse() return "".join(chars) if has_native_qQ:
else: return string_reverse(value) def test_native_qQ():
def bigendian_to_native(value): if isbigendian: return value chars = list(value) chars.reverse() return "".join(chars)
7a3bfc3a472dafc42d20845389eb79db8af0b046 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/7a3bfc3a472dafc42d20845389eb79db8af0b046/test_struct.py
cmd = form.getvalue("cmd") or "view" page = form.getvalue("page") or "FrontPage"
cmd = form.getvalue("cmd", "view") page = form.getvalue("page", "FrontPage")
def main(): form = cgi.FieldStorage() print "Content-type: text/html" print cmd = form.getvalue("cmd") or "view" page = form.getvalue("page") or "FrontPage" wiki = WikiPage(page) wiki.load() method = getattr(wiki, 'cmd_' + cmd, None) or wiki.cmd_view method(form)
48123b266cd8d041ca6d66f148c3a6c054b2cc00 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/48123b266cd8d041ca6d66f148c3a6c054b2cc00/cgi3.py
homedir = os.path.dirname(sys.argv[0])
homedir = "/tmp"
def main(): form = cgi.FieldStorage() print "Content-type: text/html" print cmd = form.getvalue("cmd") or "view" page = form.getvalue("page") or "FrontPage" wiki = WikiPage(page) wiki.load() method = getattr(wiki, 'cmd_' + cmd, None) or wiki.cmd_view method(form)
48123b266cd8d041ca6d66f148c3a6c054b2cc00 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/48123b266cd8d041ca6d66f148c3a6c054b2cc00/cgi3.py
print "<p>", self.mklink("edit", self.name, "Edit this page") + ","
print "<p>", self.mklink("edit", self.name, "Edit this page") + ";"
def cmd_view(self, form): print "<h1>", escape(self.splitwikiword(self.name)), "</h1>" print "<p>" for line in self.data.splitlines(): line = line.rstrip() if not line: print "<p>" continue words = re.split('(\W+)', line) for i in range(len(words)): word = words[i] if self.iswikiword(word): if os.path.isfile(self.mkfile(word)): word = self.mklink("view", word, word) else: word = self.mklink("new", word, word + "*") else: word = escape(word) words[i] = word print "".join(words) print "<hr>" print "<p>", self.mklink("edit", self.name, "Edit this page") + "," print self.mklink("view", "FrontPage", "go to front page") + "."
48123b266cd8d041ca6d66f148c3a6c054b2cc00 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/48123b266cd8d041ca6d66f148c3a6c054b2cc00/cgi3.py
self.store() self.cmd_view(form)
error = self.store() if error: print "<h1>I'm sorry. That didn't work</h1>" print "<p>An error occurred while attempting to write the file:" print "<p>", escape(error) else: self.cmd_view(form)
def cmd_create(self, form): self.data = form.getvalue("text", "").strip() self.store() self.cmd_view(form)
48123b266cd8d041ca6d66f148c3a6c054b2cc00 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/48123b266cd8d041ca6d66f148c3a6c054b2cc00/cgi3.py
assert flags == 0
def search(pattern, string, flags=0): assert flags == 0 return compile(pattern, _fixflags(flags)).search(string)
1b6aecb08c5496402189f455c4f07654902a8a51 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/1b6aecb08c5496402189f455c4f07654902a8a51/sre.py
print time.strftime("expires=%a, %d-%b-%x %X GMT", gmt)
print time.strftime("expires=%a, %d-%b-%y %X GMT", gmt)
def send_my_cookie(ui): name = COOKIE_NAME value = "%s/%s/%s" % (ui.author, ui.email, ui.password) import urllib value = urllib.quote(value) then = now + COOKIE_LIFETIME gmt = time.gmtime(then) print "Set-Cookie: %s=%s; path=/cgi-bin/;" % (name, value), print time.strftime("expires=%a, %d-%b-%x %X GMT", gmt)
48b1cdea455f6d041ce853cad59b48f779cf9f18 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/48b1cdea455f6d041ce853cad59b48f779cf9f18/faqwiz.py
self.recall(sel)
self.recall(sel, event)
def enter_callback(self, event): if self.executing and not self.reading: return # Let the default binding (insert '\n') take over # If some text is selected, recall the selection # (but only if this before the I/O mark) try: sel = self.text.get("sel.first", "sel.last") if sel: if self.text.compare("sel.last", "<=", "iomark"): self.recall(sel) return "break" except: pass # If we're strictly before the line containing iomark, recall # the current line, less a leading prompt, less leading or # trailing whitespace if self.text.compare("insert", "<", "iomark linestart"): # Check if there's a relevant stdin range -- if so, use it prev = self.text.tag_prevrange("stdin", "insert") if prev and self.text.compare("insert", "<", prev[1]): self.recall(self.text.get(prev[0], prev[1])) return "break" next = self.text.tag_nextrange("stdin", "insert") if next and self.text.compare("insert lineend", ">=", next[0]): self.recall(self.text.get(next[0], next[1])) return "break" # No stdin mark -- just get the current line, less any prompt line = self.text.get("insert linestart", "insert lineend") last_line_of_prompt = sys.ps1.split('\n')[-1] if line.startswith(last_line_of_prompt): line = line[len(last_line_of_prompt):] self.recall(line) return "break" # If we're between the beginning of the line and the iomark, i.e. # in the prompt area, move to the end of the prompt if self.text.compare("insert", "<", "iomark"): self.text.mark_set("insert", "iomark") # If we're in the current input and there's only whitespace # beyond the cursor, erase that whitespace first s = self.text.get("insert", "end-1c") if s and not s.strip(): self.text.delete("insert", "end-1c") # If we're in the current input before its last line, # insert a newline right at the insert point if self.text.compare("insert", "<", "end-1c linestart"): self.newline_and_indent_event(event) return "break" # We're in the last line; append a newline and submit it self.text.mark_set("insert", "end-1c") if self.reading: self.text.insert("insert", "\n") self.text.see("insert") else: self.newline_and_indent_event(event) self.text.tag_add("stdin", "iomark", "end-1c") self.text.update_idletasks() if self.reading: self.top.quit() # Break out of recursive mainloop() in raw_input() else: self.runit() return "break"
a7daba6866136d1c554ba6bf278e9ddaf52ecac6 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/a7daba6866136d1c554ba6bf278e9ddaf52ecac6/PyShell.py
self.recall(self.text.get(prev[0], prev[1]))
self.recall(self.text.get(prev[0], prev[1]), event)
def enter_callback(self, event): if self.executing and not self.reading: return # Let the default binding (insert '\n') take over # If some text is selected, recall the selection # (but only if this before the I/O mark) try: sel = self.text.get("sel.first", "sel.last") if sel: if self.text.compare("sel.last", "<=", "iomark"): self.recall(sel) return "break" except: pass # If we're strictly before the line containing iomark, recall # the current line, less a leading prompt, less leading or # trailing whitespace if self.text.compare("insert", "<", "iomark linestart"): # Check if there's a relevant stdin range -- if so, use it prev = self.text.tag_prevrange("stdin", "insert") if prev and self.text.compare("insert", "<", prev[1]): self.recall(self.text.get(prev[0], prev[1])) return "break" next = self.text.tag_nextrange("stdin", "insert") if next and self.text.compare("insert lineend", ">=", next[0]): self.recall(self.text.get(next[0], next[1])) return "break" # No stdin mark -- just get the current line, less any prompt line = self.text.get("insert linestart", "insert lineend") last_line_of_prompt = sys.ps1.split('\n')[-1] if line.startswith(last_line_of_prompt): line = line[len(last_line_of_prompt):] self.recall(line) return "break" # If we're between the beginning of the line and the iomark, i.e. # in the prompt area, move to the end of the prompt if self.text.compare("insert", "<", "iomark"): self.text.mark_set("insert", "iomark") # If we're in the current input and there's only whitespace # beyond the cursor, erase that whitespace first s = self.text.get("insert", "end-1c") if s and not s.strip(): self.text.delete("insert", "end-1c") # If we're in the current input before its last line, # insert a newline right at the insert point if self.text.compare("insert", "<", "end-1c linestart"): self.newline_and_indent_event(event) return "break" # We're in the last line; append a newline and submit it self.text.mark_set("insert", "end-1c") if self.reading: self.text.insert("insert", "\n") self.text.see("insert") else: self.newline_and_indent_event(event) self.text.tag_add("stdin", "iomark", "end-1c") self.text.update_idletasks() if self.reading: self.top.quit() # Break out of recursive mainloop() in raw_input() else: self.runit() return "break"
a7daba6866136d1c554ba6bf278e9ddaf52ecac6 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/a7daba6866136d1c554ba6bf278e9ddaf52ecac6/PyShell.py
self.recall(self.text.get(next[0], next[1]))
self.recall(self.text.get(next[0], next[1]), event)
def enter_callback(self, event): if self.executing and not self.reading: return # Let the default binding (insert '\n') take over # If some text is selected, recall the selection # (but only if this before the I/O mark) try: sel = self.text.get("sel.first", "sel.last") if sel: if self.text.compare("sel.last", "<=", "iomark"): self.recall(sel) return "break" except: pass # If we're strictly before the line containing iomark, recall # the current line, less a leading prompt, less leading or # trailing whitespace if self.text.compare("insert", "<", "iomark linestart"): # Check if there's a relevant stdin range -- if so, use it prev = self.text.tag_prevrange("stdin", "insert") if prev and self.text.compare("insert", "<", prev[1]): self.recall(self.text.get(prev[0], prev[1])) return "break" next = self.text.tag_nextrange("stdin", "insert") if next and self.text.compare("insert lineend", ">=", next[0]): self.recall(self.text.get(next[0], next[1])) return "break" # No stdin mark -- just get the current line, less any prompt line = self.text.get("insert linestart", "insert lineend") last_line_of_prompt = sys.ps1.split('\n')[-1] if line.startswith(last_line_of_prompt): line = line[len(last_line_of_prompt):] self.recall(line) return "break" # If we're between the beginning of the line and the iomark, i.e. # in the prompt area, move to the end of the prompt if self.text.compare("insert", "<", "iomark"): self.text.mark_set("insert", "iomark") # If we're in the current input and there's only whitespace # beyond the cursor, erase that whitespace first s = self.text.get("insert", "end-1c") if s and not s.strip(): self.text.delete("insert", "end-1c") # If we're in the current input before its last line, # insert a newline right at the insert point if self.text.compare("insert", "<", "end-1c linestart"): self.newline_and_indent_event(event) return "break" # We're in the last line; append a newline and submit it self.text.mark_set("insert", "end-1c") if self.reading: self.text.insert("insert", "\n") self.text.see("insert") else: self.newline_and_indent_event(event) self.text.tag_add("stdin", "iomark", "end-1c") self.text.update_idletasks() if self.reading: self.top.quit() # Break out of recursive mainloop() in raw_input() else: self.runit() return "break"
a7daba6866136d1c554ba6bf278e9ddaf52ecac6 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/a7daba6866136d1c554ba6bf278e9ddaf52ecac6/PyShell.py
self.recall(line)
self.recall(line, event)
def enter_callback(self, event): if self.executing and not self.reading: return # Let the default binding (insert '\n') take over # If some text is selected, recall the selection # (but only if this before the I/O mark) try: sel = self.text.get("sel.first", "sel.last") if sel: if self.text.compare("sel.last", "<=", "iomark"): self.recall(sel) return "break" except: pass # If we're strictly before the line containing iomark, recall # the current line, less a leading prompt, less leading or # trailing whitespace if self.text.compare("insert", "<", "iomark linestart"): # Check if there's a relevant stdin range -- if so, use it prev = self.text.tag_prevrange("stdin", "insert") if prev and self.text.compare("insert", "<", prev[1]): self.recall(self.text.get(prev[0], prev[1])) return "break" next = self.text.tag_nextrange("stdin", "insert") if next and self.text.compare("insert lineend", ">=", next[0]): self.recall(self.text.get(next[0], next[1])) return "break" # No stdin mark -- just get the current line, less any prompt line = self.text.get("insert linestart", "insert lineend") last_line_of_prompt = sys.ps1.split('\n')[-1] if line.startswith(last_line_of_prompt): line = line[len(last_line_of_prompt):] self.recall(line) return "break" # If we're between the beginning of the line and the iomark, i.e. # in the prompt area, move to the end of the prompt if self.text.compare("insert", "<", "iomark"): self.text.mark_set("insert", "iomark") # If we're in the current input and there's only whitespace # beyond the cursor, erase that whitespace first s = self.text.get("insert", "end-1c") if s and not s.strip(): self.text.delete("insert", "end-1c") # If we're in the current input before its last line, # insert a newline right at the insert point if self.text.compare("insert", "<", "end-1c linestart"): self.newline_and_indent_event(event) return "break" # We're in the last line; append a newline and submit it self.text.mark_set("insert", "end-1c") if self.reading: self.text.insert("insert", "\n") self.text.see("insert") else: self.newline_and_indent_event(event) self.text.tag_add("stdin", "iomark", "end-1c") self.text.update_idletasks() if self.reading: self.top.quit() # Break out of recursive mainloop() in raw_input() else: self.runit() return "break"
a7daba6866136d1c554ba6bf278e9ddaf52ecac6 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/a7daba6866136d1c554ba6bf278e9ddaf52ecac6/PyShell.py
def recall(self, s): if self.history: self.history.recall(s)
def recall(self, s, event): self.text.undo_block_start() try: self.text.tag_remove("sel", "1.0", "end") self.text.mark_set("insert", "end-1c") s = s.strip() lines = s.split('\n') if lines: prefix = self.text.get("insert linestart","insert").rstrip() if prefix and prefix[-1]==':': self.newline_and_indent_event(event) self.text.insert("insert",lines[0].strip()) if len(lines) > 1: self.newline_and_indent_event(event) for line in lines[1:]: self.text.insert("insert", line.strip()) self.newline_and_indent_event(event) else: self.text.insert("insert", s) finally: self.text.see("insert") self.text.undo_block_stop()
def recall(self, s): if self.history: self.history.recall(s)
a7daba6866136d1c554ba6bf278e9ddaf52ecac6 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/a7daba6866136d1c554ba6bf278e9ddaf52ecac6/PyShell.py
except (DistutilsExecError, DistutilsFileError, DistutilsOptionError,
except (DistutilsError,
def setup (**attrs): """The gateway to the Distutils: do everything your setup script needs to do, in a highly flexible and user-driven way. Briefly: create a Distribution instance; find and parse config files; parse the command line; run each Distutils command found there, customized by the options supplied to 'setup()' (as keyword arguments), in config files, and on the command line. The Distribution instance might be an instance of a class supplied via the 'distclass' keyword argument to 'setup'; if no such class is supplied, then the Distribution class (in dist.py) is instantiated. All other arguments to 'setup' (except for 'cmdclass') are used to set attributes of the Distribution instance. The 'cmdclass' argument, if supplied, is a dictionary mapping command names to command classes. Each command encountered on the command line will be turned into a command class, which is in turn instantiated; any class found in 'cmdclass' is used in place of the default, which is (for command 'foo_bar') class 'foo_bar' in module 'distutils.command.foo_bar'. The command class must provide a 'user_options' attribute which is a list of option specifiers for 'distutils.fancy_getopt'. Any command-line options between the current and the next command are used to set attributes of the current command object. When the entire command-line has been successfully parsed, calls the 'run()' method on each command object in turn. This method will be driven entirely by the Distribution object (which each command object has a reference to, thanks to its constructor), and the command-specific options that became attributes of each command object. """ global _setup_stop_after, _setup_distribution # Determine the distribution class -- either caller-supplied or # our Distribution (see below). klass = attrs.get('distclass') if klass: del attrs['distclass'] else: klass = Distribution if not attrs.has_key('script_name'): attrs['script_name'] = os.path.basename(sys.argv[0]) if not attrs.has_key('script_args'): attrs['script_args'] = sys.argv[1:] # Create the Distribution instance, using the remaining arguments # (ie. everything except distclass) to initialize it try: _setup_distribution = dist = klass(attrs) except DistutilsSetupError, msg: if attrs.has_key('name'): raise SystemExit, "error in %s setup command: %s" % \ (attrs['name'], msg) else: raise SystemExit, "error in setup command: %s" % msg if _setup_stop_after == "init": return dist # Find and parse the config file(s): they will override options from # the setup script, but be overridden by the command line. dist.parse_config_files() if DEBUG: print "options (after parsing config files):" dist.dump_option_dicts() if _setup_stop_after == "config": return dist # Parse the command line; any command-line errors are the end user's # fault, so turn them into SystemExit to suppress tracebacks. try: ok = dist.parse_command_line() except DistutilsArgError, msg: raise SystemExit, gen_usage(dist.script_name) + "\nerror: %s" % msg if DEBUG: print "options (after parsing command line):" dist.dump_option_dicts() if _setup_stop_after == "commandline": return dist # And finally, run all the commands found on the command line. if ok: try: dist.run_commands() except KeyboardInterrupt: raise SystemExit, "interrupted" except (IOError, os.error), exc: error = grok_environment_error(exc) if DEBUG: sys.stderr.write(error + "\n") raise else: raise SystemExit, error except (DistutilsExecError, DistutilsFileError, DistutilsOptionError, CCompilerError), msg: if DEBUG: raise else: raise SystemExit, "error: " + str(msg) return dist
91e77536e8285bd2276a40bb891efc9001b9f8a6 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/91e77536e8285bd2276a40bb891efc9001b9f8a6/core.py
y = _reconstruct(x, reductor(), 1)
y = _reconstruct(x, reductor(), 1, memo)
def deepcopy(x, memo = None): """Deep copy operation on arbitrary Python objects. See the module's __doc__ string for more info. """ if memo is None: memo = {} d = id(x) if memo.has_key(d): return memo[d] try: copierfunction = _deepcopy_dispatch[type(x)] except KeyError: try: copier = x.__deepcopy__ except AttributeError: try: reductor = x.__reduce__ except AttributeError: raise error, \ "un-deep-copyable object of type %s" % type(x) else: y = _reconstruct(x, reductor(), 1) else: y = copier(memo) else: y = copierfunction(x, memo) memo[d] = y return y
1e91c1444a9c8b8b58310cffbe4252698527a31e /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/1e91c1444a9c8b8b58310cffbe4252698527a31e/copy.py
def _reconstruct(x, info, deep):
def _reconstruct(x, info, deep, memo=None):
def _reconstruct(x, info, deep): if isinstance(info, str): return x assert isinstance(info, tuple) n = len(info) assert n in (2, 3) callable, args = info[:2] if n > 2: state = info[2] else: state = {} if deep: args = deepcopy(args) y = callable(*args) if state: if deep: state = deepcopy(state) y.__dict__.update(state) return y
1e91c1444a9c8b8b58310cffbe4252698527a31e /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/1e91c1444a9c8b8b58310cffbe4252698527a31e/copy.py
args = deepcopy(args)
args = deepcopy(args, memo)
def _reconstruct(x, info, deep): if isinstance(info, str): return x assert isinstance(info, tuple) n = len(info) assert n in (2, 3) callable, args = info[:2] if n > 2: state = info[2] else: state = {} if deep: args = deepcopy(args) y = callable(*args) if state: if deep: state = deepcopy(state) y.__dict__.update(state) return y
1e91c1444a9c8b8b58310cffbe4252698527a31e /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/1e91c1444a9c8b8b58310cffbe4252698527a31e/copy.py
state = deepcopy(state)
state = deepcopy(state, memo)
def _reconstruct(x, info, deep): if isinstance(info, str): return x assert isinstance(info, tuple) n = len(info) assert n in (2, 3) callable, args = info[:2] if n > 2: state = info[2] else: state = {} if deep: args = deepcopy(args) y = callable(*args) if state: if deep: state = deepcopy(state) y.__dict__.update(state) return y
1e91c1444a9c8b8b58310cffbe4252698527a31e /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/1e91c1444a9c8b8b58310cffbe4252698527a31e/copy.py
if os.name !='riscos': TESTFN = '@test'
if os.name == 'java': TESTFN = '$test' elif os.name != 'riscos': TESTFN = '@test'
def fcmp(x, y): # fuzzy comparison function if type(x) == type(0.0) or type(y) == type(0.0): try: x, y = coerce(x, y) fuzz = (abs(x) + abs(y)) * FUZZ if abs(x-y) <= fuzz: return 0 except: pass elif type(x) == type(y) and type(x) in (type(()), type([])): for i in range(min(len(x), len(y))): outcome = fcmp(x[i], y[i]) if outcome != 0: return outcome return cmp(len(x), len(y)) return cmp(x, y)
559f6680c27f346c89e6dd29ba3235f7719ea6a7 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/559f6680c27f346c89e6dd29ba3235f7719ea6a7/test_support.py
TESTFN = 'test'
TESTFN = 'test'
def fcmp(x, y): # fuzzy comparison function if type(x) == type(0.0) or type(y) == type(0.0): try: x, y = coerce(x, y) fuzz = (abs(x) + abs(y)) * FUZZ if abs(x-y) <= fuzz: return 0 except: pass elif type(x) == type(y) and type(x) in (type(()), type([])): for i in range(min(len(x), len(y))): outcome = fcmp(x[i], y[i]) if outcome != 0: return outcome return cmp(len(x), len(y)) return cmp(x, y)
559f6680c27f346c89e6dd29ba3235f7719ea6a7 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/559f6680c27f346c89e6dd29ba3235f7719ea6a7/test_support.py
self.tk.call(self._w, 'select', 'item')
return self.tk.call(self._w, 'select', 'item') or None
def select_item(self): """Return the item which has the selection.""" self.tk.call(self._w, 'select', 'item')
58b63bf4e3e8ef082126c3687edd2cf75226303d /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/58b63bf4e3e8ef082126c3687edd2cf75226303d/Tkinter.py
exit = 'Use Cmd-Q to quit.'
eof = 'Cmd-Q'
def setquit(): """Define new built-ins 'quit' and 'exit'. These are simply strings that display a hint on how to exit. """ if os.sep == ':': exit = 'Use Cmd-Q to quit.' elif os.sep == '\\': exit = 'Use Ctrl-Z plus Return to exit.' else: exit = 'Use Ctrl-D (i.e. EOF) to exit.' __builtin__.quit = __builtin__.exit = exit
24cb053b158a3cd63f7be05ac27f47e45bb2f1b3 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/24cb053b158a3cd63f7be05ac27f47e45bb2f1b3/site.py
exit = 'Use Ctrl-Z plus Return to exit.'
eof = 'Ctrl-Z plus Return'
def setquit(): """Define new built-ins 'quit' and 'exit'. These are simply strings that display a hint on how to exit. """ if os.sep == ':': exit = 'Use Cmd-Q to quit.' elif os.sep == '\\': exit = 'Use Ctrl-Z plus Return to exit.' else: exit = 'Use Ctrl-D (i.e. EOF) to exit.' __builtin__.quit = __builtin__.exit = exit
24cb053b158a3cd63f7be05ac27f47e45bb2f1b3 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/24cb053b158a3cd63f7be05ac27f47e45bb2f1b3/site.py
exit = 'Use Ctrl-D (i.e. EOF) to exit.' __builtin__.quit = __builtin__.exit = exit
eof = 'Ctrl-D (i.e. EOF)' class Quitter(object): def __init__(self, name): self.name = name def __repr__(self): return 'Use %s() or %s to exit' % (self.name, eof) def __call__(self, code=None): raise SystemExit(code) __builtin__.quit = Quitter('quit') __builtin__.exit = Quitter('exit')
def setquit(): """Define new built-ins 'quit' and 'exit'. These are simply strings that display a hint on how to exit. """ if os.sep == ':': exit = 'Use Cmd-Q to quit.' elif os.sep == '\\': exit = 'Use Ctrl-Z plus Return to exit.' else: exit = 'Use Ctrl-D (i.e. EOF) to exit.' __builtin__.quit = __builtin__.exit = exit
24cb053b158a3cd63f7be05ac27f47e45bb2f1b3 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/24cb053b158a3cd63f7be05ac27f47e45bb2f1b3/site.py
import string
def __init__(self, dirname): import string self.dirname = dirname
de3518e7cabf752cc2066878465957dcf552957d /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/de3518e7cabf752cc2066878465957dcf552957d/mailbox.py
import string
def _test(): import time import sys import string import os args = sys.argv[1:] if not args: for key in 'MAILDIR', 'MAIL', 'LOGNAME', 'USER': if os.environ.has_key(key): mbox = os.environ[key] break else: print "$MAIL, $LOGNAME nor $USER set -- who are you?" return else: mbox = args[0] if mbox[:1] == '+': mbox = os.environ['HOME'] + '/Mail/' + mbox[1:] elif not '/' in mbox: mbox = '/usr/mail/' + mbox if os.path.isdir(mbox): if os.path.isdir(os.path.join(mbox, 'cur')): mb = Maildir(mbox) else: mb = MHMailbox(mbox) else: fp = open(mbox, 'r') mb = UnixMailbox(fp) msgs = [] while 1: msg = mb.next() if msg is None: break msgs.append(msg) if len(args) <= 1: msg.fp = None if len(args) > 1: num = string.atoi(args[1]) print 'Message %d body:'%num msg = msgs[num-1] msg.rewindbody() sys.stdout.write(msg.fp.read()) else: print 'Mailbox',mbox,'has',len(msgs),'messages:' for msg in msgs: f = msg.getheader('from') or "" s = msg.getheader('subject') or "" d = msg.getheader('date') or "" print '-%20.20s %20.20s %-30.30s'%(f, d[5:], s)
de3518e7cabf752cc2066878465957dcf552957d /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/de3518e7cabf752cc2066878465957dcf552957d/mailbox.py
num = string.atoi(args[1])
num = int(args[1])
def _test(): import time import sys import string import os args = sys.argv[1:] if not args: for key in 'MAILDIR', 'MAIL', 'LOGNAME', 'USER': if os.environ.has_key(key): mbox = os.environ[key] break else: print "$MAIL, $LOGNAME nor $USER set -- who are you?" return else: mbox = args[0] if mbox[:1] == '+': mbox = os.environ['HOME'] + '/Mail/' + mbox[1:] elif not '/' in mbox: mbox = '/usr/mail/' + mbox if os.path.isdir(mbox): if os.path.isdir(os.path.join(mbox, 'cur')): mb = Maildir(mbox) else: mb = MHMailbox(mbox) else: fp = open(mbox, 'r') mb = UnixMailbox(fp) msgs = [] while 1: msg = mb.next() if msg is None: break msgs.append(msg) if len(args) <= 1: msg.fp = None if len(args) > 1: num = string.atoi(args[1]) print 'Message %d body:'%num msg = msgs[num-1] msg.rewindbody() sys.stdout.write(msg.fp.read()) else: print 'Mailbox',mbox,'has',len(msgs),'messages:' for msg in msgs: f = msg.getheader('from') or "" s = msg.getheader('subject') or "" d = msg.getheader('date') or "" print '-%20.20s %20.20s %-30.30s'%(f, d[5:], s)
de3518e7cabf752cc2066878465957dcf552957d /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/de3518e7cabf752cc2066878465957dcf552957d/mailbox.py
self.mkpath (os.path.dirname (obj))
self.mkpath(os.path.dirname(obj))
def compile (self, sources, output_dir=None, macros=None, include_dirs=None, debug=0, extra_preargs=None, extra_postargs=None):
c58c5177419a3703cb2c6397471ab1e8756a6755 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/c58c5177419a3703cb2c6397471ab1e8756a6755/bcppcompiler.py
def compile (self, sources, output_dir=None, macros=None, include_dirs=None, debug=0, extra_preargs=None, extra_postargs=None):
c58c5177419a3703cb2c6397471ab1e8756a6755 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/c58c5177419a3703cb2c6397471ab1e8756a6755/bcppcompiler.py
ldflags = self.ldflags_shared_debug
ld_args = self.ldflags_shared_debug[:]
def link_shared_object (self, objects, output_filename, output_dir=None, libraries=None, library_dirs=None, runtime_library_dirs=None, export_symbols=None, debug=0, extra_preargs=None, extra_postargs=None, build_temp=None):
c58c5177419a3703cb2c6397471ab1e8756a6755 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/c58c5177419a3703cb2c6397471ab1e8756a6755/bcppcompiler.py
ldflags = self.ldflags_shared
ld_args = self.ldflags_shared[:] objects = map(os.path.normpath, objects)
def link_shared_object (self, objects, output_filename, output_dir=None, libraries=None, library_dirs=None, runtime_library_dirs=None, export_symbols=None, debug=0, extra_preargs=None, extra_postargs=None, build_temp=None):
c58c5177419a3703cb2c6397471ab1e8756a6755 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/c58c5177419a3703cb2c6397471ab1e8756a6755/bcppcompiler.py
libraries.append ('mypylib')
objects.insert(0, startup_obj)
def link_shared_object (self, objects, output_filename, output_dir=None, libraries=None, library_dirs=None, runtime_library_dirs=None, export_symbols=None, debug=0, extra_preargs=None, extra_postargs=None, build_temp=None):
c58c5177419a3703cb2c6397471ab1e8756a6755 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/c58c5177419a3703cb2c6397471ab1e8756a6755/bcppcompiler.py
def_file = os.path.join (build_temp, '%s.def' % modname) f = open (def_file, 'w') f.write ('EXPORTS\n')
temp_dir = os.path.dirname(objects[0]) def_file = os.path.join (temp_dir, '%s.def' % modname) contents = ['EXPORTS']
def link_shared_object (self, objects, output_filename, output_dir=None, libraries=None, library_dirs=None, runtime_library_dirs=None, export_symbols=None, debug=0, extra_preargs=None, extra_postargs=None, build_temp=None):
c58c5177419a3703cb2c6397471ab1e8756a6755 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/c58c5177419a3703cb2c6397471ab1e8756a6755/bcppcompiler.py
f.write (' %s=_%s\n' % (sym, sym)) ld_args = ldflags + [startup_obj] + objects + \ [',%s,,' % output_filename] + \ libraries + [',' + def_file]
contents.append(' %s=_%s' % (sym, sym)) self.execute(write_file, (def_file, contents), "writing %s" % def_file) for l in library_dirs: ld_args.append("/L%s" % os.path.normpath(l)) ld_args.extend(objects) ld_args.extend([',',output_filename]) ld_args.extend([',', ',']) for lib in libraries: libfile = self.find_library_file(library_dirs, lib, debug) if libfile is None: ld_args.append(lib) else: ld_args.append(libfile) ld_args.extend([',',def_file])
def link_shared_object (self, objects, output_filename, output_dir=None, libraries=None, library_dirs=None, runtime_library_dirs=None, export_symbols=None, debug=0, extra_preargs=None, extra_postargs=None, build_temp=None):
c58c5177419a3703cb2c6397471ab1e8756a6755 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/c58c5177419a3703cb2c6397471ab1e8756a6755/bcppcompiler.py
ld_args.extend (extra_postargs)
ld_args.extend(extra_postargs)
def link_shared_object (self, objects, output_filename, output_dir=None, libraries=None, library_dirs=None, runtime_library_dirs=None, export_symbols=None, debug=0, extra_preargs=None, extra_postargs=None, build_temp=None):
c58c5177419a3703cb2c6397471ab1e8756a6755 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/c58c5177419a3703cb2c6397471ab1e8756a6755/bcppcompiler.py
"don't know how to set runtime library search path for MSVC++"
("don't know how to set runtime library search path " "for Borland C++")
def runtime_library_dir_option (self, dir): raise DistutilsPlatformError, \ "don't know how to set runtime library search path for MSVC++"
c58c5177419a3703cb2c6397471ab1e8756a6755 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/c58c5177419a3703cb2c6397471ab1e8756a6755/bcppcompiler.py
def find_library_file (self, dirs, lib):
def find_library_file (self, dirs, lib, debug=0):
def find_library_file (self, dirs, lib):
c58c5177419a3703cb2c6397471ab1e8756a6755 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/c58c5177419a3703cb2c6397471ab1e8756a6755/bcppcompiler.py
if not code1 and err1 == err2:
try: e1 = err1.__dict__ except AttributeError: e1 = err1 try: e2 = err2.__dict__ except AttributeError: e2 = err2 if not code1 and e1 == e2:
def compile_command(source, filename="<input>", symbol="single"): r"""Compile a command and determine whether it is incomplete. Arguments: source -- the source string; may contain \n characters filename -- optional filename from which source was read; default "<input>" symbol -- optional grammar start symbol; "single" (default) or "eval" Return value / exception raised: - Return a code object if the command is complete and valid - Return None if the command is incomplete - Raise SyntaxError if the command is a syntax error Approach: Compile three times: as is, with \n, and with \n\n appended. If it compiles as is, it's complete. If it compiles with one \n appended, we expect more. If it doesn't compile either way, we compare the error we get when compiling with \n or \n\n appended. If the errors are the same, the code is broken. But if the errors are different, we expect more. Not intuitive; not even guaranteed to hold in future releases; but this matches the compiler's behavior in Python 1.4 and 1.5. """ err = err1 = err2 = None code = code1 = code2 = None try: code = compile(source, filename, symbol) except SyntaxError, err: pass try: code1 = compile(source + "\n", filename, symbol) except SyntaxError, err1: pass try: code2 = compile(source + "\n\n", filename, symbol) except SyntaxError, err2: pass if code: return code if not code1 and err1 == err2: raise SyntaxError, err1
8687164426da64ec03762c0e73daac91fba17927 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/8687164426da64ec03762c0e73daac91fba17927/code.py
def findnames(file, prefix=""):
def findnames(file, prefixes=()):
def findnames(file, prefix=""): names = {} for line in file.readlines(): if line[0] == '!': continue fields = line.split() name, tag = fields[0], fields[-1] if tag == 'd' and name.endswith('_H'): continue if name.startswith(prefix): names[name] = tag return names
ea4d2c0241f3f32a7ff0fdc0b1b5c8e4bb58e445 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/ea4d2c0241f3f32a7ff0fdc0b1b5c8e4bb58e445/undoc_symbols.py
for line in file.readlines():
for line in file.xreadlines():
def findnames(file, prefix=""): names = {} for line in file.readlines(): if line[0] == '!': continue fields = line.split() name, tag = fields[0], fields[-1] if tag == 'd' and name.endswith('_H'): continue if name.startswith(prefix): names[name] = tag return names
ea4d2c0241f3f32a7ff0fdc0b1b5c8e4bb58e445 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/ea4d2c0241f3f32a7ff0fdc0b1b5c8e4bb58e445/undoc_symbols.py
if name.startswith(prefix):
if prefixes: sw = name.startswith for prefix in prefixes: if sw(prefix): names[name] = tag else:
def findnames(file, prefix=""): names = {} for line in file.readlines(): if line[0] == '!': continue fields = line.split() name, tag = fields[0], fields[-1] if tag == 'd' and name.endswith('_H'): continue if name.startswith(prefix): names[name] = tag return names
ea4d2c0241f3f32a7ff0fdc0b1b5c8e4bb58e445 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/ea4d2c0241f3f32a7ff0fdc0b1b5c8e4bb58e445/undoc_symbols.py
fp = os.popen("ctags -IDL_IMPORT --c-types=%s -f - %s" % (TAG_KINDS, incfiles))
fp = os.popen("ctags -IDL_IMPORT --c-types=%s -f - %s" % (TAG_KINDS, incfiles))
def print_undoc_symbols(prefix, docdir, incdir): docs = [] for sect in DOCSECTIONS: for file in glob.glob(os.path.join(docdir, sect, "*.tex")): docs.append(open(file).read()) docs = "\n".join(docs) incfiles = os.path.join(incdir, INCLUDEPATTERN) fp = os.popen("ctags -IDL_IMPORT --c-types=%s -f - %s" % (TAG_KINDS, incfiles)) dict = findnames(fp, prefix) names = dict.keys() names.sort() for name in names: if docs.find(name) == -1: print dict[name], name
ea4d2c0241f3f32a7ff0fdc0b1b5c8e4bb58e445 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/ea4d2c0241f3f32a7ff0fdc0b1b5c8e4bb58e445/undoc_symbols.py
print_undoc_symbols(PREFIX, docdir, incdir)
print_undoc_symbols(PREFIXES, docdir, incdir)
def print_undoc_symbols(prefix, docdir, incdir): docs = [] for sect in DOCSECTIONS: for file in glob.glob(os.path.join(docdir, sect, "*.tex")): docs.append(open(file).read()) docs = "\n".join(docs) incfiles = os.path.join(incdir, INCLUDEPATTERN) fp = os.popen("ctags -IDL_IMPORT --c-types=%s -f - %s" % (TAG_KINDS, incfiles)) dict = findnames(fp, prefix) names = dict.keys() names.sort() for name in names: if docs.find(name) == -1: print dict[name], name
ea4d2c0241f3f32a7ff0fdc0b1b5c8e4bb58e445 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/ea4d2c0241f3f32a7ff0fdc0b1b5c8e4bb58e445/undoc_symbols.py
if '/usr/local/lib' not in self.compiler.library_dirs: self.compiler.library_dirs.insert(0, '/usr/local/lib') if '/usr/local/include' not in self.compiler.include_dirs: self.compiler.include_dirs.insert(0, '/usr/local/include' )
add_dir_to_list(self.compiler.library_dirs, '/usr/local/lib') add_dir_to_list(self.compiler.include_dirs, '/usr/local/include') add_dir_to_list(self.compiler.library_dirs, sysconfig.get_config_var("LIBDIR")) add_dir_to_list(self.compiler.include_dirs, sysconfig.get_config_var("INCLUDEDIR"))
def detect_modules(self): # Ensure that /usr/local is always used if '/usr/local/lib' not in self.compiler.library_dirs: self.compiler.library_dirs.insert(0, '/usr/local/lib') if '/usr/local/include' not in self.compiler.include_dirs: self.compiler.include_dirs.insert(0, '/usr/local/include' )
39230b3230783d55fd5b21c0f745ab5eec366fa5 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/39230b3230783d55fd5b21c0f745ab5eec366fa5/setup.py
def test_main(): test.test_support.run_unittest(BuiltinTest, TestSorted)
def test_main(verbose=None): test_classes = (BuiltinTest, TestSorted) run_unittest(*test_classes) if verbose and hasattr(sys, "gettotalrefcount"): import gc counts = [None] * 5 for i in xrange(len(counts)): run_unittest(*test_classes) gc.collect() counts[i] = sys.gettotalrefcount() print counts
def test_main(): test.test_support.run_unittest(BuiltinTest, TestSorted)
3b0c7c20a10349fbedeb3779582280363a46f087 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/3b0c7c20a10349fbedeb3779582280363a46f087/test_builtin.py
test_main()
test_main(verbose=True)
def test_main(): test.test_support.run_unittest(BuiltinTest, TestSorted)
3b0c7c20a10349fbedeb3779582280363a46f087 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/3b0c7c20a10349fbedeb3779582280363a46f087/test_builtin.py
for option in options: yield (option, d[option])
return [(option, d[option]) for option in options]
def items(self, section, raw=False, vars=None): """Return a list of tuples with (name, value) for each option in the section.
8c4da53afedd7b7fa49f7209582b2f61d80f457e /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/8c4da53afedd7b7fa49f7209582b2f61d80f457e/ConfigParser.py
for option in options: yield (option, self._interpolate(section, option, d[option], d))
return [(option, self._interpolate(section, option, d[option], d)) for option in options]
def items(self, section, raw=False, vars=None): """Return a list of tuples with (name, value) for each option in the section.
8c4da53afedd7b7fa49f7209582b2f61d80f457e /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/8c4da53afedd7b7fa49f7209582b2f61d80f457e/ConfigParser.py
def __init__(self, locale_time=LocaleTime()):
def __init__(self, locale_time=None):
def __init__(self, locale_time=LocaleTime()): """Init inst with non-locale regexes and store LocaleTime object.""" #XXX: Does 'Y' need to worry about having less or more than 4 digits? base = super(TimeRE, self) base.__init__({ # The " \d" option is to make %c from ANSI C work 'd': r"(?P<d>3[0-1]|[1-2]\d|0[1-9]|[1-9]| [1-9])", 'H': r"(?P<H>2[0-3]|[0-1]\d|\d)", 'I': r"(?P<I>1[0-2]|0[1-9]|[1-9])", 'j': r"(?P<j>36[0-6]|3[0-5]\d|[1-2]\d\d|0[1-9]\d|00[1-9]|[1-9]\d|0[1-9]|[1-9])", 'm': r"(?P<m>1[0-2]|0[1-9]|[1-9])", 'M': r"(?P<M>[0-5]\d|\d)", 'S': r"(?P<S>6[0-1]|[0-5]\d|\d)", 'U': r"(?P<U>5[0-3]|[0-4]\d|\d)", 'w': r"(?P<w>[0-6])", # W is set below by using 'U' 'y': r"(?P<y>\d\d)", 'Y': r"(?P<Y>\d\d\d\d)"}) base.__setitem__('W', base.__getitem__('U')) self.locale_time = locale_time
2c24d42d329ad48cc7c92bfed935c28e8fcdd188 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/2c24d42d329ad48cc7c92bfed935c28e8fcdd188/_strptime.py
self.locale_time = locale_time
if locale_time: self.locale_time = locale_time else: self.locale_time = LocaleTime()
def __init__(self, locale_time=LocaleTime()): """Init inst with non-locale regexes and store LocaleTime object.""" #XXX: Does 'Y' need to worry about having less or more than 4 digits? base = super(TimeRE, self) base.__init__({ # The " \d" option is to make %c from ANSI C work 'd': r"(?P<d>3[0-1]|[1-2]\d|0[1-9]|[1-9]| [1-9])", 'H': r"(?P<H>2[0-3]|[0-1]\d|\d)", 'I': r"(?P<I>1[0-2]|0[1-9]|[1-9])", 'j': r"(?P<j>36[0-6]|3[0-5]\d|[1-2]\d\d|0[1-9]\d|00[1-9]|[1-9]\d|0[1-9]|[1-9])", 'm': r"(?P<m>1[0-2]|0[1-9]|[1-9])", 'M': r"(?P<M>[0-5]\d|\d)", 'S': r"(?P<S>6[0-1]|[0-5]\d|\d)", 'U': r"(?P<U>5[0-3]|[0-4]\d|\d)", 'w': r"(?P<w>[0-6])", # W is set below by using 'U' 'y': r"(?P<y>\d\d)", 'Y': r"(?P<Y>\d\d\d\d)"}) base.__setitem__('W', base.__getitem__('U')) self.locale_time = locale_time
2c24d42d329ad48cc7c92bfed935c28e8fcdd188 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/2c24d42d329ad48cc7c92bfed935c28e8fcdd188/_strptime.py
print "Failing syntax tree:" pprint.pprint(t) raise
raise TestFailed, s
def roundtrip(f, s): st1 = f(s) t = st1.totuple() try: st2 = parser.sequence2ast(t) except parser.ParserError: print "Failing syntax tree:" pprint.pprint(t) raise
e3fb18c1c47bda766c8e234368f4884cec1189ce /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/e3fb18c1c47bda766c8e234368f4884cec1189ce/test_parser.py
roundtrip(suite, open(filename).read())
roundtrip(parser.suite, open(filename).read())
def roundtrip_fromfile(filename): roundtrip(suite, open(filename).read())
e3fb18c1c47bda766c8e234368f4884cec1189ce /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/e3fb18c1c47bda766c8e234368f4884cec1189ce/test_parser.py
roundtrip(expr, s)
roundtrip(parser.expr, s)
def test_expr(s): print "expr:", s roundtrip(expr, s)
e3fb18c1c47bda766c8e234368f4884cec1189ce /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/e3fb18c1c47bda766c8e234368f4884cec1189ce/test_parser.py
roundtrip(suite, s)
roundtrip(parser.suite, s)
def test_suite(s): print "suite:", s roundtrip(suite, s)
e3fb18c1c47bda766c8e234368f4884cec1189ce /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/e3fb18c1c47bda766c8e234368f4884cec1189ce/test_parser.py
sequence2ast(tree)
parser.sequence2ast(tree)
def check_bad_tree(tree, label): print print label try: sequence2ast(tree) except parser.ParserError: print "caught expected exception for invalid tree" pass else: print "test failed: did not properly detect invalid tree:" pprint.pprint(tree)
e3fb18c1c47bda766c8e234368f4884cec1189ce /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/e3fb18c1c47bda766c8e234368f4884cec1189ce/test_parser.py
pass
def check_bad_tree(tree, label): print print label try: sequence2ast(tree) except parser.ParserError: print "caught expected exception for invalid tree" pass else: print "test failed: did not properly detect invalid tree:" pprint.pprint(tree)
e3fb18c1c47bda766c8e234368f4884cec1189ce /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/e3fb18c1c47bda766c8e234368f4884cec1189ce/test_parser.py
def get_devstudio_versions (): """Get list of devstudio versions from the Windows registry. Return a list of strings (???) containing version numbers; the list will be empty if we were unable to access the registry (eg. couldn't import a registry-access module) or the appropriate registry keys weren't found. (XXX is this correct???)""" try: import win32api import win32con except ImportError: return [] K = 'Software\\Microsoft\\Devstudio' L = [] for base in (win32con.HKEY_CLASSES_ROOT, win32con.HKEY_LOCAL_MACHINE, win32con.HKEY_CURRENT_USER, win32con.HKEY_USERS): try: k = win32api.RegOpenKeyEx(base,K) i = 0 while 1: try: p = win32api.RegEnumKey(k,i) if p[0] in '123456789' and p not in L: L.append(p) except win32api.error: break i = i + 1 except win32api.error: pass L.sort() L.reverse() return L
699880931e52bf7d77326f3308151b37cee42dfe /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/699880931e52bf7d77326f3308151b37cee42dfe/msvccompiler.py
list of strings (???) containing version numbers; the list will be
list of strings containing version numbers; the list will be
def get_devstudio_versions (): """Get list of devstudio versions from the Windows registry. Return a list of strings (???) containing version numbers; the list will be empty if we were unable to access the registry (eg. couldn't import a registry-access module) or the appropriate registry keys weren't found. (XXX is this correct???)""" try: import win32api import win32con except ImportError: return [] K = 'Software\\Microsoft\\Devstudio' L = [] for base in (win32con.HKEY_CLASSES_ROOT, win32con.HKEY_LOCAL_MACHINE, win32con.HKEY_CURRENT_USER, win32con.HKEY_USERS): try: k = win32api.RegOpenKeyEx(base,K) i = 0 while 1: try: p = win32api.RegEnumKey(k,i) if p[0] in '123456789' and p not in L: L.append(p) except win32api.error: break i = i + 1 except win32api.error: pass L.sort() L.reverse() return L
699880931e52bf7d77326f3308151b37cee42dfe /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/699880931e52bf7d77326f3308151b37cee42dfe/msvccompiler.py
found. (XXX is this correct???)"""
found."""
def get_devstudio_versions (): """Get list of devstudio versions from the Windows registry. Return a list of strings (???) containing version numbers; the list will be empty if we were unable to access the registry (eg. couldn't import a registry-access module) or the appropriate registry keys weren't found. (XXX is this correct???)""" try: import win32api import win32con except ImportError: return [] K = 'Software\\Microsoft\\Devstudio' L = [] for base in (win32con.HKEY_CLASSES_ROOT, win32con.HKEY_LOCAL_MACHINE, win32con.HKEY_CURRENT_USER, win32con.HKEY_USERS): try: k = win32api.RegOpenKeyEx(base,K) i = 0 while 1: try: p = win32api.RegEnumKey(k,i) if p[0] in '123456789' and p not in L: L.append(p) except win32api.error: break i = i + 1 except win32api.error: pass L.sort() L.reverse() return L
699880931e52bf7d77326f3308151b37cee42dfe /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/699880931e52bf7d77326f3308151b37cee42dfe/msvccompiler.py
"""Get a devstudio path (include, lib or path)."""
"""Get a list of devstudio directories (include, lib or path). Return a list of strings; will be empty list if unable to access the registry or appropriate registry keys not found."""
def get_msvc_paths (path, version='6.0', platform='x86'): """Get a devstudio path (include, lib or path).""" try: import win32api import win32con except ImportError: return None L = [] if path=='lib': path= 'Library' path = string.upper(path + ' Dirs') K = ('Software\\Microsoft\\Devstudio\\%s\\' + 'Build System\\Components\\Platforms\\Win32 (%s)\\Directories') % \ (version,platform) for base in (win32con.HKEY_CLASSES_ROOT, win32con.HKEY_LOCAL_MACHINE, win32con.HKEY_CURRENT_USER, win32con.HKEY_USERS): try: k = win32api.RegOpenKeyEx(base,K) i = 0 while 1: try: (p,v,t) = win32api.RegEnumValue(k,i) if string.upper(p) == path: V = string.split(v,';') for v in V: if v == '' or v in L: continue L.append(v) break i = i + 1 except win32api.error: break except win32api.error: pass return L
699880931e52bf7d77326f3308151b37cee42dfe /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/699880931e52bf7d77326f3308151b37cee42dfe/msvccompiler.py
return None
return []
def get_msvc_paths (path, version='6.0', platform='x86'): """Get a devstudio path (include, lib or path).""" try: import win32api import win32con except ImportError: return None L = [] if path=='lib': path= 'Library' path = string.upper(path + ' Dirs') K = ('Software\\Microsoft\\Devstudio\\%s\\' + 'Build System\\Components\\Platforms\\Win32 (%s)\\Directories') % \ (version,platform) for base in (win32con.HKEY_CLASSES_ROOT, win32con.HKEY_LOCAL_MACHINE, win32con.HKEY_CURRENT_USER, win32con.HKEY_USERS): try: k = win32api.RegOpenKeyEx(base,K) i = 0 while 1: try: (p,v,t) = win32api.RegEnumValue(k,i) if string.upper(p) == path: V = string.split(v,';') for v in V: if v == '' or v in L: continue L.append(v) break i = i + 1 except win32api.error: break except win32api.error: pass return L
699880931e52bf7d77326f3308151b37cee42dfe /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/699880931e52bf7d77326f3308151b37cee42dfe/msvccompiler.py
def _find_exe(exe): for v in get_devstudio_versions(): for p in get_msvc_paths('path',v): fn = os.path.join(os.path.abspath(p),exe) if os.path.isfile(fn): return fn try: for p in string.split(os.environ['Path'],';'): fn=os.path.join(os.path.abspath(p),exe) if os.path.isfile(fn): return fn except: pass return exe def _find_SET(n): for v in get_devstudio_versions(): p = get_msvc_paths(n,v) if p: return p return [] def _do_SET(n): p = _find_SET(n)
def find_exe (exe, version_number): """Try to find an MSVC executable program 'exe' (from version 'version_number' of MSVC) in several places: first, one of the MSVC program search paths from the registry; next, the directories in the PATH environment variable. If any of those work, return an absolute path that is known to exist. If none of them work, just return the original program name, 'exe'.""" for p in get_msvc_paths ('path', version_number): fn = os.path.join (os.path.abspath(p), exe) if os.path.isfile(fn): return fn for p in string.split (os.environ['Path'],';'): fn = os.path.join(os.path.abspath(p),exe) if os.path.isfile(fn): return fn return exe def _find_SET(name,version_number): """looks up in the registry and returns a list of values suitable for use in a SET command eg SET name=value. Normally the value will be a ';' separated list similar to a path list. name is the name of an MSVC path and version_number is a version_number of an MSVC installation.""" return get_msvc_paths(name, version_number) def _do_SET(name, version_number): """sets os.environ[name] to an MSVC path type value obtained from _find_SET. This is equivalent to a SET command prior to execution of spawned commands.""" p=_find_SET(name, version_number)
def _find_exe(exe): for v in get_devstudio_versions(): for p in get_msvc_paths('path',v): fn = os.path.join(os.path.abspath(p),exe) if os.path.isfile(fn): return fn #didn't find it; try existing path try: for p in string.split(os.environ['Path'],';'): fn=os.path.join(os.path.abspath(p),exe) if os.path.isfile(fn): return fn # XXX BAD BAD BAD BAD BAD BAD BAD BAD BAD BAD BAD BAD !!!!!!!!!!!!!!!! except: # XXX WHAT'S BEING CAUGHT HERE?!?!? pass return exe #last desperate hope
699880931e52bf7d77326f3308151b37cee42dfe /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/699880931e52bf7d77326f3308151b37cee42dfe/msvccompiler.py
os.environ[n] = string.join(p,';')
os.environ[name]=string.join(p,';')
def _do_SET(n): p = _find_SET(n) if p: os.environ[n] = string.join(p,';')
699880931e52bf7d77326f3308151b37cee42dfe /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/699880931e52bf7d77326f3308151b37cee42dfe/msvccompiler.py
self.cc = _find_exe("cl.exe") self.link = _find_exe("link.exe") _do_SET('lib') _do_SET('include') path=_find_SET('path') try: for p in string.split(os.environ['path'],';'): path.append(p) except KeyError: pass os.environ['path'] = string.join(path,';')
vNum = get_devstudio_versions () if vNum: vNum = vNum[0] self.cc = _find_exe("cl.exe", vNum) self.link = _find_exe("link.exe", vNum) _do_SET('lib', vNum) _do_SET('include', vNum) path=_find_SET('path', vNum) try: for p in string.split(os.environ['path'],';'): path.append(p) except KeyError: pass os.environ['path'] = string.join(path,';') else: self.cc = "cl.exe" self.link = "link.exe"
def __init__ (self, verbose=0, dry_run=0, force=0):
699880931e52bf7d77326f3308151b37cee42dfe /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/699880931e52bf7d77326f3308151b37cee42dfe/msvccompiler.py
self.compile_options = [ '/nologo', '/Ox', '/MD' ]
self.compile_options = [ '/nologo', '/Ox', '/MD', '/W3' ]
def __init__ (self, verbose=0, dry_run=0, force=0):
699880931e52bf7d77326f3308151b37cee42dfe /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/699880931e52bf7d77326f3308151b37cee42dfe/msvccompiler.py
'/nologo', '/Od', '/MDd', '/Z7', '/D_DEBUG'
'/nologo', '/Od', '/MDd', '/W3', '/Z7', '/D_DEBUG'
def __init__ (self, verbose=0, dry_run=0, force=0):
699880931e52bf7d77326f3308151b37cee42dfe /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/699880931e52bf7d77326f3308151b37cee42dfe/msvccompiler.py
spawn(("gpg", "--detach-sign", "-a", filename),
gpg_args = ["gpg", "--detach-sign", "-a", filename] if self.identity: gpg_args[2:2] = ["--local-user", self.identity] spawn(gpg_args,
def upload_file(self, command, pyversion, filename): # Sign if requested if self.sign: spawn(("gpg", "--detach-sign", "-a", filename), dry_run=self.dry_run)
2e550b3dd2a9c8a90e0811ce9f0f05690ecf05cb /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/2e550b3dd2a9c8a90e0811ce9f0f05690ecf05cb/upload.py
while args and args[0][:1] == '-' and args[0] != '-':
while args and args[0].startswith('-') and args[0] != '-':
def getopt(args, shortopts, longopts = []): """getopt(args, options[, long_options]) -> opts, args Parses command line options and parameter list. args is the argument list to be parsed, without the leading reference to the running program. Typically, this means "sys.argv[1:]". shortopts is the string of option letters that the script wants to recognize, with options that require an argument followed by a colon (i.e., the same format that Unix getopt() uses). If specified, longopts is a list of strings with the names of the long options which should be supported. The leading '--' characters should not be included in the option name. Options which require an argument should be followed by an equal sign ('='). The return value consists of two elements: the first is a list of (option, value) pairs; the second is the list of program arguments left after the option list was stripped (this is a trailing slice of the first argument). Each option-and-value pair returned has the option as its first element, prefixed with a hyphen (e.g., '-x'), and the option argument as its second element, or an empty string if the option has no argument. The options occur in the list in the same order in which they were found, thus allowing multiple occurrences. Long and short options may be mixed. """ opts = [] if type(longopts) == type(""): longopts = [longopts] else: longopts = list(longopts) longopts.sort() while args and args[0][:1] == '-' and args[0] != '-': if args[0] == '--': args = args[1:] break if args[0][:2] == '--': opts, args = do_longs(opts, args[0][2:], longopts, args[1:]) else: opts, args = do_shorts(opts, args[0][1:], shortopts, args[1:]) return opts, args
dd699b62c59d8fdbdf97a219a2a1125b691e5a98 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/dd699b62c59d8fdbdf97a219a2a1125b691e5a98/getopt.py
opt, optarg = opt[:i], opt[i+1:]
def do_longs(opts, opt, longopts, args): try: i = opt.index('=') opt, optarg = opt[:i], opt[i+1:] except ValueError: optarg = None has_arg, opt = long_has_args(opt, longopts) if has_arg: if optarg is None: if not args: raise GetoptError('option --%s requires argument' % opt, opt) optarg, args = args[0], args[1:] elif optarg: raise GetoptError('option --%s must not have an argument' % opt, opt) opts.append(('--' + opt, optarg or '')) return opts, args
dd699b62c59d8fdbdf97a219a2a1125b691e5a98 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/dd699b62c59d8fdbdf97a219a2a1125b691e5a98/getopt.py
optlen = len(opt)
def long_has_args(opt, longopts): optlen = len(opt) for i in range(len(longopts)): x, y = longopts[i][:optlen], longopts[i][optlen:] if opt != x: continue if y != '' and y != '=' and i+1 < len(longopts): if opt == longopts[i+1][:optlen]: raise GetoptError('option --%s not a unique prefix' % opt, opt) if longopts[i][-1:] in ('=', ): return 1, longopts[i][:-1] return 0, longopts[i] raise GetoptError('option --%s not recognized' % opt, opt)
dd699b62c59d8fdbdf97a219a2a1125b691e5a98 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/dd699b62c59d8fdbdf97a219a2a1125b691e5a98/getopt.py
x, y = longopts[i][:optlen], longopts[i][optlen:] if opt != x: continue if y != '' and y != '=' and i+1 < len(longopts): if opt == longopts[i+1][:optlen]: raise GetoptError('option --%s not a unique prefix' % opt, opt) if longopts[i][-1:] in ('=', ): return 1, longopts[i][:-1] return 0, longopts[i] raise GetoptError('option --%s not recognized' % opt, opt)
if longopts[i].startswith(opt): break else: raise GetoptError('option --%s not recognized' % opt, opt) j = i+1 while j < len(longopts) and longopts[j].startswith(opt): j += 1 possibilities = longopts[i:j] if opt in possibilities: return 0, opt elif opt + '=' in possibilities: return 1, opt if len(possibilities) > 1: raise GetoptError('option --%s not a unique prefix' % opt, opt) assert len(possibilities) == 1 unique_match = possibilities[0] has_arg = unique_match.endswith('=') if has_arg: unique_match = unique_match[:-1] return has_arg, unique_match
def long_has_args(opt, longopts): optlen = len(opt) for i in range(len(longopts)): x, y = longopts[i][:optlen], longopts[i][optlen:] if opt != x: continue if y != '' and y != '=' and i+1 < len(longopts): if opt == longopts[i+1][:optlen]: raise GetoptError('option --%s not a unique prefix' % opt, opt) if longopts[i][-1:] in ('=', ): return 1, longopts[i][:-1] return 0, longopts[i] raise GetoptError('option --%s not recognized' % opt, opt)
dd699b62c59d8fdbdf97a219a2a1125b691e5a98 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/dd699b62c59d8fdbdf97a219a2a1125b691e5a98/getopt.py
cur = self._make_iter_cursor()
try: cur = self._make_iter_cursor() except AttributeError: return
def iteritems(self): try: cur = self._make_iter_cursor()
26caeba35a34afb1ff5ce5104d8598b395b87716 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/26caeba35a34afb1ff5ce5104d8598b395b87716/__init__.py
return paramre.split(value)[0].lower().strip()
ctype = paramre.split(value)[0].lower().strip() if ctype.count('/') <> 1: return 'text/plain' return ctype
def get_content_type(self): """Returns the message's content type.
f36d804b3b5a73814287535bbc840c3df33d9e2d /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/f36d804b3b5a73814287535bbc840c3df33d9e2d/Message.py
if ctype.count('/') <> 1: raise ValueError, 'No maintype found in: %s' % ctype
def get_content_maintype(self): """Returns the message's main content type.
f36d804b3b5a73814287535bbc840c3df33d9e2d /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/f36d804b3b5a73814287535bbc840c3df33d9e2d/Message.py
if ctype.count('/') <> 1: raise ValueError, 'No subtype found in: %s' % ctype
def get_content_subtype(self): """Returns the message's sub content type.
f36d804b3b5a73814287535bbc840c3df33d9e2d /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/f36d804b3b5a73814287535bbc840c3df33d9e2d/Message.py
result = self.__class__([])
result = self.__class__()
def copy(self): """Return a shallow copy of a set.""" result = self.__class__([]) result._data.update(self._data) return result
fa1480f6863729102ccf276e0fa8b9ea585b37c5 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/fa1480f6863729102ccf276e0fa8b9ea585b37c5/sets.py
result = self.__class__([])
result = self.__class__()
def __deepcopy__(self, memo): """Return a deep copy of a set; used by copy module.""" # This pre-creates the result and inserts it in the memo # early, in case the deep copy recurses into another reference # to this same set. A set can't be an element of itself, but # it can certainly contain an object that has a reference to # itself. from copy import deepcopy result = self.__class__([]) memo[id(self)] = result data = result._data value = True for elt in self: data[deepcopy(elt, memo)] = value return result
fa1480f6863729102ccf276e0fa8b9ea585b37c5 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/fa1480f6863729102ccf276e0fa8b9ea585b37c5/sets.py
result = self.__class__([])
result = self.__class__()
def __and__(self, other): """Return the intersection of two sets as a new set.
fa1480f6863729102ccf276e0fa8b9ea585b37c5 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/fa1480f6863729102ccf276e0fa8b9ea585b37c5/sets.py
result = self.__class__([])
result = self.__class__()
def __xor__(self, other): """Return the symmetric difference of two sets as a new set.
fa1480f6863729102ccf276e0fa8b9ea585b37c5 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/fa1480f6863729102ccf276e0fa8b9ea585b37c5/sets.py
result = self.__class__([])
result = self.__class__()
def __sub__(self, other): """Return the difference of two sets as a new Set.
fa1480f6863729102ccf276e0fa8b9ea585b37c5 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/fa1480f6863729102ccf276e0fa8b9ea585b37c5/sets.py
class _TemporarilyImmutableSet(object):
class _TemporarilyImmutableSet(BaseSet):
def _as_temporarily_immutable(self): # Return self wrapped in a temporarily immutable set return _TemporarilyImmutableSet(self)
fa1480f6863729102ccf276e0fa8b9ea585b37c5 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/fa1480f6863729102ccf276e0fa8b9ea585b37c5/sets.py
def __eq__(self, other): return self._set == other def __ne__(self, other): return self._set != other def _test(): red = Set() assert `red` == "Set([])", "Empty set: %s" % `red` green = Set((0,)) assert `green` == "Set([0])", "Unit set: %s" % `green` blue = Set([0, 1, 2]) assert blue._repr(True) == "Set([0, 1, 2])", "3-element set: %s" % `blue` black = Set([0, 5]) assert black._repr(True) == "Set([0, 5])", "2-element set: %s" % `black` white = Set([0, 1, 2, 5]) assert white._repr(True) == "Set([0, 1, 2, 5])", "4-element set: %s" % `white` red.add(9) assert `red` == "Set([9])", "Add to empty set: %s" % `red` red.remove(9) assert `red` == "Set([])", "Remove from unit set: %s" % `red` try: red.remove(0) assert 0, "Remove element from empty set: %s" % `red` except LookupError: pass assert len(red) == 0, "Length of empty set" assert len(green) == 1, "Length of unit set" assert len(blue) == 3, "Length of 3-element set" assert green == Set([0]), "Equality failed" assert green != Set([1]), "Inequality failed" assert blue | red == blue, "Union non-empty with empty" assert red | blue == blue, "Union empty with non-empty" assert green | blue == blue, "Union non-empty with non-empty" assert blue | black == white, "Enclosing union" assert blue & red == red, "Intersect non-empty with empty" assert red & blue == red, "Intersect empty with non-empty" assert green & blue == green, "Intersect non-empty with non-empty" assert blue & black == green, "Enclosing intersection" assert red ^ green == green, "Empty symdiff non-empty" assert green ^ blue == Set([1, 2]), "Non-empty symdiff" assert white ^ white == red, "Self symdiff" assert red - green == red, "Empty - non-empty" assert blue - red == blue, "Non-empty - empty" assert white - black == Set([1, 2]), "Non-empty - non-empty" orange = Set([]) orange |= Set([1]) assert orange == Set([1]), "In-place union" orange = Set([1, 2]) orange &= Set([2]) assert orange == Set([2]), "In-place intersection" orange = Set([1, 2, 3]) orange -= Set([2, 4]) assert orange == Set([1, 3]), "In-place difference" orange = Set([1, 2, 3]) orange ^= Set([3, 4]) assert orange == Set([1, 2, 4]), "In-place symmetric difference" print "All tests passed" if __name__ == "__main__": _test()
def __hash__(self): if self._hashcode is None: self._hashcode = self._set._compute_hash() return self._hashcode
fa1480f6863729102ccf276e0fa8b9ea585b37c5 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/fa1480f6863729102ccf276e0fa8b9ea585b37c5/sets.py
except:
except NameError:
def _init_categories(categories=categories): for k,v in globals().items(): if k[:3] == 'LC_': categories[k] = v
0897f0c4f8034fa656cf2be3cda93bfb067d0a65 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/0897f0c4f8034fa656cf2be3cda93bfb067d0a65/locale.py
def read(self, n = 0): if n <= 0:
def read(self, n = -1): if n < 0:
def read(self, n = 0): if n <= 0: newpos = len(self.buf) else: newpos = min(self.pos+n, len(self.buf)) r = self.buf[self.pos:newpos] self.pos = newpos return r
f7476c5088e6f459f866901219e1b5b084fb0750 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/f7476c5088e6f459f866901219e1b5b084fb0750/StringIO.py
del ce
del riscos
def _get_exports_list(module): try: return list(module.__all__) except AttributeError: return [n for n in dir(module) if n[0] != '_']
81e4b1c5c8307285c89952c3ee9c9f5c3d4896f3 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/81e4b1c5c8307285c89952c3ee9c9f5c3d4896f3/os.py
run_unittest(StatAttributeTests)
def test_main(): run_unittest(TemporaryFileTests)
98bf58f1c61a1d6d8a21f75527c8ad7a7d47ef67 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/98bf58f1c61a1d6d8a21f75527c8ad7a7d47ef67/test_os.py
def test_filter_subclasses(self): # test, that filter() never returns tuple, str or unicode subclasses # and that the result always go's through __getitem__ # FIXME: For tuple currently it doesn't go through __getitem__ funcs = (None, lambda x: True) class tuple2(tuple): def __getitem__(self, index): return 2*tuple.__getitem__(self, index) class str2(str): def __getitem__(self, index): return 2*str.__getitem__(self, index) inputs = { tuple2: {(): (), (1, 2, 3): (1, 2, 3)}, # FIXME str2: {"": "", "123": "112233"} } if have_unicode: class unicode2(unicode): def __getitem__(self, index): return 2*unicode.__getitem__(self, index) inputs[unicode2] = { unicode(): unicode(), unicode("123"): unicode("112233") }
8dd19321bbb3b4f94d15ca3a405053265b99e91e /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/8dd19321bbb3b4f94d15ca3a405053265b99e91e/test_builtin.py
tuple2: {(): (), (1, 2, 3): (1, 2, 3)},
tuple2: {(): (), (1, 2, 3): (2, 4, 6)},
def __getitem__(self, index): return 2*str.__getitem__(self, index)
8dd19321bbb3b4f94d15ca3a405053265b99e91e /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/8dd19321bbb3b4f94d15ca3a405053265b99e91e/test_builtin.py
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") "\\uyyyy".decode("raw-unicode-escape", "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".decode, "ascii", "test.posreturn") 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".decode, "ascii", "test.posreturn") handler.pos = 6 self.assertEquals("\\uyyyy0".decode("raw-unicode-escape", "test.posreturn"), u"<?>0")
def baddecodereturn2(exc): return (u"?", None)
2e0b18af3092a24c9689f72af898083ebfd9aec7 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/2e0b18af3092a24c9689f72af898083ebfd9aec7/test_codeccallbacks.py
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".encode, "ascii", "test.posreturn") 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".encode, "ascii", "test.posreturn") handler.pos = 0
def badencodereturn2(exc): return (u"?", None)
2e0b18af3092a24c9689f72af898083ebfd9aec7 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/2e0b18af3092a24c9689f72af898083ebfd9aec7/test_codeccallbacks.py
for err in ("strict", "replace", "xmlcharrefreplace", "backslashreplace", "test.hugeposreturn"):
for err in ("strict", "replace", "xmlcharrefreplace", "backslashreplace", "test.posreturn"):
def __getitem__(self, key): raise ValueError
2e0b18af3092a24c9689f72af898083ebfd9aec7 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/2e0b18af3092a24c9689f72af898083ebfd9aec7/test_codeccallbacks.py
self.pimpinstaller = pimp.PimpInstaller(self.pimpdb)
def setuppimp(self, url): self.pimpprefs = pimp.PimpPreferences() self.pimpdb = pimp.PimpDatabase(self.pimpprefs) self.pimpinstaller = pimp.PimpInstaller(self.pimpdb) if not url: url = self.pimpprefs.pimpDatabase try: self.pimpdb.appendURL(url) except IOError, arg: rv = "Cannot open %s: %s\n" % (url, arg) rv += "\nSee MacPython Package Manager help page." return rv except: rv = "Unspecified error while parsing database: %s\n" % url rv += "Usually, this means the database is not correctly formatted.\n" rv += "\nSee MacPython Package Manager help page." return rv # Check whether we can write the installation directory. # If not, set to the per-user directory, possibly # creating it, if needed. installDir = self.pimpprefs.installDir if not os.access(installDir, os.R_OK|os.W_OK|os.X_OK): rv = self.setuserinstall(1) if rv: return rv return self.pimpprefs.check()
40b2e839246aa74f08eea1c2abb60e5ca93ecab0 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/8546/40b2e839246aa74f08eea1c2abb60e5ca93ecab0/PackageManager.py