From python-checkins at python.org Fri Dec 1 00:15:21 2006 From: python-checkins at python.org (guido.van.rossum) Date: Fri, 1 Dec 2006 00:15:21 +0100 (CET) Subject: [Python-checkins] r52880 - sandbox/trunk/2to3/example.py sandbox/trunk/2to3/fix_print.py sandbox/trunk/2to3/pytree.py Message-ID: <20061130231521.207761E401A@bag.python.org> Author: guido.van.rossum Date: Fri Dec 1 00:15:20 2006 New Revision: 52880 Added: sandbox/trunk/2to3/fix_print.py (contents, props changed) Modified: sandbox/trunk/2to3/example.py sandbox/trunk/2to3/pytree.py Log: Completed the print stmt -> function refactoring. Modified: sandbox/trunk/2to3/example.py ============================================================================== --- sandbox/trunk/2to3/example.py (original) +++ sandbox/trunk/2to3/example.py Fri Dec 1 00:15:20 2006 @@ -1,6 +1,7 @@ #!/usr/bin/python # comment indented by tab """Docstring.""" +import sys d = {"x": 42} if d.has_key("x") or d.has_key("y"): @@ -10,4 +11,32 @@ def foo(): pass # body indented by tab +def print_examples(): + # plain vanilla + print 1, 1+1, 1+1+1 + # + print 1, 2 + # + print 1 + + print + + # trailing commas + print 1, 2, 3, + # + print 1, 2, + # + print 1, + # + print + + # >> stuff + print >>sys.stderr, 1, 2, 3 # no trailing comma + # + print >>sys.stdder, 1, 2, # trailing comma + # + print >>sys.stderr, 1+1 # no trailing comma + # + print >> sys.stderr # spaces before sys.stderr + # This is the last line. Added: sandbox/trunk/2to3/fix_print.py ============================================================================== --- (empty file) +++ sandbox/trunk/2to3/fix_print.py Fri Dec 1 00:15:20 2006 @@ -0,0 +1,126 @@ +#!/usr/bin/env python2.5 +# Copyright 2006 Google Inc. All Rights Reserved. +# Licensed to PSF under a Contributor Agreement. + +"""Refactoring tool: change 'x.has_key(y)' into 'y in x'.""" + +__author__ = "Guido van Rossum " + +# Python imports +import os +import sys +import token +import logging + +import pgen2 +from pgen2 import driver + +import pytree + +logging.basicConfig(level=logging.DEBUG) + +gr = driver.load_grammar("Grammar.txt") # used by node initializers + + +class Symbols(object): + + def __init__(self, gr): + for name, symbol in gr.symbol2number.iteritems(): + setattr(self, name, symbol) + + +syms = Symbols(gr) + + +def main(): + args = sys.argv[1:] or ["example.py"] + + dr = driver.Driver(gr, convert=pytree.convert) + + for fn in args: + print "Parsing", fn + tree = dr.parse_file(fn) + refactor(tree) + diff(fn, tree) + + +def refactor(tree): + visit(tree, fix_print) + + +def visit(node, func): + func(node) + for child in node.children: + visit(child, func) + + +def fix_print(node): + if node.type != syms.print_stmt: + return + print "Bingo! >>>%s<<<" % node + assert node.children[0] == pytree.Leaf(token.NAME, "print") + args = node.children[1:] + sep = end = file = None + if args and args[-1] == pytree.Leaf(token.COMMA, ","): + args = args[:-1] + sep = " " + end = "" + if args and args[0] == pytree.Leaf(token.RIGHTSHIFT, ">>"): + assert len(args) >= 2 + file = args[1] + args = args[3:] # Strip a possible comma after the file expression + # Now synthesize a Print(args, sep=..., end=..., file=...) node. + n_print = pytree.Leaf(token.NAME, "Print") # XXX -> "print" + l_args = list(args) + if l_args: + l_args[0].set_prefix("") + if sep is not None or end is not None or file is not None: + if sep is not None: + add_kwarg(l_args, "sep", + pytree.Leaf(token.STRING, repr(sep))) + if end is not None: + add_kwarg(l_args, "end", + pytree.Leaf(token.STRING, repr(end))) + if file is not None: + add_kwarg(l_args, "file", file) + if l_args: + n_arglist = pytree.Node(syms.arglist, l_args) + else: + n_arglist = None + l_args = [pytree.Leaf(token.LPAR, "("), pytree.Leaf(token.RPAR, ")")] + if n_arglist: + l_args.insert(1, n_arglist) + n_trailer = pytree.Node(syms.trailer, l_args) + n_stmt = pytree.Node(syms.power, (n_print, n_trailer)) + n_stmt.set_prefix(node.get_prefix()) + print "Synthesized: >>>%s<<<" % n_stmt + node.parent.replace(node, n_stmt) + + +def add_kwarg(l_nodes, s_kwd, n_expr): + # XXX All this prefix-setting may lose comments (though rarely) + n_expr.set_prefix("") + n_argument = pytree.Node(syms.argument, + (pytree.Leaf(token.NAME, s_kwd), + pytree.Leaf(token.EQUAL, "="), + n_expr)) + if l_nodes: + l_nodes.append(pytree.Leaf(token.COMMA, ",")) + n_argument.set_prefix(" ") + l_nodes.append(n_argument) + + +def diff(fn, tree): + f = open("@", "w") + try: + f.write(str(tree)) + finally: + f.close() + try: + return os.system("diff -u %s @" % fn) + finally: + os.remove("@") + + +if __name__ == "__main__": + main() Modified: sandbox/trunk/2to3/pytree.py ============================================================================== --- sandbox/trunk/2to3/pytree.py (original) +++ sandbox/trunk/2to3/pytree.py Fri Dec 1 00:15:20 2006 @@ -87,6 +87,8 @@ class Leaf(Base): + lineno = column = 0 + def __init__(self, type, value, context=None): if context is not None: self.prefix, (self.lineno, self.column) = context From python-checkins at python.org Fri Dec 1 00:23:28 2006 From: python-checkins at python.org (guido.van.rossum) Date: Fri, 1 Dec 2006 00:23:28 +0100 (CET) Subject: [Python-checkins] r52881 - sandbox/trunk/2to3/fix_has_key.py sandbox/trunk/2to3/fix_print.py sandbox/trunk/2to3/pytree.py Message-ID: <20061130232328.D0B001E4004@bag.python.org> Author: guido.van.rossum Date: Fri Dec 1 00:23:28 2006 New Revision: 52881 Modified: sandbox/trunk/2to3/fix_has_key.py sandbox/trunk/2to3/fix_print.py sandbox/trunk/2to3/pytree.py Log: Change replace() API to not require passing in the parent. Also, n.replace(None) deletes n from its parent. Modified: sandbox/trunk/2to3/fix_has_key.py ============================================================================== --- sandbox/trunk/2to3/fix_has_key.py (original) +++ sandbox/trunk/2to3/fix_has_key.py Fri Dec 1 00:23:28 2006 @@ -101,7 +101,7 @@ new = pytree.Node(syms.comparison, (arg, n_in, pytree.Node(syms.power, nodes[:i]))) # XXX Sometimes we need to parenthesize arg or new. Later. - parent.parent.replace(parent, new) + parent.replace(new) def diff(fn, tree): f = open("@", "w") Modified: sandbox/trunk/2to3/fix_print.py ============================================================================== --- sandbox/trunk/2to3/fix_print.py (original) +++ sandbox/trunk/2to3/fix_print.py Fri Dec 1 00:23:28 2006 @@ -94,7 +94,7 @@ n_stmt = pytree.Node(syms.power, (n_print, n_trailer)) n_stmt.set_prefix(node.get_prefix()) print "Synthesized: >>>%s<<<" % n_stmt - node.parent.replace(node, n_stmt) + node.replace(n_stmt) def add_kwarg(l_nodes, s_kwd, n_expr): Modified: sandbox/trunk/2to3/pytree.py ============================================================================== --- sandbox/trunk/2to3/pytree.py (original) +++ sandbox/trunk/2to3/pytree.py Fri Dec 1 00:23:28 2006 @@ -70,19 +70,24 @@ return "" return self.children[0].get_prefix() - def replace(self, old, new): + def replace(self, new): + if self is new: + return l_children = [] found = False - for ch in self.children: - if ch is old: - assert not found, (self.children, old, new) - l_children.append(new) + for ch in self.parent.children: + if ch is self: + assert not found, (self.parent.children, self, new) + if new is not None: + l_children.append(new) found = True else: l_children.append(ch) - assert found, (self.children, old, new) - self.children = tuple(l_children) - new.parent = self + assert found, (self.children, self, new) + self.parent.children = tuple(l_children) + if new is not None: + new.parent = self.parent + self.parent = None class Leaf(Base): From python-checkins at python.org Fri Dec 1 01:21:41 2006 From: python-checkins at python.org (guido.van.rossum) Date: Fri, 1 Dec 2006 01:21:41 +0100 (CET) Subject: [Python-checkins] r52882 - sandbox/trunk/2to3/example.py sandbox/trunk/2to3/fix_print.py sandbox/trunk/2to3/pytree.py Message-ID: <20061201002141.82D0D1E4004@bag.python.org> Author: guido.van.rossum Date: Fri Dec 1 01:21:41 2006 New Revision: 52882 Modified: sandbox/trunk/2to3/example.py sandbox/trunk/2to3/fix_print.py sandbox/trunk/2to3/pytree.py Log: Refactoring tool for apply(). Modified: sandbox/trunk/2to3/example.py ============================================================================== --- sandbox/trunk/2to3/example.py (original) +++ sandbox/trunk/2to3/example.py Fri Dec 1 01:21:41 2006 @@ -11,6 +11,13 @@ def foo(): pass # body indented by tab +def apply_examples(): + x = apply(f, g + h) + y = apply(f, g, h) + z = apply(fs[0], g or h, h or g) + # Hello + apply(f, (x, y) + t) + def print_examples(): # plain vanilla print 1, 1+1, 1+1+1 Modified: sandbox/trunk/2to3/fix_print.py ============================================================================== --- sandbox/trunk/2to3/fix_print.py (original) +++ sandbox/trunk/2to3/fix_print.py Fri Dec 1 01:21:41 2006 @@ -57,7 +57,6 @@ def fix_print(node): if node.type != syms.print_stmt: return - print "Bingo! >>>%s<<<" % node assert node.children[0] == pytree.Leaf(token.NAME, "print") args = node.children[1:] sep = end = file = None @@ -93,7 +92,6 @@ n_trailer = pytree.Node(syms.trailer, l_args) n_stmt = pytree.Node(syms.power, (n_print, n_trailer)) n_stmt.set_prefix(node.get_prefix()) - print "Synthesized: >>>%s<<<" % n_stmt node.replace(n_stmt) Modified: sandbox/trunk/2to3/pytree.py ============================================================================== --- sandbox/trunk/2to3/pytree.py (original) +++ sandbox/trunk/2to3/pytree.py Fri Dec 1 01:21:41 2006 @@ -51,9 +51,9 @@ ch.parent = self def __repr__(self): - return "%s(<>, %r, %r)" % (self.__class__.__name__, - self.type, - self.children) + return "%s(%r, %r)" % (self.__class__.__name__, + self.type, + self.children) def __str__(self): return "".join(str(ch) for ch in self.children) @@ -104,9 +104,9 @@ self.value = value def __repr__(self): - return "%s(<>, %r, %r)" % (self.__class__.__name__, - self.type, - self.value) + return "%s(%r, %r)" % (self.__class__.__name__, + self.type, + self.value) def __str__(self): return self.prefix + self.value @@ -124,6 +124,8 @@ def convert(gr, raw_node): type, value, context, children = raw_node if children or type in gr.number2symbol: + # XXX If there's exactly one child, should return that child + # instead of synthesizing a new node. return Node(type, children, context=context) else: return Leaf(type, value, context=context) From python-checkins at python.org Fri Dec 1 02:47:41 2006 From: python-checkins at python.org (guido.van.rossum) Date: Fri, 1 Dec 2006 02:47:41 +0100 (CET) Subject: [Python-checkins] r52883 - sandbox/trunk/2to3/fix_apply.py sandbox/trunk/2to3/play.py sandbox/trunk/2to3/pytree.py Message-ID: <20061201014741.7F6481E401F@bag.python.org> Author: guido.van.rossum Date: Fri Dec 1 02:47:40 2006 New Revision: 52883 Added: sandbox/trunk/2to3/fix_apply.py (contents, props changed) Modified: sandbox/trunk/2to3/play.py sandbox/trunk/2to3/pytree.py Log: Forgot to check in fix_apply.py. Added docstrings and a few more asserts to pytree.py. Added: sandbox/trunk/2to3/fix_apply.py ============================================================================== --- (empty file) +++ sandbox/trunk/2to3/fix_apply.py Fri Dec 1 02:47:40 2006 @@ -0,0 +1,117 @@ +#!/usr/bin/env python2.5 +# Copyright 2006 Google Inc. All Rights Reserved. +# Licensed to PSF under a Contributor Agreement. + +"""Refactoring tool: change 'x.has_key(y)' into 'y in x'.""" + +__author__ = "Guido van Rossum " + +# Python imports +import os +import sys +import token +import logging + +import pgen2 +from pgen2 import driver + +import pytree + +logging.basicConfig(level=logging.DEBUG) + +gr = driver.load_grammar("Grammar.txt") # used by node initializers + + +class Symbols(object): + + def __init__(self, gr): + for name, symbol in gr.symbol2number.iteritems(): + setattr(self, name, symbol) + + +# XXX Make this importable as a module +syms = Symbols(gr) + + +# XXX Write a single driver script that can do any (or all) refactorings +def main(): + args = sys.argv[1:] or ["example.py"] + + dr = driver.Driver(gr, convert=pytree.convert) + + for fn in args: + print "Parsing", fn + tree = dr.parse_file(fn) + refactor(tree) + diff(fn, tree) + + +def refactor(tree): + visit(tree, fix_apply) + + +def visit(node, func): + func(node) + for child in node.children: + visit(child, func) + + +# Constant nodes +n_apply = pytree.Node(syms.atom, [pytree.Leaf(token.NAME, "apply")]) +n_lpar = pytree.Leaf(token.LPAR, "(") +n_rpar = pytree.Leaf(token.RPAR, ")") +n_comma = pytree.Leaf(token.COMMA, ",") +n_star = pytree.Leaf(token.STAR, "*") +n_doublestar = pytree.Leaf(token.DOUBLESTAR, "**") + + +def fix_apply(node): + if not (node.type == syms.power and + len(node.children) >= 2 and + node.children[0] == n_apply and + node.children[1].type == syms.trailer and + node.children[1].children[0] == n_lpar): + return + n_arglist = node.children[1].children[1] + if n_arglist == n_rpar: + return # apply() with no arguments?! + l_args = [] + for arg in n_arglist.children: + if arg == n_comma: + continue + if arg == n_star or arg == n_doublestar: + return # apply() with a * or ** in its argument list?! + arg.set_prefix("") + l_args.append(arg) + if not 2 <= len(l_args) <= 3: + return # too few or too many arguments to handle + print "Bingo! >>>%s<<<" % node + prefix = node.get_prefix() + l_args[0].replace(None) + node.children[0].replace(l_args[0]) + node.set_prefix(prefix) + l_newargs = [pytree.Leaf(token.STAR, "*"), l_args[1]] + if l_args[2:]: + l_newargs.extend([pytree.Leaf(token.COMMA, ","), + pytree.Leaf(token.DOUBLESTAR, "**"), + l_args[2]]) + l_newargs[-2].set_prefix(" ") + n_arglist.replace(pytree.Node(syms.arglist, l_newargs)) + # XXX Sometimes we can be cleverer, e.g. apply(f, (x, y) + t) + # can be translated into f(x, y, *t) instead of f(*(x, y) + t) + + +def diff(fn, tree): + f = open("@", "w") + try: + f.write(str(tree)) + finally: + f.close() + try: + return os.system("diff -u %s @" % fn) + finally: + os.remove("@") + + +if __name__ == "__main__": + main() Modified: sandbox/trunk/2to3/play.py ============================================================================== --- sandbox/trunk/2to3/play.py (original) +++ sandbox/trunk/2to3/play.py Fri Dec 1 02:47:40 2006 @@ -24,7 +24,6 @@ fn = "example.py" tree = dr.parse_file(fn, debug=True) - sys.stdout.write(str(tree)) if not diff(fn, tree): print "No diffs." if not sys.argv[1:]: Modified: sandbox/trunk/2to3/pytree.py ============================================================================== --- sandbox/trunk/2to3/pytree.py (original) +++ sandbox/trunk/2to3/pytree.py Fri Dec 1 02:47:40 2006 @@ -1,13 +1,12 @@ # Copyright 2006 Google, Inc. All Rights Reserved. # Licensed to PSF under a Contributor Agreement. -"""Python syntax tree definitions. +"""Python parse tree definitions. -There are two concrete classes: Node, which represents an interior -node, and Leaf, which represents a leaf node. +This is a very concrete parse tree; we need to keep every token and +even the comments and whitespace between tokens. -The Base class is an abstract base class that provides some default -functionality and boilerplate using the template pattern. +A node may be a subnode of at most one parent. """ __author__ = "Guido van Rossum " @@ -15,64 +14,126 @@ class Base(object): - parent = None - children = () + """Abstract base class for Node and Leaf. + + This provides some default functionality and boilerplate using the + template pattern. + """ + + # Default values for instance variables + type = None # int: token number (< 256) or symbol number (>= 256) + parent = None # Parent node pointer, or None + children = () # Tuple of subnodes def __new__(cls, *args, **kwds): + """Constructor that prevents Base from being instantiated.""" assert cls is not Base, "Cannot instantiate Base" return object.__new__(cls, *args, **kwds) def __eq__(self, other): + """Compares two nodes for equality. + + This calls the method _eq(). + """ if self.__class__ is not other.__class__: return NotImplemented return self._eq(other) def __ne__(self, other): + """Compares two nodes for inequality. + + This calls the method _eq(). + """ if self.__class__ is not other.__class__: return NotImplemented return not self._eq(other) def _eq(self, other): + """Compares two nodes for equality. + + This is called by __eq__ and __ne__. It is only called if the + two nodes have the same type. This must be implemented by the + concrete subclass. Nodes should be considered equal if they + have the same structure, ignoring the prefix string and other + context information. + """ raise NotImplementedError def set_prefix(self, prefix): + """Sets the prefix for the node (see Leaf class). + + This must be implemented by the concrete subclass. + """ raise NotImplementedError def get_prefix(self): + """Returns the prefix for the node (see Leaf class). + + This must be implemented by the concrete subclass. + """ raise NotImplementedError class Node(Base): + """Concrete implementation for interior nodes.""" + def __init__(self, type, children, context=None): + """Initializer. + + Takes a type constant (a symbol number >= 256), a sequence of + child nodes, and an optional context keyword argument. + + As a side effect, the parent pointers of the children are updated. + """ + assert type >= 256, type self.type = type self.children = tuple(children) for ch in self.children: ch.parent = self def __repr__(self): + """Returns a canonical string representation.""" return "%s(%r, %r)" % (self.__class__.__name__, self.type, self.children) def __str__(self): - return "".join(str(ch) for ch in self.children) + """Returns a pretty string representation. + + This reproduces the input source exactly. + """ + return "".join(map(str, self.children)) def _eq(self, other): + """Compares two nodes for equality.""" return (self.type, self.children) == (other.type, other.children) def set_prefix(self, prefix): + """Sets the prefix for the node. + + This passes the responsibility on to the first child. + """ if self.children: self.children[0].set_prefix(prefix) def get_prefix(self): + """Returns the prefix for the node. + + This passes the call on to the first child. + """ if not self.children: return "" return self.children[0].get_prefix() def replace(self, new): - if self is new: - return + """Replaces this node with a new one in the parent. + + This can also be used to remove this node from the parent by + passing None. + """ + assert self.parent is not None, str(self) + assert new is None or new.parent is None, str(new) l_children = [] found = False for ch in self.parent.children: @@ -92,36 +153,58 @@ class Leaf(Base): - lineno = column = 0 + """Concrete implementation for leaf nodes.""" + + # Default values for instance variables + prefix = "" # Whitespace and comments preceding this token in the input + lineno = 0 # Line where this token starts in the input + column = 0 # Column where this token tarts in the input def __init__(self, type, value, context=None): + """Initializer. + + Takes a type constant (a token number < 256), a string value, + and an optional context keyword argument. + """ + assert 0 <= type < 256, type if context is not None: self.prefix, (self.lineno, self.column) = context - else: - self.prefix = "" - self.lineno = self.column = 0 self.type = type self.value = value def __repr__(self): + """Returns a canonical string representation.""" return "%s(%r, %r)" % (self.__class__.__name__, self.type, self.value) def __str__(self): + """Returns a pretty string representation. + + This reproduces the input source exactly. + """ return self.prefix + self.value def _eq(self, other): + """Compares two nodes for equality.""" return (self.type, self.value) == (other.type, other.value) def set_prefix(self, prefix): + """Sets the prefix for the node.""" self.prefix = prefix def get_prefix(self): + """Returns the prefix for the node.""" return self.prefix def convert(gr, raw_node): + """Converts raw node information to a Node or Leaf instance. + + This is passed to the parser driver which calls it whenever a + reduction of a grammar rule produces a new complete node, so that + the tree is build strictly bottom-up. + """ type, value, context, children = raw_node if children or type in gr.number2symbol: # XXX If there's exactly one child, should return that child From python-checkins at python.org Fri Dec 1 02:50:22 2006 From: python-checkins at python.org (guido.van.rossum) Date: Fri, 1 Dec 2006 02:50:22 +0100 (CET) Subject: [Python-checkins] r52884 - sandbox/trunk/2to3/fix_apply.py Message-ID: <20061201015022.955A81E4019@bag.python.org> Author: guido.van.rossum Date: Fri Dec 1 02:50:22 2006 New Revision: 52884 Modified: sandbox/trunk/2to3/fix_apply.py Log: Delete a debug print. Modified: sandbox/trunk/2to3/fix_apply.py ============================================================================== --- sandbox/trunk/2to3/fix_apply.py (original) +++ sandbox/trunk/2to3/fix_apply.py Fri Dec 1 02:50:22 2006 @@ -85,7 +85,6 @@ l_args.append(arg) if not 2 <= len(l_args) <= 3: return # too few or too many arguments to handle - print "Bingo! >>>%s<<<" % node prefix = node.get_prefix() l_args[0].replace(None) node.children[0].replace(l_args[0]) From python-checkins at python.org Fri Dec 1 04:32:34 2006 From: python-checkins at python.org (ka-ping.yee) Date: Fri, 1 Dec 2006 04:32:34 +0100 (CET) Subject: [Python-checkins] r52885 - peps/trunk/pep-3104.txt Message-ID: <20061201033234.9A2D11E4005@bag.python.org> Author: ka-ping.yee Date: Fri Dec 1 04:32:33 2006 New Revision: 52885 Modified: peps/trunk/pep-3104.txt Log: Add one more proposal to the list of extant proposals (and a reference to the relevant message on the Python-3000 mailing list). Modified: peps/trunk/pep-3104.txt ============================================================================== --- peps/trunk/pep-3104.txt (original) +++ peps/trunk/pep-3104.txt Fri Dec 1 04:32:33 2006 @@ -168,7 +168,7 @@ if it would not shadow a name already bound in an outer scope; otherwise assignment is interpreted as rebinding of the outer name. Ruby's scoping syntax and rules have also been debated at great -length, and changes seem likely in Ruby 2.0 [25]_. +length, and changes seem likely in Ruby 2.0 [28]_. Overview of Proposals @@ -313,12 +313,13 @@ - ``using x`` [22]_ - ``borrow x`` [22]_ - ``reuse x`` [23]_ + - ``scope f x`` [25]_ (explicitly specify which scope) The most commonly discussed choices appear to be ``outer``, ``global``, and ``nonlocal``. ``outer`` is already used as both a variable name and an attribute name in the standard library. The word ``global`` has a conflicting meaning, because "global variable" -is generally understood to mean a variable with top-level scope [24]_. +is generally understood to mean a variable with top-level scope [27]_. In C, the keyword ``extern`` means that a name refers to a variable in a different compilation unit. While ``nonlocal`` is a bit long and less pleasant-sounding than some of the other options, it does @@ -361,7 +362,7 @@ nonlocal x = 3 The above has exactly the same meaning as ``nonlocal x; x = 3``. -(Guido supports a similar form of the ``global`` statement [26]_.) +(Guido supports a similar form of the ``global`` statement [24]_.) On the left side of the shorthand form, only identifiers are allowed, not target expressions like ``x[0]``. Otherwise, all forms of @@ -384,7 +385,7 @@ This PEP targets Python 3000, as suggested by Guido [19]_. However, others have noted that some options considered in this PEP may be -small enough changes to be feasible in Python 2.x [27]_, in which +small enough changes to be feasible in Python 2.x [26]_, in which case this PEP could possibly be moved to be a 2.x series PEP. As a (very rough) measure of the impact of introducing a new keyword, @@ -500,17 +501,21 @@ .. [23] Alternatives to 'outer' (Jim Jewett) http://mail.python.org/pipermail/python-3000/2006-November/004153.html -.. [24] Global variable (version 2006-11-01T01:23:16) +.. [24] Draft PEP for outer scopes (Guido van Rossum) + http://mail.python.org/pipermail/python-3000/2006-November/004166.html + +.. [25] Draft PEP for outer scopes (Talin) + http://mail.python.org/pipermail/python-3000/2006-November/004190.html + +.. [26] Draft PEP for outer scopes (Nick Coghlan) + http://mail.python.org/pipermail/python-3000/2006-November/004237.html + +.. [27] Global variable (version 2006-11-01T01:23:16) http://en.wikipedia.org/wiki/Global_variable -.. [25] Ruby 2.0 block local variable +.. [28] Ruby 2.0 block local variable http://redhanded.hobix.com/inspect/ruby20BlockLocalVariable.html -.. [26] Draft PEP for outer scopes (Guido van Rossum) - http://mail.python.org/pipermail/python-3000/2006-November/004166.html - -.. [27] Draft PEP for outer scopes (Nick Coghlan) - http://mail.python.org/pipermail/python-3000/2006-November/004237.html Acknowledgements ================ From python-checkins at python.org Fri Dec 1 04:39:01 2006 From: python-checkins at python.org (phillip.eby) Date: Fri, 1 Dec 2006 04:39:01 +0100 (CET) Subject: [Python-checkins] r52886 - sandbox/trunk/setuptools/setuptools/command/easy_install.py Message-ID: <20061201033901.82C791E4004@bag.python.org> Author: phillip.eby Date: Fri Dec 1 04:39:00 2006 New Revision: 52886 Modified: sandbox/trunk/setuptools/setuptools/command/easy_install.py Log: Fix problem w/' ' in sys.executable on Windows. Modified: sandbox/trunk/setuptools/setuptools/command/easy_install.py ============================================================================== --- sandbox/trunk/setuptools/setuptools/command/easy_install.py (original) +++ sandbox/trunk/setuptools/setuptools/command/easy_install.py Fri Dec 1 04:39:00 2006 @@ -349,7 +349,7 @@ if basename.lower()=='python.exe' and os.path.exists(alt): # use pythonw.exe to avoid opening a console window executable = alt - if ' ' in executable: executable='"%s"' % executable + from distutils.spawn import spawn spawn([executable,'-E','-c','pass'],0) From python-checkins at python.org Fri Dec 1 04:41:11 2006 From: python-checkins at python.org (phillip.eby) Date: Fri, 1 Dec 2006 04:41:11 +0100 (CET) Subject: [Python-checkins] r52887 - in sandbox/branches/setuptools-0.6: EasyInstall.txt setuptools/command/easy_install.py Message-ID: <20061201034111.17E231E4004@bag.python.org> Author: phillip.eby Date: Fri Dec 1 04:41:08 2006 New Revision: 52887 Modified: sandbox/branches/setuptools-0.6/EasyInstall.txt sandbox/branches/setuptools-0.6/setuptools/command/easy_install.py Log: Fixed a problem with ``.pth`` testing on Windows when ``sys.executable`` has a space in it (e.g., the user installed Python to a ``Program Files`` directory). (backport from trunk) Modified: sandbox/branches/setuptools-0.6/EasyInstall.txt ============================================================================== --- sandbox/branches/setuptools-0.6/EasyInstall.txt (original) +++ sandbox/branches/setuptools-0.6/EasyInstall.txt Fri Dec 1 04:41:08 2006 @@ -1269,6 +1269,10 @@ are opened read-only (e.g. reading ``/dev/urandom`` for random numbers, as is done by ``os.urandom()`` on some platforms). + * Fixed a problem with ``.pth`` testing on Windows when ``sys.executable`` + has a space in it (e.g., the user installed Python to a ``Program Files`` + directory). + 0.6c3 * You once again use "python -m easy_install" with Python 2.4 and above. Modified: sandbox/branches/setuptools-0.6/setuptools/command/easy_install.py ============================================================================== --- sandbox/branches/setuptools-0.6/setuptools/command/easy_install.py (original) +++ sandbox/branches/setuptools-0.6/setuptools/command/easy_install.py Fri Dec 1 04:41:08 2006 @@ -349,7 +349,7 @@ if basename.lower()=='python.exe' and os.path.exists(alt): # use pythonw.exe to avoid opening a console window executable = alt - if ' ' in executable: executable='"%s"' % executable + from distutils.spawn import spawn spawn([executable,'-E','-c','pass'],0) From python-checkins at python.org Fri Dec 1 09:28:11 2006 From: python-checkins at python.org (neal.norwitz) Date: Fri, 1 Dec 2006 09:28:11 +0100 (CET) Subject: [Python-checkins] r52888 - sandbox/trunk/2to3/fix_apply.py sandbox/trunk/2to3/fix_print.py Message-ID: <20061201082811.3608C1E4004@bag.python.org> Author: neal.norwitz Date: Fri Dec 1 09:28:10 2006 New Revision: 52888 Modified: sandbox/trunk/2to3/fix_apply.py sandbox/trunk/2to3/fix_print.py Log: Fix docstrings to reflect the refactoring Modified: sandbox/trunk/2to3/fix_apply.py ============================================================================== --- sandbox/trunk/2to3/fix_apply.py (original) +++ sandbox/trunk/2to3/fix_apply.py Fri Dec 1 09:28:10 2006 @@ -2,7 +2,7 @@ # Copyright 2006 Google Inc. All Rights Reserved. # Licensed to PSF under a Contributor Agreement. -"""Refactoring tool: change 'x.has_key(y)' into 'y in x'.""" +"""Refactoring tool: change apply(f, a, kw) into f(*a, **kw).""" __author__ = "Guido van Rossum " Modified: sandbox/trunk/2to3/fix_print.py ============================================================================== --- sandbox/trunk/2to3/fix_print.py (original) +++ sandbox/trunk/2to3/fix_print.py Fri Dec 1 09:28:10 2006 @@ -2,7 +2,11 @@ # Copyright 2006 Google Inc. All Rights Reserved. # Licensed to PSF under a Contributor Agreement. -"""Refactoring tool: change 'x.has_key(y)' into 'y in x'.""" +"""Refactoring tool: change print statements into function calls, ie change: + 'print ...' into 'Print(...)' + 'print ... ,' into 'Print(..., sep=" ", end="")' + 'print >>x, ...' into 'Print(..., file=x)' +""" __author__ = "Guido van Rossum " From python-checkins at python.org Fri Dec 1 16:57:07 2006 From: python-checkins at python.org (guido.van.rossum) Date: Fri, 1 Dec 2006 16:57:07 +0100 (CET) Subject: [Python-checkins] r52889 - sandbox/trunk/2to3/fix_apply.py sandbox/trunk/2to3/fix_has_key.py sandbox/trunk/2to3/pytree.py Message-ID: <20061201155707.4D0741E400E@bag.python.org> Author: guido.van.rossum Date: Fri Dec 1 16:57:06 2006 New Revision: 52889 Modified: sandbox/trunk/2to3/fix_apply.py sandbox/trunk/2to3/fix_has_key.py sandbox/trunk/2to3/pytree.py Log: Reduce parse tree complexity by leaving out interior nodes with one child. Modified: sandbox/trunk/2to3/fix_apply.py ============================================================================== --- sandbox/trunk/2to3/fix_apply.py (original) +++ sandbox/trunk/2to3/fix_apply.py Fri Dec 1 16:57:06 2006 @@ -57,7 +57,7 @@ # Constant nodes -n_apply = pytree.Node(syms.atom, [pytree.Leaf(token.NAME, "apply")]) +n_apply = pytree.Leaf(token.NAME, "apply") n_lpar = pytree.Leaf(token.LPAR, "(") n_rpar = pytree.Leaf(token.RPAR, ")") n_comma = pytree.Leaf(token.COMMA, ",") @@ -75,6 +75,8 @@ n_arglist = node.children[1].children[1] if n_arglist == n_rpar: return # apply() with no arguments?! + if n_arglist.type != syms.arglist: + return # apply() with only one argument?! l_args = [] for arg in n_arglist.children: if arg == n_comma: Modified: sandbox/trunk/2to3/fix_has_key.py ============================================================================== --- sandbox/trunk/2to3/fix_has_key.py (original) +++ sandbox/trunk/2to3/fix_has_key.py Fri Dec 1 16:57:06 2006 @@ -85,7 +85,7 @@ return # ".has_key" followed by "()" argsnode = next_children[1] arg = argsnode - if argsnode.type != syms.arglist: + if argsnode.type == syms.arglist: args = argsnode.children if len(args) > 2: return # Too many arguments Modified: sandbox/trunk/2to3/pytree.py ============================================================================== --- sandbox/trunk/2to3/pytree.py (original) +++ sandbox/trunk/2to3/pytree.py Fri Dec 1 16:57:06 2006 @@ -73,6 +73,30 @@ """ raise NotImplementedError + def replace(self, new): + """Replaces this node with a new one in the parent. + + This can also be used to remove this node from the parent by + passing None. + """ + assert self.parent is not None, str(self) + assert new is None or new.parent is None, str(new) + l_children = [] + found = False + for ch in self.parent.children: + if ch is self: + assert not found, (self.parent.children, self, new) + if new is not None: + l_children.append(new) + found = True + else: + l_children.append(ch) + assert found, (self.children, self, new) + self.parent.children = tuple(l_children) + if new is not None: + new.parent = self.parent + self.parent = None + class Node(Base): @@ -126,30 +150,6 @@ return "" return self.children[0].get_prefix() - def replace(self, new): - """Replaces this node with a new one in the parent. - - This can also be used to remove this node from the parent by - passing None. - """ - assert self.parent is not None, str(self) - assert new is None or new.parent is None, str(new) - l_children = [] - found = False - for ch in self.parent.children: - if ch is self: - assert not found, (self.parent.children, self, new) - if new is not None: - l_children.append(new) - found = True - else: - l_children.append(ch) - assert found, (self.children, self, new) - self.parent.children = tuple(l_children) - if new is not None: - new.parent = self.parent - self.parent = None - class Leaf(Base): @@ -207,8 +207,10 @@ """ type, value, context, children = raw_node if children or type in gr.number2symbol: - # XXX If there's exactly one child, should return that child - # instead of synthesizing a new node. + # If there's exactly one child, return that child instead of + # creating a new node. + if len(children) == 1: + return children[0] return Node(type, children, context=context) else: return Leaf(type, value, context=context) From python-checkins at python.org Fri Dec 1 17:59:48 2006 From: python-checkins at python.org (walter.doerwald) Date: Fri, 1 Dec 2006 17:59:48 +0100 (CET) Subject: [Python-checkins] r52890 - in python/trunk/Lib: test/output/test_xdrlib test/test_xdrlib.py xdrlib.py Message-ID: <20061201165948.8F86F1E400E@bag.python.org> Author: walter.doerwald Date: Fri Dec 1 17:59:47 2006 New Revision: 52890 Removed: python/trunk/Lib/test/output/test_xdrlib Modified: python/trunk/Lib/test/test_xdrlib.py python/trunk/Lib/xdrlib.py Log: Move xdrlib tests from the module into a separate test script, port the tests to unittest and add a few new tests. Deleted: /python/trunk/Lib/test/output/test_xdrlib ============================================================================== --- /python/trunk/Lib/test/output/test_xdrlib Fri Dec 1 17:59:47 2006 +++ (empty file) @@ -1,19 +0,0 @@ -test_xdrlib -pack test 0 succeeded -pack test 1 succeeded -pack test 2 succeeded -pack test 3 succeeded -pack test 4 succeeded -pack test 5 succeeded -pack test 6 succeeded -pack test 7 succeeded -pack test 8 succeeded -unpack test 0 succeeded : 9 -unpack test 1 succeeded : True -unpack test 2 succeeded : False -unpack test 3 succeeded : 45 -unpack test 4 succeeded : 1.89999997616 -unpack test 5 succeeded : 1.9 -unpack test 6 succeeded : hello world -unpack test 7 succeeded : [0, 1, 2, 3, 4] -unpack test 8 succeeded : ['what', 'is', 'hapnin', 'doctor'] Modified: python/trunk/Lib/test/test_xdrlib.py ============================================================================== --- python/trunk/Lib/test/test_xdrlib.py (original) +++ python/trunk/Lib/test/test_xdrlib.py Fri Dec 1 17:59:47 2006 @@ -1,3 +1,56 @@ +from test import test_support +import unittest + import xdrlib -xdrlib._test() +class XDRTest(unittest.TestCase): + + def test_xdr(self): + p = xdrlib.Packer() + + s = 'hello world' + a = ['what', 'is', 'hapnin', 'doctor'] + + p.pack_int(42) + p.pack_uint(9) + p.pack_bool(True) + p.pack_bool(False) + p.pack_uhyper(45L) + p.pack_float(1.9) + p.pack_double(1.9) + p.pack_string(s) + p.pack_list(range(5), p.pack_uint) + p.pack_array(a, p.pack_string) + + # now verify + data = p.get_buffer() + up = xdrlib.Unpacker(data) + + self.assertEqual(up.get_position(), 0) + + self.assertEqual(up.unpack_int(), 42) + self.assertEqual(up.unpack_uint(), 9) + self.assert_(up.unpack_bool() is True) + + # remember position + pos = up.get_position() + self.assert_(up.unpack_bool() is False) + + # rewind and unpack again + up.set_position(pos) + self.assert_(up.unpack_bool() is False) + + self.assertEqual(up.unpack_uhyper(), 45L) + self.assertAlmostEqual(up.unpack_float(), 1.9) + self.assertAlmostEqual(up.unpack_double(), 1.9) + self.assertEqual(up.unpack_string(), s) + self.assertEqual(up.unpack_list(up.unpack_uint), range(5)) + self.assertEqual(up.unpack_array(up.unpack_string), a) + up.done() + self.assertRaises(EOFError, up.unpack_uint) + +def test_main(): + test_support.run_unittest(XDRTest) + +if __name__ == "__main__": + test_main() Modified: python/trunk/Lib/xdrlib.py ============================================================================== --- python/trunk/Lib/xdrlib.py (original) +++ python/trunk/Lib/xdrlib.py Fri Dec 1 17:59:47 2006 @@ -227,61 +227,3 @@ def unpack_array(self, unpack_item): n = self.unpack_uint() return self.unpack_farray(n, unpack_item) - - -# test suite -def _test(): - p = Packer() - packtest = [ - (p.pack_uint, (9,)), - (p.pack_bool, (True,)), - (p.pack_bool, (False,)), - (p.pack_uhyper, (45L,)), - (p.pack_float, (1.9,)), - (p.pack_double, (1.9,)), - (p.pack_string, ('hello world',)), - (p.pack_list, (range(5), p.pack_uint)), - (p.pack_array, (['what', 'is', 'hapnin', 'doctor'], p.pack_string)), - ] - succeedlist = [1] * len(packtest) - count = 0 - for method, args in packtest: - print 'pack test', count, - try: - method(*args) - print 'succeeded' - except ConversionError, var: - print 'ConversionError:', var.msg - succeedlist[count] = 0 - count = count + 1 - data = p.get_buffer() - # now verify - up = Unpacker(data) - unpacktest = [ - (up.unpack_uint, (), lambda x: x == 9), - (up.unpack_bool, (), lambda x: x is True), - (up.unpack_bool, (), lambda x: x is False), - (up.unpack_uhyper, (), lambda x: x == 45L), - (up.unpack_float, (), lambda x: 1.89 < x < 1.91), - (up.unpack_double, (), lambda x: 1.89 < x < 1.91), - (up.unpack_string, (), lambda x: x == 'hello world'), - (up.unpack_list, (up.unpack_uint,), lambda x: x == range(5)), - (up.unpack_array, (up.unpack_string,), - lambda x: x == ['what', 'is', 'hapnin', 'doctor']), - ] - count = 0 - for method, args, pred in unpacktest: - print 'unpack test', count, - try: - if succeedlist[count]: - x = method(*args) - print pred(x) and 'succeeded' or 'failed', ':', x - else: - print 'skipping' - except ConversionError, var: - print 'ConversionError:', var.msg - count = count + 1 - - -if __name__ == '__main__': - _test() From buildbot at python.org Fri Dec 1 19:02:29 2006 From: buildbot at python.org (buildbot at python.org) Date: Fri, 01 Dec 2006 18:02:29 +0000 Subject: [Python-checkins] buildbot warnings in alpha Tru64 5.1 trunk Message-ID: <20061201180229.6FBBA1E400E@bag.python.org> The Buildbot has detected a new failure of alpha Tru64 5.1 trunk. Full details are available at: http://www.python.org/dev/buildbot/all/alpha%2520Tru64%25205.1%2520trunk/builds/1304 Buildbot URL: http://www.python.org/dev/buildbot/all/ Build Reason: Build Source Stamp: [branch trunk] HEAD Blamelist: walter.doerwald Build had warnings: warnings test Excerpt from the test logfile: 1 test failed: test_socket ====================================================================== FAIL: testInterruptedTimeout (test.test_socket.TCPTimeoutTest) ---------------------------------------------------------------------- Traceback (most recent call last): File "/net/ringneck/scratch1/nnorwitz/buildbot/trunk.norwitz-tru64/build/Lib/test/test_socket.py", line 847, in testInterruptedTimeout self.fail("got Alarm in wrong place") AssertionError: got Alarm in wrong place sincerely, -The Buildbot From python-checkins at python.org Fri Dec 1 21:26:53 2006 From: python-checkins at python.org (guido.van.rossum) Date: Fri, 1 Dec 2006 21:26:53 +0100 (CET) Subject: [Python-checkins] r52895 - sandbox/trunk/2to3/fix_has_key.py sandbox/trunk/2to3/pytree.py Message-ID: <20061201202653.D2E231E4026@bag.python.org> Author: guido.van.rossum Date: Fri Dec 1 21:26:53 2006 New Revision: 52895 Modified: sandbox/trunk/2to3/fix_has_key.py sandbox/trunk/2to3/pytree.py Log: Add a pattern matching capability. Only one example updated to use it so far. (It needs more powerful wildcards -- it has the equivalent of '.' but not '.*'.) Modified: sandbox/trunk/2to3/fix_has_key.py ============================================================================== --- sandbox/trunk/2to3/fix_has_key.py (original) +++ sandbox/trunk/2to3/fix_has_key.py Fri Dec 1 21:26:53 2006 @@ -49,20 +49,23 @@ visit(child, func) # Sample nodes -n_dot = pytree.Leaf(token.DOT, ".") -n_has_key = pytree.Leaf(token.NAME, "has_key") -n_trailer_has_key = pytree.Node(syms.trailer, (n_dot, n_has_key)) -n_lpar = pytree.Leaf(token.LPAR, "(") n_star = pytree.Leaf(token.STAR, "*") n_comma = pytree.Leaf(token.COMMA, ",") n_in = pytree.Leaf(token.NAME, "in", context=(" ", (0, 0))) -import pdb +# Tree matching patterns +p_has_key = pytree.NodePattern(syms.trailer, + (pytree.LeafPattern(token.DOT), + pytree.LeafPattern(token.NAME, "has_key"))) +p_trailer_args = pytree.NodePattern(syms.trailer, + (pytree.LeafPattern(token.LPAR), + pytree.NodePattern(name="args"), + pytree.LeafPattern(token.RPAR))) + def fix_has_key(node): - if node != n_trailer_has_key: + if not p_has_key.match(node): return - # XXX Could use more DOM manipulation primitives and matching operations parent = node.parent nodes = parent.children for i, n in enumerate(nodes): @@ -76,14 +79,10 @@ if len(nodes) != i+2: return # Too much follows ".has_key", e.g. ".has_key(x).blah" next = nodes[i+1] - if next.type != syms.trailer: - return # ".has_key" not followed by another trailer - next_children = next.children - if next_children[0] != n_lpar: - return # ".has_key" not followed by "(...)" - if len(next_children) != 3: - return # ".has_key" followed by "()" - argsnode = next_children[1] + results = {} + if not p_trailer_args.match(next, results): + return + argsnode = results["args"] arg = argsnode if argsnode.type == syms.arglist: args = argsnode.children Modified: sandbox/trunk/2to3/pytree.py ============================================================================== --- sandbox/trunk/2to3/pytree.py (original) +++ sandbox/trunk/2to3/pytree.py Fri Dec 1 21:26:53 2006 @@ -6,7 +6,7 @@ This is a very concrete parse tree; we need to keep every token and even the comments and whitespace between tokens. -A node may be a subnode of at most one parent. +There's also a matching pattern implementation here. """ __author__ = "Guido van Rossum " @@ -18,6 +18,8 @@ This provides some default functionality and boilerplate using the template pattern. + + A node may be a subnode of at most one parent. """ # Default values for instance variables @@ -214,3 +216,124 @@ return Node(type, children, context=context) else: return Leaf(type, value, context=context) + + +class BasePattern(object): + + """A pattern is a tree matching pattern. + + It looks for a specific node type (token or symbol), and + optionally for a specific content. + """ + + # Defaults for instance variables + type = None # Node type (token if < 256, symbol if >= 256) + content = None # Optional content matching pattern + name = None # Optional name used to store match in results dict + + def __new__(cls, *args, **kwds): + """Constructor that prevents BasePattern from being instantiated.""" + assert cls is not BasePattern, "Cannot instantiate BasePattern" + return object.__new__(cls, *args, **kwds) + + def match(self, node, results=None): + """Does that node match this pattern? + + Returns True if it matches, False if not. + + If results is not None, it must be a dict which will be + updated with the nodes matching named subpatterns. + """ + if self.type is not None and node.type != self.type: + return False + if self.content is not None: + r = None + if results is not None: + r = {} + if not self._submatch(node, r): + return False + if r: + results.update(r) + if results is not None and self.name is not None: + results[self.name] = node + return True + + +class NodePattern(BasePattern): + + def __init__(self, type=None, content=None, name=None): + """Constructor. Takes optional type, content, and name. + + The type, if given, must be a symbol type (>= 256). + + The content, if given, must be a sequence of Patterns that + must match the node's children exactly. + + If a name is given, the matching node is stored in the results + dict under that key. + """ + if type is not None: + assert type >= 256, type + else: + assert content is None, repr(content) + if content is not None: + assert not isinstance(content, basestring), repr(content) + content = tuple(content) + for i, item in enumerate(content): + assert isinstance(item, BasePattern), (i, item) + self.type = type + self.content = content + self.name = name + + def _submatch(self, node, results=None): + """Match the pattern's content to the node's children. + + This assumes the node type matches and self.content is not None. + + Returns True if it matches, False if not. + + If results is not None, it must be a dict which will be + updated with the nodes matching named subpatterns. + + When returning False, the results dict may still be updated. + """ + if len(self.content) != len(node.children): + return False + for subpattern, child in zip(self.content, node.children): + if not subpattern.match(child, results): + return False + return True + + +class LeafPattern(BasePattern): + + def __init__(self, type, content=None, name=None): + """Constructor. Takes a type, optional content, and optional name. + + The type must be a token type (< 256). + + The content, if given, must be a string. + + If a name is given, the matching node is stored in the results + dict under that key. + """ + assert type < 256, type + if content is not None: + assert isinstance(content, basestring), repr(content) + self.type = type + self.content = content + self.name = name + + def _submatch(self, node, results=None): + """Match the pattern's content to the node's children. + + This assumes the node type matches and self.content is not None. + + Returns True if it matches, False if not. + + If results is not None, it must be a dict which will be + updated with the nodes matching named subpatterns. + + When returning False, the results dict may still be updated. + """ + return self.content == node.value From python-checkins at python.org Sat Dec 2 00:41:06 2006 From: python-checkins at python.org (guido.van.rossum) Date: Sat, 2 Dec 2006 00:41:06 +0100 (CET) Subject: [Python-checkins] r52897 - sandbox/trunk/2to3/fix_apply.py Message-ID: <20061201234106.6C7471E400E@bag.python.org> Author: guido.van.rossum Date: Sat Dec 2 00:41:06 2006 New Revision: 52897 Modified: sandbox/trunk/2to3/fix_apply.py Log: Another fixer to use pattern matching. Modified: sandbox/trunk/2to3/fix_apply.py ============================================================================== --- sandbox/trunk/2to3/fix_apply.py (original) +++ sandbox/trunk/2to3/fix_apply.py Sat Dec 2 00:41:06 2006 @@ -56,25 +56,24 @@ visit(child, func) -# Constant nodes -n_apply = pytree.Leaf(token.NAME, "apply") -n_lpar = pytree.Leaf(token.LPAR, "(") -n_rpar = pytree.Leaf(token.RPAR, ")") +# Constant nodes used for matching n_comma = pytree.Leaf(token.COMMA, ",") n_star = pytree.Leaf(token.STAR, "*") n_doublestar = pytree.Leaf(token.DOUBLESTAR, "**") +# Tree matching patterns +p_apply = pytree.NodePattern(syms.power, + (pytree.LeafPattern(token.NAME, "apply"), + pytree.NodePattern(syms.trailer, + (pytree.LeafPattern(token.LPAR), + pytree.NodePattern(name="args"), + pytree.LeafPattern(token.RPAR))))) + def fix_apply(node): - if not (node.type == syms.power and - len(node.children) >= 2 and - node.children[0] == n_apply and - node.children[1].type == syms.trailer and - node.children[1].children[0] == n_lpar): + if not p_apply.match(node): return n_arglist = node.children[1].children[1] - if n_arglist == n_rpar: - return # apply() with no arguments?! if n_arglist.type != syms.arglist: return # apply() with only one argument?! l_args = [] From python-checkins at python.org Sat Dec 2 00:51:14 2006 From: python-checkins at python.org (guido.van.rossum) Date: Sat, 2 Dec 2006 00:51:14 +0100 (CET) Subject: [Python-checkins] r52898 - sandbox/trunk/2to3/fix_print.py Message-ID: <20061201235114.50C981E400E@bag.python.org> Author: guido.van.rossum Date: Sat Dec 2 00:51:14 2006 New Revision: 52898 Modified: sandbox/trunk/2to3/fix_print.py Log: This doesn't benefit from matching patterns (yet), but it did get broken subtly by the tree optimization change. Modified: sandbox/trunk/2to3/fix_print.py ============================================================================== --- sandbox/trunk/2to3/fix_print.py (original) +++ sandbox/trunk/2to3/fix_print.py Sat Dec 2 00:51:14 2006 @@ -3,8 +3,9 @@ # Licensed to PSF under a Contributor Agreement. """Refactoring tool: change print statements into function calls, ie change: + 'print' into 'Print()' 'print ...' into 'Print(...)' - 'print ... ,' into 'Print(..., sep=" ", end="")' + 'print ... ,' into 'Print(..., end=" ")' 'print >>x, ...' into 'Print(..., file=x)' """ @@ -59,6 +60,16 @@ def fix_print(node): + if node == pytree.Leaf(token.NAME, "print"): + # Special-case print all by itself + new = pytree.Node(syms.power, + (pytree.Leaf(token.NAME, "Print"), + pytree.Node(syms.trailer, + (pytree.Leaf(token.LPAR, "("), + pytree.Leaf(token.RPAR, ")"))))) + new.set_prefix(node.get_prefix()) + node.replace(new) + return if node.type != syms.print_stmt: return assert node.children[0] == pytree.Leaf(token.NAME, "print") @@ -66,8 +77,7 @@ sep = end = file = None if args and args[-1] == pytree.Leaf(token.COMMA, ","): args = args[:-1] - sep = " " - end = "" + end = " " if args and args[0] == pytree.Leaf(token.RIGHTSHIFT, ">>"): assert len(args) >= 2 file = args[1] From python-checkins at python.org Sat Dec 2 02:57:22 2006 From: python-checkins at python.org (raymond.hettinger) Date: Sat, 2 Dec 2006 02:57:22 +0100 (CET) Subject: [Python-checkins] r52899 - python/branches/release25-maint/Lib/Queue.py Message-ID: <20061202015722.77DC71E4006@bag.python.org> Author: raymond.hettinger Date: Sat Dec 2 02:57:21 2006 New Revision: 52899 Modified: python/branches/release25-maint/Lib/Queue.py Log: Fix nit in comment. Modified: python/branches/release25-maint/Lib/Queue.py ============================================================================== --- python/branches/release25-maint/Lib/Queue.py (original) +++ python/branches/release25-maint/Lib/Queue.py Sat Dec 2 02:57:21 2006 @@ -26,7 +26,7 @@ self._init(maxsize) # mutex must be held whenever the queue is mutating. All methods # that acquire mutex must release it before returning. mutex - # is shared between the two conditions, so acquiring and + # is shared between the three conditions, so acquiring and # releasing the conditions also acquires and releases mutex. self.mutex = threading.Lock() # Notify not_empty whenever an item is added to the queue; a From python-checkins at python.org Sat Dec 2 03:00:39 2006 From: python-checkins at python.org (raymond.hettinger) Date: Sat, 2 Dec 2006 03:00:39 +0100 (CET) Subject: [Python-checkins] r52900 - python/trunk/Lib/tokenize.py Message-ID: <20061202020039.578DF1E4006@bag.python.org> Author: raymond.hettinger Date: Sat Dec 2 03:00:39 2006 New Revision: 52900 Modified: python/trunk/Lib/tokenize.py Log: Add name to credits (for untokenize). Modified: python/trunk/Lib/tokenize.py ============================================================================== --- python/trunk/Lib/tokenize.py (original) +++ python/trunk/Lib/tokenize.py Sat Dec 2 03:00:39 2006 @@ -24,7 +24,7 @@ __author__ = 'Ka-Ping Yee ' __credits__ = \ - 'GvR, ESR, Tim Peters, Thomas Wouters, Fred Drake, Skip Montanaro' + 'GvR, ESR, Tim Peters, Thomas Wouters, Fred Drake, Skip Montanaro, Raymond Hettinger' import string, re from token import * From buildbot at python.org Sat Dec 2 03:11:12 2006 From: buildbot at python.org (buildbot at python.org) Date: Sat, 02 Dec 2006 02:11:12 +0000 Subject: [Python-checkins] buildbot warnings in x86 XP 2.5 Message-ID: <20061202021112.D5B291E4010@bag.python.org> The Buildbot has detected a new failure of x86 XP 2.5. Full details are available at: http://www.python.org/dev/buildbot/all/x86%2520XP%25202.5/builds/49 Buildbot URL: http://www.python.org/dev/buildbot/all/ Build Reason: Build Source Stamp: [branch branches/release25-maint] HEAD Blamelist: raymond.hettinger Build had warnings: warnings failed slave lost sincerely, -The Buildbot From python-checkins at python.org Sat Dec 2 03:43:48 2006 From: python-checkins at python.org (guido.van.rossum) Date: Sat, 2 Dec 2006 03:43:48 +0100 (CET) Subject: [Python-checkins] r52901 - sandbox/trunk/2to3/fix_has_key.py sandbox/trunk/2to3/pytree.py Message-ID: <20061202024348.6BC711E4006@bag.python.org> Author: guido.van.rossum Date: Sat Dec 2 03:43:47 2006 New Revision: 52901 Modified: sandbox/trunk/2to3/fix_has_key.py sandbox/trunk/2to3/pytree.py Log: Add a wildcard pattern matcher. Lightly tested. Modified: sandbox/trunk/2to3/fix_has_key.py ============================================================================== --- sandbox/trunk/2to3/fix_has_key.py (original) +++ sandbox/trunk/2to3/fix_has_key.py Sat Dec 2 03:43:47 2006 @@ -59,7 +59,7 @@ pytree.LeafPattern(token.NAME, "has_key"))) p_trailer_args = pytree.NodePattern(syms.trailer, (pytree.LeafPattern(token.LPAR), - pytree.NodePattern(name="args"), + pytree.WildcardPattern(name="args"), pytree.LeafPattern(token.RPAR))) @@ -82,7 +82,10 @@ results = {} if not p_trailer_args.match(next, results): return - argsnode = results["args"] + argsnodes = results["args"] + if len(argsnodes) != 1: + return + argsnode = argsnodes[0] arg = argsnode if argsnode.type == syms.arglist: args = argsnode.children Modified: sandbox/trunk/2to3/pytree.py ============================================================================== --- sandbox/trunk/2to3/pytree.py (original) +++ sandbox/trunk/2to3/pytree.py Sat Dec 2 03:43:47 2006 @@ -6,11 +6,13 @@ This is a very concrete parse tree; we need to keep every token and even the comments and whitespace between tokens. -There's also a matching pattern implementation here. +There's also a pattern matching implementation here. """ __author__ = "Guido van Rossum " +import sys + class Base(object): @@ -261,6 +263,8 @@ class NodePattern(BasePattern): + wildcards = False + def __init__(self, type=None, content=None, name=None): """Constructor. Takes optional type, content, and name. @@ -281,6 +285,8 @@ content = tuple(content) for i, item in enumerate(content): assert isinstance(item, BasePattern), (i, item) + if isinstance(item, WildcardPattern): + self.wildcards = True self.type = type self.content = content self.name = name @@ -297,6 +303,8 @@ When returning False, the results dict may still be updated. """ + if self.wildcards: + return _wcmatch(self.content, node.children, results) if len(self.content) != len(node.children): return False for subpattern, child in zip(self.content, node.children): @@ -305,6 +313,38 @@ return True +def _wcmatch(patterns, nodes, results): + if not patterns: + if nodes: + return False + return True + pat = patterns[0] + if isinstance(pat, WildcardPattern): + for i in xrange(pat.min): + if i >= len(nodes) or not pat.match(nodes[i], None): + return False + for i in xrange(pat.min, pat.max): + # Shortest match wins + r = {} + if _wcmatch(patterns[1:], nodes[i:], r): + if pat.name: + r[pat.name] = nodes[:i] + if results is not None: + results.update(r) + return True + return False + else: + if not nodes: + return False + r = {} + if pat.match(nodes[0], r): + if _wcmatch(patterns[1:], nodes[1:], r): + if results is not None: + results.update(r) + return True + return False + + class LeafPattern(BasePattern): def __init__(self, type, content=None, name=None): @@ -337,3 +377,18 @@ When returning False, the results dict may still be updated. """ return self.content == node.value + + +class WildcardPattern(NodePattern): + + """A wildcard pattern can match zero or more nodes. + + The matching must be done by special-casing in NodePattern._submatch(). + """ + + def __init__(self, type=None, content=None, name=None, + min=0, max=sys.maxint): + """Constructor.""" + NodePattern.__init__(self, type=type, content=content, name=name) + self.min = min + self.max = max From buildbot at python.org Sat Dec 2 04:30:11 2006 From: buildbot at python.org (buildbot at python.org) Date: Sat, 02 Dec 2006 03:30:11 +0000 Subject: [Python-checkins] buildbot failure in x86 Ubuntu edgy (icc) trunk Message-ID: <20061202033011.3D3501E4006@bag.python.org> The Buildbot has detected a new failure of x86 Ubuntu edgy (icc) trunk. Full details are available at: http://www.python.org/dev/buildbot/all/x86%2520Ubuntu%2520edgy%2520%2528icc%2529%2520trunk/builds/1095 Buildbot URL: http://www.python.org/dev/buildbot/all/ Build Reason: Build Source Stamp: [branch trunk] HEAD Blamelist: raymond.hettinger BUILD FAILED: failed failed slave lost sincerely, -The Buildbot From buildbot at python.org Sat Dec 2 06:08:49 2006 From: buildbot at python.org (buildbot at python.org) Date: Sat, 02 Dec 2006 05:08:49 +0000 Subject: [Python-checkins] buildbot failure in sparc Ubuntu dapper trunk Message-ID: <20061202050849.B5FE71E4006@bag.python.org> The Buildbot has detected a new failure of sparc Ubuntu dapper trunk. Full details are available at: http://www.python.org/dev/buildbot/all/sparc%2520Ubuntu%2520dapper%2520trunk/builds/813 Buildbot URL: http://www.python.org/dev/buildbot/all/ Build Reason: Build Source Stamp: [branch trunk] HEAD Blamelist: raymond.hettinger BUILD FAILED: failed compile sincerely, -The Buildbot From python-checkins at python.org Sat Dec 2 23:38:26 2006 From: python-checkins at python.org (erik.forsberg) Date: Sat, 2 Dec 2006 23:38:26 +0100 (CET) Subject: [Python-checkins] r52902 - tracker/instances/python-dev/html/page.html Message-ID: <20061202223826.741771E4010@bag.python.org> Author: erik.forsberg Date: Sat Dec 2 23:38:25 2006 New Revision: 52902 Modified: tracker/instances/python-dev/html/page.html Log: Removed references to keyword, as there is no keywords in this instance. Modified: tracker/instances/python-dev/html/page.html ============================================================================== --- tracker/instances/python-dev/html/page.html (original) +++ tracker/instances/python-dev/html/page.html Sat Dec 2 23:38:25 2006 @@ -18,9 +18,7 @@ Message-ID: <87r6vh3cqg.fsf@hydra.bayview.thirdcreek.com> "martin.v.loewis" writes: > Modified: python/trunk/Misc/NEWS > ============================================================================== > --- python/trunk/Misc/NEWS (original) > +++ python/trunk/Misc/NEWS Wed Nov 22 09:50:02 2006 > @@ -101,6 +101,9 @@ > Library > ------- > > +- Patch #1362975: Rework CodeContext indentation algorithm to > + avoid hard-coding pixel widths. > + > - Patch #1070046: Marshal new-style objects like InstanceType > in xmlrpclib. IDLE NEWS is being kept in idlelib/NEWS.txt. It displays via the IDLE About dialog. -- KBK From python-checkins at python.org Sun Dec 3 09:23:02 2006 From: python-checkins at python.org (georg.brandl) Date: Sun, 3 Dec 2006 09:23:02 +0100 (CET) Subject: [Python-checkins] r52903 - peps/trunk/pep-3100.txt Message-ID: <20061203082302.D7AFA1E4011@bag.python.org> Author: georg.brandl Date: Sun Dec 3 09:23:02 2006 New Revision: 52903 Modified: peps/trunk/pep-3100.txt Log: Removing callable() is not certain. Modified: peps/trunk/pep-3100.txt ============================================================================== --- peps/trunk/pep-3100.txt (original) +++ peps/trunk/pep-3100.txt Sun Dec 3 09:23:02 2006 @@ -173,7 +173,7 @@ * ``apply()``: use ``f(*args, **kw)`` instead [2]_ [done] * ``buffer()``: must die (use a bytes() type instead) (?) [2]_ -* ``callable()``: just call the object and catch the exception [2]_ +* ``callable()``: just call the object and catch the exception??? [2]_ * ``compile()``: put in ``sys`` (or perhaps in a module of its own) [2]_ * ``coerce()``: no longer needed [2]_ * ``execfile()``, ``reload()``: use ``exec()`` [2]_ From python-checkins at python.org Sun Dec 3 10:17:50 2006 From: python-checkins at python.org (erik.forsberg) Date: Sun, 3 Dec 2006 10:17:50 +0100 (CET) Subject: [Python-checkins] r52904 - tracker/instances/python-dev/schema.py Message-ID: <20061203091750.B82301E4011@bag.python.org> Author: erik.forsberg Date: Sun Dec 3 10:17:50 2006 New Revision: 52904 Modified: tracker/instances/python-dev/schema.py Log: Fixed cut'n paste error - do setkey('name') on priority, not twice on severity.. :-) Modified: tracker/instances/python-dev/schema.py ============================================================================== --- tracker/instances/python-dev/schema.py (original) +++ tracker/instances/python-dev/schema.py Sun Dec 3 10:17:50 2006 @@ -49,7 +49,7 @@ name=String(), description=String(), order=Number()) -severity.setkey('name') +priority.setkey('name') # Status status = Class(db, "status", From python-checkins at python.org Sun Dec 3 10:54:47 2006 From: python-checkins at python.org (martin.v.loewis) Date: Sun, 3 Dec 2006 10:54:47 +0100 (CET) Subject: [Python-checkins] r52905 - in python/trunk: Lib/idlelib/NEWS.txt Misc/NEWS Message-ID: <20061203095447.BBCB71E4011@bag.python.org> Author: martin.v.loewis Date: Sun Dec 3 10:54:46 2006 New Revision: 52905 Modified: python/trunk/Lib/idlelib/NEWS.txt python/trunk/Misc/NEWS Log: Move IDLE news into NEWS.txt. Modified: python/trunk/Lib/idlelib/NEWS.txt ============================================================================== --- python/trunk/Lib/idlelib/NEWS.txt (original) +++ python/trunk/Lib/idlelib/NEWS.txt Sun Dec 3 10:54:46 2006 @@ -3,6 +3,9 @@ *Release date: XX-XXX-200X* +- Patch #1362975: Rework CodeContext indentation algorithm to + avoid hard-coding pixel widths. + - Some syntax errors were being caught by tokenize during the tabnanny check, resulting in obscure error messages. Do the syntax check first. Bug 1562716, 1562719 Modified: python/trunk/Misc/NEWS ============================================================================== --- python/trunk/Misc/NEWS (original) +++ python/trunk/Misc/NEWS Sun Dec 3 10:54:46 2006 @@ -105,9 +105,6 @@ - Bug #1598620: A ctypes Structure cannot contain itself. -- Patch #1362975: Rework CodeContext indentation algorithm to - avoid hard-coding pixel widths. - - Patch #1070046: Marshal new-style objects like InstanceType in xmlrpclib. From martin at v.loewis.de Sun Dec 3 10:55:12 2006 From: martin at v.loewis.de (=?ISO-8859-1?Q?=22Martin_v=2E_L=F6wis=22?=) Date: Sun, 03 Dec 2006 10:55:12 +0100 Subject: [Python-checkins] r52821 - in python/trunk: Lib/idlelib/CodeContext.py Lib/idlelib/EditorWindow.py Misc/NEWS In-Reply-To: <87r6vh3cqg.fsf@hydra.bayview.thirdcreek.com> References: <20061122085004.25FCF1E4008@bag.python.org> <87r6vh3cqg.fsf@hydra.bayview.thirdcreek.com> Message-ID: <45729F00.2040904@v.loewis.de> Kurt B. Kaiser schrieb: > IDLE NEWS is being kept in idlelib/NEWS.txt. It displays via the IDLE > About dialog. Ok, I've moved it there. Regards, Martin From python-checkins at python.org Sun Dec 3 12:23:47 2006 From: python-checkins at python.org (martin.v.loewis) Date: Sun, 3 Dec 2006 12:23:47 +0100 (CET) Subject: [Python-checkins] r52906 - in python/trunk: Misc/NEWS Modules/socketmodule.c Modules/socketmodule.h Message-ID: <20061203112347.E02CA1E4011@bag.python.org> Author: martin.v.loewis Date: Sun Dec 3 12:23:45 2006 New Revision: 52906 Modified: python/trunk/Misc/NEWS python/trunk/Modules/socketmodule.c python/trunk/Modules/socketmodule.h Log: Patch #1544279: Improve thread-safety of the socket module by moving the sock_addr_t storage out of the socket object. Will backport to 2.5. Modified: python/trunk/Misc/NEWS ============================================================================== --- python/trunk/Misc/NEWS (original) +++ python/trunk/Misc/NEWS Sun Dec 3 12:23:45 2006 @@ -240,6 +240,9 @@ Extension Modules ----------------- +- Patch #1544279: Improve thread-safety of the socket module by moving + the sock_addr_t storage out of the socket object. + - Speed up function calls into the math module. - Bug #1588217: don't parse "= " as a soft line break in binascii's Modified: python/trunk/Modules/socketmodule.c ============================================================================== --- python/trunk/Modules/socketmodule.c (original) +++ python/trunk/Modules/socketmodule.c Sun Dec 3 12:23:45 2006 @@ -364,19 +364,16 @@ #define BTPROTO_RFCOMM BLUETOOTH_PROTO_RFCOMM #define sockaddr_l2 sockaddr_l2cap #define sockaddr_rc sockaddr_rfcomm -#define _BT_SOCKADDR_MEMB(s, proto) &((s)->sock_addr) #define _BT_L2_MEMB(sa, memb) ((sa)->l2cap_##memb) #define _BT_RC_MEMB(sa, memb) ((sa)->rfcomm_##memb) #elif defined(__NetBSD__) #define sockaddr_l2 sockaddr_bt #define sockaddr_rc sockaddr_bt #define sockaddr_sco sockaddr_bt -#define _BT_SOCKADDR_MEMB(s, proto) &((s)->sock_addr) #define _BT_L2_MEMB(sa, memb) ((sa)->bt_##memb) #define _BT_RC_MEMB(sa, memb) ((sa)->bt_##memb) #define _BT_SCO_MEMB(sa, memb) ((sa)->bt_##memb) #else -#define _BT_SOCKADDR_MEMB(s, proto) (&((s)->sock_addr).bt_##proto) #define _BT_L2_MEMB(sa, memb) ((sa)->l2_##memb) #define _BT_RC_MEMB(sa, memb) ((sa)->rc_##memb) #define _BT_SCO_MEMB(sa, memb) ((sa)->sco_##memb) @@ -388,6 +385,8 @@ #define SEGMENT_SIZE (32 * 1024 -1) #endif +#define SAS2SA(x) ((struct sockaddr *)(x)) + /* * Constants for getnameinfo() */ @@ -1174,7 +1173,7 @@ static int getsockaddrarg(PySocketSockObject *s, PyObject *args, - struct sockaddr **addr_ret, int *len_ret) + struct sockaddr *addr_ret, int *len_ret) { switch (s->sock_family) { @@ -1184,9 +1183,10 @@ struct sockaddr_un* addr; char *path; int len; - addr = (struct sockaddr_un*)&(s->sock_addr).un; if (!PyArg_Parse(args, "t#", &path, &len)) return 0; + + addr = (struct sockaddr_un*)addr_ret; #ifdef linux if (len > 0 && path[0] == 0) { /* Linux abstract namespace extension */ @@ -1209,7 +1209,6 @@ } addr->sun_family = s->sock_family; memcpy(addr->sun_path, path, len); - *addr_ret = (struct sockaddr *) addr; #if defined(PYOS_OS2) *len_ret = sizeof(*addr); #else @@ -1224,7 +1223,7 @@ { struct sockaddr_nl* addr; int pid, groups; - addr = (struct sockaddr_nl *)&(s->sock_addr).nl; + addr = (struct sockaddr_nl *)addr_ret; if (!PyTuple_Check(args)) { PyErr_Format( PyExc_TypeError, @@ -1238,7 +1237,6 @@ addr->nl_family = AF_NETLINK; addr->nl_pid = pid; addr->nl_groups = groups; - *addr_ret = (struct sockaddr *) addr; *len_ret = sizeof(*addr); return 1; } @@ -1249,7 +1247,6 @@ struct sockaddr_in* addr; char *host; int port, result; - addr=(struct sockaddr_in*)&(s->sock_addr).in; if (!PyTuple_Check(args)) { PyErr_Format( PyExc_TypeError, @@ -1261,6 +1258,7 @@ if (!PyArg_ParseTuple(args, "eti:getsockaddrarg", "idna", &host, &port)) return 0; + addr=(struct sockaddr_in*)addr_ret; result = setipaddr(host, (struct sockaddr *)addr, sizeof(*addr), AF_INET); PyMem_Free(host); @@ -1268,7 +1266,6 @@ return 0; addr->sin_family = AF_INET; addr->sin_port = htons((short)port); - *addr_ret = (struct sockaddr *) addr; *len_ret = sizeof *addr; return 1; } @@ -1279,7 +1276,6 @@ struct sockaddr_in6* addr; char *host; int port, flowinfo, scope_id, result; - addr = (struct sockaddr_in6*)&(s->sock_addr).in6; flowinfo = scope_id = 0; if (!PyTuple_Check(args)) { PyErr_Format( @@ -1294,6 +1290,7 @@ &scope_id)) { return 0; } + addr = (struct sockaddr_in6*)addr_ret; result = setipaddr(host, (struct sockaddr *)addr, sizeof(*addr), AF_INET6); PyMem_Free(host); @@ -1303,7 +1300,6 @@ addr->sin6_port = htons((short)port); addr->sin6_flowinfo = flowinfo; addr->sin6_scope_id = scope_id; - *addr_ret = (struct sockaddr *) addr; *len_ret = sizeof *addr; return 1; } @@ -1315,9 +1311,10 @@ switch (s->sock_proto) { case BTPROTO_L2CAP: { - struct sockaddr_l2 *addr = (struct sockaddr_l2 *) _BT_SOCKADDR_MEMB(s, l2); + struct sockaddr_l2 *addr; char *straddr; + addr = (struct sockaddr_l2 *)addr_ret; _BT_L2_MEMB(addr, family) = AF_BLUETOOTH; if (!PyArg_ParseTuple(args, "si", &straddr, &_BT_L2_MEMB(addr, psm))) { @@ -1328,15 +1325,15 @@ if (setbdaddr(straddr, &_BT_L2_MEMB(addr, bdaddr)) < 0) return 0; - *addr_ret = (struct sockaddr *) addr; *len_ret = sizeof *addr; return 1; } case BTPROTO_RFCOMM: { - struct sockaddr_rc *addr = (struct sockaddr_rc *) _BT_SOCKADDR_MEMB(s, rc); + struct sockaddr_rc *addr; char *straddr; + addr = (struct sockaddr_rc *)addr_ret; _BT_RC_MEMB(addr, family) = AF_BLUETOOTH; if (!PyArg_ParseTuple(args, "si", &straddr, &_BT_RC_MEMB(addr, channel))) { @@ -1347,16 +1344,16 @@ if (setbdaddr(straddr, &_BT_RC_MEMB(addr, bdaddr)) < 0) return 0; - *addr_ret = (struct sockaddr *) addr; *len_ret = sizeof *addr; return 1; } #if !defined(__FreeBSD__) case BTPROTO_SCO: { - struct sockaddr_sco *addr = (struct sockaddr_sco *) _BT_SOCKADDR_MEMB(s, sco); + struct sockaddr_sco *addr; char *straddr; + addr = (struct sockaddr_sco *)addr_ret; _BT_SCO_MEMB(addr, family) = AF_BLUETOOTH; straddr = PyString_AsString(args); if (straddr == NULL) { @@ -1367,7 +1364,6 @@ if (setbdaddr(straddr, &_BT_SCO_MEMB(addr, bdaddr)) < 0) return 0; - *addr_ret = (struct sockaddr *) addr; *len_ret = sizeof *addr; return 1; } @@ -1409,22 +1405,21 @@ s->errorhandler(); return 0; } - addr = &(s->sock_addr.ll); - addr->sll_family = AF_PACKET; - addr->sll_protocol = htons((short)protoNumber); - addr->sll_ifindex = ifr.ifr_ifindex; - addr->sll_pkttype = pkttype; - addr->sll_hatype = hatype; if (halen > 8) { PyErr_SetString(PyExc_ValueError, "Hardware address must be 8 bytes or less"); return 0; } + addr = (struct sockaddr_ll*)addr_ret; + addr->sll_family = AF_PACKET; + addr->sll_protocol = htons((short)protoNumber); + addr->sll_ifindex = ifr.ifr_ifindex; + addr->sll_pkttype = pkttype; + addr->sll_hatype = hatype; if (halen != 0) { memcpy(&addr->sll_addr, haddr, halen); } addr->sll_halen = halen; - *addr_ret = (struct sockaddr *) addr; *len_ret = sizeof *addr; return 1; } @@ -1551,8 +1546,7 @@ Py_BEGIN_ALLOW_THREADS timeout = internal_select(s, 0); if (!timeout) - newfd = accept(s->sock_fd, (struct sockaddr *) &addrbuf, - &addrlen); + newfd = accept(s->sock_fd, SAS2SA(&addrbuf), &addrlen); Py_END_ALLOW_THREADS if (timeout == 1) { @@ -1578,7 +1572,7 @@ SOCKETCLOSE(newfd); goto finally; } - addr = makesockaddr(s->sock_fd, (struct sockaddr *) &addrbuf, + addr = makesockaddr(s->sock_fd, SAS2SA(&addrbuf), addrlen, s->sock_proto); if (addr == NULL) goto finally; @@ -1819,14 +1813,14 @@ static PyObject * sock_bind(PySocketSockObject *s, PyObject *addro) { - struct sockaddr *addr; + sock_addr_t addrbuf; int addrlen; int res; - if (!getsockaddrarg(s, addro, &addr, &addrlen)) + if (!getsockaddrarg(s, addro, SAS2SA(&addrbuf), &addrlen)) return NULL; Py_BEGIN_ALLOW_THREADS - res = bind(s->sock_fd, addr, addrlen); + res = bind(s->sock_fd, SAS2SA(&addrbuf), addrlen); Py_END_ALLOW_THREADS if (res < 0) return s->errorhandler(); @@ -1952,16 +1946,16 @@ static PyObject * sock_connect(PySocketSockObject *s, PyObject *addro) { - struct sockaddr *addr; + sock_addr_t addrbuf; int addrlen; int res; int timeout; - if (!getsockaddrarg(s, addro, &addr, &addrlen)) + if (!getsockaddrarg(s, addro, SAS2SA(&addrbuf), &addrlen)) return NULL; Py_BEGIN_ALLOW_THREADS - res = internal_connect(s, addr, addrlen, &timeout); + res = internal_connect(s, SAS2SA(&addrbuf), addrlen, &timeout); Py_END_ALLOW_THREADS if (timeout == 1) { @@ -1986,16 +1980,16 @@ static PyObject * sock_connect_ex(PySocketSockObject *s, PyObject *addro) { - struct sockaddr *addr; + sock_addr_t addrbuf; int addrlen; int res; int timeout; - if (!getsockaddrarg(s, addro, &addr, &addrlen)) + if (!getsockaddrarg(s, addro, SAS2SA(&addrbuf), &addrlen)) return NULL; Py_BEGIN_ALLOW_THREADS - res = internal_connect(s, addr, addrlen, &timeout); + res = internal_connect(s, SAS2SA(&addrbuf), addrlen, &timeout); Py_END_ALLOW_THREADS /* Signals are not errors (though they may raise exceptions). Adapted @@ -2075,11 +2069,11 @@ return NULL; memset(&addrbuf, 0, addrlen); Py_BEGIN_ALLOW_THREADS - res = getsockname(s->sock_fd, (struct sockaddr *) &addrbuf, &addrlen); + res = getsockname(s->sock_fd, SAS2SA(&addrbuf), &addrlen); Py_END_ALLOW_THREADS if (res < 0) return s->errorhandler(); - return makesockaddr(s->sock_fd, (struct sockaddr *) &addrbuf, addrlen, + return makesockaddr(s->sock_fd, SAS2SA(&addrbuf), addrlen, s->sock_proto); } @@ -2104,11 +2098,11 @@ return NULL; memset(&addrbuf, 0, addrlen); Py_BEGIN_ALLOW_THREADS - res = getpeername(s->sock_fd, (struct sockaddr *) &addrbuf, &addrlen); + res = getpeername(s->sock_fd, SAS2SA(&addrbuf), &addrlen); Py_END_ALLOW_THREADS if (res < 0) return s->errorhandler(); - return makesockaddr(s->sock_fd, (struct sockaddr *) &addrbuf, addrlen, + return makesockaddr(s->sock_fd, SAS2SA(&addrbuf), addrlen, s->sock_proto); } @@ -2443,14 +2437,14 @@ #ifndef MS_WINDOWS #if defined(PYOS_OS2) && !defined(PYCC_GCC) n = recvfrom(s->sock_fd, cbuf, len, flags, - (struct sockaddr *) &addrbuf, &addrlen); + SAS2SA(&addrbuf), &addrlen); #else n = recvfrom(s->sock_fd, cbuf, len, flags, (void *) &addrbuf, &addrlen); #endif #else n = recvfrom(s->sock_fd, cbuf, len, flags, - (struct sockaddr *) &addrbuf, &addrlen); + SAS2SA(&addrbuf), &addrlen); #endif } Py_END_ALLOW_THREADS @@ -2464,7 +2458,7 @@ return -1; } - if (!(*addr = makesockaddr(s->sock_fd, (struct sockaddr *) &addrbuf, + if (!(*addr = makesockaddr(s->sock_fd, SAS2SA(&addrbuf), addrlen, s->sock_proto))) return -1; @@ -2664,7 +2658,7 @@ { PyObject *addro; char *buf; - struct sockaddr *addr; + sock_addr_t addrbuf; int addrlen, len, n = -1, flags, timeout; flags = 0; @@ -2675,16 +2669,16 @@ return NULL; } - if (!getsockaddrarg(s, addro, &addr, &addrlen)) - return NULL; - if (!IS_SELECTABLE(s)) return select_error(); + if (!getsockaddrarg(s, addro, SAS2SA(&addrbuf), &addrlen)) + return NULL; + Py_BEGIN_ALLOW_THREADS timeout = internal_select(s, 1); if (!timeout) - n = sendto(s->sock_fd, buf, len, flags, addr, addrlen); + n = sendto(s->sock_fd, buf, len, flags, SAS2SA(&addrbuf), addrlen); Py_END_ALLOW_THREADS if (timeout == 1) { @@ -2973,10 +2967,9 @@ if (!PyArg_ParseTuple(args, "s:gethostbyname", &name)) return NULL; - if (setipaddr(name, (struct sockaddr *)&addrbuf, sizeof(addrbuf), AF_INET) < 0) + if (setipaddr(name, SAS2SA(&addrbuf), sizeof(addrbuf), AF_INET) < 0) return NULL; - return makeipaddr((struct sockaddr *)&addrbuf, - sizeof(struct sockaddr_in)); + return makeipaddr(SAS2SA(&addrbuf), sizeof(struct sockaddr_in)); } PyDoc_STRVAR(gethostbyname_doc, Modified: python/trunk/Modules/socketmodule.h ============================================================================== --- python/trunk/Modules/socketmodule.h (original) +++ python/trunk/Modules/socketmodule.h Sun Dec 3 12:23:45 2006 @@ -114,7 +114,6 @@ int sock_family; /* Address family, e.g., AF_INET */ int sock_type; /* Socket type, e.g., SOCK_STREAM */ int sock_proto; /* Protocol type, usually 0 */ - sock_addr_t sock_addr; /* Socket address */ PyObject *(*errorhandler)(void); /* Error handler; checks errno, returns NULL and sets a Python exception */ From python-checkins at python.org Sun Dec 3 12:24:00 2006 From: python-checkins at python.org (martin.v.loewis) Date: Sun, 3 Dec 2006 12:24:00 +0100 (CET) Subject: [Python-checkins] r52907 - in python/branches/release25-maint: Misc/NEWS Modules/socketmodule.c Modules/socketmodule.h Message-ID: <20061203112400.F33691E4011@bag.python.org> Author: martin.v.loewis Date: Sun Dec 3 12:24:00 2006 New Revision: 52907 Modified: python/branches/release25-maint/Misc/NEWS python/branches/release25-maint/Modules/socketmodule.c python/branches/release25-maint/Modules/socketmodule.h Log: Patch #1544279: Improve thread-safety of the socket module by moving the sock_addr_t storage out of the socket object. Modified: python/branches/release25-maint/Misc/NEWS ============================================================================== --- python/branches/release25-maint/Misc/NEWS (original) +++ python/branches/release25-maint/Misc/NEWS Sun Dec 3 12:24:00 2006 @@ -70,6 +70,9 @@ Extension Modules ----------------- +- Patch #1544279: Improve thread-safety of the socket module by moving + the sock_addr_t storage out of the socket object. + - Bug #1563807: _ctypes built on AIX fails with ld ffi error. - Bug #1598620: A ctypes Structure cannot contain itself. Modified: python/branches/release25-maint/Modules/socketmodule.c ============================================================================== --- python/branches/release25-maint/Modules/socketmodule.c (original) +++ python/branches/release25-maint/Modules/socketmodule.c Sun Dec 3 12:24:00 2006 @@ -364,19 +364,16 @@ #define BTPROTO_RFCOMM BLUETOOTH_PROTO_RFCOMM #define sockaddr_l2 sockaddr_l2cap #define sockaddr_rc sockaddr_rfcomm -#define _BT_SOCKADDR_MEMB(s, proto) &((s)->sock_addr) #define _BT_L2_MEMB(sa, memb) ((sa)->l2cap_##memb) #define _BT_RC_MEMB(sa, memb) ((sa)->rfcomm_##memb) #elif defined(__NetBSD__) #define sockaddr_l2 sockaddr_bt #define sockaddr_rc sockaddr_bt #define sockaddr_sco sockaddr_bt -#define _BT_SOCKADDR_MEMB(s, proto) &((s)->sock_addr) #define _BT_L2_MEMB(sa, memb) ((sa)->bt_##memb) #define _BT_RC_MEMB(sa, memb) ((sa)->bt_##memb) #define _BT_SCO_MEMB(sa, memb) ((sa)->bt_##memb) #else -#define _BT_SOCKADDR_MEMB(s, proto) (&((s)->sock_addr).bt_##proto) #define _BT_L2_MEMB(sa, memb) ((sa)->l2_##memb) #define _BT_RC_MEMB(sa, memb) ((sa)->rc_##memb) #define _BT_SCO_MEMB(sa, memb) ((sa)->sco_##memb) @@ -388,6 +385,8 @@ #define SEGMENT_SIZE (32 * 1024 -1) #endif +#define SAS2SA(x) ((struct sockaddr *)(x)) + /* * Constants for getnameinfo() */ @@ -1174,7 +1173,7 @@ static int getsockaddrarg(PySocketSockObject *s, PyObject *args, - struct sockaddr **addr_ret, int *len_ret) + struct sockaddr *addr_ret, int *len_ret) { switch (s->sock_family) { @@ -1184,9 +1183,10 @@ struct sockaddr_un* addr; char *path; int len; - addr = (struct sockaddr_un*)&(s->sock_addr).un; if (!PyArg_Parse(args, "t#", &path, &len)) return 0; + + addr = (struct sockaddr_un*)addr_ret; #ifdef linux if (len > 0 && path[0] == 0) { /* Linux abstract namespace extension */ @@ -1209,7 +1209,6 @@ } addr->sun_family = s->sock_family; memcpy(addr->sun_path, path, len); - *addr_ret = (struct sockaddr *) addr; #if defined(PYOS_OS2) *len_ret = sizeof(*addr); #else @@ -1224,7 +1223,7 @@ { struct sockaddr_nl* addr; int pid, groups; - addr = (struct sockaddr_nl *)&(s->sock_addr).nl; + addr = (struct sockaddr_nl *)addr_ret; if (!PyTuple_Check(args)) { PyErr_Format( PyExc_TypeError, @@ -1238,7 +1237,6 @@ addr->nl_family = AF_NETLINK; addr->nl_pid = pid; addr->nl_groups = groups; - *addr_ret = (struct sockaddr *) addr; *len_ret = sizeof(*addr); return 1; } @@ -1249,7 +1247,6 @@ struct sockaddr_in* addr; char *host; int port, result; - addr=(struct sockaddr_in*)&(s->sock_addr).in; if (!PyTuple_Check(args)) { PyErr_Format( PyExc_TypeError, @@ -1261,6 +1258,7 @@ if (!PyArg_ParseTuple(args, "eti:getsockaddrarg", "idna", &host, &port)) return 0; + addr=(struct sockaddr_in*)addr_ret; result = setipaddr(host, (struct sockaddr *)addr, sizeof(*addr), AF_INET); PyMem_Free(host); @@ -1268,7 +1266,6 @@ return 0; addr->sin_family = AF_INET; addr->sin_port = htons((short)port); - *addr_ret = (struct sockaddr *) addr; *len_ret = sizeof *addr; return 1; } @@ -1279,7 +1276,6 @@ struct sockaddr_in6* addr; char *host; int port, flowinfo, scope_id, result; - addr = (struct sockaddr_in6*)&(s->sock_addr).in6; flowinfo = scope_id = 0; if (!PyTuple_Check(args)) { PyErr_Format( @@ -1294,6 +1290,7 @@ &scope_id)) { return 0; } + addr = (struct sockaddr_in6*)addr_ret; result = setipaddr(host, (struct sockaddr *)addr, sizeof(*addr), AF_INET6); PyMem_Free(host); @@ -1303,7 +1300,6 @@ addr->sin6_port = htons((short)port); addr->sin6_flowinfo = flowinfo; addr->sin6_scope_id = scope_id; - *addr_ret = (struct sockaddr *) addr; *len_ret = sizeof *addr; return 1; } @@ -1315,9 +1311,10 @@ switch (s->sock_proto) { case BTPROTO_L2CAP: { - struct sockaddr_l2 *addr = (struct sockaddr_l2 *) _BT_SOCKADDR_MEMB(s, l2); + struct sockaddr_l2 *addr; char *straddr; + addr = (struct sockaddr_l2 *)addr_ret; _BT_L2_MEMB(addr, family) = AF_BLUETOOTH; if (!PyArg_ParseTuple(args, "si", &straddr, &_BT_L2_MEMB(addr, psm))) { @@ -1328,15 +1325,15 @@ if (setbdaddr(straddr, &_BT_L2_MEMB(addr, bdaddr)) < 0) return 0; - *addr_ret = (struct sockaddr *) addr; *len_ret = sizeof *addr; return 1; } case BTPROTO_RFCOMM: { - struct sockaddr_rc *addr = (struct sockaddr_rc *) _BT_SOCKADDR_MEMB(s, rc); + struct sockaddr_rc *addr; char *straddr; + addr = (struct sockaddr_rc *)addr_ret; _BT_RC_MEMB(addr, family) = AF_BLUETOOTH; if (!PyArg_ParseTuple(args, "si", &straddr, &_BT_RC_MEMB(addr, channel))) { @@ -1347,16 +1344,16 @@ if (setbdaddr(straddr, &_BT_RC_MEMB(addr, bdaddr)) < 0) return 0; - *addr_ret = (struct sockaddr *) addr; *len_ret = sizeof *addr; return 1; } #if !defined(__FreeBSD__) case BTPROTO_SCO: { - struct sockaddr_sco *addr = (struct sockaddr_sco *) _BT_SOCKADDR_MEMB(s, sco); + struct sockaddr_sco *addr; char *straddr; + addr = (struct sockaddr_sco *)addr_ret; _BT_SCO_MEMB(addr, family) = AF_BLUETOOTH; straddr = PyString_AsString(args); if (straddr == NULL) { @@ -1367,7 +1364,6 @@ if (setbdaddr(straddr, &_BT_SCO_MEMB(addr, bdaddr)) < 0) return 0; - *addr_ret = (struct sockaddr *) addr; *len_ret = sizeof *addr; return 1; } @@ -1409,22 +1405,21 @@ s->errorhandler(); return 0; } - addr = &(s->sock_addr.ll); - addr->sll_family = AF_PACKET; - addr->sll_protocol = htons((short)protoNumber); - addr->sll_ifindex = ifr.ifr_ifindex; - addr->sll_pkttype = pkttype; - addr->sll_hatype = hatype; if (halen > 8) { PyErr_SetString(PyExc_ValueError, "Hardware address must be 8 bytes or less"); return 0; } + addr = (struct sockaddr_ll*)addr_ret; + addr->sll_family = AF_PACKET; + addr->sll_protocol = htons((short)protoNumber); + addr->sll_ifindex = ifr.ifr_ifindex; + addr->sll_pkttype = pkttype; + addr->sll_hatype = hatype; if (halen != 0) { memcpy(&addr->sll_addr, haddr, halen); } addr->sll_halen = halen; - *addr_ret = (struct sockaddr *) addr; *len_ret = sizeof *addr; return 1; } @@ -1551,8 +1546,7 @@ Py_BEGIN_ALLOW_THREADS timeout = internal_select(s, 0); if (!timeout) - newfd = accept(s->sock_fd, (struct sockaddr *) &addrbuf, - &addrlen); + newfd = accept(s->sock_fd, SAS2SA(&addrbuf), &addrlen); Py_END_ALLOW_THREADS if (timeout == 1) { @@ -1578,7 +1572,7 @@ SOCKETCLOSE(newfd); goto finally; } - addr = makesockaddr(s->sock_fd, (struct sockaddr *) &addrbuf, + addr = makesockaddr(s->sock_fd, SAS2SA(&addrbuf), addrlen, s->sock_proto); if (addr == NULL) goto finally; @@ -1819,14 +1813,14 @@ static PyObject * sock_bind(PySocketSockObject *s, PyObject *addro) { - struct sockaddr *addr; + sock_addr_t addrbuf; int addrlen; int res; - if (!getsockaddrarg(s, addro, &addr, &addrlen)) + if (!getsockaddrarg(s, addro, SAS2SA(&addrbuf), &addrlen)) return NULL; Py_BEGIN_ALLOW_THREADS - res = bind(s->sock_fd, addr, addrlen); + res = bind(s->sock_fd, SAS2SA(&addrbuf), addrlen); Py_END_ALLOW_THREADS if (res < 0) return s->errorhandler(); @@ -1952,16 +1946,16 @@ static PyObject * sock_connect(PySocketSockObject *s, PyObject *addro) { - struct sockaddr *addr; + sock_addr_t addrbuf; int addrlen; int res; int timeout; - if (!getsockaddrarg(s, addro, &addr, &addrlen)) + if (!getsockaddrarg(s, addro, SAS2SA(&addrbuf), &addrlen)) return NULL; Py_BEGIN_ALLOW_THREADS - res = internal_connect(s, addr, addrlen, &timeout); + res = internal_connect(s, SAS2SA(&addrbuf), addrlen, &timeout); Py_END_ALLOW_THREADS if (timeout == 1) { @@ -1986,16 +1980,16 @@ static PyObject * sock_connect_ex(PySocketSockObject *s, PyObject *addro) { - struct sockaddr *addr; + sock_addr_t addrbuf; int addrlen; int res; int timeout; - if (!getsockaddrarg(s, addro, &addr, &addrlen)) + if (!getsockaddrarg(s, addro, SAS2SA(&addrbuf), &addrlen)) return NULL; Py_BEGIN_ALLOW_THREADS - res = internal_connect(s, addr, addrlen, &timeout); + res = internal_connect(s, SAS2SA(&addrbuf), addrlen, &timeout); Py_END_ALLOW_THREADS /* Signals are not errors (though they may raise exceptions). Adapted @@ -2075,11 +2069,11 @@ return NULL; memset(&addrbuf, 0, addrlen); Py_BEGIN_ALLOW_THREADS - res = getsockname(s->sock_fd, (struct sockaddr *) &addrbuf, &addrlen); + res = getsockname(s->sock_fd, SAS2SA(&addrbuf), &addrlen); Py_END_ALLOW_THREADS if (res < 0) return s->errorhandler(); - return makesockaddr(s->sock_fd, (struct sockaddr *) &addrbuf, addrlen, + return makesockaddr(s->sock_fd, SAS2SA(&addrbuf), addrlen, s->sock_proto); } @@ -2104,11 +2098,11 @@ return NULL; memset(&addrbuf, 0, addrlen); Py_BEGIN_ALLOW_THREADS - res = getpeername(s->sock_fd, (struct sockaddr *) &addrbuf, &addrlen); + res = getpeername(s->sock_fd, SAS2SA(&addrbuf), &addrlen); Py_END_ALLOW_THREADS if (res < 0) return s->errorhandler(); - return makesockaddr(s->sock_fd, (struct sockaddr *) &addrbuf, addrlen, + return makesockaddr(s->sock_fd, SAS2SA(&addrbuf), addrlen, s->sock_proto); } @@ -2443,14 +2437,14 @@ #ifndef MS_WINDOWS #if defined(PYOS_OS2) && !defined(PYCC_GCC) n = recvfrom(s->sock_fd, cbuf, len, flags, - (struct sockaddr *) &addrbuf, &addrlen); + SAS2SA(&addrbuf), &addrlen); #else n = recvfrom(s->sock_fd, cbuf, len, flags, (void *) &addrbuf, &addrlen); #endif #else n = recvfrom(s->sock_fd, cbuf, len, flags, - (struct sockaddr *) &addrbuf, &addrlen); + SAS2SA(&addrbuf), &addrlen); #endif } Py_END_ALLOW_THREADS @@ -2464,7 +2458,7 @@ return -1; } - if (!(*addr = makesockaddr(s->sock_fd, (struct sockaddr *) &addrbuf, + if (!(*addr = makesockaddr(s->sock_fd, SAS2SA(&addrbuf), addrlen, s->sock_proto))) return -1; @@ -2664,7 +2658,7 @@ { PyObject *addro; char *buf; - struct sockaddr *addr; + sock_addr_t addrbuf; int addrlen, len, n = -1, flags, timeout; flags = 0; @@ -2675,16 +2669,16 @@ return NULL; } - if (!getsockaddrarg(s, addro, &addr, &addrlen)) - return NULL; - if (!IS_SELECTABLE(s)) return select_error(); + if (!getsockaddrarg(s, addro, SAS2SA(&addrbuf), &addrlen)) + return NULL; + Py_BEGIN_ALLOW_THREADS timeout = internal_select(s, 1); if (!timeout) - n = sendto(s->sock_fd, buf, len, flags, addr, addrlen); + n = sendto(s->sock_fd, buf, len, flags, SAS2SA(&addrbuf), addrlen); Py_END_ALLOW_THREADS if (timeout == 1) { @@ -2973,10 +2967,9 @@ if (!PyArg_ParseTuple(args, "s:gethostbyname", &name)) return NULL; - if (setipaddr(name, (struct sockaddr *)&addrbuf, sizeof(addrbuf), AF_INET) < 0) + if (setipaddr(name, SAS2SA(&addrbuf), sizeof(addrbuf), AF_INET) < 0) return NULL; - return makeipaddr((struct sockaddr *)&addrbuf, - sizeof(struct sockaddr_in)); + return makeipaddr(SAS2SA(&addrbuf), sizeof(struct sockaddr_in)); } PyDoc_STRVAR(gethostbyname_doc, Modified: python/branches/release25-maint/Modules/socketmodule.h ============================================================================== --- python/branches/release25-maint/Modules/socketmodule.h (original) +++ python/branches/release25-maint/Modules/socketmodule.h Sun Dec 3 12:24:00 2006 @@ -114,7 +114,6 @@ int sock_family; /* Address family, e.g., AF_INET */ int sock_type; /* Socket type, e.g., SOCK_STREAM */ int sock_proto; /* Protocol type, usually 0 */ - sock_addr_t sock_addr; /* Socket address */ PyObject *(*errorhandler)(void); /* Error handler; checks errno, returns NULL and sets a Python exception */ From python-checkins at python.org Sun Dec 3 13:01:54 2006 From: python-checkins at python.org (martin.v.loewis) Date: Sun, 3 Dec 2006 13:01:54 +0100 (CET) Subject: [Python-checkins] r52908 - in python/trunk: Doc/lib/libcfgparser.tex Lib/ConfigParser.py Lib/test/test_cfgparser.py Misc/NEWS Message-ID: <20061203120154.B9BEA1E4009@bag.python.org> Author: martin.v.loewis Date: Sun Dec 3 13:01:53 2006 New Revision: 52908 Modified: python/trunk/Doc/lib/libcfgparser.tex python/trunk/Lib/ConfigParser.py python/trunk/Lib/test/test_cfgparser.py python/trunk/Misc/NEWS Log: Patch #1371075: Make ConfigParser accept optional dict type for ordering, sorting, etc. Modified: python/trunk/Doc/lib/libcfgparser.tex ============================================================================== --- python/trunk/Doc/lib/libcfgparser.tex (original) +++ python/trunk/Doc/lib/libcfgparser.tex Sun Dec 3 13:01:53 2006 @@ -48,11 +48,20 @@ may be passed into the \method{get()} method which will override all others. -\begin{classdesc}{RawConfigParser}{\optional{defaults}} +Sections are normally stored in a builtin dictionary. An alternative +dictionary type can be passed to the \class{ConfigParser} constructor. +For example, if a dictionary type is passed that sorts is keys, +the sections will be sorted on write-back, as will be the keys within +each section. + +\begin{classdesc}{RawConfigParser}{\optional{defaults\optional{, dict_type}}} The basic configuration object. When \var{defaults} is given, it is -initialized into the dictionary of intrinsic defaults. This class -does not support the magical interpolation behavior. +initialized into the dictionary of intrinsic defaults. When \var{dict_type} +is given, it will be used to create the dictionary objects for the list +of sections, for the options within a section, and for the default values. +This class does not support the magical interpolation behavior. \versionadded{2.3} +\versionchanged{\var{dict_type} was added}[2.6] \end{classdesc} \begin{classdesc}{ConfigParser}{\optional{defaults}} Modified: python/trunk/Lib/ConfigParser.py ============================================================================== --- python/trunk/Lib/ConfigParser.py (original) +++ python/trunk/Lib/ConfigParser.py Sun Dec 3 13:01:53 2006 @@ -199,11 +199,11 @@ self.line = line - class RawConfigParser: - def __init__(self, defaults=None): - self._sections = {} - self._defaults = {} + def __init__(self, defaults=None, dict_type=dict): + self._dict = dict_type + self._sections = self._dict() + self._defaults = self._dict() if defaults: for key, value in defaults.items(): self._defaults[self.optionxform(key)] = value @@ -224,7 +224,7 @@ """ if section in self._sections: raise DuplicateSectionError(section) - self._sections[section] = {} + self._sections[section] = self._dict() def has_section(self, section): """Indicate whether the named section is present in the configuration. @@ -307,7 +307,7 @@ except KeyError: if section != DEFAULTSECT: raise NoSectionError(section) - d2 = {} + d2 = self._dict() d = self._defaults.copy() d.update(d2) if "__name__" in d: @@ -453,7 +453,8 @@ elif sectname == DEFAULTSECT: cursect = self._defaults else: - cursect = {'__name__': sectname} + cursect = self._dict() + cursect['__name__'] = sectname self._sections[sectname] = cursect # So sections can't start with a continuation line optname = None Modified: python/trunk/Lib/test/test_cfgparser.py ============================================================================== --- python/trunk/Lib/test/test_cfgparser.py (original) +++ python/trunk/Lib/test/test_cfgparser.py Sun Dec 3 13:01:53 2006 @@ -1,9 +1,29 @@ import ConfigParser import StringIO import unittest +import UserDict from test import test_support +class SortedDict(UserDict.UserDict): + def items(self): + result = self.data.items() + result.sort() + return result + + def keys(self): + result = self.data.keys() + result.sort() + return result + + def values(self): + result = self.items() + return [i[1] for i in values] + + def iteritems(self): return iter(self.items()) + def iterkeys(self): return iter(self.keys()) + __iter__ = iterkeys + def itervalues(self): return iter(self.values()) class TestCaseBase(unittest.TestCase): def newconfig(self, defaults=None): @@ -414,12 +434,36 @@ self.assertRaises(TypeError, cf.set, "sect", "option2", 1.0) self.assertRaises(TypeError, cf.set, "sect", "option2", object()) +class SortedTestCase(RawConfigParserTestCase): + def newconfig(self, defaults=None): + self.cf = self.config_class(defaults=defaults, dict_type=SortedDict) + return self.cf + + def test_sorted(self): + self.fromstring("[b]\n" + "o4=1\n" + "o3=2\n" + "o2=3\n" + "o1=4\n" + "[a]\n" + "k=v\n") + output = StringIO.StringIO() + self.cf.write(output) + self.assertEquals(output.getvalue(), + "[a]\n" + "k = v\n\n" + "[b]\n" + "o1 = 4\n" + "o2 = 3\n" + "o3 = 2\n" + "o4 = 1\n\n") def test_main(): test_support.run_unittest( ConfigParserTestCase, RawConfigParserTestCase, - SafeConfigParserTestCase + SafeConfigParserTestCase, + SortedTestCase ) if __name__ == "__main__": Modified: python/trunk/Misc/NEWS ============================================================================== --- python/trunk/Misc/NEWS (original) +++ python/trunk/Misc/NEWS Sun Dec 3 13:01:53 2006 @@ -101,6 +101,9 @@ Library ------- +- Patch #1371075: Make ConfigParser accept optional dict type + for ordering, sorting, etc. + - Bug #1563807: _ctypes built on AIX fails with ld ffi error. - Bug #1598620: A ctypes Structure cannot contain itself. From buildbot at python.org Sun Dec 3 14:24:17 2006 From: buildbot at python.org (buildbot at python.org) Date: Sun, 03 Dec 2006 13:24:17 +0000 Subject: [Python-checkins] buildbot warnings in x86 Ubuntu edgy (icc) 2.5 Message-ID: <20061203132417.EE0281E4009@bag.python.org> The Buildbot has detected a new failure of x86 Ubuntu edgy (icc) 2.5. Full details are available at: http://www.python.org/dev/buildbot/all/x86%2520Ubuntu%2520edgy%2520%2528icc%2529%25202.5/builds/118 Buildbot URL: http://www.python.org/dev/buildbot/all/ Build Reason: Build Source Stamp: [branch branches/release25-maint] HEAD Blamelist: martin.v.loewis Build had warnings: warnings failed slave lost sincerely, -The Buildbot From buildbot at python.org Sun Dec 3 14:25:26 2006 From: buildbot at python.org (buildbot at python.org) Date: Sun, 03 Dec 2006 13:25:26 +0000 Subject: [Python-checkins] buildbot warnings in hppa Ubuntu dapper trunk Message-ID: <20061203132526.66F241E4009@bag.python.org> The Buildbot has detected a new failure of hppa Ubuntu dapper trunk. Full details are available at: http://www.python.org/dev/buildbot/all/hppa%2520Ubuntu%2520dapper%2520trunk/builds/237 Buildbot URL: http://www.python.org/dev/buildbot/all/ Build Reason: Build Source Stamp: [branch trunk] HEAD Blamelist: martin.v.loewis Build had warnings: warnings test Excerpt from the test logfile: sincerely, -The Buildbot From buildbot at python.org Sun Dec 3 16:46:12 2006 From: buildbot at python.org (buildbot at python.org) Date: Sun, 03 Dec 2006 15:46:12 +0000 Subject: [Python-checkins] buildbot warnings in alpha Debian trunk Message-ID: <20061203154612.50A801E4011@bag.python.org> The Buildbot has detected a new failure of alpha Debian trunk. Full details are available at: http://www.python.org/dev/buildbot/all/alpha%2520Debian%2520trunk/builds/0 Buildbot URL: http://www.python.org/dev/buildbot/all/ Build Reason: Build Source Stamp: [branch trunk] HEAD Blamelist: andrew.kuchling,armin.rigo,georg.brandl,george.yoshida,guido.van.rossum,martin.v.loewis,michael.hudson,neal.norwitz,phillip.eby,raymond.hettinger,ronald.oussoren,skip.montanaro,thomas.heller,tim.peters,vinay.sajip,walter.doerwald Build had warnings: warnings test Excerpt from the test logfile: sincerely, -The Buildbot From buildbot at python.org Sun Dec 3 17:06:16 2006 From: buildbot at python.org (buildbot at python.org) Date: Sun, 03 Dec 2006 16:06:16 +0000 Subject: [Python-checkins] buildbot warnings in x86 XP trunk Message-ID: <20061203160616.39F8C1E4016@bag.python.org> The Buildbot has detected a new failure of x86 XP trunk. Full details are available at: http://www.python.org/dev/buildbot/all/x86%2520XP%2520trunk/builds/79 Buildbot URL: http://www.python.org/dev/buildbot/all/ Build Reason: Build Source Stamp: [branch trunk] HEAD Blamelist: martin.v.loewis Build had warnings: warnings failed slave lost sincerely, -The Buildbot From python-checkins at python.org Sun Dec 3 18:13:55 2006 From: python-checkins at python.org (matthias.klose) Date: Sun, 3 Dec 2006 18:13:55 +0100 (CET) Subject: [Python-checkins] r52909 - in python/branches/release25-maint: Lib/distutils/command/build_ext.py Misc/NEWS Message-ID: <20061203171355.1EBFE1E4011@bag.python.org> Author: matthias.klose Date: Sun Dec 3 18:13:54 2006 New Revision: 52909 Modified: python/branches/release25-maint/Lib/distutils/command/build_ext.py python/branches/release25-maint/Misc/NEWS Log: - Fix build failure on kfreebsd and on the hurd. Modified: python/branches/release25-maint/Lib/distutils/command/build_ext.py ============================================================================== --- python/branches/release25-maint/Lib/distutils/command/build_ext.py (original) +++ python/branches/release25-maint/Lib/distutils/command/build_ext.py Sun Dec 3 18:13:54 2006 @@ -186,7 +186,7 @@ # for extensions under Cygwin and AtheOS Python's library directory must be # appended to library_dirs if sys.platform[:6] == 'cygwin' or sys.platform[:6] == 'atheos' or \ - (sys.platform.startswith('linux') and + ((sys.platform.startswith('linux') or sys.platform.startswith('gnu')) and sysconfig.get_config_var('Py_ENABLE_SHARED')): if string.find(sys.executable, sys.exec_prefix) != -1: # building third party extensions Modified: python/branches/release25-maint/Misc/NEWS ============================================================================== --- python/branches/release25-maint/Misc/NEWS (original) +++ python/branches/release25-maint/Misc/NEWS Sun Dec 3 18:13:54 2006 @@ -214,6 +214,8 @@ - Patch #1576954: Update VC6 build directory; remove redundant files in VC7. +- Fix build failure on kfreebsd and on the hurd. + Windows ------- From python-checkins at python.org Sun Dec 3 18:16:42 2006 From: python-checkins at python.org (matthias.klose) Date: Sun, 3 Dec 2006 18:16:42 +0100 (CET) Subject: [Python-checkins] r52910 - in python/trunk: Lib/distutils/command/build_ext.py Misc/NEWS Message-ID: <20061203171642.2835C1E4011@bag.python.org> Author: matthias.klose Date: Sun Dec 3 18:16:41 2006 New Revision: 52910 Modified: python/trunk/Lib/distutils/command/build_ext.py python/trunk/Misc/NEWS Log: - Fix build failure on kfreebsd and on the hurd. Modified: python/trunk/Lib/distutils/command/build_ext.py ============================================================================== --- python/trunk/Lib/distutils/command/build_ext.py (original) +++ python/trunk/Lib/distutils/command/build_ext.py Sun Dec 3 18:16:41 2006 @@ -186,7 +186,7 @@ # for extensions under Cygwin and AtheOS Python's library directory must be # appended to library_dirs if sys.platform[:6] == 'cygwin' or sys.platform[:6] == 'atheos' or \ - (sys.platform.startswith('linux') and + ((sys.platform.startswith('linux') or sys.platform.startswith('gnu')) and sysconfig.get_config_var('Py_ENABLE_SHARED')): if string.find(sys.executable, sys.exec_prefix) != -1: # building third party extensions Modified: python/trunk/Misc/NEWS ============================================================================== --- python/trunk/Misc/NEWS (original) +++ python/trunk/Misc/NEWS Sun Dec 3 18:16:41 2006 @@ -351,6 +351,8 @@ - Patch #1540470, for OpenBSD 4.0. +- Fix build failure on kfreebsd and on the hurd. + C API ----- From buildbot at python.org Sun Dec 3 18:33:32 2006 From: buildbot at python.org (buildbot at python.org) Date: Sun, 03 Dec 2006 17:33:32 +0000 Subject: [Python-checkins] buildbot warnings in alpha Debian 2.5 Message-ID: <20061203173332.6E3D81E4011@bag.python.org> The Buildbot has detected a new failure of alpha Debian 2.5. Full details are available at: http://www.python.org/dev/buildbot/all/alpha%2520Debian%25202.5/builds/1 Buildbot URL: http://www.python.org/dev/buildbot/all/ Build Reason: Build Source Stamp: [branch branches/release25-maint] HEAD Blamelist: martin.v.loewis Build had warnings: warnings test Excerpt from the test logfile: sincerely, -The Buildbot From buildbot at python.org Sun Dec 3 20:52:21 2006 From: buildbot at python.org (buildbot at python.org) Date: Sun, 03 Dec 2006 19:52:21 +0000 Subject: [Python-checkins] buildbot warnings in x86 Ubuntu edgy (icc) trunk Message-ID: <20061203195221.2B5BA1E4011@bag.python.org> The Buildbot has detected a new failure of x86 Ubuntu edgy (icc) trunk. Full details are available at: http://www.python.org/dev/buildbot/all/x86%2520Ubuntu%2520edgy%2520%2528icc%2529%2520trunk/builds/1099 Buildbot URL: http://www.python.org/dev/buildbot/all/ Build Reason: Build Source Stamp: [branch trunk] HEAD Blamelist: matthias.klose Build had warnings: warnings test Excerpt from the test logfile: 1 test failed: test_timeout ====================================================================== FAIL: testConnectTimeout (test.test_timeout.TimeoutTestCase) ---------------------------------------------------------------------- Traceback (most recent call last): File "/home/buildbot/Buildbot/trunk.baxter-ubuntu/build/Lib/test/test_timeout.py", line 128, in testConnectTimeout %(_delta, self.fuzz, _timeout)) AssertionError: timeout (3.58903) is more than 2 seconds more than expected (0.001) sincerely, -The Buildbot From python-checkins at python.org Sun Dec 3 21:24:05 2006 From: python-checkins at python.org (erik.forsberg) Date: Sun, 3 Dec 2006 21:24:05 +0100 (CET) Subject: [Python-checkins] r52911 - tracker/importer/BeautifulSoup.py tracker/importer/sfxml2roundup.py tracker/importer/sfxmlhandlers.py Message-ID: <20061203202405.B83B11E4011@bag.python.org> Author: erik.forsberg Date: Sun Dec 3 21:24:04 2006 New Revision: 52911 Added: tracker/importer/BeautifulSoup.py tracker/importer/sfxml2roundup.py (contents, props changed) tracker/importer/sfxmlhandlers.py Log: New importer using the backup xml file from sourceforge instead of effbot's sourceforge scraper. BeatifulSoup.py copied from the sourceforge scraper. Importer has support for most of the fields in the python-dev roundup schema, with one notable exception in the status and resolution handling, which need to be further researched given the large number of different more or less invalid combinations of status/resolution. See http://psf.upfronthosting.co.za/roundup/meta/issue55 for details. Added: tracker/importer/BeautifulSoup.py ============================================================================== --- (empty file) +++ tracker/importer/BeautifulSoup.py Sun Dec 3 21:24:04 2006 @@ -0,0 +1,1812 @@ +"""Beautiful Soup +Elixir and Tonic +"The Screen-Scraper's Friend" +http://www.crummy.com/software/BeautifulSoup/ + +Beautiful Soup parses a (possibly invalid) XML or HTML document into a +tree representation. It provides methods and Pythonic idioms that make +it easy to navigate, search, and modify the tree. + +A well-structured XML/HTML document yields a well-behaved data +structure. An ill-structured XML/HTML document yields a +correspondingly ill-behaved data structure. If your document is only +locally well-structured, you can use this library to find and process +the well-structured part of it. + +Beautiful Soup works with Python 2.2 and up. It has no external +dependencies, but you'll have more success at converting data to UTF-8 +if you also install these three packages: + +* chardet, for auto-detecting character encodings + http://chardet.feedparser.org/ +* cjkcodecs and iconv_codec, which add more encodings to the ones supported + by stock Python. + http://cjkpython.i18n.org/ + +Beautiful Soup defines classes for two main parsing strategies: + + * BeautifulStoneSoup, for parsing XML, SGML, or your domain-specific + language that kind of looks like XML. + + * BeautifulSoup, for parsing run-of-the-mill HTML code, be it valid + or invalid. This class has web browser-like heuristics for + obtaining a sensible parse tree in the face of common HTML errors. + +Beautiful Soup also defines a class (UnicodeDammit) for autodetecting +the encoding of an HTML or XML document, and converting it to +Unicode. Much of this code is taken from Mark Pilgrim's Universal Feed +Parser. + +For more than you ever wanted to know about Beautiful Soup, see the +documentation: +http://www.crummy.com/software/BeautifulSoup/documentation.html +""" +from __future__ import generators + +__author__ = "Leonard Richardson (crummy.com)" +__contributors__ = ["Sam Ruby (intertwingly.net)", + "the unwitting Mark Pilgrim (diveintomark.org)", + "http://www.crummy.com/software/BeautifulSoup/AUTHORS.html"] +__version__ = "3.0.3" +__copyright__ = "Copyright (c) 2004-2006 Leonard Richardson" +__license__ = "PSF" + +from sgmllib import SGMLParser, SGMLParseError +import codecs +import types +import re +import sgmllib +from htmlentitydefs import name2codepoint + +# This RE makes Beautiful Soup able to parse XML with namespaces. +sgmllib.tagfind = re.compile('[a-zA-Z][-_.:a-zA-Z0-9]*') + +# This RE makes Beautiful Soup capable of recognizing numeric character +# references that use hexadecimal. +sgmllib.charref = re.compile('&#(\d+|x[0-9a-fA-F]+);') + +DEFAULT_OUTPUT_ENCODING = "utf-8" + +# First, the classes that represent markup elements. + +class PageElement: + """Contains the navigational information for some part of the page + (either a tag or a piece of text)""" + + def setup(self, parent=None, previous=None): + """Sets up the initial relations between this element and + other elements.""" + self.parent = parent + self.previous = previous + self.next = None + self.previousSibling = None + self.nextSibling = None + if self.parent and self.parent.contents: + self.previousSibling = self.parent.contents[-1] + self.previousSibling.nextSibling = self + + def replaceWith(self, replaceWith): + oldParent = self.parent + myIndex = self.parent.contents.index(self) + if hasattr(replaceWith, 'parent') and replaceWith.parent == self.parent: + # We're replacing this element with one of its siblings. + index = self.parent.contents.index(replaceWith) + if index and index < myIndex: + # Furthermore, it comes before this element. That + # means that when we extract it, the index of this + # element will change. + myIndex = myIndex - 1 + self.extract() + oldParent.insert(myIndex, replaceWith) + + def extract(self): + """Destructively rips this element out of the tree.""" + if self.parent: + try: + self.parent.contents.remove(self) + except ValueError: + pass + + #Find the two elements that would be next to each other if + #this element (and any children) hadn't been parsed. Connect + #the two. + lastChild = self._lastRecursiveChild() + nextElement = lastChild.next + + if self.previous: + self.previous.next = nextElement + if nextElement: + nextElement.previous = self.previous + self.previous = None + lastChild.next = None + + self.parent = None + if self.previousSibling: + self.previousSibling.nextSibling = self.nextSibling + if self.nextSibling: + self.nextSibling.previousSibling = self.previousSibling + self.previousSibling = self.nextSibling = None + + def _lastRecursiveChild(self): + "Finds the last element beneath this object to be parsed." + lastChild = self + while hasattr(lastChild, 'contents') and lastChild.contents: + lastChild = lastChild.contents[-1] + return lastChild + + def insert(self, position, newChild): + if (isinstance(newChild, basestring) + or isinstance(newChild, unicode)) \ + and not isinstance(newChild, NavigableString): + newChild = NavigableString(newChild) + + position = min(position, len(self.contents)) + if hasattr(newChild, 'parent') and newChild.parent != None: + # We're 'inserting' an element that's already one + # of this object's children. + if newChild.parent == self: + index = self.find(newChild) + if index and index < position: + # Furthermore we're moving it further down the + # list of this object's children. That means that + # when we extract this element, our target index + # will jump down one. + position = position - 1 + newChild.extract() + + newChild.parent = self + previousChild = None + if position == 0: + newChild.previousSibling = None + newChild.previous = self + else: + previousChild = self.contents[position-1] + newChild.previousSibling = previousChild + newChild.previousSibling.nextSibling = newChild + newChild.previous = previousChild._lastRecursiveChild() + if newChild.previous: + newChild.previous.next = newChild + + newChildsLastElement = newChild._lastRecursiveChild() + + if position >= len(self.contents): + newChild.nextSibling = None + + parent = self + parentsNextSibling = None + while not parentsNextSibling: + parentsNextSibling = parent.nextSibling + parent = parent.parent + if not parent: # This is the last element in the document. + break + if parentsNextSibling: + newChildsLastElement.next = parentsNextSibling + else: + newChildsLastElement.next = None + else: + nextChild = self.contents[position] + newChild.nextSibling = nextChild + if newChild.nextSibling: + newChild.nextSibling.previousSibling = newChild + newChildsLastElement.next = nextChild + + if newChildsLastElement.next: + newChildsLastElement.next.previous = newChildsLastElement + self.contents.insert(position, newChild) + + def findNext(self, name=None, attrs={}, text=None, **kwargs): + """Returns the first item that matches the given criteria and + appears after this Tag in the document.""" + return self._findOne(self.findAllNext, name, attrs, text, **kwargs) + + def findAllNext(self, name=None, attrs={}, text=None, limit=None, + **kwargs): + """Returns all items that match the given criteria and appear + before after Tag in the document.""" + return self._findAll(name, attrs, text, limit, self.nextGenerator) + + def findNextSibling(self, name=None, attrs={}, text=None, **kwargs): + """Returns the closest sibling to this Tag that matches the + given criteria and appears after this Tag in the document.""" + return self._findOne(self.findNextSiblings, name, attrs, text, + **kwargs) + + def findNextSiblings(self, name=None, attrs={}, text=None, limit=None, + **kwargs): + """Returns the siblings of this Tag that match the given + criteria and appear after this Tag in the document.""" + return self._findAll(name, attrs, text, limit, + self.nextSiblingGenerator, **kwargs) + fetchNextSiblings = findNextSiblings # Compatibility with pre-3.x + + def findPrevious(self, name=None, attrs={}, text=None, **kwargs): + """Returns the first item that matches the given criteria and + appears before this Tag in the document.""" + return self._findOne(self.findAllPrevious, name, attrs, text, **kwargs) + + def findAllPrevious(self, name=None, attrs={}, text=None, limit=None, + **kwargs): + """Returns all items that match the given criteria and appear + before this Tag in the document.""" + return self._findAll(name, attrs, text, limit, self.previousGenerator, + **kwargs) + fetchPrevious = findAllPrevious # Compatibility with pre-3.x + + def findPreviousSibling(self, name=None, attrs={}, text=None, **kwargs): + """Returns the closest sibling to this Tag that matches the + given criteria and appears before this Tag in the document.""" + return self._findOne(self.findPreviousSiblings, name, attrs, text, + **kwargs) + + def findPreviousSiblings(self, name=None, attrs={}, text=None, + limit=None, **kwargs): + """Returns the siblings of this Tag that match the given + criteria and appear before this Tag in the document.""" + return self._findAll(name, attrs, text, limit, + self.previousSiblingGenerator, **kwargs) + fetchPreviousSiblings = findPreviousSiblings # Compatibility with pre-3.x + + def findParent(self, name=None, attrs={}, **kwargs): + """Returns the closest parent of this Tag that matches the given + criteria.""" + # NOTE: We can't use _findOne because findParents takes a different + # set of arguments. + r = None + l = self.findParents(name, attrs, 1) + if l: + r = l[0] + return r + + def findParents(self, name=None, attrs={}, limit=None, **kwargs): + """Returns the parents of this Tag that match the given + criteria.""" + + return self._findAll(name, attrs, None, limit, self.parentGenerator, + **kwargs) + fetchParents = findParents # Compatibility with pre-3.x + + #These methods do the real heavy lifting. + + def _findOne(self, method, name, attrs, text, **kwargs): + r = None + l = method(name, attrs, text, 1, **kwargs) + if l: + r = l[0] + return r + + def _findAll(self, name, attrs, text, limit, generator, **kwargs): + "Iterates over a generator looking for things that match." + + if isinstance(name, SoupStrainer): + strainer = name + else: + # Build a SoupStrainer + strainer = SoupStrainer(name, attrs, text, **kwargs) + results = ResultSet(strainer) + g = generator() + while True: + try: + i = g.next() + except StopIteration: + break + if i: + found = strainer.search(i) + if found: + results.append(found) + if limit and len(results) >= limit: + break + return results + + #These Generators can be used to navigate starting from both + #NavigableStrings and Tags. + def nextGenerator(self): + i = self + while i: + i = i.next + yield i + + def nextSiblingGenerator(self): + i = self + while i: + i = i.nextSibling + yield i + + def previousGenerator(self): + i = self + while i: + i = i.previous + yield i + + def previousSiblingGenerator(self): + i = self + while i: + i = i.previousSibling + yield i + + def parentGenerator(self): + i = self + while i: + i = i.parent + yield i + + # Utility methods + def substituteEncoding(self, str, encoding=None): + encoding = encoding or "utf-8" + return str.replace("%SOUP-ENCODING%", encoding) + + def toEncoding(self, s, encoding=None): + """Encodes an object to a string in some encoding, or to Unicode. + .""" + if isinstance(s, unicode): + if encoding: + s = s.encode(encoding) + elif isinstance(s, str): + if encoding: + s = s.encode(encoding) + else: + s = unicode(s) + else: + if encoding: + s = self.toEncoding(str(s), encoding) + else: + s = unicode(s) + return s + +class NavigableString(unicode, PageElement): + + def __getattr__(self, attr): + """text.string gives you text. This is for backwards + compatibility for Navigable*String, but for CData* it lets you + get the string without the CData wrapper.""" + if attr == 'string': + return self + else: + raise AttributeError, "'%s' object has no attribute '%s'" % (self.__class__.__name__, attr) + + def __unicode__(self): + return __str__(self, None) + + def __str__(self, encoding=DEFAULT_OUTPUT_ENCODING): + if encoding: + return self.encode(encoding) + else: + return self + +class CData(NavigableString): + + def __str__(self, encoding=DEFAULT_OUTPUT_ENCODING): + return "" % NavigableString.__str__(self, encoding) + +class ProcessingInstruction(NavigableString): + def __str__(self, encoding=DEFAULT_OUTPUT_ENCODING): + output = self + if "%SOUP-ENCODING%" in output: + output = self.substituteEncoding(output, encoding) + return "" % self.toEncoding(output, encoding) + +class Comment(NavigableString): + def __str__(self, encoding=DEFAULT_OUTPUT_ENCODING): + return "" % NavigableString.__str__(self, encoding) + +class Declaration(NavigableString): + def __str__(self, encoding=DEFAULT_OUTPUT_ENCODING): + return "" % NavigableString.__str__(self, encoding) + +class Tag(PageElement): + """Represents a found HTML tag with its attributes and contents.""" + + XML_ENTITIES_TO_CHARS = { 'apos' : "'", + "quot" : '"', + "amp" : "&", + "lt" : "<", + "gt" : ">" + } + # An RE for finding ampersands that aren't the start of of a + # numeric entity. + BARE_AMPERSAND = re.compile("&(?!#\d+;|#x[0-9a-fA-F]+;|\w+;)") + + def __init__(self, parser, name, attrs=None, parent=None, + previous=None): + "Basic constructor." + + # We don't actually store the parser object: that lets extracted + # chunks be garbage-collected + self.parserClass = parser.__class__ + self.isSelfClosing = parser.isSelfClosingTag(name) + self.convertHTMLEntities = parser.convertHTMLEntities + self.name = name + if attrs == None: + attrs = [] + self.attrs = attrs + self.contents = [] + self.setup(parent, previous) + self.hidden = False + self.containsSubstitutions = False + + def get(self, key, default=None): + """Returns the value of the 'key' attribute for the tag, or + the value given for 'default' if it doesn't have that + attribute.""" + return self._getAttrMap().get(key, default) + + def has_key(self, key): + return self._getAttrMap().has_key(key) + + def __getitem__(self, key): + """tag[key] returns the value of the 'key' attribute for the tag, + and throws an exception if it's not there.""" + return self._getAttrMap()[key] + + def __iter__(self): + "Iterating over a tag iterates over its contents." + return iter(self.contents) + + def __len__(self): + "The length of a tag is the length of its list of contents." + return len(self.contents) + + def __contains__(self, x): + return x in self.contents + + def __nonzero__(self): + "A tag is non-None even if it has no contents." + return True + + def __setitem__(self, key, value): + """Setting tag[key] sets the value of the 'key' attribute for the + tag.""" + self._getAttrMap() + self.attrMap[key] = value + found = False + for i in range(0, len(self.attrs)): + if self.attrs[i][0] == key: + self.attrs[i] = (key, value) + found = True + if not found: + self.attrs.append((key, value)) + self._getAttrMap()[key] = value + + def __delitem__(self, key): + "Deleting tag[key] deletes all 'key' attributes for the tag." + for item in self.attrs: + if item[0] == key: + self.attrs.remove(item) + #We don't break because bad HTML can define the same + #attribute multiple times. + self._getAttrMap() + if self.attrMap.has_key(key): + del self.attrMap[key] + + def __call__(self, *args, **kwargs): + """Calling a tag like a function is the same as calling its + findAll() method. Eg. tag('a') returns a list of all the A tags + found within this tag.""" + return apply(self.findAll, args, kwargs) + + def __getattr__(self, tag): + #print "Getattr %s.%s" % (self.__class__, tag) + if len(tag) > 3 and tag.rfind('Tag') == len(tag)-3: + return self.find(tag[:-3]) + elif tag.find('__') != 0: + return self.find(tag) + + def __eq__(self, other): + """Returns true iff this tag has the same name, the same attributes, + and the same contents (recursively) as the given tag. + + NOTE: right now this will return false if two tags have the + same attributes in a different order. Should this be fixed?""" + if not hasattr(other, 'name') or not hasattr(other, 'attrs') or not hasattr(other, 'contents') or self.name != other.name or self.attrs != other.attrs or len(self) != len(other): + return False + for i in range(0, len(self.contents)): + if self.contents[i] != other.contents[i]: + return False + return True + + def __ne__(self, other): + """Returns true iff this tag is not identical to the other tag, + as defined in __eq__.""" + return not self == other + + def __repr__(self, encoding=DEFAULT_OUTPUT_ENCODING): + """Renders this tag as a string.""" + return self.__str__(encoding) + + def __unicode__(self): + return self.__str__(None) + + def _convertEntities(self, match): + x = match.group(1) + if x in name2codepoint: + return unichr(name2codepoint[x]) + elif "&" + x + ";" in self.XML_ENTITIES_TO_CHARS: + return '&%s;' % x + else: + return '&%s;' % x + + def __str__(self, encoding=DEFAULT_OUTPUT_ENCODING, + prettyPrint=False, indentLevel=0): + """Returns a string or Unicode representation of this tag and + its contents. To get Unicode, pass None for encoding. + + NOTE: since Python's HTML parser consumes whitespace, this + method is not certain to reproduce the whitespace present in + the original string.""" + + encodedName = self.toEncoding(self.name, encoding) + + attrs = [] + if self.attrs: + for key, val in self.attrs: + fmt = '%s="%s"' + if isString(val): + if self.containsSubstitutions and '%SOUP-ENCODING%' in val: + val = self.substituteEncoding(val, encoding) + + # The attribute value either: + # + # * Contains no embedded double quotes or single quotes. + # No problem: we enclose it in double quotes. + # * Contains embedded single quotes. No problem: + # double quotes work here too. + # * Contains embedded double quotes. No problem: + # we enclose it in single quotes. + # * Embeds both single _and_ double quotes. This + # can't happen naturally, but it can happen if + # you modify an attribute value after parsing + # the document. Now we have a bit of a + # problem. We solve it by enclosing the + # attribute in single quotes, and escaping any + # embedded single quotes to XML entities. + if '"' in val: + # This can't happen naturally, but it can happen + # if you modify an attribute value after parsing. + if "'" in val: + val = val.replace('"', """) + else: + fmt = "%s='%s'" + + # Optionally convert any HTML entities + if self.convertHTMLEntities: + val = re.sub("&(\w+);", self._convertEntities, val) + + # Now we're okay w/r/t quotes. But the attribute + # value might also contain angle brackets, or + # ampersands that aren't part of entities. We need + # to escape those to XML entities too. + val = val.replace("<", "<").replace(">", ">") + val = self.BARE_AMPERSAND.sub("&", val) + + + attrs.append(fmt % (self.toEncoding(key, encoding), + self.toEncoding(val, encoding))) + close = '' + closeTag = '' + if self.isSelfClosing: + close = ' /' + else: + closeTag = '' % encodedName + + indentTag, indentContents = 0, 0 + if prettyPrint: + indentTag = indentLevel + space = (' ' * (indentTag-1)) + indentContents = indentTag + 1 + contents = self.renderContents(encoding, prettyPrint, indentContents) + if self.hidden: + s = contents + else: + s = [] + attributeString = '' + if attrs: + attributeString = ' ' + ' '.join(attrs) + if prettyPrint: + s.append(space) + s.append('<%s%s%s>' % (encodedName, attributeString, close)) + if prettyPrint: + s.append("\n") + s.append(contents) + if prettyPrint and contents and contents[-1] != "\n": + s.append("\n") + if prettyPrint and closeTag: + s.append(space) + s.append(closeTag) + if prettyPrint and closeTag and self.nextSibling: + s.append("\n") + s = ''.join(s) + return s + + def prettify(self, encoding=DEFAULT_OUTPUT_ENCODING): + return self.__str__(encoding, True) + + def renderContents(self, encoding=DEFAULT_OUTPUT_ENCODING, + prettyPrint=False, indentLevel=0): + """Renders the contents of this tag as a string in the given + encoding. If encoding is None, returns a Unicode string..""" + s=[] + for c in self: + text = None + if isinstance(c, NavigableString): + text = c.__str__(encoding) + elif isinstance(c, Tag): + s.append(c.__str__(encoding, prettyPrint, indentLevel)) + if text and prettyPrint: + text = text.strip() + if text: + if prettyPrint: + s.append(" " * (indentLevel-1)) + s.append(text) + if prettyPrint: + s.append("\n") + return ''.join(s) + + #Soup methods + + def find(self, name=None, attrs={}, recursive=True, text=None, + **kwargs): + """Return only the first child of this Tag matching the given + criteria.""" + r = None + l = self.findAll(name, attrs, recursive, text, 1, **kwargs) + if l: + r = l[0] + return r + findChild = find + + def findAll(self, name=None, attrs={}, recursive=True, text=None, + limit=None, **kwargs): + """Extracts a list of Tag objects that match the given + criteria. You can specify the name of the Tag and any + attributes you want the Tag to have. + + The value of a key-value pair in the 'attrs' map can be a + string, a list of strings, a regular expression object, or a + callable that takes a string and returns whether or not the + string matches for some custom definition of 'matches'. The + same is true of the tag name.""" + generator = self.recursiveChildGenerator + if not recursive: + generator = self.childGenerator + return self._findAll(name, attrs, text, limit, generator, **kwargs) + findChildren = findAll + + # Pre-3.x compatibility methods + first = find + fetch = findAll + + def fetchText(self, text=None, recursive=True, limit=None): + return self.findAll(text=text, recursive=recursive, limit=limit) + + def firstText(self, text=None, recursive=True): + return self.find(text=text, recursive=recursive) + + #Utility methods + + def append(self, tag): + """Appends the given tag to the contents of this tag.""" + self.contents.append(tag) + + #Private methods + + def _getAttrMap(self): + """Initializes a map representation of this tag's attributes, + if not already initialized.""" + if not getattr(self, 'attrMap'): + self.attrMap = {} + for (key, value) in self.attrs: + self.attrMap[key] = value + return self.attrMap + + #Generator methods + def childGenerator(self): + for i in range(0, len(self.contents)): + yield self.contents[i] + raise StopIteration + + def recursiveChildGenerator(self): + stack = [(self, 0)] + while stack: + tag, start = stack.pop() + if isinstance(tag, Tag): + for i in range(start, len(tag.contents)): + a = tag.contents[i] + yield a + if isinstance(a, Tag) and tag.contents: + if i < len(tag.contents) - 1: + stack.append((tag, i+1)) + stack.append((a, 0)) + break + raise StopIteration + +# Next, a couple classes to represent queries and their results. +class SoupStrainer: + """Encapsulates a number of ways of matching a markup element (tag or + text).""" + + def __init__(self, name=None, attrs={}, text=None, **kwargs): + self.name = name + if isString(attrs): + kwargs['class'] = attrs + attrs = None + if kwargs: + if attrs: + attrs = attrs.copy() + attrs.update(kwargs) + else: + attrs = kwargs + self.attrs = attrs + self.text = text + + def __str__(self): + if self.text: + return self.text + else: + return "%s|%s" % (self.name, self.attrs) + + def searchTag(self, markupName=None, markupAttrs={}): + found = None + markup = None + if isinstance(markupName, Tag): + markup = markupName + markupAttrs = markup + callFunctionWithTagData = callable(self.name) \ + and not isinstance(markupName, Tag) + + if (not self.name) \ + or callFunctionWithTagData \ + or (markup and self._matches(markup, self.name)) \ + or (not markup and self._matches(markupName, self.name)): + if callFunctionWithTagData: + match = self.name(markupName, markupAttrs) + else: + match = True + markupAttrMap = None + for attr, matchAgainst in self.attrs.items(): + if not markupAttrMap: + if hasattr(markupAttrs, 'get'): + markupAttrMap = markupAttrs + else: + markupAttrMap = {} + for k,v in markupAttrs: + markupAttrMap[k] = v + attrValue = markupAttrMap.get(attr) + if not self._matches(attrValue, matchAgainst): + match = False + break + if match: + if markup: + found = markup + else: + found = markupName + return found + + def search(self, markup): + #print 'looking for %s in %s' % (self, markup) + found = None + # If given a list of items, scan it for a text element that + # matches. + if isList(markup) and not isinstance(markup, Tag): + for element in markup: + if isinstance(element, NavigableString) \ + and self.search(element): + found = element + break + # If it's a Tag, make sure its name or attributes match. + # Don't bother with Tags if we're searching for text. + elif isinstance(markup, Tag): + if not self.text: + found = self.searchTag(markup) + # If it's text, make sure the text matches. + elif isinstance(markup, NavigableString) or \ + isString(markup): + if self._matches(markup, self.text): + found = markup + else: + raise Exception, "I don't know how to match against a %s" \ + % markup.__class__ + return found + + def _matches(self, markup, matchAgainst): + #print "Matching %s against %s" % (markup, matchAgainst) + result = False + if matchAgainst == True and type(matchAgainst) == types.BooleanType: + result = markup != None + elif callable(matchAgainst): + result = matchAgainst(markup) + else: + #Custom match methods take the tag as an argument, but all + #other ways of matching match the tag name as a string. + if isinstance(markup, Tag): + markup = markup.name + if markup and not isString(markup): + markup = unicode(markup) + #Now we know that chunk is either a string, or None. + if hasattr(matchAgainst, 'match'): + # It's a regexp object. + result = markup and matchAgainst.search(markup) + elif isList(matchAgainst): + result = markup in matchAgainst + elif hasattr(matchAgainst, 'items'): + result = markup.has_key(matchAgainst) + elif matchAgainst and isString(markup): + if isinstance(markup, unicode): + matchAgainst = unicode(matchAgainst) + else: + matchAgainst = str(matchAgainst) + + if not result: + result = matchAgainst == markup + return result + +class ResultSet(list): + """A ResultSet is just a list that keeps track of the SoupStrainer + that created it.""" + def __init__(self, source): + list.__init__([]) + self.source = source + +# Now, some helper functions. + +def isList(l): + """Convenience method that works with all 2.x versions of Python + to determine whether or not something is listlike.""" + return hasattr(l, '__iter__') \ + or (type(l) in (types.ListType, types.TupleType)) + +def isString(s): + """Convenience method that works with all 2.x versions of Python + to determine whether or not something is stringlike.""" + try: + return isinstance(s, unicode) or isintance(s, basestring) + except NameError: + return isinstance(s, str) + +def buildTagMap(default, *args): + """Turns a list of maps, lists, or scalars into a single map. + Used to build the SELF_CLOSING_TAGS, NESTABLE_TAGS, and + NESTING_RESET_TAGS maps out of lists and partial maps.""" + built = {} + for portion in args: + if hasattr(portion, 'items'): + #It's a map. Merge it. + for k,v in portion.items(): + built[k] = v + elif isList(portion): + #It's a list. Map each item to the default. + for k in portion: + built[k] = default + else: + #It's a scalar. Map it to the default. + built[portion] = default + return built + +# Now, the parser classes. + +class BeautifulStoneSoup(Tag, SGMLParser): + + """This class contains the basic parser and search code. It defines + a parser that knows nothing about tag behavior except for the + following: + + You can't close a tag without closing all the tags it encloses. + That is, "" actually means + "". + + [Another possible explanation is "", but since + this class defines no SELF_CLOSING_TAGS, it will never use that + explanation.] + + This class is useful for parsing XML or made-up markup languages, + or when BeautifulSoup makes an assumption counter to what you were + expecting.""" + + SELF_CLOSING_TAGS = {} + NESTABLE_TAGS = {} + RESET_NESTING_TAGS = {} + QUOTE_TAGS = {} + + MARKUP_MASSAGE = [(re.compile('(<[^<>]*)/>'), + lambda x: x.group(1) + ' />'), + (re.compile(']*)>'), + lambda x: '') + ] + + ROOT_TAG_NAME = u'[document]' + + HTML_ENTITIES = "html" + XML_ENTITIES = "xml" + ALL_ENTITIES = [HTML_ENTITIES, XML_ENTITIES] + + def __init__(self, markup="", parseOnlyThese=None, fromEncoding=None, + markupMassage=True, smartQuotesTo=XML_ENTITIES, + convertEntities=None, selfClosingTags=None): + """The Soup object is initialized as the 'root tag', and the + provided markup (which can be a string or a file-like object) + is fed into the underlying parser. + + sgmllib will process most bad HTML, and the BeautifulSoup + class has some tricks for dealing with some HTML that kills + sgmllib, but Beautiful Soup can nonetheless choke or lose data + if your data uses self-closing tags or declarations + incorrectly. + + By default, Beautiful Soup uses regexes to sanitize input, + avoiding the vast majority of these problems. If the problems + don't apply to you, pass in False for markupMassage, and + you'll get better performance. + + The default parser massage techniques fix the two most common + instances of invalid HTML that choke sgmllib: + +
(No space between name of closing tag and tag close) + (Extraneous whitespace in declaration) + + You can pass in a custom list of (RE object, replace method) + tuples to get Beautiful Soup to scrub your input the way you + want.""" + + self.parseOnlyThese = parseOnlyThese + self.fromEncoding = fromEncoding + self.smartQuotesTo = smartQuotesTo + + if convertEntities: + # It doesn't make sense to convert encoded characters to + # entities even while you're converting entities to Unicode. + # Just convert it all to Unicode. + self.smartQuotesTo = None + + if isList(convertEntities): + self.convertHTMLEntities = self.HTML_ENTITIES in convertEntities + self.convertXMLEntities = self.XML_ENTITIES in convertEntities + else: + self.convertHTMLEntities = self.HTML_ENTITIES == convertEntities + self.convertXMLEntities = self.XML_ENTITIES == convertEntities + + self.instanceSelfClosingTags = buildTagMap(None, selfClosingTags) + SGMLParser.__init__(self) + + if hasattr(markup, 'read'): # It's a file-type object. + markup = markup.read() + self.markup = markup + self.markupMassage = markupMassage + try: + self._feed() + except StopParsing: + pass + self.markup = None # The markup can now be GCed + + def _feed(self, inDocumentEncoding=None): + # Convert the document to Unicode. + markup = self.markup + if isinstance(markup, unicode): + if not hasattr(self, 'originalEncoding'): + self.originalEncoding = None + else: + dammit = UnicodeDammit\ + (markup, [self.fromEncoding, inDocumentEncoding], + smartQuotesTo=self.smartQuotesTo) + markup = dammit.unicode + self.originalEncoding = dammit.originalEncoding + if markup: + if self.markupMassage: + if not isList(self.markupMassage): + self.markupMassage = self.MARKUP_MASSAGE + for fix, m in self.markupMassage: + markup = fix.sub(m, markup) + self.reset() + + SGMLParser.feed(self, markup or "") + SGMLParser.close(self) + # Close out any unfinished strings and close all the open tags. + self.endData() + while self.currentTag.name != self.ROOT_TAG_NAME: + self.popTag() + + def __getattr__(self, methodName): + """This method routes method call requests to either the SGMLParser + superclass or the Tag superclass, depending on the method name.""" + #print "__getattr__ called on %s.%s" % (self.__class__, methodName) + + if methodName.find('start_') == 0 or methodName.find('end_') == 0 \ + or methodName.find('do_') == 0: + return SGMLParser.__getattr__(self, methodName) + elif methodName.find('__') != 0: + return Tag.__getattr__(self, methodName) + else: + raise AttributeError + + def isSelfClosingTag(self, name): + """Returns true iff the given string is the name of a + self-closing tag according to this parser.""" + return self.SELF_CLOSING_TAGS.has_key(name) \ + or self.instanceSelfClosingTags.has_key(name) + + def reset(self): + Tag.__init__(self, self, self.ROOT_TAG_NAME) + self.hidden = 1 + SGMLParser.reset(self) + self.currentData = [] + self.currentTag = None + self.tagStack = [] + self.quoteStack = [] + self.pushTag(self) + + def popTag(self): + tag = self.tagStack.pop() + # Tags with just one string-owning child get the child as a + # 'string' property, so that soup.tag.string is shorthand for + # soup.tag.contents[0] + if len(self.currentTag.contents) == 1 and \ + isinstance(self.currentTag.contents[0], NavigableString): + self.currentTag.string = self.currentTag.contents[0] + + #print "Pop", tag.name + if self.tagStack: + self.currentTag = self.tagStack[-1] + return self.currentTag + + def pushTag(self, tag): + #print "Push", tag.name + if self.currentTag: + self.currentTag.append(tag) + self.tagStack.append(tag) + self.currentTag = self.tagStack[-1] + + def endData(self, containerClass=NavigableString): + if self.currentData: + currentData = ''.join(self.currentData) + if currentData.endswith('<') and self.convertHTMLEntities: + currentData = currentData[:-1] + '<' + if not currentData.strip(): + if '\n' in currentData: + currentData = '\n' + else: + currentData = ' ' + self.currentData = [] + if self.parseOnlyThese and len(self.tagStack) <= 1 and \ + (not self.parseOnlyThese.text or \ + not self.parseOnlyThese.search(currentData)): + return + o = containerClass(currentData) + o.setup(self.currentTag, self.previous) + if self.previous: + self.previous.next = o + self.previous = o + self.currentTag.contents.append(o) + + + def _popToTag(self, name, inclusivePop=True): + """Pops the tag stack up to and including the most recent + instance of the given tag. If inclusivePop is false, pops the tag + stack up to but *not* including the most recent instqance of + the given tag.""" + #print "Popping to %s" % name + if name == self.ROOT_TAG_NAME: + return + + numPops = 0 + mostRecentTag = None + for i in range(len(self.tagStack)-1, 0, -1): + if name == self.tagStack[i].name: + numPops = len(self.tagStack)-i + break + if not inclusivePop: + numPops = numPops - 1 + + for i in range(0, numPops): + mostRecentTag = self.popTag() + return mostRecentTag + + def _smartPop(self, name): + + """We need to pop up to the previous tag of this type, unless + one of this tag's nesting reset triggers comes between this + tag and the previous tag of this type, OR unless this tag is a + generic nesting trigger and another generic nesting trigger + comes between this tag and the previous tag of this type. + + Examples: +

FooBar

should pop to 'p', not 'b'. +

FooBar

should pop to 'table', not 'p'. +

Foo

Bar

should pop to 'tr', not 'p'. +

FooBar

should pop to 'p', not 'b'. + +

    • *
    • * should pop to 'ul', not the first 'li'. +
  • ** should pop to 'table', not the first 'tr' + tag should + implicitly close the previous tag within the same
    ** should pop to 'tr', not the first 'td' + """ + + nestingResetTriggers = self.NESTABLE_TAGS.get(name) + isNestable = nestingResetTriggers != None + isResetNesting = self.RESET_NESTING_TAGS.has_key(name) + popTo = None + inclusive = True + for i in range(len(self.tagStack)-1, 0, -1): + p = self.tagStack[i] + if (not p or p.name == name) and not isNestable: + #Non-nestable tags get popped to the top or to their + #last occurance. + popTo = name + break + if (nestingResetTriggers != None + and p.name in nestingResetTriggers) \ + or (nestingResetTriggers == None and isResetNesting + and self.RESET_NESTING_TAGS.has_key(p.name)): + + #If we encounter one of the nesting reset triggers + #peculiar to this tag, or we encounter another tag + #that causes nesting to reset, pop up to but not + #including that tag. + popTo = p.name + inclusive = False + break + p = p.parent + if popTo: + self._popToTag(popTo, inclusive) + + def unknown_starttag(self, name, attrs, selfClosing=0): + #print "Start tag %s: %s" % (name, attrs) + if self.quoteStack: + #This is not a real tag. + #print "<%s> is not real!" % name + attrs = ''.join(map(lambda(x, y): ' %s="%s"' % (x, y), attrs)) + self.currentData.append('<%s%s>' % (name, attrs)) + return + self.endData() + + if not self.isSelfClosingTag(name) and not selfClosing: + self._smartPop(name) + + if self.parseOnlyThese and len(self.tagStack) <= 1 \ + and (self.parseOnlyThese.text or not self.parseOnlyThese.searchTag(name, attrs)): + return + + tag = Tag(self, name, attrs, self.currentTag, self.previous) + if self.previous: + self.previous.next = tag + self.previous = tag + self.pushTag(tag) + if selfClosing or self.isSelfClosingTag(name): + self.popTag() + if name in self.QUOTE_TAGS: + #print "Beginning quote (%s)" % name + self.quoteStack.append(name) + self.literal = 1 + return tag + + def unknown_endtag(self, name): + #print "End tag %s" % name + if self.quoteStack and self.quoteStack[-1] != name: + #This is not a real end tag. + #print " is not real!" % name + self.currentData.append('' % name) + return + self.endData() + self._popToTag(name) + if self.quoteStack and self.quoteStack[-1] == name: + self.quoteStack.pop() + self.literal = (len(self.quoteStack) > 0) + + def handle_data(self, data): + if self.convertHTMLEntities: + if data[0] == '&': + data = self.BARE_AMPERSAND.sub("&",data) + else: + data = data.replace('&','&') \ + .replace('<','<') \ + .replace('>','>') + self.currentData.append(data) + + def _toStringSubclass(self, text, subclass): + """Adds a certain piece of text to the tree as a NavigableString + subclass.""" + self.endData() + self.handle_data(text) + self.endData(subclass) + + def handle_pi(self, text): + """Handle a processing instruction as a ProcessingInstruction + object, possibly one with a %SOUP-ENCODING% slot into which an + encoding will be plugged later.""" + if text[:3] == "xml": + text = "xml version='1.0' encoding='%SOUP-ENCODING%'" + self._toStringSubclass(text, ProcessingInstruction) + + def handle_comment(self, text): + "Handle comments as Comment objects." + self._toStringSubclass(text, Comment) + + def handle_charref(self, ref): + "Handle character references as data." + if ref[0] == 'x': + data = unichr(int(ref[1:],16)) + else: + data = unichr(int(ref)) + + if u'\x80' <= data <= u'\x9F': + data = UnicodeDammit.subMSChar(chr(ord(data)), self.smartQuotesTo) + elif not self.convertHTMLEntities and not self.convertXMLEntities: + data = '&#%s;' % ref + + self.handle_data(data) + + def handle_entityref(self, ref): + """Handle entity references as data, possibly converting known + HTML entity references to the corresponding Unicode + characters.""" + replaceWithXMLEntity = self.convertXMLEntities and \ + self.XML_ENTITIES_TO_CHARS.has_key(ref) + if self.convertHTMLEntities or replaceWithXMLEntity: + try: + data = unichr(name2codepoint[ref]) + except KeyError: + if replaceWithXMLEntity: + data = self.XML_ENTITIES_TO_CHARS.get(ref) + else: + data="&%s" % ref + else: + data = '&%s;' % ref + self.handle_data(data) + + def handle_decl(self, data): + "Handle DOCTYPEs and the like as Declaration objects." + self._toStringSubclass(data, Declaration) + + def parse_declaration(self, i): + """Treat a bogus SGML declaration as raw data. Treat a CDATA + declaration as a CData object.""" + j = None + if self.rawdata[i:i+9] == '', i) + if k == -1: + k = len(self.rawdata) + data = self.rawdata[i+9:k] + j = k+3 + self._toStringSubclass(data, CData) + else: + try: + j = SGMLParser.parse_declaration(self, i) + except SGMLParseError: + toHandle = self.rawdata[i:] + self.handle_data(toHandle) + j = i + len(toHandle) + return j + +class BeautifulSoup(BeautifulStoneSoup): + + """This parser knows the following facts about HTML: + + * Some tags have no closing tag and should be interpreted as being + closed as soon as they are encountered. + + * The text inside some tags (ie. 'script') may contain tags which + are not really part of the document and which should be parsed + as text, not tags. If you want to parse the text as tags, you can + always fetch it and parse it explicitly. + + * Tag nesting rules: + + Most tags can't be nested at all. For instance, the occurance of + a

    tag should implicitly close the previous

    tag. + +

    Para1

    Para2 + should be transformed into: +

    Para1

    Para2 + + Some tags can be nested arbitrarily. For instance, the occurance + of a

    tag should _not_ implicitly close the previous +
    tag. + + Alice said:
    Bob said:
    Blah + should NOT be transformed into: + Alice said:
    Bob said:
    Blah + + Some tags can be nested, but the nesting is reset by the + interposition of other tags. For instance, a
    , + but not close a tag in another table. + +
    BlahBlah + should be transformed into: +
    BlahBlah + but, + Blah
    Blah + should NOT be transformed into + Blah
    Blah + + Differing assumptions about tag nesting rules are a major source + of problems with the BeautifulSoup class. If BeautifulSoup is not + treating as nestable a tag your page author treats as nestable, + try ICantBelieveItsBeautifulSoup, MinimalSoup, or + BeautifulStoneSoup before writing your own subclass.""" + + def __init__(self, *args, **kwargs): + if not kwargs.has_key('smartQuotesTo'): + kwargs['smartQuotesTo'] = self.HTML_ENTITIES + BeautifulStoneSoup.__init__(self, *args, **kwargs) + + SELF_CLOSING_TAGS = buildTagMap(None, + ['br' , 'hr', 'input', 'img', 'meta', + 'spacer', 'link', 'frame', 'base']) + + QUOTE_TAGS = {'script': None} + + #According to the HTML standard, each of these inline tags can + #contain another tag of the same type. Furthermore, it's common + #to actually use these tags this way. + NESTABLE_INLINE_TAGS = ['span', 'font', 'q', 'object', 'bdo', 'sub', 'sup', + 'center'] + + #According to the HTML standard, these block tags can contain + #another tag of the same type. Furthermore, it's common + #to actually use these tags this way. + NESTABLE_BLOCK_TAGS = ['blockquote', 'div', 'fieldset', 'ins', 'del'] + + #Lists can contain other lists, but there are restrictions. + NESTABLE_LIST_TAGS = { 'ol' : [], + 'ul' : [], + 'li' : ['ul', 'ol'], + 'dl' : [], + 'dd' : ['dl'], + 'dt' : ['dl'] } + + #Tables can contain other tables, but there are restrictions. + NESTABLE_TABLE_TAGS = {'table' : [], + 'tr' : ['table', 'tbody', 'tfoot', 'thead'], + 'td' : ['tr'], + 'th' : ['tr'], + 'thead' : ['table'], + 'tbody' : ['table'], + 'tfoot' : ['table'], + } + + NON_NESTABLE_BLOCK_TAGS = ['address', 'form', 'p', 'pre'] + + #If one of these tags is encountered, all tags up to the next tag of + #this type are popped. + RESET_NESTING_TAGS = buildTagMap(None, NESTABLE_BLOCK_TAGS, 'noscript', + NON_NESTABLE_BLOCK_TAGS, + NESTABLE_LIST_TAGS, + NESTABLE_TABLE_TAGS) + + NESTABLE_TAGS = buildTagMap([], NESTABLE_INLINE_TAGS, NESTABLE_BLOCK_TAGS, + NESTABLE_LIST_TAGS, NESTABLE_TABLE_TAGS) + + # Used to detect the charset in a META tag; see start_meta + CHARSET_RE = re.compile("((^|;)\s*charset=)([^;]*)") + + def start_meta(self, attrs): + """Beautiful Soup can detect a charset included in a META tag, + try to convert the document to that charset, and re-parse the + document from the beginning.""" + httpEquiv = None + contentType = None + contentTypeIndex = None + tagNeedsEncodingSubstitution = False + + for i in range(0, len(attrs)): + key, value = attrs[i] + key = key.lower() + if key == 'http-equiv': + httpEquiv = value + elif key == 'content': + contentType = value + contentTypeIndex = i + + if httpEquiv and contentType: # It's an interesting meta tag. + match = self.CHARSET_RE.search(contentType) + if match: + if getattr(self, 'declaredHTMLEncoding') or \ + (self.originalEncoding == self.fromEncoding): + # This is our second pass through the document, or + # else an encoding was specified explicitly and it + # worked. Rewrite the meta tag. + newAttr = self.CHARSET_RE.sub\ + (lambda(match):match.group(1) + + "%SOUP-ENCODING%", value) + attrs[contentTypeIndex] = (attrs[contentTypeIndex][0], + newAttr) + tagNeedsEncodingSubstitution = True + else: + # This is our first pass through the document. + # Go through it again with the new information. + newCharset = match.group(3) + if newCharset and newCharset != self.originalEncoding: + self.declaredHTMLEncoding = newCharset + self._feed(self.declaredHTMLEncoding) + raise StopParsing + tag = self.unknown_starttag("meta", attrs) + if tag and tagNeedsEncodingSubstitution: + tag.containsSubstitutions = True + +class StopParsing(Exception): + pass + +class ICantBelieveItsBeautifulSoup(BeautifulSoup): + + """The BeautifulSoup class is oriented towards skipping over + common HTML errors like unclosed tags. However, sometimes it makes + errors of its own. For instance, consider this fragment: + + FooBar + + This is perfectly valid (if bizarre) HTML. However, the + BeautifulSoup class will implicitly close the first b tag when it + encounters the second 'b'. It will think the author wrote + "FooBar", and didn't close the first 'b' tag, because + there's no real-world reason to bold something that's already + bold. When it encounters '' it will close two more 'b' + tags, for a grand total of three tags closed instead of two. This + can throw off the rest of your document structure. The same is + true of a number of other tags, listed below. + + It's much more common for someone to forget to close a 'b' tag + than to actually use nested 'b' tags, and the BeautifulSoup class + handles the common case. This class handles the not-co-common + case: where you can't believe someone wrote what they did, but + it's valid HTML and BeautifulSoup screwed up by assuming it + wouldn't be.""" + + I_CANT_BELIEVE_THEYRE_NESTABLE_INLINE_TAGS = \ + ['em', 'big', 'i', 'small', 'tt', 'abbr', 'acronym', 'strong', + 'cite', 'code', 'dfn', 'kbd', 'samp', 'strong', 'var', 'b', + 'big'] + + I_CANT_BELIEVE_THEYRE_NESTABLE_BLOCK_TAGS = ['noscript'] + + NESTABLE_TAGS = buildTagMap([], BeautifulSoup.NESTABLE_TAGS, + I_CANT_BELIEVE_THEYRE_NESTABLE_BLOCK_TAGS, + I_CANT_BELIEVE_THEYRE_NESTABLE_INLINE_TAGS) + +class MinimalSoup(BeautifulSoup): + """The MinimalSoup class is for parsing HTML that contains + pathologically bad markup. It makes no assumptions about tag + nesting, but it does know which tags are self-closing, that + - - - - -If anything blows up after this line, it's from Cookie's doctest. Deleted: /python/branches/p3yk/Lib/test/output/test_global ============================================================================== --- /python/branches/p3yk/Lib/test/output/test_global Wed Dec 13 05:49:30 2006 +++ (empty file) @@ -1,5 +0,0 @@ -test_global -got SyntaxError as expected -got SyntaxError as expected -got SyntaxError as expected -as expected, no SyntaxError Deleted: /python/branches/p3yk/Lib/test/output/test_grammar ============================================================================== --- /python/branches/p3yk/Lib/test/output/test_grammar Wed Dec 13 05:49:30 2006 +++ (empty file) @@ -1,69 +0,0 @@ -test_grammar -1. Parser -1.1 Tokens -1.1.1 Backslashes -1.1.2 Numeric literals -1.1.2.1 Plain integers -1.1.2.2 Long integers -1.1.2.3 Floating point -1.1.3 String literals -1.1.4 Ellipsis literal -1.2 Grammar -single_input -file_input -expr_input -eval_input -funcdef -lambdef -simple_stmt -expr_stmt -print_stmt -1 2 3 -1 2 3 -1 1 1 -extended print_stmt -1 2 3 -1 2 3 -1 1 1 -hello world -del_stmt -pass_stmt -flow_stmt -break_stmt -continue_stmt -continue + try/except ok -continue + try/finally ok -testing continue and break in try/except in loop -return_stmt -yield_stmt -raise_stmt -import_name -import_from -global_stmt -assert_stmt -if_stmt -while_stmt -for_stmt -try_stmt -suite -test -comparison -binary mask ops -shift ops -additive ops -multiplicative ops -unary ops -selectors - -[1, (1,), (1, 2), (1, 2, 3)] -atoms -classdef -['Apple', 'Banana', 'Coco nut'] -[3, 6, 9, 12, 15] -[3, 4, 5] -[(1, 'Apple'), (1, 'Banana'), (1, 'Coconut'), (2, 'Apple'), (2, 'Banana'), (2, 'Coconut'), (3, 'Apple'), (3, 'Banana'), (3, 'Coconut'), (4, 'Apple'), (4, 'Banana'), (4, 'Coconut'), (5, 'Apple'), (5, 'Banana'), (5, 'Coconut')] -[(1, 'Banana'), (1, 'Coconut'), (2, 'Banana'), (2, 'Coconut'), (3, 'Banana'), (3, 'Coconut'), (4, 'Banana'), (4, 'Coconut'), (5, 'Banana'), (5, 'Coconut')] -[[1], [1, 1], [1, 2, 4], [1, 3, 9, 27], [1, 4, 16, 64, 256]] -[False, False, False] -[[1, 2], [3, 4], [5, 6]] -[('Boeing', 'Airliner'), ('Boeing', 'Engine'), ('Ford', 'Engine'), ('Macdonalds', 'Cheeseburger')] Deleted: /python/branches/p3yk/Lib/test/output/test_httplib ============================================================================== --- /python/branches/p3yk/Lib/test/output/test_httplib Wed Dec 13 05:49:30 2006 +++ (empty file) @@ -1,13 +0,0 @@ -test_httplib -reply: 'HTTP/1.1 200 Ok\r\n' -Text -reply: 'HTTP/1.1 400.100 Not Ok\r\n' -BadStatusLine raised as expected -InvalidURL raised as expected -InvalidURL raised as expected -reply: 'HTTP/1.1 200 OK\r\n' -header: Set-Cookie: Customer="WILE_E_COYOTE"; Version="1"; Path="/acme" -header: Set-Cookie: Part_Number="Rocket_Launcher_0001"; Version="1"; Path="/acme" -reply: 'HTTP/1.1 200 OK\r\n' -header: Content-Length: 14432 - Deleted: /python/branches/p3yk/Lib/test/output/test_math ============================================================================== --- /python/branches/p3yk/Lib/test/output/test_math Wed Dec 13 05:49:30 2006 +++ (empty file) @@ -1,28 +0,0 @@ -test_math -math module, testing with eps 1e-05 -constants -acos -asin -atan -atan2 -ceil -cos -cosh -degrees -exp -fabs -floor -fmod -frexp -hypot -ldexp -log -log10 -modf -pow -radians -sin -sinh -sqrt -tan -tanh Deleted: /python/branches/p3yk/Lib/test/output/test_mmap ============================================================================== --- /python/branches/p3yk/Lib/test/output/test_mmap Wed Dec 13 05:49:30 2006 +++ (empty file) @@ -1,38 +0,0 @@ -test_mmap - - Position of foo: 1.0 pages - Length of file: 2.0 pages - Contents of byte 0: '\x00' - Contents of first 3 bytes: '\x00\x00\x00' - - Modifying file's content... - Contents of byte 0: '3' - Contents of first 3 bytes: '3\x00\x00' - Contents of second page: '\x00foobar\x00' - Regex match on mmap (page start, length of match): 1.0 6 - Seek to zeroth byte - Seek to 42nd byte - Seek to last byte - Try to seek to negative position... - Try to seek beyond end of mmap... - Try to seek to negative position... - Attempting resize() - Creating 10 byte test data file. - Opening mmap with access=ACCESS_READ - Ensuring that readonly mmap can't be slice assigned. - Ensuring that readonly mmap can't be item assigned. - Ensuring that readonly mmap can't be write() to. - Ensuring that readonly mmap can't be write_byte() to. - Ensuring that readonly mmap can't be resized. - Opening mmap with size too big - Opening mmap with access=ACCESS_WRITE - Modifying write-through memory map. - Opening mmap with access=ACCESS_COPY - Modifying copy-on-write memory map. - Ensuring copy-on-write maps cannot be resized. - Ensuring invalid access parameter raises exception. - Try opening a bad file descriptor... - Ensuring that passing 0 as map length sets map size to current file size. - Ensuring that passing 0 as map length sets map size to current file size. - anonymous mmap.mmap(-1, PAGESIZE)... - Test passed Deleted: /python/branches/p3yk/Lib/test/output/test_nis ============================================================================== --- /python/branches/p3yk/Lib/test/output/test_nis Wed Dec 13 05:49:30 2006 +++ (empty file) @@ -1,2 +0,0 @@ -test_nis -nis.maps() Deleted: /python/branches/p3yk/Lib/test/output/test_opcodes ============================================================================== --- /python/branches/p3yk/Lib/test/output/test_opcodes Wed Dec 13 05:49:30 2006 +++ (empty file) @@ -1,6 +0,0 @@ -test_opcodes -2. Opcodes -XXX Not yet fully implemented -2.1 try inside for loop -2.2 raise class exceptions -2.3 comparing function objects Deleted: /python/branches/p3yk/Lib/test/output/test_openpty ============================================================================== --- /python/branches/p3yk/Lib/test/output/test_openpty Wed Dec 13 05:49:30 2006 +++ (empty file) @@ -1,2 +0,0 @@ -test_openpty -Ping! Deleted: /python/branches/p3yk/Lib/test/output/test_poll ============================================================================== --- /python/branches/p3yk/Lib/test/output/test_poll Wed Dec 13 05:49:30 2006 +++ (empty file) @@ -1,19 +0,0 @@ -test_poll -Running poll test 1 - This is a test. - This is a test. - This is a test. - This is a test. - This is a test. - This is a test. - This is a test. - This is a test. - This is a test. - This is a test. - This is a test. - This is a test. -Poll test 1 complete -Running poll test 2 -Poll test 2 complete -Running poll test 3 -Poll test 3 complete Deleted: /python/branches/p3yk/Lib/test/output/test_regex ============================================================================== --- /python/branches/p3yk/Lib/test/output/test_regex Wed Dec 13 05:49:30 2006 +++ (empty file) @@ -1,29 +0,0 @@ -test_regex -no match: -1 -successful search: 6 -caught expected exception -failed awk syntax: -1 -successful awk syntax: 2 -failed awk syntax: -1 -matching with group names and compile() --1 -caught expected exception -matching with group names and symcomp() -7 -801 999 -801 -('801', '999') -('801', '999') -realpat: \([0-9]+\) *\([0-9]+\) -groupindex: {'one': 1, 'two': 2} -not case folded search: -1 -case folded search: 6 -__members__: ['last', 'regs', 'translate', 'groupindex', 'realpat', 'givenpat'] -regs: ((6, 11), (-1, -1), (-1, -1), (-1, -1), (-1, -1), (-1, -1), (-1, -1), (-1, -1), (-1, -1), (-1, -1), (-1, -1), (-1, -1), (-1, -1), (-1, -1), (-1, -1), (-1, -1), (-1, -1), (-1, -1), (-1, -1), (-1, -1), (-1, -1), (-1, -1), (-1, -1), (-1, -1), (-1, -1), (-1, -1), (-1, -1), (-1, -1), (-1, -1), (-1, -1), (-1, -1), (-1, -1), (-1, -1), (-1, -1), (-1, -1), (-1, -1), (-1, -1), (-1, -1), (-1, -1), (-1, -1), (-1, -1), (-1, -1), (-1, -1), (-1, -1), (-1, -1), (-1, -1), (-1, -1), (-1, -1), (-1, -1), (-1, -1), (-1, -1), (-1, -1), (-1, -1), (-1, -1), (-1, -1), (-1, -1), (-1, -1), (-1, -1), (-1, -1), (-1, -1), (-1, -1), (-1, -1), (-1, -1), (-1, -1), (-1, -1), (-1, -1), (-1, -1), (-1, -1), (-1, -1), (-1, -1), (-1, -1), (-1, -1), (-1, -1), (-1, -1), (-1, -1), (-1, -1), (-1, -1), (-1, -1), (-1, -1), (-1, -1), (-1, -1), (-1, -1), (-1, -1), (-1, -1), (-1, -1), (-1, -1), (-1, -1), (-1, -1), (-1, -1), (-1, -1), (-1, -1), (-1, -1), (-1, -1), (-1, -1), (-1, -1), (-1, -1), (-1, -1), (-1, -1), (-1, -1), (-1, -1)) -last: HELLO WORLD -translate: 256 -givenpat: world -match with pos: -1 -search with pos: 18 -bogus group: ('world', None, None) -no name: caught expected exception Deleted: /python/branches/p3yk/Lib/test/output/test_scope ============================================================================== --- /python/branches/p3yk/Lib/test/output/test_scope Wed Dec 13 05:49:30 2006 +++ (empty file) @@ -1,24 +0,0 @@ -test_scope -1. simple nesting -2. extra nesting -3. simple nesting + rebinding -4. nesting with global but no free -5. nesting through class -6. nesting plus free ref to global -7. nearest enclosing scope -8. mixed freevars and cellvars -9. free variable in method -10. recursion -11. unoptimized namespaces -12. lambdas -13. UnboundLocal -14. complex definitions -15. scope of global statements -16. check leaks -17. class and global -18. verify that locals() works -19. var is bound and free in class -20. interaction with trace function -20. eval and exec with free variables -21. list comprehension with local variables -22. eval with free variables Modified: python/branches/p3yk/Lib/test/output/test_tokenize ============================================================================== --- python/branches/p3yk/Lib/test/output/test_tokenize (original) +++ python/branches/p3yk/Lib/test/output/test_tokenize Wed Dec 13 05:49:30 2006 @@ -1,15 +1,23 @@ test_tokenize -1,0-1,35: COMMENT "# Tests for the 'tokenize' module.\n" -2,0-2,43: COMMENT '# Large bits stolen from test_grammar.py. \n' +1,0-1,34: COMMENT "# Tests for the 'tokenize' module." +1,34-1,35: NL '\n' +2,0-2,42: COMMENT '# Large bits stolen from test_grammar.py. ' +2,42-2,43: NL '\n' 3,0-3,1: NL '\n' -4,0-4,11: COMMENT '# Comments\n' +4,0-4,10: COMMENT '# Comments' +4,10-4,11: NL '\n' 5,0-5,3: STRING '"#"' 5,3-5,4: NEWLINE '\n' -6,0-6,3: COMMENT "#'\n" -7,0-7,3: COMMENT '#"\n' -8,0-8,3: COMMENT '#\\\n' -9,7-9,9: COMMENT '#\n' -10,4-10,10: COMMENT '# abc\n' +6,0-6,2: COMMENT "#'" +6,2-6,3: NL '\n' +7,0-7,2: COMMENT '#"' +7,2-7,3: NL '\n' +8,0-8,2: COMMENT '#\\' +8,2-8,3: NL '\n' +9,7-9,8: COMMENT '#' +9,8-9,9: NL '\n' +10,4-10,9: COMMENT '# abc' +10,9-10,10: NL '\n' 11,0-12,4: STRING "'''#\n#'''" 12,4-12,5: NEWLINE '\n' 13,0-13,1: NL '\n' @@ -19,7 +27,8 @@ 14,7-14,8: COMMENT '#' 14,8-14,9: NEWLINE '\n' 15,0-15,1: NL '\n' -16,0-16,25: COMMENT '# Balancing continuation\n' +16,0-16,24: COMMENT '# Balancing continuation' +16,24-16,25: NL '\n' 17,0-17,1: NL '\n' 18,0-18,1: NAME 'a' 18,2-18,3: OP '=' @@ -93,7 +102,8 @@ 29,2-29,3: OP ')' 29,3-29,4: NEWLINE '\n' 30,0-30,1: NL '\n' -31,0-31,37: COMMENT '# Backslash means line continuation:\n' +31,0-31,36: COMMENT '# Backslash means line continuation:' +31,36-31,37: NL '\n' 32,0-32,1: NAME 'x' 32,2-32,3: OP '=' 32,4-32,5: NUMBER '1' @@ -101,13 +111,15 @@ 33,2-33,3: NUMBER '1' 33,3-33,4: NEWLINE '\n' 34,0-34,1: NL '\n' -35,0-35,55: COMMENT '# Backslash does not means continuation in comments :\\\n' +35,0-35,54: COMMENT '# Backslash does not means continuation in comments :\\' +35,54-35,55: NL '\n' 36,0-36,1: NAME 'x' 36,2-36,3: OP '=' 36,4-36,5: NUMBER '0' 36,5-36,6: NEWLINE '\n' 37,0-37,1: NL '\n' -38,0-38,20: COMMENT '# Ordinary integers\n' +38,0-38,19: COMMENT '# Ordinary integers' +38,19-38,20: NL '\n' 39,0-39,4: NUMBER '0xff' 39,5-39,7: OP '!=' 39,8-39,11: NUMBER '255' @@ -138,7 +150,8 @@ 44,15-44,16: NUMBER '1' 44,16-44,17: NEWLINE '\n' 45,0-45,1: NL '\n' -46,0-46,16: COMMENT '# Long integers\n' +46,0-46,15: COMMENT '# Long integers' +46,15-46,16: NL '\n' 47,0-47,1: NAME 'x' 47,2-47,3: OP '=' 47,4-47,6: NUMBER '0L' @@ -172,7 +185,8 @@ 54,4-54,35: NUMBER '123456789012345678901234567890l' 54,35-54,36: NEWLINE '\n' 55,0-55,1: NL '\n' -56,0-56,25: COMMENT '# Floating-point numbers\n' +56,0-56,24: COMMENT '# Floating-point numbers' +56,24-56,25: NL '\n' 57,0-57,1: NAME 'x' 57,2-57,3: OP '=' 57,4-57,8: NUMBER '3.14' @@ -185,7 +199,8 @@ 59,2-59,3: OP '=' 59,4-59,9: NUMBER '0.314' 59,9-59,10: NEWLINE '\n' -60,0-60,18: COMMENT '# XXX x = 000.314\n' +60,0-60,17: COMMENT '# XXX x = 000.314' +60,17-60,18: NL '\n' 61,0-61,1: NAME 'x' 61,2-61,3: OP '=' 61,4-61,8: NUMBER '.314' @@ -219,7 +234,8 @@ 68,4-68,9: NUMBER '3.1e4' 68,9-68,10: NEWLINE '\n' 69,0-69,1: NL '\n' -70,0-70,18: COMMENT '# String literals\n' +70,0-70,17: COMMENT '# String literals' +70,17-70,18: NL '\n' 71,0-71,1: NAME 'x' 71,2-71,3: OP '=' 71,4-71,6: STRING "''" @@ -367,7 +383,8 @@ 125,6-126,3: STRING "uR'''spam\n'''" 126,3-126,4: NEWLINE '\n' 127,0-127,1: NL '\n' -128,0-128,14: COMMENT '# Indentation\n' +128,0-128,13: COMMENT '# Indentation' +128,13-128,14: NL '\n' 129,0-129,2: NAME 'if' 129,3-129,4: NUMBER '1' 129,4-129,5: OP ':' @@ -439,7 +456,8 @@ 142,14-142,15: NUMBER '2' 142,15-142,16: NEWLINE '\n' 143,0-143,1: NL '\n' -144,0-144,12: COMMENT '# Operators\n' +144,0-144,11: COMMENT '# Operators' +144,11-144,12: NL '\n' 145,0-145,1: NL '\n' 146,0-146,0: DEDENT '' 146,0-146,0: DEDENT '' @@ -501,7 +519,8 @@ 149,27-149,28: OP ')' 149,28-149,29: NEWLINE '\n' 150,0-150,1: NL '\n' -151,0-151,13: COMMENT '# comparison\n' +151,0-151,12: COMMENT '# comparison' +151,12-151,13: NL '\n' 152,0-152,2: NAME 'if' 152,3-152,4: NUMBER '1' 152,5-152,6: OP '<' @@ -532,7 +551,8 @@ 152,67-152,71: NAME 'pass' 152,71-152,72: NEWLINE '\n' 153,0-153,1: NL '\n' -154,0-154,9: COMMENT '# binary\n' +154,0-154,8: COMMENT '# binary' +154,8-154,9: NL '\n' 155,0-155,1: NAME 'x' 155,2-155,3: OP '=' 155,4-155,5: NUMBER '1' @@ -552,7 +572,8 @@ 157,8-157,9: NUMBER '1' 157,9-157,10: NEWLINE '\n' 158,0-158,1: NL '\n' -159,0-159,8: COMMENT '# shift\n' +159,0-159,7: COMMENT '# shift' +159,7-159,8: NL '\n' 160,0-160,1: NAME 'x' 160,2-160,3: OP '=' 160,4-160,5: NUMBER '1' @@ -562,7 +583,8 @@ 160,14-160,15: NUMBER '1' 160,15-160,16: NEWLINE '\n' 161,0-161,1: NL '\n' -162,0-162,11: COMMENT '# additive\n' +162,0-162,10: COMMENT '# additive' +162,10-162,11: NL '\n' 163,0-163,1: NAME 'x' 163,2-163,3: OP '=' 163,4-163,5: NUMBER '1' @@ -576,7 +598,8 @@ 163,20-163,21: NUMBER '1' 163,21-163,22: NEWLINE '\n' 164,0-164,1: NL '\n' -165,0-165,17: COMMENT '# multiplicative\n' +165,0-165,16: COMMENT '# multiplicative' +165,16-165,17: NL '\n' 166,0-166,1: NAME 'x' 166,2-166,3: OP '=' 166,4-166,5: NUMBER '1' @@ -588,7 +611,8 @@ 166,16-166,17: NUMBER '1' 166,17-166,18: NEWLINE '\n' 167,0-167,1: NL '\n' -168,0-168,8: COMMENT '# unary\n' +168,0-168,7: COMMENT '# unary' +168,7-168,8: NL '\n' 169,0-169,1: NAME 'x' 169,2-169,3: OP '=' 169,4-169,5: OP '~' @@ -626,7 +650,8 @@ 170,24-170,25: NUMBER '1' 170,25-170,26: NEWLINE '\n' 171,0-171,1: NL '\n' -172,0-172,11: COMMENT '# selector\n' +172,0-172,10: COMMENT '# selector' +172,10-172,11: NL '\n' 173,0-173,6: NAME 'import' 173,7-173,10: NAME 'sys' 173,10-173,11: OP ',' Deleted: /python/branches/p3yk/Lib/test/output/test_types ============================================================================== --- /python/branches/p3yk/Lib/test/output/test_types Wed Dec 13 05:49:30 2006 +++ (empty file) @@ -1,15 +0,0 @@ -test_types -6. Built-in types -6.1 Truth value testing -6.2 Boolean operations -6.3 Comparisons -6.4 Numeric types (mostly conversions) -6.4.1 32-bit integers -6.4.2 Long integers -6.4.3 Floating point numbers -6.5 Sequence types -6.5.1 Strings -6.5.2 Tuples [see test_tuple.py] -6.5.3 Lists [see test_list.py] -6.6 Mappings == Dictionaries [see test_dict.py] -Buffers Deleted: /python/branches/p3yk/Lib/test/output/test_xdrlib ============================================================================== --- /python/branches/p3yk/Lib/test/output/test_xdrlib Wed Dec 13 05:49:30 2006 +++ (empty file) @@ -1,19 +0,0 @@ -test_xdrlib -pack test 0 succeeded -pack test 1 succeeded -pack test 2 succeeded -pack test 3 succeeded -pack test 4 succeeded -pack test 5 succeeded -pack test 6 succeeded -pack test 7 succeeded -pack test 8 succeeded -unpack test 0 succeeded : 9 -unpack test 1 succeeded : True -unpack test 2 succeeded : False -unpack test 3 succeeded : 45 -unpack test 4 succeeded : 1.89999997616 -unpack test 5 succeeded : 1.9 -unpack test 6 succeeded : hello world -unpack test 7 succeeded : [0, 1, 2, 3, 4] -unpack test 8 succeeded : ['what', 'is', 'hapnin', 'doctor'] Modified: python/branches/p3yk/Lib/test/outstanding_bugs.py ============================================================================== --- python/branches/p3yk/Lib/test/outstanding_bugs.py (original) +++ python/branches/p3yk/Lib/test/outstanding_bugs.py Wed Dec 13 05:49:30 2006 @@ -9,19 +9,14 @@ import unittest from test import test_support -class TestBug1385040(unittest.TestCase): - def testSyntaxError(self): - import compiler - - # The following snippet gives a SyntaxError in the interpreter - # - # If you compile and exec it, the call foo(7) returns (7, 1) - self.assertRaises(SyntaxError, compiler.compile, - "def foo(a=1, b): return a, b\n\n", "", "exec") +# +# No test cases for outstanding bugs at the moment. +# def test_main(): - test_support.run_unittest(TestBug1385040) + #test_support.run_unittest() + pass if __name__ == "__main__": test_main() Modified: python/branches/p3yk/Lib/test/string_tests.py ============================================================================== --- python/branches/p3yk/Lib/test/string_tests.py (original) +++ python/branches/p3yk/Lib/test/string_tests.py Wed Dec 13 05:49:30 2006 @@ -1069,7 +1069,7 @@ # from raymond's original specification S = 'http://www.python.org' self.checkequal(('http', '://', 'www.python.org'), S, 'rpartition', '://') - self.checkequal(('http://www.python.org', '', ''), S, 'rpartition', '?') + self.checkequal(('', '', 'http://www.python.org'), S, 'rpartition', '?') self.checkequal(('', 'http://', 'www.python.org'), S, 'rpartition', 'http://') self.checkequal(('http://www.python.', 'org', ''), S, 'rpartition', 'org') Modified: python/branches/p3yk/Lib/test/test_MimeWriter.py ============================================================================== --- python/branches/p3yk/Lib/test/test_MimeWriter.py (original) +++ python/branches/p3yk/Lib/test/test_MimeWriter.py Wed Dec 13 05:49:30 2006 @@ -7,6 +7,8 @@ """ +import unittest, sys, StringIO +from test.test_support import run_unittest from MimeWriter import MimeWriter @@ -77,94 +79,213 @@ ] -def main(): - import sys +OUTPUT = '''\ +From: bwarsaw at cnri.reston.va.us +Date: Mon Feb 12 17:21:48 EST 1996 +To: kss-submit at cnri.reston.va.us +MIME-Version: 1.0 +Content-Type: multipart/knowbot; + boundary="801spam999"; + version="0.1" + +This is a multi-part message in MIME format. + +--801spam999 +Content-Type: multipart/knowbot-metadata; + boundary="802spam999" + + +--802spam999 +Content-Type: message/rfc822 +KP-Metadata-Type: simple +KP-Access: read-only + +KPMD-Interpreter: python +KPMD-Interpreter-Version: 1.3 +KPMD-Owner-Name: Barry Warsaw +KPMD-Owner-Rendezvous: bwarsaw at cnri.reston.va.us +KPMD-Home-KSS: kss.cnri.reston.va.us +KPMD-Identifier: hdl://cnri.kss/my_first_knowbot +KPMD-Launch-Date: Mon Feb 12 16:39:03 EST 1996 + +--802spam999 +Content-Type: text/isl +KP-Metadata-Type: complex +KP-Metadata-Key: connection +KP-Access: read-only +KP-Connection-Description: Barry's Big Bass Business +KP-Connection-Id: B4 +KP-Connection-Direction: client - # Toplevel headers +INTERFACE Seller-1; + +TYPE Seller = OBJECT + DOCUMENTATION "A simple Seller interface to test ILU" + METHODS + price():INTEGER, + END; + +--802spam999 +Content-Type: message/external-body; + access-type="URL"; + URL="hdl://cnri.kss/generic-knowbot" + +Content-Type: text/isl +KP-Metadata-Type: complex +KP-Metadata-Key: generic-interface +KP-Access: read-only +KP-Connection-Description: Generic Interface for All Knowbots +KP-Connection-Id: generic-kp +KP-Connection-Direction: client + + +--802spam999-- + +--801spam999 +Content-Type: multipart/knowbot-code; + boundary="803spam999" + + +--803spam999 +Content-Type: text/plain +KP-Module-Name: BuyerKP + +class Buyer: + def __setup__(self, maxprice): + self._maxprice = maxprice + + def __main__(self, kos): + """Entry point upon arrival at a new KOS.""" + broker = kos.broker() + # B4 == Barry's Big Bass Business :-) + seller = broker.lookup('Seller_1.Seller', 'B4') + if seller: + price = seller.price() + print 'Seller wants $', price, '... ' + if price > self._maxprice: + print 'too much!' + else: + print "I'll take it!" + else: + print 'no seller found here' + +--803spam999-- + +--801spam999 +Content-Type: multipart/knowbot-state; + boundary="804spam999" +KP-Main-Module: main + + +--804spam999 +Content-Type: text/plain +KP-Module-Name: main + +# instantiate a buyer instance and put it in a magic place for the KOS +# to find. +__kp__ = Buyer() +__kp__.__setup__(500) + +--804spam999-- + +--801spam999-- +''' + +class MimewriterTest(unittest.TestCase): + + def test(self): + buf = StringIO.StringIO() + + # Toplevel headers + + toplevel = MimeWriter(buf) + toplevel.addheader("From", "bwarsaw at cnri.reston.va.us") + toplevel.addheader("Date", "Mon Feb 12 17:21:48 EST 1996") + toplevel.addheader("To", "kss-submit at cnri.reston.va.us") + toplevel.addheader("MIME-Version", "1.0") - toplevel = MimeWriter(sys.stdout) - toplevel.addheader("From", "bwarsaw at cnri.reston.va.us") - toplevel.addheader("Date", "Mon Feb 12 17:21:48 EST 1996") - toplevel.addheader("To", "kss-submit at cnri.reston.va.us") - toplevel.addheader("MIME-Version", "1.0") + # Toplevel body parts - # Toplevel body parts + f = toplevel.startmultipartbody("knowbot", "801spam999", + [("version", "0.1")], prefix=0) + f.write("This is a multi-part message in MIME format.\n") - f = toplevel.startmultipartbody("knowbot", "801spam999", - [("version", "0.1")], prefix=0) - f.write("This is a multi-part message in MIME format.\n") + # First toplevel body part: metadata - # First toplevel body part: metadata + md = toplevel.nextpart() + md.startmultipartbody("knowbot-metadata", "802spam999") - md = toplevel.nextpart() - md.startmultipartbody("knowbot-metadata", "802spam999") + # Metadata part 1 - # Metadata part 1 + md1 = md.nextpart() + md1.addheader("KP-Metadata-Type", "simple") + md1.addheader("KP-Access", "read-only") + m = MimeWriter(md1.startbody("message/rfc822")) + for key, value in SIMPLE_METADATA: + m.addheader("KPMD-" + key, value) + m.flushheaders() + del md1 - md1 = md.nextpart() - md1.addheader("KP-Metadata-Type", "simple") - md1.addheader("KP-Access", "read-only") - m = MimeWriter(md1.startbody("message/rfc822")) - for key, value in SIMPLE_METADATA: - m.addheader("KPMD-" + key, value) - m.flushheaders() - del md1 + # Metadata part 2 - # Metadata part 2 + md2 = md.nextpart() + for key, value in COMPLEX_METADATA: + md2.addheader("KP-" + key, value) + f = md2.startbody("text/isl") + f.write(SELLER) + del md2 - md2 = md.nextpart() - for key, value in COMPLEX_METADATA: - md2.addheader("KP-" + key, value) - f = md2.startbody("text/isl") - f.write(SELLER) - del md2 + # Metadata part 3 - # Metadata part 3 + md3 = md.nextpart() + f = md3.startbody("message/external-body", + [("access-type", "URL"), + ("URL", "hdl://cnri.kss/generic-knowbot")]) + m = MimeWriter(f) + for key, value in EXTERNAL_METADATA: + md3.addheader("KP-" + key, value) + md3.startbody("text/isl") + # Phantom body doesn't need to be written - md3 = md.nextpart() - f = md3.startbody("message/external-body", - [("access-type", "URL"), - ("URL", "hdl://cnri.kss/generic-knowbot")]) - m = MimeWriter(f) - for key, value in EXTERNAL_METADATA: - md3.addheader("KP-" + key, value) - md3.startbody("text/isl") - # Phantom body doesn't need to be written + md.lastpart() - md.lastpart() + # Second toplevel body part: code - # Second toplevel body part: code + code = toplevel.nextpart() + code.startmultipartbody("knowbot-code", "803spam999") - code = toplevel.nextpart() - code.startmultipartbody("knowbot-code", "803spam999") + # Code: buyer program source - # Code: buyer program source + buyer = code.nextpart() + buyer.addheader("KP-Module-Name", "BuyerKP") + f = buyer.startbody("text/plain") + f.write(BUYER) - buyer = code.nextpart() - buyer.addheader("KP-Module-Name", "BuyerKP") - f = buyer.startbody("text/plain") - f.write(BUYER) + code.lastpart() - code.lastpart() + # Third toplevel body part: state - # Third toplevel body part: state + state = toplevel.nextpart() + state.addheader("KP-Main-Module", "main") + state.startmultipartbody("knowbot-state", "804spam999") - state = toplevel.nextpart() - state.addheader("KP-Main-Module", "main") - state.startmultipartbody("knowbot-state", "804spam999") + # State: a bunch of assignments - # State: a bunch of assignments + st = state.nextpart() + st.addheader("KP-Module-Name", "main") + f = st.startbody("text/plain") + f.write(STATE) - st = state.nextpart() - st.addheader("KP-Module-Name", "main") - f = st.startbody("text/plain") - f.write(STATE) + state.lastpart() - state.lastpart() + # End toplevel body parts - # End toplevel body parts + toplevel.lastpart() - toplevel.lastpart() + self.assertEqual(buf.getvalue(), OUTPUT) +def test_main(): + run_unittest(MimewriterTest) -main() +if __name__ == '__main__': + test_main() Modified: python/branches/p3yk/Lib/test/test_StringIO.py ============================================================================== --- python/branches/p3yk/Lib/test/test_StringIO.py (original) +++ python/branches/p3yk/Lib/test/test_StringIO.py Wed Dec 13 05:49:30 2006 @@ -62,6 +62,7 @@ eq(f.getvalue(), 'abcde') f.write('xyz') eq(f.getvalue(), 'abcdexyz') + self.assertRaises(IOError, f.truncate, -1) f.close() self.assertRaises(ValueError, f.write, 'frobnitz') @@ -120,6 +121,28 @@ class TestcStringIO(TestGenericStringIO): MODULE = cStringIO + def test_unicode(self): + + if not test_support.have_unicode: return + + # The cStringIO module converts Unicode strings to character + # strings when writing them to cStringIO objects. + # Check that this works. + + f = self.MODULE.StringIO() + f.write(unicode(self._line[:5])) + s = f.getvalue() + self.assertEqual(s, 'abcde') + self.assertEqual(type(s), types.StringType) + + f = self.MODULE.StringIO(unicode(self._line[:5])) + s = f.getvalue() + self.assertEqual(s, 'abcde') + self.assertEqual(type(s), types.StringType) + + self.assertRaises(UnicodeEncodeError, self.MODULE.StringIO, + unicode('\xf4', 'latin-1')) + import sys if sys.platform.startswith('java'): # Jython doesn't have a buffer object, so we just do a useless Modified: python/branches/p3yk/Lib/test/test___future__.py ============================================================================== --- python/branches/p3yk/Lib/test/test___future__.py (original) +++ python/branches/p3yk/Lib/test/test___future__.py Wed Dec 13 05:49:30 2006 @@ -1,59 +1,63 @@ #! /usr/bin/env python -from test.test_support import verbose, verify -from types import TupleType, StringType, IntType +import unittest +from test import test_support import __future__ GOOD_SERIALS = ("alpha", "beta", "candidate", "final") features = __future__.all_feature_names -# Verify that all_feature_names appears correct. -given_feature_names = features[:] -for name in dir(__future__): - obj = getattr(__future__, name, None) - if obj is not None and isinstance(obj, __future__._Feature): - verify(name in given_feature_names, - "%r should have been in all_feature_names" % name) - given_feature_names.remove(name) -verify(len(given_feature_names) == 0, - "all_feature_names has too much: %r" % given_feature_names) -del given_feature_names - -for feature in features: - value = getattr(__future__, feature) - if verbose: - print "Checking __future__ ", feature, "value", value - - optional = value.getOptionalRelease() - mandatory = value.getMandatoryRelease() - - verify(type(optional) is TupleType, "optional isn't tuple") - verify(len(optional) == 5, "optional isn't 5-tuple") - major, minor, micro, level, serial = optional - verify(type(major) is IntType, "optional major isn't int") - verify(type(minor) is IntType, "optional minor isn't int") - verify(type(micro) is IntType, "optional micro isn't int") - verify(isinstance(level, basestring), "optional level isn't string") - verify(level in GOOD_SERIALS, - "optional level string has unknown value") - verify(type(serial) is IntType, "optional serial isn't int") - - verify(type(mandatory) is TupleType or - mandatory is None, "mandatory isn't tuple or None") - if mandatory is not None: - verify(len(mandatory) == 5, "mandatory isn't 5-tuple") - major, minor, micro, level, serial = mandatory - verify(type(major) is IntType, "mandatory major isn't int") - verify(type(minor) is IntType, "mandatory minor isn't int") - verify(type(micro) is IntType, "mandatory micro isn't int") - verify(isinstance(level, basestring), "mandatory level isn't string") - verify(level in GOOD_SERIALS, - "mandatory serial string has unknown value") - verify(type(serial) is IntType, "mandatory serial isn't int") - verify(optional < mandatory, - "optional not less than mandatory, and mandatory not None") - - verify(hasattr(value, "compiler_flag"), - "feature is missing a .compiler_flag attr") - verify(type(getattr(value, "compiler_flag")) is IntType, - ".compiler_flag isn't int") +class FutureTest(unittest.TestCase): + + def test_names(self): + # Verify that all_feature_names appears correct. + given_feature_names = features[:] + for name in dir(__future__): + obj = getattr(__future__, name, None) + if obj is not None and isinstance(obj, __future__._Feature): + self.assert_( + name in given_feature_names, + "%r should have been in all_feature_names" % name + ) + given_feature_names.remove(name) + self.assertEqual(len(given_feature_names), 0, + "all_feature_names has too much: %r" % given_feature_names) + + def test_attributes(self): + for feature in features: + value = getattr(__future__, feature) + + optional = value.getOptionalRelease() + mandatory = value.getMandatoryRelease() + + a = self.assert_ + e = self.assertEqual + def check(t, name): + a(isinstance(t, tuple), "%s isn't tuple" % name) + e(len(t), 5, "%s isn't 5-tuple" % name) + (major, minor, micro, level, serial) = t + a(isinstance(major, int), "%s major isn't int" % name) + a(isinstance(minor, int), "%s minor isn't int" % name) + a(isinstance(micro, int), "%s micro isn't int" % name) + a(isinstance(level, basestring), + "%s level isn't string" % name) + a(level in GOOD_SERIALS, + "%s level string has unknown value" % name) + a(isinstance(serial, int), "%s serial isn't int" % name) + + check(optional, "optional") + if mandatory is not None: + check(mandatory, "mandatory") + a(optional < mandatory, + "optional not less than mandatory, and mandatory not None") + + a(hasattr(value, "compiler_flag"), + "feature is missing a .compiler_flag attr") + a(isinstance(getattr(value, "compiler_flag"), int), + ".compiler_flag isn't int") + +def test_main(): + test_support.run_unittest(FutureTest) + +if __name__ == "__main__": + test_main() Modified: python/branches/p3yk/Lib/test/test_array.py ============================================================================== --- python/branches/p3yk/Lib/test/test_array.py (original) +++ python/branches/p3yk/Lib/test/test_array.py Wed Dec 13 05:49:30 2006 @@ -85,6 +85,13 @@ self.assertNotEqual(id(a), id(b)) self.assertEqual(a, b) + def test_deepcopy(self): + import copy + a = array.array(self.typecode, self.example) + b = copy.deepcopy(a) + self.assertNotEqual(id(a), id(b)) + self.assertEqual(a, b) + def test_pickle(self): for protocol in (0, 1, 2): a = array.array(self.typecode, self.example) Modified: python/branches/p3yk/Lib/test/test_binascii.py ============================================================================== --- python/branches/p3yk/Lib/test/test_binascii.py (original) +++ python/branches/p3yk/Lib/test/test_binascii.py Wed Dec 13 05:49:30 2006 @@ -134,7 +134,7 @@ pass else: self.fail("binascii.a2b_qp(**{1:1}) didn't raise TypeError") - self.assertEqual(binascii.a2b_qp("= "), "") + self.assertEqual(binascii.a2b_qp("= "), "= ") self.assertEqual(binascii.a2b_qp("=="), "=") self.assertEqual(binascii.a2b_qp("=AX"), "=AX") self.assertRaises(TypeError, binascii.b2a_qp, foo="bar") Modified: python/branches/p3yk/Lib/test/test_bufio.py ============================================================================== --- python/branches/p3yk/Lib/test/test_bufio.py (original) +++ python/branches/p3yk/Lib/test/test_bufio.py Wed Dec 13 05:49:30 2006 @@ -1,60 +1,66 @@ -from test.test_support import verify, TestFailed, TESTFN +import unittest +from test import test_support # Simple test to ensure that optimizations in fileobject.c deliver # the expected results. For best testing, run this under a debug-build # Python too (to exercise asserts in the C code). -# Repeat string 'pattern' as often as needed to reach total length -# 'length'. Then call try_one with that string, a string one larger -# than that, and a string one smaller than that. The main driver -# feeds this all small sizes and various powers of 2, so we exercise -# all likely stdio buffer sizes, and "off by one" errors on both -# sides. -def drive_one(pattern, length): - q, r = divmod(length, len(pattern)) - teststring = pattern * q + pattern[:r] - verify(len(teststring) == length) - try_one(teststring) - try_one(teststring + "x") - try_one(teststring[:-1]) - -# Write s + "\n" + s to file, then open it and ensure that successive -# .readline()s deliver what we wrote. -def try_one(s): - # Since C doesn't guarantee we can write/read arbitrary bytes in text - # files, use binary mode. - f = open(TESTFN, "wb") - # write once with \n and once without - f.write(s) - f.write("\n") - f.write(s) - f.close() - f = open(TESTFN, "rb") - line = f.readline() - if line != s + "\n": - raise TestFailed("Expected %r got %r" % (s + "\n", line)) - line = f.readline() - if line != s: - raise TestFailed("Expected %r got %r" % (s, line)) - line = f.readline() - if line: - raise TestFailed("Expected EOF but got %r" % line) - f.close() - -# A pattern with prime length, to avoid simple relationships with -# stdio buffer sizes. -primepat = "1234567890\00\01\02\03\04\05\06" - -nullpat = "\0" * 1000 - -try: - for size in range(1, 257) + [512, 1000, 1024, 2048, 4096, 8192, 10000, - 16384, 32768, 65536, 1000000]: - drive_one(primepat, size) - drive_one(nullpat, size) -finally: - try: - import os - os.unlink(TESTFN) - except: - pass +lengths = range(1, 257) + [512, 1000, 1024, 2048, 4096, 8192, 10000, + 16384, 32768, 65536, 1000000] + +class BufferSizeTest(unittest.TestCase): + def try_one(self, s): + # Write s + "\n" + s to file, then open it and ensure that successive + # .readline()s deliver what we wrote. + + # Since C doesn't guarantee we can write/read arbitrary bytes in text + # files, use binary mode. + f = open(test_support.TESTFN, "wb") + try: + # write once with \n and once without + f.write(s) + f.write("\n") + f.write(s) + f.close() + f = open(test_support.TESTFN, "rb") + line = f.readline() + self.assertEqual(line, s + "\n") + line = f.readline() + self.assertEqual(line, s) + line = f.readline() + self.assert_(not line) # Must be at EOF + f.close() + finally: + try: + import os + os.unlink(test_support.TESTFN) + except: + pass + + def drive_one(self, pattern): + for length in lengths: + # Repeat string 'pattern' as often as needed to reach total length + # 'length'. Then call try_one with that string, a string one larger + # than that, and a string one smaller than that. Try this with all + # small sizes and various powers of 2, so we exercise all likely + # stdio buffer sizes, and "off by one" errors on both sides. + q, r = divmod(length, len(pattern)) + teststring = pattern * q + pattern[:r] + self.assertEqual(len(teststring), length) + self.try_one(teststring) + self.try_one(teststring + "x") + self.try_one(teststring[:-1]) + + def test_primepat(self): + # A pattern with prime length, to avoid simple relationships with + # stdio buffer sizes. + self.drive_one("1234567890\00\01\02\03\04\05\06") + + def test_nullpat(self): + self.drive_one("\0" * 1000) + +def test_main(): + test_support.run_unittest(BufferSizeTest) + +if __name__ == "__main__": + test_main() Modified: python/branches/p3yk/Lib/test/test_builtin.py ============================================================================== --- python/branches/p3yk/Lib/test/test_builtin.py (original) +++ python/branches/p3yk/Lib/test/test_builtin.py Wed Dec 13 05:49:30 2006 @@ -116,6 +116,7 @@ self.assertEqual(abs(0), 0) self.assertEqual(abs(1234), 1234) self.assertEqual(abs(-1234), 1234) + self.assertTrue(abs(-sys.maxint-1) > 0) # float self.assertEqual(abs(0.0), 0.0) self.assertEqual(abs(3.14), 3.14) @@ -155,6 +156,11 @@ S = [10, 20, 30] self.assertEqual(any(x > 42 for x in S), False) + def test_neg(self): + x = -sys.maxint-1 + self.assert_(isinstance(x, int)) + self.assertEqual(-x, sys.maxint+1) + def test_callable(self): self.assert_(callable(len)) def f(): pass @@ -686,9 +692,11 @@ pass s = repr(-1-sys.maxint) - self.assertEqual(int(s)+1, -sys.maxint) + x = int(s) + self.assertEqual(x+1, -sys.maxint) + self.assert_(isinstance(x, int)) # should return long - int(s[1:]) + self.assertEqual(int(s[1:]), sys.maxint+1) # should return long x = int(1e100) @@ -706,6 +714,11 @@ self.assertRaises(ValueError, int, '123\0') self.assertRaises(ValueError, int, '53', 40) + # SF bug 1545497: embedded NULs were not detected with + # explicit base + self.assertRaises(ValueError, int, '123\0', 10) + self.assertRaises(ValueError, int, '123\x00 245', 20) + x = int('1' * 600) self.assert_(isinstance(x, long)) Modified: python/branches/p3yk/Lib/test/test_cfgparser.py ============================================================================== --- python/branches/p3yk/Lib/test/test_cfgparser.py (original) +++ python/branches/p3yk/Lib/test/test_cfgparser.py Wed Dec 13 05:49:30 2006 @@ -1,9 +1,29 @@ import ConfigParser import StringIO import unittest +import UserDict from test import test_support +class SortedDict(UserDict.UserDict): + def items(self): + result = self.data.items() + result.sort() + return result + + def keys(self): + result = self.data.keys() + result.sort() + return result + + def values(self): + result = self.items() + return [i[1] for i in values] + + def iteritems(self): return iter(self.items()) + def iterkeys(self): return iter(self.keys()) + __iter__ = iterkeys + def itervalues(self): return iter(self.values()) class TestCaseBase(unittest.TestCase): def newconfig(self, defaults=None): @@ -414,12 +434,36 @@ self.assertRaises(TypeError, cf.set, "sect", "option2", 1.0) self.assertRaises(TypeError, cf.set, "sect", "option2", object()) +class SortedTestCase(RawConfigParserTestCase): + def newconfig(self, defaults=None): + self.cf = self.config_class(defaults=defaults, dict_type=SortedDict) + return self.cf + + def test_sorted(self): + self.fromstring("[b]\n" + "o4=1\n" + "o3=2\n" + "o2=3\n" + "o1=4\n" + "[a]\n" + "k=v\n") + output = StringIO.StringIO() + self.cf.write(output) + self.assertEquals(output.getvalue(), + "[a]\n" + "k = v\n\n" + "[b]\n" + "o1 = 4\n" + "o2 = 3\n" + "o3 = 2\n" + "o4 = 1\n\n") def test_main(): test_support.run_unittest( ConfigParserTestCase, RawConfigParserTestCase, - SafeConfigParserTestCase + SafeConfigParserTestCase, + SortedTestCase ) if __name__ == "__main__": Modified: python/branches/p3yk/Lib/test/test_cgi.py ============================================================================== --- python/branches/p3yk/Lib/test/test_cgi.py (original) +++ python/branches/p3yk/Lib/test/test_cgi.py Wed Dec 13 05:49:30 2006 @@ -1,8 +1,9 @@ -from test.test_support import verify, verbose +from test.test_support import run_unittest import cgi import os import sys import tempfile +import unittest from StringIO import StringIO class HackedSysModule: @@ -127,119 +128,124 @@ def first_second_elts(list): return map(lambda p:(p[0], p[1][0]), list) -def main(): - for orig, expect in parse_qsl_test_cases: - result = cgi.parse_qsl(orig, keep_blank_values=True) - print repr(orig), '=>', result - verify(result == expect, "Error parsing %s" % repr(orig)) - - for orig, expect in parse_strict_test_cases: - # Test basic parsing - print repr(orig) - d = do_test(orig, "GET") - verify(d == expect, "Error parsing %s" % repr(orig)) - d = do_test(orig, "POST") - verify(d == expect, "Error parsing %s" % repr(orig)) - - env = {'QUERY_STRING': orig} - fcd = cgi.FormContentDict(env) - sd = cgi.SvFormContentDict(env) - fs = cgi.FieldStorage(environ=env) - if type(expect) == type({}): - # test dict interface - verify(len(expect) == len(fcd)) - verify(norm(expect.keys()) == norm(fcd.keys())) - verify(norm(expect.values()) == norm(fcd.values())) - verify(norm(expect.items()) == norm(fcd.items())) - verify(fcd.get("nonexistent field", "default") == "default") - verify(len(sd) == len(fs)) - verify(norm(sd.keys()) == norm(fs.keys())) - verify(fs.getvalue("nonexistent field", "default") == "default") - # test individual fields - for key in expect.keys(): - expect_val = expect[key] - verify(key in fcd) - verify(norm(fcd[key]) == norm(expect[key])) - verify(fcd.get(key, "default") == fcd[key]) - verify(key in fs) - if len(expect_val) > 1: - single_value = 0 - else: - single_value = 1 - try: - val = sd[key] - except IndexError: - verify(not single_value) - verify(fs.getvalue(key) == expect_val) +class CgiTests(unittest.TestCase): + + def test_qsl(self): + for orig, expect in parse_qsl_test_cases: + result = cgi.parse_qsl(orig, keep_blank_values=True) + self.assertEqual(result, expect, "Error parsing %s" % repr(orig)) + + def test_strict(self): + for orig, expect in parse_strict_test_cases: + # Test basic parsing + d = do_test(orig, "GET") + self.assertEqual(d, expect, "Error parsing %s" % repr(orig)) + d = do_test(orig, "POST") + self.assertEqual(d, expect, "Error parsing %s" % repr(orig)) + + env = {'QUERY_STRING': orig} + fcd = cgi.FormContentDict(env) + sd = cgi.SvFormContentDict(env) + fs = cgi.FieldStorage(environ=env) + if type(expect) == type({}): + # test dict interface + self.assertEqual(len(expect), len(fcd)) + self.assertEqual(norm(expect.keys()), norm(fcd.keys())) + self.assertEqual(norm(expect.values()), norm(fcd.values())) + self.assertEqual(norm(expect.items()), norm(fcd.items())) + self.assertEqual(fcd.get("nonexistent field", "default"), "default") + self.assertEqual(len(sd), len(fs)) + self.assertEqual(norm(sd.keys()), norm(fs.keys())) + self.assertEqual(fs.getvalue("nonexistent field", "default"), "default") + # test individual fields + for key in expect.keys(): + expect_val = expect[key] + self.assert_(key in fcd) + self.assertEqual(norm(fcd[key]), norm(expect[key])) + self.assertEqual(fcd.get(key, "default"), fcd[key]) + self.assert_(key in fs) + if len(expect_val) > 1: + single_value = 0 + else: + single_value = 1 + try: + val = sd[key] + except IndexError: + self.failIf(single_value) + self.assertEqual(fs.getvalue(key), expect_val) + else: + self.assert_(single_value) + self.assertEqual(val, expect_val[0]) + self.assertEqual(fs.getvalue(key), expect_val[0]) + self.assertEqual(norm(sd.getlist(key)), norm(expect_val)) + if single_value: + self.assertEqual(norm(sd.values()), + first_elts(norm(expect.values()))) + self.assertEqual(norm(sd.items()), + first_second_elts(norm(expect.items()))) + + def test_weird_formcontentdict(self): + # Test the weird FormContentDict classes + env = {'QUERY_STRING': "x=1&y=2.0&z=2-3.%2b0&1=1abc"} + expect = {'x': 1, 'y': 2.0, 'z': '2-3.+0', '1': '1abc'} + d = cgi.InterpFormContentDict(env) + for k, v in expect.items(): + self.assertEqual(d[k], v) + for k, v in d.items(): + self.assertEqual(expect[k], v) + self.assertEqual(norm(expect.values()), norm(d.values())) + + def test_log(self): + cgi.log("Testing") + + cgi.logfp = StringIO() + cgi.initlog("%s", "Testing initlog 1") + cgi.log("%s", "Testing log 2") + self.assertEqual(cgi.logfp.getvalue(), "Testing initlog 1\nTesting log 2\n") + if os.path.exists("/dev/null"): + cgi.logfp = None + cgi.logfile = "/dev/null" + cgi.initlog("%s", "Testing log 3") + cgi.log("Testing log 4") + + def test_fieldstorage_readline(self): + # FieldStorage uses readline, which has the capacity to read all + # contents of the input file into memory; we use readline's size argument + # to prevent that for files that do not contain any newlines in + # non-GET/HEAD requests + class TestReadlineFile: + def __init__(self, file): + self.file = file + self.numcalls = 0 + + def readline(self, size=None): + self.numcalls += 1 + if size: + return self.file.readline(size) else: - verify(single_value) - verify(val == expect_val[0]) - verify(fs.getvalue(key) == expect_val[0]) - verify(norm(sd.getlist(key)) == norm(expect_val)) - if single_value: - verify(norm(sd.values()) == \ - first_elts(norm(expect.values()))) - verify(norm(sd.items()) == \ - first_second_elts(norm(expect.items()))) - - # Test the weird FormContentDict classes - env = {'QUERY_STRING': "x=1&y=2.0&z=2-3.%2b0&1=1abc"} - expect = {'x': 1, 'y': 2.0, 'z': '2-3.+0', '1': '1abc'} - d = cgi.InterpFormContentDict(env) - for k, v in expect.items(): - verify(d[k] == v) - for k, v in d.items(): - verify(expect[k] == v) - verify(norm(expect.values()) == norm(d.values())) - - print "Testing log" - cgi.log("Testing") - cgi.logfp = sys.stdout - cgi.initlog("%s", "Testing initlog 1") - cgi.log("%s", "Testing log 2") - if os.path.exists("/dev/null"): - cgi.logfp = None - cgi.logfile = "/dev/null" - cgi.initlog("%s", "Testing log 3") - cgi.log("Testing log 4") - - print "Test FieldStorage methods that use readline" - # FieldStorage uses readline, which has the capacity to read all - # contents of the input file into memory; we use readline's size argument - # to prevent that for files that do not contain any newlines in - # non-GET/HEAD requests - class TestReadlineFile: - def __init__(self, file): - self.file = file - self.numcalls = 0 - - def readline(self, size=None): - self.numcalls += 1 - if size: - return self.file.readline(size) - else: - return self.file.readline() - - def __getattr__(self, name): - file = self.__dict__['file'] - a = getattr(file, name) - if not isinstance(a, int): - setattr(self, name, a) - return a - - f = TestReadlineFile(tempfile.TemporaryFile()) - f.write('x' * 256 * 1024) - f.seek(0) - env = {'REQUEST_METHOD':'PUT'} - fs = cgi.FieldStorage(fp=f, environ=env) - # if we're not chunking properly, readline is only called twice - # (by read_binary); if we are chunking properly, it will be called 5 times - # as long as the chunksize is 1 << 16. - verify(f.numcalls > 2) - - print "Test basic FieldStorage multipart parsing" - env = {'REQUEST_METHOD':'POST', 'CONTENT_TYPE':'multipart/form-data; boundary=---------------------------721837373350705526688164684', 'CONTENT_LENGTH':'558'} - postdata = """-----------------------------721837373350705526688164684 + return self.file.readline() + + def __getattr__(self, name): + file = self.__dict__['file'] + a = getattr(file, name) + if not isinstance(a, int): + setattr(self, name, a) + return a + + f = TestReadlineFile(tempfile.TemporaryFile()) + f.write('x' * 256 * 1024) + f.seek(0) + env = {'REQUEST_METHOD':'PUT'} + fs = cgi.FieldStorage(fp=f, environ=env) + # if we're not chunking properly, readline is only called twice + # (by read_binary); if we are chunking properly, it will be called 5 times + # as long as the chunksize is 1 << 16. + self.assert_(f.numcalls > 2) + + def test_fieldstorage_multipart(self): + #Test basic FieldStorage multipart parsing + env = {'REQUEST_METHOD':'POST', 'CONTENT_TYPE':'multipart/form-data; boundary=---------------------------721837373350705526688164684', 'CONTENT_LENGTH':'558'} + postdata = """-----------------------------721837373350705526688164684 Content-Disposition: form-data; name="id" 1234 @@ -259,15 +265,19 @@ Add\x20 -----------------------------721837373350705526688164684-- """ - fs = cgi.FieldStorage(fp=StringIO(postdata), environ=env) - verify(len(fs.list) == 4) - expect = [{'name':'id', 'filename':None, 'value':'1234'}, - {'name':'title', 'filename':None, 'value':''}, - {'name':'file', 'filename':'test.txt','value':'Testing 123.\n'}, - {'name':'submit', 'filename':None, 'value':' Add '}] - for x in range(len(fs.list)): - for k, exp in expect[x].items(): - got = getattr(fs.list[x], k) - verify(got == exp) + fs = cgi.FieldStorage(fp=StringIO(postdata), environ=env) + self.assertEquals(len(fs.list), 4) + expect = [{'name':'id', 'filename':None, 'value':'1234'}, + {'name':'title', 'filename':None, 'value':''}, + {'name':'file', 'filename':'test.txt','value':'Testing 123.\n'}, + {'name':'submit', 'filename':None, 'value':' Add '}] + for x in range(len(fs.list)): + for k, exp in expect[x].items(): + got = getattr(fs.list[x], k) + self.assertEquals(got, exp) + +def test_main(): + run_unittest(CgiTests) -main() +if __name__ == '__main__': + test_main() Modified: python/branches/p3yk/Lib/test/test_class.py ============================================================================== --- python/branches/p3yk/Lib/test/test_class.py (original) +++ python/branches/p3yk/Lib/test/test_class.py Wed Dec 13 05:49:30 2006 @@ -186,6 +186,14 @@ # List/dict operations +class Empty: pass + +try: + 1 in Empty() + print 'failed, should have raised TypeError' +except TypeError: + pass + 1 in testme testme[1] Modified: python/branches/p3yk/Lib/test/test_codecencodings_cn.py ============================================================================== --- python/branches/p3yk/Lib/test/test_codecencodings_cn.py (original) +++ python/branches/p3yk/Lib/test/test_codecencodings_cn.py Wed Dec 13 05:49:30 2006 @@ -32,6 +32,7 @@ ("abc\x80\x80\xc1\xc4\xc8", "replace", u"abc\ufffd\u804a\ufffd"), ("abc\x80\x80\xc1\xc4", "ignore", u"abc\u804a"), ("\x83\x34\x83\x31", "strict", None), + (u"\u30fb", "strict", None), ) class Test_GB18030(test_multibytecodec_support.TestBase, unittest.TestCase): @@ -45,6 +46,7 @@ ("abc\x80\x80\xc1\xc4\xc8", "replace", u"abc\ufffd\u804a\ufffd"), ("abc\x80\x80\xc1\xc4", "ignore", u"abc\u804a"), ("abc\x84\x39\x84\x39\xc1\xc4", "replace", u"abc\ufffd\u804a"), + (u"\u30fb", "strict", "\x819\xa79"), ) has_iso10646 = True Modified: python/branches/p3yk/Lib/test/test_codecs.py ============================================================================== --- python/branches/p3yk/Lib/test/test_codecs.py (original) +++ python/branches/p3yk/Lib/test/test_codecs.py Wed Dec 13 05:49:30 2006 @@ -425,6 +425,10 @@ ] ) + def test_bug1601501(self): + # SF bug #1601501: check that the codec works with a buffer + unicode("\xef\xbb\xbf", "utf-8-sig") + class EscapeDecodeTest(unittest.TestCase): def test_empty(self): self.assertEquals(codecs.escape_decode(""), ("", 0)) @@ -910,6 +914,18 @@ f = self.reader(self.stream) self.assertEquals(f.readlines(), [u'\ud55c\n', u'\uae00']) +class EncodedFileTest(unittest.TestCase): + + def test_basic(self): + f = StringIO.StringIO('\xed\x95\x9c\n\xea\xb8\x80') + ef = codecs.EncodedFile(f, 'utf-16-le', 'utf-8') + self.assertEquals(ef.read(), '\\\xd5\n\x00\x00\xae') + + f = StringIO.StringIO() + ef = codecs.EncodedFile(f, 'utf-8', 'latin1') + ef.write('\xc3\xbc') + self.assertEquals(f.getvalue(), '\xfc') + class Str2StrTest(unittest.TestCase): def test_read(self): @@ -1050,6 +1066,14 @@ "punycode", "unicode_internal" ] +broken_incremental_coders = broken_unicode_with_streams[:] + +# The following encodings only support "strict" mode +only_strict_mode = [ + "idna", + "zlib_codec", + "bz2_codec", +] try: import bz2 @@ -1099,6 +1123,7 @@ decodedresult += reader.read() self.assertEqual(decodedresult, s, "%r != %r (encoding=%r)" % (decodedresult, s, encoding)) + if encoding not in broken_incremental_coders: # check incremental decoder/encoder (fetched via the Python # and C API) and iterencode()/iterdecode() try: @@ -1139,6 +1164,24 @@ result = u"".join(codecs.iterdecode(codecs.iterencode(u"", encoding), encoding)) self.assertEqual(result, u"") + if encoding not in only_strict_mode: + # check incremental decoder/encoder with errors argument + try: + encoder = codecs.getincrementalencoder(encoding)("ignore") + cencoder = _testcapi.codec_incrementalencoder(encoding, "ignore") + except LookupError: # no IncrementalEncoder + pass + else: + encodedresult = "".join(encoder.encode(c) for c in s) + decoder = codecs.getincrementaldecoder(encoding)("ignore") + decodedresult = u"".join(decoder.decode(c) for c in encodedresult) + self.assertEqual(decodedresult, s, "%r != %r (encoding=%r)" % (decodedresult, s, encoding)) + + encodedresult = "".join(cencoder.encode(c) for c in s) + cdecoder = _testcapi.codec_incrementaldecoder(encoding, "ignore") + decodedresult = u"".join(cdecoder.decode(c) for c in encodedresult) + self.assertEqual(decodedresult, s, "%r != %r (encoding=%r)" % (decodedresult, s, encoding)) + def test_seek(self): # all codecs should be able to encode these s = u"%s\n%s\n" % (100*u"abc123", 100*u"def456") @@ -1214,6 +1257,19 @@ (u"", len(allbytes)) ) +class WithStmtTest(unittest.TestCase): + def test_encodedfile(self): + f = StringIO.StringIO("\xc3\xbc") + with codecs.EncodedFile(f, "latin-1", "utf-8") as ef: + self.assertEquals(ef.read(), "\xfc") + + def test_streamreaderwriter(self): + f = StringIO.StringIO("\xc3\xbc") + info = codecs.lookup("utf-8") + with codecs.StreamReaderWriter(f, info.streamreader, + info.streamwriter, 'strict') as srw: + self.assertEquals(srw.read(), u"\xfc") + def test_main(): test_support.run_unittest( @@ -1234,10 +1290,12 @@ IDNACodecTest, CodecsModuleTest, StreamReaderTest, + EncodedFileTest, Str2StrTest, BasicUnicodeTest, BasicStrTest, - CharmapTest + CharmapTest, + WithStmtTest, ) Modified: python/branches/p3yk/Lib/test/test_contextlib.py ============================================================================== --- python/branches/p3yk/Lib/test/test_contextlib.py (original) +++ python/branches/p3yk/Lib/test/test_contextlib.py Wed Dec 13 05:49:30 2006 @@ -330,32 +330,6 @@ return True self.boilerPlate(lock, locked) -class DecimalContextTestCase(unittest.TestCase): - - # XXX Somebody should write more thorough tests for this - - def testBasic(self): - ctx = decimal.getcontext() - orig_context = ctx.copy() - try: - ctx.prec = save_prec = decimal.ExtendedContext.prec + 5 - with decimal.ExtendedContext.get_manager(): - self.assertEqual(decimal.getcontext().prec, - decimal.ExtendedContext.prec) - self.assertEqual(decimal.getcontext().prec, save_prec) - try: - with decimal.ExtendedContext.get_manager(): - self.assertEqual(decimal.getcontext().prec, - decimal.ExtendedContext.prec) - 1/0 - except ZeroDivisionError: - self.assertEqual(decimal.getcontext().prec, save_prec) - else: - self.fail("Didn't raise ZeroDivisionError") - finally: - decimal.setcontext(orig_context) - - # This is needed to make the test actually run under regrtest.py! def test_main(): run_suite( Modified: python/branches/p3yk/Lib/test/test_cookie.py ============================================================================== --- python/branches/p3yk/Lib/test/test_cookie.py (original) +++ python/branches/p3yk/Lib/test/test_cookie.py Wed Dec 13 05:49:30 2006 @@ -1,6 +1,7 @@ # Simple test suite for Cookie.py -from test.test_support import verify, verbose, run_doctest +from test.test_support import run_unittest, run_doctest +import unittest import Cookie import warnings @@ -8,43 +9,74 @@ ".* class is insecure.*", DeprecationWarning) -# Currently this only tests SimpleCookie +class CookieTests(unittest.TestCase): + # Currently this only tests SimpleCookie + def test_basic(self): + cases = [ + { 'data': 'chips=ahoy; vienna=finger', + 'dict': {'chips':'ahoy', 'vienna':'finger'}, + 'repr': "", + 'output': 'Set-Cookie: chips=ahoy\nSet-Cookie: vienna=finger', + }, + + { 'data': 'keebler="E=mc2; L=\\"Loves\\"; fudge=\\012;"', + 'dict': {'keebler' : 'E=mc2; L="Loves"; fudge=\012;'}, + 'repr': '''''', + 'output': 'Set-Cookie: keebler="E=mc2; L=\\"Loves\\"; fudge=\\012;"', + }, + + # Check illegal cookies that have an '=' char in an unquoted value + { 'data': 'keebler=E=mc2', + 'dict': {'keebler' : 'E=mc2'}, + 'repr': "", + 'output': 'Set-Cookie: keebler=E=mc2', + } + ] + + for case in cases: + C = Cookie.SimpleCookie() + C.load(case['data']) + self.assertEqual(repr(C), case['repr']) + self.assertEqual(C.output(sep='\n'), case['output']) + for k, v in sorted(case['dict'].iteritems()): + self.assertEqual(C[k].value, v) + + def test_load(self): + C = Cookie.SimpleCookie() + C.load('Customer="WILE_E_COYOTE"; Version=1; Path=/acme') + + self.assertEqual(C['Customer'].value, 'WILE_E_COYOTE') + self.assertEqual(C['Customer']['version'], '1') + self.assertEqual(C['Customer']['path'], '/acme') + + self.assertEqual(C.output(['path']), + 'Set-Cookie: Customer="WILE_E_COYOTE"; Path=/acme') + self.assertEqual(C.js_output(), """ + + """) + self.assertEqual(C.js_output(['path']), """ + + """) + + def test_quoted_meta(self): + # Try cookie with quoted meta-data + C = Cookie.SimpleCookie() + C.load('Customer="WILE_E_COYOTE"; Version="1"; Path="/acme"') + self.assertEqual(C['Customer'].value, 'WILE_E_COYOTE') + self.assertEqual(C['Customer']['version'], '1') + self.assertEqual(C['Customer']['path'], '/acme') + +def test_main(): + run_unittest(CookieTests) + run_doctest(Cookie) -cases = [ - ('chips=ahoy; vienna=finger', {'chips':'ahoy', 'vienna':'finger'}), - ('keebler="E=mc2; L=\\"Loves\\"; fudge=\\012;"', - {'keebler' : 'E=mc2; L="Loves"; fudge=\012;'}), - - # Check illegal cookies that have an '=' char in an unquoted value - ('keebler=E=mc2', {'keebler' : 'E=mc2'}) - ] - -for data, dict in cases: - C = Cookie.SimpleCookie() ; C.load(data) - print repr(C) - print C.output(sep='\n') - for k, v in sorted(dict.iteritems()): - print ' ', k, repr( C[k].value ), repr(v) - verify(C[k].value == v) - print C[k] - -C = Cookie.SimpleCookie() -C.load('Customer="WILE_E_COYOTE"; Version=1; Path=/acme') - -verify(C['Customer'].value == 'WILE_E_COYOTE') -verify(C['Customer']['version'] == '1') -verify(C['Customer']['path'] == '/acme') - -print C.output(['path']) -print C.js_output() -print C.js_output(['path']) - -# Try cookie with quoted meta-data -C = Cookie.SimpleCookie() -C.load('Customer="WILE_E_COYOTE"; Version="1"; Path="/acme"') -verify(C['Customer'].value == 'WILE_E_COYOTE') -verify(C['Customer']['version'] == '1') -verify(C['Customer']['path'] == '/acme') - -print "If anything blows up after this line, it's from Cookie's doctest." -run_doctest(Cookie) +if __name__ == '__main__': + test_main() Modified: python/branches/p3yk/Lib/test/test_datetime.py ============================================================================== --- python/branches/p3yk/Lib/test/test_datetime.py (original) +++ python/branches/p3yk/Lib/test/test_datetime.py Wed Dec 13 05:49:30 2006 @@ -852,6 +852,7 @@ t = self.theclass(2005, 3, 2) self.assertEqual(t.strftime("m:%m d:%d y:%y"), "m:03 d:02 y:05") self.assertEqual(t.strftime(""), "") # SF bug #761337 + self.assertEqual(t.strftime('x'*1000), 'x'*1000) # SF bug #1556784 self.assertRaises(TypeError, t.strftime) # needs an arg self.assertRaises(TypeError, t.strftime, "one", "two") # too many args Modified: python/branches/p3yk/Lib/test/test_decimal.py ============================================================================== --- python/branches/p3yk/Lib/test/test_decimal.py (original) +++ python/branches/p3yk/Lib/test/test_decimal.py Wed Dec 13 05:49:30 2006 @@ -23,6 +23,7 @@ you're working through IDLE, you can import this test module and call test_main() with the corresponding argument. """ +from __future__ import with_statement import unittest import glob @@ -1057,6 +1058,32 @@ self.assertNotEqual(id(c.flags), id(d.flags)) self.assertNotEqual(id(c.traps), id(d.traps)) +class WithStatementTest(unittest.TestCase): + # Can't do these as docstrings until Python 2.6 + # as doctest can't handle __future__ statements + + def test_localcontext(self): + # Use a copy of the current context in the block + orig_ctx = getcontext() + with localcontext() as enter_ctx: + set_ctx = getcontext() + final_ctx = getcontext() + self.assert_(orig_ctx is final_ctx, 'did not restore context correctly') + self.assert_(orig_ctx is not set_ctx, 'did not copy the context') + self.assert_(set_ctx is enter_ctx, '__enter__ returned wrong context') + + def test_localcontextarg(self): + # Use a copy of the supplied context in the block + orig_ctx = getcontext() + new_ctx = Context(prec=42) + with localcontext(new_ctx) as enter_ctx: + set_ctx = getcontext() + final_ctx = getcontext() + self.assert_(orig_ctx is final_ctx, 'did not restore context correctly') + self.assert_(set_ctx.prec == new_ctx.prec, 'did not set correct context') + self.assert_(new_ctx is not set_ctx, 'did not copy the context') + self.assert_(set_ctx is enter_ctx, '__enter__ returned wrong context') + def test_main(arith=False, verbose=None): """ Execute the tests. @@ -1077,6 +1104,7 @@ DecimalPythonAPItests, ContextAPItests, DecimalTest, + WithStatementTest, ] try: Modified: python/branches/p3yk/Lib/test/test_descr.py ============================================================================== --- python/branches/p3yk/Lib/test/test_descr.py (original) +++ python/branches/p3yk/Lib/test/test_descr.py Wed Dec 13 05:49:30 2006 @@ -2017,6 +2017,13 @@ veris(Sub.test(), Base.aProp) + # Verify that super() doesn't allow keyword args + try: + super(Base, kw=1) + except TypeError: + pass + else: + raise TestFailed, "super shouldn't accept keyword args" def inherits(): if verbose: print "Testing inheritance from basic types..." @@ -3501,6 +3508,13 @@ raise TestFailed, "shouldn't be able to assign to list.__bases__" try: + D.__bases__ = (C2, list) + except TypeError: + pass + else: + assert 0, "best_base calculation found wanting" + + try: del D.__bases__ except TypeError: pass Modified: python/branches/p3yk/Lib/test/test_dict.py ============================================================================== --- python/branches/p3yk/Lib/test/test_dict.py (original) +++ python/branches/p3yk/Lib/test/test_dict.py Wed Dec 13 05:49:30 2006 @@ -439,6 +439,16 @@ else: self.fail_("g[42] didn't raise KeyError") + def test_tuple_keyerror(self): + # SF #1576657 + d = {} + try: + d[(1,)] + except KeyError, e: + self.assertEqual(e.args, ((1,),)) + else: + self.fail("missing KeyError") + from test import mapping_tests Modified: python/branches/p3yk/Lib/test/test_exceptions.py ============================================================================== --- python/branches/p3yk/Lib/test/test_exceptions.py (original) +++ python/branches/p3yk/Lib/test/test_exceptions.py Wed Dec 13 05:49:30 2006 @@ -196,17 +196,21 @@ test_capi2() test_capi3() - def testAttributes(self): - # test that exception attributes are happy + def test_WindowsError(self): try: - str(u'Hello \u00E1') - except Exception, e: - sampleUnicodeEncodeError = e + WindowsError + except NameError: + pass + else: + self.failUnlessEqual(str(WindowsError(1001)), + "1001") + self.failUnlessEqual(str(WindowsError(1001, "message")), + "[Error 1001] message") + self.failUnlessEqual(WindowsError(1001, "message").errno, 22) + self.failUnlessEqual(WindowsError(1001, "message").winerror, 1001) - try: - unicode('\xff') - except Exception, e: - sampleUnicodeDecodeError = e + def testAttributes(self): + # test that exception attributes are happy exceptionList = [ (BaseException, (), {'message' : '', 'args' : ()}), @@ -218,11 +222,16 @@ (SystemExit, ('foo',), {'message' : 'foo', 'args' : ('foo',), 'code' : 'foo'}), (IOError, ('foo',), - {'message' : 'foo', 'args' : ('foo',)}), + {'message' : 'foo', 'args' : ('foo',), 'filename' : None, + 'errno' : None, 'strerror' : None}), (IOError, ('foo', 'bar'), - {'message' : '', 'args' : ('foo', 'bar')}), + {'message' : '', 'args' : ('foo', 'bar'), 'filename' : None, + 'errno' : 'foo', 'strerror' : 'bar'}), (IOError, ('foo', 'bar', 'baz'), - {'message' : '', 'args' : ('foo', 'bar')}), + {'message' : '', 'args' : ('foo', 'bar'), 'filename' : 'baz', + 'errno' : 'foo', 'strerror' : 'bar'}), + (IOError, ('foo', 'bar', 'baz', 'quux'), + {'message' : '', 'args' : ('foo', 'bar', 'baz', 'quux')}), (EnvironmentError, ('errnoStr', 'strErrorStr', 'filenameStr'), {'message' : '', 'args' : ('errnoStr', 'strErrorStr'), 'strerror' : 'strErrorStr', 'errno' : 'errnoStr', @@ -249,16 +258,16 @@ 'print_file_and_line' : None, 'msg' : 'msgStr', 'filename' : None, 'lineno' : None, 'offset' : None}), (UnicodeError, (), {'message' : '', 'args' : (),}), - (sampleUnicodeEncodeError, - {'message' : '', 'args' : ('ascii', u'Hello \xe1', 6, 7, - 'ordinal not in range(128)'), - 'encoding' : 'ascii', 'object' : u'Hello \xe1', - 'start' : 6, 'reason' : 'ordinal not in range(128)'}), - (sampleUnicodeDecodeError, + (UnicodeEncodeError, ('ascii', u'a', 0, 1, 'ordinal not in range'), + {'message' : '', 'args' : ('ascii', u'a', 0, 1, + 'ordinal not in range'), + 'encoding' : 'ascii', 'object' : u'a', + 'start' : 0, 'reason' : 'ordinal not in range'}), + (UnicodeDecodeError, ('ascii', '\xff', 0, 1, 'ordinal not in range'), {'message' : '', 'args' : ('ascii', '\xff', 0, 1, - 'ordinal not in range(128)'), + 'ordinal not in range'), 'encoding' : 'ascii', 'object' : '\xff', - 'start' : 0, 'reason' : 'ordinal not in range(128)'}), + 'start' : 0, 'reason' : 'ordinal not in range'}), (UnicodeTranslateError, (u"\u3042", 0, 1, "ouch"), {'message' : '', 'args' : (u'\u3042', 0, 1, 'ouch'), 'object' : u'\u3042', 'reason' : 'ouch', @@ -274,18 +283,14 @@ except NameError: pass - for args in exceptionList: - expected = args[-1] + for exc, args, expected in exceptionList: try: - exc = args[0] - if len(args) == 2: - raise exc - else: - raise exc(*args[1]) + raise exc(*args) except BaseException, e: - if (e is not exc and # needed for sampleUnicode errors - type(e) is not exc): + if type(e) is not exc: raise + # Verify module name + self.assertEquals(type(e).__module__, 'exceptions') # Verify no ref leaks in Exc_str() s = str(e) for checkArgName in expected: @@ -332,6 +337,15 @@ return -1 self.assertRaises(RuntimeError, g) + def testUnicodeStrUsage(self): + # Make sure both instances and classes have a str and unicode + # representation. + self.failUnless(str(Exception)) + self.failUnless(unicode(Exception)) + self.failUnless(str(Exception('a'))) + self.failUnless(unicode(Exception(u'a'))) + + def test_main(): run_unittest(ExceptionTests) Modified: python/branches/p3yk/Lib/test/test_fcntl.py ============================================================================== --- python/branches/p3yk/Lib/test/test_fcntl.py (original) +++ python/branches/p3yk/Lib/test/test_fcntl.py Wed Dec 13 05:49:30 2006 @@ -25,7 +25,7 @@ 'freebsd2', 'freebsd3', 'freebsd4', 'freebsd5', 'freebsd6', 'freebsd7', 'bsdos2', 'bsdos3', 'bsdos4', - 'openbsd', 'openbsd2', 'openbsd3'): + 'openbsd', 'openbsd2', 'openbsd3', 'openbsd4'): if struct.calcsize('l') == 8: off_t = 'l' pid_t = 'i' Modified: python/branches/p3yk/Lib/test/test_format.py ============================================================================== --- python/branches/p3yk/Lib/test/test_format.py (original) +++ python/branches/p3yk/Lib/test/test_format.py Wed Dec 13 05:49:30 2006 @@ -219,8 +219,8 @@ test_exc(unicode('abc %\u3000','raw-unicode-escape'), 1, ValueError, "unsupported format character '?' (0x3000) at index 5") -test_exc('%d', '1', TypeError, "int argument required") -test_exc('%g', '1', TypeError, "float argument required") +test_exc('%d', '1', TypeError, "int argument required, not str") +test_exc('%g', '1', TypeError, "float argument required, not str") test_exc('no format', '1', TypeError, "not all arguments converted during string formatting") test_exc('no format', u'1', TypeError, Modified: python/branches/p3yk/Lib/test/test_functools.py ============================================================================== --- python/branches/p3yk/Lib/test/test_functools.py (original) +++ python/branches/p3yk/Lib/test/test_functools.py Wed Dec 13 05:49:30 2006 @@ -210,6 +210,13 @@ self.assertEqual(wrapper.attr, 'This is a different test') self.assertEqual(wrapper.dict_attr, f.dict_attr) + def test_builtin_update(self): + # Test for bug #1576241 + def wrapper(): + pass + functools.update_wrapper(wrapper, max) + self.assertEqual(wrapper.__name__, 'max') + self.assert_(wrapper.__doc__.startswith('max(')) class TestWraps(TestUpdateWrapper): Modified: python/branches/p3yk/Lib/test/test_future.py ============================================================================== --- python/branches/p3yk/Lib/test/test_future.py (original) +++ python/branches/p3yk/Lib/test/test_future.py Wed Dec 13 05:49:30 2006 @@ -82,6 +82,27 @@ else: self.fail("expected exception didn't occur") + def test_parserhack(self): + # test that the parser.c::future_hack function works as expected + # Note: although this test must pass, it's not testing the original + # bug as of 2.6 since the with statement is not optional and + # the parser hack disabled. If a new keyword is introduced in + # 2.6, change this to refer to the new future import. + try: + exec("from __future__ import division, with_statement; with = 0") + except SyntaxError: + pass + else: + self.fail("syntax error didn't occur") + + try: + exec("from __future__ import (with_statement, division); with = 0") + except SyntaxError: + pass + else: + self.fail("syntax error didn't occur") + + def test_main(): test_support.run_unittest(FutureTest) Modified: python/branches/p3yk/Lib/test/test_global.py ============================================================================== --- python/branches/p3yk/Lib/test/test_global.py (original) +++ python/branches/p3yk/Lib/test/test_global.py Wed Dec 13 05:49:30 2006 @@ -1,51 +1,51 @@ """Verify that warnings are issued for global statements following use.""" -from test.test_support import check_syntax +from test.test_support import run_unittest, check_syntax_error +import unittest import warnings +warnings.filterwarnings("error", module="") -warnings.filterwarnings("error", module="") +class GlobalTests(unittest.TestCase): -def compile_and_check(text, should_fail=1): - try: - compile(text, "", "exec") - except SyntaxError, msg: - if should_fail: - print "got SyntaxError as expected" - else: - print "raised unexpected SyntaxError:", text - else: - if should_fail: - print "should have raised SyntaxError:", text - else: - print "as expected, no SyntaxError" - -prog_text_1 = """ + def test1(self): + prog_text_1 = """\ def wrong1(): a = 1 b = 2 global a global b """ -compile_and_check(prog_text_1) + check_syntax_error(self, prog_text_1) -prog_text_2 = """ + def test2(self): + prog_text_2 = """\ def wrong2(): print x global x """ -compile_and_check(prog_text_2) + check_syntax_error(self, prog_text_2) -prog_text_3 = """ + def test3(self): + prog_text_3 = """\ def wrong3(): print x x = 2 global x """ -compile_and_check(prog_text_3) + check_syntax_error(self, prog_text_3) -prog_text_4 = """ + def test4(self): + prog_text_4 = """\ global x x = 2 """ -compile_and_check(prog_text_4, 0) + # this should work + compile(prog_text_4, "", "exec") + + +def test_main(): + run_unittest(GlobalTests) + +if __name__ == "__main__": + test_main() Modified: python/branches/p3yk/Lib/test/test_grammar.py ============================================================================== --- python/branches/p3yk/Lib/test/test_grammar.py (original) +++ python/branches/p3yk/Lib/test/test_grammar.py Wed Dec 13 05:49:30 2006 @@ -8,830 +8,897 @@ # regression test, the filterwarnings() call has been added to # regrtest.py. -from test.test_support import TestFailed, verify, vereq, check_syntax +from test.test_support import run_unittest, check_syntax_error +import unittest import sys +# testing import * +from sys import * -print '1. Parser' - -print '1.1 Tokens' - -print '1.1.1 Backslashes' +class TokenTests(unittest.TestCase): -# Backslash means line continuation: -x = 1 \ -+ 1 -if x != 2: raise TestFailed, 'backslash for line continuation' - -# Backslash does not means continuation in comments :\ -x = 0 -if x != 0: raise TestFailed, 'backslash ending comment' - -print '1.1.2 Numeric literals' - -print '1.1.2.1 Plain integers' -if 0xff != 255: raise TestFailed, 'hex int' -if 0377 != 255: raise TestFailed, 'octal int' -if 2147483647 != 017777777777: raise TestFailed, 'large positive int' -try: - from sys import maxint -except ImportError: - maxint = 2147483647 -if maxint == 2147483647: - # The following test will start to fail in Python 2.4; - # change the 020000000000 to -020000000000 - if -2147483647-1 != -020000000000: raise TestFailed, 'max negative int' - # XXX -2147483648 - if 037777777777 < 0: raise TestFailed, 'large oct' - if 0xffffffff < 0: raise TestFailed, 'large hex' - for s in '2147483648', '040000000000', '0x100000000': - try: - x = eval(s) - except OverflowError: - print "OverflowError on huge integer literal " + repr(s) -elif eval('maxint == 9223372036854775807'): - if eval('-9223372036854775807-1 != -01000000000000000000000'): - raise TestFailed, 'max negative int' - if eval('01777777777777777777777') < 0: raise TestFailed, 'large oct' - if eval('0xffffffffffffffff') < 0: raise TestFailed, 'large hex' - for s in '9223372036854775808', '02000000000000000000000', \ - '0x10000000000000000': - try: - x = eval(s) - except OverflowError: - print "OverflowError on huge integer literal " + repr(s) -else: - print 'Weird maxint value', maxint - -print '1.1.2.2 Long integers' -x = 0L -x = 0l -x = 0xffffffffffffffffL -x = 0xffffffffffffffffl -x = 077777777777777777L -x = 077777777777777777l -x = 123456789012345678901234567890L -x = 123456789012345678901234567890l - -print '1.1.2.3 Floating point' -x = 3.14 -x = 314. -x = 0.314 -# XXX x = 000.314 -x = .314 -x = 3e14 -x = 3E14 -x = 3e-14 -x = 3e+14 -x = 3.e14 -x = .3e14 -x = 3.1e4 - -print '1.1.3 String literals' - -x = ''; y = ""; verify(len(x) == 0 and x == y) -x = '\''; y = "'"; verify(len(x) == 1 and x == y and ord(x) == 39) -x = '"'; y = "\""; verify(len(x) == 1 and x == y and ord(x) == 34) -x = "doesn't \"shrink\" does it" -y = 'doesn\'t "shrink" does it' -verify(len(x) == 24 and x == y) -x = "does \"shrink\" doesn't it" -y = 'does "shrink" doesn\'t it' -verify(len(x) == 24 and x == y) -x = """ + def testBackslash(self): + # Backslash means line continuation: + x = 1 \ + + 1 + self.assertEquals(x, 2, 'backslash for line continuation') + + # Backslash does not means continuation in comments :\ + x = 0 + self.assertEquals(x, 0, 'backslash ending comment') + + def testPlainIntegers(self): + self.assertEquals(0xff, 255) + self.assertEquals(0377, 255) + self.assertEquals(2147483647, 017777777777) + from sys import maxint + if maxint == 2147483647: + self.assertEquals(-2147483647-1, -020000000000) + # XXX -2147483648 + self.assert_(037777777777 > 0) + self.assert_(0xffffffff > 0) + for s in '2147483648', '040000000000', '0x100000000': + try: + x = eval(s) + except OverflowError: + self.fail("OverflowError on huge integer literal %r" % s) + elif maxint == 9223372036854775807: + self.assertEquals(-9223372036854775807-1, -01000000000000000000000) + self.assert_(01777777777777777777777 > 0) + self.assert_(0xffffffffffffffff > 0) + for s in '9223372036854775808', '02000000000000000000000', \ + '0x10000000000000000': + try: + x = eval(s) + except OverflowError: + self.fail("OverflowError on huge integer literal %r" % s) + else: + self.fail('Weird maxint value %r' % maxint) + + def testLongIntegers(self): + x = 0L + x = 0l + x = 0xffffffffffffffffL + x = 0xffffffffffffffffl + x = 077777777777777777L + x = 077777777777777777l + x = 123456789012345678901234567890L + x = 123456789012345678901234567890l + + def testFloats(self): + x = 3.14 + x = 314. + x = 0.314 + # XXX x = 000.314 + x = .314 + x = 3e14 + x = 3E14 + x = 3e-14 + x = 3e+14 + x = 3.e14 + x = .3e14 + x = 3.1e4 + + def testStringLiterals(self): + x = ''; y = ""; self.assert_(len(x) == 0 and x == y) + x = '\''; y = "'"; self.assert_(len(x) == 1 and x == y and ord(x) == 39) + x = '"'; y = "\""; self.assert_(len(x) == 1 and x == y and ord(x) == 34) + x = "doesn't \"shrink\" does it" + y = 'doesn\'t "shrink" does it' + self.assert_(len(x) == 24 and x == y) + x = "does \"shrink\" doesn't it" + y = 'does "shrink" doesn\'t it' + self.assert_(len(x) == 24 and x == y) + x = """ The "quick" brown fox jumps over the 'lazy' dog. """ -y = '\nThe "quick"\nbrown fox\njumps over\nthe \'lazy\' dog.\n' -verify(x == y) -y = ''' + y = '\nThe "quick"\nbrown fox\njumps over\nthe \'lazy\' dog.\n' + self.assertEquals(x, y) + y = ''' The "quick" brown fox jumps over the 'lazy' dog. -'''; verify(x == y) -y = "\n\ +''' + self.assertEquals(x, y) + y = "\n\ The \"quick\"\n\ brown fox\n\ jumps over\n\ the 'lazy' dog.\n\ -"; verify(x == y) -y = '\n\ +" + self.assertEquals(x, y) + y = '\n\ The \"quick\"\n\ brown fox\n\ jumps over\n\ the \'lazy\' dog.\n\ -'; verify(x == y) - +' + self.assertEquals(x, y) -print '1.1.4 Ellipsis literal' - -x = ... -verify(x == Ellipsis) + def testEllipsis(self): + x = ... + self.assert_(x is Ellipsis) + +class GrammarTests(unittest.TestCase): + + # single_input: NEWLINE | simple_stmt | compound_stmt NEWLINE + # XXX can't test in a script -- this rule is only used when interactive + + # file_input: (NEWLINE | stmt)* ENDMARKER + # Being tested as this very moment this very module + + # expr_input: testlist NEWLINE + # XXX Hard to test -- used only in calls to input() + + def testEvalInput(self): + # testlist ENDMARKER + x = eval('1, 0 or 1') + + def testFuncdef(self): + ### 'def' NAME parameters ':' suite + ### parameters: '(' [varargslist] ')' + ### varargslist: (fpdef ['=' test] ',')* + ### ('*' (NAME|',' fpdef ['=' test]) [',' ('**'|'*' '*') NAME] + ### | ('**'|'*' '*') NAME) + ### | fpdef ['=' test] (',' fpdef ['=' test])* [','] + ### fpdef: NAME | '(' fplist ')' + ### fplist: fpdef (',' fpdef)* [','] + ### arglist: (argument ',')* (argument | *' test [',' '**' test] | '**' test) + ### argument: [test '='] test # Really [keyword '='] test + def f1(): pass + f1() + f1(*()) + f1(*(), **{}) + def f2(one_argument): pass + def f3(two, arguments): pass + def f4(two, (compound, (argument, list))): pass + def f5((compound, first), two): pass + self.assertEquals(f2.func_code.co_varnames, ('one_argument',)) + self.assertEquals(f3.func_code.co_varnames, ('two', 'arguments')) + if sys.platform.startswith('java'): + self.assertEquals(f4.func_code.co_varnames, + ('two', '(compound, (argument, list))', 'compound', 'argument', + 'list',)) + self.assertEquals(f5.func_code.co_varnames, + ('(compound, first)', 'two', 'compound', 'first')) + else: + self.assertEquals(f4.func_code.co_varnames, + ('two', '.1', 'compound', 'argument', 'list')) + self.assertEquals(f5.func_code.co_varnames, + ('.0', 'two', 'compound', 'first')) + def a1(one_arg,): pass + def a2(two, args,): pass + def v0(*rest): pass + def v1(a, *rest): pass + def v2(a, b, *rest): pass + def v3(a, (b, c), *rest): return a, b, c, rest + + f1() + f2(1) + f2(1,) + f3(1, 2) + f3(1, 2,) + f4(1, (2, (3, 4))) + v0() + v0(1) + v0(1,) + v0(1,2) + v0(1,2,3,4,5,6,7,8,9,0) + v1(1) + v1(1,) + v1(1,2) + v1(1,2,3) + v1(1,2,3,4,5,6,7,8,9,0) + v2(1,2) + v2(1,2,3) + v2(1,2,3,4) + v2(1,2,3,4,5,6,7,8,9,0) + v3(1,(2,3)) + v3(1,(2,3),4) + v3(1,(2,3),4,5,6,7,8,9,0) + + # ceval unpacks the formal arguments into the first argcount names; + # thus, the names nested inside tuples must appear after these names. + if sys.platform.startswith('java'): + self.assertEquals(v3.func_code.co_varnames, ('a', '(b, c)', 'rest', 'b', 'c')) + else: + self.assertEquals(v3.func_code.co_varnames, ('a', '.1', 'rest', 'b', 'c')) + self.assertEquals(v3(1, (2, 3), 4), (1, 2, 3, (4,))) + def d01(a=1): pass + d01() + d01(1) + d01(*(1,)) + d01(**{'a':2}) + def d11(a, b=1): pass + d11(1) + d11(1, 2) + d11(1, **{'b':2}) + def d21(a, b, c=1): pass + d21(1, 2) + d21(1, 2, 3) + d21(*(1, 2, 3)) + d21(1, *(2, 3)) + d21(1, 2, *(3,)) + d21(1, 2, **{'c':3}) + def d02(a=1, b=2): pass + d02() + d02(1) + d02(1, 2) + d02(*(1, 2)) + d02(1, *(2,)) + d02(1, **{'b':2}) + d02(**{'a': 1, 'b': 2}) + def d12(a, b=1, c=2): pass + d12(1) + d12(1, 2) + d12(1, 2, 3) + def d22(a, b, c=1, d=2): pass + d22(1, 2) + d22(1, 2, 3) + d22(1, 2, 3, 4) + def d01v(a=1, *rest): pass + d01v() + d01v(1) + d01v(1, 2) + d01v(*(1, 2, 3, 4)) + d01v(*(1,)) + d01v(**{'a':2}) + def d11v(a, b=1, *rest): pass + d11v(1) + d11v(1, 2) + d11v(1, 2, 3) + def d21v(a, b, c=1, *rest): pass + d21v(1, 2) + d21v(1, 2, 3) + d21v(1, 2, 3, 4) + d21v(*(1, 2, 3, 4)) + d21v(1, 2, **{'c': 3}) + def d02v(a=1, b=2, *rest): pass + d02v() + d02v(1) + d02v(1, 2) + d02v(1, 2, 3) + d02v(1, *(2, 3, 4)) + d02v(**{'a': 1, 'b': 2}) + def d12v(a, b=1, c=2, *rest): pass + d12v(1) + d12v(1, 2) + d12v(1, 2, 3) + d12v(1, 2, 3, 4) + d12v(*(1, 2, 3, 4)) + d12v(1, 2, *(3, 4, 5)) + d12v(1, *(2,), **{'c': 3}) + def d22v(a, b, c=1, d=2, *rest): pass + d22v(1, 2) + d22v(1, 2, 3) + d22v(1, 2, 3, 4) + d22v(1, 2, 3, 4, 5) + d22v(*(1, 2, 3, 4)) + d22v(1, 2, *(3, 4, 5)) + d22v(1, *(2, 3), **{'d': 4}) + def d31v((x)): pass + d31v(1) + def d32v((x,)): pass + d32v((1,)) + # keyword only argument tests + def pos0key1(*, key): return key + pos0key1(key=100) + def pos2key2(p1, p2, *, k1, k2=100): return p1,p2,k1,k2 + pos2key2(1, 2, k1=100) + pos2key2(1, 2, k1=100, k2=200) + pos2key2(1, 2, k2=100, k1=200) + def pos2key2dict(p1, p2, *, k1=100, k2, **kwarg): return p1,p2,k1,k2,kwarg + pos2key2dict(1,2,k2=100,tokwarg1=100,tokwarg2=200) + pos2key2dict(1,2,tokwarg1=100,tokwarg2=200, k2=100) + + def testLambdef(self): + ### lambdef: 'lambda' [varargslist] ':' test + l1 = lambda : 0 + self.assertEquals(l1(), 0) + l2 = lambda : a[d] # XXX just testing the expression + l3 = lambda : [2 < x for x in [-1, 3, 0L]] + self.assertEquals(l3(), [0, 1, 0]) + l4 = lambda x = lambda y = lambda z=1 : z : y() : x() + self.assertEquals(l4(), 1) + l5 = lambda x, y, z=2: x + y + z + self.assertEquals(l5(1, 2), 5) + self.assertEquals(l5(1, 2, 3), 6) + check_syntax_error(self, "lambda x: x = 2") + l6 = lambda x, y, *, k=20: x+y+k + self.assertEquals(l6(1,2), 1+2+20) + self.assertEquals(l6(1,2,k=10), 1+2+10) + + + ### stmt: simple_stmt | compound_stmt + # Tested below + + def testSimpleStmt(self): + ### simple_stmt: small_stmt (';' small_stmt)* [';'] + x = 1; pass; del x + def foo(): + # verify statments that end with semi-colons + x = 1; pass; del x; + foo() + + ### small_stmt: expr_stmt | print_stmt | pass_stmt | del_stmt | flow_stmt | import_stmt | global_stmt | access_stmt + # Tested below + + def testExprStmt(self): + # (exprlist '=')* exprlist + 1 + 1, 2, 3 + x = 1 + x = 1, 2, 3 + x = y = z = 1, 2, 3 + x, y, z = 1, 2, 3 + abc = a, b, c = x, y, z = xyz = 1, 2, (3, 4) + + check_syntax_error(self, "x + 1 = 1") + check_syntax_error(self, "a + 1 = b + 2") + + def testPrintStmt(self): + # 'print' (test ',')* [test] + import StringIO + + # Can't test printing to real stdout without comparing output + # which is not available in unittest. + save_stdout = sys.stdout + sys.stdout = StringIO.StringIO() + + print 1, 2, 3 + print 1, 2, 3, + print + print 0 or 1, 0 or 1, + print 0 or 1 + + # 'print' '>>' test ',' + print >> sys.stdout, 1, 2, 3 + print >> sys.stdout, 1, 2, 3, + print >> sys.stdout + print >> sys.stdout, 0 or 1, 0 or 1, + print >> sys.stdout, 0 or 1 + + # test printing to an instance + class Gulp: + def write(self, msg): pass + + gulp = Gulp() + print >> gulp, 1, 2, 3 + print >> gulp, 1, 2, 3, + print >> gulp + print >> gulp, 0 or 1, 0 or 1, + print >> gulp, 0 or 1 + + # test print >> None + def driver(): + oldstdout = sys.stdout + sys.stdout = Gulp() + try: + tellme(Gulp()) + tellme() + finally: + sys.stdout = oldstdout + + # we should see this once + def tellme(file=sys.stdout): + print >> file, 'hello world' + + driver() + + # we should not see this at all + def tellme(file=None): + print >> file, 'goodbye universe' + + driver() + + self.assertEqual(sys.stdout.getvalue(), '''\ +1 2 3 +1 2 3 +1 1 1 +1 2 3 +1 2 3 +1 1 1 +hello world +''') + sys.stdout = save_stdout + + # syntax errors + check_syntax_error(self, 'print ,') + check_syntax_error(self, 'print >> x,') + + def testDelStmt(self): + # 'del' exprlist + abc = [1,2,3] + x, y, z = abc + xyz = x, y, z + + del abc + del x, y, (z, xyz) + + def testPassStmt(self): + # 'pass' + pass + + # flow_stmt: break_stmt | continue_stmt | return_stmt | raise_stmt + # Tested below + + def testBreakStmt(self): + # 'break' + while 1: break + + def testContinueStmt(self): + # 'continue' + i = 1 + while i: i = 0; continue + + msg = "" + while not msg: + msg = "ok" + try: + continue + msg = "continue failed to continue inside try" + except: + msg = "continue inside try called except block" + if msg != "ok": + self.fail(msg) + + msg = "" + while not msg: + msg = "finally block not called" + try: + continue + finally: + msg = "ok" + if msg != "ok": + self.fail(msg) + + def test_break_continue_loop(self): + # This test warrants an explanation. It is a test specifically for SF bugs + # #463359 and #462937. The bug is that a 'break' statement executed or + # exception raised inside a try/except inside a loop, *after* a continue + # statement has been executed in that loop, will cause the wrong number of + # arguments to be popped off the stack and the instruction pointer reset to + # a very small number (usually 0.) Because of this, the following test + # *must* written as a function, and the tracking vars *must* be function + # arguments with default values. Otherwise, the test will loop and loop. + + def test_inner(extra_burning_oil = 1, count=0): + big_hippo = 2 + while big_hippo: + count += 1 + try: + if extra_burning_oil and big_hippo == 1: + extra_burning_oil -= 1 + break + big_hippo -= 1 + continue + except: + raise + if count > 2 or big_hippo != 1: + self.fail("continue then break in try/except in loop broken!") + test_inner() + + def testReturn(self): + # 'return' [testlist] + def g1(): return + def g2(): return 1 + g1() + x = g2() + check_syntax_error(self, "class foo:return 1") + + def testYield(self): + check_syntax_error(self, "class foo:yield 1") + + def testRaise(self): + # 'raise' test [',' test] + try: raise RuntimeError, 'just testing' + except RuntimeError: pass + try: raise KeyboardInterrupt + except KeyboardInterrupt: pass + + def testImport(self): + # 'import' dotted_as_names + import sys + import time, sys + # 'from' dotted_name 'import' ('*' | '(' import_as_names ')' | import_as_names) + from time import time + from time import (time) + # not testable inside a function, but already done at top of the module + # from sys import * + from sys import path, argv + from sys import (path, argv) + from sys import (path, argv,) + + def testGlobal(self): + # 'global' NAME (',' NAME)* + global a + global a, b + global one, two, three, four, five, six, seven, eight, nine, ten + + def testAssert(self): + # assert_stmt: 'assert' test [',' test] + assert 1 + assert 1, 1 + assert lambda x:x + assert 1, lambda x:x+1 + try: + assert 0, "msg" + except AssertionError, e: + self.assertEquals(e.args[0], "msg") + else: + if __debug__: + self.fail("AssertionError not raised by assert 0") + + ### compound_stmt: if_stmt | while_stmt | for_stmt | try_stmt | funcdef | classdef + # Tested below + + def testIf(self): + # 'if' test ':' suite ('elif' test ':' suite)* ['else' ':' suite] + if 1: pass + if 1: pass + else: pass + if 0: pass + elif 0: pass + if 0: pass + elif 0: pass + elif 0: pass + elif 0: pass + else: pass + + def testWhile(self): + # 'while' test ':' suite ['else' ':' suite] + while 0: pass + while 0: pass + else: pass + + def testFor(self): + # 'for' exprlist 'in' exprlist ':' suite ['else' ':' suite] + for i in 1, 2, 3: pass + for i, j, k in (): pass + else: pass + class Squares: + def __init__(self, max): + self.max = max + self.sofar = [] + def __len__(self): return len(self.sofar) + def __getitem__(self, i): + if not 0 <= i < self.max: raise IndexError + n = len(self.sofar) + while n <= i: + self.sofar.append(n*n) + n = n+1 + return self.sofar[i] + n = 0 + for x in Squares(10): n = n+x + if n != 285: + self.fail('for over growing sequence') + + result = [] + for x, in [(1,), (2,), (3,)]: + result.append(x) + self.assertEqual(result, [1, 2, 3]) + + def testTry(self): + ### try_stmt: 'try' ':' suite (except_clause ':' suite)+ ['else' ':' suite] + ### | 'try' ':' suite 'finally' ':' suite + ### except_clause: 'except' [expr [',' expr]] + try: + 1/0 + except ZeroDivisionError: + pass + else: + pass + try: 1/0 + except EOFError: pass + except TypeError, msg: pass + except RuntimeError, msg: pass + except: pass + else: pass + try: 1/0 + except (EOFError, TypeError, ZeroDivisionError): pass + try: 1/0 + except (EOFError, TypeError, ZeroDivisionError), msg: pass + try: pass + finally: pass + + def testSuite(self): + # simple_stmt | NEWLINE INDENT NEWLINE* (stmt NEWLINE*)+ DEDENT + if 1: pass + if 1: + pass + if 1: + # + # + # + pass + pass + # + pass + # + + def testTest(self): + ### and_test ('or' and_test)* + ### and_test: not_test ('and' not_test)* + ### not_test: 'not' not_test | comparison + if not 1: pass + if 1 and 1: pass + if 1 or 1: pass + if not not not 1: pass + if not 1 and 1 and 1: pass + if 1 and 1 or 1 and 1 and 1 or not 1 and 1: pass + + def testComparison(self): + ### comparison: expr (comp_op expr)* + ### comp_op: '<'|'>'|'=='|'>='|'<='|'!='|'in'|'not' 'in'|'is'|'is' 'not' + if 1: pass + x = (1 == 1) + if 1 == 1: pass + if 1 != 1: pass + if 1 < 1: pass + if 1 > 1: pass + if 1 <= 1: pass + if 1 >= 1: pass + if 1 is 1: pass + if 1 is not 1: pass + if 1 in (): pass + if 1 not in (): pass + if 1 < 1 > 1 == 1 >= 1 <= 1 != 1 in 1 not in 1 is 1 is not 1: pass + + def testBinaryMaskOps(self): + x = 1 & 1 + x = 1 ^ 1 + x = 1 | 1 + + def testShiftOps(self): + x = 1 << 1 + x = 1 >> 1 + x = 1 << 1 >> 1 + + def testAdditiveOps(self): + x = 1 + x = 1 + 1 + x = 1 - 1 - 1 + x = 1 - 1 + 1 - 1 + 1 + + def testMultiplicativeOps(self): + x = 1 * 1 + x = 1 / 1 + x = 1 % 1 + x = 1 / 1 * 1 % 1 + + def testUnaryOps(self): + x = +1 + x = -1 + x = ~1 + x = ~1 ^ 1 & 1 | 1 & 1 ^ -1 + x = -1*1/1 + 1*1 - ---1*1 + + def testSelectors(self): + ### trailer: '(' [testlist] ')' | '[' subscript ']' | '.' NAME + ### subscript: expr | [expr] ':' [expr] + + import sys, time + c = sys.path[0] + x = time.time() + x = sys.modules['time'].time() + a = '01234' + c = a[0] + c = a[-1] + s = a[0:5] + s = a[:5] + s = a[0:] + s = a[:] + s = a[-5:] + s = a[:-1] + s = a[-4:-3] + # A rough test of SF bug 1333982. http://python.org/sf/1333982 + # The testing here is fairly incomplete. + # Test cases should include: commas with 1 and 2 colons + d = {} + d[1] = 1 + d[1,] = 2 + d[1,2] = 3 + d[1,2,3] = 4 + L = list(d) + L.sort(key=lambda x: x if isinstance(x, tuple) else ()) + self.assertEquals(str(L), '[1, (1,), (1, 2), (1, 2, 3)]') + + def testAtoms(self): + ### atom: '(' [testlist] ')' | '[' [testlist] ']' | '{' [dictsetmaker] '}' | NAME | NUMBER | STRING + ### dictsetmaker: (test ':' test (',' test ':' test)* [',']) | (test (',' test)* [',']) + + x = (1) + x = (1 or 2 or 3) + x = (1 or 2 or 3, 2, 3) + + x = [] + x = [1] + x = [1 or 2 or 3] + x = [1 or 2 or 3, 2, 3] + x = [] + + x = {} + x = {'one': 1} + x = {'one': 1,} + x = {'one' or 'two': 1 or 2} + x = {'one': 1, 'two': 2} + x = {'one': 1, 'two': 2,} + x = {'one': 1, 'two': 2, 'three': 3, 'four': 4, 'five': 5, 'six': 6} + + x = {'one'} + x = {'one', 1,} + x = {'one', 'two', 'three'} + x = {2, 3, 4,} + + x = x + x = 'x' + x = 123 + + ### exprlist: expr (',' expr)* [','] + ### testlist: test (',' test)* [','] + # These have been exercised enough above + + def testClassdef(self): + # 'class' NAME ['(' [testlist] ')'] ':' suite + class B: pass + class B2(): pass + class C1(B): pass + class C2(B): pass + class D(C1, C2, B): pass + class C: + def meth1(self): pass + def meth2(self, arg): pass + def meth3(self, a1, a2): pass + + def testListcomps(self): + # list comprehension tests + nums = [1, 2, 3, 4, 5] + strs = ["Apple", "Banana", "Coconut"] + spcs = [" Apple", " Banana ", "Coco nut "] + + self.assertEqual([s.strip() for s in spcs], ['Apple', 'Banana', 'Coco nut']) + self.assertEqual([3 * x for x in nums], [3, 6, 9, 12, 15]) + self.assertEqual([x for x in nums if x > 2], [3, 4, 5]) + self.assertEqual([(i, s) for i in nums for s in strs], + [(1, 'Apple'), (1, 'Banana'), (1, 'Coconut'), + (2, 'Apple'), (2, 'Banana'), (2, 'Coconut'), + (3, 'Apple'), (3, 'Banana'), (3, 'Coconut'), + (4, 'Apple'), (4, 'Banana'), (4, 'Coconut'), + (5, 'Apple'), (5, 'Banana'), (5, 'Coconut')]) + self.assertEqual([(i, s) for i in nums for s in [f for f in strs if "n" in f]], + [(1, 'Banana'), (1, 'Coconut'), (2, 'Banana'), (2, 'Coconut'), + (3, 'Banana'), (3, 'Coconut'), (4, 'Banana'), (4, 'Coconut'), + (5, 'Banana'), (5, 'Coconut')]) + self.assertEqual([(lambda a:[a**i for i in range(a+1)])(j) for j in range(5)], + [[1], [1, 1], [1, 2, 4], [1, 3, 9, 27], [1, 4, 16, 64, 256]]) + + def test_in_func(l): + return [0 < x < 3 for x in l if x > 2] + + self.assertEqual(test_in_func(nums), [False, False, False]) + + def test_nested_front(): + self.assertEqual([[y for y in [x, x + 1]] for x in [1,3,5]], + [[1, 2], [3, 4], [5, 6]]) + + test_nested_front() + + check_syntax_error(self, "[i, s for i in nums for s in strs]") + check_syntax_error(self, "[x if y]") + + suppliers = [ + (1, "Boeing"), + (2, "Ford"), + (3, "Macdonalds") + ] + + parts = [ + (10, "Airliner"), + (20, "Engine"), + (30, "Cheeseburger") + ] + + suppart = [ + (1, 10), (1, 20), (2, 20), (3, 30) + ] + + x = [ + (sname, pname) + for (sno, sname) in suppliers + for (pno, pname) in parts + for (sp_sno, sp_pno) in suppart + if sno == sp_sno and pno == sp_pno + ] + + self.assertEqual(x, [('Boeing', 'Airliner'), ('Boeing', 'Engine'), ('Ford', 'Engine'), + ('Macdonalds', 'Cheeseburger')]) + + def testGenexps(self): + # generator expression tests + g = ([x for x in range(10)] for x in range(1)) + self.assertEqual(g.next(), [x for x in range(10)]) + try: + g.next() + self.fail('should produce StopIteration exception') + except StopIteration: + pass + a = 1 + try: + g = (a for d in a) + g.next() + self.fail('should produce TypeError') + except TypeError: + pass + + self.assertEqual(list((x, y) for x in 'abcd' for y in 'abcd'), [(x, y) for x in 'abcd' for y in 'abcd']) + self.assertEqual(list((x, y) for x in 'ab' for y in 'xy'), [(x, y) for x in 'ab' for y in 'xy']) + + a = [x for x in range(10)] + b = (x for x in (y for y in a)) + self.assertEqual(sum(b), sum([x for x in range(10)])) + + self.assertEqual(sum(x**2 for x in range(10)), sum([x**2 for x in range(10)])) + self.assertEqual(sum(x*x for x in range(10) if x%2), sum([x*x for x in range(10) if x%2])) + self.assertEqual(sum(x for x in (y for y in range(10))), sum([x for x in range(10)])) + self.assertEqual(sum(x for x in (y for y in (z for z in range(10)))), sum([x for x in range(10)])) + self.assertEqual(sum(x for x in [y for y in (z for z in range(10))]), sum([x for x in range(10)])) + self.assertEqual(sum(x for x in (y for y in (z for z in range(10) if True)) if True), sum([x for x in range(10)])) + self.assertEqual(sum(x for x in (y for y in (z for z in range(10) if True) if False) if True), 0) + check_syntax_error(self, "foo(x for x in range(10), 100)") + check_syntax_error(self, "foo(100, x for x in range(10))") + + def testComprehensionSpecials(self): + # test for outmost iterable precomputation + x = 10; g = (i for i in range(x)); x = 5 + self.assertEqual(len(list(g)), 10) + + # This should hold, since we're only precomputing outmost iterable. + x = 10; t = False; g = ((i,j) for i in range(x) if t for j in range(x)) + x = 5; t = True; + self.assertEqual([(i,j) for i in range(10) for j in range(5)], list(g)) + + # Grammar allows multiple adjacent 'if's in listcomps and genexps, + # even though it's silly. Make sure it works (ifelse broke this.) + self.assertEqual([ x for x in range(10) if x % 2 if x % 3 ], [1, 5, 7]) + self.assertEqual(list(x for x in range(10) if x % 2 if x % 3), [1, 5, 7]) + + # verify unpacking single element tuples in listcomp/genexp. + self.assertEqual([x for x, in [(4,), (5,), (6,)]], [4, 5, 6]) + self.assertEqual(list(x for x, in [(7,), (8,), (9,)]), [7, 8, 9]) + + def testIfElseExpr(self): + # Test ifelse expressions in various cases + def _checkeval(msg, ret): + "helper to check that evaluation of expressions is done correctly" + print x + return ret + + self.assertEqual([ x() for x in lambda: True, lambda: False if x() ], [True]) + self.assertEqual([ x() for x in (lambda: True, lambda: False) if x() ], [True]) + self.assertEqual([ x(False) for x in (lambda x: False if x else True, lambda x: True if x else False) if x(False) ], [True]) + self.assertEqual((5 if 1 else _checkeval("check 1", 0)), 5) + self.assertEqual((_checkeval("check 2", 0) if 0 else 5), 5) + self.assertEqual((5 and 6 if 0 else 1), 1) + self.assertEqual(((5 and 6) if 0 else 1), 1) + self.assertEqual((5 and (6 if 1 else 1)), 6) + self.assertEqual((0 or _checkeval("check 3", 2) if 0 else 3), 3) + self.assertEqual((1 or _checkeval("check 4", 2) if 1 else _checkeval("check 5", 3)), 1) + self.assertEqual((0 or 5 if 1 else _checkeval("check 6", 3)), 5) + self.assertEqual((not 5 if 1 else 1), False) + self.assertEqual((not 5 if 0 else 1), 1) + self.assertEqual((6 + 1 if 1 else 2), 7) + self.assertEqual((6 - 1 if 1 else 2), 5) + self.assertEqual((6 * 2 if 1 else 4), 12) + self.assertEqual((6 / 2 if 1 else 3), 3) + self.assertEqual((6 < 4 if 0 else 2), 2) -print '1.2 Grammar' - -print 'single_input' # NEWLINE | simple_stmt | compound_stmt NEWLINE -# XXX can't test in a script -- this rule is only used when interactive - -print 'file_input' # (NEWLINE | stmt)* ENDMARKER -# Being tested as this very moment this very module - -print 'expr_input' # testlist NEWLINE -# XXX Hard to test -- used only in calls to input() - -print 'eval_input' # testlist ENDMARKER -x = eval('1, 0 or 1') - -print 'funcdef' -### 'def' NAME parameters ':' suite -### parameters: '(' [varargslist] ')' -### varargslist: (fpdef ['=' test] ',')* -### ('*' (NAME|',' fpdef ['=' test]) [',' ('**'|'*' '*') NAME] -### | ('**'|'*' '*') NAME) -### | fpdef ['=' test] (',' fpdef ['=' test])* [','] -### fpdef: NAME | '(' fplist ')' -### fplist: fpdef (',' fpdef)* [','] -### arglist: (argument ',')* (argument | *' test [',' '**' test] | '**' test) -### argument: [test '='] test # Really [keyword '='] test -def f1(): pass -f1() -f1(*()) -f1(*(), **{}) -def f2(one_argument): pass -def f3(two, arguments): pass -def f4(two, (compound, (argument, list))): pass -def f5((compound, first), two): pass -vereq(f2.func_code.co_varnames, ('one_argument',)) -vereq(f3.func_code.co_varnames, ('two', 'arguments')) -if sys.platform.startswith('java'): - vereq(f4.func_code.co_varnames, - ('two', '(compound, (argument, list))', 'compound', 'argument', - 'list',)) - vereq(f5.func_code.co_varnames, - ('(compound, first)', 'two', 'compound', 'first')) -else: - vereq(f4.func_code.co_varnames, - ('two', '.1', 'compound', 'argument', 'list')) - vereq(f5.func_code.co_varnames, - ('.0', 'two', 'compound', 'first')) -def a1(one_arg,): pass -def a2(two, args,): pass -def v0(*rest): pass -def v1(a, *rest): pass -def v2(a, b, *rest): pass -def v3(a, (b, c), *rest): return a, b, c, rest -# ceval unpacks the formal arguments into the first argcount names; -# thus, the names nested inside tuples must appear after these names. -if sys.platform.startswith('java'): - verify(v3.func_code.co_varnames == ('a', '(b, c)', 'rest', 'b', 'c')) -else: - vereq(v3.func_code.co_varnames, ('a', '.1', 'rest', 'b', 'c')) -verify(v3(1, (2, 3), 4) == (1, 2, 3, (4,))) -def d01(a=1): pass -d01() -d01(1) -d01(*(1,)) -d01(**{'a':2}) -def d11(a, b=1): pass -d11(1) -d11(1, 2) -d11(1, **{'b':2}) -def d21(a, b, c=1): pass -d21(1, 2) -d21(1, 2, 3) -d21(*(1, 2, 3)) -d21(1, *(2, 3)) -d21(1, 2, *(3,)) -d21(1, 2, **{'c':3}) -def d02(a=1, b=2): pass -d02() -d02(1) -d02(1, 2) -d02(*(1, 2)) -d02(1, *(2,)) -d02(1, **{'b':2}) -d02(**{'a': 1, 'b': 2}) -def d12(a, b=1, c=2): pass -d12(1) -d12(1, 2) -d12(1, 2, 3) -def d22(a, b, c=1, d=2): pass -d22(1, 2) -d22(1, 2, 3) -d22(1, 2, 3, 4) -def d01v(a=1, *rest): pass -d01v() -d01v(1) -d01v(1, 2) -d01v(*(1, 2, 3, 4)) -d01v(*(1,)) -d01v(**{'a':2}) -def d11v(a, b=1, *rest): pass -d11v(1) -d11v(1, 2) -d11v(1, 2, 3) -def d21v(a, b, c=1, *rest): pass -d21v(1, 2) -d21v(1, 2, 3) -d21v(1, 2, 3, 4) -d21v(*(1, 2, 3, 4)) -d21v(1, 2, **{'c': 3}) -def d02v(a=1, b=2, *rest): pass -d02v() -d02v(1) -d02v(1, 2) -d02v(1, 2, 3) -d02v(1, *(2, 3, 4)) -d02v(**{'a': 1, 'b': 2}) -def d12v(a, b=1, c=2, *rest): pass -d12v(1) -d12v(1, 2) -d12v(1, 2, 3) -d12v(1, 2, 3, 4) -d12v(*(1, 2, 3, 4)) -d12v(1, 2, *(3, 4, 5)) -d12v(1, *(2,), **{'c': 3}) -def d22v(a, b, c=1, d=2, *rest): pass -d22v(1, 2) -d22v(1, 2, 3) -d22v(1, 2, 3, 4) -d22v(1, 2, 3, 4, 5) -d22v(*(1, 2, 3, 4)) -d22v(1, 2, *(3, 4, 5)) -d22v(1, *(2, 3), **{'d': 4}) -def d31v((x)): pass -d31v(1) -def d32v((x,)): pass -d32v((1,)) -#keyword only argument tests -def pos0key1(*, key): return key -pos0key1(key=100) -def pos2key2(p1, p2, *, k1, k2=100): return p1,p2,k1,k2 -pos2key2(1, 2, k1=100) -pos2key2(1, 2, k1=100, k2=200) -pos2key2(1, 2, k2=100, k1=200) -def pos2key2dict(p1, p2, *, k1=100, k2, **kwarg): return p1,p2,k1,k2,kwarg -pos2key2dict(1,2,k2=100,tokwarg1=100,tokwarg2=200) -pos2key2dict(1,2,tokwarg1=100,tokwarg2=200, k2=100) - -### lambdef: 'lambda' [varargslist] ':' test -print 'lambdef' -l1 = lambda : 0 -verify(l1() == 0) -l2 = lambda : a[d] # XXX just testing the expression -l3 = lambda : [2 < x for x in [-1, 3, 0L]] -verify(l3() == [0, 1, 0]) -l4 = lambda x = lambda y = lambda z=1 : z : y() : x() -verify(l4() == 1) -l5 = lambda x, y, z=2: x + y + z -verify(l5(1, 2) == 5) -verify(l5(1, 2, 3) == 6) -check_syntax("lambda x: x = 2") -l6 = lambda x, y, *, k=20: x+y+k -verify(l6(1,2) == 1+2+20) -verify(l6(1,2,k=10) == 1+2+10) - -### stmt: simple_stmt | compound_stmt -# Tested below - -### simple_stmt: small_stmt (';' small_stmt)* [';'] -print 'simple_stmt' -x = 1; pass; del x -def foo(): - # verify statments that end with semi-colons - x = 1; pass; del x; -foo() - -### small_stmt: expr_stmt | print_stmt | pass_stmt | del_stmt | flow_stmt | import_stmt | global_stmt | access_stmt | exec_stmt -# Tested below - -print 'expr_stmt' # (exprlist '=')* exprlist -1 -1, 2, 3 -x = 1 -x = 1, 2, 3 -x = y = z = 1, 2, 3 -x, y, z = 1, 2, 3 -abc = a, b, c = x, y, z = xyz = 1, 2, (3, 4) -# NB these variables are deleted below - -check_syntax("x + 1 = 1") -check_syntax("a + 1 = b + 2") - -print 'print_stmt' # 'print' (test ',')* [test] -print 1, 2, 3 -print 1, 2, 3, -print -print 0 or 1, 0 or 1, -print 0 or 1 -print 'extended print_stmt' # 'print' '>>' test ',' -import sys -print >> sys.stdout, 1, 2, 3 -print >> sys.stdout, 1, 2, 3, -print >> sys.stdout -print >> sys.stdout, 0 or 1, 0 or 1, -print >> sys.stdout, 0 or 1 - -# test printing to an instance -class Gulp: - def write(self, msg): pass - -gulp = Gulp() -print >> gulp, 1, 2, 3 -print >> gulp, 1, 2, 3, -print >> gulp -print >> gulp, 0 or 1, 0 or 1, -print >> gulp, 0 or 1 - -# test print >> None -def driver(): - oldstdout = sys.stdout - sys.stdout = Gulp() - try: - tellme(Gulp()) - tellme() - finally: - sys.stdout = oldstdout - -# we should see this once -def tellme(file=sys.stdout): - print >> file, 'hello world' - -driver() - -# we should not see this at all -def tellme(file=None): - print >> file, 'goodbye universe' - -driver() - -# syntax errors -check_syntax('print ,') -check_syntax('print >> x,') - -print 'del_stmt' # 'del' exprlist -del abc -del x, y, (z, xyz) - -print 'pass_stmt' # 'pass' -pass - -print 'flow_stmt' # break_stmt | continue_stmt | return_stmt | raise_stmt -# Tested below - -print 'break_stmt' # 'break' -while 1: break - -print 'continue_stmt' # 'continue' -i = 1 -while i: i = 0; continue - -msg = "" -while not msg: - msg = "continue + try/except ok" - try: - continue - msg = "continue failed to continue inside try" - except: - msg = "continue inside try called except block" -print msg - -msg = "" -while not msg: - msg = "finally block not called" - try: - continue - finally: - msg = "continue + try/finally ok" -print msg - - -# This test warrants an explanation. It is a test specifically for SF bugs -# #463359 and #462937. The bug is that a 'break' statement executed or -# exception raised inside a try/except inside a loop, *after* a continue -# statement has been executed in that loop, will cause the wrong number of -# arguments to be popped off the stack and the instruction pointer reset to -# a very small number (usually 0.) Because of this, the following test -# *must* written as a function, and the tracking vars *must* be function -# arguments with default values. Otherwise, the test will loop and loop. - -print "testing continue and break in try/except in loop" -def test_break_continue_loop(extra_burning_oil = 1, count=0): - big_hippo = 2 - while big_hippo: - count += 1 - try: - if extra_burning_oil and big_hippo == 1: - extra_burning_oil -= 1 - break - big_hippo -= 1 - continue - except: - raise - if count > 2 or big_hippo != 1: - print "continue then break in try/except in loop broken!" -test_break_continue_loop() - -print 'return_stmt' # 'return' [testlist] -def g1(): return -def g2(): return 1 -g1() -x = g2() -check_syntax("class foo:return 1") - -print 'yield_stmt' -check_syntax("class foo:yield 1") - -print 'raise_stmt' # 'raise' test [',' test] -try: raise RuntimeError, 'just testing' -except RuntimeError: pass -try: raise KeyboardInterrupt -except KeyboardInterrupt: pass +def test_main(): + run_unittest(TokenTests, GrammarTests) -print 'import_name' # 'import' dotted_as_names -import sys -import time, sys -print 'import_from' # 'from' dotted_name 'import' ('*' | '(' import_as_names ')' | import_as_names) -from time import time -from time import (time) -from sys import * -from sys import path, argv -from sys import (path, argv) -from sys import (path, argv,) - -print 'global_stmt' # 'global' NAME (',' NAME)* -def f(): - global a - global a, b - global one, two, three, four, five, six, seven, eight, nine, ten - -print "assert_stmt" # assert_stmt: 'assert' test [',' test] -assert 1 -assert 1, 1 -assert lambda x:x -assert 1, lambda x:x+1 - -### compound_stmt: if_stmt | while_stmt | for_stmt | try_stmt | funcdef | classdef -# Tested below - -print 'if_stmt' # 'if' test ':' suite ('elif' test ':' suite)* ['else' ':' suite] -if 1: pass -if 1: pass -else: pass -if 0: pass -elif 0: pass -if 0: pass -elif 0: pass -elif 0: pass -elif 0: pass -else: pass - -print 'while_stmt' # 'while' test ':' suite ['else' ':' suite] -while 0: pass -while 0: pass -else: pass - -print 'for_stmt' # 'for' exprlist 'in' exprlist ':' suite ['else' ':' suite] -for i in 1, 2, 3: pass -for i, j, k in (): pass -else: pass -class Squares: - def __init__(self, max): - self.max = max - self.sofar = [] - def __len__(self): return len(self.sofar) - def __getitem__(self, i): - if not 0 <= i < self.max: raise IndexError - n = len(self.sofar) - while n <= i: - self.sofar.append(n*n) - n = n+1 - return self.sofar[i] -n = 0 -for x in Squares(10): n = n+x -if n != 285: raise TestFailed, 'for over growing sequence' - -result = [] -for x, in [(1,), (2,), (3,)]: - result.append(x) -vereq(result, [1, 2, 3]) - -print 'try_stmt' -### try_stmt: 'try' ':' suite (except_clause ':' suite)+ ['else' ':' suite] -### | 'try' ':' suite 'finally' ':' suite -### except_clause: 'except' [expr [',' expr]] -try: - 1/0 -except ZeroDivisionError: - pass -else: - pass -try: 1/0 -except EOFError: pass -except TypeError, msg: pass -except RuntimeError, msg: pass -except: pass -else: pass -try: 1/0 -except (EOFError, TypeError, ZeroDivisionError): pass -try: 1/0 -except (EOFError, TypeError, ZeroDivisionError), msg: pass -try: pass -finally: pass - -print 'suite' # simple_stmt | NEWLINE INDENT NEWLINE* (stmt NEWLINE*)+ DEDENT -if 1: pass -if 1: - pass -if 1: - # - # - # - pass - pass - # - pass - # - -print 'test' -### and_test ('or' and_test)* -### and_test: not_test ('and' not_test)* -### not_test: 'not' not_test | comparison -if not 1: pass -if 1 and 1: pass -if 1 or 1: pass -if not not not 1: pass -if not 1 and 1 and 1: pass -if 1 and 1 or 1 and 1 and 1 or not 1 and 1: pass - -print 'comparison' -### comparison: expr (comp_op expr)* -### comp_op: '<'|'>'|'=='|'>='|'<='|'!='|'in'|'not' 'in'|'is'|'is' 'not' -if 1: pass -x = (1 == 1) -if 1 == 1: pass -if 1 != 1: pass -if 1 < 1: pass -if 1 > 1: pass -if 1 <= 1: pass -if 1 >= 1: pass -if 1 is 1: pass -if 1 is not 1: pass -if 1 in (): pass -if 1 not in (): pass -if 1 < 1 > 1 == 1 >= 1 <= 1 != 1 in 1 not in 1 is 1 is not 1: pass - -print 'binary mask ops' -x = 1 & 1 -x = 1 ^ 1 -x = 1 | 1 - -print 'shift ops' -x = 1 << 1 -x = 1 >> 1 -x = 1 << 1 >> 1 - -print 'additive ops' -x = 1 -x = 1 + 1 -x = 1 - 1 - 1 -x = 1 - 1 + 1 - 1 + 1 - -print 'multiplicative ops' -x = 1 * 1 -x = 1 / 1 -x = 1 % 1 -x = 1 / 1 * 1 % 1 - -print 'unary ops' -x = +1 -x = -1 -x = ~1 -x = ~1 ^ 1 & 1 | 1 & 1 ^ -1 -x = -1*1/1 + 1*1 - ---1*1 - -print 'selectors' -### trailer: '(' [testlist] ')' | '[' subscript ']' | '.' NAME -### subscript: expr | [expr] ':' [expr] -f1() -f2(1) -f2(1,) -f3(1, 2) -f3(1, 2,) -f4(1, (2, (3, 4))) -v0() -v0(1) -v0(1,) -v0(1,2) -v0(1,2,3,4,5,6,7,8,9,0) -v1(1) -v1(1,) -v1(1,2) -v1(1,2,3) -v1(1,2,3,4,5,6,7,8,9,0) -v2(1,2) -v2(1,2,3) -v2(1,2,3,4) -v2(1,2,3,4,5,6,7,8,9,0) -v3(1,(2,3)) -v3(1,(2,3),4) -v3(1,(2,3),4,5,6,7,8,9,0) -print -import sys, time -c = sys.path[0] -x = time.time() -x = sys.modules['time'].time() -a = '01234' -c = a[0] -c = a[-1] -s = a[0:5] -s = a[:5] -s = a[0:] -s = a[:] -s = a[-5:] -s = a[:-1] -s = a[-4:-3] -# A rough test of SF bug 1333982. http://python.org/sf/1333982 -# The testing here is fairly incomplete. -# Test cases should include: commas with 1 and 2 colons -d = {} -d[1] = 1 -d[1,] = 2 -d[1,2] = 3 -d[1,2,3] = 4 -L = list(d) -L.sort(key=lambda x: x if isinstance(x, tuple) else ()) -print L - - -print 'atoms' -### atom: '(' [testlist] ')' | '[' [testlist] ']' | '{' [dictsetmaker] '}' | NAME | NUMBER | STRING -### dictsetmaker: (test ':' test (',' test ':' test)* [',']) | (test (',' test)* [',']) - -x = (1) -x = (1 or 2 or 3) -x = (1 or 2 or 3, 2, 3) - -x = [] -x = [1] -x = [1 or 2 or 3] -x = [1 or 2 or 3, 2, 3] -x = [] - -x = {} -x = {'one': 1} -x = {'one': 1,} -x = {'one' or 'two': 1 or 2} -x = {'one': 1, 'two': 2} -x = {'one': 1, 'two': 2,} -x = {'one': 1, 'two': 2, 'three': 3, 'four': 4, 'five': 5, 'six': 6} - -x = {'one'} -x = {'one', 1,} -x = {'one', 'two', 'three'} -x = {2, 3, 4,} - -x = x -x = 'x' -x = 123 - -### exprlist: expr (',' expr)* [','] -### testlist: test (',' test)* [','] -# These have been exercised enough above - -print 'classdef' # 'class' NAME ['(' [testlist] ')'] ':' suite -class B: pass -class B2(): pass -class C1(B): pass -class C2(B): pass -class D(C1, C2, B): pass -class C: - def meth1(self): pass - def meth2(self, arg): pass - def meth3(self, a1, a2): pass - -# list comprehension tests -nums = [1, 2, 3, 4, 5] -strs = ["Apple", "Banana", "Coconut"] -spcs = [" Apple", " Banana ", "Coco nut "] - -print [s.strip() for s in spcs] -print [3 * x for x in nums] -print [x for x in nums if x > 2] -print [(i, s) for i in nums for s in strs] -print [(i, s) for i in nums for s in [f for f in strs if "n" in f]] -print [(lambda a:[a**i for i in range(a+1)])(j) for j in range(5)] - -def test_in_func(l): - return [0 < x < 3 for x in l if x > 2] - -print test_in_func(nums) - -def test_nested_front(): - print [[y for y in [x, x + 1]] for x in [1,3,5]] - -test_nested_front() - -check_syntax("[i, s for i in nums for s in strs]") -check_syntax("[x if y]") - -suppliers = [ - (1, "Boeing"), - (2, "Ford"), - (3, "Macdonalds") -] - -parts = [ - (10, "Airliner"), - (20, "Engine"), - (30, "Cheeseburger") -] - -suppart = [ - (1, 10), (1, 20), (2, 20), (3, 30) -] - -print [ - (sname, pname) - for (sno, sname) in suppliers - for (pno, pname) in parts - for (sp_sno, sp_pno) in suppart - if sno == sp_sno and pno == sp_pno -] - -# generator expression tests -g = ([x for x in range(10)] for x in range(1)) -verify(g.next() == [x for x in range(10)]) -try: - g.next() - raise TestFailed, 'should produce StopIteration exception' -except StopIteration: - pass - -a = 1 -try: - g = (a for d in a) - g.next() - raise TestFailed, 'should produce TypeError' -except TypeError: - pass - -verify(list((x, y) for x in 'abcd' for y in 'abcd') == [(x, y) for x in 'abcd' for y in 'abcd']) -verify(list((x, y) for x in 'ab' for y in 'xy') == [(x, y) for x in 'ab' for y in 'xy']) - -a = [x for x in range(10)] -b = (x for x in (y for y in a)) -verify(sum(b) == sum([x for x in range(10)])) - -verify(sum(x**2 for x in range(10)) == sum([x**2 for x in range(10)])) -verify(sum(x*x for x in range(10) if x%2) == sum([x*x for x in range(10) if x%2])) -verify(sum(x for x in (y for y in range(10))) == sum([x for x in range(10)])) -verify(sum(x for x in (y for y in (z for z in range(10)))) == sum([x for x in range(10)])) -verify(sum(x for x in [y for y in (z for z in range(10))]) == sum([x for x in range(10)])) -verify(sum(x for x in (y for y in (z for z in range(10) if True)) if True) == sum([x for x in range(10)])) -verify(sum(x for x in (y for y in (z for z in range(10) if True) if False) if True) == 0) -check_syntax("foo(x for x in range(10), 100)") -check_syntax("foo(100, x for x in range(10))") - -# test for outmost iterable precomputation -x = 10; g = (i for i in range(x)); x = 5 -verify(len(list(g)) == 10) - -# This should hold, since we're only precomputing outmost iterable. -x = 10; t = False; g = ((i,j) for i in range(x) if t for j in range(x)) -x = 5; t = True; -verify([(i,j) for i in range(10) for j in range(5)] == list(g)) - -# Grammar allows multiple adjacent 'if's in listcomps and genexps, -# even though it's silly. Make sure it works (ifelse broke this.) -verify([ x for x in range(10) if x % 2 if x % 3 ], [1, 5, 7]) -verify((x for x in range(10) if x % 2 if x % 3), [1, 5, 7]) - -# Test ifelse expressions in various cases -def _checkeval(msg, ret): - "helper to check that evaluation of expressions is done correctly" - print x - return ret - -verify([ x() for x in lambda: True, lambda: False if x() ] == [True]) -verify([ x() for x in (lambda: True, lambda: False) if x() ] == [True]) -verify([ x(False) for x in (lambda x: False if x else True, lambda x: True if x else False) if x(False) ] == [True]) -verify((5 if 1 else _checkeval("check 1", 0)) == 5) -verify((_checkeval("check 2", 0) if 0 else 5) == 5) -verify((5 and 6 if 0 else 1) == 1) -verify(((5 and 6) if 0 else 1) == 1) -verify((5 and (6 if 1 else 1)) == 6) -verify((0 or _checkeval("check 3", 2) if 0 else 3) == 3) -verify((1 or _checkeval("check 4", 2) if 1 else _checkeval("check 5", 3)) == 1) -verify((0 or 5 if 1 else _checkeval("check 6", 3)) == 5) -verify((not 5 if 1 else 1) == False) -verify((not 5 if 0 else 1) == 1) -verify((6 + 1 if 1 else 2) == 7) -verify((6 - 1 if 1 else 2) == 5) -verify((6 * 2 if 1 else 4) == 12) -verify((6 / 2 if 1 else 3) == 3) -verify((6 < 4 if 0 else 2) == 2) +if __name__ == '__main__': + test_main() Modified: python/branches/p3yk/Lib/test/test_gzip.py ============================================================================== --- python/branches/p3yk/Lib/test/test_gzip.py (original) +++ python/branches/p3yk/Lib/test/test_gzip.py Wed Dec 13 05:49:30 2006 @@ -128,6 +128,17 @@ f.seek(newpos) # positive seek f.close() + def test_seek_whence(self): + self.test_write() + # Try seek(whence=1), read test + + f = gzip.GzipFile(self.filename) + f.read(10) + f.seek(10, whence=1) + y = f.read(10) + f.close() + self.assertEquals(y, data1[20:30]) + def test_seek_write(self): # Try seek, write test f = gzip.GzipFile(self.filename, 'w') Modified: python/branches/p3yk/Lib/test/test_httplib.py ============================================================================== --- python/branches/p3yk/Lib/test/test_httplib.py (original) +++ python/branches/p3yk/Lib/test/test_httplib.py Wed Dec 13 05:49:30 2006 @@ -10,9 +10,10 @@ def __init__(self, text, fileclass=StringIO.StringIO): self.text = text self.fileclass = fileclass + self.data = '' def sendall(self, data): - self.data = data + self.data += data def makefile(self, mode, bufsize=None): if mode != 'r' and mode != 'rb': @@ -70,103 +71,86 @@ conn.request('POST', '/', body, headers) self.assertEqual(conn._buffer.count[header.lower()], 1) -# Collect output to a buffer so that we don't have to cope with line-ending -# issues across platforms. Specifically, the headers will have \r\n pairs -# and some platforms will strip them from the output file. - -def test(): - buf = StringIO.StringIO() - _stdout = sys.stdout - try: - sys.stdout = buf - _test() - finally: - sys.stdout = _stdout - - # print individual lines with endings stripped - s = buf.getvalue() - for line in s.split("\n"): - print line.strip() - -def _test(): - # Test HTTP status lines - - body = "HTTP/1.1 200 Ok\r\n\r\nText" - sock = FakeSocket(body) - resp = httplib.HTTPResponse(sock, 1) - resp.begin() - print resp.read() - resp.close() - - body = "HTTP/1.1 400.100 Not Ok\r\n\r\nText" - sock = FakeSocket(body) - resp = httplib.HTTPResponse(sock, 1) - try: +class BasicTest(TestCase): + def test_status_lines(self): + # Test HTTP status lines + + body = "HTTP/1.1 200 Ok\r\n\r\nText" + sock = FakeSocket(body) + resp = httplib.HTTPResponse(sock) resp.begin() - except httplib.BadStatusLine: - print "BadStatusLine raised as expected" - else: - print "Expect BadStatusLine" - - # Check invalid host_port - - for hp in ("www.python.org:abc", "www.python.org:"): - try: - h = httplib.HTTP(hp) - except httplib.InvalidURL: - print "InvalidURL raised as expected" - else: - print "Expect InvalidURL" - - for hp,h,p in (("[fe80::207:e9ff:fe9b]:8000", "fe80::207:e9ff:fe9b", 8000), - ("www.python.org:80", "www.python.org", 80), - ("www.python.org", "www.python.org", 80), - ("[fe80::207:e9ff:fe9b]", "fe80::207:e9ff:fe9b", 80)): - try: - http = httplib.HTTP(hp) - except httplib.InvalidURL: - print "InvalidURL raised erroneously" - c = http._conn - if h != c.host: raise AssertionError, ("Host incorrectly parsed", h, c.host) - if p != c.port: raise AssertionError, ("Port incorrectly parsed", p, c.host) - - # test response with multiple message headers with the same field name. - text = ('HTTP/1.1 200 OK\r\n' - 'Set-Cookie: Customer="WILE_E_COYOTE"; Version="1"; Path="/acme"\r\n' - 'Set-Cookie: Part_Number="Rocket_Launcher_0001"; Version="1";' - ' Path="/acme"\r\n' - '\r\n' - 'No body\r\n') - hdr = ('Customer="WILE_E_COYOTE"; Version="1"; Path="/acme"' - ', ' - 'Part_Number="Rocket_Launcher_0001"; Version="1"; Path="/acme"') - s = FakeSocket(text) - r = httplib.HTTPResponse(s, 1) - r.begin() - cookies = r.getheader("Set-Cookie") - if cookies != hdr: - raise AssertionError, "multiple headers not combined properly" - - # Test that the library doesn't attempt to read any data - # from a HEAD request. (Tickles SF bug #622042.) - sock = FakeSocket( - 'HTTP/1.1 200 OK\r\n' - 'Content-Length: 14432\r\n' - '\r\n', - NoEOFStringIO) - resp = httplib.HTTPResponse(sock, 1, method="HEAD") - resp.begin() - if resp.read() != "": - raise AssertionError, "Did not expect response from HEAD request" - resp.close() + self.assertEqual(resp.read(), 'Text') + resp.close() + body = "HTTP/1.1 400.100 Not Ok\r\n\r\nText" + sock = FakeSocket(body) + resp = httplib.HTTPResponse(sock) + self.assertRaises(httplib.BadStatusLine, resp.begin) + + def test_host_port(self): + # Check invalid host_port + + for hp in ("www.python.org:abc", "www.python.org:"): + self.assertRaises(httplib.InvalidURL, httplib.HTTP, hp) + + for hp, h, p in (("[fe80::207:e9ff:fe9b]:8000", "fe80::207:e9ff:fe9b", 8000), + ("www.python.org:80", "www.python.org", 80), + ("www.python.org", "www.python.org", 80), + ("[fe80::207:e9ff:fe9b]", "fe80::207:e9ff:fe9b", 80)): + http = httplib.HTTP(hp) + c = http._conn + if h != c.host: self.fail("Host incorrectly parsed: %s != %s" % (h, c.host)) + if p != c.port: self.fail("Port incorrectly parsed: %s != %s" % (p, c.host)) + + def test_response_headers(self): + # test response with multiple message headers with the same field name. + text = ('HTTP/1.1 200 OK\r\n' + 'Set-Cookie: Customer="WILE_E_COYOTE"; Version="1"; Path="/acme"\r\n' + 'Set-Cookie: Part_Number="Rocket_Launcher_0001"; Version="1";' + ' Path="/acme"\r\n' + '\r\n' + 'No body\r\n') + hdr = ('Customer="WILE_E_COYOTE"; Version="1"; Path="/acme"' + ', ' + 'Part_Number="Rocket_Launcher_0001"; Version="1"; Path="/acme"') + s = FakeSocket(text) + r = httplib.HTTPResponse(s) + r.begin() + cookies = r.getheader("Set-Cookie") + if cookies != hdr: + self.fail("multiple headers not combined properly") + + def test_read_head(self): + # Test that the library doesn't attempt to read any data + # from a HEAD request. (Tickles SF bug #622042.) + sock = FakeSocket( + 'HTTP/1.1 200 OK\r\n' + 'Content-Length: 14432\r\n' + '\r\n', + NoEOFStringIO) + resp = httplib.HTTPResponse(sock, method="HEAD") + resp.begin() + if resp.read() != "": + self.fail("Did not expect response from HEAD request") + resp.close() + + def test_send_file(self): + expected = 'GET /foo HTTP/1.1\r\nHost: example.com\r\n' \ + 'Accept-Encoding: identity\r\nContent-Length:' + + body = open(__file__, 'rb') + conn = httplib.HTTPConnection('example.com') + sock = FakeSocket(body) + conn.sock = sock + conn.request('GET', '/foo', body) + self.assertTrue(sock.data.startswith(expected)) class OfflineTest(TestCase): def test_responses(self): self.assertEquals(httplib.responses[httplib.NOT_FOUND], "Not Found") def test_main(verbose=None): - tests = [HeaderTests,OfflineTest] - test_support.run_unittest(*tests) + test_support.run_unittest(HeaderTests, OfflineTest, BasicTest) -test() +if __name__ == '__main__': + test_main() Modified: python/branches/p3yk/Lib/test/test_imp.py ============================================================================== --- python/branches/p3yk/Lib/test/test_imp.py (original) +++ python/branches/p3yk/Lib/test/test_imp.py Wed Dec 13 05:49:30 2006 @@ -1,43 +1,47 @@ import imp -from test.test_support import TestFailed, TestSkipped -try: - import thread -except ImportError: - raise TestSkipped("test only valid when thread support is available") - -def verify_lock_state(expected): - if imp.lock_held() != expected: - raise TestFailed("expected imp.lock_held() to be %r" % expected) - -def testLock(): - LOOPS = 50 - - # The import lock may already be held, e.g. if the test suite is run - # via "import test.autotest". - lock_held_at_start = imp.lock_held() - verify_lock_state(lock_held_at_start) - - for i in range(LOOPS): - imp.acquire_lock() - verify_lock_state(True) +import thread +import unittest +from test import test_support - for i in range(LOOPS): - imp.release_lock() - # The original state should be restored now. - verify_lock_state(lock_held_at_start) +class LockTests(unittest.TestCase): - if not lock_held_at_start: - try: + """Very basic test of import lock functions.""" + + def verify_lock_state(self, expected): + self.failUnlessEqual(imp.lock_held(), expected, + "expected imp.lock_held() to be %r" % expected) + def testLock(self): + LOOPS = 50 + + # The import lock may already be held, e.g. if the test suite is run + # via "import test.autotest". + lock_held_at_start = imp.lock_held() + self.verify_lock_state(lock_held_at_start) + + for i in range(LOOPS): + imp.acquire_lock() + self.verify_lock_state(True) + + for i in range(LOOPS): imp.release_lock() - except RuntimeError: - pass - else: - raise TestFailed("release_lock() without lock should raise " - "RuntimeError") + + # The original state should be restored now. + self.verify_lock_state(lock_held_at_start) + + if not lock_held_at_start: + try: + imp.release_lock() + except RuntimeError: + pass + else: + self.fail("release_lock() without lock should raise " + "RuntimeError") def test_main(): - testLock() + test_support.run_unittest( + LockTests, + ) if __name__ == "__main__": test_main() Modified: python/branches/p3yk/Lib/test/test_import.py ============================================================================== --- python/branches/p3yk/Lib/test/test_import.py (original) +++ python/branches/p3yk/Lib/test/test_import.py Wed Dec 13 05:49:30 2006 @@ -1,21 +1,11 @@ -from test.test_support import TESTFN, TestFailed +from test.test_support import TESTFN, run_unittest +import unittest import os import random import sys import py_compile -# Brief digression to test that import is case-sensitive: if we got this -# far, we know for sure that "random" exists. -try: - import RAnDoM -except ImportError: - pass -else: - raise TestFailed("import of RAnDoM should have failed (case mismatch)") - -# Another brief digression to test the accuracy of manifest float constants. -from test import double_const # don't blink -- that *was* the test def remove_files(name): for f in (name + os.extsep + "py", @@ -26,199 +16,206 @@ if os.path.exists(f): os.remove(f) -def test_with_extension(ext): # ext normally ".py"; perhaps ".pyw" - source = TESTFN + ext - pyo = TESTFN + os.extsep + "pyo" - if sys.platform.startswith('java'): - pyc = TESTFN + "$py.class" - else: - pyc = TESTFN + os.extsep + "pyc" - - f = open(source, "w") - print >> f, "# This tests Python's ability to import a", ext, "file." - a = random.randrange(1000) - b = random.randrange(1000) - print >> f, "a =", a - print >> f, "b =", b - f.close() - - try: - try: - mod = __import__(TESTFN) - except ImportError, err: - raise ValueError("import from %s failed: %s" % (ext, err)) - if mod.a != a or mod.b != b: - print a, "!=", mod.a - print b, "!=", mod.b - raise ValueError("module loaded (%s) but contents invalid" % mod) - finally: - os.unlink(source) +class ImportTest(unittest.TestCase): - try: + def testCaseSensitivity(self): + # Brief digression to test that import is case-sensitive: if we got this + # far, we know for sure that "random" exists. try: - reload(mod) - except ImportError, err: - raise ValueError("import from .pyc/.pyo failed: %s" % err) - finally: - try: - os.unlink(pyc) - except os.error: - pass - try: - os.unlink(pyo) - except os.error: + import RAnDoM + except ImportError: pass - del sys.modules[TESTFN] + else: + self.fail("import of RAnDoM should have failed (case mismatch)") -sys.path.insert(0, os.curdir) -try: - test_with_extension(os.extsep + "py") - if sys.platform.startswith("win"): - for ext in ".PY", ".Py", ".pY", ".pyw", ".PYW", ".pYw": - test_with_extension(ext) -finally: - del sys.path[0] - -# Verify that the imp module can correctly load and find .py files -import imp -x = imp.find_module("os") -os = imp.load_module("os", *x) - -def test_module_with_large_stack(module): - # create module w/list of 65000 elements to test bug #561858 - filename = module + os.extsep + 'py' - - # create a file with a list of 65000 elements - f = open(filename, 'w+') - f.write('d = [\n') - for i in range(65000): - f.write('"",\n') - f.write(']') - f.close() - - # compile & remove .py file, we only need .pyc (or .pyo) - f = open(filename, 'r') - py_compile.compile(filename) - f.close() - os.unlink(filename) - - # need to be able to load from current dir - sys.path.append('') - - # this used to crash - exec('import ' + module) - - # cleanup - del sys.path[-1] - for ext in 'pyc', 'pyo': - fname = module + os.extsep + ext - if os.path.exists(fname): - os.unlink(fname) - -test_module_with_large_stack('longlist') - -def test_failing_import_sticks(): - source = TESTFN + os.extsep + "py" - f = open(source, "w") - print >> f, "a = 1/0" - f.close() - - # New in 2.4, we shouldn't be able to import that no matter how often - # we try. - sys.path.insert(0, os.curdir) - try: - for i in 1, 2, 3: - try: - mod = __import__(TESTFN) - except ZeroDivisionError: - if TESTFN in sys.modules: - raise TestFailed("damaged module in sys.modules", i) + def testDoubleConst(self): + # Another brief digression to test the accuracy of manifest float constants. + from test import double_const # don't blink -- that *was* the test + + def testImport(self): + def test_with_extension(ext): + # ext normally ".py"; perhaps ".pyw" + source = TESTFN + ext + pyo = TESTFN + os.extsep + "pyo" + if sys.platform.startswith('java'): + pyc = TESTFN + "$py.class" else: - raise TestFailed("was able to import a damaged module", i) - finally: - sys.path.pop(0) - remove_files(TESTFN) - -test_failing_import_sticks() - -def test_failing_reload(): - # A failing reload should leave the module object in sys.modules. - source = TESTFN + os.extsep + "py" - f = open(source, "w") - print >> f, "a = 1" - print >> f, "b = 2" - f.close() - - sys.path.insert(0, os.curdir) - try: - mod = __import__(TESTFN) - if TESTFN not in sys.modules: - raise TestFailed("expected module in sys.modules") - if mod.a != 1 or mod.b != 2: - raise TestFailed("module has wrong attribute values") - - # On WinXP, just replacing the .py file wasn't enough to - # convince reload() to reparse it. Maybe the timestamp didn't - # move enough. We force it to get reparsed by removing the - # compiled file too. - remove_files(TESTFN) + pyc = TESTFN + os.extsep + "pyc" + + f = open(source, "w") + print >> f, "# This tests Python's ability to import a", ext, "file." + a = random.randrange(1000) + b = random.randrange(1000) + print >> f, "a =", a + print >> f, "b =", b + f.close() + + try: + try: + mod = __import__(TESTFN) + except ImportError, err: + self.fail("import from %s failed: %s" % (ext, err)) + + self.assertEquals(mod.a, a, + "module loaded (%s) but contents invalid" % mod) + self.assertEquals(mod.b, b, + "module loaded (%s) but contents invalid" % mod) + finally: + os.unlink(source) - # Now damage the module. + try: + try: + reload(mod) + except ImportError, err: + self.fail("import from .pyc/.pyo failed: %s" % err) + finally: + try: + os.unlink(pyc) + except OSError: + pass + try: + os.unlink(pyo) + except OSError: + pass + del sys.modules[TESTFN] + + sys.path.insert(0, os.curdir) + try: + test_with_extension(os.extsep + "py") + if sys.platform.startswith("win"): + for ext in ".PY", ".Py", ".pY", ".pyw", ".PYW", ".pYw": + test_with_extension(ext) + finally: + del sys.path[0] + + def testImpModule(self): + # Verify that the imp module can correctly load and find .py files + import imp + x = imp.find_module("os") + os = imp.load_module("os", *x) + + def test_module_with_large_stack(self, module='longlist'): + # create module w/list of 65000 elements to test bug #561858 + filename = module + os.extsep + 'py' + + # create a file with a list of 65000 elements + f = open(filename, 'w+') + f.write('d = [\n') + for i in range(65000): + f.write('"",\n') + f.write(']') + f.close() + + # compile & remove .py file, we only need .pyc (or .pyo) + f = open(filename, 'r') + py_compile.compile(filename) + f.close() + os.unlink(filename) + + # need to be able to load from current dir + sys.path.append('') + + # this used to crash + exec('import ' + module) + + # cleanup + del sys.path[-1] + for ext in 'pyc', 'pyo': + fname = module + os.extsep + ext + if os.path.exists(fname): + os.unlink(fname) + + def test_failing_import_sticks(self): + source = TESTFN + os.extsep + "py" f = open(source, "w") - print >> f, "a = 10" - print >> f, "b = 20//0" + print >> f, "a = 1/0" f.close() + + # New in 2.4, we shouldn't be able to import that no matter how often + # we try. + sys.path.insert(0, os.curdir) try: - reload(mod) - except ZeroDivisionError: - pass - else: - raise TestFailed("was able to reload a damaged module") + for i in 1, 2, 3: + try: + mod = __import__(TESTFN) + except ZeroDivisionError: + if TESTFN in sys.modules: + self.fail("damaged module in sys.modules on %i. try" % i) + else: + self.fail("was able to import a damaged module on %i. try" % i) + finally: + sys.path.pop(0) + remove_files(TESTFN) + + def test_failing_reload(self): + # A failing reload should leave the module object in sys.modules. + source = TESTFN + os.extsep + "py" + f = open(source, "w") + print >> f, "a = 1" + print >> f, "b = 2" + f.close() + + sys.path.insert(0, os.curdir) + try: + mod = __import__(TESTFN) + self.assert_(TESTFN in sys.modules, "expected module in sys.modules") + self.assertEquals(mod.a, 1, "module has wrong attribute values") + self.assertEquals(mod.b, 2, "module has wrong attribute values") + + # On WinXP, just replacing the .py file wasn't enough to + # convince reload() to reparse it. Maybe the timestamp didn't + # move enough. We force it to get reparsed by removing the + # compiled file too. + remove_files(TESTFN) + + # Now damage the module. + f = open(source, "w") + print >> f, "a = 10" + print >> f, "b = 20//0" + f.close() + + self.assertRaises(ZeroDivisionError, reload, mod) + + # But we still expect the module to be in sys.modules. + mod = sys.modules.get(TESTFN) + self.failIf(mod is None, "expected module to still be in sys.modules") + + # We should have replaced a w/ 10, but the old b value should + # stick. + self.assertEquals(mod.a, 10, "module has wrong attribute values") + self.assertEquals(mod.b, 2, "module has wrong attribute values") + + finally: + sys.path.pop(0) + remove_files(TESTFN) + if TESTFN in sys.modules: + del sys.modules[TESTFN] + + def test_import_name_binding(self): + # import x.y.z binds x in the current namespace + import test as x + import test.test_support + self.assert_(x is test, x.__name__) + self.assert_(hasattr(test.test_support, "__file__")) + + # import x.y.z as w binds z as w + import test.test_support as y + self.assert_(y is test.test_support, y.__name__) + + def test_import_initless_directory_warning(self): + import warnings + oldfilters = warnings.filters[:] + warnings.simplefilter('error', ImportWarning); + try: + # Just a random non-package directory we always expect to be + # somewhere in sys.path... + self.assertRaises(ImportWarning, __import__, "site-packages") + finally: + warnings.filters = oldfilters - # But we still expect the module to be in sys.modules. - mod = sys.modules.get(TESTFN) - if mod is None: - raise TestFailed("expected module to still be in sys.modules") - # We should have replaced a w/ 10, but the old b value should - # stick. - if mod.a != 10 or mod.b != 2: - raise TestFailed("module has wrong attribute values") - - finally: - sys.path.pop(0) - remove_files(TESTFN) - if TESTFN in sys.modules: - del sys.modules[TESTFN] - -test_failing_reload() - -def test_import_name_binding(): - # import x.y.z binds x in the current namespace - import test as x - import test.test_support - assert x is test, x.__name__ - assert hasattr(test.test_support, "__file__") - - # import x.y.z as w binds z as w - import test.test_support as y - assert y is test.test_support, y.__name__ - -test_import_name_binding() - -def test_import_initless_directory_warning(): - import warnings - oldfilters = warnings.filters[:] - warnings.simplefilter('error', ImportWarning); - try: - # Just a random non-package directory we always expect to be - # somewhere in sys.path... - __import__("site-packages") - except ImportWarning: - pass - else: - raise AssertionError - finally: - warnings.filters = oldfilters +def test_main(verbose=None): + run_unittest(ImportTest) -test_import_initless_directory_warning() +if __name__ == '__main__': + test_main() Modified: python/branches/p3yk/Lib/test/test_inspect.py ============================================================================== --- python/branches/p3yk/Lib/test/test_inspect.py (original) +++ python/branches/p3yk/Lib/test/test_inspect.py Wed Dec 13 05:49:30 2006 @@ -180,7 +180,18 @@ self.assertEqual(inspect.getcomments(mod.StupidGit), '# line 20\n') def test_getmodule(self): + # Check actual module + self.assertEqual(inspect.getmodule(mod), mod) + # Check class (uses __module__ attribute) self.assertEqual(inspect.getmodule(mod.StupidGit), mod) + # Check a method (no __module__ attribute, falls back to filename) + self.assertEqual(inspect.getmodule(mod.StupidGit.abuse), mod) + # Do it again (check the caching isn't broken) + self.assertEqual(inspect.getmodule(mod.StupidGit.abuse), mod) + # Check a builtin + self.assertEqual(inspect.getmodule(str), sys.modules["__builtin__"]) + # Check filename override + self.assertEqual(inspect.getmodule(None, modfile), mod) def test_getsource(self): self.assertSourceEqual(git.abuse, 29, 39) Modified: python/branches/p3yk/Lib/test/test_itertools.py ============================================================================== --- python/branches/p3yk/Lib/test/test_itertools.py (original) +++ python/branches/p3yk/Lib/test/test_itertools.py Wed Dec 13 05:49:30 2006 @@ -61,6 +61,10 @@ self.assertEqual(repr(c), 'count(3)') c.next() self.assertEqual(repr(c), 'count(4)') + c = count(-9) + self.assertEqual(repr(c), 'count(-9)') + c.next() + self.assertEqual(c.next(), -8) def test_cycle(self): self.assertEqual(take(10, cycle('abc')), list('abcabcabca')) @@ -375,6 +379,7 @@ # test values of n self.assertRaises(TypeError, tee, 'abc', 'invalid') + self.assertRaises(ValueError, tee, [], -1) for n in xrange(5): result = tee('abc', n) self.assertEqual(type(result), tuple) Modified: python/branches/p3yk/Lib/test/test_long.py ============================================================================== --- python/branches/p3yk/Lib/test/test_long.py (original) +++ python/branches/p3yk/Lib/test/test_long.py Wed Dec 13 05:49:30 2006 @@ -247,17 +247,23 @@ "long(-sys.maxint-1) != -sys.maxint-1") # long -> int should not fail for hugepos_aslong or hugeneg_aslong + x = int(hugepos_aslong) try: - self.assertEqual(int(hugepos_aslong), hugepos, + self.assertEqual(x, hugepos, "converting sys.maxint to long and back to int fails") except OverflowError: self.fail("int(long(sys.maxint)) overflowed!") + if not isinstance(x, int): + raise TestFailed("int(long(sys.maxint)) should have returned int") + x = int(hugeneg_aslong) try: - self.assertEqual(int(hugeneg_aslong), hugeneg, + self.assertEqual(x, hugeneg, "converting -sys.maxint-1 to long and back to int fails") except OverflowError: self.fail("int(long(-sys.maxint-1)) overflowed!") - + if not isinstance(x, int): + raise TestFailed("int(long(-sys.maxint-1)) should have " + "returned int") # but long -> int should overflow for hugepos+1 and hugeneg-1 x = hugepos_aslong + 1 try: @@ -282,6 +288,17 @@ self.assert_(type(y) is long, "overflowing int conversion must return long not long subtype") + # long -> Py_ssize_t conversion + class X(object): + def __getslice__(self, i, j): + return i, j + + self.assertEqual(X()[-5L:7L], (-5, 7)) + # use the clamping effect to test the smallest and largest longs + # that fit a Py_ssize_t + slicemin, slicemax = X()[-2L**100:2L**100] + self.assertEqual(X()[slicemin:slicemax], (slicemin, slicemax)) + # ----------------------------------- tests of auto int->long conversion def test_auto_overflow(self): Modified: python/branches/p3yk/Lib/test/test_mailbox.py ============================================================================== --- python/branches/p3yk/Lib/test/test_mailbox.py (original) +++ python/branches/p3yk/Lib/test/test_mailbox.py Wed Dec 13 05:49:30 2006 @@ -666,6 +666,19 @@ self._box.lock() self._box.unlock() + def test_folder (self): + # Test for bug #1569790: verify that folders returned by .get_folder() + # use the same factory function. + def dummy_factory (s): + return None + box = self._factory(self._path, factory=dummy_factory) + folder = box.add_folder('folder1') + self.assert_(folder._factory is dummy_factory) + + folder1_alias = box.get_folder('folder1') + self.assert_(folder1_alias._factory is dummy_factory) + + class _TestMboxMMDF(TestMailbox): @@ -740,6 +753,22 @@ self._box.lock() self._box.unlock() + def test_relock(self): + # Test case for bug #1575506: the mailbox class was locking the + # wrong file object in its flush() method. + msg = "Subject: sub\n\nbody\n" + key1 = self._box.add(msg) + self._box.flush() + self._box.close() + + self._box = self._factory(self._path) + self._box.lock() + key2 = self._box.add(msg) + self._box.flush() + self.assert_(self._box._locked) + self._box.close() + + class TestMbox(_TestMboxMMDF): @@ -766,7 +795,11 @@ def test_get_folder(self): # Open folders - self._box.add_folder('foo.bar') + def dummy_factory (s): + return None + self._box = self._factory(self._path, dummy_factory) + + new_folder = self._box.add_folder('foo.bar') folder0 = self._box.get_folder('foo.bar') folder0.add(self._template % 'bar') self.assert_(os.path.isdir(os.path.join(self._path, 'foo.bar'))) @@ -774,6 +807,11 @@ self.assert_(folder1.get_string(folder1.keys()[0]) == \ self._template % 'bar') + # Test for bug #1569790: verify that folders returned by .get_folder() + # use the same factory function. + self.assert_(new_folder._factory is self._box._factory) + self.assert_(folder0._factory is self._box._factory) + def test_add_and_remove_folders(self): # Delete folders self._box.add_folder('one') @@ -842,6 +880,21 @@ self.assert_(self._box.get_sequences() == {'foo':[1, 2, 3], 'unseen':[1], 'bar':[3], 'replied':[3]}) + # Test case for packing while holding the mailbox locked. + key0 = self._box.add(msg1) + key1 = self._box.add(msg1) + key2 = self._box.add(msg1) + key3 = self._box.add(msg1) + + self._box.remove(key0) + self._box.remove(key2) + self._box.lock() + self._box.pack() + self._box.unlock() + self.assert_(self._box.get_sequences() == + {'foo':[1, 2, 3, 4, 5], + 'unseen':[1], 'bar':[3], 'replied':[3]}) + def _get_lock_path(self): return os.path.join(self._path, '.mh_sequences.lock') Modified: python/branches/p3yk/Lib/test/test_math.py ============================================================================== --- python/branches/p3yk/Lib/test/test_math.py (original) +++ python/branches/p3yk/Lib/test/test_math.py Wed Dec 13 05:49:30 2006 @@ -1,208 +1,241 @@ # Python test set -- math module # XXXX Should not do tests around zero only -from test.test_support import TestFailed, verbose +from test.test_support import run_unittest, verbose +import unittest +import math seps='1e-05' eps = eval(seps) -print 'math module, testing with eps', seps -import math -def testit(name, value, expected): - if abs(value-expected) > eps: - raise TestFailed, '%s returned %f, expected %f'%\ - (name, value, expected) - -print 'constants' -testit('pi', math.pi, 3.1415926) -testit('e', math.e, 2.7182818) - -print 'acos' -testit('acos(-1)', math.acos(-1), math.pi) -testit('acos(0)', math.acos(0), math.pi/2) -testit('acos(1)', math.acos(1), 0) - -print 'asin' -testit('asin(-1)', math.asin(-1), -math.pi/2) -testit('asin(0)', math.asin(0), 0) -testit('asin(1)', math.asin(1), math.pi/2) - -print 'atan' -testit('atan(-1)', math.atan(-1), -math.pi/4) -testit('atan(0)', math.atan(0), 0) -testit('atan(1)', math.atan(1), math.pi/4) - -print 'atan2' -testit('atan2(-1, 0)', math.atan2(-1, 0), -math.pi/2) -testit('atan2(-1, 1)', math.atan2(-1, 1), -math.pi/4) -testit('atan2(0, 1)', math.atan2(0, 1), 0) -testit('atan2(1, 1)', math.atan2(1, 1), math.pi/4) -testit('atan2(1, 0)', math.atan2(1, 0), math.pi/2) - -print 'ceil' -testit('ceil(0.5)', math.ceil(0.5), 1) -testit('ceil(1.0)', math.ceil(1.0), 1) -testit('ceil(1.5)', math.ceil(1.5), 2) -testit('ceil(-0.5)', math.ceil(-0.5), 0) -testit('ceil(-1.0)', math.ceil(-1.0), -1) -testit('ceil(-1.5)', math.ceil(-1.5), -1) - -print 'cos' -testit('cos(-pi/2)', math.cos(-math.pi/2), 0) -testit('cos(0)', math.cos(0), 1) -testit('cos(pi/2)', math.cos(math.pi/2), 0) -testit('cos(pi)', math.cos(math.pi), -1) - -print 'cosh' -testit('cosh(0)', math.cosh(0), 1) -testit('cosh(2)-2*cosh(1)**2', math.cosh(2)-2*math.cosh(1)**2, -1) # Thanks to Lambert - -print 'degrees' -testit('degrees(pi)', math.degrees(math.pi), 180.0) -testit('degrees(pi/2)', math.degrees(math.pi/2), 90.0) -testit('degrees(-pi/4)', math.degrees(-math.pi/4), -45.0) - -print 'exp' -testit('exp(-1)', math.exp(-1), 1/math.e) -testit('exp(0)', math.exp(0), 1) -testit('exp(1)', math.exp(1), math.e) - -print 'fabs' -testit('fabs(-1)', math.fabs(-1), 1) -testit('fabs(0)', math.fabs(0), 0) -testit('fabs(1)', math.fabs(1), 1) - -print 'floor' -testit('floor(0.5)', math.floor(0.5), 0) -testit('floor(1.0)', math.floor(1.0), 1) -testit('floor(1.5)', math.floor(1.5), 1) -testit('floor(-0.5)', math.floor(-0.5), -1) -testit('floor(-1.0)', math.floor(-1.0), -1) -testit('floor(-1.5)', math.floor(-1.5), -2) - -print 'fmod' -testit('fmod(10,1)', math.fmod(10,1), 0) -testit('fmod(10,0.5)', math.fmod(10,0.5), 0) -testit('fmod(10,1.5)', math.fmod(10,1.5), 1) -testit('fmod(-10,1)', math.fmod(-10,1), 0) -testit('fmod(-10,0.5)', math.fmod(-10,0.5), 0) -testit('fmod(-10,1.5)', math.fmod(-10,1.5), -1) - -print 'frexp' -def testfrexp(name, (mant, exp), (emant, eexp)): - if abs(mant-emant) > eps or exp != eexp: - raise TestFailed, '%s returned %r, expected %r'%\ - (name, (mant, exp), (emant,eexp)) - -testfrexp('frexp(-1)', math.frexp(-1), (-0.5, 1)) -testfrexp('frexp(0)', math.frexp(0), (0, 0)) -testfrexp('frexp(1)', math.frexp(1), (0.5, 1)) -testfrexp('frexp(2)', math.frexp(2), (0.5, 2)) - -print 'hypot' -testit('hypot(0,0)', math.hypot(0,0), 0) -testit('hypot(3,4)', math.hypot(3,4), 5) - -print 'ldexp' -testit('ldexp(0,1)', math.ldexp(0,1), 0) -testit('ldexp(1,1)', math.ldexp(1,1), 2) -testit('ldexp(1,-1)', math.ldexp(1,-1), 0.5) -testit('ldexp(-1,1)', math.ldexp(-1,1), -2) - -print 'log' -testit('log(1/e)', math.log(1/math.e), -1) -testit('log(1)', math.log(1), 0) -testit('log(e)', math.log(math.e), 1) -testit('log(32,2)', math.log(32,2), 5) -testit('log(10**40, 10)', math.log(10**40, 10), 40) -testit('log(10**40, 10**20)', math.log(10**40, 10**20), 2) - -print 'log10' -testit('log10(0.1)', math.log10(0.1), -1) -testit('log10(1)', math.log10(1), 0) -testit('log10(10)', math.log10(10), 1) - -print 'modf' -def testmodf(name, (v1, v2), (e1, e2)): - if abs(v1-e1) > eps or abs(v2-e2): - raise TestFailed, '%s returned %r, expected %r'%\ - (name, (v1,v2), (e1,e2)) - -testmodf('modf(1.5)', math.modf(1.5), (0.5, 1.0)) -testmodf('modf(-1.5)', math.modf(-1.5), (-0.5, -1.0)) - -print 'pow' -testit('pow(0,1)', math.pow(0,1), 0) -testit('pow(1,0)', math.pow(1,0), 1) -testit('pow(2,1)', math.pow(2,1), 2) -testit('pow(2,-1)', math.pow(2,-1), 0.5) - -print 'radians' -testit('radians(180)', math.radians(180), math.pi) -testit('radians(90)', math.radians(90), math.pi/2) -testit('radians(-45)', math.radians(-45), -math.pi/4) - -print 'sin' -testit('sin(0)', math.sin(0), 0) -testit('sin(pi/2)', math.sin(math.pi/2), 1) -testit('sin(-pi/2)', math.sin(-math.pi/2), -1) - -print 'sinh' -testit('sinh(0)', math.sinh(0), 0) -testit('sinh(1)**2-cosh(1)**2', math.sinh(1)**2-math.cosh(1)**2, -1) -testit('sinh(1)+sinh(-1)', math.sinh(1)+math.sinh(-1), 0) - -print 'sqrt' -testit('sqrt(0)', math.sqrt(0), 0) -testit('sqrt(1)', math.sqrt(1), 1) -testit('sqrt(4)', math.sqrt(4), 2) - -print 'tan' -testit('tan(0)', math.tan(0), 0) -testit('tan(pi/4)', math.tan(math.pi/4), 1) -testit('tan(-pi/4)', math.tan(-math.pi/4), -1) - -print 'tanh' -testit('tanh(0)', math.tanh(0), 0) -testit('tanh(1)+tanh(-1)', math.tanh(1)+math.tanh(-1), 0) - -# RED_FLAG 16-Oct-2000 Tim -# While 2.0 is more consistent about exceptions than previous releases, it -# still fails this part of the test on some platforms. For now, we only -# *run* test_exceptions() in verbose mode, so that this isn't normally -# tested. - -def test_exceptions(): - print 'exceptions' - try: - x = math.exp(-1000000000) - except: - # mathmodule.c is failing to weed out underflows from libm, or - # we've got an fp format with huge dynamic range - raise TestFailed("underflowing exp() should not have raised " - "an exception") - if x != 0: - raise TestFailed("underflowing exp() should have returned 0") - - # If this fails, probably using a strict IEEE-754 conforming libm, and x - # is +Inf afterwards. But Python wants overflows detected by default. - try: - x = math.exp(1000000000) - except OverflowError: - pass - else: - raise TestFailed("overflowing exp() didn't trigger OverflowError") - - # If this fails, it could be a puzzle. One odd possibility is that - # mathmodule.c's macros are getting confused while comparing - # Inf (HUGE_VAL) to a NaN, and artificially setting errno to ERANGE - # as a result (and so raising OverflowError instead). - try: - x = math.sqrt(-1.0) - except ValueError: - pass - else: - raise TestFailed("sqrt(-1) didn't raise ValueError") +class MathTests(unittest.TestCase): + + def ftest(self, name, value, expected): + if abs(value-expected) > eps: + self.fail('%s returned %f, expected %f'%\ + (name, value, expected)) + + def testConstants(self): + self.ftest('pi', math.pi, 3.1415926) + self.ftest('e', math.e, 2.7182818) + + def testAcos(self): + self.assertRaises(TypeError, math.acos) + self.ftest('acos(-1)', math.acos(-1), math.pi) + self.ftest('acos(0)', math.acos(0), math.pi/2) + self.ftest('acos(1)', math.acos(1), 0) + + def testAsin(self): + self.assertRaises(TypeError, math.asin) + self.ftest('asin(-1)', math.asin(-1), -math.pi/2) + self.ftest('asin(0)', math.asin(0), 0) + self.ftest('asin(1)', math.asin(1), math.pi/2) + + def testAtan(self): + self.assertRaises(TypeError, math.atan) + self.ftest('atan(-1)', math.atan(-1), -math.pi/4) + self.ftest('atan(0)', math.atan(0), 0) + self.ftest('atan(1)', math.atan(1), math.pi/4) + + def testAtan2(self): + self.assertRaises(TypeError, math.atan2) + self.ftest('atan2(-1, 0)', math.atan2(-1, 0), -math.pi/2) + self.ftest('atan2(-1, 1)', math.atan2(-1, 1), -math.pi/4) + self.ftest('atan2(0, 1)', math.atan2(0, 1), 0) + self.ftest('atan2(1, 1)', math.atan2(1, 1), math.pi/4) + self.ftest('atan2(1, 0)', math.atan2(1, 0), math.pi/2) + + def testCeil(self): + self.assertRaises(TypeError, math.ceil) + self.ftest('ceil(0.5)', math.ceil(0.5), 1) + self.ftest('ceil(1.0)', math.ceil(1.0), 1) + self.ftest('ceil(1.5)', math.ceil(1.5), 2) + self.ftest('ceil(-0.5)', math.ceil(-0.5), 0) + self.ftest('ceil(-1.0)', math.ceil(-1.0), -1) + self.ftest('ceil(-1.5)', math.ceil(-1.5), -1) + + def testCos(self): + self.assertRaises(TypeError, math.cos) + self.ftest('cos(-pi/2)', math.cos(-math.pi/2), 0) + self.ftest('cos(0)', math.cos(0), 1) + self.ftest('cos(pi/2)', math.cos(math.pi/2), 0) + self.ftest('cos(pi)', math.cos(math.pi), -1) + + def testCosh(self): + self.assertRaises(TypeError, math.cosh) + self.ftest('cosh(0)', math.cosh(0), 1) + self.ftest('cosh(2)-2*cosh(1)**2', math.cosh(2)-2*math.cosh(1)**2, -1) # Thanks to Lambert + + def testDegrees(self): + self.assertRaises(TypeError, math.degrees) + self.ftest('degrees(pi)', math.degrees(math.pi), 180.0) + self.ftest('degrees(pi/2)', math.degrees(math.pi/2), 90.0) + self.ftest('degrees(-pi/4)', math.degrees(-math.pi/4), -45.0) + + def testExp(self): + self.assertRaises(TypeError, math.exp) + self.ftest('exp(-1)', math.exp(-1), 1/math.e) + self.ftest('exp(0)', math.exp(0), 1) + self.ftest('exp(1)', math.exp(1), math.e) + + def testFabs(self): + self.assertRaises(TypeError, math.fabs) + self.ftest('fabs(-1)', math.fabs(-1), 1) + self.ftest('fabs(0)', math.fabs(0), 0) + self.ftest('fabs(1)', math.fabs(1), 1) + + def testFloor(self): + self.assertRaises(TypeError, math.floor) + self.ftest('floor(0.5)', math.floor(0.5), 0) + self.ftest('floor(1.0)', math.floor(1.0), 1) + self.ftest('floor(1.5)', math.floor(1.5), 1) + self.ftest('floor(-0.5)', math.floor(-0.5), -1) + self.ftest('floor(-1.0)', math.floor(-1.0), -1) + self.ftest('floor(-1.5)', math.floor(-1.5), -2) + + def testFmod(self): + self.assertRaises(TypeError, math.fmod) + self.ftest('fmod(10,1)', math.fmod(10,1), 0) + self.ftest('fmod(10,0.5)', math.fmod(10,0.5), 0) + self.ftest('fmod(10,1.5)', math.fmod(10,1.5), 1) + self.ftest('fmod(-10,1)', math.fmod(-10,1), 0) + self.ftest('fmod(-10,0.5)', math.fmod(-10,0.5), 0) + self.ftest('fmod(-10,1.5)', math.fmod(-10,1.5), -1) + + def testFrexp(self): + self.assertRaises(TypeError, math.frexp) + + def testfrexp(name, (mant, exp), (emant, eexp)): + if abs(mant-emant) > eps or exp != eexp: + self.fail('%s returned %r, expected %r'%\ + (name, (mant, exp), (emant,eexp))) + + testfrexp('frexp(-1)', math.frexp(-1), (-0.5, 1)) + testfrexp('frexp(0)', math.frexp(0), (0, 0)) + testfrexp('frexp(1)', math.frexp(1), (0.5, 1)) + testfrexp('frexp(2)', math.frexp(2), (0.5, 2)) + + def testHypot(self): + self.assertRaises(TypeError, math.hypot) + self.ftest('hypot(0,0)', math.hypot(0,0), 0) + self.ftest('hypot(3,4)', math.hypot(3,4), 5) + + def testLdexp(self): + self.assertRaises(TypeError, math.ldexp) + self.ftest('ldexp(0,1)', math.ldexp(0,1), 0) + self.ftest('ldexp(1,1)', math.ldexp(1,1), 2) + self.ftest('ldexp(1,-1)', math.ldexp(1,-1), 0.5) + self.ftest('ldexp(-1,1)', math.ldexp(-1,1), -2) + + def testLog(self): + self.assertRaises(TypeError, math.log) + self.ftest('log(1/e)', math.log(1/math.e), -1) + self.ftest('log(1)', math.log(1), 0) + self.ftest('log(e)', math.log(math.e), 1) + self.ftest('log(32,2)', math.log(32,2), 5) + self.ftest('log(10**40, 10)', math.log(10**40, 10), 40) + self.ftest('log(10**40, 10**20)', math.log(10**40, 10**20), 2) + + def testLog10(self): + self.assertRaises(TypeError, math.log10) + self.ftest('log10(0.1)', math.log10(0.1), -1) + self.ftest('log10(1)', math.log10(1), 0) + self.ftest('log10(10)', math.log10(10), 1) + + def testModf(self): + self.assertRaises(TypeError, math.modf) + + def testmodf(name, (v1, v2), (e1, e2)): + if abs(v1-e1) > eps or abs(v2-e2): + self.fail('%s returned %r, expected %r'%\ + (name, (v1,v2), (e1,e2))) + + testmodf('modf(1.5)', math.modf(1.5), (0.5, 1.0)) + testmodf('modf(-1.5)', math.modf(-1.5), (-0.5, -1.0)) + + def testPow(self): + self.assertRaises(TypeError, math.pow) + self.ftest('pow(0,1)', math.pow(0,1), 0) + self.ftest('pow(1,0)', math.pow(1,0), 1) + self.ftest('pow(2,1)', math.pow(2,1), 2) + self.ftest('pow(2,-1)', math.pow(2,-1), 0.5) + + def testRadians(self): + self.assertRaises(TypeError, math.radians) + self.ftest('radians(180)', math.radians(180), math.pi) + self.ftest('radians(90)', math.radians(90), math.pi/2) + self.ftest('radians(-45)', math.radians(-45), -math.pi/4) + + def testSin(self): + self.assertRaises(TypeError, math.sin) + self.ftest('sin(0)', math.sin(0), 0) + self.ftest('sin(pi/2)', math.sin(math.pi/2), 1) + self.ftest('sin(-pi/2)', math.sin(-math.pi/2), -1) + + def testSinh(self): + self.assertRaises(TypeError, math.sinh) + self.ftest('sinh(0)', math.sinh(0), 0) + self.ftest('sinh(1)**2-cosh(1)**2', math.sinh(1)**2-math.cosh(1)**2, -1) + self.ftest('sinh(1)+sinh(-1)', math.sinh(1)+math.sinh(-1), 0) + + def testSqrt(self): + self.assertRaises(TypeError, math.sqrt) + self.ftest('sqrt(0)', math.sqrt(0), 0) + self.ftest('sqrt(1)', math.sqrt(1), 1) + self.ftest('sqrt(4)', math.sqrt(4), 2) + + def testTan(self): + self.assertRaises(TypeError, math.tan) + self.ftest('tan(0)', math.tan(0), 0) + self.ftest('tan(pi/4)', math.tan(math.pi/4), 1) + self.ftest('tan(-pi/4)', math.tan(-math.pi/4), -1) + + def testTanh(self): + self.assertRaises(TypeError, math.tanh) + self.ftest('tanh(0)', math.tanh(0), 0) + self.ftest('tanh(1)+tanh(-1)', math.tanh(1)+math.tanh(-1), 0) + + # RED_FLAG 16-Oct-2000 Tim + # While 2.0 is more consistent about exceptions than previous releases, it + # still fails this part of the test on some platforms. For now, we only + # *run* test_exceptions() in verbose mode, so that this isn't normally + # tested. + + if verbose: + def test_exceptions(self): + try: + x = math.exp(-1000000000) + except: + # mathmodule.c is failing to weed out underflows from libm, or + # we've got an fp format with huge dynamic range + self.fail("underflowing exp() should not have raised " + "an exception") + if x != 0: + self.fail("underflowing exp() should have returned 0") + + # If this fails, probably using a strict IEEE-754 conforming libm, and x + # is +Inf afterwards. But Python wants overflows detected by default. + try: + x = math.exp(1000000000) + except OverflowError: + pass + else: + self.fail("overflowing exp() didn't trigger OverflowError") + + # If this fails, it could be a puzzle. One odd possibility is that + # mathmodule.c's macros are getting confused while comparing + # Inf (HUGE_VAL) to a NaN, and artificially setting errno to ERANGE + # as a result (and so raising OverflowError instead). + try: + x = math.sqrt(-1.0) + except ValueError: + pass + else: + self.fail("sqrt(-1) didn't raise ValueError") + + +def test_main(): + run_unittest(MathTests) -if verbose: - test_exceptions() +if __name__ == '__main__': + test_main() Modified: python/branches/p3yk/Lib/test/test_mmap.py ============================================================================== --- python/branches/p3yk/Lib/test/test_mmap.py (original) +++ python/branches/p3yk/Lib/test/test_mmap.py Wed Dec 13 05:49:30 2006 @@ -1,190 +1,158 @@ -from test.test_support import verify, vereq, TESTFN +from test.test_support import TESTFN, run_unittest import mmap +import unittest import os, re PAGESIZE = mmap.PAGESIZE -def test_both(): - "Test mmap module on Unix systems and Windows" +class MmapTests(unittest.TestCase): - # Create a file to be mmap'ed. - if os.path.exists(TESTFN): - os.unlink(TESTFN) - f = open(TESTFN, 'w+') - - try: # unlink TESTFN no matter what - # Write 2 pages worth of data to the file - f.write('\0'* PAGESIZE) - f.write('foo') - f.write('\0'* (PAGESIZE-3) ) - f.flush() - m = mmap.mmap(f.fileno(), 2 * PAGESIZE) - f.close() + def setUp(self): + if os.path.exists(TESTFN): + os.unlink(TESTFN) - # Simple sanity checks + def tearDown(self): + try: + os.unlink(TESTFN) + except OSError: + pass - print type(m) # SF bug 128713: segfaulted on Linux - print ' Position of foo:', m.find('foo') / float(PAGESIZE), 'pages' - vereq(m.find('foo'), PAGESIZE) - - print ' Length of file:', len(m) / float(PAGESIZE), 'pages' - vereq(len(m), 2*PAGESIZE) - - print ' Contents of byte 0:', repr(m[0]) - vereq(m[0], '\0') - print ' Contents of first 3 bytes:', repr(m[0:3]) - vereq(m[0:3], '\0\0\0') - - # Modify the file's content - print "\n Modifying file's content..." - m[0] = '3' - m[PAGESIZE +3: PAGESIZE +3+3] = 'bar' - - # Check that the modification worked - print ' Contents of byte 0:', repr(m[0]) - vereq(m[0], '3') - print ' Contents of first 3 bytes:', repr(m[0:3]) - vereq(m[0:3], '3\0\0') - print ' Contents of second page:', repr(m[PAGESIZE-1 : PAGESIZE + 7]) - vereq(m[PAGESIZE-1 : PAGESIZE + 7], '\0foobar\0') + def test_basic(self): + # Test mmap module on Unix systems and Windows - m.flush() + # Create a file to be mmap'ed. + f = open(TESTFN, 'w+') + try: + # Write 2 pages worth of data to the file + f.write('\0'* PAGESIZE) + f.write('foo') + f.write('\0'* (PAGESIZE-3) ) + f.flush() + m = mmap.mmap(f.fileno(), 2 * PAGESIZE) + f.close() - # Test doing a regular expression match in an mmap'ed file - match = re.search('[A-Za-z]+', m) - if match is None: - print ' ERROR: regex match on mmap failed!' - else: - start, end = match.span(0) - length = end - start + # Simple sanity checks - print ' Regex match on mmap (page start, length of match):', - print start / float(PAGESIZE), length + tp = str(type(m)) # SF bug 128713: segfaulted on Linux + self.assertEqual(m.find('foo'), PAGESIZE) - vereq(start, PAGESIZE) - vereq(end, PAGESIZE + 6) + self.assertEqual(len(m), 2*PAGESIZE) - # test seeking around (try to overflow the seek implementation) - m.seek(0,0) - print ' Seek to zeroth byte' - vereq(m.tell(), 0) - m.seek(42,1) - print ' Seek to 42nd byte' - vereq(m.tell(), 42) - m.seek(0,2) - print ' Seek to last byte' - vereq(m.tell(), len(m)) + self.assertEqual(m[0], '\0') + self.assertEqual(m[0:3], '\0\0\0') - print ' Try to seek to negative position...' - try: - m.seek(-1) - except ValueError: - pass - else: - verify(0, 'expected a ValueError but did not get it') + # Modify the file's content + m[0] = '3' + m[PAGESIZE +3: PAGESIZE +3+3] = 'bar' - print ' Try to seek beyond end of mmap...' - try: - m.seek(1,2) - except ValueError: - pass - else: - verify(0, 'expected a ValueError but did not get it') + # Check that the modification worked + self.assertEqual(m[0], '3') + self.assertEqual(m[0:3], '3\0\0') + self.assertEqual(m[PAGESIZE-1 : PAGESIZE + 7], '\0foobar\0') - print ' Try to seek to negative position...' - try: - m.seek(-len(m)-1,2) - except ValueError: - pass - else: - verify(0, 'expected a ValueError but did not get it') + m.flush() - # Try resizing map - print ' Attempting resize()' - try: - m.resize(512) - except SystemError: - # resize() not supported - # No messages are printed, since the output of this test suite - # would then be different across platforms. - pass - else: - # resize() is supported - verify(len(m) == 512, - "len(m) is %d, but expecting 512" % (len(m),) ) - # Check that we can no longer seek beyond the new size. + # Test doing a regular expression match in an mmap'ed file + match = re.search('[A-Za-z]+', m) + if match is None: + self.fail('regex match on mmap failed!') + else: + start, end = match.span(0) + length = end - start + + self.assertEqual(start, PAGESIZE) + self.assertEqual(end, PAGESIZE + 6) + + # test seeking around (try to overflow the seek implementation) + m.seek(0,0) + self.assertEqual(m.tell(), 0) + m.seek(42,1) + self.assertEqual(m.tell(), 42) + m.seek(0,2) + self.assertEqual(m.tell(), len(m)) + + # Try to seek to negative position... + self.assertRaises(ValueError, m.seek, -1) + + # Try to seek beyond end of mmap... + self.assertRaises(ValueError, m.seek, 1, 2) + + # Try to seek to negative position... + self.assertRaises(ValueError, m.seek, -len(m)-1, 2) + + # Try resizing map try: - m.seek(513,0) - except ValueError: + m.resize(512) + except SystemError: + # resize() not supported + # No messages are printed, since the output of this test suite + # would then be different across platforms. pass else: - verify(0, 'Could seek beyond the new size') + # resize() is supported + self.assertEqual(len(m), 512) + # Check that we can no longer seek beyond the new size. + self.assertRaises(ValueError, m.seek, 513, 0) + + # Check that the underlying file is truncated too + # (bug #728515) + f = open(TESTFN) + f.seek(0, 2) + self.assertEqual(f.tell(), 512) + f.close() + self.assertEqual(m.size(), 512) - # Check that the underlying file is truncated too - # (bug #728515) - f = open(TESTFN) - f.seek(0, 2) - verify(f.tell() == 512, 'Underlying file not truncated') - f.close() - verify(m.size() == 512, 'New size not reflected in file') - - m.close() + m.close() - finally: - try: - f.close() - except OSError: - pass - try: - os.unlink(TESTFN) - except OSError: - pass + finally: + try: + f.close() + except OSError: + pass - # Test for "access" keyword parameter - try: + def test_access_parameter(self): + # Test for "access" keyword parameter mapsize = 10 - print " Creating", mapsize, "byte test data file." open(TESTFN, "wb").write("a"*mapsize) - print " Opening mmap with access=ACCESS_READ" f = open(TESTFN, "rb") m = mmap.mmap(f.fileno(), mapsize, access=mmap.ACCESS_READ) - verify(m[:] == 'a'*mapsize, "Readonly memory map data incorrect.") + self.assertEqual(m[:], 'a'*mapsize, "Readonly memory map data incorrect.") - print " Ensuring that readonly mmap can't be slice assigned." + # Ensuring that readonly mmap can't be slice assigned try: m[:] = 'b'*mapsize except TypeError: pass else: - verify(0, "Able to write to readonly memory map") + self.fail("Able to write to readonly memory map") - print " Ensuring that readonly mmap can't be item assigned." + # Ensuring that readonly mmap can't be item assigned try: m[0] = 'b' except TypeError: pass else: - verify(0, "Able to write to readonly memory map") + self.fail("Able to write to readonly memory map") - print " Ensuring that readonly mmap can't be write() to." + # Ensuring that readonly mmap can't be write() to try: m.seek(0,0) m.write('abc') except TypeError: pass else: - verify(0, "Able to write to readonly memory map") + self.fail("Able to write to readonly memory map") - print " Ensuring that readonly mmap can't be write_byte() to." + # Ensuring that readonly mmap can't be write_byte() to try: m.seek(0,0) m.write_byte('d') except TypeError: pass else: - verify(0, "Able to write to readonly memory map") + self.fail("Able to write to readonly memory map") - print " Ensuring that readonly mmap can't be resized." + # Ensuring that readonly mmap can't be resized try: m.resize(2*mapsize) except SystemError: # resize is not universally supported @@ -192,12 +160,12 @@ except TypeError: pass else: - verify(0, "Able to resize readonly memory map") + self.fail("Able to resize readonly memory map") del m, f - verify(open(TESTFN, "rb").read() == 'a'*mapsize, + self.assertEqual(open(TESTFN, "rb").read(), 'a'*mapsize, "Readonly memory map data file was modified") - print " Opening mmap with size too big" + # Opening mmap with size too big import sys f = open(TESTFN, "r+b") try: @@ -208,11 +176,11 @@ # later tests assume that the length hasn't changed. We need to # repair that. if sys.platform.startswith('win'): - verify(0, "Opening mmap with size+1 should work on Windows.") + self.fail("Opening mmap with size+1 should work on Windows.") else: # we expect a ValueError on Unix, but not on Windows if not sys.platform.startswith('win'): - verify(0, "Opening mmap with size+1 should raise ValueError.") + self.fail("Opening mmap with size+1 should raise ValueError.") m.close() f.close() if sys.platform.startswith('win'): @@ -221,12 +189,12 @@ f.truncate(mapsize) f.close() - print " Opening mmap with access=ACCESS_WRITE" + # Opening mmap with access=ACCESS_WRITE f = open(TESTFN, "r+b") m = mmap.mmap(f.fileno(), mapsize, access=mmap.ACCESS_WRITE) - print " Modifying write-through memory map." + # Modifying write-through memory map m[:] = 'c'*mapsize - verify(m[:] == 'c'*mapsize, + self.assertEqual(m[:], 'c'*mapsize, "Write-through memory map memory not updated properly.") m.flush() m.close() @@ -234,66 +202,45 @@ f = open(TESTFN, 'rb') stuff = f.read() f.close() - verify(stuff == 'c'*mapsize, + self.assertEqual(stuff, 'c'*mapsize, "Write-through memory map data file not updated properly.") - print " Opening mmap with access=ACCESS_COPY" + # Opening mmap with access=ACCESS_COPY f = open(TESTFN, "r+b") m = mmap.mmap(f.fileno(), mapsize, access=mmap.ACCESS_COPY) - print " Modifying copy-on-write memory map." + # Modifying copy-on-write memory map m[:] = 'd'*mapsize - verify(m[:] == 'd' * mapsize, + self.assertEqual(m[:], 'd' * mapsize, "Copy-on-write memory map data not written correctly.") m.flush() - verify(open(TESTFN, "rb").read() == 'c'*mapsize, + self.assertEqual(open(TESTFN, "rb").read(), 'c'*mapsize, "Copy-on-write test data file should not be modified.") - try: - print " Ensuring copy-on-write maps cannot be resized." - m.resize(2*mapsize) - except TypeError: - pass - else: - verify(0, "Copy-on-write mmap resize did not raise exception.") + # Ensuring copy-on-write maps cannot be resized + self.assertRaises(TypeError, m.resize, 2*mapsize) del m, f - try: - print " Ensuring invalid access parameter raises exception." - f = open(TESTFN, "r+b") - m = mmap.mmap(f.fileno(), mapsize, access=4) - except ValueError: - pass - else: - verify(0, "Invalid access code should have raised exception.") + + # Ensuring invalid access parameter raises exception + f = open(TESTFN, "r+b") + self.assertRaises(ValueError, mmap.mmap, f.fileno(), mapsize, access=4) + f.close() if os.name == "posix": # Try incompatible flags, prot and access parameters. f = open(TESTFN, "r+b") - try: - m = mmap.mmap(f.fileno(), mapsize, flags=mmap.MAP_PRIVATE, + self.assertRaises(ValueError, mmap.mmap, f.fileno(), mapsize, + flags=mmap.MAP_PRIVATE, prot=mmap.PROT_READ, access=mmap.ACCESS_WRITE) - except ValueError: - pass - else: - verify(0, "Incompatible parameters should raise ValueError.") f.close() - finally: - try: - os.unlink(TESTFN) - except OSError: - pass - print ' Try opening a bad file descriptor...' - try: - mmap.mmap(-2, 4096) - except mmap.error: - pass - else: - verify(0, 'expected a mmap.error but did not get it') - - # Do a tougher .find() test. SF bug 515943 pointed out that, in 2.2, - # searching for data with embedded \0 bytes didn't work. - f = open(TESTFN, 'w+') + def test_bad_file_desc(self): + # Try opening a bad file descriptor... + self.assertRaises(mmap.error, mmap.mmap, -2, 4096) + + def test_tougher_find(self): + # Do a tougher .find() test. SF bug 515943 pointed out that, in 2.2, + # searching for data with embedded \0 bytes didn't work. + f = open(TESTFN, 'w+') - try: # unlink TESTFN no matter what data = 'aabaac\x00deef\x00\x00aa\x00' n = len(data) f.write(data) @@ -304,17 +251,14 @@ for start in range(n+1): for finish in range(start, n+1): slice = data[start : finish] - vereq(m.find(slice), data.find(slice)) - vereq(m.find(slice + 'x'), -1) + self.assertEqual(m.find(slice), data.find(slice)) + self.assertEqual(m.find(slice + 'x'), -1) m.close() - finally: - os.unlink(TESTFN) - - # make sure a double close doesn't crash on Solaris (Bug# 665913) - f = open(TESTFN, 'w+') + def test_double_close(self): + # make sure a double close doesn't crash on Solaris (Bug# 665913) + f = open(TESTFN, 'w+') - try: # unlink TESTFN no matter what f.write(2**16 * 'a') # Arbitrary character f.close() @@ -324,72 +268,46 @@ mf.close() f.close() - finally: - os.unlink(TESTFN) + def test_entire_file(self): + # test mapping of entire file by passing 0 for map length + if hasattr(os, "stat"): + f = open(TESTFN, "w+") - # test mapping of entire file by passing 0 for map length - if hasattr(os, "stat"): - print " Ensuring that passing 0 as map length sets map size to current file size." - f = open(TESTFN, "w+") - - try: f.write(2**16 * 'm') # Arbitrary character f.close() f = open(TESTFN, "rb+") mf = mmap.mmap(f.fileno(), 0) - verify(len(mf) == 2**16, "Map size should equal file size.") - vereq(mf.read(2**16), 2**16 * "m") + self.assertEqual(len(mf), 2**16, "Map size should equal file size.") + self.assertEqual(mf.read(2**16), 2**16 * "m") mf.close() f.close() - finally: - os.unlink(TESTFN) - - # test mapping of entire file by passing 0 for map length - if hasattr(os, "stat"): - print " Ensuring that passing 0 as map length sets map size to current file size." - f = open(TESTFN, "w+") - try: - f.write(2**16 * 'm') # Arbitrary character - f.close() + def test_move(self): + # make move works everywhere (64-bit format problem earlier) + f = open(TESTFN, 'w+') - f = open(TESTFN, "rb+") - mf = mmap.mmap(f.fileno(), 0) - verify(len(mf) == 2**16, "Map size should equal file size.") - vereq(mf.read(2**16), 2**16 * "m") - mf.close() - f.close() - - finally: - os.unlink(TESTFN) - - # make move works everywhere (64-bit format problem earlier) - f = open(TESTFN, 'w+') - - try: # unlink TESTFN no matter what f.write("ABCDEabcde") # Arbitrary character f.flush() mf = mmap.mmap(f.fileno(), 10) mf.move(5, 0, 5) - verify(mf[:] == "ABCDEABCDE", "Map move should have duplicated front 5") + self.assertEqual(mf[:], "ABCDEABCDE", "Map move should have duplicated front 5") mf.close() f.close() - finally: - os.unlink(TESTFN) + def test_anonymous(self): + # anonymous mmap.mmap(-1, PAGE) + m = mmap.mmap(-1, PAGESIZE) + for x in xrange(PAGESIZE): + self.assertEqual(m[x], '\0', "anonymously mmap'ed contents should be zero") + + for x in xrange(PAGESIZE): + m[x] = ch = chr(x & 255) + self.assertEqual(m[x], ch) + +def test_main(): + run_unittest(MmapTests) -def test_anon(): - print " anonymous mmap.mmap(-1, PAGESIZE)..." - m = mmap.mmap(-1, PAGESIZE) - for x in xrange(PAGESIZE): - verify(m[x] == '\0', "anonymously mmap'ed contents should be zero") - - for x in xrange(PAGESIZE): - m[x] = ch = chr(x & 255) - vereq(m[x], ch) - -test_both() -test_anon() -print ' Test passed' +if __name__ == '__main__': + test_main() Copied: python/branches/p3yk/Lib/test/test_modulefinder.py (from r53011, python/trunk/Lib/test/test_modulefinder.py) ============================================================================== --- python/trunk/Lib/test/test_modulefinder.py (original) +++ python/branches/p3yk/Lib/test/test_modulefinder.py Wed Dec 13 05:49:30 2006 @@ -65,7 +65,7 @@ package_test = [ "a.module", ["a", "a.b", "a.c", "a.module", "mymodule", "sys"], - ["blahblah"], [], + ["blahblah", "c"], [], """\ mymodule.py a/__init__.py @@ -88,7 +88,7 @@ ["a", "a.module", "b", "b.x", "b.y", "b.z", "__future__", "sys", "exceptions"], - ["blahblah"], [], + ["blahblah", "z"], [], """\ mymodule.py a/__init__.py Modified: python/branches/p3yk/Lib/test/test_multibytecodec.py ============================================================================== --- python/branches/p3yk/Lib/test/test_multibytecodec.py (original) +++ python/branches/p3yk/Lib/test/test_multibytecodec.py Wed Dec 13 05:49:30 2006 @@ -202,6 +202,22 @@ uni = u':hu4:unit\xe9 de famille' self.assertEqual(iso2022jp2.decode('iso2022-jp-2'), uni) + def test_iso2022_jp_g0(self): + self.failIf('\x0e' in u'\N{SOFT HYPHEN}'.encode('iso-2022-jp-2')) + for encoding in ('iso-2022-jp-2004', 'iso-2022-jp-3'): + e = u'\u3406'.encode(encoding) + self.failIf(filter(lambda x: x >= '\x80', e)) + + def test_bug1572832(self): + if sys.maxunicode >= 0x10000: + myunichr = unichr + else: + myunichr = lambda x: unichr(0xD7C0+(x>>10)) + unichr(0xDC00+(x&0x3FF)) + + for x in xrange(0x10000, 0x110000): + # Any ISO 2022 codec will cause the segfault + myunichr(x).encode('iso_2022_jp', 'ignore') + def test_main(): suite = unittest.TestSuite() suite.addTest(unittest.makeSuite(Test_MultibyteCodec)) Modified: python/branches/p3yk/Lib/test/test_mutants.py ============================================================================== --- python/branches/p3yk/Lib/test/test_mutants.py (original) +++ python/branches/p3yk/Lib/test/test_mutants.py Wed Dec 13 05:49:30 2006 @@ -92,8 +92,8 @@ ##self.hashcode = random.randrange(1000000000) def __hash__(self): - ##return self.hashcode return 42 + return self.hashcode def __eq__(self, other): maybe_mutate() # The point of the test. Modified: python/branches/p3yk/Lib/test/test_new.py ============================================================================== --- python/branches/p3yk/Lib/test/test_new.py (original) +++ python/branches/p3yk/Lib/test/test_new.py Wed Dec 13 05:49:30 2006 @@ -47,6 +47,14 @@ else: raise TestFailed, "dangerous instance method creation allowed" +# Verify that instancemethod() doesn't allow keyword args +try: + new.instancemethod(break_yolks, c, kw=1) +except TypeError: + pass +else: + raise TestFailed, "instancemethod shouldn't accept keyword args" + # It's unclear what the semantics should be for a code object compiled at # module scope, but bound and run in a function. In CPython, `c' is global # (by accident?) while in Jython, `c' is local. The intent of the test Modified: python/branches/p3yk/Lib/test/test_nis.py ============================================================================== --- python/branches/p3yk/Lib/test/test_nis.py (original) +++ python/branches/p3yk/Lib/test/test_nis.py Wed Dec 13 05:49:30 2006 @@ -1,32 +1,41 @@ -from test.test_support import verbose, TestFailed, TestSkipped +from test.test_support import verbose, run_unittest +import unittest import nis -print 'nis.maps()' -try: - maps = nis.maps() -except nis.error, msg: - # NIS is probably not active, so this test isn't useful - if verbose: - raise TestFailed, msg - # only do this if running under the regression suite - raise TestSkipped, msg +class NisTests(unittest.TestCase): + def test_maps(self): + try: + maps = nis.maps() + except nis.error, msg: + # NIS is probably not active, so this test isn't useful + if verbose: + self.fail("(failing because of verbose mode) %s" % msg) + return + try: + # On some systems, this map is only accessible to the + # super user + maps.remove("passwd.adjunct.byname") + except ValueError: + pass -done = 0 -for nismap in maps: - if verbose: - print nismap - mapping = nis.cat(nismap) - for k, v in mapping.items(): - if verbose: - print ' ', k, v - if not k: - continue - if nis.match(k, nismap) != v: - print "NIS match failed for key `%s' in map `%s'" % (k, nismap) - else: - # just test the one key, otherwise this test could take a - # very long time - done = 1 - break - if done: - break + done = 0 + for nismap in maps: + mapping = nis.cat(nismap) + for k, v in mapping.items(): + if not k: + continue + if nis.match(k, nismap) != v: + self.fail("NIS match failed for key `%s' in map `%s'" % (k, nismap)) + else: + # just test the one key, otherwise this test could take a + # very long time + done = 1 + break + if done: + break + +def test_main(): + run_unittest(NisTests) + +if __name__ == '__main__': + test_main() Modified: python/branches/p3yk/Lib/test/test_opcodes.py ============================================================================== --- python/branches/p3yk/Lib/test/test_opcodes.py (original) +++ python/branches/p3yk/Lib/test/test_opcodes.py Wed Dec 13 05:49:30 2006 @@ -1,101 +1,110 @@ # Python test set -- part 2, opcodes -from test.test_support import TestFailed +from test.test_support import run_unittest +import unittest +class OpcodeTest(unittest.TestCase): -print '2. Opcodes' -print 'XXX Not yet fully implemented' + def test_try_inside_for_loop(self): + n = 0 + for i in range(10): + n = n+i + try: 1/0 + except NameError: pass + except ZeroDivisionError: pass + except TypeError: pass + try: pass + except: pass + try: pass + finally: pass + n = n+i + if n != 90: + self.fail('try inside for') + + def test_raise_class_exceptions(self): + + class AClass(Exception): pass + class BClass(AClass): pass + class CClass(Exception): pass + class DClass(AClass): + def __init__(self, ignore): + pass + + try: raise AClass() + except: pass + + try: raise AClass() + except AClass: pass + + try: raise BClass() + except AClass: pass + + try: raise BClass() + except CClass: self.fail() + except: pass + + a = AClass() + b = BClass() + + try: raise AClass, b + except BClass, v: + if v != b: self.fail("v!=b") + else: self.fail("no exception") + + try: raise b + except AClass, v: + if v != b: self.fail("v!=b AClass") + else: + self.fail("no exception") + + # not enough arguments + ##try: raise BClass, a + ##except TypeError: pass + ##else: self.fail("no exception") + + try: raise DClass, a + except DClass, v: + self.assert_(isinstance(v, DClass)) + else: + self.fail("no exception") + + def test_compare_function_objects(self): + + f = eval('lambda: None') + g = eval('lambda: None') + self.failIf(f == g) + + f = eval('lambda a: a') + g = eval('lambda a: a') + self.failIf(f == g) + + f = eval('lambda a=1: a') + g = eval('lambda a=1: a') + self.failIf(f == g) + + f = eval('lambda: 0') + g = eval('lambda: 1') + self.failIf(f == g) + + f = eval('lambda: None') + g = eval('lambda a: None') + self.failIf(f == g) + + f = eval('lambda a: None') + g = eval('lambda b: None') + self.failIf(f == g) + + f = eval('lambda a: None') + g = eval('lambda a=None: None') + self.failIf(f == g) + + f = eval('lambda a=0: None') + g = eval('lambda a=1: None') + self.failIf(f == g) -print '2.1 try inside for loop' -n = 0 -for i in range(10): - n = n+i - try: 1/0 - except NameError: pass - except ZeroDivisionError: pass - except TypeError: pass - try: pass - except: pass - try: pass - finally: pass - n = n+i -if n != 90: - raise TestFailed, 'try inside for' - - -print '2.2 raise class exceptions' - -class AClass(Exception): pass -class BClass(AClass): pass -class CClass(Exception): pass -class DClass(AClass): - def __init__(self, ignore): - pass - -try: raise AClass() -except: pass - -try: raise AClass() -except AClass: pass - -try: raise BClass() -except AClass: pass - -try: raise BClass() -except CClass: raise TestFailed -except: pass - -a = AClass() -b = BClass() - -try: raise AClass, b -except BClass, v: - if v != b: raise TestFailed, "v!=b" -else: raise TestFailed, "no exception" - -try: raise b -except AClass, v: - if v != b: raise TestFailed, "v!=b AClass" - -# not enough arguments -##try: raise BClass, a -##except TypeError: pass - -try: raise DClass, a -except DClass, v: - if not isinstance(v, DClass): - raise TestFailed, "v not DClass" - -print '2.3 comparing function objects' - -f = eval('lambda: None') -g = eval('lambda: None') -if f == g: raise TestFailed, "functions should not be same" - -f = eval('lambda a: a') -g = eval('lambda a: a') -if f == g: raise TestFailed, "functions should not be same" - -f = eval('lambda a=1: a') -g = eval('lambda a=1: a') -if f == g: raise TestFailed, "functions should not be same" - -f = eval('lambda: 0') -g = eval('lambda: 1') -if f == g: raise TestFailed - -f = eval('lambda: None') -g = eval('lambda a: None') -if f == g: raise TestFailed - -f = eval('lambda a: None') -g = eval('lambda b: None') -if f == g: raise TestFailed - -f = eval('lambda a: None') -g = eval('lambda a=None: None') -if f == g: raise TestFailed - -f = eval('lambda a=0: None') -g = eval('lambda a=1: None') -if f == g: raise TestFailed + +def test_main(): + run_unittest(OpcodeTest) + +if __name__ == '__main__': + test_main() Modified: python/branches/p3yk/Lib/test/test_openpty.py ============================================================================== --- python/branches/p3yk/Lib/test/test_openpty.py (original) +++ python/branches/p3yk/Lib/test/test_openpty.py Wed Dec 13 05:49:30 2006 @@ -1,19 +1,23 @@ # Test to see if openpty works. (But don't worry if it isn't available.) -import os -from test.test_support import verbose, TestFailed, TestSkipped +import os, unittest +from test.test_support import run_unittest, TestSkipped -try: - if verbose: - print "Calling os.openpty()" - master, slave = os.openpty() - if verbose: - print "(master, slave) = (%d, %d)"%(master, slave) -except AttributeError: +if not hasattr(os, "openpty"): raise TestSkipped, "No openpty() available." -if not os.isatty(slave): - raise TestFailed, "Slave-end of pty is not a terminal." -os.write(slave, 'Ping!') -print os.read(master, 1024) +class OpenptyTest(unittest.TestCase): + def test(self): + master, slave = os.openpty() + if not os.isatty(slave): + self.fail("Slave-end of pty is not a terminal.") + + os.write(slave, 'Ping!') + self.assertEqual(os.read(master, 1024), 'Ping!') + +def test_main(): + run_unittest(OpenptyTest) + +if __name__ == '__main__': + test_main() Modified: python/branches/p3yk/Lib/test/test_os.py ============================================================================== --- python/branches/p3yk/Lib/test/test_os.py (original) +++ python/branches/p3yk/Lib/test/test_os.py Wed Dec 13 05:49:30 2006 @@ -223,6 +223,23 @@ except TypeError: pass + def test_utime_dir(self): + delta = 1000000 + st = os.stat(test_support.TESTFN) + # round to int, because some systems may support sub-second + # time stamps in stat, but not in utime. + os.utime(test_support.TESTFN, (st.st_atime, int(st.st_mtime-delta))) + st2 = os.stat(test_support.TESTFN) + self.assertEquals(st2.st_mtime, int(st.st_mtime-delta)) + + # Restrict test to Win32, since there is no guarantee other + # systems support centiseconds + if sys.platform == 'win32': + def test_1565150(self): + t1 = 1159195039.25 + os.utime(self.fname, (t1, t1)) + self.assertEquals(os.stat(self.fname).st_mtime, t1) + from test import mapping_tests class EnvironTests(mapping_tests.BasicTestMappingProtocol): Modified: python/branches/p3yk/Lib/test/test_parser.py ============================================================================== --- python/branches/p3yk/Lib/test/test_parser.py (original) +++ python/branches/p3yk/Lib/test/test_parser.py Wed Dec 13 05:49:30 2006 @@ -183,6 +183,44 @@ def test_assert(self): self.check_suite("assert alo < ahi and blo < bhi\n") + def test_position(self): + # An absolutely minimal test of position information. Better + # tests would be a big project. + code = "def f(x):\n return x + 1\n" + st1 = parser.suite(code) + st2 = st1.totuple(line_info=1, col_info=1) + + def walk(tree): + node_type = tree[0] + next = tree[1] + if isinstance(next, tuple): + for elt in tree[1:]: + for x in walk(elt): + yield x + else: + yield tree + + terminals = list(walk(st2)) + self.assertEqual([ + (1, 'def', 1, 0), + (1, 'f', 1, 4), + (7, '(', 1, 5), + (1, 'x', 1, 6), + (8, ')', 1, 7), + (11, ':', 1, 8), + (4, '', 1, 9), + (5, '', 2, -1), + (1, 'return', 2, 4), + (1, 'x', 2, 11), + (14, '+', 2, 13), + (2, '1', 2, 15), + (4, '', 2, 16), + (6, '', 2, -1), + (4, '', 2, -1), + (0, '', 2, -1)], + terminals) + + # # Second, we take *invalid* trees and make sure we get ParserError # rejections for them. Modified: python/branches/p3yk/Lib/test/test_peepholer.py ============================================================================== --- python/branches/p3yk/Lib/test/test_peepholer.py (original) +++ python/branches/p3yk/Lib/test/test_peepholer.py Wed Dec 13 05:49:30 2006 @@ -160,6 +160,41 @@ self.assert_('(None)' not in asm) self.assertEqual(asm.split().count('RETURN_VALUE'), 1) + def test_elim_jump_to_return(self): + # JUMP_FORWARD to RETURN --> RETURN + def f(cond, true_value, false_value): + return true_value if cond else false_value + asm = disassemble(f) + self.assert_('JUMP_FORWARD' not in asm) + self.assert_('JUMP_ABSOLUTE' not in asm) + self.assertEqual(asm.split().count('RETURN_VALUE'), 2) + + def test_elim_jump_after_return1(self): + # Eliminate dead code: jumps immediately after returns can't be reached + def f(cond1, cond2): + if cond1: return 1 + if cond2: return 2 + while 1: + return 3 + while 1: + if cond1: return 4 + return 5 + return 6 + asm = disassemble(f) + self.assert_('JUMP_FORWARD' not in asm) + self.assert_('JUMP_ABSOLUTE' not in asm) + self.assertEqual(asm.split().count('RETURN_VALUE'), 6) + + def test_elim_jump_after_return2(self): + # Eliminate dead code: jumps immediately after returns can't be reached + def f(cond1, cond2): + while 1: + if cond1: return 4 + asm = disassemble(f) + self.assert_('JUMP_FORWARD' not in asm) + # There should be one jump for the while loop. + self.assertEqual(asm.split().count('JUMP_ABSOLUTE'), 1) + self.assertEqual(asm.split().count('RETURN_VALUE'), 2) def test_main(verbose=None): Modified: python/branches/p3yk/Lib/test/test_pep352.py ============================================================================== --- python/branches/p3yk/Lib/test/test_pep352.py (original) +++ python/branches/p3yk/Lib/test/test_pep352.py Wed Dec 13 05:49:30 2006 @@ -15,8 +15,7 @@ self.failUnless(issubclass(Exception, object)) def verify_instance_interface(self, ins): - for attr in ("args", "message", "__str__", "__unicode__", "__repr__", - "__getitem__"): + for attr in ("args", "message", "__str__", "__repr__", "__getitem__"): self.failUnless(hasattr(ins, attr), "%s missing %s attribute" % (ins.__class__.__name__, attr)) Modified: python/branches/p3yk/Lib/test/test_poll.py ============================================================================== --- python/branches/p3yk/Lib/test/test_poll.py (original) +++ python/branches/p3yk/Lib/test/test_poll.py Wed Dec 13 05:49:30 2006 @@ -1,7 +1,7 @@ # Test case for the os.poll() function -import sys, os, select, random -from test.test_support import verify, verbose, TestSkipped, TESTFN +import sys, os, select, random, unittest +from test.test_support import TestSkipped, TESTFN, run_unittest try: select.poll @@ -16,177 +16,141 @@ match.append(fd) return match -def test_poll1(): - """Basic functional test of poll object +class PollTests(unittest.TestCase): - Create a bunch of pipe and test that poll works with them. - """ - print 'Running poll test 1' - p = select.poll() - - NUM_PIPES = 12 - MSG = " This is a test." - MSG_LEN = len(MSG) - readers = [] - writers = [] - r2w = {} - w2r = {} - - for i in range(NUM_PIPES): - rd, wr = os.pipe() - p.register(rd, select.POLLIN) - p.register(wr, select.POLLOUT) - readers.append(rd) - writers.append(wr) - r2w[rd] = wr - w2r[wr] = rd - - while writers: - ready = p.poll() - ready_writers = find_ready_matching(ready, select.POLLOUT) - if not ready_writers: - raise RuntimeError, "no pipes ready for writing" - wr = random.choice(ready_writers) - os.write(wr, MSG) - - ready = p.poll() - ready_readers = find_ready_matching(ready, select.POLLIN) - if not ready_readers: - raise RuntimeError, "no pipes ready for reading" - rd = random.choice(ready_readers) - buf = os.read(rd, MSG_LEN) - verify(len(buf) == MSG_LEN) - print buf - os.close(r2w[rd]) ; os.close( rd ) - p.unregister( r2w[rd] ) - p.unregister( rd ) - writers.remove(r2w[rd]) - - poll_unit_tests() - print 'Poll test 1 complete' - -def poll_unit_tests(): - # returns NVAL for invalid file descriptor - FD = 42 - try: - os.close(FD) - except OSError: - pass - p = select.poll() - p.register(FD) - r = p.poll() - verify(r[0] == (FD, select.POLLNVAL)) - - f = open(TESTFN, 'w') - fd = f.fileno() - p = select.poll() - p.register(f) - r = p.poll() - verify(r[0][0] == fd) - f.close() - r = p.poll() - verify(r[0] == (fd, select.POLLNVAL)) - os.unlink(TESTFN) - - # type error for invalid arguments - p = select.poll() - try: - p.register(p) - except TypeError: - pass - else: - print "Bogus register call did not raise TypeError" - try: - p.unregister(p) - except TypeError: - pass - else: - print "Bogus unregister call did not raise TypeError" - - # can't unregister non-existent object - p = select.poll() - try: - p.unregister(3) - except KeyError: - pass - else: - print "Bogus unregister call did not raise KeyError" - - # Test error cases - pollster = select.poll() - class Nope: - pass - - class Almost: - def fileno(self): - return 'fileno' - - try: - pollster.register( Nope(), 0 ) - except TypeError: pass - else: print 'expected TypeError exception, not raised' - - try: - pollster.register( Almost(), 0 ) - except TypeError: pass - else: print 'expected TypeError exception, not raised' - - -# Another test case for poll(). This is copied from the test case for -# select(), modified to use poll() instead. - -def test_poll2(): - print 'Running poll test 2' - cmd = 'for i in 0 1 2 3 4 5 6 7 8 9; do echo testing...; sleep 1; done' - p = os.popen(cmd, 'r') - pollster = select.poll() - pollster.register( p, select.POLLIN ) - for tout in (0, 1000, 2000, 4000, 8000, 16000) + (-1,)*10: - if verbose: - print 'timeout =', tout - fdlist = pollster.poll(tout) - if (fdlist == []): - continue - fd, flags = fdlist[0] - if flags & select.POLLHUP: - line = p.readline() - if line != "": - print 'error: pipe seems to be closed, but still returns data' - continue - - elif flags & select.POLLIN: - line = p.readline() - if verbose: - print repr(line) - if not line: - if verbose: - print 'EOF' - break - continue - else: - print 'Unexpected return value from select.poll:', fdlist - p.close() - print 'Poll test 2 complete' - -def test_poll3(): - # test int overflow - print 'Running poll test 3' - pollster = select.poll() - pollster.register(1) - - try: - pollster.poll(1L << 64) - except OverflowError: - pass - else: - print 'Expected OverflowError with excessive timeout' - - x = 2 + 3 - if x != 5: - print 'Overflow must have occurred' - print 'Poll test 3 complete' - - -test_poll1() -test_poll2() -test_poll3() + def test_poll1(self): + # Basic functional test of poll object + # Create a bunch of pipe and test that poll works with them. + + p = select.poll() + + NUM_PIPES = 12 + MSG = " This is a test." + MSG_LEN = len(MSG) + readers = [] + writers = [] + r2w = {} + w2r = {} + + for i in range(NUM_PIPES): + rd, wr = os.pipe() + p.register(rd, select.POLLIN) + p.register(wr, select.POLLOUT) + readers.append(rd) + writers.append(wr) + r2w[rd] = wr + w2r[wr] = rd + + bufs = [] + + while writers: + ready = p.poll() + ready_writers = find_ready_matching(ready, select.POLLOUT) + if not ready_writers: + raise RuntimeError, "no pipes ready for writing" + wr = random.choice(ready_writers) + os.write(wr, MSG) + + ready = p.poll() + ready_readers = find_ready_matching(ready, select.POLLIN) + if not ready_readers: + raise RuntimeError, "no pipes ready for reading" + rd = random.choice(ready_readers) + buf = os.read(rd, MSG_LEN) + self.assertEqual(len(buf), MSG_LEN) + bufs.append(buf) + os.close(r2w[rd]) ; os.close( rd ) + p.unregister( r2w[rd] ) + p.unregister( rd ) + writers.remove(r2w[rd]) + + self.assertEqual(bufs, [MSG] * NUM_PIPES) + + def poll_unit_tests(self): + # returns NVAL for invalid file descriptor + FD = 42 + try: + os.close(FD) + except OSError: + pass + p = select.poll() + p.register(FD) + r = p.poll() + self.assertEqual(r[0], (FD, select.POLLNVAL)) + + f = open(TESTFN, 'w') + fd = f.fileno() + p = select.poll() + p.register(f) + r = p.poll() + self.assertEqual(r[0][0], fd) + f.close() + r = p.poll() + self.assertEqual(r[0], (fd, select.POLLNVAL)) + os.unlink(TESTFN) + + # type error for invalid arguments + p = select.poll() + self.assertRaises(TypeError, p.register, p) + self.assertRaises(TypeError, p.unregister, p) + + # can't unregister non-existent object + p = select.poll() + self.assertRaises(KeyError, p.unregister, 3) + + # Test error cases + pollster = select.poll() + class Nope: + pass + + class Almost: + def fileno(self): + return 'fileno' + + self.assertRaises(TypeError, pollster.register, Nope(), 0) + self.assertRaises(TypeError, pollster.register, Almost(), 0) + + # Another test case for poll(). This is copied from the test case for + # select(), modified to use poll() instead. + + def test_poll2(self): + cmd = 'for i in 0 1 2 3 4 5 6 7 8 9; do echo testing...; sleep 1; done' + p = os.popen(cmd, 'r') + pollster = select.poll() + pollster.register( p, select.POLLIN ) + for tout in (0, 1000, 2000, 4000, 8000, 16000) + (-1,)*10: + fdlist = pollster.poll(tout) + if (fdlist == []): + continue + fd, flags = fdlist[0] + if flags & select.POLLHUP: + line = p.readline() + if line != "": + self.fail('error: pipe seems to be closed, but still returns data') + continue + + elif flags & select.POLLIN: + line = p.readline() + if not line: + break + continue + else: + self.fail('Unexpected return value from select.poll: %s' % fdlist) + p.close() + + def test_poll3(self): + # test int overflow + pollster = select.poll() + pollster.register(1) + + self.assertRaises(OverflowError, pollster.poll, 1L << 64) + + x = 2 + 3 + if x != 5: + self.fail('Overflow must have occurred') + +def test_main(): + run_unittest(PollTests) + +if __name__ == '__main__': + test_main() Modified: python/branches/p3yk/Lib/test/test_pyclbr.py ============================================================================== --- python/branches/p3yk/Lib/test/test_pyclbr.py (original) +++ python/branches/p3yk/Lib/test/test_pyclbr.py Wed Dec 13 05:49:30 2006 @@ -95,6 +95,9 @@ py_item = getattr(module, name) if isinstance(value, pyclbr.Function): self.assert_(isinstance(py_item, (FunctionType, BuiltinFunctionType))) + if py_item.__module__ != moduleName: + continue # skip functions that came from somewhere else + self.assertEquals(py_item.__module__, value.module) else: self.failUnless(isinstance(py_item, (ClassType, type))) if py_item.__module__ != moduleName: Modified: python/branches/p3yk/Lib/test/test_scope.py ============================================================================== --- python/branches/p3yk/Lib/test/test_scope.py (original) +++ python/branches/p3yk/Lib/test/test_scope.py Wed Dec 13 05:49:30 2006 @@ -1,186 +1,190 @@ -from test.test_support import verify, TestFailed, check_syntax, vereq +import unittest +from test.test_support import check_syntax_error, run_unittest import warnings +warnings.filterwarnings("ignore", r"import \*", SyntaxWarning, "") warnings.filterwarnings("ignore", r"import \*", SyntaxWarning, "") -print "1. simple nesting" +class ScopeTests(unittest.TestCase): -def make_adder(x): - def adder(y): - return x + y - return adder + def testSimpleNesting(self): -inc = make_adder(1) -plus10 = make_adder(10) + def make_adder(x): + def adder(y): + return x + y + return adder -vereq(inc(1), 2) -vereq(plus10(-2), 8) + inc = make_adder(1) + plus10 = make_adder(10) -print "2. extra nesting" + self.assertEqual(inc(1), 2) + self.assertEqual(plus10(-2), 8) -def make_adder2(x): - def extra(): # check freevars passing through non-use scopes - def adder(y): - return x + y - return adder - return extra() + def testExtraNesting(self): -inc = make_adder2(1) -plus10 = make_adder2(10) + def make_adder2(x): + def extra(): # check freevars passing through non-use scopes + def adder(y): + return x + y + return adder + return extra() -vereq(inc(1), 2) -vereq(plus10(-2), 8) + inc = make_adder2(1) + plus10 = make_adder2(10) -print "3. simple nesting + rebinding" + self.assertEqual(inc(1), 2) + self.assertEqual(plus10(-2), 8) -def make_adder3(x): - def adder(y): - return x + y - x = x + 1 # check tracking of assignment to x in defining scope - return adder + def testSimpleAndRebinding(self): -inc = make_adder3(0) -plus10 = make_adder3(9) + def make_adder3(x): + def adder(y): + return x + y + x = x + 1 # check tracking of assignment to x in defining scope + return adder -vereq(inc(1), 2) -vereq(plus10(-2), 8) + inc = make_adder3(0) + plus10 = make_adder3(9) -print "4. nesting with global but no free" + self.assertEqual(inc(1), 2) + self.assertEqual(plus10(-2), 8) -def make_adder4(): # XXX add exta level of indirection - def nest(): - def nest(): - def adder(y): - return global_x + y # check that plain old globals work - return adder - return nest() - return nest() + def testNestingGlobalNoFree(self): -global_x = 1 -adder = make_adder4() -vereq(adder(1), 2) + def make_adder4(): # XXX add exta level of indirection + def nest(): + def nest(): + def adder(y): + return global_x + y # check that plain old globals work + return adder + return nest() + return nest() -global_x = 10 -vereq(adder(-2), 8) + global_x = 1 + adder = make_adder4() + self.assertEqual(adder(1), 2) -print "5. nesting through class" + global_x = 10 + self.assertEqual(adder(-2), 8) -def make_adder5(x): - class Adder: - def __call__(self, y): - return x + y - return Adder() + def testNestingThroughClass(self): -inc = make_adder5(1) -plus10 = make_adder5(10) + def make_adder5(x): + class Adder: + def __call__(self, y): + return x + y + return Adder() -vereq(inc(1), 2) -vereq(plus10(-2), 8) + inc = make_adder5(1) + plus10 = make_adder5(10) -print "6. nesting plus free ref to global" + self.assertEqual(inc(1), 2) + self.assertEqual(plus10(-2), 8) -def make_adder6(x): - global global_nest_x - def adder(y): - return global_nest_x + y - global_nest_x = x - return adder + def testNestingPlusFreeRefToGlobal(self): -inc = make_adder6(1) -plus10 = make_adder6(10) + def make_adder6(x): + global global_nest_x + def adder(y): + return global_nest_x + y + global_nest_x = x + return adder -vereq(inc(1), 11) # there's only one global -vereq(plus10(-2), 8) + inc = make_adder6(1) + plus10 = make_adder6(10) -print "7. nearest enclosing scope" + self.assertEqual(inc(1), 11) # there's only one global + self.assertEqual(plus10(-2), 8) -def f(x): - def g(y): - x = 42 # check that this masks binding in f() - def h(z): - return x + z - return h - return g(2) - -test_func = f(10) -vereq(test_func(5), 47) - -print "8. mixed freevars and cellvars" - -def identity(x): - return x - -def f(x, y, z): - def g(a, b, c): - a = a + x # 3 - def h(): - # z * (4 + 9) - # 3 * 13 - return identity(z * (b + y)) - y = c + z # 9 - return h - return g - -g = f(1, 2, 3) -h = g(2, 4, 6) -vereq(h(), 39) - -print "9. free variable in method" - -def test(): - method_and_var = "var" - class Test: - def method_and_var(self): - return "method" - def test(self): - return method_and_var - def actual_global(self): - return str("global") - def str(self): - return str(self) - return Test() - -t = test() -vereq(t.test(), "var") -vereq(t.method_and_var(), "method") -vereq(t.actual_global(), "global") - -method_and_var = "var" -class Test: - # this class is not nested, so the rules are different - def method_and_var(self): - return "method" - def test(self): - return method_and_var - def actual_global(self): - return str("global") - def str(self): - return str(self) - -t = Test() -vereq(t.test(), "var") -vereq(t.method_and_var(), "method") -vereq(t.actual_global(), "global") + def testNearestEnclosingScope(self): -print "10. recursion" + def f(x): + def g(y): + x = 42 # check that this masks binding in f() + def h(z): + return x + z + return h + return g(2) -def f(x): - def fact(n): - if n == 0: - return 1 - else: - return n * fact(n - 1) - if x >= 0: - return fact(x) - else: - raise ValueError, "x must be >= 0" + test_func = f(10) + self.assertEqual(test_func(5), 47) -vereq(f(6), 720) + def testMixedFreevarsAndCellvars(self): + + def identity(x): + return x + def f(x, y, z): + def g(a, b, c): + a = a + x # 3 + def h(): + # z * (4 + 9) + # 3 * 13 + return identity(z * (b + y)) + y = c + z # 9 + return h + return g + + g = f(1, 2, 3) + h = g(2, 4, 6) + self.assertEqual(h(), 39) + + def testFreeVarInMethod(self): + + def test(): + method_and_var = "var" + class Test: + def method_and_var(self): + return "method" + def test(self): + return method_and_var + def actual_global(self): + return str("global") + def str(self): + return str(self) + return Test() + + t = test() + self.assertEqual(t.test(), "var") + self.assertEqual(t.method_and_var(), "method") + self.assertEqual(t.actual_global(), "global") + + method_and_var = "var" + class Test: + # this class is not nested, so the rules are different + def method_and_var(self): + return "method" + def test(self): + return method_and_var + def actual_global(self): + return str("global") + def str(self): + return str(self) + + t = Test() + self.assertEqual(t.test(), "var") + self.assertEqual(t.method_and_var(), "method") + self.assertEqual(t.actual_global(), "global") + + def testRecursion(self): + + def f(x): + def fact(n): + if n == 0: + return 1 + else: + return n * fact(n - 1) + if x >= 0: + return fact(x) + else: + raise ValueError, "x must be >= 0" -print "11. unoptimized namespaces" + self.assertEqual(f(6), 720) -check_syntax("""\ + + def testUnoptimizedNamespaces(self): + + check_syntax_error(self, """\ def unoptimized_clash1(strip): def f(s): from string import * @@ -188,7 +192,7 @@ return f """) -check_syntax("""\ + check_syntax_error(self, """\ def unoptimized_clash2(): from string import * def f(s): @@ -196,7 +200,7 @@ return f """) -check_syntax("""\ + check_syntax_error(self, """\ def unoptimized_clash2(): from string import * def g(): @@ -205,23 +209,23 @@ return f """) -check_syntax("""\ + check_syntax_error(self, """\ def f(x): def g(): return x del x # can't del name """) -check_syntax("""\ + check_syntax_error(self, """\ def f(): def g(): - from string import * - return strip # global or local? + from string import * + return strip # global or local? """) -# and verify a few cases that should work + # and verify a few cases that should work -exec(""" + exec(""" def noproblem1(): from string import * f = lambda x:x @@ -238,59 +242,60 @@ y = x """) -print "12. lambdas" - -f1 = lambda x: lambda y: x + y -inc = f1(1) -plus10 = f1(10) -vereq(inc(1), 2) -vereq(plus10(5), 15) - -f2 = lambda x: (lambda : lambda y: x + y)() -inc = f2(1) -plus10 = f2(10) -vereq(inc(1), 2) -vereq(plus10(5), 15) + def testLambdas(self): -f3 = lambda x: lambda y: global_x + y -global_x = 1 -inc = f3(None) -vereq(inc(2), 3) - -f8 = lambda x, y, z: lambda a, b, c: lambda : z * (b + y) -g = f8(1, 2, 3) -h = g(2, 4, 6) -vereq(h(), 18) - -print "13. UnboundLocal" - -def errorInOuter(): - print y - def inner(): - return y - y = 1 - -def errorInInner(): - def inner(): - return y - inner() - y = 1 - -try: - errorInOuter() -except UnboundLocalError: - pass -else: - raise TestFailed + f1 = lambda x: lambda y: x + y + inc = f1(1) + plus10 = f1(10) + self.assertEqual(inc(1), 2) + self.assertEqual(plus10(5), 15) + + f2 = lambda x: (lambda : lambda y: x + y)() + inc = f2(1) + plus10 = f2(10) + self.assertEqual(inc(1), 2) + self.assertEqual(plus10(5), 15) + + f3 = lambda x: lambda y: global_x + y + global_x = 1 + inc = f3(None) + self.assertEqual(inc(2), 3) + + f8 = lambda x, y, z: lambda a, b, c: lambda : z * (b + y) + g = f8(1, 2, 3) + h = g(2, 4, 6) + self.assertEqual(h(), 18) + + def testUnboundLocal(self): + + def errorInOuter(): + print y + def inner(): + return y + y = 1 + + def errorInInner(): + def inner(): + return y + inner() + y = 1 + + try: + errorInOuter() + except UnboundLocalError: + pass + else: + self.fail() -try: - errorInInner() -except NameError: - pass -else: - raise TestFailed + try: + errorInInner() + except NameError: + pass + else: + self.fail() -# test for bug #1501934: incorrect LOAD/STORE_GLOBAL generation + # test for bug #1501934: incorrect LOAD/STORE_GLOBAL generation + exec(""" global_x = 1 def f(): global_x += 1 @@ -299,34 +304,36 @@ except UnboundLocalError: pass else: - raise TestFailed, 'scope of global_x not correctly determined' + fail('scope of global_x not correctly determined') +""", {'fail': self.fail}) -print "14. complex definitions" + def testComplexDefinitions(self): -def makeReturner(*lst): - def returner(): - return lst - return returner + def makeReturner(*lst): + def returner(): + return lst + return returner -vereq(makeReturner(1,2,3)(), (1,2,3)) + self.assertEqual(makeReturner(1,2,3)(), (1,2,3)) -def makeReturner2(**kwargs): - def returner(): - return kwargs - return returner + def makeReturner2(**kwargs): + def returner(): + return kwargs + return returner -vereq(makeReturner2(a=11)()['a'], 11) + self.assertEqual(makeReturner2(a=11)()['a'], 11) -def makeAddPair((a, b)): - def addPair((c, d)): - return (a + c, b + d) - return addPair + def makeAddPair((a, b)): + def addPair((c, d)): + return (a + c, b + d) + return addPair -vereq(makeAddPair((1, 2))((100, 200)), (101,202)) + self.assertEqual(makeAddPair((1, 2))((100, 200)), (101,202)) -print "15. scope of global statements" + def testScopeOfGlobalStmt(self): # Examples posted by Samuele Pedroni to python-dev on 3/1/2001 + exec("""\ # I x = 7 def f(): @@ -339,8 +346,8 @@ return h() return i() return g() -vereq(f(), 7) -vereq(x, 7) +self.assertEqual(f(), 7) +self.assertEqual(x, 7) # II x = 7 @@ -354,8 +361,8 @@ return h() return i() return g() -vereq(f(), 2) -vereq(x, 7) +self.assertEqual(f(), 2) +self.assertEqual(x, 7) # III x = 7 @@ -370,8 +377,8 @@ return h() return i() return g() -vereq(f(), 2) -vereq(x, 2) +self.assertEqual(f(), 2) +self.assertEqual(x, 2) # IV x = 7 @@ -386,8 +393,8 @@ return h() return i() return g() -vereq(f(), 2) -vereq(x, 2) +self.assertEqual(f(), 2) +self.assertEqual(x, 2) # XXX what about global statements in class blocks? # do they affect methods? @@ -402,34 +409,36 @@ return x g = Global() -vereq(g.get(), 13) +self.assertEqual(g.get(), 13) g.set(15) -vereq(g.get(), 13) +self.assertEqual(g.get(), 13) +""") -print "16. check leaks" + def testLeaks(self): -class Foo: - count = 0 + class Foo: + count = 0 - def __init__(self): - Foo.count += 1 + def __init__(self): + Foo.count += 1 - def __del__(self): - Foo.count -= 1 + def __del__(self): + Foo.count -= 1 -def f1(): - x = Foo() - def f2(): - return x - f2() + def f1(): + x = Foo() + def f2(): + return x + f2() -for i in range(100): - f1() + for i in range(100): + f1() -vereq(Foo.count, 0) + self.assertEqual(Foo.count, 0) -print "17. class and global" + def testClassAndGlobal(self): + exec("""\ def test(x): class Foo: global x @@ -438,9 +447,9 @@ return Foo() x = 0 -vereq(test(6)(2), 8) +self.assertEqual(test(6)(2), 8) x = -1 -vereq(test(3)(2), 5) +self.assertEqual(test(3)(2), 5) looked_up_by_load_name = False class X: @@ -449,104 +458,106 @@ locals()['looked_up_by_load_name'] = True passed = looked_up_by_load_name -verify(X.passed) - -print "18. verify that locals() works" - -def f(x): - def g(y): - def h(z): - return y + z - w = x + y - y += 3 - return locals() - return g - -d = f(2)(4) -verify('h' in d) -del d['h'] -vereq(d, {'x': 2, 'y': 7, 'w': 6}) - -print "19. var is bound and free in class" - -def f(x): - class C: - def m(self): - return x - a = x - return C - -inst = f(3)() -vereq(inst.a, inst.m()) - -print "20. interaction with trace function" - -import sys -def tracer(a,b,c): - return tracer - -def adaptgetter(name, klass, getter): - kind, des = getter - if kind == 1: # AV happens when stepping from this line to next - if des == "": - des = "_%s__%s" % (klass.__name__, name) - return lambda obj: getattr(obj, des) - -class TestClass: - pass +self.assert_(X.passed) +""") -sys.settrace(tracer) -adaptgetter("foo", TestClass, (1, "")) -sys.settrace(None) - -try: sys.settrace() -except TypeError: pass -else: raise TestFailed, 'sys.settrace() did not raise TypeError' + def testLocalsFunction(self): -print "20. eval and exec with free variables" + def f(x): + def g(y): + def h(z): + return y + z + w = x + y + y += 3 + return locals() + return g + + d = f(2)(4) + self.assert_('h' in d) + del d['h'] + self.assertEqual(d, {'x': 2, 'y': 7, 'w': 6}) + + def testBoundAndFree(self): + # var is bound and free in class + + def f(x): + class C: + def m(self): + return x + a = x + return C + + inst = f(3)() + self.assertEqual(inst.a, inst.m()) + + def testInteractionWithTraceFunc(self): + + import sys + def tracer(a,b,c): + return tracer + + def adaptgetter(name, klass, getter): + kind, des = getter + if kind == 1: # AV happens when stepping from this line to next + if des == "": + des = "_%s__%s" % (klass.__name__, name) + return lambda obj: getattr(obj, des) + + class TestClass: + pass + + sys.settrace(tracer) + adaptgetter("foo", TestClass, (1, "")) + sys.settrace(None) + + self.assertRaises(TypeError, sys.settrace) + + def testEvalExecFreeVars(self): + + def f(x): + return lambda: x + 1 + + g = f(3) + self.assertRaises(TypeError, eval, g.func_code) + + try: + exec(g.func_code, {}) + except TypeError: + pass + else: + self.fail("exec should have failed, because code contained free vars") -def f(x): - return lambda: x + 1 + def testListCompLocalVars(self): -g = f(3) -try: - eval(g.func_code) -except TypeError: - pass -else: - print "eval() should have failed, because code contained free vars" + try: + print bad + except NameError: + pass + else: + print "bad should not be defined" -try: - exec(g.func_code) -except TypeError: - pass -else: - print "exec should have failed, because code contained free vars" + def x(): + [bad for s in 'a b' for bad in s.split()] -print "21. list comprehension with local variables" + x() + try: + print bad + except NameError: + pass -try: - print bad -except NameError: - pass -else: - print "bad should not be defined" + def testEvalFreeVars(self): -def x(): - [bad for s in 'a b' for bad in s.split()] + def f(x): + def g(): + x + eval("x + 1") + return g -x() -try: - print bad -except NameError: - pass + f(4)() -print "22. eval with free variables" -def f(x): - def g(): - x - eval("x + 1") - return g +def test_main(): + run_unittest(ScopeTests) -f(4)() +if __name__ == '__main__': + test_main() Modified: python/branches/p3yk/Lib/test/test_set.py ============================================================================== --- python/branches/p3yk/Lib/test/test_set.py (original) +++ python/branches/p3yk/Lib/test/test_set.py Wed Dec 13 05:49:30 2006 @@ -298,6 +298,17 @@ self.assert_(self.thetype(self.word) not in s) self.assertRaises(KeyError, self.s.remove, self.thetype(self.word)) + def test_remove_keyerror_unpacking(self): + # bug: www.python.org/sf/1576657 + for v1 in ['Q', (1,)]: + try: + self.s.remove(v1) + except KeyError, e: + v2 = e.args[0] + self.assertEqual(v1, v2) + else: + self.fail() + def test_discard(self): self.s.discard('a') self.assert_('a' not in self.s) Modified: python/branches/p3yk/Lib/test/test_sgmllib.py ============================================================================== --- python/branches/p3yk/Lib/test/test_sgmllib.py (original) +++ python/branches/p3yk/Lib/test/test_sgmllib.py Wed Dec 13 05:49:30 2006 @@ -286,21 +286,6 @@ ('codepoint', 'convert', 42), ]) - def test_attr_values_quoted_markup(self): - """Multi-line and markup in attribute values""" - self.check_events("""text""", - [("starttag", "a", [("title", "foo\n
    bar")]), - ("data", "text"), - ("endtag", "a")]) - self.check_events("""text""", - [("starttag", "a", [("title", "less < than")]), - ("data", "text"), - ("endtag", "a")]) - self.check_events("""text""", - [("starttag", "a", [("title", "greater > than")]), - ("data", "text"), - ("endtag", "a")]) - def test_attr_funky_names(self): self.check_events("""""", [ ("starttag", "a", [("a.b", "v"), ("c:d", "v"), ("e-f", "v")]), @@ -376,6 +361,19 @@ ('decl', 'DOCTYPE doc []'), ]) + def test_read_chunks(self): + # SF bug #1541697, this caused sgml parser to hang + # Just verify this code doesn't cause a hang. + CHUNK = 1024 # increasing this to 8212 makes the problem go away + + f = open(test_support.findfile('sgml_input.html')) + fp = sgmllib.SGMLParser() + while 1: + data = f.read(CHUNK) + fp.feed(data) + if len(data) != CHUNK: + break + # XXX These tests have been disabled by prefixing their names with # an underscore. The first two exercise outstanding bugs in the # sgmllib module, and the third exhibits questionable behavior Modified: python/branches/p3yk/Lib/test/test_sha.py ============================================================================== --- python/branches/p3yk/Lib/test/test_sha.py (original) +++ python/branches/p3yk/Lib/test/test_sha.py Wed Dec 13 05:49:30 2006 @@ -11,9 +11,23 @@ class SHATestCase(unittest.TestCase): def check(self, data, digest): - computed = sha.new(data).hexdigest() + # Check digest matches the expected value + obj = sha.new(data) + computed = obj.hexdigest() self.assert_(computed == digest) + # Verify that the value doesn't change between two consecutive + # digest operations. + computed_again = obj.hexdigest() + self.assert_(computed == computed_again) + + # Check hexdigest() output matches digest()'s output + digest = obj.digest() + hexd = "" + for c in digest: + hexd += '%02x' % ord(c) + self.assert_(computed == hexd) + def test_case_1(self): self.check("abc", "a9993e364706816aba3e25717850c26c9cd0d89d") @@ -26,6 +40,9 @@ self.check("a" * 1000000, "34aa973cd4c4daa4f61eeb2bdbad27316534016f") + def test_case_4(self): + self.check(chr(0xAA) * 80, + '4ca0ef38f1794b28a8f8ee110ee79d48ce13be25') def test_main(): test_support.run_unittest(SHATestCase) Modified: python/branches/p3yk/Lib/test/test_subprocess.py ============================================================================== --- python/branches/p3yk/Lib/test/test_subprocess.py (original) +++ python/branches/p3yk/Lib/test/test_subprocess.py Wed Dec 13 05:49:30 2006 @@ -234,6 +234,12 @@ stripped = remove_stderr_debug_decorations(output) self.assertEqual(stripped, "appleorange") + def test_stdout_filedes_of_stdout(self): + # stdout is set to 1 (#1531862). + cmd = r"import sys, os; sys.exit(os.write(sys.stdout.fileno(), '.\n'))" + rc = subprocess.call([sys.executable, "-c", cmd], stdout=1) + self.assertEquals(rc, 2) + def test_cwd(self): tmpdir = os.getenv("TEMP", "/tmp") # We cannot use os.path.realpath to canonicalize the path, Modified: python/branches/p3yk/Lib/test/test_support.py ============================================================================== --- python/branches/p3yk/Lib/test/test_support.py (original) +++ python/branches/p3yk/Lib/test/test_support.py Wed Dec 13 05:49:30 2006 @@ -244,13 +244,13 @@ withcommas = ", ".join(reprpairs) return "{%s}" % withcommas -def check_syntax(statement): +def check_syntax_error(testcase, statement): try: - compile(statement, '', 'exec') + compile(statement, '', 'exec') except SyntaxError: pass else: - print 'Missing SyntaxError: "%s"' % statement + testcase.fail('Missing SyntaxError: "%s"' % statement) def open_urlresource(url): import urllib, urlparse Modified: python/branches/p3yk/Lib/test/test_syntax.py ============================================================================== --- python/branches/p3yk/Lib/test/test_syntax.py (original) +++ python/branches/p3yk/Lib/test/test_syntax.py Wed Dec 13 05:49:30 2006 @@ -235,6 +235,138 @@ >>> f() += 1 Traceback (most recent call last): SyntaxError: illegal expression for augmented assignment (, line 1) + + +Test continue in finally in weird combinations. + +continue in for loop under finally shouuld be ok. + + >>> def test(): + ... try: + ... pass + ... finally: + ... for abc in range(10): + ... continue + ... print abc + >>> test() + 9 + +Start simple, a continue in a finally should not be allowed. + + >>> def test(): + ... for abc in range(10): + ... try: + ... pass + ... finally: + ... continue + Traceback (most recent call last): + ... + SyntaxError: 'continue' not supported inside 'finally' clause (, line 6) + +This is essentially a continue in a finally which should not be allowed. + + >>> def test(): + ... for abc in range(10): + ... try: + ... pass + ... finally: + ... try: + ... continue + ... except: + ... pass + Traceback (most recent call last): + ... + SyntaxError: 'continue' not supported inside 'finally' clause (, line 7) + + >>> def foo(): + ... try: + ... pass + ... finally: + ... continue + Traceback (most recent call last): + ... + SyntaxError: 'continue' not supported inside 'finally' clause (, line 5) + + >>> def foo(): + ... for a in (): + ... try: + ... pass + ... finally: + ... continue + Traceback (most recent call last): + ... + SyntaxError: 'continue' not supported inside 'finally' clause (, line 6) + + >>> def foo(): + ... for a in (): + ... try: + ... pass + ... finally: + ... try: + ... continue + ... finally: + ... pass + Traceback (most recent call last): + ... + SyntaxError: 'continue' not supported inside 'finally' clause (, line 7) + + >>> def foo(): + ... for a in (): + ... try: pass + ... finally: + ... try: + ... pass + ... except: + ... continue + Traceback (most recent call last): + ... + SyntaxError: 'continue' not supported inside 'finally' clause (, line 8) + +There is one test for a break that is not in a loop. The compiler +uses a single data structure to keep track of try-finally and loops, +so we need to be sure that a break is actually inside a loop. If it +isn't, there should be a syntax error. + + >>> try: + ... print 1 + ... break + ... print 2 + ... finally: + ... print 3 + Traceback (most recent call last): + ... + SyntaxError: 'break' outside loop (, line 3) + +This should probably raise a better error than a SystemError (or none at all). +In 2.5 there was a missing exception and an assert was triggered in a debug +build. The number of blocks must be greater than CO_MAXBLOCKS. SF #1565514 + + >>> while 1: + ... while 2: + ... while 3: + ... while 4: + ... while 5: + ... while 6: + ... while 8: + ... while 9: + ... while 10: + ... while 11: + ... while 12: + ... while 13: + ... while 14: + ... while 15: + ... while 16: + ... while 17: + ... while 18: + ... while 19: + ... while 20: + ... while 21: + ... while 22: + ... break + Traceback (most recent call last): + ... + SystemError: too many statically nested blocks + """ import re Modified: python/branches/p3yk/Lib/test/test_tarfile.py ============================================================================== --- python/branches/p3yk/Lib/test/test_tarfile.py (original) +++ python/branches/p3yk/Lib/test/test_tarfile.py Wed Dec 13 05:49:30 2006 @@ -280,6 +280,32 @@ else: self.dst.addfile(tarinfo, f) + +class Write100Test(BaseTest): + # The name field in a tar header stores strings of at most 100 chars. + # If a string is shorter than 100 chars it has to be padded with '\0', + # which implies that a string of exactly 100 chars is stored without + # a trailing '\0'. + + def setUp(self): + self.name = "01234567890123456789012345678901234567890123456789" + self.name += "01234567890123456789012345678901234567890123456789" + + self.tar = tarfile.open(tmpname(), "w") + t = tarfile.TarInfo(self.name) + self.tar.addfile(t) + self.tar.close() + + self.tar = tarfile.open(tmpname()) + + def tearDown(self): + self.tar.close() + + def test(self): + self.assertEqual(self.tar.getnames()[0], self.name, + "failed to store 100 char filename") + + class WriteSize0Test(BaseTest): mode = 'w' @@ -362,13 +388,6 @@ is tested as well. """ - def setUp(self): - self.tar = tarfile.open(tmpname(), "w") - self.tar.posix = False - - def tearDown(self): - self.tar.close() - def _length(self, s): blocks, remainder = divmod(len(s) + 1, 512) if remainder: @@ -397,12 +416,23 @@ tarinfo.linkname = link tarinfo.type = tarfile.LNKTYPE - self.tar.addfile(tarinfo) + tar = tarfile.open(tmpname(), "w") + tar.posix = False + tar.addfile(tarinfo) v1 = self._calc_size(name, link) - v2 = self.tar.offset + v2 = tar.offset self.assertEqual(v1, v2, "GNU longname/longlink creation failed") + tar.close() + + tar = tarfile.open(tmpname()) + member = tar.next() + self.failIf(member is None, "unable to read longname member") + self.assert_(tarinfo.name == member.name and \ + tarinfo.linkname == member.linkname, \ + "unable to read longname member") + def test_longname_1023(self): self._test(("longnam/" * 127) + "longnam") @@ -623,6 +653,7 @@ ReadAsteriskTest, ReadStreamAsteriskTest, WriteTest, + Write100Test, WriteSize0Test, WriteStreamTest, WriteGNULongTest, Modified: python/branches/p3yk/Lib/test/test_tempfile.py ============================================================================== --- python/branches/p3yk/Lib/test/test_tempfile.py (original) +++ python/branches/p3yk/Lib/test/test_tempfile.py Wed Dec 13 05:49:30 2006 @@ -27,7 +27,7 @@ # number of files that can be opened at one time (see ulimit -n) if sys.platform == 'mac': TEST_FILES = 32 -elif sys.platform == 'openbsd3': +elif sys.platform in ('openbsd3', 'openbsd4'): TEST_FILES = 48 else: TEST_FILES = 100 Modified: python/branches/p3yk/Lib/test/test_time.py ============================================================================== --- python/branches/p3yk/Lib/test/test_time.py (original) +++ python/branches/p3yk/Lib/test/test_time.py Wed Dec 13 05:49:30 2006 @@ -102,15 +102,19 @@ self.assertEquals(expected, result) def test_strptime(self): + # Should be able to go round-trip from strftime to strptime without + # throwing an exception. tt = time.gmtime(self.t) for directive in ('a', 'A', 'b', 'B', 'c', 'd', 'H', 'I', 'j', 'm', 'M', 'p', 'S', 'U', 'w', 'W', 'x', 'X', 'y', 'Y', 'Z', '%'): - format = ' %' + directive + format = '%' + directive + strf_output = time.strftime(format, tt) try: - time.strptime(time.strftime(format, tt), format) + time.strptime(strf_output, format) except ValueError: - self.fail('conversion specifier: %r failed.' % format) + self.fail("conversion specifier %r failed with '%s' input." % + (format, strf_output)) def test_asctime(self): time.asctime(time.gmtime(self.t)) Modified: python/branches/p3yk/Lib/test/test_tokenize.py ============================================================================== --- python/branches/p3yk/Lib/test/test_tokenize.py (original) +++ python/branches/p3yk/Lib/test/test_tokenize.py Wed Dec 13 05:49:30 2006 @@ -1,9 +1,93 @@ -import os, glob, random +"""Tests for the tokenize module. + +The tests were originally written in the old Python style, where the +test output was compared to a golden file. This docstring represents +the first steps towards rewriting the entire test as a doctest. + +The tests can be really simple. Given a small fragment of source +code, print out a table with the tokens. The ENDMARK is omitted for +brevity. + +>>> dump_tokens("1 + 1") +NUMBER '1' (1, 0) (1, 1) +OP '+' (1, 2) (1, 3) +NUMBER '1' (1, 4) (1, 5) + +A comment generates a token here, unlike in the parser module. The +comment token is followed by an NL or a NEWLINE token, depending on +whether the line contains the completion of a statement. + +>>> dump_tokens("if False:\\n" +... " # NL\\n" +... " True = False # NEWLINE\\n") +NAME 'if' (1, 0) (1, 2) +NAME 'False' (1, 3) (1, 8) +OP ':' (1, 8) (1, 9) +NEWLINE '\\n' (1, 9) (1, 10) +COMMENT '# NL' (2, 4) (2, 8) +NL '\\n' (2, 8) (2, 9) +INDENT ' ' (3, 0) (3, 4) +NAME 'True' (3, 4) (3, 8) +OP '=' (3, 9) (3, 10) +NAME 'False' (3, 11) (3, 16) +COMMENT '# NEWLINE' (3, 17) (3, 26) +NEWLINE '\\n' (3, 26) (3, 27) +DEDENT '' (4, 0) (4, 0) + + +There will be a bunch more tests of specific source patterns. + +The tokenize module also defines an untokenize function that should +regenerate the original program text from the tokens. + +There are some standard formatting practices that are easy to get right. + +>>> roundtrip("if x == 1:\\n" +... " print x\\n") +if x == 1: + print x + +Some people use different formatting conventions, which makes +untokenize a little trickier. Note that this test involves trailing +whitespace after the colon. Note that we use hex escapes to make the +two trailing blanks apparent in the expected output. + +>>> roundtrip("if x == 1 : \\n" +... " print x\\n") +if x == 1 :\x20\x20 + print x + +Comments need to go in the right place. + +>>> roundtrip("if x == 1:\\n" +... " # A comment by itself.\\n" +... " print x # Comment here, too.\\n" +... " # Another comment.\\n" +... "after_if = True\\n") +if x == 1: + # A comment by itself. + print x # Comment here, too. + # Another comment. +after_if = True + +>>> roundtrip("if (x # The comments need to go in the right place\\n" +... " == 1):\\n" +... " print 'x == 1'\\n") +if (x # The comments need to go in the right place + == 1): + print 'x == 1' + +""" + +import os, glob, random, time, sys from cStringIO import StringIO from test.test_support import (verbose, findfile, is_resource_enabled, TestFailed) -from tokenize import (tokenize, generate_tokens, untokenize, - NUMBER, NAME, OP, STRING) +from tokenize import (tokenize, generate_tokens, untokenize, tok_name, + ENDMARKER, NUMBER, NAME, OP, STRING, COMMENT) + +# How much time in seconds can pass before we print a 'Still working' message. +_PRINT_WORKING_MSG_INTERVAL = 5 * 60 # Test roundtrip for `untokenize`. `f` is a file path. The source code in f # is tokenized, converted back to source code via tokenize.untokenize(), @@ -24,6 +108,23 @@ if t1 != t2: raise TestFailed("untokenize() roundtrip failed for %r" % f) +def dump_tokens(s): + """Print out the tokens in s in a table format. + + The ENDMARKER is omitted. + """ + f = StringIO(s) + for type, token, start, end, line in generate_tokens(f.readline): + if type == ENDMARKER: + break + type = tok_name[type] + print "%(type)-10.10s %(token)-13.13r %(start)s %(end)s" % locals() + +def roundtrip(s): + f = StringIO(s) + source = untokenize(generate_tokens(f.readline)) + print source, + # This is an example from the docs, set up as a doctest. def decistmt(s): """Substitute Decimals for floats in a string of statements. @@ -66,6 +167,8 @@ if verbose: print 'starting...' + next_time = time.time() + _PRINT_WORKING_MSG_INTERVAL + # This displays the tokenization of tokenize_tests.py to stdout, and # regrtest.py checks that this equals the expected output (in the # test/output/ directory). @@ -85,6 +188,12 @@ testfiles = random.sample(testfiles, 10) for f in testfiles: + # Print still working message since this test can be really slow + if next_time <= time.time(): + next_time = time.time() + _PRINT_WORKING_MSG_INTERVAL + print >>sys.__stdout__, ' test_main still working, be patient...' + sys.__stdout__.flush() + test_roundtrip(f) # Test detecton of IndentationError. @@ -105,7 +214,7 @@ # Run the doctests in this module. from test import test_tokenize # i.e., this module from test.test_support import run_doctest - run_doctest(test_tokenize) + run_doctest(test_tokenize, verbose) if verbose: print 'finished' Modified: python/branches/p3yk/Lib/test/test_traceback.py ============================================================================== --- python/branches/p3yk/Lib/test/test_traceback.py (original) +++ python/branches/p3yk/Lib/test/test_traceback.py Wed Dec 13 05:49:30 2006 @@ -122,6 +122,10 @@ X.__name__, str_value)) + def test_without_exception(self): + err = traceback.format_exception_only(None, None) + self.assertEqual(err, ['None\n']) + def test_main(): run_unittest(TracebackCases) Modified: python/branches/p3yk/Lib/test/test_types.py ============================================================================== --- python/branches/p3yk/Lib/test/test_types.py (original) +++ python/branches/p3yk/Lib/test/test_types.py Wed Dec 13 05:49:30 2006 @@ -1,285 +1,271 @@ # Python test set -- part 6, built-in types -from test.test_support import * +from test.test_support import run_unittest, have_unicode +import unittest +import sys -print '6. Built-in types' +class TypesTests(unittest.TestCase): -print '6.1 Truth value testing' -if None: raise TestFailed, 'None is true instead of false' -if 0: raise TestFailed, '0 is true instead of false' -if 0L: raise TestFailed, '0L is true instead of false' -if 0.0: raise TestFailed, '0.0 is true instead of false' -if '': raise TestFailed, '\'\' is true instead of false' -if not 1: raise TestFailed, '1 is false instead of true' -if not 1L: raise TestFailed, '1L is false instead of true' -if not 1.0: raise TestFailed, '1.0 is false instead of true' -if not 'x': raise TestFailed, '\'x\' is false instead of true' -if not {'x': 1}: raise TestFailed, '{\'x\': 1} is false instead of true' -def f(): pass -class C: pass -import sys -x = C() -if not f: raise TestFailed, 'f is false instead of true' -if not C: raise TestFailed, 'C is false instead of true' -if not sys: raise TestFailed, 'sys is false instead of true' -if not x: raise TestFailed, 'x is false instead of true' - -print '6.2 Boolean operations' -if 0 or 0: raise TestFailed, '0 or 0 is true instead of false' -if 1 and 1: pass -else: raise TestFailed, '1 and 1 is false instead of true' -if not 1: raise TestFailed, 'not 1 is true instead of false' - -print '6.3 Comparisons' -if 0 < 1 <= 1 == 1 >= 1 > 0 != 1: pass -else: raise TestFailed, 'int comparisons failed' -if 0L < 1L <= 1L == 1L >= 1L > 0L != 1L: pass -else: raise TestFailed, 'long int comparisons failed' -if 0.0 < 1.0 <= 1.0 == 1.0 >= 1.0 > 0.0 != 1.0: pass -else: raise TestFailed, 'float comparisons failed' -if '' < 'a' <= 'a' == 'a' < 'abc' < 'abd' < 'b': pass -else: raise TestFailed, 'string comparisons failed' -if None is None: pass -else: raise TestFailed, 'identity test failed' - -try: float('') -except ValueError: pass -else: raise TestFailed, "float('') didn't raise ValueError" - -try: float('5\0') -except ValueError: pass -else: raise TestFailed, "float('5\0') didn't raise ValueError" - -try: 5.0 / 0.0 -except ZeroDivisionError: pass -else: raise TestFailed, "5.0 / 0.0 didn't raise ZeroDivisionError" - -try: 5.0 // 0.0 -except ZeroDivisionError: pass -else: raise TestFailed, "5.0 // 0.0 didn't raise ZeroDivisionError" - -try: 5.0 % 0.0 -except ZeroDivisionError: pass -else: raise TestFailed, "5.0 % 0.0 didn't raise ZeroDivisionError" - -try: 5 / 0L -except ZeroDivisionError: pass -else: raise TestFailed, "5 / 0L didn't raise ZeroDivisionError" - -try: 5 // 0L -except ZeroDivisionError: pass -else: raise TestFailed, "5 // 0L didn't raise ZeroDivisionError" - -try: 5 % 0L -except ZeroDivisionError: pass -else: raise TestFailed, "5 % 0L didn't raise ZeroDivisionError" - -print '6.4 Numeric types (mostly conversions)' -if 0 != 0L or 0 != 0.0 or 0L != 0.0: raise TestFailed, 'mixed comparisons' -if 1 != 1L or 1 != 1.0 or 1L != 1.0: raise TestFailed, 'mixed comparisons' -if -1 != -1L or -1 != -1.0 or -1L != -1.0: - raise TestFailed, 'int/long/float value not equal' -# calling built-in types without argument must return 0 -if int() != 0: raise TestFailed, 'int() does not return 0' -if long() != 0L: raise TestFailed, 'long() does not return 0L' -if float() != 0.0: raise TestFailed, 'float() does not return 0.0' -if int(1.9) == 1 == int(1.1) and int(-1.1) == -1 == int(-1.9): pass -else: raise TestFailed, 'int() does not round properly' -if long(1.9) == 1L == long(1.1) and long(-1.1) == -1L == long(-1.9): pass -else: raise TestFailed, 'long() does not round properly' -if float(1) == 1.0 and float(-1) == -1.0 and float(0) == 0.0: pass -else: raise TestFailed, 'float() does not work properly' -print '6.4.1 32-bit integers' -# Ensure the first 256 integers are shared -a = 256 -b = 128*2 -if a is not b: raise TestFailed, '256 is not shared' -if 12 + 24 != 36: raise TestFailed, 'int op' -if 12 + (-24) != -12: raise TestFailed, 'int op' -if (-12) + 24 != 12: raise TestFailed, 'int op' -if (-12) + (-24) != -36: raise TestFailed, 'int op' -if not 12 < 24: raise TestFailed, 'int op' -if not -24 < -12: raise TestFailed, 'int op' -# Test for a particular bug in integer multiply -xsize, ysize, zsize = 238, 356, 4 -if not (xsize*ysize*zsize == zsize*xsize*ysize == 338912): - raise TestFailed, 'int mul commutativity' -# And another. -m = -sys.maxint - 1 -for divisor in 1, 2, 4, 8, 16, 32: - j = m // divisor - prod = divisor * j - if prod != m: - raise TestFailed, "%r * %r == %r != %r" % (divisor, j, prod, m) - if type(prod) is not int: - raise TestFailed, ("expected type(prod) to be int, not %r" % - type(prod)) -# Check for expected * overflow to long. -for divisor in 1, 2, 4, 8, 16, 32: - j = m // divisor - 1 - prod = divisor * j - if type(prod) is not long: - raise TestFailed, ("expected type(%r) to be long, not %r" % - (prod, type(prod))) -# Check for expected * overflow to long. -m = sys.maxint -for divisor in 1, 2, 4, 8, 16, 32: - j = m // divisor + 1 - prod = divisor * j - if type(prod) is not long: - raise TestFailed, ("expected type(%r) to be long, not %r" % - (prod, type(prod))) - -print '6.4.2 Long integers' -if 12L + 24L != 36L: raise TestFailed, 'long op' -if 12L + (-24L) != -12L: raise TestFailed, 'long op' -if (-12L) + 24L != 12L: raise TestFailed, 'long op' -if (-12L) + (-24L) != -36L: raise TestFailed, 'long op' -if not 12L < 24L: raise TestFailed, 'long op' -if not -24L < -12L: raise TestFailed, 'long op' -x = sys.maxint -if int(long(x)) != x: raise TestFailed, 'long op' -try: y = int(long(x)+1L) -except OverflowError: raise TestFailed, 'long op' -if not isinstance(y, long): raise TestFailed, 'long op' -x = -x -if int(long(x)) != x: raise TestFailed, 'long op' -x = x-1 -if int(long(x)) != x: raise TestFailed, 'long op' -try: y = int(long(x)-1L) -except OverflowError: raise TestFailed, 'long op' -if not isinstance(y, long): raise TestFailed, 'long op' - -try: 5 << -5 -except ValueError: pass -else: raise TestFailed, 'int negative shift <<' - -try: 5L << -5L -except ValueError: pass -else: raise TestFailed, 'long negative shift <<' - -try: 5 >> -5 -except ValueError: pass -else: raise TestFailed, 'int negative shift >>' - -try: 5L >> -5L -except ValueError: pass -else: raise TestFailed, 'long negative shift >>' - -print '6.4.3 Floating point numbers' -if 12.0 + 24.0 != 36.0: raise TestFailed, 'float op' -if 12.0 + (-24.0) != -12.0: raise TestFailed, 'float op' -if (-12.0) + 24.0 != 12.0: raise TestFailed, 'float op' -if (-12.0) + (-24.0) != -36.0: raise TestFailed, 'float op' -if not 12.0 < 24.0: raise TestFailed, 'float op' -if not -24.0 < -12.0: raise TestFailed, 'float op' - -print '6.5 Sequence types' - -print '6.5.1 Strings' -if len('') != 0: raise TestFailed, 'len(\'\')' -if len('a') != 1: raise TestFailed, 'len(\'a\')' -if len('abcdef') != 6: raise TestFailed, 'len(\'abcdef\')' -if 'xyz' + 'abcde' != 'xyzabcde': raise TestFailed, 'string concatenation' -if 'xyz'*3 != 'xyzxyzxyz': raise TestFailed, 'string repetition *3' -if 0*'abcde' != '': raise TestFailed, 'string repetition 0*' -if min('abc') != 'a' or max('abc') != 'c': raise TestFailed, 'min/max string' -if 'a' in 'abc' and 'b' in 'abc' and 'c' in 'abc' and 'd' not in 'abc': pass -else: raise TestFailed, 'in/not in string' -x = 'x'*103 -if '%s!'%x != x+'!': raise TestFailed, 'nasty string formatting bug' - -#extended slices for strings -a = '0123456789' -vereq(a[::], a) -vereq(a[::2], '02468') -vereq(a[1::2], '13579') -vereq(a[::-1],'9876543210') -vereq(a[::-2], '97531') -vereq(a[3::-2], '31') -vereq(a[-100:100:], a) -vereq(a[100:-100:-1], a[::-1]) -vereq(a[-100L:100L:2L], '02468') - -if have_unicode: - a = unicode('0123456789', 'ascii') - vereq(a[::], a) - vereq(a[::2], unicode('02468', 'ascii')) - vereq(a[1::2], unicode('13579', 'ascii')) - vereq(a[::-1], unicode('9876543210', 'ascii')) - vereq(a[::-2], unicode('97531', 'ascii')) - vereq(a[3::-2], unicode('31', 'ascii')) - vereq(a[-100:100:], a) - vereq(a[100:-100:-1], a[::-1]) - vereq(a[-100L:100L:2L], unicode('02468', 'ascii')) - - -print '6.5.2 Tuples [see test_tuple.py]' - -print '6.5.3 Lists [see test_list.py]' - -print '6.6 Mappings == Dictionaries [see test_dict.py]' - - -try: type(1, 2) -except TypeError: pass -else: raise TestFailed, 'type(), w/2 args expected TypeError' - -try: type(1, 2, 3, 4) -except TypeError: pass -else: raise TestFailed, 'type(), w/4 args expected TypeError' - -print 'Buffers' -try: buffer('asdf', -1) -except ValueError: pass -else: raise TestFailed, "buffer('asdf', -1) should raise ValueError" - -try: buffer(None) -except TypeError: pass -else: raise TestFailed, "buffer(None) should raise TypeError" - -a = buffer('asdf') -hash(a) -b = a * 5 -if a == b: - raise TestFailed, 'buffers should not be equal' -if str(b) != ('asdf' * 5): - raise TestFailed, 'repeated buffer has wrong content' -if str(a * 0) != '': - raise TestFailed, 'repeated buffer zero times has wrong content' -if str(a + buffer('def')) != 'asdfdef': - raise TestFailed, 'concatenation of buffers yields wrong content' -if str(buffer(a)) != 'asdf': - raise TestFailed, 'composing buffers failed' -if str(buffer(a, 2)) != 'df': - raise TestFailed, 'specifying buffer offset failed' -if str(buffer(a, 0, 2)) != 'as': - raise TestFailed, 'specifying buffer size failed' -if str(buffer(a, 1, 2)) != 'sd': - raise TestFailed, 'specifying buffer offset and size failed' -try: buffer(buffer('asdf', 1), -1) -except ValueError: pass -else: raise TestFailed, "buffer(buffer('asdf', 1), -1) should raise ValueError" -if str(buffer(buffer('asdf', 0, 2), 0)) != 'as': - raise TestFailed, 'composing length-specified buffer failed' -if str(buffer(buffer('asdf', 0, 2), 0, 5000)) != 'as': - raise TestFailed, 'composing length-specified buffer failed' -if str(buffer(buffer('asdf', 0, 2), 0, -1)) != 'as': - raise TestFailed, 'composing length-specified buffer failed' -if str(buffer(buffer('asdf', 0, 2), 1, 2)) != 's': - raise TestFailed, 'composing length-specified buffer failed' - -try: a[1] = 'g' -except TypeError: pass -else: raise TestFailed, "buffer assignment should raise TypeError" - -try: a[0:1] = 'g' -except TypeError: pass -else: raise TestFailed, "buffer slice assignment should raise TypeError" - -# array.array() returns an object that does not implement a char buffer, -# something which int() uses for conversion. -import array -try: int(buffer(array.array('c'))) -except TypeError :pass -else: raise TestFailed, "char buffer (at C level) not working" + def test_truth_values(self): + if None: self.fail('None is true instead of false') + if 0: self.fail('0 is true instead of false') + if 0L: self.fail('0L is true instead of false') + if 0.0: self.fail('0.0 is true instead of false') + if '': self.fail('\'\' is true instead of false') + if not 1: self.fail('1 is false instead of true') + if not 1L: self.fail('1L is false instead of true') + if not 1.0: self.fail('1.0 is false instead of true') + if not 'x': self.fail('\'x\' is false instead of true') + if not {'x': 1}: self.fail('{\'x\': 1} is false instead of true') + def f(): pass + class C: pass + import sys + x = C() + if not f: self.fail('f is false instead of true') + if not C: self.fail('C is false instead of true') + if not sys: self.fail('sys is false instead of true') + if not x: self.fail('x is false instead of true') + + def test_boolean_ops(self): + if 0 or 0: self.fail('0 or 0 is true instead of false') + if 1 and 1: pass + else: self.fail('1 and 1 is false instead of true') + if not 1: self.fail('not 1 is true instead of false') + + def test_comparisons(self): + if 0 < 1 <= 1 == 1 >= 1 > 0 != 1: pass + else: self.fail('int comparisons failed') + if 0L < 1L <= 1L == 1L >= 1L > 0L != 1L: pass + else: self.fail('long int comparisons failed') + if 0.0 < 1.0 <= 1.0 == 1.0 >= 1.0 > 0.0 != 1.0: pass + else: self.fail('float comparisons failed') + if '' < 'a' <= 'a' == 'a' < 'abc' < 'abd' < 'b': pass + else: self.fail('string comparisons failed') + if None is None: pass + else: self.fail('identity test failed') + + def test_float_constructor(self): + self.assertRaises(ValueError, float, '') + self.assertRaises(ValueError, float, '5\0') + + def test_zero_division(self): + try: 5.0 / 0.0 + except ZeroDivisionError: pass + else: self.fail("5.0 / 0.0 didn't raise ZeroDivisionError") + + try: 5.0 // 0.0 + except ZeroDivisionError: pass + else: self.fail("5.0 // 0.0 didn't raise ZeroDivisionError") + + try: 5.0 % 0.0 + except ZeroDivisionError: pass + else: self.fail("5.0 % 0.0 didn't raise ZeroDivisionError") + + try: 5 / 0L + except ZeroDivisionError: pass + else: self.fail("5 / 0L didn't raise ZeroDivisionError") + + try: 5 // 0L + except ZeroDivisionError: pass + else: self.fail("5 // 0L didn't raise ZeroDivisionError") + + try: 5 % 0L + except ZeroDivisionError: pass + else: self.fail("5 % 0L didn't raise ZeroDivisionError") + + def test_numeric_types(self): + if 0 != 0L or 0 != 0.0 or 0L != 0.0: self.fail('mixed comparisons') + if 1 != 1L or 1 != 1.0 or 1L != 1.0: self.fail('mixed comparisons') + if -1 != -1L or -1 != -1.0 or -1L != -1.0: + self.fail('int/long/float value not equal') + # calling built-in types without argument must return 0 + if int() != 0: self.fail('int() does not return 0') + if long() != 0L: self.fail('long() does not return 0L') + if float() != 0.0: self.fail('float() does not return 0.0') + if int(1.9) == 1 == int(1.1) and int(-1.1) == -1 == int(-1.9): pass + else: self.fail('int() does not round properly') + if long(1.9) == 1L == long(1.1) and long(-1.1) == -1L == long(-1.9): pass + else: self.fail('long() does not round properly') + if float(1) == 1.0 and float(-1) == -1.0 and float(0) == 0.0: pass + else: self.fail('float() does not work properly') + + def test_normal_integers(self): + # Ensure the first 256 integers are shared + a = 256 + b = 128*2 + if a is not b: self.fail('256 is not shared') + if 12 + 24 != 36: self.fail('int op') + if 12 + (-24) != -12: self.fail('int op') + if (-12) + 24 != 12: self.fail('int op') + if (-12) + (-24) != -36: self.fail('int op') + if not 12 < 24: self.fail('int op') + if not -24 < -12: self.fail('int op') + # Test for a particular bug in integer multiply + xsize, ysize, zsize = 238, 356, 4 + if not (xsize*ysize*zsize == zsize*xsize*ysize == 338912): + self.fail('int mul commutativity') + # And another. + m = -sys.maxint - 1 + for divisor in 1, 2, 4, 8, 16, 32: + j = m // divisor + prod = divisor * j + if prod != m: + self.fail("%r * %r == %r != %r" % (divisor, j, prod, m)) + if type(prod) is not int: + self.fail("expected type(prod) to be int, not %r" % + type(prod)) + # Check for expected * overflow to long. + for divisor in 1, 2, 4, 8, 16, 32: + j = m // divisor - 1 + prod = divisor * j + if type(prod) is not long: + self.fail("expected type(%r) to be long, not %r" % + (prod, type(prod))) + # Check for expected * overflow to long. + m = sys.maxint + for divisor in 1, 2, 4, 8, 16, 32: + j = m // divisor + 1 + prod = divisor * j + if type(prod) is not long: + self.fail("expected type(%r) to be long, not %r" % + (prod, type(prod))) + + def test_long_integers(self): + if 12L + 24L != 36L: self.fail('long op') + if 12L + (-24L) != -12L: self.fail('long op') + if (-12L) + 24L != 12L: self.fail('long op') + if (-12L) + (-24L) != -36L: self.fail('long op') + if not 12L < 24L: self.fail('long op') + if not -24L < -12L: self.fail('long op') + x = sys.maxint + if int(long(x)) != x: self.fail('long op') + try: y = int(long(x)+1L) + except OverflowError: self.fail('long op') + if not isinstance(y, long): self.fail('long op') + x = -x + if int(long(x)) != x: self.fail('long op') + x = x-1 + if int(long(x)) != x: self.fail('long op') + try: y = int(long(x)-1L) + except OverflowError: self.fail('long op') + if not isinstance(y, long): self.fail('long op') + + try: 5 << -5 + except ValueError: pass + else: self.fail('int negative shift <<') + + try: 5L << -5L + except ValueError: pass + else: self.fail('long negative shift <<') + + try: 5 >> -5 + except ValueError: pass + else: self.fail('int negative shift >>') + + try: 5L >> -5L + except ValueError: pass + else: self.fail('long negative shift >>') + + def test_floats(self): + if 12.0 + 24.0 != 36.0: self.fail('float op') + if 12.0 + (-24.0) != -12.0: self.fail('float op') + if (-12.0) + 24.0 != 12.0: self.fail('float op') + if (-12.0) + (-24.0) != -36.0: self.fail('float op') + if not 12.0 < 24.0: self.fail('float op') + if not -24.0 < -12.0: self.fail('float op') + + def test_strings(self): + if len('') != 0: self.fail('len(\'\')') + if len('a') != 1: self.fail('len(\'a\')') + if len('abcdef') != 6: self.fail('len(\'abcdef\')') + if 'xyz' + 'abcde' != 'xyzabcde': self.fail('string concatenation') + if 'xyz'*3 != 'xyzxyzxyz': self.fail('string repetition *3') + if 0*'abcde' != '': self.fail('string repetition 0*') + if min('abc') != 'a' or max('abc') != 'c': self.fail('min/max string') + if 'a' in 'abc' and 'b' in 'abc' and 'c' in 'abc' and 'd' not in 'abc': pass + else: self.fail('in/not in string') + x = 'x'*103 + if '%s!'%x != x+'!': self.fail('nasty string formatting bug') + + #extended slices for strings + a = '0123456789' + self.assertEqual(a[::], a) + self.assertEqual(a[::2], '02468') + self.assertEqual(a[1::2], '13579') + self.assertEqual(a[::-1],'9876543210') + self.assertEqual(a[::-2], '97531') + self.assertEqual(a[3::-2], '31') + self.assertEqual(a[-100:100:], a) + self.assertEqual(a[100:-100:-1], a[::-1]) + self.assertEqual(a[-100L:100L:2L], '02468') + + if have_unicode: + a = unicode('0123456789', 'ascii') + self.assertEqual(a[::], a) + self.assertEqual(a[::2], unicode('02468', 'ascii')) + self.assertEqual(a[1::2], unicode('13579', 'ascii')) + self.assertEqual(a[::-1], unicode('9876543210', 'ascii')) + self.assertEqual(a[::-2], unicode('97531', 'ascii')) + self.assertEqual(a[3::-2], unicode('31', 'ascii')) + self.assertEqual(a[-100:100:], a) + self.assertEqual(a[100:-100:-1], a[::-1]) + self.assertEqual(a[-100L:100L:2L], unicode('02468', 'ascii')) + + + def test_type_function(self): + self.assertRaises(TypeError, type, 1, 2) + self.assertRaises(TypeError, type, 1, 2, 3, 4) + + def test_buffers(self): + self.assertRaises(ValueError, buffer, 'asdf', -1) + self.assertRaises(TypeError, buffer, None) + + a = buffer('asdf') + hash(a) + b = a * 5 + if a == b: + self.fail('buffers should not be equal') + if str(b) != ('asdf' * 5): + self.fail('repeated buffer has wrong content') + if str(a * 0) != '': + self.fail('repeated buffer zero times has wrong content') + if str(a + buffer('def')) != 'asdfdef': + self.fail('concatenation of buffers yields wrong content') + if str(buffer(a)) != 'asdf': + self.fail('composing buffers failed') + if str(buffer(a, 2)) != 'df': + self.fail('specifying buffer offset failed') + if str(buffer(a, 0, 2)) != 'as': + self.fail('specifying buffer size failed') + if str(buffer(a, 1, 2)) != 'sd': + self.fail('specifying buffer offset and size failed') + self.assertRaises(ValueError, buffer, buffer('asdf', 1), -1) + if str(buffer(buffer('asdf', 0, 2), 0)) != 'as': + self.fail('composing length-specified buffer failed') + if str(buffer(buffer('asdf', 0, 2), 0, 5000)) != 'as': + self.fail('composing length-specified buffer failed') + if str(buffer(buffer('asdf', 0, 2), 0, -1)) != 'as': + self.fail('composing length-specified buffer failed') + if str(buffer(buffer('asdf', 0, 2), 1, 2)) != 's': + self.fail('composing length-specified buffer failed') + + try: a[1] = 'g' + except TypeError: pass + else: self.fail("buffer assignment should raise TypeError") + + try: a[0:1] = 'g' + except TypeError: pass + else: self.fail("buffer slice assignment should raise TypeError") + + # array.array() returns an object that does not implement a char buffer, + # something which int() uses for conversion. + import array + try: int(buffer(array.array('c'))) + except TypeError: pass + else: self.fail("char buffer (at C level) not working") + +def test_main(): + run_unittest(TypesTests) + +if __name__ == '__main__': + test_main() Modified: python/branches/p3yk/Lib/test/test_unicode.py ============================================================================== --- python/branches/p3yk/Lib/test/test_unicode.py (original) +++ python/branches/p3yk/Lib/test/test_unicode.py Wed Dec 13 05:49:30 2006 @@ -92,6 +92,9 @@ "\\xfe\\xff'") testrepr = repr(u''.join(map(unichr, xrange(256)))) self.assertEqual(testrepr, latin1repr) + # Test repr works on wide unicode escapes without overflow. + self.assertEqual(repr(u"\U00010000" * 39 + u"\uffff" * 4096), + repr(u"\U00010000" * 39 + u"\uffff" * 4096)) def test_iterators(self): # Make sure unicode objects have an __iter__ method Modified: python/branches/p3yk/Lib/test/test_xdrlib.py ============================================================================== --- python/branches/p3yk/Lib/test/test_xdrlib.py (original) +++ python/branches/p3yk/Lib/test/test_xdrlib.py Wed Dec 13 05:49:30 2006 @@ -1,3 +1,56 @@ +from test import test_support +import unittest + import xdrlib -xdrlib._test() +class XDRTest(unittest.TestCase): + + def test_xdr(self): + p = xdrlib.Packer() + + s = 'hello world' + a = ['what', 'is', 'hapnin', 'doctor'] + + p.pack_int(42) + p.pack_uint(9) + p.pack_bool(True) + p.pack_bool(False) + p.pack_uhyper(45L) + p.pack_float(1.9) + p.pack_double(1.9) + p.pack_string(s) + p.pack_list(range(5), p.pack_uint) + p.pack_array(a, p.pack_string) + + # now verify + data = p.get_buffer() + up = xdrlib.Unpacker(data) + + self.assertEqual(up.get_position(), 0) + + self.assertEqual(up.unpack_int(), 42) + self.assertEqual(up.unpack_uint(), 9) + self.assert_(up.unpack_bool() is True) + + # remember position + pos = up.get_position() + self.assert_(up.unpack_bool() is False) + + # rewind and unpack again + up.set_position(pos) + self.assert_(up.unpack_bool() is False) + + self.assertEqual(up.unpack_uhyper(), 45L) + self.assertAlmostEqual(up.unpack_float(), 1.9) + self.assertAlmostEqual(up.unpack_double(), 1.9) + self.assertEqual(up.unpack_string(), s) + self.assertEqual(up.unpack_list(up.unpack_uint), range(5)) + self.assertEqual(up.unpack_array(up.unpack_string), a) + up.done() + self.assertRaises(EOFError, up.unpack_uint) + +def test_main(): + test_support.run_unittest(XDRTest) + +if __name__ == "__main__": + test_main() Modified: python/branches/p3yk/Lib/test/test_xmlrpc.py ============================================================================== --- python/branches/p3yk/Lib/test/test_xmlrpc.py (original) +++ python/branches/p3yk/Lib/test/test_xmlrpc.py Wed Dec 13 05:49:30 2006 @@ -86,6 +86,15 @@ s = xmlrpclib.dumps((new_d,), methodresponse=True) self.assert_(isinstance(s, str)) + def test_newstyle_class(self): + class T(object): + pass + t = T() + t.x = 100 + t.y = "Hello" + ((t2,), dummy) = xmlrpclib.loads(xmlrpclib.dumps((t,))) + self.assertEquals(t2, t.__dict__) + def test_dump_big_long(self): self.assertRaises(OverflowError, xmlrpclib.dumps, (2L**99,)) Modified: python/branches/p3yk/Lib/tokenize.py ============================================================================== --- python/branches/p3yk/Lib/tokenize.py (original) +++ python/branches/p3yk/Lib/tokenize.py Wed Dec 13 05:49:30 2006 @@ -24,7 +24,7 @@ __author__ = 'Ka-Ping Yee ' __credits__ = \ - 'GvR, ESR, Tim Peters, Thomas Wouters, Fred Drake, Skip Montanaro' + 'GvR, ESR, Tim Peters, Thomas Wouters, Fred Drake, Skip Montanaro, Raymond Hettinger' import string, re from token import * @@ -159,14 +159,73 @@ for token_info in generate_tokens(readline): tokeneater(*token_info) +class Untokenizer: + + def __init__(self): + self.tokens = [] + self.prev_row = 1 + self.prev_col = 0 + + def add_whitespace(self, start): + row, col = start + assert row <= self.prev_row + col_offset = col - self.prev_col + if col_offset: + self.tokens.append(" " * col_offset) + + def untokenize(self, iterable): + for t in iterable: + if len(t) == 2: + self.compat(t, iterable) + break + tok_type, token, start, end, line = t + self.add_whitespace(start) + self.tokens.append(token) + self.prev_row, self.prev_col = end + if tok_type in (NEWLINE, NL): + self.prev_row += 1 + self.prev_col = 0 + return "".join(self.tokens) + + def compat(self, token, iterable): + startline = False + indents = [] + toks_append = self.tokens.append + toknum, tokval = token + if toknum in (NAME, NUMBER): + tokval += ' ' + if toknum in (NEWLINE, NL): + startline = True + for tok in iterable: + toknum, tokval = tok[:2] + + if toknum in (NAME, NUMBER): + tokval += ' ' + + if toknum == INDENT: + indents.append(tokval) + continue + elif toknum == DEDENT: + indents.pop() + continue + elif toknum in (NEWLINE, NL): + startline = True + elif startline and indents: + toks_append(indents[-1]) + startline = False + toks_append(tokval) def untokenize(iterable): """Transform tokens back into Python source code. Each element returned by the iterable must be a token sequence - with at least two elements, a token number and token value. + with at least two elements, a token number and token value. If + only two tokens are passed, the resulting output is poor. + + Round-trip invariant for full input: + Untokenized source will match input source exactly - Round-trip invariant: + Round-trip invariant for limited intput: # Output text will tokenize the back to the input t1 = [tok[:2] for tok in generate_tokens(f.readline)] newcode = untokenize(t1) @@ -174,31 +233,8 @@ t2 = [tok[:2] for tokin generate_tokens(readline)] assert t1 == t2 """ - - startline = False - indents = [] - toks = [] - toks_append = toks.append - for tok in iterable: - toknum, tokval = tok[:2] - - if toknum in (NAME, NUMBER): - tokval += ' ' - - if toknum == INDENT: - indents.append(tokval) - continue - elif toknum == DEDENT: - indents.pop() - continue - elif toknum in (NEWLINE, COMMENT, NL): - startline = True - elif startline and indents: - toks_append(indents[-1]) - startline = False - toks_append(tokval) - return ''.join(toks) - + ut = Untokenizer() + return ut.untokenize(iterable) def generate_tokens(readline): """ @@ -237,7 +273,7 @@ if endmatch: pos = end = endmatch.end(0) yield (STRING, contstr + line[:end], - strstart, (lnum, end), contline + line) + strstart, (lnum, end), contline + line) contstr, needcont = '', 0 contline = None elif needcont and line[-2:] != '\\\n' and line[-3:] != '\\\r\n': @@ -263,7 +299,15 @@ if pos == max: break if line[pos] in '#\r\n': # skip comments or blank lines - yield ((NL, COMMENT)[line[pos] == '#'], line[pos:], + if line[pos] == '#': + comment_token = line[pos:].rstrip('\r\n') + nl_pos = pos + len(comment_token) + yield (COMMENT, comment_token, + (lnum, pos), (lnum, pos + len(comment_token)), line) + yield (NL, line[nl_pos:], + (lnum, nl_pos), (lnum, len(line)), line) + else: + yield ((NL, COMMENT)[line[pos] == '#'], line[pos:], (lnum, pos), (lnum, len(line)), line) continue @@ -294,9 +338,10 @@ (initial == '.' and token != '.'): # ordinary number yield (NUMBER, token, spos, epos, line) elif initial in '\r\n': - yield (parenlev > 0 and NL or NEWLINE, - token, spos, epos, line) + yield (NL if parenlev > 0 else NEWLINE, + token, spos, epos, line) elif initial == '#': + assert not token.endswith("\n") yield (COMMENT, token, spos, epos, line) elif token in triple_quoted: endprog = endprogs[token] Modified: python/branches/p3yk/Lib/traceback.py ============================================================================== --- python/branches/p3yk/Lib/traceback.py (original) +++ python/branches/p3yk/Lib/traceback.py Wed Dec 13 05:49:30 2006 @@ -162,6 +162,11 @@ """ + # Gracefully handle (the way Python 2.4 and earlier did) the case of + # being called with (None, None). + if etype is None: + return [_format_final_exc_line(etype, value)] + stype = etype.__name__ smod = etype.__module__ if smod not in ("exceptions", "__main__", "__builtin__"): Modified: python/branches/p3yk/Lib/urllib.py ============================================================================== --- python/branches/p3yk/Lib/urllib.py (original) +++ python/branches/p3yk/Lib/urllib.py Wed Dec 13 05:49:30 2006 @@ -302,13 +302,13 @@ if proxy_passwd: import base64 - proxy_auth = base64.encodestring(proxy_passwd).strip() + proxy_auth = base64.b64encode(proxy_passwd).strip() else: proxy_auth = None if user_passwd: import base64 - auth = base64.encodestring(user_passwd).strip() + auth = base64.b64encode(user_passwd).strip() else: auth = None h = httplib.HTTP(host) @@ -387,12 +387,12 @@ if not host: raise IOError, ('https error', 'no host given') if proxy_passwd: import base64 - proxy_auth = base64.encodestring(proxy_passwd).strip() + proxy_auth = base64.b64encode(proxy_passwd).strip() else: proxy_auth = None if user_passwd: import base64 - auth = base64.encodestring(user_passwd).strip() + auth = base64.b64encode(user_passwd).strip() else: auth = None h = httplib.HTTPS(host, 0, Modified: python/branches/p3yk/Lib/urllib2.py ============================================================================== --- python/branches/p3yk/Lib/urllib2.py (original) +++ python/branches/p3yk/Lib/urllib2.py Wed Dec 13 05:49:30 2006 @@ -674,7 +674,7 @@ proxy_type = orig_type if user and password: user_pass = '%s:%s' % (unquote(user), unquote(password)) - creds = base64.encodestring(user_pass).strip() + creds = base64.b64encode(user_pass).strip() req.add_header('Proxy-authorization', 'Basic ' + creds) hostport = unquote(hostport) req.set_proxy(hostport, proxy_type) @@ -798,7 +798,7 @@ user, pw = self.passwd.find_user_password(realm, host) if pw is not None: raw = "%s:%s" % (user, pw) - auth = 'Basic %s' % base64.encodestring(raw).strip() + auth = 'Basic %s' % base64.b64encode(raw).strip() if req.headers.get(self.auth_header, None) == auth: return None req.add_header(self.auth_header, auth) Modified: python/branches/p3yk/Lib/uu.py ============================================================================== --- python/branches/p3yk/Lib/uu.py (original) +++ python/branches/p3yk/Lib/uu.py Wed Dec 13 05:49:30 2006 @@ -114,6 +114,7 @@ # # Open the output file # + opened = False if out_file == '-': out_file = sys.stdout elif isinstance(out_file, basestring): @@ -123,6 +124,7 @@ except AttributeError: pass out_file = fp + opened = True # # Main decoding loop # @@ -140,6 +142,8 @@ s = in_file.readline() if not s: raise Error('Truncated input file') + if opened: + out_file.close() def test(): """uuencode/uudecode main program""" Modified: python/branches/p3yk/Lib/webbrowser.py ============================================================================== --- python/branches/p3yk/Lib/webbrowser.py (original) +++ python/branches/p3yk/Lib/webbrowser.py Wed Dec 13 05:49:30 2006 @@ -165,7 +165,10 @@ cmdline = [self.name] + [arg.replace("%s", url) for arg in self.args] try: - p = subprocess.Popen(cmdline, close_fds=True) + if sys.platform[:3] == 'win': + p = subprocess.Popen(cmdline) + else: + p = subprocess.Popen(cmdline, close_fds=True) return not p.wait() except OSError: return False @@ -178,11 +181,14 @@ def open(self, url, new=0, autoraise=1): cmdline = [self.name] + [arg.replace("%s", url) for arg in self.args] - setsid = getattr(os, 'setsid', None) - if not setsid: - setsid = getattr(os, 'setpgrp', None) try: - p = subprocess.Popen(cmdline, close_fds=True, preexec_fn=setsid) + if sys.platform[:3] == 'win': + p = subprocess.Popen(cmdline) + else: + setsid = getattr(os, 'setsid', None) + if not setsid: + setsid = getattr(os, 'setpgrp', None) + p = subprocess.Popen(cmdline, close_fds=True, preexec_fn=setsid) return (p.poll() is None) except OSError: return False @@ -441,7 +447,7 @@ # if successful, register it if retncode is None and commd: - register("gnome", None, BackgroundBrowser(commd)) + register("gnome", None, BackgroundBrowser(commd.split())) # First, the Mozilla/Netscape browsers for browser in ("mozilla-firefox", "firefox", Modified: python/branches/p3yk/Lib/xdrlib.py ============================================================================== --- python/branches/p3yk/Lib/xdrlib.py (original) +++ python/branches/p3yk/Lib/xdrlib.py Wed Dec 13 05:49:30 2006 @@ -227,61 +227,3 @@ def unpack_array(self, unpack_item): n = self.unpack_uint() return self.unpack_farray(n, unpack_item) - - -# test suite -def _test(): - p = Packer() - packtest = [ - (p.pack_uint, (9,)), - (p.pack_bool, (True,)), - (p.pack_bool, (False,)), - (p.pack_uhyper, (45L,)), - (p.pack_float, (1.9,)), - (p.pack_double, (1.9,)), - (p.pack_string, ('hello world',)), - (p.pack_list, (range(5), p.pack_uint)), - (p.pack_array, (['what', 'is', 'hapnin', 'doctor'], p.pack_string)), - ] - succeedlist = [1] * len(packtest) - count = 0 - for method, args in packtest: - print 'pack test', count, - try: - method(*args) - print 'succeeded' - except ConversionError, var: - print 'ConversionError:', var.msg - succeedlist[count] = 0 - count = count + 1 - data = p.get_buffer() - # now verify - up = Unpacker(data) - unpacktest = [ - (up.unpack_uint, (), lambda x: x == 9), - (up.unpack_bool, (), lambda x: x is True), - (up.unpack_bool, (), lambda x: x is False), - (up.unpack_uhyper, (), lambda x: x == 45L), - (up.unpack_float, (), lambda x: 1.89 < x < 1.91), - (up.unpack_double, (), lambda x: 1.89 < x < 1.91), - (up.unpack_string, (), lambda x: x == 'hello world'), - (up.unpack_list, (up.unpack_uint,), lambda x: x == range(5)), - (up.unpack_array, (up.unpack_string,), - lambda x: x == ['what', 'is', 'hapnin', 'doctor']), - ] - count = 0 - for method, args, pred in unpacktest: - print 'unpack test', count, - try: - if succeedlist[count]: - x = method(*args) - print pred(x) and 'succeeded' or 'failed', ':', x - else: - print 'skipping' - except ConversionError, var: - print 'ConversionError:', var.msg - count = count + 1 - - -if __name__ == '__main__': - _test() Modified: python/branches/p3yk/Lib/xmlrpclib.py ============================================================================== --- python/branches/p3yk/Lib/xmlrpclib.py (original) +++ python/branches/p3yk/Lib/xmlrpclib.py Wed Dec 13 05:49:30 2006 @@ -593,9 +593,21 @@ try: f = self.dispatch[type(value)] except KeyError: - raise TypeError, "cannot marshal %s objects" % type(value) - else: - f(self, value, write) + # check if this object can be marshalled as a structure + try: + value.__dict__ + except: + raise TypeError, "cannot marshal %s objects" % type(value) + # check if this class is a sub-class of a basic type, + # because we don't know how to marshal these types + # (e.g. a string sub-class) + for type_ in type(value).__mro__: + if type_ in self.dispatch.keys(): + raise TypeError, "cannot marshal %s objects" % type(value) + # XXX(twouters): using "_arbitrary_instance" as key as a quick-fix + # for the p3yk merge, this should probably be fixed more neatly. + f = self.dispatch["_arbitrary_instance"] + f(self, value, write) def dump_nil (self, value, write): if not self.allow_none: @@ -713,6 +725,9 @@ self.dump_struct(value.__dict__, write) dispatch[DateTime] = dump_instance dispatch[Binary] = dump_instance + # XXX(twouters): using "_arbitrary_instance" as key as a quick-fix + # for the p3yk merge, this should probably be fixed more neatly. + dispatch["_arbitrary_instance"] = dump_instance ## # XML-RPC unmarshaller. Modified: python/branches/p3yk/Mac/BuildScript/build-installer.py ============================================================================== --- python/branches/p3yk/Mac/BuildScript/build-installer.py (original) +++ python/branches/p3yk/Mac/BuildScript/build-installer.py Wed Dec 13 05:49:30 2006 @@ -10,9 +10,10 @@ Usage: see USAGE variable in the script. """ import platform, os, sys, getopt, textwrap, shutil, urllib2, stat, time, pwd +import grp -INCLUDE_TIMESTAMP=1 -VERBOSE=1 +INCLUDE_TIMESTAMP = 1 +VERBOSE = 1 from plistlib import Plist @@ -32,7 +33,7 @@ def shellQuote(value): """ - Return the string value in a form that can savely be inserted into + Return the string value in a form that can safely be inserted into a shell command. """ return "'%s'"%(value.replace("'", "'\"'\"'")) @@ -55,28 +56,28 @@ raise RuntimeError, "Cannot find full version??" -# The directory we'll use to create the build, will be erased and recreated -WORKDIR="/tmp/_py" +# The directory we'll use to create the build (will be erased and recreated) +WORKDIR = "/tmp/_py" -# The directory we'll use to store third-party sources, set this to something +# The directory we'll use to store third-party sources. Set this to something # else if you don't want to re-fetch required libraries every time. -DEPSRC=os.path.join(WORKDIR, 'third-party') -DEPSRC=os.path.expanduser('~/Universal/other-sources') +DEPSRC = os.path.join(WORKDIR, 'third-party') +DEPSRC = os.path.expanduser('~/Universal/other-sources') # Location of the preferred SDK -SDKPATH="/Developer/SDKs/MacOSX10.4u.sdk" -#SDKPATH="/" +SDKPATH = "/Developer/SDKs/MacOSX10.4u.sdk" +#SDKPATH = "/" -ARCHLIST=('i386', 'ppc',) +ARCHLIST = ('i386', 'ppc',) # Source directory (asume we're in Mac/BuildScript) -SRCDIR=os.path.dirname( +SRCDIR = os.path.dirname( os.path.dirname( os.path.dirname( os.path.abspath(__file__ )))) -USAGE=textwrap.dedent("""\ +USAGE = textwrap.dedent("""\ Usage: build_python [options] Options: @@ -91,7 +92,7 @@ # Instructions for building libraries that are necessary for building a # batteries included python. -LIBRARY_RECIPES=[ +LIBRARY_RECIPES = [ dict( name="Bzip2 1.0.3", url="http://www.bzip.org/1.0.3/bzip2-1.0.3.tar.gz", @@ -183,7 +184,7 @@ # Instructions for building packages inside the .mpkg. -PKG_RECIPES=[ +PKG_RECIPES = [ dict( name="PythonFramework", long_name="Python Framework", @@ -200,7 +201,7 @@ long_name="GUI Applications", source="/Applications/MacPython %(VER)s", readme="""\ - This package installs IDLE (an interactive Python IDLE), + This package installs IDLE (an interactive Python IDE), Python Launcher and Build Applet (create application bundles from python scripts). @@ -256,8 +257,7 @@ readme="""\ This package updates the system python installation on Mac OS X 10.3 to ensure that you can build new python extensions - using that copy of python after installing this version of - python. + using that copy of python after installing this version. """, postflight="../Tools/fixapplepython23.py", topdir="/Library/Frameworks/Python.framework", @@ -323,7 +323,7 @@ -def parseOptions(args = None): +def parseOptions(args=None): """ Parse arguments and update global settings. """ @@ -636,15 +636,15 @@ print "Running make" runCommand("make") - print "Runing make frameworkinstall" + print "Running make frameworkinstall" runCommand("make frameworkinstall DESTDIR=%s"%( shellQuote(rootDir))) - print "Runing make frameworkinstallextras" + print "Running make frameworkinstallextras" runCommand("make frameworkinstallextras DESTDIR=%s"%( shellQuote(rootDir))) - print "Copy required shared libraries" + print "Copying required shared libraries" if os.path.exists(os.path.join(WORKDIR, 'libraries', 'Library')): runCommand("mv %s/* %s"%( shellQuote(os.path.join( @@ -657,9 +657,13 @@ print "Fix file modes" frmDir = os.path.join(rootDir, 'Library', 'Frameworks', 'Python.framework') + gid = grp.getgrnam('admin').gr_gid + for dirpath, dirnames, filenames in os.walk(frmDir): for dn in dirnames: os.chmod(os.path.join(dirpath, dn), 0775) + os.chown(os.path.join(dirpath, dn), -1, gid) + for fn in filenames: if os.path.islink(fn): @@ -668,7 +672,8 @@ # "chmod g+w $fn" p = os.path.join(dirpath, fn) st = os.stat(p) - os.chmod(p, stat.S_IMODE(st.st_mode) | stat.S_IXGRP) + os.chmod(p, stat.S_IMODE(st.st_mode) | stat.S_IWGRP) + os.chown(p, -1, gid) # We added some directories to the search path during the configure # phase. Remove those because those directories won't be there on @@ -729,8 +734,8 @@ def packageFromRecipe(targetDir, recipe): curdir = os.getcwd() try: - # The major version (such as 2.5) is included in the pacakge name - # because haveing two version of python installed at the same time is + # The major version (such as 2.5) is included in the package name + # because having two version of python installed at the same time is # common. pkgname = '%s-%s'%(recipe['name'], getVersion()) srcdir = recipe.get('source') @@ -904,7 +909,7 @@ def buildDMG(): """ - Create DMG containing the rootDir + Create DMG containing the rootDir. """ outdir = os.path.join(WORKDIR, 'diskimage') if os.path.exists(outdir): @@ -917,7 +922,7 @@ imagepath = imagepath + '.dmg' os.mkdir(outdir) - runCommand("hdiutil create -volname 'Univeral MacPython %s' -srcfolder %s %s"%( + runCommand("hdiutil create -volname 'Universal MacPython %s' -srcfolder %s %s"%( getFullVersion(), shellQuote(os.path.join(WORKDIR, 'installer')), shellQuote(imagepath))) @@ -945,6 +950,10 @@ ref, isDirectory = Carbon.File.FSPathMakeRef(filePath) if isDirectory: + # There is a problem with getting this into the pax(1) archive, + # just ignore directory icons for now. + return + tmpPath = os.path.join(filePath, "Icon\r") if not os.path.exists(tmpPath): fp = open(tmpPath, 'w') Modified: python/branches/p3yk/Mac/BuildScript/scripts/postflight.documentation ============================================================================== --- python/branches/p3yk/Mac/BuildScript/scripts/postflight.documentation (original) +++ python/branches/p3yk/Mac/BuildScript/scripts/postflight.documentation Wed Dec 13 05:49:30 2006 @@ -1,6 +1,5 @@ #!/bin/sh -# FIXME PYVER="@PYVER@" if [ -d /Developer/Documentation ]; then @@ -8,5 +7,5 @@ mkdir -p /Developer/Documentation/Python fi - ln -fhs /Library/Frameworks/Python.framework/Versions/${PYVER}/Resources/English.lproj/Documentation "/Developer/Documentation/Python/Reference Documentation" + ln -fhs /Library/Frameworks/Python.framework/Versions/${PYVER}/Resources/English.lproj/Documentation "/Developer/Documentation/Python/Reference Documentation @PYVER@" fi Modified: python/branches/p3yk/Mac/BuildScript/scripts/postflight.patch-profile ============================================================================== --- python/branches/p3yk/Mac/BuildScript/scripts/postflight.patch-profile (original) +++ python/branches/p3yk/Mac/BuildScript/scripts/postflight.patch-profile Wed Dec 13 05:49:30 2006 @@ -47,22 +47,29 @@ echo "${PYTHON_ROOT}/bin is not on your PATH or at least not early enough" case "${BSH}" in *csh) + if [ -f "${HOME}/.tcshrc" ]; then + RC="${HOME}/.tcshrc" + else + RC="${HOME}/.cshrc" + fi # Create backup copy before patching - if [ -f "${HOME}/.cshrc" ]; then - cp -fp "${HOME}/.cshrc" "${HOME}/.cshrc.pysave" + if [ -f "${RC}" ]; then + cp -fp "${RC}" "${RC}.pysave" fi - echo "" >> "${HOME}/.cshrc" - echo "# Setting PATH for MacPython ${PYVER}" >> "${HOME}/.cshrc" - echo "# The orginal version is saved in .cshrc.pysave" >> "${HOME}/.cshrc" - echo "set path=(${PYTHON_ROOT}/bin "'$path'")" >> "${HOME}/.cshrc" + echo "" >> "${RC}" + echo "# Setting PATH for MacPython ${PYVER}" >> "${RC}" + echo "# The orginal version is saved in .cshrc.pysave" >> "${RC}" + echo "set path=(${PYTHON_ROOT}/bin "'$path'")" >> "${RC}" if [ `id -ur` = 0 ]; then - chown "${USER}" "${HOME}/.cshrc" + chown "${USER}" "${RC}" fi exit 0 ;; bash) if [ -e "${HOME}/.bash_profile" ]; then PR="${HOME}/.bash_profile" + elif [ -e "${HOME}/.bash_login" ]; then + PR="${HOME}/.bash_login" elif [ -e "${HOME}/.profile" ]; then PR="${HOME}/.profile" else Modified: python/branches/p3yk/Mac/Makefile.in ============================================================================== --- python/branches/p3yk/Mac/Makefile.in (original) +++ python/branches/p3yk/Mac/Makefile.in Wed Dec 13 05:49:30 2006 @@ -101,7 +101,7 @@ fi -pythonw: $(srcdir)/Tools/pythonw.c +pythonw: $(srcdir)/Tools/pythonw.c Makefile $(CC) $(LDFLAGS) -o $@ $(srcdir)/Tools/pythonw.c \ -DPYTHONWEXECUTABLE='"$(APPINSTALLDIR)/Contents/MacOS/Python"' @@ -249,3 +249,6 @@ rm pythonw cd PythonLauncher && make clean cd IDLE && make clean + +Makefile: $(srcdir)/Makefile.in ../config.status + cd .. && CONFIG_FILES=Mac/Makefile CONFIG_HEADERS= $(SHELL) ./config.status Modified: python/branches/p3yk/Mac/PythonLauncher/FileSettings.m ============================================================================== --- python/branches/p3yk/Mac/PythonLauncher/FileSettings.m (original) +++ python/branches/p3yk/Mac/PythonLauncher/FileSettings.m Wed Dec 13 05:49:30 2006 @@ -207,7 +207,7 @@ [NSNumber numberWithBool: inspect], @"inspect", [NSNumber numberWithBool: optimize], @"optimize", [NSNumber numberWithBool: nosite], @"nosite", - [NSNumber numberWithBool: nosite], @"nosite", + [NSNumber numberWithBool: tabs], @"tabs", others, @"others", scriptargs, @"scriptargs", [NSNumber numberWithBool: with_terminal], @"with_terminal", @@ -235,7 +235,7 @@ if (value) optimize = [value boolValue]; value = [dict objectForKey: @"nosite"]; if (value) nosite = [value boolValue]; - value = [dict objectForKey: @"nosite"]; + value = [dict objectForKey: @"tabs"]; if (value) tabs = [value boolValue]; value = [dict objectForKey: @"others"]; if (value) others = [value retain]; @@ -291,7 +291,7 @@ tabs?" -t":"", others, [self _replaceSingleQuotes:script], - scriptargs, + scriptargs ? scriptargs : @"", with_terminal? "&& echo Exit status: $? && exit 1" : " &"]; } Modified: python/branches/p3yk/Mac/README ============================================================================== --- python/branches/p3yk/Mac/README (original) +++ python/branches/p3yk/Mac/README Wed Dec 13 05:49:30 2006 @@ -48,7 +48,7 @@ A second reason for using frameworks is that they put Python-related items in only two places: "/Library/Framework/Python.framework" and -"/Applications/MacPython 2.5". This simplifies matters for users installing +"/Applications/MacPython 2.6". This simplifies matters for users installing Python from a binary distribution if they want to get rid of it again. Moreover, due to the way frameworks work a user without admin privileges can install a binary distribution in his or her home directory without recompilation. @@ -75,7 +75,7 @@ This directory contains a Makefile that will create a couple of python-related applications (fullblown OSX .app applications, that is) in -"/Applications/MacPython 2.3", and a hidden helper application Python.app +"/Applications/MacPython 2.6", and a hidden helper application Python.app inside the Python.framework, and unix tools "python" and "pythonw" into /usr/local/bin. In addition it has a target "installmacsubtree" that installs the relevant portions of the Mac subtree into the Python.framework. @@ -90,20 +90,16 @@ 3. make install This sequence will put the framework in /Library/Framework/Python.framework, -the applications in /Applications/MacPython 2.5 and the unix tools in +the applications in "/Applications/MacPython 2.6" and the unix tools in /usr/local/bin. Installing in another place, for instance $HOME/Library/Frameworks if you have no admin privileges on your machine, has only been tested very lightly. This can be done by configuring with --enable-framework=$HOME/Library/Frameworks. -The other two directories, /Applications/MacPython-2.3 and /usr/local/bin, will -then also be deposited in $HOME. This is sub-optimal for the unix tools, which -you would want in $HOME/bin, but there is no easy way to fix this right now. - -Note that there are no references to the actual locations in the code or -resource files, so you are free to move things around afterwards. For example, -you could use --enable-framework=/tmp/newversion/Library/Frameworks and use -/tmp/newversion as the basis for an installer or something. +The other two directories, "/Applications/MacPython-2.6" and /usr/local/bin, +will then also be deposited in $HOME. This is sub-optimal for the unix tools, +which you would want in $HOME/bin, but there is no easy way to fix this right +now. If you want to install some part, but not all, read the main Makefile. The frameworkinstall is composed of a couple of sub-targets that install the @@ -111,7 +107,7 @@ There is an extra target frameworkinstallextras that is not part of the normal frameworkinstall which installs the Demo and Tools directories -into /Applications/MacPython-2.3, this is useful for binary distributions. +into "/Applications/MacPython 2.6", this is useful for binary distributions. What do all these programs do? =============================== Modified: python/branches/p3yk/Mac/Tools/fixapplepython23.py ============================================================================== --- python/branches/p3yk/Mac/Tools/fixapplepython23.py (original) +++ python/branches/p3yk/Mac/Tools/fixapplepython23.py Wed Dec 13 05:49:30 2006 @@ -123,7 +123,8 @@ makescript(GXX_SCRIPT, "g++") # Finally fix the makefile rv = fix(MAKEFILE, do_apply) - sys.exit(rv) + #sys.exit(rv) + sys.exit(0) if __name__ == '__main__': main() Modified: python/branches/p3yk/Makefile.pre.in ============================================================================== --- python/branches/p3yk/Makefile.pre.in (original) +++ python/branches/p3yk/Makefile.pre.in Wed Dec 13 05:49:30 2006 @@ -346,7 +346,7 @@ # Build the shared modules sharedmods: $(BUILDPYTHON) - case $$MAKEFLAGS in \ + @case $$MAKEFLAGS in \ *-s*) $(RUNSHARED) CC='$(CC)' LDSHARED='$(BLDSHARED)' OPT='$(OPT)' ./$(BUILDPYTHON) -E $(srcdir)/setup.py -q build;; \ *) $(RUNSHARED) CC='$(CC)' LDSHARED='$(BLDSHARED)' OPT='$(OPT)' ./$(BUILDPYTHON) -E $(srcdir)/setup.py build;; \ esac @@ -457,7 +457,7 @@ $(SIGNAL_OBJS) \ $(MODOBJS) \ $(srcdir)/Modules/getbuildinfo.c - $(CC) -c $(PY_CFLAGS) -DSVNVERSION=\"`LANG=C $(SVNVERSION)`\" -o $@ $(srcdir)/Modules/getbuildinfo.c + $(CC) -c $(PY_CFLAGS) -DSVNVERSION=\"`LC_ALL=C $(SVNVERSION)`\" -o $@ $(srcdir)/Modules/getbuildinfo.c Modules/getpath.o: $(srcdir)/Modules/getpath.c Makefile $(CC) -c $(PY_CFLAGS) -DPYTHONPATH='"$(PYTHONPATH)"' \ Modified: python/branches/p3yk/Misc/ACKS ============================================================================== --- python/branches/p3yk/Misc/ACKS (original) +++ python/branches/p3yk/Misc/ACKS Wed Dec 13 05:49:30 2006 @@ -242,6 +242,7 @@ Michael Guravage Lars Gust?bel Barry Haddow +V?clav Haisman Paul ten Hagen Rasmus Hahn Peter Haight @@ -365,6 +366,7 @@ Soren Larsen Piers Lauder Ben Laurie +Simon Law Chris Lawrence Christopher Lee Inyeol Lee @@ -611,6 +613,7 @@ Christian Tanzer Steven Taschuk Amy Taylor +Monty Taylor Tobias Thelen Robin Thomas Eric Tiedemann @@ -631,6 +634,7 @@ Bill Tutt Doobee R. Tzeck Lionel Ulmer +Roger Upole Michael Urman Hector Urtubia Dmitry Vasiliev Modified: python/branches/p3yk/Misc/HISTORY ============================================================================== --- python/branches/p3yk/Misc/HISTORY (original) +++ python/branches/p3yk/Misc/HISTORY Wed Dec 13 05:49:30 2006 @@ -11679,7 +11679,7 @@ - The way GNU readline is configured is totally different. The --with-readline configure option is gone. It is now an extension module, which may be loaded dynamically. You must enable it (and -specify the correct linraries to link with) in the Modules/Setup file. +specify the correct libraries to link with) in the Modules/Setup file. Importing the module installs some hooks which enable command line editing. When the interpreter shell is invoked interactively, it attempts to import the readline module; when this fails, the default Modified: python/branches/p3yk/Misc/SpecialBuilds.txt ============================================================================== --- python/branches/p3yk/Misc/SpecialBuilds.txt (original) +++ python/branches/p3yk/Misc/SpecialBuilds.txt Wed Dec 13 05:49:30 2006 @@ -91,7 +91,7 @@ #define CLEANBYTE 0xCB /* clean (newly allocated) memory */ #define DEADBYTE 0xDB /* dead (newly freed) memory */ -#define FORBIDDENBYTE 0xFB /* fordidden -- untouchable bytes */ +#define FORBIDDENBYTE 0xFB /* forbidden -- untouchable bytes */ Strings of these bytes are unlikely to be valid addresses, floats, or 7-bit ASCII strings. Modified: python/branches/p3yk/Misc/Vim/python.vim ============================================================================== --- python/branches/p3yk/Misc/Vim/python.vim (original) +++ python/branches/p3yk/Misc/Vim/python.vim Wed Dec 13 05:49:30 2006 @@ -62,39 +62,39 @@ if exists("python_highlight_builtins") - syn keyword pythonBuiltin unichr all set abs vars int __import__ unicode - syn keyword pythonBuiltin enumerate exit issubclass - syn keyword pythonBuiltin divmod file Ellipsis isinstance open any - syn keyword pythonBuiltin locals help filter basestring slice copyright min - syn keyword pythonBuiltin super sum tuple hex execfile long id chr - syn keyword pythonBuiltin complex bool zip pow dict True oct NotImplemented - syn keyword pythonBuiltin map None float hash getattr buffer max reversed - syn keyword pythonBuiltin object quit len repr callable credits setattr - syn keyword pythonBuiltin eval frozenset sorted ord __debug__ hasattr - syn keyword pythonBuiltin delattr False license classmethod type - syn keyword pythonBuiltin list iter reload range globals - syn keyword pythonBuiltin staticmethod str property round dir cmp + syn keyword pythonBuiltin Ellipsis False None NotImplemented True __debug__ + syn keyword pythonBuiltin __import__ abs all any basestring bool + syn keyword pythonBuiltin buffer callable chr classmethod cmp + syn keyword pythonBuiltin complex copyright credits delattr dict + syn keyword pythonBuiltin dir divmod enumerate eval execfile exit file + syn keyword pythonBuiltin filter float frozenset getattr globals hasattr + syn keyword pythonBuiltin hash help hex id int isinstance + syn keyword pythonBuiltin issubclass iter len license list locals long map + syn keyword pythonBuiltin max min object oct open ord pow property quit + syn keyword pythonBuiltin range reload repr reversed round + syn keyword pythonBuiltin set setattr slice sorted staticmethod str sum + syn keyword pythonBuiltin super tuple type unichr unicode vars zip endif if exists("python_highlight_exceptions") - syn keyword pythonException GeneratorExit ImportError RuntimeError - syn keyword pythonException UnicodeTranslateError MemoryError StopIteration - syn keyword pythonException PendingDeprecationWarning EnvironmentError - syn keyword pythonException LookupError OSError DeprecationWarning - syn keyword pythonException UnicodeError UnicodeEncodeError - syn keyword pythonException FloatingPointError ReferenceError NameError - syn keyword pythonException IOError SyntaxError - syn keyword pythonException FutureWarning ImportWarning SystemExit - syn keyword pythonException Exception EOFError StandardError ValueError - syn keyword pythonException TabError KeyError ZeroDivisionError SystemError - syn keyword pythonException UnicodeDecodeError IndentationError - syn keyword pythonException AssertionError TypeError IndexError - syn keyword pythonException RuntimeWarning KeyboardInterrupt UserWarning - syn keyword pythonException SyntaxWarning UnboundLocalError ArithmeticError - syn keyword pythonException Warning NotImplementedError AttributeError - syn keyword pythonException OverflowError BaseException + syn keyword pythonException ArithmeticError AssertionError AttributeError + syn keyword pythonException BaseException DeprecationWarning EOFError + syn keyword pythonException EnvironmentError Exception FloatingPointError + syn keyword pythonException FutureWarning GeneratorExit IOError ImportError + syn keyword pythonException ImportWarning IndentationError IndexError + syn keyword pythonException KeyError KeyboardInterrupt LookupError + syn keyword pythonException MemoryError NameError NotImplementedError + syn keyword pythonException OSError OverflowError PendingDeprecationWarning + syn keyword pythonException ReferenceError RuntimeError RuntimeWarning + syn keyword pythonException StandardError StopIteration SyntaxError + syn keyword pythonException SyntaxWarning SystemError SystemExit TabError + syn keyword pythonException TypeError UnboundLocalError UnicodeDecodeError + syn keyword pythonException UnicodeEncodeError UnicodeError + syn keyword pythonException UnicodeTranslateError UnicodeWarning + syn keyword pythonException UserWarning ValueError Warning + syn keyword pythonException ZeroDivisionError endif Modified: python/branches/p3yk/Misc/Vim/vim_syntax.py ============================================================================== --- python/branches/p3yk/Misc/Vim/vim_syntax.py (original) +++ python/branches/p3yk/Misc/Vim/vim_syntax.py Wed Dec 13 05:49:30 2006 @@ -5,9 +5,9 @@ import __builtin__ from string import Template -comment_header = """" Auto-generated Vim syntax file for Python +comment_header = '''" Auto-generated Vim syntax file for Python. " -" To use: copy or symlink to ~/.vim/syntax/python.vim""" +" To use: copy or symlink to ~/.vim/syntax/python.vim''' statement_header = """ if exists("b:current_syntax") @@ -30,14 +30,14 @@ import_stmts = ('import', 'from') object_defs = ('def', 'class') -exception_names = frozenset(exc for exc in dir(exceptions) +exception_names = sorted(exc for exc in dir(exceptions) if not exc.startswith('__')) # Need to include functions that start with '__' (e.g., __import__), but # nothing that comes with modules (e.g., __name__), so just exclude anything in # the 'exceptions' module since we want to ignore exceptions *and* what any # module would have -builtin_names = frozenset(builtin for builtin in dir(__builtin__) +builtin_names = sorted(builtin for builtin in dir(__builtin__) if builtin not in dir(exceptions)) escapes = (r'+\\[abfnrtv\'"\\]+', r'"\\\o\{1,3}"', r'"\\x\x\{2}"', Modified: python/branches/p3yk/Misc/Vim/vimrc ============================================================================== --- python/branches/p3yk/Misc/Vim/vimrc (original) +++ python/branches/p3yk/Misc/Vim/vimrc Wed Dec 13 05:49:30 2006 @@ -21,7 +21,8 @@ " Python: 4 spaces " C: 4 spaces au BufRead,BufNewFile *.py,*pyw set shiftwidth=4 -au BufRead,BufNewFile *.c,*.h set shiftwidth=4 +au BufRead *.c,*.h set shiftwidth=8 +au BufNewFile *.c,*.h set shiftwidth=4 " Number of spaces that a pre-existing tab is equal to. " For the amount of space used for a new tab use shiftwidth. Modified: python/branches/p3yk/Modules/_bsddb.c ============================================================================== --- python/branches/p3yk/Modules/_bsddb.c (original) +++ python/branches/p3yk/Modules/_bsddb.c Wed Dec 13 05:49:30 2006 @@ -98,7 +98,7 @@ #error "eek! DBVER can't handle minor versions > 9" #endif -#define PY_BSDDB_VERSION "4.4.5" +#define PY_BSDDB_VERSION "4.4.6" static char *rcs_id = "$Id$"; @@ -1779,9 +1779,7 @@ return NULL; CHECK_DB_NOT_CLOSED(self); - MYDB_BEGIN_ALLOW_THREADS; type = _DB_get_type(self); - MYDB_END_ALLOW_THREADS; if (type == -1) return NULL; return PyInt_FromLong(type); @@ -2430,7 +2428,7 @@ #if (DBVER >= 43) PyObject* txnobj = NULL; DB_TXN *txn = NULL; - static char* kwnames[] = { "txn", "flags", NULL }; + static char* kwnames[] = { "flags", "txn", NULL }; #else static char* kwnames[] = { "flags", NULL }; #endif Modified: python/branches/p3yk/Modules/_ctypes/_ctypes.c ============================================================================== --- python/branches/p3yk/Modules/_ctypes/_ctypes.c (original) +++ python/branches/p3yk/Modules/_ctypes/_ctypes.c Wed Dec 13 05:49:30 2006 @@ -2589,16 +2589,22 @@ PPROC address; char *mangled_name; int i; - StgDictObject *dict = PyType_stgdict((PyObject *)type); + StgDictObject *dict; address = (PPROC)GetProcAddress(handle, name); +#ifdef _WIN64 + /* win64 has no stdcall calling conv, so it should + also not have the name mangling of it. + */ + return address; +#else if (address) return address; - if (((size_t)name & ~0xFFFF) == 0) { return NULL; } + dict = PyType_stgdict((PyObject *)type); /* It should not happen that dict is NULL, but better be safe */ if (dict==NULL || dict->flags & FUNCFLAG_CDECL) return address; @@ -2617,6 +2623,7 @@ return address; } return NULL; +#endif } #endif @@ -4588,11 +4595,11 @@ if (obj->b_objects == NULL) goto failed; } + Py_XINCREF(obj->b_objects); result->b_objects = obj->b_objects; - if (result->b_objects) { + if (result->b_objects && PyDict_Check(result->b_objects)) { PyObject *index; int rc; - Py_INCREF(obj->b_objects); index = PyLong_FromVoidPtr((void *)src); if (index == NULL) goto failed; Modified: python/branches/p3yk/Modules/_ctypes/_ctypes_test.c ============================================================================== --- python/branches/p3yk/Modules/_ctypes/_ctypes_test.c (original) +++ python/branches/p3yk/Modules/_ctypes/_ctypes_test.c Wed Dec 13 05:49:30 2006 @@ -25,6 +25,16 @@ /* some functions handy for testing */ +EXPORT(int)myprintf(char *fmt, ...) +{ + int result; + va_list argptr; + va_start(argptr, fmt); + result = vprintf(fmt, argptr); + va_end(argptr); + return result; +} + EXPORT(char *)my_strtok(char *token, const char *delim) { return strtok(token, delim); Modified: python/branches/p3yk/Modules/_ctypes/callbacks.c ============================================================================== --- python/branches/p3yk/Modules/_ctypes/callbacks.c (original) +++ python/branches/p3yk/Modules/_ctypes/callbacks.c Wed Dec 13 05:49:30 2006 @@ -294,14 +294,17 @@ p->restype = &ffi_type_void; } else { StgDictObject *dict = PyType_stgdict(restype); - if (dict == NULL) - goto error; + if (dict == NULL || dict->setfunc == NULL) { + PyErr_SetString(PyExc_TypeError, + "invalid result type for callback function"); + goto error; + } p->setfunc = dict->setfunc; p->restype = &dict->ffi_type_pointer; } cc = FFI_DEFAULT_ABI; -#if defined(MS_WIN32) && !defined(_WIN32_WCE) +#if defined(MS_WIN32) && !defined(_WIN32_WCE) && !defined(MS_WIN64) if (is_cdecl == 0) cc = FFI_STDCALL; #endif Modified: python/branches/p3yk/Modules/_ctypes/callproc.c ============================================================================== --- python/branches/p3yk/Modules/_ctypes/callproc.c (original) +++ python/branches/p3yk/Modules/_ctypes/callproc.c Wed Dec 13 05:49:30 2006 @@ -638,7 +638,7 @@ } cc = FFI_DEFAULT_ABI; -#if defined(MS_WIN32) && !defined(_WIN32_WCE) +#if defined(MS_WIN32) && !defined(MS_WIN64) && !defined(_WIN32_WCE) if ((flags & FUNCFLAG_CDECL) == 0) cc = FFI_STDCALL; #endif @@ -683,6 +683,14 @@ return -1; } #endif +#ifdef MS_WIN64 + if (delta != 0) { + PyErr_Format(PyExc_RuntimeError, + "ffi_call failed with code %d", + delta); + return -1; + } +#else if (delta < 0) { if (flags & FUNCFLAG_CDECL) PyErr_Format(PyExc_ValueError, @@ -704,6 +712,7 @@ return -1; } #endif +#endif if ((flags & FUNCFLAG_PYTHONAPI) && PyErr_Occurred()) return -1; return 0; @@ -979,7 +988,11 @@ } for (i = 0; i < argcount; ++i) { atypes[i] = args[i].ffi_type; - if (atypes[i]->type == FFI_TYPE_STRUCT) + if (atypes[i]->type == FFI_TYPE_STRUCT +#ifdef _WIN64 + && atypes[i]->size <= sizeof(void *) +#endif + ) avalues[i] = (void *)args[i].value.p; else avalues[i] = (void *)&args[i].value; @@ -1099,7 +1112,11 @@ hMod = LoadLibrary(name); if (!hMod) return PyErr_SetFromWindowsErr(GetLastError()); +#ifdef _WIN64 + return PyLong_FromVoidPtr(hMod); +#else return Py_BuildValue("i", hMod); +#endif } static char free_library_doc[] = @@ -1230,11 +1247,11 @@ static PyObject *py_dl_close(PyObject *self, PyObject *args) { - void * handle; + int handle; if (!PyArg_ParseTuple(args, "i:dlclose", &handle)) return NULL; - if (dlclose(handle)) { + if (dlclose((void*)handle)) { PyErr_SetString(PyExc_OSError, ctypes_dlerror()); return NULL; @@ -1246,12 +1263,12 @@ static PyObject *py_dl_sym(PyObject *self, PyObject *args) { char *name; - void *handle; + int handle; void *ptr; if (!PyArg_ParseTuple(args, "is:dlsym", &handle, &name)) return NULL; - ptr = ctypes_dlsym(handle, name); + ptr = ctypes_dlsym((void*)handle, name); if (!ptr) { PyErr_SetString(PyExc_OSError, ctypes_dlerror()); @@ -1269,7 +1286,7 @@ static PyObject * call_function(PyObject *self, PyObject *args) { - PPROC func; + int func; PyObject *arguments; PyObject *result; @@ -1279,7 +1296,7 @@ &PyTuple_Type, &arguments)) return NULL; - result = _CallProc(func, + result = _CallProc((PPROC)func, arguments, #ifdef MS_WIN32 NULL, @@ -1300,7 +1317,7 @@ static PyObject * call_cdeclfunction(PyObject *self, PyObject *args) { - PPROC func; + int func; PyObject *arguments; PyObject *result; @@ -1310,7 +1327,7 @@ &PyTuple_Type, &arguments)) return NULL; - result = _CallProc(func, + result = _CallProc((PPROC)func, arguments, #ifdef MS_WIN32 NULL, @@ -1493,7 +1510,7 @@ #else "On:resize", #endif - (PyObject *)&obj, &size)) + &obj, &size)) return NULL; dict = PyObject_stgdict((PyObject *)obj); Modified: python/branches/p3yk/Modules/_ctypes/cfield.c ============================================================================== --- python/branches/p3yk/Modules/_ctypes/cfield.c (original) +++ python/branches/p3yk/Modules/_ctypes/cfield.c Wed Dec 13 05:49:30 2006 @@ -1315,7 +1315,11 @@ *(char **)ptr = PyString_AS_STRING(str); return str; } else if (PyInt_Check(value) || PyLong_Check(value)) { +#if SIZEOF_VOID_P == SIZEOF_LONG_LONG + *(char **)ptr = (char *)PyInt_AsUnsignedLongLongMask(value); +#else *(char **)ptr = (char *)PyInt_AsUnsignedLongMask(value); +#endif _RET(value); } PyErr_Format(PyExc_TypeError, @@ -1360,7 +1364,11 @@ if (!value) return NULL; } else if (PyInt_Check(value) || PyLong_Check(value)) { +#if SIZEOF_VOID_P == SIZEOF_LONG_LONG + *(wchar_t **)ptr = (wchar_t *)PyInt_AsUnsignedLongLongMask(value); +#else *(wchar_t **)ptr = (wchar_t *)PyInt_AsUnsignedLongMask(value); +#endif Py_INCREF(Py_None); return Py_None; } else if (!PyUnicode_Check(value)) { Modified: python/branches/p3yk/Modules/_ctypes/libffi/src/powerpc/ffi_darwin.c ============================================================================== --- python/branches/p3yk/Modules/_ctypes/libffi/src/powerpc/ffi_darwin.c (original) +++ python/branches/p3yk/Modules/_ctypes/libffi/src/powerpc/ffi_darwin.c Wed Dec 13 05:49:30 2006 @@ -1,4 +1,4 @@ -#ifdef __ppc__ +#if !(defined(__APPLE__) && !defined(__ppc__)) /* ----------------------------------------------------------------------- ffi.c - Copyright (c) 1998 Geoffrey Keating Modified: python/branches/p3yk/Modules/_ctypes/libffi/src/x86/sysv.S ============================================================================== --- python/branches/p3yk/Modules/_ctypes/libffi/src/x86/sysv.S (original) +++ python/branches/p3yk/Modules/_ctypes/libffi/src/x86/sysv.S Wed Dec 13 05:49:30 2006 @@ -376,3 +376,7 @@ #endif #endif /* ifndef __x86_64__ */ + +#ifdef __ELF__ +.section .note.GNU-stack,"",%progbits +#endif Modified: python/branches/p3yk/Modules/_ctypes/libffi_msvc/ffi.c ============================================================================== --- python/branches/p3yk/Modules/_ctypes/libffi_msvc/ffi.c (original) +++ python/branches/p3yk/Modules/_ctypes/libffi_msvc/ffi.c Wed Dec 13 05:49:30 2006 @@ -34,6 +34,8 @@ /* ffi_prep_args is called by the assembly routine once stack space has been allocated for the function's arguments */ +extern void Py_FatalError(char *msg); + /*@-exportheader@*/ void ffi_prep_args(char *stack, extended_cif *ecif) /*@=exportheader@*/ @@ -44,11 +46,10 @@ register ffi_type **p_arg; argp = stack; - if (ecif->cif->rtype->type == FFI_TYPE_STRUCT) { *(void **) argp = ecif->rvalue; - argp += 4; + argp += sizeof(void *); } p_argv = ecif->avalue; @@ -60,8 +61,8 @@ size_t z; /* Align if necessary */ - if ((sizeof(int) - 1) & (unsigned) argp) - argp = (char *) ALIGN(argp, sizeof(int)); + if ((sizeof(void *) - 1) & (size_t) argp) + argp = (char *) ALIGN(argp, sizeof(void *)); z = (*p_arg)->size; if (z < sizeof(int)) @@ -108,7 +109,11 @@ p_argv++; argp += z; } - + + if (argp - stack > ecif->cif->bytes) + { + Py_FatalError("FFI BUG: not enough stack space for arguments"); + } return; } @@ -128,6 +133,9 @@ break; case FFI_TYPE_UINT64: +#ifdef _WIN64 + case FFI_TYPE_POINTER: +#endif cif->flags = FFI_TYPE_SINT64; break; @@ -139,6 +147,7 @@ return FFI_OK; } +#ifdef _WIN32 /*@-declundef@*/ /*@-exportheader@*/ extern int @@ -160,6 +169,16 @@ void (*fn)()); /*@=declundef@*/ /*@=exportheader@*/ +#endif + +#ifdef _WIN64 +extern int +ffi_call_AMD64(void (*)(char *, extended_cif *), + /*@out@*/ extended_cif *, + unsigned, unsigned, + /*@out@*/ unsigned *, + void (*fn)()); +#endif int ffi_call(/*@dependent@*/ ffi_cif *cif, @@ -188,6 +207,7 @@ switch (cif->abi) { +#if !defined(_WIN64) case FFI_SYSV: /*@-usedef@*/ return ffi_call_SYSV(ffi_prep_args, &ecif, cif->bytes, @@ -201,6 +221,14 @@ cif->flags, ecif.rvalue, fn); /*@=usedef@*/ break; +#else + case FFI_SYSV: + /*@-usedef@*/ + return ffi_call_AMD64(ffi_prep_args, &ecif, cif->bytes, + cif->flags, ecif.rvalue, fn); + /*@=usedef@*/ + break; +#endif default: FFI_ASSERT(0); @@ -213,10 +241,14 @@ /** private members **/ static void ffi_prep_incoming_args_SYSV (char *stack, void **ret, - void** args, ffi_cif* cif); + void** args, ffi_cif* cif); /* This function is jumped to by the trampoline */ +#ifdef _WIN64 +void * +#else static void __fastcall +#endif ffi_closure_SYSV (ffi_closure *closure, int *argp) { // this is our return value storage @@ -244,6 +276,7 @@ rtype = cif->flags; +#if defined(_WIN32) && !defined(_WIN64) #ifdef _MSC_VER /* now, do a generic return based on the value of rtype */ if (rtype == FFI_TYPE_INT) @@ -303,6 +336,15 @@ : "eax", "edx"); } #endif +#endif + +#ifdef _WIN64 + /* The result is returned in rax. This does the right thing for + result types except for floats; we have to 'mov xmm0, rax' in the + caller to correct this. + */ + return *(void **)resp; +#endif } /*@-exportheader@*/ @@ -330,8 +372,8 @@ size_t z; /* Align if necessary */ - if ((sizeof(int) - 1) & (unsigned) argp) { - argp = (char *) ALIGN(argp, sizeof(int)); + if ((sizeof(char *) - 1) & (size_t) argp) { + argp = (char *) ALIGN(argp, sizeof(char*)); } z = (*p_arg)->size; @@ -347,24 +389,8 @@ return; } -/* How to make a trampoline. Derived from gcc/config/i386/i386.c. */ - -#define FFI_INIT_TRAMPOLINE(TRAMP,FUN,CTX,BYTES) \ -{ unsigned char *__tramp = (unsigned char*)(TRAMP); \ - unsigned int __fun = (unsigned int)(FUN); \ - unsigned int __ctx = (unsigned int)(CTX); \ - unsigned int __dis = __fun - ((unsigned int) __tramp + 8 + 4); \ - *(unsigned char*) &__tramp[0] = 0xb9; \ - *(unsigned int*) &__tramp[1] = __ctx; /* mov ecx, __ctx */ \ - *(unsigned char*) &__tramp[5] = 0x8b; \ - *(unsigned char*) &__tramp[6] = 0xd4; /* mov edx, esp */ \ - *(unsigned char*) &__tramp[7] = 0xe8; \ - *(unsigned int*) &__tramp[8] = __dis; /* call __fun */ \ - *(unsigned char*) &__tramp[12] = 0xC2; /* ret BYTES */ \ - *(unsigned short*) &__tramp[13] = BYTES; \ - } - /* the cif must already be prep'ed */ +extern void ffi_closure_OUTER(); ffi_status ffi_prep_closure (ffi_closure* closure, @@ -373,19 +399,78 @@ void *user_data) { short bytes; + char *tramp; +#ifdef _WIN64 + int mask; +#endif FFI_ASSERT (cif->abi == FFI_SYSV); if (cif->abi == FFI_SYSV) bytes = 0; +#if !defined(_WIN64) else if (cif->abi == FFI_STDCALL) bytes = cif->bytes; +#endif else return FFI_BAD_ABI; - FFI_INIT_TRAMPOLINE (&closure->tramp[0], - &ffi_closure_SYSV, - (void*)closure, - bytes); + tramp = &closure->tramp[0]; + +#define BYTES(text) memcpy(tramp, text, sizeof(text)), tramp += sizeof(text)-1 +#define POINTER(x) *(void**)tramp = (void*)(x), tramp += sizeof(void*) +#define SHORT(x) *(short*)tramp = x, tramp += sizeof(short) +#define INT(x) *(int*)tramp = x, tramp += sizeof(int) + +#ifdef _WIN64 + if (cif->nargs >= 1 && + (cif->arg_types[0]->type == FFI_TYPE_FLOAT + || cif->arg_types[0]->type == FFI_TYPE_DOUBLE)) + mask |= 1; + if (cif->nargs >= 2 && + (cif->arg_types[1]->type == FFI_TYPE_FLOAT + || cif->arg_types[1]->type == FFI_TYPE_DOUBLE)) + mask |= 2; + if (cif->nargs >= 3 && + (cif->arg_types[2]->type == FFI_TYPE_FLOAT + || cif->arg_types[2]->type == FFI_TYPE_DOUBLE)) + mask |= 4; + if (cif->nargs >= 4 && + (cif->arg_types[3]->type == FFI_TYPE_FLOAT + || cif->arg_types[3]->type == FFI_TYPE_DOUBLE)) + mask |= 8; + + /* 41 BB ---- mov r11d,mask */ + BYTES("\x41\xBB"); INT(mask); + + /* 48 B8 -------- mov rax, closure */ + BYTES("\x48\xB8"); POINTER(closure); + + /* 49 BA -------- mov r10, ffi_closure_OUTER */ + BYTES("\x49\xBA"); POINTER(ffi_closure_OUTER); + + /* 41 FF E2 jmp r10 */ + BYTES("\x41\xFF\xE2"); + +#else + + /* mov ecx, closure */ + BYTES("\xb9"); POINTER(closure); + + /* mov edx, esp */ + BYTES("\x8b\xd4"); + + /* call ffi_closure_SYSV */ + BYTES("\xe8"); POINTER((char*)&ffi_closure_SYSV - (tramp + 4)); + + /* ret bytes */ + BYTES("\xc2"); + SHORT(bytes); + +#endif + + if (tramp - &closure->tramp[0] > FFI_TRAMPOLINE_SIZE) + Py_FatalError("FFI_TRAMPOLINE_SIZE too small in " __FILE__); + closure->cif = cif; closure->user_data = user_data; closure->fun = fun; Modified: python/branches/p3yk/Modules/_ctypes/libffi_msvc/ffi.h ============================================================================== --- python/branches/p3yk/Modules/_ctypes/libffi_msvc/ffi.h (original) +++ python/branches/p3yk/Modules/_ctypes/libffi_msvc/ffi.h Wed Dec 13 05:49:30 2006 @@ -174,12 +174,10 @@ /* ---- Definitions for the raw API -------------------------------------- */ -#ifndef FFI_SIZEOF_ARG -# if LONG_MAX == 2147483647 -# define FFI_SIZEOF_ARG 4 -# elif LONG_MAX == 9223372036854775807 -# define FFI_SIZEOF_ARG 8 -# endif +#ifdef _WIN64 +#define FFI_SIZEOF_ARG 8 +#else +#define FFI_SIZEOF_ARG 4 #endif typedef union { Modified: python/branches/p3yk/Modules/_ctypes/libffi_msvc/ffitarget.h ============================================================================== --- python/branches/p3yk/Modules/_ctypes/libffi_msvc/ffitarget.h (original) +++ python/branches/p3yk/Modules/_ctypes/libffi_msvc/ffitarget.h Wed Dec 13 05:49:30 2006 @@ -44,7 +44,9 @@ /* ---- Intel x86 Win32 ---------- */ FFI_SYSV, +#ifndef _WIN64 FFI_STDCALL, +#endif /* TODO: Add fastcall support for the sake of completeness */ FFI_DEFAULT_ABI = FFI_SYSV, @@ -67,8 +69,8 @@ #define FFI_CLOSURES 1 -#ifdef X86_64 -#define FFI_TRAMPOLINE_SIZE 24 +#ifdef _WIN64 +#define FFI_TRAMPOLINE_SIZE 29 #define FFI_NATIVE_RAW_API 0 #else #define FFI_TRAMPOLINE_SIZE 15 Modified: python/branches/p3yk/Modules/_ctypes/stgdict.c ============================================================================== --- python/branches/p3yk/Modules/_ctypes/stgdict.c (original) +++ python/branches/p3yk/Modules/_ctypes/stgdict.c Wed Dec 13 05:49:30 2006 @@ -173,11 +173,11 @@ for (i = 0; i < PySequence_Fast_GET_SIZE(fieldlist); ++i) { PyObject *pair = PySequence_Fast_GET_ITEM(fieldlist, i); /* borrowed */ - PyObject *fname, *ftype; + PyObject *fname, *ftype, *bits; CFieldObject *fdescr; CFieldObject *new_descr; /* Convert to PyArg_UnpackTuple... */ - if (!PyArg_ParseTuple(pair, "OO", &fname, &ftype)) { + if (!PyArg_ParseTuple(pair, "OO|O", &fname, &ftype, &bits)) { Py_DECREF(fieldlist); return -1; } @@ -335,14 +335,14 @@ stgdict = PyType_stgdict(type); if (!stgdict) return -1; + /* If this structure/union is already marked final we cannot assign + _fields_ anymore. */ + if (stgdict->flags & DICTFLAG_FINAL) {/* is final ? */ PyErr_SetString(PyExc_AttributeError, "_fields_ is final"); return -1; } - /* XXX This should probably be moved to a point when all this - stuff is sucessfully finished. */ - stgdict->flags |= DICTFLAG_FINAL; /* set final */ if (stgdict->ffi_type_pointer.elements) PyMem_Free(stgdict->ffi_type_pointer.elements); @@ -476,5 +476,15 @@ stgdict->size = size; stgdict->align = total_align; stgdict->length = len; /* ADD ffi_ofs? */ + + /* We did check that this flag was NOT set above, it must not + have been set until now. */ + if (stgdict->flags & DICTFLAG_FINAL) { + PyErr_SetString(PyExc_AttributeError, + "Structure or union cannot contain itself"); + return -1; + } + stgdict->flags |= DICTFLAG_FINAL; + return MakeAnonFields(type); } Modified: python/branches/p3yk/Modules/_cursesmodule.c ============================================================================== --- python/branches/p3yk/Modules/_cursesmodule.c (original) +++ python/branches/p3yk/Modules/_cursesmodule.c Wed Dec 13 05:49:30 2006 @@ -2334,6 +2334,10 @@ } result = tparm(fmt,i1,i2,i3,i4,i5,i6,i7,i8,i9); + if (!result) { + PyErr_SetString(PyCursesError, "tparm() returned NULL"); + return NULL; + } return PyString_FromString(result); } Modified: python/branches/p3yk/Modules/_sre.c ============================================================================== --- python/branches/p3yk/Modules/_sre.c (original) +++ python/branches/p3yk/Modules/_sre.c Wed Dec 13 05:49:30 2006 @@ -1166,9 +1166,10 @@ /* install new repeat context */ ctx->u.rep = (SRE_REPEAT*) PyObject_MALLOC(sizeof(*ctx->u.rep)); - /* XXX(nnorwitz): anything else we need to do on error? */ - if (!ctx->u.rep) + if (!ctx->u.rep) { + PyErr_NoMemory(); RETURN_FAILURE; + } ctx->u.rep->count = -1; ctx->u.rep->pattern = ctx->pattern; ctx->u.rep->prev = state->repeat; @@ -1884,6 +1885,8 @@ } TRACE(("|%p|%p|END\n", PatternObject_GetCode(self), state.ptr)); + if (PyErr_Occurred()) + return NULL; state_fini(&state); @@ -1922,6 +1925,9 @@ state_fini(&state); + if (PyErr_Occurred()) + return NULL; + return pattern_new_match(self, &state, status); } @@ -2071,6 +2077,9 @@ #endif } + if (PyErr_Occurred()) + goto error; + if (status <= 0) { if (status == 0) break; @@ -2198,6 +2207,9 @@ #endif } + if (PyErr_Occurred()) + goto error; + if (status <= 0) { if (status == 0) break; @@ -2347,6 +2359,9 @@ #endif } + if (PyErr_Occurred()) + goto error; + if (status <= 0) { if (status == 0) break; @@ -3250,6 +3265,8 @@ status = sre_umatch(state, PatternObject_GetCode(self->pattern)); #endif } + if (PyErr_Occurred()) + return NULL; match = pattern_new_match((PatternObject*) self->pattern, state, status); @@ -3281,6 +3298,8 @@ status = sre_usearch(state, PatternObject_GetCode(self->pattern)); #endif } + if (PyErr_Occurred()) + return NULL; match = pattern_new_match((PatternObject*) self->pattern, state, status); Modified: python/branches/p3yk/Modules/_ssl.c ============================================================================== --- python/branches/p3yk/Modules/_ssl.c (original) +++ python/branches/p3yk/Modules/_ssl.c Wed Dec 13 05:49:30 2006 @@ -317,7 +317,7 @@ if (!PyArg_ParseTuple(args, "O!|zz:ssl", PySocketModule.Sock_Type, - (PyObject*)&Sock, + &Sock, &key_file, &cert_file)) return NULL; Modified: python/branches/p3yk/Modules/_testcapimodule.c ============================================================================== --- python/branches/p3yk/Modules/_testcapimodule.c (original) +++ python/branches/p3yk/Modules/_testcapimodule.c Wed Dec 13 05:49:30 2006 @@ -6,6 +6,8 @@ */ #include "Python.h" +#include +#include "structmember.h" #ifdef WITH_THREAD #include "pythread.h" @@ -35,13 +37,13 @@ platforms have these hardcoded. Better safe than sorry. */ static PyObject* -sizeof_error(const char* fatname, const char* typename, +sizeof_error(const char* fatname, const char* typname, int expected, int got) { char buf[1024]; PyOS_snprintf(buf, sizeof(buf), "%.200s #define == %d but sizeof(%.200s) == %d", - fatname, expected, typename, got); + fatname, expected, typname, got); PyErr_SetString(TestError, buf); return (PyObject*)NULL; } @@ -615,7 +617,7 @@ { PyObject *rc; PyGILState_STATE s = PyGILState_Ensure(); - rc = PyObject_CallFunction(callable, ""); + rc = PyObject_CallFunction((PyObject *)callable, ""); Py_XDECREF(rc); PyGILState_Release(s); } @@ -665,6 +667,9 @@ PyThread_acquire_lock(thread_done, 1); /* wait for thread to finish */ Py_END_ALLOW_THREADS + /* Release lock we acquired above. This is required on HP-UX. */ + PyThread_release_lock(thread_done); + PyThread_free_lock(thread_done); Py_RETURN_NONE; } @@ -756,6 +761,105 @@ #define AddSym(d, n, f, v) {PyObject *o = f(v); PyDict_SetItemString(d, n, o); Py_DECREF(o);} +typedef struct { + char byte_member; + unsigned char ubyte_member; + short short_member; + unsigned short ushort_member; + int int_member; + unsigned int uint_member; + long long_member; + unsigned long ulong_member; + float float_member; + double double_member; +} all_structmembers; + +typedef struct { + PyObject_HEAD + all_structmembers structmembers; +} test_structmembers; + +static struct PyMemberDef test_members[] = { + {"T_BYTE", T_BYTE, offsetof(test_structmembers, structmembers.byte_member), 0, NULL}, + {"T_UBYTE", T_UBYTE, offsetof(test_structmembers, structmembers.ubyte_member), 0, NULL}, + {"T_SHORT", T_SHORT, offsetof(test_structmembers, structmembers.short_member), 0, NULL}, + {"T_USHORT", T_USHORT, offsetof(test_structmembers, structmembers.ushort_member), 0, NULL}, + {"T_INT", T_INT, offsetof(test_structmembers, structmembers.int_member), 0, NULL}, + {"T_UINT", T_UINT, offsetof(test_structmembers, structmembers.uint_member), 0, NULL}, + {"T_LONG", T_LONG, offsetof(test_structmembers, structmembers.long_member), 0, NULL}, + {"T_ULONG", T_ULONG, offsetof(test_structmembers, structmembers.ulong_member), 0, NULL}, + {"T_FLOAT", T_FLOAT, offsetof(test_structmembers, structmembers.float_member), 0, NULL}, + {"T_DOUBLE", T_DOUBLE, offsetof(test_structmembers, structmembers.double_member), 0, NULL}, + {NULL} +}; + + +static PyObject *test_structmembers_new(PyTypeObject *type, PyObject *args, PyObject *kwargs){ + static char *keywords[]={"T_BYTE", "T_UBYTE", "T_SHORT", "T_USHORT", "T_INT", "T_UINT", + "T_LONG", "T_ULONG", "T_FLOAT", "T_DOUBLE", NULL}; + test_structmembers *ob=PyObject_New(test_structmembers, type); + if (ob==NULL) + return NULL; + memset(&ob->structmembers, 0, sizeof(all_structmembers)); + if (!PyArg_ParseTupleAndKeywords(args, kwargs, "|bBhHiIlkfd", keywords, + &ob->structmembers.byte_member, &ob->structmembers.ubyte_member, + &ob->structmembers.short_member, &ob->structmembers.ushort_member, + &ob->structmembers.int_member, &ob->structmembers.uint_member, + &ob->structmembers.long_member, &ob->structmembers.ulong_member, + &ob->structmembers.float_member, &ob->structmembers.double_member)){ + Py_DECREF(ob); + return NULL; + } + return (PyObject *)ob; +} + +static void test_structmembers_free(PyObject *ob){ + PyObject_FREE(ob); +} + +static PyTypeObject test_structmembersType = { + PyObject_HEAD_INIT(NULL) + 0, + "test_structmembersType", + sizeof(test_structmembers), /* tp_basicsize */ + 0, /* tp_itemsize */ + test_structmembers_free, /* destructor tp_dealloc */ + 0, /* tp_print */ + 0, /* tp_getattr */ + 0, /* tp_setattr */ + 0, /* tp_compare */ + 0, /* tp_repr */ + 0, /* tp_as_number */ + 0, /* tp_as_sequence */ + 0, /* tp_as_mapping */ + 0, /* tp_hash */ + 0, /* tp_call */ + 0, /* tp_str */ + PyObject_GenericGetAttr, + PyObject_GenericSetAttr, + 0, /* tp_as_buffer */ + 0, /* tp_flags */ + "Type containing all structmember types", + 0, /* traverseproc tp_traverse */ + 0, /* tp_clear */ + 0, /* tp_richcompare */ + 0, /* tp_weaklistoffset */ + 0, /* tp_iter */ + 0, /* tp_iternext */ + 0, /* tp_methods */ + test_members, /* tp_members */ + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + test_structmembers_new, /* tp_new */ +}; + + PyMODINIT_FUNC init_testcapi(void) { @@ -765,16 +869,28 @@ if (m == NULL) return; + test_structmembersType.ob_type=&PyType_Type; + Py_INCREF(&test_structmembersType); + PyModule_AddObject(m, "test_structmembersType", (PyObject *)&test_structmembersType); + + PyModule_AddObject(m, "CHAR_MAX", PyInt_FromLong(CHAR_MAX)); + PyModule_AddObject(m, "CHAR_MIN", PyInt_FromLong(CHAR_MIN)); PyModule_AddObject(m, "UCHAR_MAX", PyInt_FromLong(UCHAR_MAX)); + PyModule_AddObject(m, "SHRT_MAX", PyInt_FromLong(SHRT_MAX)); + PyModule_AddObject(m, "SHRT_MIN", PyInt_FromLong(SHRT_MIN)); PyModule_AddObject(m, "USHRT_MAX", PyInt_FromLong(USHRT_MAX)); + PyModule_AddObject(m, "INT_MAX", PyLong_FromLong(INT_MAX)); + PyModule_AddObject(m, "INT_MIN", PyLong_FromLong(INT_MIN)); PyModule_AddObject(m, "UINT_MAX", PyLong_FromUnsignedLong(UINT_MAX)); - PyModule_AddObject(m, "ULONG_MAX", PyLong_FromUnsignedLong(ULONG_MAX)); - PyModule_AddObject(m, "INT_MIN", PyInt_FromLong(INT_MIN)); - PyModule_AddObject(m, "LONG_MIN", PyInt_FromLong(LONG_MIN)); - PyModule_AddObject(m, "PY_SSIZE_T_MIN", PyInt_FromSsize_t(PY_SSIZE_T_MIN)); - PyModule_AddObject(m, "INT_MAX", PyInt_FromLong(INT_MAX)); PyModule_AddObject(m, "LONG_MAX", PyInt_FromLong(LONG_MAX)); + PyModule_AddObject(m, "LONG_MIN", PyInt_FromLong(LONG_MIN)); + PyModule_AddObject(m, "ULONG_MAX", PyLong_FromUnsignedLong(ULONG_MAX)); + PyModule_AddObject(m, "FLT_MAX", PyFloat_FromDouble(FLT_MAX)); + PyModule_AddObject(m, "FLT_MIN", PyFloat_FromDouble(FLT_MIN)); + PyModule_AddObject(m, "DBL_MAX", PyFloat_FromDouble(DBL_MAX)); + PyModule_AddObject(m, "DBL_MIN", PyFloat_FromDouble(DBL_MIN)); PyModule_AddObject(m, "PY_SSIZE_T_MAX", PyInt_FromSsize_t(PY_SSIZE_T_MAX)); + PyModule_AddObject(m, "PY_SSIZE_T_MIN", PyInt_FromSsize_t(PY_SSIZE_T_MIN)); TestError = PyErr_NewException("_testcapi.error", NULL, NULL); Py_INCREF(TestError); Modified: python/branches/p3yk/Modules/almodule.c ============================================================================== --- python/branches/p3yk/Modules/almodule.c (original) +++ python/branches/p3yk/Modules/almodule.c Wed Dec 13 05:49:30 2006 @@ -1686,7 +1686,7 @@ { int res, param; ALparamInfo pinfo; - PyObject *v, *item;; + PyObject *v, *item; if (!PyArg_ParseTuple(args, "ii:GetParamInfo", &res, ¶m)) return NULL; Modified: python/branches/p3yk/Modules/arraymodule.c ============================================================================== --- python/branches/p3yk/Modules/arraymodule.c (original) +++ python/branches/p3yk/Modules/arraymodule.c Wed Dec 13 05:49:30 2006 @@ -1495,7 +1495,7 @@ copy_doc}, {"count", (PyCFunction)array_count, METH_O, count_doc}, - {"__deepcopy__",(PyCFunction)array_copy, METH_NOARGS, + {"__deepcopy__",(PyCFunction)array_copy, METH_O, copy_doc}, {"extend", (PyCFunction)array_extend, METH_O, extend_doc}, Modified: python/branches/p3yk/Modules/audioop.c ============================================================================== --- python/branches/p3yk/Modules/audioop.c (original) +++ python/branches/p3yk/Modules/audioop.c Wed Dec 13 05:49:30 2006 @@ -472,8 +472,12 @@ double aj_m1, aj_lm1; double sum_ri_2, sum_aij_2, sum_aij_ri, result, best_result, factor; + /* Passing a short** for an 's' argument is correct only + if the string contents is aligned for interpretation + as short[]. Due to the definition of PyStringObject, + this is currently (Python 2.6) the case. */ if ( !PyArg_ParseTuple(args, "s#s#:findfit", - &cp1, &len1, &cp2, &len2) ) + (char**)&cp1, &len1, (char**)&cp2, &len2) ) return 0; if ( len1 & 1 || len2 & 1 ) { PyErr_SetString(AudioopError, "Strings should be even-sized"); @@ -530,7 +534,7 @@ double sum_ri_2, sum_aij_ri, result; if ( !PyArg_ParseTuple(args, "s#s#:findfactor", - &cp1, &len1, &cp2, &len2) ) + (char**)&cp1, &len1, (char**)&cp2, &len2) ) return 0; if ( len1 & 1 || len2 & 1 ) { PyErr_SetString(AudioopError, "Strings should be even-sized"); @@ -562,7 +566,8 @@ double aj_m1, aj_lm1; double result, best_result; - if ( !PyArg_ParseTuple(args, "s#i:findmax", &cp1, &len1, &len2) ) + if ( !PyArg_ParseTuple(args, "s#i:findmax", + (char**)&cp1, &len1, &len2) ) return 0; if ( len1 & 1 ) { PyErr_SetString(AudioopError, "Strings should be even-sized"); Modified: python/branches/p3yk/Modules/binascii.c ============================================================================== --- python/branches/p3yk/Modules/binascii.c (original) +++ python/branches/p3yk/Modules/binascii.c Wed Dec 13 05:49:30 2006 @@ -1057,8 +1057,7 @@ in++; if (in >= datalen) break; /* Soft line breaks */ - if ((data[in] == '\n') || (data[in] == '\r') || - (data[in] == ' ') || (data[in] == '\t')) { + if ((data[in] == '\n') || (data[in] == '\r')) { if (data[in] != '\n') { while (in < datalen && data[in] != '\n') in++; } Modified: python/branches/p3yk/Modules/bz2module.c ============================================================================== --- python/branches/p3yk/Modules/bz2module.c (original) +++ python/branches/p3yk/Modules/bz2module.c Wed Dec 13 05:49:30 2006 @@ -1016,12 +1016,12 @@ case MODE_CLOSED: PyErr_SetString(PyExc_ValueError, "I/O operation on closed file"); - goto cleanup;; + goto cleanup; default: PyErr_SetString(PyExc_IOError, "seek works only while reading"); - goto cleanup;; + goto cleanup; } if (where == 2) { Modified: python/branches/p3yk/Modules/cPickle.c ============================================================================== --- python/branches/p3yk/Modules/cPickle.c (original) +++ python/branches/p3yk/Modules/cPickle.c Wed Dec 13 05:49:30 2006 @@ -1024,7 +1024,7 @@ static int save_long(Picklerobject *self, PyObject *args) { - int size; + Py_ssize_t size; int res = -1; PyObject *repr = NULL; @@ -1066,7 +1066,7 @@ * byte at the start, and cut it back later if possible. */ nbytes = (nbits >> 3) + 1; - if ((int)nbytes < 0 || (size_t)(int)nbytes != nbytes) { + if (nbytes > INT_MAX) { PyErr_SetString(PyExc_OverflowError, "long too large " "to pickle"); goto finally; @@ -1208,12 +1208,14 @@ c_str[1] = size; len = 2; } - else { + else if (size <= INT_MAX) { c_str[0] = BINSTRING; for (i = 1; i < 5; i++) c_str[i] = (int)(size >> ((i - 1) * 8)); len = 5; } + else + return -1; /* string too large */ if (self->write_func(self, c_str, len) < 0) return -1; @@ -1286,7 +1288,7 @@ static int save_unicode(Picklerobject *self, PyObject *args, int doput) { - int size, len; + Py_ssize_t size, len; PyObject *repr=0; if (!PyUnicode_Check(args)) @@ -1325,6 +1327,8 @@ if ((size = PyString_Size(repr)) < 0) goto err; + if (size > INT_MAX) + return -1; /* string too large */ c_str[0] = BINUNICODE; for (i = 1; i < 5; i++) Modified: python/branches/p3yk/Modules/cStringIO.c ============================================================================== --- python/branches/p3yk/Modules/cStringIO.c (original) +++ python/branches/p3yk/Modules/cStringIO.c Wed Dec 13 05:49:30 2006 @@ -289,7 +289,17 @@ if (!IO__opencheck(self)) return NULL; if (!PyArg_ParseTuple(args, "|n:truncate", &pos)) return NULL; - if (pos < 0) pos = self->pos; + + if (PyTuple_Size(args) == 0) { + /* No argument passed, truncate to current position */ + pos = self->pos; + } + + if (pos < 0) { + errno = EINVAL; + PyErr_SetFromErrno(PyExc_IOError); + return NULL; + } if (self->string_size > pos) self->string_size = pos; self->pos = self->string_size; @@ -657,11 +667,9 @@ char *buf; Py_ssize_t size; - if (PyObject_AsReadBuffer(s, (const void **)&buf, &size)) { - PyErr_Format(PyExc_TypeError, "expected read buffer, %.200s found", - s->ob_type->tp_name); + if (PyObject_AsCharBuffer(s, (const char **)&buf, &size) != 0) return NULL; - } + self = PyObject_New(Iobject, &Itype); if (!self) return NULL; Py_INCREF(s); Modified: python/branches/p3yk/Modules/cjkcodecs/_codecs_cn.c ============================================================================== --- python/branches/p3yk/Modules/cjkcodecs/_codecs_cn.c (original) +++ python/branches/p3yk/Modules/cjkcodecs/_codecs_cn.c Wed Dec 13 05:49:30 2006 @@ -15,14 +15,26 @@ #undef hz #endif -#define GBK_PREDECODE(dc1, dc2, assi) \ +/* GBK and GB2312 map differently in few codepoints that are listed below: + * + * gb2312 gbk + * A1A4 U+30FB KATAKANA MIDDLE DOT U+00B7 MIDDLE DOT + * A1AA U+2015 HORIZONTAL BAR U+2014 EM DASH + * A844 undefined U+2015 HORIZONTAL BAR + */ + +#define GBK_DECODE(dc1, dc2, assi) \ if ((dc1) == 0xa1 && (dc2) == 0xaa) (assi) = 0x2014; \ else if ((dc1) == 0xa8 && (dc2) == 0x44) (assi) = 0x2015; \ - else if ((dc1) == 0xa1 && (dc2) == 0xa4) (assi) = 0x00b7; -#define GBK_PREENCODE(code, assi) \ + else if ((dc1) == 0xa1 && (dc2) == 0xa4) (assi) = 0x00b7; \ + else TRYMAP_DEC(gb2312, assi, dc1 ^ 0x80, dc2 ^ 0x80); \ + else TRYMAP_DEC(gbkext, assi, dc1, dc2); + +#define GBK_ENCODE(code, assi) \ if ((code) == 0x2014) (assi) = 0xa1aa; \ else if ((code) == 0x2015) (assi) = 0xa844; \ - else if ((code) == 0x00b7) (assi) = 0xa1a4; + else if ((code) == 0x00b7) (assi) = 0xa1a4; \ + else if ((code) != 0x30fb && TRYMAP_ENC_COND(gbcommon, assi, code)); /* * GB2312 codec @@ -99,8 +111,7 @@ REQUIRE_OUTBUF(2) - GBK_PREENCODE(c, code) - else TRYMAP_ENC(gbcommon, code, c); + GBK_ENCODE(c, code) else return 1; OUT1((code >> 8) | 0x80) @@ -129,9 +140,7 @@ REQUIRE_INBUF(2) - GBK_PREDECODE(c, IN2, **outbuf) - else TRYMAP_DEC(gb2312, **outbuf, c ^ 0x80, IN2 ^ 0x80); - else TRYMAP_DEC(gbkext, **outbuf, c, IN2); + GBK_DECODE(c, IN2, **outbuf) else return 2; NEXT(2, 1) @@ -187,9 +196,7 @@ REQUIRE_OUTBUF(2) - GBK_PREENCODE(c, code) - else TRYMAP_ENC(gbcommon, code, c); - else TRYMAP_ENC(gb18030ext, code, c); + GBK_ENCODE(c, code) else { const struct _gb18030_to_unibmp_ranges *utrrange; @@ -287,9 +294,7 @@ return 4; } - GBK_PREDECODE(c, c2, **outbuf) - else TRYMAP_DEC(gb2312, **outbuf, c ^ 0x80, c2 ^ 0x80); - else TRYMAP_DEC(gbkext, **outbuf, c, c2); + GBK_DECODE(c, c2, **outbuf) else TRYMAP_DEC(gb18030ext, **outbuf, c, c2); else return 2; Modified: python/branches/p3yk/Modules/cjkcodecs/_codecs_iso2022.c ============================================================================== --- python/branches/p3yk/Modules/cjkcodecs/_codecs_iso2022.c (original) +++ python/branches/p3yk/Modules/cjkcodecs/_codecs_iso2022.c Wed Dec 13 05:49:30 2006 @@ -592,9 +592,11 @@ { DBCHAR coded; assert(*length == 1); - TRYMAP_ENC(cp949, coded, *data) - if (!(coded & 0x8000)) - return coded; + if (*data < 0x10000) { + TRYMAP_ENC(cp949, coded, *data) + if (!(coded & 0x8000)) + return coded; + } return MAP_UNMAPPABLE; } @@ -628,11 +630,13 @@ { DBCHAR coded; assert(*length == 1); - if (*data == 0xff3c) /* F/W REVERSE SOLIDUS */ - return 0x2140; - else TRYMAP_ENC(jisxcommon, coded, *data) { - if (!(coded & 0x8000)) - return coded; + if (*data < 0x10000) { + if (*data == 0xff3c) /* F/W REVERSE SOLIDUS */ + return 0x2140; + else TRYMAP_ENC(jisxcommon, coded, *data) { + if (!(coded & 0x8000)) + return coded; + } } return MAP_UNMAPPABLE; } @@ -665,9 +669,11 @@ { DBCHAR coded; assert(*length == 1); - TRYMAP_ENC(jisxcommon, coded, *data) { - if (coded & 0x8000) - return coded & 0x7fff; + if (*data < 0x10000) { + TRYMAP_ENC(jisxcommon, coded, *data) { + if (coded & 0x8000) + return coded & 0x7fff; + } } return MAP_UNMAPPABLE; } @@ -854,7 +860,7 @@ if (coded == MAP_UNMAPPABLE || coded == MAP_MULTIPLE_AVAIL) return coded; else if (coded & 0x8000) - return coded; + return coded & 0x7fff; else return MAP_UNMAPPABLE; } @@ -901,7 +907,7 @@ if (coded == MAP_UNMAPPABLE || coded == MAP_MULTIPLE_AVAIL) return coded; else if (coded & 0x8000) - return coded; + return coded & 0x7fff; else return MAP_UNMAPPABLE; } @@ -970,9 +976,11 @@ { DBCHAR coded; assert(*length == 1); - TRYMAP_ENC(gbcommon, coded, *data) { - if (!(coded & 0x8000)) - return coded; + if (*data < 0x10000) { + TRYMAP_ENC(gbcommon, coded, *data) { + if (!(coded & 0x8000)) + return coded; + } } return MAP_UNMAPPABLE; } @@ -992,7 +1000,10 @@ /*-*- registry tables -*-*/ -#define REGISTRY_KSX1001 { CHARSET_KSX1001, 1, 2, \ +#define REGISTRY_KSX1001_G0 { CHARSET_KSX1001, 0, 2, \ + ksx1001_init, \ + ksx1001_decoder, ksx1001_encoder } +#define REGISTRY_KSX1001_G1 { CHARSET_KSX1001, 1, 2, \ ksx1001_init, \ ksx1001_decoder, ksx1001_encoder } #define REGISTRY_JISX0201_R { CHARSET_JISX0201_R, 0, 1, \ @@ -1034,7 +1045,7 @@ jisx0213_init, \ jisx0213_2004_2_decoder, \ jisx0213_2004_2_encoder } -#define REGISTRY_GB2312 { CHARSET_GB2312, 1, 2, \ +#define REGISTRY_GB2312 { CHARSET_GB2312, 0, 2, \ gb2312_init, \ gb2312_decoder, gb2312_encoder } #define REGISTRY_CNS11643_1 { CHARSET_CNS11643_1, 1, 2, \ @@ -1054,7 +1065,7 @@ }; static const struct iso2022_designation iso2022_kr_designations[] = { - REGISTRY_KSX1001, REGISTRY_SENTINEL + REGISTRY_KSX1001_G1, REGISTRY_SENTINEL }; CONFIGDEF(kr, 0) @@ -1071,7 +1082,7 @@ CONFIGDEF(jp_1, NO_SHIFT | USE_JISX0208_EXT) static const struct iso2022_designation iso2022_jp_2_designations[] = { - REGISTRY_JISX0208, REGISTRY_JISX0212, REGISTRY_KSX1001, + REGISTRY_JISX0208, REGISTRY_JISX0212, REGISTRY_KSX1001_G0, REGISTRY_GB2312, REGISTRY_JISX0201_R, REGISTRY_JISX0208_O, REGISTRY_ISO8859_1, REGISTRY_ISO8859_7, REGISTRY_SENTINEL }; Modified: python/branches/p3yk/Modules/cjkcodecs/cjkcodecs.h ============================================================================== --- python/branches/p3yk/Modules/cjkcodecs/cjkcodecs.h (original) +++ python/branches/p3yk/Modules/cjkcodecs/cjkcodecs.h Wed Dec 13 05:49:30 2006 @@ -159,29 +159,32 @@ #endif #define _TRYMAP_ENC(m, assi, val) \ - if ((m)->map != NULL && (val) >= (m)->bottom && \ + ((m)->map != NULL && (val) >= (m)->bottom && \ (val)<= (m)->top && ((assi) = (m)->map[(val) - \ (m)->bottom]) != NOCHAR) -#define TRYMAP_ENC(charset, assi, uni) \ +#define TRYMAP_ENC_COND(charset, assi, uni) \ _TRYMAP_ENC(&charset##_encmap[(uni) >> 8], assi, (uni) & 0xff) +#define TRYMAP_ENC(charset, assi, uni) \ + if TRYMAP_ENC_COND(charset, assi, uni) + #define _TRYMAP_DEC(m, assi, val) \ - if ((m)->map != NULL && (val) >= (m)->bottom && \ + ((m)->map != NULL && (val) >= (m)->bottom && \ (val)<= (m)->top && ((assi) = (m)->map[(val) - \ (m)->bottom]) != UNIINV) #define TRYMAP_DEC(charset, assi, c1, c2) \ - _TRYMAP_DEC(&charset##_decmap[c1], assi, c2) + if _TRYMAP_DEC(&charset##_decmap[c1], assi, c2) #define _TRYMAP_ENC_MPLANE(m, assplane, asshi, asslo, val) \ - if ((m)->map != NULL && (val) >= (m)->bottom && \ + ((m)->map != NULL && (val) >= (m)->bottom && \ (val)<= (m)->top && \ ((assplane) = (m)->map[((val) - (m)->bottom)*3]) != 0 && \ (((asshi) = (m)->map[((val) - (m)->bottom)*3 + 1]), 1) && \ (((asslo) = (m)->map[((val) - (m)->bottom)*3 + 2]), 1)) #define TRYMAP_ENC_MPLANE(charset, assplane, asshi, asslo, uni) \ - _TRYMAP_ENC_MPLANE(&charset##_encmap[(uni) >> 8], \ + if _TRYMAP_ENC_MPLANE(&charset##_encmap[(uni) >> 8], \ assplane, asshi, asslo, (uni) & 0xff) #define TRYMAP_DEC_MPLANE(charset, assi, plane, c1, c2) \ - _TRYMAP_DEC(&charset##_decmap[plane][c1], assi, c2) + if _TRYMAP_DEC(&charset##_decmap[plane][c1], assi, c2) #if Py_UNICODE_SIZE == 2 #define DECODE_SURROGATE(c) \ Modified: python/branches/p3yk/Modules/datetimemodule.c ============================================================================== --- python/branches/p3yk/Modules/datetimemodule.c (original) +++ python/branches/p3yk/Modules/datetimemodule.c Wed Dec 13 05:49:30 2006 @@ -1149,9 +1149,9 @@ PyObject *newfmt = NULL; /* py string, the output format */ char *pnew; /* pointer to available byte in output format */ - char totalnew; /* number bytes total in output format buffer, + int totalnew; /* number bytes total in output format buffer, exclusive of trailing \0 */ - char usednew; /* number bytes used so far in output format buffer */ + int usednew; /* number bytes used so far in output format buffer */ char *ptoappend; /* pointer to string to append to output buffer */ int ntoappend; /* # of bytes to append to output buffer */ Modified: python/branches/p3yk/Modules/dbmmodule.c ============================================================================== --- python/branches/p3yk/Modules/dbmmodule.c (original) +++ python/branches/p3yk/Modules/dbmmodule.c Wed Dec 13 05:49:30 2006 @@ -246,11 +246,13 @@ { datum key, val; PyObject *defvalue = Py_None; + char *tmp_ptr; int tmp_size; if (!PyArg_ParseTuple(args, "s#|O:get", - &key.dptr, &tmp_size, &defvalue)) + &tmp_ptr, &tmp_size, &defvalue)) return NULL; + key.dptr = tmp_ptr; key.dsize = tmp_size; check_dbmobject_open(dp); val = dbm_fetch(dp->di_dbm, key); @@ -267,11 +269,13 @@ { datum key, val; PyObject *defvalue = NULL; + char *tmp_ptr; int tmp_size; if (!PyArg_ParseTuple(args, "s#|S:setdefault", - &key.dptr, &tmp_size, &defvalue)) + &tmp_ptr, &tmp_size, &defvalue)) return NULL; + key.dptr = tmp_ptr; key.dsize = tmp_size; check_dbmobject_open(dp); val = dbm_fetch(dp->di_dbm, key); Modified: python/branches/p3yk/Modules/gcmodule.c ============================================================================== --- python/branches/p3yk/Modules/gcmodule.c (original) +++ python/branches/p3yk/Modules/gcmodule.c Wed Dec 13 05:49:30 2006 @@ -1153,6 +1153,7 @@ "disable() -- Disable automatic garbage collection.\n" "isenabled() -- Returns true if automatic collection is enabled.\n" "collect() -- Do a full collection right now.\n" +"get_count() -- Return the current collection counts.\n" "set_debug() -- Set debugging flags.\n" "get_debug() -- Get debugging flags.\n" "set_threshold() -- Set the collection thresholds.\n" Modified: python/branches/p3yk/Modules/itertoolsmodule.c ============================================================================== --- python/branches/p3yk/Modules/itertoolsmodule.c (original) +++ python/branches/p3yk/Modules/itertoolsmodule.c Wed Dec 13 05:49:30 2006 @@ -618,11 +618,15 @@ static PyObject * tee(PyObject *self, PyObject *args) { - int i, n=2; + Py_ssize_t i, n=2; PyObject *it, *iterable, *copyable, *result; - if (!PyArg_ParseTuple(args, "O|i", &iterable, &n)) + if (!PyArg_ParseTuple(args, "O|n", &iterable, &n)) return NULL; + if (n < 0) { + PyErr_SetString(PyExc_ValueError, "n must be >= 0"); + return NULL; + } result = PyTuple_New(n); if (result == NULL) return NULL; @@ -2068,7 +2072,7 @@ static PyObject * count_next(countobject *lz) { - return PyInt_FromSize_t(lz->cnt++); + return PyInt_FromSsize_t(lz->cnt++); } static PyObject * Modified: python/branches/p3yk/Modules/linuxaudiodev.c ============================================================================== --- python/branches/p3yk/Modules/linuxaudiodev.c (original) +++ python/branches/p3yk/Modules/linuxaudiodev.c Wed Dec 13 05:49:30 2006 @@ -28,7 +28,9 @@ #if defined(linux) #include +#ifndef HAVE_STDINT_H typedef unsigned long uint32_t; +#endif #elif defined(__FreeBSD__) #include Modified: python/branches/p3yk/Modules/main.c ============================================================================== --- python/branches/p3yk/Modules/main.c (original) +++ python/branches/p3yk/Modules/main.c Wed Dec 13 05:49:30 2006 @@ -59,31 +59,32 @@ static char *usage_1 = "\ Options and arguments (and corresponding environment variables):\n\ -c cmd : program passed in as string (terminates option list)\n\ --d : debug output from parser (also PYTHONDEBUG=x)\n\ +-d : debug output from parser; also PYTHONDEBUG=x\n\ -E : ignore environment variables (such as PYTHONPATH)\n\ -h : print this help message and exit (also --help)\n\ --i : inspect interactively after running script, (also PYTHONINSPECT=x)\n\ - and force prompts, even if stdin does not appear to be a terminal\n\ +-i : inspect interactively after running script; forces a prompt even\n\ + if stdin does not appear to be a terminal; also PYTHONINSPECT=x\n\ "; static char *usage_2 = "\ -m mod : run library module as a script (terminates option list)\n\ --O : optimize generated bytecode (a tad; also PYTHONOPTIMIZE=x)\n\ +-O : optimize generated bytecode slightly; also PYTHONOPTIMIZE=x\n\ -OO : remove doc-strings in addition to the -O optimizations\n\ -S : don't imply 'import site' on initialization\n\ -t : issue warnings about inconsistent tab usage (-tt: issue errors)\n\ --u : unbuffered binary stdout and stderr (also PYTHONUNBUFFERED=x)\n\ +-u : unbuffered binary stdout and stderr; also PYTHONUNBUFFERED=x\n\ "; static char *usage_3 = "\ see man page for details on internal buffering relating to '-u'\n\ --v : verbose (trace import statements) (also PYTHONVERBOSE=x)\n\ +-v : verbose (trace import statements); also PYTHONVERBOSE=x\n\ + can be supplied multiple times to increase verbosity\n\ -V : print the Python version number and exit (also --version)\n\ --W arg : warning control (arg is action:message:category:module:lineno)\n\ +-W arg : warning control; arg is action:message:category:module:lineno\n\ -x : skip first line of source, allowing use of non-Unix forms of #!cmd\n\ file : program read from script file\n\ - : program read from stdin (default; interactive mode if a tty)\n\ "; static char *usage_4 = "\ -arg ...: arguments passed to program in sys.argv[1:]\n\ +arg ...: arguments passed to program in sys.argv[1:]\n\n\ Other environment variables:\n\ PYTHONSTARTUP: file executed on interactive startup (no default)\n\ PYTHONPATH : '%c'-separated list of directories prefixed to the\n\ Modified: python/branches/p3yk/Modules/mathmodule.c ============================================================================== --- python/branches/p3yk/Modules/mathmodule.c (original) +++ python/branches/p3yk/Modules/mathmodule.c Wed Dec 13 05:49:30 2006 @@ -48,10 +48,10 @@ } static PyObject * -math_1(PyObject *args, double (*func) (double), char *argsfmt) +math_1(PyObject *arg, double (*func) (double)) { - double x; - if (! PyArg_ParseTuple(args, argsfmt, &x)) + double x = PyFloat_AsDouble(arg); + if (x == -1.0 && PyErr_Occurred()) return NULL; errno = 0; PyFPE_START_PROTECT("in math_1", return 0) @@ -65,10 +65,15 @@ } static PyObject * -math_2(PyObject *args, double (*func) (double, double), char *argsfmt) +math_2(PyObject *args, double (*func) (double, double), char *funcname) { + PyObject *ox, *oy; double x, y; - if (! PyArg_ParseTuple(args, argsfmt, &x, &y)) + if (! PyArg_UnpackTuple(args, funcname, 2, 2, &ox, &oy)) + return NULL; + x = PyFloat_AsDouble(ox); + y = PyFloat_AsDouble(oy); + if ((x == -1.0 || y == -1.0) && PyErr_Occurred()) return NULL; errno = 0; PyFPE_START_PROTECT("in math_2", return 0) @@ -83,13 +88,13 @@ #define FUNC1(funcname, func, docstring) \ static PyObject * math_##funcname(PyObject *self, PyObject *args) { \ - return math_1(args, func, "d:" #funcname); \ + return math_1(args, func); \ }\ PyDoc_STRVAR(math_##funcname##_doc, docstring); #define FUNC2(funcname, func, docstring) \ static PyObject * math_##funcname(PyObject *self, PyObject *args) { \ - return math_2(args, func, "dd:" #funcname); \ + return math_2(args, func, #funcname); \ }\ PyDoc_STRVAR(math_##funcname##_doc, docstring); @@ -135,11 +140,11 @@ "tanh(x)\n\nReturn the hyperbolic tangent of x.") static PyObject * -math_frexp(PyObject *self, PyObject *args) +math_frexp(PyObject *self, PyObject *arg) { - double x; int i; - if (! PyArg_ParseTuple(args, "d:frexp", &x)) + double x = PyFloat_AsDouble(arg); + if (x == -1.0 && PyErr_Occurred()) return NULL; errno = 0; x = frexp(x, &i); @@ -179,10 +184,10 @@ "ldexp(x, i) -> x * (2**i)"); static PyObject * -math_modf(PyObject *self, PyObject *args) +math_modf(PyObject *self, PyObject *arg) { - double x, y; - if (! PyArg_ParseTuple(args, "d:modf", &x)) + double y, x = PyFloat_AsDouble(arg); + if (x == -1.0 && PyErr_Occurred()) return NULL; errno = 0; x = modf(x, &y); @@ -208,7 +213,7 @@ */ static PyObject* -loghelper(PyObject* args, double (*func)(double), char *format, PyObject *arg) +loghelper(PyObject* arg, double (*func)(double), char *funcname) { /* If it is long, do it ourselves. */ if (PyLong_Check(arg)) { @@ -229,7 +234,7 @@ } /* Else let libm handle it by itself. */ - return math_1(args, func, format); + return math_1(arg, func); } static PyObject * @@ -239,28 +244,15 @@ PyObject *base = NULL; PyObject *num, *den; PyObject *ans; - PyObject *newargs; if (!PyArg_UnpackTuple(args, "log", 1, 2, &arg, &base)) return NULL; - if (base == NULL) - return loghelper(args, log, "d:log", arg); - newargs = PyTuple_Pack(1, arg); - if (newargs == NULL) - return NULL; - num = loghelper(newargs, log, "d:log", arg); - Py_DECREF(newargs); - if (num == NULL) - return NULL; + num = loghelper(arg, log, "log"); + if (num == NULL || base == NULL) + return num; - newargs = PyTuple_Pack(1, base); - if (newargs == NULL) { - Py_DECREF(num); - return NULL; - } - den = loghelper(newargs, log, "d:log", base); - Py_DECREF(newargs); + den = loghelper(base, log, "log"); if (den == NULL) { Py_DECREF(num); return NULL; @@ -277,25 +269,23 @@ If the base not specified, returns the natural logarithm (base e) of x."); static PyObject * -math_log10(PyObject *self, PyObject *args) +math_log10(PyObject *self, PyObject *arg) { - PyObject *arg; - - if (!PyArg_UnpackTuple(args, "log10", 1, 1, &arg)) - return NULL; - return loghelper(args, log10, "d:log10", arg); + return loghelper(arg, log10, "log10"); } PyDoc_STRVAR(math_log10_doc, "log10(x) -> the base 10 logarithm of x."); +/* XXX(nnorwitz): Should we use the platform M_PI or something more accurate + like: 3.14159265358979323846264338327950288 */ static const double degToRad = 3.141592653589793238462643383 / 180.0; static PyObject * -math_degrees(PyObject *self, PyObject *args) +math_degrees(PyObject *self, PyObject *arg) { - double x; - if (! PyArg_ParseTuple(args, "d:degrees", &x)) + double x = PyFloat_AsDouble(arg); + if (x == -1.0 && PyErr_Occurred()) return NULL; return PyFloat_FromDouble(x / degToRad); } @@ -304,10 +294,10 @@ "degrees(x) -> converts angle x from radians to degrees"); static PyObject * -math_radians(PyObject *self, PyObject *args) +math_radians(PyObject *self, PyObject *arg) { - double x; - if (! PyArg_ParseTuple(args, "d:radians", &x)) + double x = PyFloat_AsDouble(arg); + if (x == -1.0 && PyErr_Occurred()) return NULL; return PyFloat_FromDouble(x * degToRad); } @@ -316,31 +306,31 @@ "radians(x) -> converts angle x from degrees to radians"); static PyMethodDef math_methods[] = { - {"acos", math_acos, METH_VARARGS, math_acos_doc}, - {"asin", math_asin, METH_VARARGS, math_asin_doc}, - {"atan", math_atan, METH_VARARGS, math_atan_doc}, + {"acos", math_acos, METH_O, math_acos_doc}, + {"asin", math_asin, METH_O, math_asin_doc}, + {"atan", math_atan, METH_O, math_atan_doc}, {"atan2", math_atan2, METH_VARARGS, math_atan2_doc}, - {"ceil", math_ceil, METH_VARARGS, math_ceil_doc}, - {"cos", math_cos, METH_VARARGS, math_cos_doc}, - {"cosh", math_cosh, METH_VARARGS, math_cosh_doc}, - {"degrees", math_degrees, METH_VARARGS, math_degrees_doc}, - {"exp", math_exp, METH_VARARGS, math_exp_doc}, - {"fabs", math_fabs, METH_VARARGS, math_fabs_doc}, - {"floor", math_floor, METH_VARARGS, math_floor_doc}, + {"ceil", math_ceil, METH_O, math_ceil_doc}, + {"cos", math_cos, METH_O, math_cos_doc}, + {"cosh", math_cosh, METH_O, math_cosh_doc}, + {"degrees", math_degrees, METH_O, math_degrees_doc}, + {"exp", math_exp, METH_O, math_exp_doc}, + {"fabs", math_fabs, METH_O, math_fabs_doc}, + {"floor", math_floor, METH_O, math_floor_doc}, {"fmod", math_fmod, METH_VARARGS, math_fmod_doc}, - {"frexp", math_frexp, METH_VARARGS, math_frexp_doc}, + {"frexp", math_frexp, METH_O, math_frexp_doc}, {"hypot", math_hypot, METH_VARARGS, math_hypot_doc}, {"ldexp", math_ldexp, METH_VARARGS, math_ldexp_doc}, {"log", math_log, METH_VARARGS, math_log_doc}, - {"log10", math_log10, METH_VARARGS, math_log10_doc}, - {"modf", math_modf, METH_VARARGS, math_modf_doc}, + {"log10", math_log10, METH_O, math_log10_doc}, + {"modf", math_modf, METH_O, math_modf_doc}, {"pow", math_pow, METH_VARARGS, math_pow_doc}, - {"radians", math_radians, METH_VARARGS, math_radians_doc}, - {"sin", math_sin, METH_VARARGS, math_sin_doc}, - {"sinh", math_sinh, METH_VARARGS, math_sinh_doc}, - {"sqrt", math_sqrt, METH_VARARGS, math_sqrt_doc}, - {"tan", math_tan, METH_VARARGS, math_tan_doc}, - {"tanh", math_tanh, METH_VARARGS, math_tanh_doc}, + {"radians", math_radians, METH_O, math_radians_doc}, + {"sin", math_sin, METH_O, math_sin_doc}, + {"sinh", math_sinh, METH_O, math_sinh_doc}, + {"sqrt", math_sqrt, METH_O, math_sqrt_doc}, + {"tan", math_tan, METH_O, math_tan_doc}, + {"tanh", math_tanh, METH_O, math_tanh_doc}, {NULL, NULL} /* sentinel */ }; @@ -358,6 +348,8 @@ if (m == NULL) goto finally; d = PyModule_GetDict(m); + if (d == NULL) + goto finally; if (!(v = PyFloat_FromDouble(atan(1.0) * 4.0))) goto finally; Modified: python/branches/p3yk/Modules/mmapmodule.c ============================================================================== --- python/branches/p3yk/Modules/mmapmodule.c (original) +++ python/branches/p3yk/Modules/mmapmodule.c Wed Dec 13 05:49:30 2006 @@ -470,7 +470,7 @@ mmap_tell_method(mmap_object *self, PyObject *unused) { CHECK_VALID(NULL); - return PyInt_FromLong((long) self->pos); + return PyInt_FromSize_t(self->pos); } static PyObject * Modified: python/branches/p3yk/Modules/ossaudiodev.c ============================================================================== --- python/branches/p3yk/Modules/ossaudiodev.c (original) +++ python/branches/p3yk/Modules/ossaudiodev.c Wed Dec 13 05:49:30 2006 @@ -34,7 +34,9 @@ #if defined(linux) +#ifndef HAVE_STDINT_H typedef unsigned long uint32_t; +#endif #elif defined(__FreeBSD__) Modified: python/branches/p3yk/Modules/parsermodule.c ============================================================================== --- python/branches/p3yk/Modules/parsermodule.c (original) +++ python/branches/p3yk/Modules/parsermodule.c Wed Dec 13 05:49:30 2006 @@ -74,7 +74,8 @@ node2tuple(node *n, /* node to convert */ SeqMaker mkseq, /* create sequence */ SeqInserter addelem, /* func. to add elem. in seq. */ - int lineno) /* include line numbers? */ + int lineno, /* include line numbers? */ + int col_offset) /* include column offsets? */ { if (n == NULL) { Py_INCREF(Py_None); @@ -95,7 +96,7 @@ } (void) addelem(v, 0, w); for (i = 0; i < NCH(n); i++) { - w = node2tuple(CHILD(n, i), mkseq, addelem, lineno); + w = node2tuple(CHILD(n, i), mkseq, addelem, lineno, col_offset); if (w == NULL) { Py_DECREF(v); return ((PyObject*) NULL); @@ -108,12 +109,14 @@ return (v); } else if (ISTERMINAL(TYPE(n))) { - PyObject *result = mkseq(2 + lineno); + PyObject *result = mkseq(2 + lineno + col_offset); if (result != NULL) { (void) addelem(result, 0, PyInt_FromLong(TYPE(n))); (void) addelem(result, 1, PyString_FromString(STR(n))); if (lineno == 1) (void) addelem(result, 2, PyInt_FromLong(n->n_lineno)); + if (col_offset == 1) + (void) addelem(result, 3, PyInt_FromLong(n->n_col_offset)); } return (result); } @@ -289,29 +292,35 @@ parser_st2tuple(PyST_Object *self, PyObject *args, PyObject *kw) { PyObject *line_option = 0; + PyObject *col_option = 0; PyObject *res = 0; int ok; - static char *keywords[] = {"ast", "line_info", NULL}; + static char *keywords[] = {"ast", "line_info", "col_info", NULL}; if (self == NULL) { - ok = PyArg_ParseTupleAndKeywords(args, kw, "O!|O:st2tuple", keywords, - &PyST_Type, &self, &line_option); + ok = PyArg_ParseTupleAndKeywords(args, kw, "O!|OO:st2tuple", keywords, + &PyST_Type, &self, &line_option, + &col_option); } else - ok = PyArg_ParseTupleAndKeywords(args, kw, "|O:totuple", &keywords[1], - &line_option); + ok = PyArg_ParseTupleAndKeywords(args, kw, "|OO:totuple", &keywords[1], + &line_option, &col_option); if (ok != 0) { int lineno = 0; + int col_offset = 0; if (line_option != NULL) { lineno = (PyObject_IsTrue(line_option) != 0) ? 1 : 0; } + if (col_option != NULL) { + col_offset = (PyObject_IsTrue(col_option) != 0) ? 1 : 0; + } /* * Convert ST into a tuple representation. Use Guido's function, * since it's known to work already. */ res = node2tuple(((PyST_Object*)self)->st_node, - PyTuple_New, PyTuple_SetItem, lineno); + PyTuple_New, PyTuple_SetItem, lineno, col_offset); } return (res); } @@ -327,28 +336,34 @@ parser_st2list(PyST_Object *self, PyObject *args, PyObject *kw) { PyObject *line_option = 0; + PyObject *col_option = 0; PyObject *res = 0; int ok; - static char *keywords[] = {"ast", "line_info", NULL}; + static char *keywords[] = {"ast", "line_info", "col_info", NULL}; if (self == NULL) - ok = PyArg_ParseTupleAndKeywords(args, kw, "O!|O:st2list", keywords, - &PyST_Type, &self, &line_option); + ok = PyArg_ParseTupleAndKeywords(args, kw, "O!|OO:st2list", keywords, + &PyST_Type, &self, &line_option, + &col_option); else - ok = PyArg_ParseTupleAndKeywords(args, kw, "|O:tolist", &keywords[1], - &line_option); + ok = PyArg_ParseTupleAndKeywords(args, kw, "|OO:tolist", &keywords[1], + &line_option, &col_option); if (ok) { int lineno = 0; + int col_offset = 0; if (line_option != 0) { lineno = PyObject_IsTrue(line_option) ? 1 : 0; } + if (col_option != NULL) { + col_offset = (PyObject_IsTrue(col_option) != 0) ? 1 : 0; + } /* * Convert ST into a tuple representation. Use Guido's function, * since it's known to work already. */ res = node2tuple(self->st_node, - PyList_New, PyList_SetItem, lineno); + PyList_New, PyList_SetItem, lineno, col_offset); } return (res); } Modified: python/branches/p3yk/Modules/posixmodule.c ============================================================================== --- python/branches/p3yk/Modules/posixmodule.c (original) +++ python/branches/p3yk/Modules/posixmodule.c Wed Dec 13 05:49:30 2006 @@ -792,7 +792,7 @@ /* XXX endianness */ __int64 out; out = time_in + secs_between_epochs; - out = out * 10000000 + nsec_in; + out = out * 10000000 + nsec_in / 100; memcpy(out_ptr, &out, sizeof(out)); } @@ -828,6 +828,106 @@ return 0; } +/* Emulate GetFileAttributesEx[AW] on Windows 95 */ +static int checked = 0; +static BOOL (CALLBACK *gfaxa)(LPCSTR, GET_FILEEX_INFO_LEVELS, LPVOID); +static BOOL (CALLBACK *gfaxw)(LPCWSTR, GET_FILEEX_INFO_LEVELS, LPVOID); +static void +check_gfax() +{ + HINSTANCE hKernel32; + if (checked) + return; + checked = 1; + hKernel32 = GetModuleHandle("KERNEL32"); + *(FARPROC*)&gfaxa = GetProcAddress(hKernel32, "GetFileAttributesExA"); + *(FARPROC*)&gfaxw = GetProcAddress(hKernel32, "GetFileAttributesExW"); +} + +static BOOL WINAPI +Py_GetFileAttributesExA(LPCSTR pszFile, + GET_FILEEX_INFO_LEVELS level, + LPVOID pv) +{ + BOOL result; + HANDLE hFindFile; + WIN32_FIND_DATAA FileData; + LPWIN32_FILE_ATTRIBUTE_DATA pfad = pv; + /* First try to use the system's implementation, if that is + available and either succeeds to gives an error other than + that it isn't implemented. */ + check_gfax(); + if (gfaxa) { + result = gfaxa(pszFile, level, pv); + if (result || GetLastError() != ERROR_CALL_NOT_IMPLEMENTED) + return result; + } + /* It's either not present, or not implemented. + Emulate using FindFirstFile. */ + if (level != GetFileExInfoStandard) { + SetLastError(ERROR_INVALID_PARAMETER); + return FALSE; + } + /* Use GetFileAttributes to validate that the file name + does not contain wildcards (which FindFirstFile would + accept). */ + if (GetFileAttributesA(pszFile) == 0xFFFFFFFF) + return FALSE; + hFindFile = FindFirstFileA(pszFile, &FileData); + if (hFindFile == INVALID_HANDLE_VALUE) + return FALSE; + FindClose(hFindFile); + pfad->dwFileAttributes = FileData.dwFileAttributes; + pfad->ftCreationTime = FileData.ftCreationTime; + pfad->ftLastAccessTime = FileData.ftLastAccessTime; + pfad->ftLastWriteTime = FileData.ftLastWriteTime; + pfad->nFileSizeHigh = FileData.nFileSizeHigh; + pfad->nFileSizeLow = FileData.nFileSizeLow; + return TRUE; +} + +static BOOL WINAPI +Py_GetFileAttributesExW(LPCWSTR pszFile, + GET_FILEEX_INFO_LEVELS level, + LPVOID pv) +{ + BOOL result; + HANDLE hFindFile; + WIN32_FIND_DATAW FileData; + LPWIN32_FILE_ATTRIBUTE_DATA pfad = pv; + /* First try to use the system's implementation, if that is + available and either succeeds to gives an error other than + that it isn't implemented. */ + check_gfax(); + if (gfaxa) { + result = gfaxw(pszFile, level, pv); + if (result || GetLastError() != ERROR_CALL_NOT_IMPLEMENTED) + return result; + } + /* It's either not present, or not implemented. + Emulate using FindFirstFile. */ + if (level != GetFileExInfoStandard) { + SetLastError(ERROR_INVALID_PARAMETER); + return FALSE; + } + /* Use GetFileAttributes to validate that the file name + does not contain wildcards (which FindFirstFile would + accept). */ + if (GetFileAttributesW(pszFile) == 0xFFFFFFFF) + return FALSE; + hFindFile = FindFirstFileW(pszFile, &FileData); + if (hFindFile == INVALID_HANDLE_VALUE) + return FALSE; + FindClose(hFindFile); + pfad->dwFileAttributes = FileData.dwFileAttributes; + pfad->ftCreationTime = FileData.ftCreationTime; + pfad->ftLastAccessTime = FileData.ftLastAccessTime; + pfad->ftLastWriteTime = FileData.ftLastWriteTime; + pfad->nFileSizeHigh = FileData.nFileSizeHigh; + pfad->nFileSizeLow = FileData.nFileSizeLow; + return TRUE; +} + static int win32_stat(const char* path, struct win32_stat *result) { @@ -835,7 +935,7 @@ int code; char *dot; /* XXX not supported on Win95 and NT 3.x */ - if (!GetFileAttributesExA(path, GetFileExInfoStandard, &info)) { + if (!Py_GetFileAttributesExA(path, GetFileExInfoStandard, &info)) { /* Protocol violation: we explicitly clear errno, instead of setting it to a POSIX error. Callers should use GetLastError. */ errno = 0; @@ -863,7 +963,7 @@ const wchar_t *dot; WIN32_FILE_ATTRIBUTE_DATA info; /* XXX not supported on Win95 and NT 3.x */ - if (!GetFileAttributesExW(path, GetFileExInfoStandard, &info)) { + if (!Py_GetFileAttributesExW(path, GetFileExInfoStandard, &info)) { /* Protocol violation: we explicitly clear errno, instead of setting it to a POSIX error. Callers should use GetLastError. */ errno = 0; @@ -2458,7 +2558,8 @@ wpath = PyUnicode_AS_UNICODE(obwpath); Py_BEGIN_ALLOW_THREADS hFile = CreateFileW(wpath, FILE_WRITE_ATTRIBUTES, 0, - NULL, OPEN_EXISTING, 0, NULL); + NULL, OPEN_EXISTING, + FILE_FLAG_BACKUP_SEMANTICS, NULL); Py_END_ALLOW_THREADS if (hFile == INVALID_HANDLE_VALUE) return win32_error_unicode("utime", wpath); @@ -2473,7 +2574,8 @@ return NULL; Py_BEGIN_ALLOW_THREADS hFile = CreateFileA(apath, FILE_WRITE_ATTRIBUTES, 0, - NULL, OPEN_EXISTING, 0, NULL); + NULL, OPEN_EXISTING, + FILE_FLAG_BACKUP_SEMANTICS, NULL); Py_END_ALLOW_THREADS if (hFile == INVALID_HANDLE_VALUE) { win32_error("utime", apath); @@ -2501,11 +2603,11 @@ if (extract_time(PyTuple_GET_ITEM(arg, 0), &atimesec, &ausec) == -1) goto done; - time_t_to_FILE_TIME(atimesec, ausec, &atime); + time_t_to_FILE_TIME(atimesec, 1000*ausec, &atime); if (extract_time(PyTuple_GET_ITEM(arg, 1), &mtimesec, &musec) == -1) goto done; - time_t_to_FILE_TIME(mtimesec, musec, &mtime); + time_t_to_FILE_TIME(mtimesec, 1000*musec, &mtime); } if (!SetFileTime(hFile, NULL, &atime, &mtime)) { /* Avoid putting the file name into the error here, @@ -5585,17 +5687,53 @@ static PyObject * posix_readlink(PyObject *self, PyObject *args) { + PyObject* v; char buf[MAXPATHLEN]; char *path; int n; - if (!PyArg_ParseTuple(args, "s:readlink", &path)) +#ifdef Py_USING_UNICODE + int arg_is_unicode = 0; +#endif + + if (!PyArg_ParseTuple(args, "et:readlink", + Py_FileSystemDefaultEncoding, &path)) return NULL; +#ifdef Py_USING_UNICODE + v = PySequence_GetItem(args, 0); + if (v == NULL) return NULL; + + if (PyUnicode_Check(v)) { + arg_is_unicode = 1; + } + Py_DECREF(v); +#endif + Py_BEGIN_ALLOW_THREADS n = readlink(path, buf, (int) sizeof buf); Py_END_ALLOW_THREADS if (n < 0) return posix_error_with_filename(path); - return PyString_FromStringAndSize(buf, n); + + v = PyString_FromStringAndSize(buf, n); +#ifdef Py_USING_UNICODE + if (arg_is_unicode) { + PyObject *w; + + w = PyUnicode_FromEncodedObject(v, + Py_FileSystemDefaultEncoding, + "strict"); + if (w != NULL) { + Py_DECREF(v); + v = w; + } + else { + /* fall back to the original byte string, as + discussed in patch #683592 */ + PyErr_Clear(); + } + } +#endif + return v; } #endif /* HAVE_READLINK */ @@ -7877,7 +8015,7 @@ pCryptGenRandom = (CRYPTGENRANDOM)GetProcAddress( hAdvAPI32, "CryptGenRandom"); - if (pCryptAcquireContext == NULL) + if (pCryptGenRandom == NULL) return PyErr_Format(PyExc_NotImplementedError, "CryptGenRandom not found"); @@ -8617,3 +8755,4 @@ } #endif + Modified: python/branches/p3yk/Modules/readline.c ============================================================================== --- python/branches/p3yk/Modules/readline.c (original) +++ python/branches/p3yk/Modules/readline.c Wed Dec 13 05:49:30 2006 @@ -768,10 +768,16 @@ while (!has_input) { struct timeval timeout = {0, 100000}; /* 0.1 seconds */ + + /* [Bug #1552726] Only limit the pause if an input hook has been + defined. */ + struct timeval *timeoutp = NULL; + if (PyOS_InputHook) + timeoutp = &timeout; FD_SET(fileno(rl_instream), &selectset); /* select resets selectset if no input was available */ has_input = select(fileno(rl_instream) + 1, &selectset, - NULL, NULL, &timeout); + NULL, NULL, timeoutp); if(PyOS_InputHook) PyOS_InputHook(); } Modified: python/branches/p3yk/Modules/resource.c ============================================================================== --- python/branches/p3yk/Modules/resource.c (original) +++ python/branches/p3yk/Modules/resource.c Wed Dec 13 05:49:30 2006 @@ -298,6 +298,10 @@ PyModule_AddIntConstant(m, "RLIMIT_MEMLOCK", RLIMIT_MEMLOCK); #endif +#ifdef RLIMIT_SBSIZE + PyModule_AddIntConstant(m, "RLIMIT_SBSIZE", RLIMIT_SBSIZE); +#endif + #ifdef RUSAGE_SELF PyModule_AddIntConstant(m, "RUSAGE_SELF", RUSAGE_SELF); #endif Modified: python/branches/p3yk/Modules/socketmodule.c ============================================================================== --- python/branches/p3yk/Modules/socketmodule.c (original) +++ python/branches/p3yk/Modules/socketmodule.c Wed Dec 13 05:49:30 2006 @@ -364,19 +364,16 @@ #define BTPROTO_RFCOMM BLUETOOTH_PROTO_RFCOMM #define sockaddr_l2 sockaddr_l2cap #define sockaddr_rc sockaddr_rfcomm -#define _BT_SOCKADDR_MEMB(s, proto) &((s)->sock_addr) #define _BT_L2_MEMB(sa, memb) ((sa)->l2cap_##memb) #define _BT_RC_MEMB(sa, memb) ((sa)->rfcomm_##memb) #elif defined(__NetBSD__) #define sockaddr_l2 sockaddr_bt #define sockaddr_rc sockaddr_bt #define sockaddr_sco sockaddr_bt -#define _BT_SOCKADDR_MEMB(s, proto) &((s)->sock_addr) #define _BT_L2_MEMB(sa, memb) ((sa)->bt_##memb) #define _BT_RC_MEMB(sa, memb) ((sa)->bt_##memb) #define _BT_SCO_MEMB(sa, memb) ((sa)->bt_##memb) #else -#define _BT_SOCKADDR_MEMB(s, proto) (&((s)->sock_addr).bt_##proto) #define _BT_L2_MEMB(sa, memb) ((sa)->l2_##memb) #define _BT_RC_MEMB(sa, memb) ((sa)->rc_##memb) #define _BT_SCO_MEMB(sa, memb) ((sa)->sco_##memb) @@ -388,6 +385,8 @@ #define SEGMENT_SIZE (32 * 1024 -1) #endif +#define SAS2SA(x) ((struct sockaddr *)(x)) + /* * Constants for getnameinfo() */ @@ -1174,7 +1173,7 @@ static int getsockaddrarg(PySocketSockObject *s, PyObject *args, - struct sockaddr **addr_ret, int *len_ret) + struct sockaddr *addr_ret, int *len_ret) { switch (s->sock_family) { @@ -1184,9 +1183,10 @@ struct sockaddr_un* addr; char *path; int len; - addr = (struct sockaddr_un*)&(s->sock_addr).un; if (!PyArg_Parse(args, "t#", &path, &len)) return 0; + + addr = (struct sockaddr_un*)addr_ret; #ifdef linux if (len > 0 && path[0] == 0) { /* Linux abstract namespace extension */ @@ -1209,7 +1209,6 @@ } addr->sun_family = s->sock_family; memcpy(addr->sun_path, path, len); - *addr_ret = (struct sockaddr *) addr; #if defined(PYOS_OS2) *len_ret = sizeof(*addr); #else @@ -1224,7 +1223,7 @@ { struct sockaddr_nl* addr; int pid, groups; - addr = (struct sockaddr_nl *)&(s->sock_addr).nl; + addr = (struct sockaddr_nl *)addr_ret; if (!PyTuple_Check(args)) { PyErr_Format( PyExc_TypeError, @@ -1238,7 +1237,6 @@ addr->nl_family = AF_NETLINK; addr->nl_pid = pid; addr->nl_groups = groups; - *addr_ret = (struct sockaddr *) addr; *len_ret = sizeof(*addr); return 1; } @@ -1249,7 +1247,6 @@ struct sockaddr_in* addr; char *host; int port, result; - addr=(struct sockaddr_in*)&(s->sock_addr).in; if (!PyTuple_Check(args)) { PyErr_Format( PyExc_TypeError, @@ -1261,6 +1258,7 @@ if (!PyArg_ParseTuple(args, "eti:getsockaddrarg", "idna", &host, &port)) return 0; + addr=(struct sockaddr_in*)addr_ret; result = setipaddr(host, (struct sockaddr *)addr, sizeof(*addr), AF_INET); PyMem_Free(host); @@ -1268,7 +1266,6 @@ return 0; addr->sin_family = AF_INET; addr->sin_port = htons((short)port); - *addr_ret = (struct sockaddr *) addr; *len_ret = sizeof *addr; return 1; } @@ -1279,7 +1276,6 @@ struct sockaddr_in6* addr; char *host; int port, flowinfo, scope_id, result; - addr = (struct sockaddr_in6*)&(s->sock_addr).in6; flowinfo = scope_id = 0; if (!PyTuple_Check(args)) { PyErr_Format( @@ -1294,6 +1290,7 @@ &scope_id)) { return 0; } + addr = (struct sockaddr_in6*)addr_ret; result = setipaddr(host, (struct sockaddr *)addr, sizeof(*addr), AF_INET6); PyMem_Free(host); @@ -1303,7 +1300,6 @@ addr->sin6_port = htons((short)port); addr->sin6_flowinfo = flowinfo; addr->sin6_scope_id = scope_id; - *addr_ret = (struct sockaddr *) addr; *len_ret = sizeof *addr; return 1; } @@ -1315,9 +1311,10 @@ switch (s->sock_proto) { case BTPROTO_L2CAP: { - struct sockaddr_l2 *addr = (struct sockaddr_l2 *) _BT_SOCKADDR_MEMB(s, l2); + struct sockaddr_l2 *addr; char *straddr; + addr = (struct sockaddr_l2 *)addr_ret; _BT_L2_MEMB(addr, family) = AF_BLUETOOTH; if (!PyArg_ParseTuple(args, "si", &straddr, &_BT_L2_MEMB(addr, psm))) { @@ -1328,15 +1325,15 @@ if (setbdaddr(straddr, &_BT_L2_MEMB(addr, bdaddr)) < 0) return 0; - *addr_ret = (struct sockaddr *) addr; *len_ret = sizeof *addr; return 1; } case BTPROTO_RFCOMM: { - struct sockaddr_rc *addr = (struct sockaddr_rc *) _BT_SOCKADDR_MEMB(s, rc); + struct sockaddr_rc *addr; char *straddr; + addr = (struct sockaddr_rc *)addr_ret; _BT_RC_MEMB(addr, family) = AF_BLUETOOTH; if (!PyArg_ParseTuple(args, "si", &straddr, &_BT_RC_MEMB(addr, channel))) { @@ -1347,16 +1344,16 @@ if (setbdaddr(straddr, &_BT_RC_MEMB(addr, bdaddr)) < 0) return 0; - *addr_ret = (struct sockaddr *) addr; *len_ret = sizeof *addr; return 1; } #if !defined(__FreeBSD__) case BTPROTO_SCO: { - struct sockaddr_sco *addr = (struct sockaddr_sco *) _BT_SOCKADDR_MEMB(s, sco); + struct sockaddr_sco *addr; char *straddr; + addr = (struct sockaddr_sco *)addr_ret; _BT_SCO_MEMB(addr, family) = AF_BLUETOOTH; straddr = PyString_AsString(args); if (straddr == NULL) { @@ -1367,7 +1364,6 @@ if (setbdaddr(straddr, &_BT_SCO_MEMB(addr, bdaddr)) < 0) return 0; - *addr_ret = (struct sockaddr *) addr; *len_ret = sizeof *addr; return 1; } @@ -1409,22 +1405,21 @@ s->errorhandler(); return 0; } - addr = &(s->sock_addr.ll); - addr->sll_family = AF_PACKET; - addr->sll_protocol = htons((short)protoNumber); - addr->sll_ifindex = ifr.ifr_ifindex; - addr->sll_pkttype = pkttype; - addr->sll_hatype = hatype; if (halen > 8) { PyErr_SetString(PyExc_ValueError, "Hardware address must be 8 bytes or less"); return 0; } + addr = (struct sockaddr_ll*)addr_ret; + addr->sll_family = AF_PACKET; + addr->sll_protocol = htons((short)protoNumber); + addr->sll_ifindex = ifr.ifr_ifindex; + addr->sll_pkttype = pkttype; + addr->sll_hatype = hatype; if (halen != 0) { memcpy(&addr->sll_addr, haddr, halen); } addr->sll_halen = halen; - *addr_ret = (struct sockaddr *) addr; *len_ret = sizeof *addr; return 1; } @@ -1551,8 +1546,7 @@ Py_BEGIN_ALLOW_THREADS timeout = internal_select(s, 0); if (!timeout) - newfd = accept(s->sock_fd, (struct sockaddr *) &addrbuf, - &addrlen); + newfd = accept(s->sock_fd, SAS2SA(&addrbuf), &addrlen); Py_END_ALLOW_THREADS if (timeout == 1) { @@ -1578,7 +1572,7 @@ SOCKETCLOSE(newfd); goto finally; } - addr = makesockaddr(s->sock_fd, (struct sockaddr *) &addrbuf, + addr = makesockaddr(s->sock_fd, SAS2SA(&addrbuf), addrlen, s->sock_proto); if (addr == NULL) goto finally; @@ -1819,14 +1813,14 @@ static PyObject * sock_bind(PySocketSockObject *s, PyObject *addro) { - struct sockaddr *addr; + sock_addr_t addrbuf; int addrlen; int res; - if (!getsockaddrarg(s, addro, &addr, &addrlen)) + if (!getsockaddrarg(s, addro, SAS2SA(&addrbuf), &addrlen)) return NULL; Py_BEGIN_ALLOW_THREADS - res = bind(s->sock_fd, addr, addrlen); + res = bind(s->sock_fd, SAS2SA(&addrbuf), addrlen); Py_END_ALLOW_THREADS if (res < 0) return s->errorhandler(); @@ -1952,16 +1946,16 @@ static PyObject * sock_connect(PySocketSockObject *s, PyObject *addro) { - struct sockaddr *addr; + sock_addr_t addrbuf; int addrlen; int res; int timeout; - if (!getsockaddrarg(s, addro, &addr, &addrlen)) + if (!getsockaddrarg(s, addro, SAS2SA(&addrbuf), &addrlen)) return NULL; Py_BEGIN_ALLOW_THREADS - res = internal_connect(s, addr, addrlen, &timeout); + res = internal_connect(s, SAS2SA(&addrbuf), addrlen, &timeout); Py_END_ALLOW_THREADS if (timeout == 1) { @@ -1986,16 +1980,16 @@ static PyObject * sock_connect_ex(PySocketSockObject *s, PyObject *addro) { - struct sockaddr *addr; + sock_addr_t addrbuf; int addrlen; int res; int timeout; - if (!getsockaddrarg(s, addro, &addr, &addrlen)) + if (!getsockaddrarg(s, addro, SAS2SA(&addrbuf), &addrlen)) return NULL; Py_BEGIN_ALLOW_THREADS - res = internal_connect(s, addr, addrlen, &timeout); + res = internal_connect(s, SAS2SA(&addrbuf), addrlen, &timeout); Py_END_ALLOW_THREADS /* Signals are not errors (though they may raise exceptions). Adapted @@ -2075,11 +2069,11 @@ return NULL; memset(&addrbuf, 0, addrlen); Py_BEGIN_ALLOW_THREADS - res = getsockname(s->sock_fd, (struct sockaddr *) &addrbuf, &addrlen); + res = getsockname(s->sock_fd, SAS2SA(&addrbuf), &addrlen); Py_END_ALLOW_THREADS if (res < 0) return s->errorhandler(); - return makesockaddr(s->sock_fd, (struct sockaddr *) &addrbuf, addrlen, + return makesockaddr(s->sock_fd, SAS2SA(&addrbuf), addrlen, s->sock_proto); } @@ -2104,11 +2098,11 @@ return NULL; memset(&addrbuf, 0, addrlen); Py_BEGIN_ALLOW_THREADS - res = getpeername(s->sock_fd, (struct sockaddr *) &addrbuf, &addrlen); + res = getpeername(s->sock_fd, SAS2SA(&addrbuf), &addrlen); Py_END_ALLOW_THREADS if (res < 0) return s->errorhandler(); - return makesockaddr(s->sock_fd, (struct sockaddr *) &addrbuf, addrlen, + return makesockaddr(s->sock_fd, SAS2SA(&addrbuf), addrlen, s->sock_proto); } @@ -2443,14 +2437,14 @@ #ifndef MS_WINDOWS #if defined(PYOS_OS2) && !defined(PYCC_GCC) n = recvfrom(s->sock_fd, cbuf, len, flags, - (struct sockaddr *) &addrbuf, &addrlen); + SAS2SA(&addrbuf), &addrlen); #else n = recvfrom(s->sock_fd, cbuf, len, flags, (void *) &addrbuf, &addrlen); #endif #else n = recvfrom(s->sock_fd, cbuf, len, flags, - (struct sockaddr *) &addrbuf, &addrlen); + SAS2SA(&addrbuf), &addrlen); #endif } Py_END_ALLOW_THREADS @@ -2464,7 +2458,7 @@ return -1; } - if (!(*addr = makesockaddr(s->sock_fd, (struct sockaddr *) &addrbuf, + if (!(*addr = makesockaddr(s->sock_fd, SAS2SA(&addrbuf), addrlen, s->sock_proto))) return -1; @@ -2664,7 +2658,7 @@ { PyObject *addro; char *buf; - struct sockaddr *addr; + sock_addr_t addrbuf; int addrlen, len, n = -1, flags, timeout; flags = 0; @@ -2675,16 +2669,16 @@ return NULL; } - if (!getsockaddrarg(s, addro, &addr, &addrlen)) - return NULL; - if (!IS_SELECTABLE(s)) return select_error(); + if (!getsockaddrarg(s, addro, SAS2SA(&addrbuf), &addrlen)) + return NULL; + Py_BEGIN_ALLOW_THREADS timeout = internal_select(s, 1); if (!timeout) - n = sendto(s->sock_fd, buf, len, flags, addr, addrlen); + n = sendto(s->sock_fd, buf, len, flags, SAS2SA(&addrbuf), addrlen); Py_END_ALLOW_THREADS if (timeout == 1) { @@ -2973,10 +2967,9 @@ if (!PyArg_ParseTuple(args, "s:gethostbyname", &name)) return NULL; - if (setipaddr(name, (struct sockaddr *)&addrbuf, sizeof(addrbuf), AF_INET) < 0) + if (setipaddr(name, SAS2SA(&addrbuf), sizeof(addrbuf), AF_INET) < 0) return NULL; - return makeipaddr((struct sockaddr *)&addrbuf, - sizeof(struct sockaddr_in)); + return makeipaddr(SAS2SA(&addrbuf), sizeof(struct sockaddr_in)); } PyDoc_STRVAR(gethostbyname_doc, Modified: python/branches/p3yk/Modules/socketmodule.h ============================================================================== --- python/branches/p3yk/Modules/socketmodule.h (original) +++ python/branches/p3yk/Modules/socketmodule.h Wed Dec 13 05:49:30 2006 @@ -114,7 +114,6 @@ int sock_family; /* Address family, e.g., AF_INET */ int sock_type; /* Socket type, e.g., SOCK_STREAM */ int sock_proto; /* Protocol type, usually 0 */ - sock_addr_t sock_addr; /* Socket address */ PyObject *(*errorhandler)(void); /* Error handler; checks errno, returns NULL and sets a Python exception */ Modified: python/branches/p3yk/Modules/threadmodule.c ============================================================================== --- python/branches/p3yk/Modules/threadmodule.c (original) +++ python/branches/p3yk/Modules/threadmodule.c Wed Dec 13 05:49:30 2006 @@ -25,6 +25,7 @@ static void lock_dealloc(lockobject *self) { + assert(self->lock_lock); /* Unlock the lock so it's safe to free it */ PyThread_acquire_lock(self->lock_lock, 0); PyThread_release_lock(self->lock_lock); Modified: python/branches/p3yk/Modules/unicodedata.c ============================================================================== --- python/branches/p3yk/Modules/unicodedata.c (original) +++ python/branches/p3yk/Modules/unicodedata.c Wed Dec 13 05:49:30 2006 @@ -75,7 +75,7 @@ {NULL} }; -// forward declaration +/* forward declaration */ static PyTypeObject UCD_Type; static PyObject* Modified: python/branches/p3yk/Objects/abstract.c ============================================================================== --- python/branches/p3yk/Objects/abstract.c (original) +++ python/branches/p3yk/Objects/abstract.c Wed Dec 13 05:49:30 2006 @@ -1524,20 +1524,18 @@ if (cmp > 0) { switch (operation) { case PY_ITERSEARCH_COUNT: - ++n; - if (n <= 0) { - /* XXX(nnorwitz): int means ssize_t */ + if (n == PY_SSIZE_T_MAX) { PyErr_SetString(PyExc_OverflowError, - "count exceeds C int size"); + "count exceeds C integer size"); goto Fail; } + ++n; break; case PY_ITERSEARCH_INDEX: if (wrapped) { - /* XXX(nnorwitz): int means ssize_t */ PyErr_SetString(PyExc_OverflowError, - "index exceeds C int size"); + "index exceeds C integer size"); goto Fail; } goto Done; @@ -1552,9 +1550,9 @@ } if (operation == PY_ITERSEARCH_INDEX) { - ++n; - if (n <= 0) + if (n == PY_SSIZE_T_MAX) wrapped = 1; + ++n; } } Modified: python/branches/p3yk/Objects/classobject.c ============================================================================== --- python/branches/p3yk/Objects/classobject.c (original) +++ python/branches/p3yk/Objects/classobject.c Wed Dec 13 05:49:30 2006 @@ -152,6 +152,8 @@ PyObject *self; PyObject *classObj = NULL; + if (!_PyArg_NoKeywords("instancemethod", kw)) + return NULL; if (!PyArg_UnpackTuple(args, "method", 2, 3, &func, &self, &classObj)) return NULL; Modified: python/branches/p3yk/Objects/dictobject.c ============================================================================== --- python/branches/p3yk/Objects/dictobject.c (original) +++ python/branches/p3yk/Objects/dictobject.c Wed Dec 13 05:49:30 2006 @@ -12,6 +12,20 @@ typedef PyDictEntry dictentry; typedef PyDictObject dictobject; +/* Set a key error with the specified argument, wrapping it in a + * tuple automatically so that tuple keys are not unpacked as the + * exception arguments. */ +static void +set_key_error(PyObject *arg) +{ + PyObject *tup; + tup = PyTuple_Pack(1, arg); + if (!tup) + return; /* caller will expect error to be set anyway */ + PyErr_SetObject(PyExc_KeyError, tup); + Py_DECREF(tup); +} + /* Define this out if you don't want conversion statistics on exit. */ #undef SHOW_CONVERSION_COUNTS @@ -307,6 +321,8 @@ else if (ep->me_key == dummy && freeslot == NULL) freeslot = ep; } + assert(0); /* NOT REACHED */ + return 0; } /* @@ -366,6 +382,8 @@ if (ep->me_key == dummy && freeslot == NULL) freeslot = ep; } + assert(0); /* NOT REACHED */ + return 0; } /* @@ -691,7 +709,7 @@ if (ep == NULL) return -1; if (ep->me_value == NULL) { - PyErr_SetObject(PyExc_KeyError, key); + set_key_error(key); return -1; } old_key = ep->me_key; @@ -1000,7 +1018,7 @@ return PyObject_CallFunctionObjArgs(missing, (PyObject *)mp, key, NULL); } - PyErr_SetObject(PyExc_KeyError, key); + set_key_error(key); return NULL; } else @@ -1644,7 +1662,7 @@ Py_INCREF(deflt); return deflt; } - PyErr_SetObject(PyExc_KeyError, key); + set_key_error(key); return NULL; } old_key = ep->me_key; Modified: python/branches/p3yk/Objects/exceptions.c ============================================================================== --- python/branches/p3yk/Objects/exceptions.c (original) +++ python/branches/p3yk/Objects/exceptions.c Wed Dec 13 05:49:30 2006 @@ -81,6 +81,7 @@ static void BaseException_dealloc(PyBaseExceptionObject *self) { + _PyObject_GC_UNTRACK(self); BaseException_clear(self); self->ob_type->tp_free((PyObject *)self); } @@ -174,27 +175,10 @@ Py_RETURN_NONE; } -#ifdef Py_USING_UNICODE -/* while this method generates fairly uninspired output, it a least - * guarantees that we can display exceptions that have unicode attributes - */ -static PyObject * -BaseException_unicode(PyBaseExceptionObject *self) -{ - if (PyTuple_GET_SIZE(self->args) == 0) - return PyUnicode_FromUnicode(NULL, 0); - if (PyTuple_GET_SIZE(self->args) == 1) - return PyObject_Unicode(PyTuple_GET_ITEM(self->args, 0)); - return PyObject_Unicode(self->args); -} -#endif /* Py_USING_UNICODE */ static PyMethodDef BaseException_methods[] = { {"__reduce__", (PyCFunction)BaseException_reduce, METH_NOARGS }, {"__setstate__", (PyCFunction)BaseException_setstate, METH_O }, -#ifdef Py_USING_UNICODE - {"__unicode__", (PyCFunction)BaseException_unicode, METH_NOARGS }, -#endif {NULL, NULL, 0, NULL}, }; @@ -206,12 +190,19 @@ return PySequence_GetItem(self->args, index); } +static PyObject * +BaseException_getslice(PyBaseExceptionObject *self, + Py_ssize_t start, Py_ssize_t stop) +{ + return PySequence_GetSlice(self->args, start, stop); +} + static PySequenceMethods BaseException_as_sequence = { 0, /* sq_length; */ 0, /* sq_concat; */ 0, /* sq_repeat; */ (ssizeargfunc)BaseException_getitem, /* sq_item; */ - 0, /* sq_slice; */ + (ssizessizeargfunc)BaseException_getslice, /* sq_slice; */ 0, /* sq_ass_item; */ 0, /* sq_ass_slice; */ 0, /* sq_contains; */ @@ -456,6 +447,7 @@ static void SystemExit_dealloc(PySystemExitObject *self) { + _PyObject_GC_UNTRACK(self); SystemExit_clear(self); self->ob_type->tp_free((PyObject *)self); } @@ -518,7 +510,7 @@ if (BaseException_init((PyBaseExceptionObject *)self, args, kwds) == -1) return -1; - if (PyTuple_GET_SIZE(args) <= 1) { + if (PyTuple_GET_SIZE(args) <= 1 || PyTuple_GET_SIZE(args) > 3) { return 0; } @@ -562,6 +554,7 @@ static void EnvironmentError_dealloc(PyEnvironmentErrorObject *self) { + _PyObject_GC_UNTRACK(self); EnvironmentError_clear(self); self->ob_type->tp_free((PyObject *)self); } @@ -760,6 +753,7 @@ static void WindowsError_dealloc(PyWindowsErrorObject *self) { + _PyObject_GC_UNTRACK(self); WindowsError_clear(self); self->ob_type->tp_free((PyObject *)self); } @@ -834,9 +828,9 @@ return NULL; } - if (self->myerrno) { - Py_INCREF(self->myerrno); - PyTuple_SET_ITEM(tuple, 0, self->myerrno); + if (self->winerror) { + Py_INCREF(self->winerror); + PyTuple_SET_ITEM(tuple, 0, self->winerror); } else { Py_INCREF(Py_None); @@ -858,7 +852,7 @@ Py_DECREF(fmt); Py_DECREF(tuple); } - else if (self->myerrno && self->strerror) { + else if (self->winerror && self->strerror) { PyObject *fmt; PyObject *tuple; @@ -872,9 +866,9 @@ return NULL; } - if (self->myerrno) { - Py_INCREF(self->myerrno); - PyTuple_SET_ITEM(tuple, 0, self->myerrno); + if (self->winerror) { + Py_INCREF(self->winerror); + PyTuple_SET_ITEM(tuple, 0, self->winerror); } else { Py_INCREF(Py_None); @@ -1035,6 +1029,7 @@ static void SyntaxError_dealloc(PySyntaxErrorObject *self) { + _PyObject_GC_UNTRACK(self); SyntaxError_clear(self); self->ob_type->tp_free((PyObject *)self); } @@ -1551,6 +1546,7 @@ static void UnicodeError_dealloc(PyUnicodeErrorObject *self) { + _PyObject_GC_UNTRACK(self); UnicodeError_clear(self); self->ob_type->tp_free((PyObject *)self); } @@ -1637,7 +1633,7 @@ static PyTypeObject _PyExc_UnicodeEncodeError = { PyObject_HEAD_INIT(NULL) 0, - "UnicodeEncodeError", + EXC_MODULE_NAME "UnicodeEncodeError", sizeof(PyUnicodeErrorObject), 0, (destructor)UnicodeError_dealloc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, (reprfunc)UnicodeEncodeError_str, 0, 0, 0, @@ -1812,7 +1808,7 @@ (destructor)UnicodeError_dealloc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, (reprfunc)UnicodeTranslateError_str, 0, 0, 0, Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE | Py_TPFLAGS_HAVE_GC, - PyDoc_STR("Unicode decoding error."), (traverseproc)UnicodeError_traverse, + PyDoc_STR("Unicode translation error."), (traverseproc)UnicodeError_traverse, (inquiry)UnicodeError_clear, 0, 0, 0, 0, 0, UnicodeError_members, 0, &_PyExc_UnicodeError, 0, 0, 0, offsetof(PyUnicodeErrorObject, dict), (initproc)UnicodeTranslateError_init, 0, BaseException_new, Modified: python/branches/p3yk/Objects/fileobject.c ============================================================================== --- python/branches/p3yk/Objects/fileobject.c (original) +++ python/branches/p3yk/Objects/fileobject.c Wed Dec 13 05:49:30 2006 @@ -540,7 +540,7 @@ int whence; int ret; Py_off_t offset; - PyObject *offobj; + PyObject *offobj, *off_index; if (f->f_fp == NULL) return err_closed(); @@ -548,12 +548,25 @@ whence = 0; if (!PyArg_ParseTuple(args, "O|i:seek", &offobj, &whence)) return NULL; + off_index = PyNumber_Index(offobj); + if (!off_index) { + if (!PyFloat_Check(offobj)) + return NULL; + /* Deprecated in 2.6 */ + PyErr_Clear(); + if (PyErr_Warn(PyExc_DeprecationWarning, + "integer argument expected, got float")) + return NULL; + off_index = offobj; + Py_INCREF(offobj); + } #if !defined(HAVE_LARGEFILE_SUPPORT) - offset = PyInt_AsLong(offobj); + offset = PyInt_AsLong(off_index); #else - offset = PyLong_Check(offobj) ? - PyLong_AsLongLong(offobj) : PyInt_AsLong(offobj); + offset = PyLong_Check(off_index) ? + PyLong_AsLongLong(off_index) : PyInt_AsLong(off_index); #endif + Py_DECREF(off_index); if (PyErr_Occurred()) return NULL; @@ -927,7 +940,7 @@ ndone += nnow; ntodo -= nnow; } - return PyInt_FromLong((long)ndone); + return PyInt_FromSsize_t(ndone); } /************************************************************************** @@ -1006,6 +1019,7 @@ size_t nfree; /* # of free buffer slots; pvend-pvfree */ size_t total_v_size; /* total # of slots in buffer */ size_t increment; /* amount to increment the buffer */ + size_t prev_v_size; /* Optimize for normal case: avoid _PyString_Resize if at all * possible via first reading into stack buffer "buf". @@ -1120,8 +1134,11 @@ /* expand buffer and try again */ assert(*(pvend-1) == '\0'); increment = total_v_size >> 2; /* mild exponential growth */ + prev_v_size = total_v_size; total_v_size += increment; - if (total_v_size > PY_SSIZE_T_MAX) { + /* check for overflow */ + if (total_v_size <= prev_v_size || + total_v_size > PY_SSIZE_T_MAX) { PyErr_SetString(PyExc_OverflowError, "line is longer than a Python string can hold"); Py_DECREF(v); @@ -1130,7 +1147,7 @@ if (_PyString_Resize(&v, (int)total_v_size) < 0) return NULL; /* overwrite the trailing null byte */ - pvfree = BUF(v) + (total_v_size - increment - 1); + pvfree = BUF(v) + (prev_v_size - 1); } if (BUF(v) + total_v_size != p) _PyString_Resize(&v, p - BUF(v)); @@ -2014,7 +2031,7 @@ if (!PyArg_ParseTupleAndKeywords(args, kwds, "O|si:file", kwlist, &o_name, &mode, &bufsize)) - return -1; + goto Error; if (fill_file_fields(foself, NULL, o_name, mode, fclose) == NULL) Modified: python/branches/p3yk/Objects/intobject.c ============================================================================== --- python/branches/p3yk/Objects/intobject.c (original) +++ python/branches/p3yk/Objects/intobject.c Wed Dec 13 05:49:30 2006 @@ -557,6 +557,17 @@ } } +/* Integer overflow checking for unary negation: on a 2's-complement + * box, -x overflows iff x is the most negative long. In this case we + * get -x == x. However, -x is undefined (by C) if x /is/ the most + * negative long (it's a signed overflow case), and some compilers care. + * So we cast x to unsigned long first. However, then other compilers + * warn about applying unary minus to an unsigned operand. Hence the + * weird "0-". + */ +#define UNARY_NEG_WOULD_OVERFLOW(x) \ + ((x) < 0 && (unsigned long)(x) == 0-(unsigned long)(x)) + /* Return type of i_divmod */ enum divmod_result { DIVMOD_OK, /* Correct result */ @@ -576,7 +587,7 @@ return DIVMOD_ERROR; } /* (-sys.maxint-1)/-1 is the only overflow case. */ - if (y == -1 && x < 0 && x == -x) + if (y == -1 && UNARY_NEG_WOULD_OVERFLOW(x)) return DIVMOD_OVERFLOW; xdivy = x / y; xmody = x - xdivy * y; @@ -744,10 +755,10 @@ static PyObject * int_neg(PyIntObject *v) { - register long a, x; + register long a; a = v->ob_ival; - x = -a; - if (a < 0 && x < 0) { + /* check for overflow */ + if (UNARY_NEG_WOULD_OVERFLOW(a)) { PyObject *o = PyLong_FromLong(a); if (o != NULL) { PyObject *result = PyNumber_Negative(o); @@ -756,7 +767,7 @@ } return NULL; } - return PyInt_FromLong(x); + return PyInt_FromLong(-a); } static PyObject * @@ -955,8 +966,25 @@ return PyInt_FromLong(0L); if (base == -909) return PyNumber_Int(x); - if (PyString_Check(x)) - return PyInt_FromString(PyString_AS_STRING(x), NULL, base); + if (PyString_Check(x)) { + /* Since PyInt_FromString doesn't have a length parameter, + * check here for possible NULs in the string. */ + char *string = PyString_AS_STRING(x); + if (strlen(string) != PyString_Size(x)) { + /* create a repr() of the input string, + * just like PyInt_FromString does */ + PyObject *srepr; + srepr = PyObject_Repr(x); + if (srepr == NULL) + return NULL; + PyErr_Format(PyExc_ValueError, + "invalid literal for int() with base %d: %s", + base, PyString_AS_STRING(srepr)); + Py_DECREF(srepr); + return NULL; + } + return PyInt_FromString(string, NULL, base); + } #ifdef Py_USING_UNICODE if (PyUnicode_Check(x)) return PyInt_FromUnicode(PyUnicode_AS_UNICODE(x), Modified: python/branches/p3yk/Objects/listobject.c ============================================================================== --- python/branches/p3yk/Objects/listobject.c (original) +++ python/branches/p3yk/Objects/listobject.c Wed Dec 13 05:49:30 2006 @@ -863,17 +863,12 @@ listpop(PyListObject *self, PyObject *args) { Py_ssize_t i = -1; - PyObject *v, *arg = NULL; + PyObject *v; int status; - if (!PyArg_UnpackTuple(args, "pop", 0, 1, &arg)) + if (!PyArg_ParseTuple(args, "|n:pop", &i)) return NULL; - if (arg != NULL) { - if (PyInt_Check(arg)) - i = PyInt_AS_LONG((PyIntObject*) arg); - else if (!PyArg_ParseTuple(args, "|n:pop", &i)) - return NULL; - } + if (self->ob_size == 0) { /* Special-case most common failure cause */ PyErr_SetString(PyExc_IndexError, "pop from empty list"); @@ -951,9 +946,10 @@ if (res == NULL) return -1; if (!PyInt_Check(res)) { + PyErr_Format(PyExc_TypeError, + "comparison function must return int, not %.200s", + res->ob_type->tp_name); Py_DECREF(res); - PyErr_SetString(PyExc_TypeError, - "comparison function must return int"); return -1; } i = PyInt_AsLong(res); @@ -2507,8 +2503,9 @@ } } else { - PyErr_SetString(PyExc_TypeError, - "list indices must be integers"); + PyErr_Format(PyExc_TypeError, + "list indices must be integers, not %.200s", + item->ob_type->tp_name); return NULL; } } @@ -2624,6 +2621,11 @@ garbage = (PyObject**) PyMem_MALLOC(slicelength*sizeof(PyObject*)); + if (!garbage) { + Py_DECREF(seq); + PyErr_NoMemory(); + return -1; + } selfitems = self->ob_item; seqitems = PySequence_Fast_ITEMS(seq); @@ -2646,8 +2648,9 @@ } } else { - PyErr_SetString(PyExc_TypeError, - "list indices must be integers"); + PyErr_Format(PyExc_TypeError, + "list indices must be integers, not %.200s", + item->ob_type->tp_name); return -1; } } Modified: python/branches/p3yk/Objects/longobject.c ============================================================================== --- python/branches/p3yk/Objects/longobject.c (original) +++ python/branches/p3yk/Objects/longobject.c Wed Dec 13 05:49:30 2006 @@ -191,6 +191,18 @@ return (PyObject *)v; } +/* Checking for overflow in PyLong_AsLong is a PITA since C doesn't define + * anything about what happens when a signed integer operation overflows, + * and some compilers think they're doing you a favor by being "clever" + * then. The bit pattern for the largest postive signed long is + * (unsigned long)LONG_MAX, and for the smallest negative signed long + * it is abs(LONG_MIN), which we could write -(unsigned long)LONG_MIN. + * However, some other compilers warn about applying unary minus to an + * unsigned operand. Hence the weird "0-". + */ +#define PY_ABS_LONG_MIN (0-(unsigned long)LONG_MIN) +#define PY_ABS_SSIZE_T_MIN (0-(size_t)PY_SSIZE_T_MIN) + /* Get a C long int from a long int object. Returns -1 and sets an error condition if overflow occurs. */ @@ -223,14 +235,16 @@ if ((x >> SHIFT) != prev) goto overflow; } - /* Haven't lost any bits, but if the sign bit is set we're in - * trouble *unless* this is the min negative number. So, - * trouble iff sign bit set && (positive || some bit set other - * than the sign bit). - */ - if ((long)x < 0 && (sign > 0 || (x << 1) != 0)) - goto overflow; - return (long)x * sign; + /* Haven't lost any bits, but casting to long requires extra care + * (see comment above). + */ + if (x <= (unsigned long)LONG_MAX) { + return (long)x * sign; + } + else if (sign < 0 && x == PY_ABS_LONG_MIN) { + return LONG_MIN; + } + /* else overflow */ overflow: PyErr_SetString(PyExc_OverflowError, @@ -266,14 +280,16 @@ if ((x >> SHIFT) != prev) goto overflow; } - /* Haven't lost any bits, but if the sign bit is set we're in - * trouble *unless* this is the min negative number. So, - * trouble iff sign bit set && (positive || some bit set other - * than the sign bit). + /* Haven't lost any bits, but casting to a signed type requires + * extra care (see comment above). */ - if ((Py_ssize_t)x < 0 && (sign > 0 || (x << 1) != 0)) - goto overflow; - return (Py_ssize_t)x * sign; + if (x <= (size_t)PY_SSIZE_T_MAX) { + return (Py_ssize_t)x * sign; + } + else if (sign < 0 && x == PY_ABS_SSIZE_T_MIN) { + return PY_SSIZE_T_MIN; + } + /* else overflow */ overflow: PyErr_SetString(PyExc_OverflowError, @@ -1165,7 +1181,7 @@ { register PyLongObject *a = (PyLongObject *)aa; PyStringObject *str; - Py_ssize_t i; + Py_ssize_t i, j, sz; Py_ssize_t size_a; char *p; int bits; @@ -1185,11 +1201,18 @@ ++bits; i >>= 1; } - i = 5 + (size_a*SHIFT + bits-1) / bits; - str = (PyStringObject *) PyString_FromStringAndSize((char *)0, i); + i = 5; + j = size_a*SHIFT + bits-1; + sz = i + j / bits; + if (j / SHIFT < size_a || sz < i) { + PyErr_SetString(PyExc_OverflowError, + "long is too large to format"); + return NULL; + } + str = (PyStringObject *) PyString_FromStringAndSize((char *)0, sz); if (str == NULL) return NULL; - p = PyString_AS_STRING(str) + i; + p = PyString_AS_STRING(str) + sz; *p = '\0'; if (a->ob_size < 0) sign = '-'; @@ -1301,7 +1324,7 @@ } while ((*q++ = *p++) != '\0'); q--; _PyString_Resize((PyObject **)&str, - (int) (q - PyString_AS_STRING(str))); + (Py_ssize_t) (q - PyString_AS_STRING(str))); } return (PyObject *)str; } @@ -1359,14 +1382,14 @@ while (_PyLong_DigitValue[Py_CHARMASK(*p)] < base) ++p; *str = p; - n = (p - start) * bits_per_char; - if (n / bits_per_char != p - start) { + /* n <- # of Python digits needed, = ceiling(n/SHIFT). */ + n = (p - start) * bits_per_char + SHIFT - 1; + if (n / bits_per_char < p - start) { PyErr_SetString(PyExc_ValueError, "long string too large to convert"); return NULL; } - /* n <- # of Python digits needed, = ceiling(n/SHIFT). */ - n = (n + SHIFT - 1) / SHIFT; + n = n / SHIFT; z = _PyLong_New(n); if (z == NULL) return NULL; Modified: python/branches/p3yk/Objects/obmalloc.c ============================================================================== --- python/branches/p3yk/Objects/obmalloc.c (original) +++ python/branches/p3yk/Objects/obmalloc.c Wed Dec 13 05:49:30 2006 @@ -691,7 +691,8 @@ #undef Py_ADDRESS_IN_RANGE -#if defined(__GNUC__) && (__GNUC__ == 3) && (__GNUC_MINOR__ >= 1) +#if defined(__GNUC__) && ((__GNUC__ == 3) && (__GNUC_MINOR__ >= 1) || \ + (__GNUC__ >= 4)) #define Py_NO_INLINE __attribute__((__noinline__)) #else #define Py_NO_INLINE Modified: python/branches/p3yk/Objects/setobject.c ============================================================================== --- python/branches/p3yk/Objects/setobject.c (original) +++ python/branches/p3yk/Objects/setobject.c Wed Dec 13 05:49:30 2006 @@ -10,6 +10,20 @@ #include "Python.h" #include "structmember.h" +/* Set a key error with the specified argument, wrapping it in a + * tuple automatically so that tuple keys are not unpacked as the + * exception arguments. */ +static void +set_key_error(PyObject *arg) +{ + PyObject *tup; + tup = PyTuple_Pack(1, arg); + if (!tup) + return; /* caller will expect error to be set anyway */ + PyErr_SetObject(PyExc_KeyError, tup); + Py_DECREF(tup); +} + /* This must be >= 1. */ #define PERTURB_SHIFT 5 @@ -179,11 +193,13 @@ if (entry->key == dummy && freeslot == NULL) freeslot = entry; } + assert(0); /* NOT REACHED */ + return 0; } /* Internal routine to insert a new key into the table. -Used both by the internal resize routine and by the public insert routine. +Used by the public insert routine. Eats a reference to key. */ static int @@ -216,6 +232,35 @@ } /* +Internal routine used by set_table_resize() to insert an item which is +known to be absent from the set. This routine also assumes that +the set contains no deleted entries. Besides the performance benefit, +using set_insert_clean() in set_table_resize() is dangerous (SF bug #1456209). +Note that no refcounts are changed by this routine; if needed, the caller +is responsible for incref'ing `key`. +*/ +static void +set_insert_clean(register PySetObject *so, PyObject *key, long hash) +{ + register size_t i; + register size_t perturb; + register size_t mask = (size_t)so->mask; + setentry *table = so->table; + register setentry *entry; + + i = hash & mask; + entry = &table[i]; + for (perturb = hash; entry->key != NULL; perturb >>= PERTURB_SHIFT) { + i = (i << 2) + i + perturb + 1; + entry = &table[i & mask]; + } + so->fill++; + entry->key = key; + entry->hash = hash; + so->used++; +} + +/* Restructure the table by allocating a new table and reinserting all keys again. When entries have been deleted, the new table may actually be smaller than the old one. @@ -296,11 +341,7 @@ } else { /* ACTIVE */ --i; - if(set_insert_key(so, entry->key, entry->hash) == -1) { - if (is_oldtable_malloced) - PyMem_DEL(oldtable); - return -1; - } + set_insert_clean(so, entry->key, entry->hash); } } @@ -319,8 +360,10 @@ assert(so->fill <= so->mask); /* at least one empty slot */ n_used = so->used; Py_INCREF(entry->key); - if (set_insert_key(so, entry->key, entry->hash) == -1) + if (set_insert_key(so, entry->key, entry->hash) == -1) { + Py_DECREF(entry->key); return -1; + } if (!(so->used > n_used && so->fill*3 >= (so->mask+1)*2)) return 0; return set_table_resize(so, so->used>50000 ? so->used*2 : so->used*4); @@ -1155,7 +1198,12 @@ } while (set_next((PySetObject *)other, &pos, &entry)) { - if (set_contains_entry(so, entry)) { + int rv = set_contains_entry(so, entry); + if (rv == -1) { + Py_DECREF(result); + return NULL; + } + if (rv) { if (set_add_entry(result, entry) == -1) { Py_DECREF(result); return NULL; @@ -1172,8 +1220,27 @@ } while ((key = PyIter_Next(it)) != NULL) { - if (set_contains_key(so, key)) { - if (set_add_key(result, key) == -1) { + int rv; + setentry entry; + long hash = PyObject_Hash(key); + + if (hash == -1) { + Py_DECREF(it); + Py_DECREF(result); + Py_DECREF(key); + return NULL; + } + entry.hash = hash; + entry.key = key; + rv = set_contains_entry(so, &entry); + if (rv == -1) { + Py_DECREF(it); + Py_DECREF(result); + Py_DECREF(key); + return NULL; + } + if (rv) { + if (set_add_entry(result, &entry) == -1) { Py_DECREF(it); Py_DECREF(result); Py_DECREF(key); @@ -1249,7 +1316,8 @@ Py_ssize_t pos = 0; while (set_next((PySetObject *)other, &pos, &entry)) - set_discard_entry(so, entry); + if (set_discard_entry(so, entry) == -1) + return -1; } else { PyObject *key, *it; it = PyObject_GetIter(other); @@ -1312,17 +1380,26 @@ entrycopy.hash = entry->hash; entrycopy.key = entry->key; if (!PyDict_Contains(other, entry->key)) { - if (set_add_entry((PySetObject *)result, &entrycopy) == -1) + if (set_add_entry((PySetObject *)result, &entrycopy) == -1) { + Py_DECREF(result); return NULL; + } } } return result; } while (set_next(so, &pos, &entry)) { - if (!set_contains_entry((PySetObject *)other, entry)) { - if (set_add_entry((PySetObject *)result, entry) == -1) + int rv = set_contains_entry((PySetObject *)other, entry); + if (rv == -1) { + Py_DECREF(result); + return NULL; + } + if (!rv) { + if (set_add_entry((PySetObject *)result, entry) == -1) { + Py_DECREF(result); return NULL; + } } } return result; @@ -1374,11 +1451,18 @@ PyObject *value; int rv; while (PyDict_Next(other, &pos, &key, &value)) { - rv = set_discard_key(so, key); + setentry an_entry; + long hash = PyObject_Hash(key); + + if (hash == -1) + return NULL; + an_entry.hash = hash; + an_entry.key = key; + rv = set_discard_entry(so, &an_entry); if (rv == -1) return NULL; if (rv == DISCARD_NOTFOUND) { - if (set_add_key(so, key) == -1) + if (set_add_entry(so, &an_entry) == -1) return NULL; } } @@ -1481,7 +1565,10 @@ Py_RETURN_FALSE; while (set_next(so, &pos, &entry)) { - if (!set_contains_entry((PySetObject *)other, entry)) + int rv = set_contains_entry((PySetObject *)other, entry); + if (rv == -1) + return NULL; + if (!rv) Py_RETURN_FALSE; } Py_RETURN_TRUE; @@ -1628,7 +1715,7 @@ Py_DECREF(tmpkey); return result; } else if (rv == DISCARD_NOTFOUND) { - PyErr_SetObject(PyExc_KeyError, key); + set_key_error(key); return NULL; } Py_RETURN_NONE; Modified: python/branches/p3yk/Objects/stringlib/partition.h ============================================================================== --- python/branches/p3yk/Objects/stringlib/partition.h (original) +++ python/branches/p3yk/Objects/stringlib/partition.h Wed Dec 13 05:49:30 2006 @@ -78,12 +78,12 @@ } if (pos < 0) { - Py_INCREF(str_obj); - PyTuple_SET_ITEM(out, 0, (PyObject*) str_obj); Py_INCREF(STRINGLIB_EMPTY); - PyTuple_SET_ITEM(out, 1, (PyObject*) STRINGLIB_EMPTY); + PyTuple_SET_ITEM(out, 0, (PyObject*) STRINGLIB_EMPTY); Py_INCREF(STRINGLIB_EMPTY); - PyTuple_SET_ITEM(out, 2, (PyObject*) STRINGLIB_EMPTY); + PyTuple_SET_ITEM(out, 1, (PyObject*) STRINGLIB_EMPTY); + Py_INCREF(str_obj); + PyTuple_SET_ITEM(out, 2, (PyObject*) str_obj); return out; } Modified: python/branches/p3yk/Objects/stringobject.c ============================================================================== --- python/branches/p3yk/Objects/stringobject.c (original) +++ python/branches/p3yk/Objects/stringobject.c Wed Dec 13 05:49:30 2006 @@ -804,10 +804,22 @@ return ret; } if (flags & Py_PRINT_RAW) { + char *data = op->ob_sval; + Py_ssize_t size = op->ob_size; + while (size > INT_MAX) { + /* Very long strings cannot be written atomically. + * But don't write exactly INT_MAX bytes at a time + * to avoid memory aligment issues. + */ + const int chunk_size = INT_MAX & ~0x3FFF; + fwrite(data, 1, chunk_size, fp); + data += chunk_size; + size -= chunk_size; + } #ifdef __VMS - if (op->ob_size) fwrite(op->ob_sval, (int) op->ob_size, 1, fp); + if (size) fwrite(data, (int)size, 1, fp); #else - fwrite(op->ob_sval, 1, (int) op->ob_size, fp); + fwrite(data, 1, (int)size, fp); #endif return 0; } @@ -844,7 +856,7 @@ register PyStringObject* op = (PyStringObject*) obj; size_t newsize = 2 + 4 * op->ob_size; PyObject *v; - if (newsize > PY_SSIZE_T_MAX) { + if (newsize > PY_SSIZE_T_MAX || newsize / 4 != op->ob_size) { PyErr_SetString(PyExc_OverflowError, "string is too large to make repr"); } @@ -1059,8 +1071,9 @@ return PyUnicode_Contains(str_obj, sub_obj); #endif if (!PyString_Check(sub_obj)) { - PyErr_SetString(PyExc_TypeError, - "'in ' requires string as left operand"); + PyErr_Format(PyExc_TypeError, + "'in ' requires string as left operand, " + "not %.200s", sub_obj->ob_type->tp_name); return -1; } } @@ -1228,8 +1241,9 @@ } } else { - PyErr_SetString(PyExc_TypeError, - "string indices must be integers"); + PyErr_Format(PyExc_TypeError, + "string indices must be integers, not %.200s", + item->ob_type->tp_name); return NULL; } } @@ -1543,11 +1557,11 @@ } PyDoc_STRVAR(rpartition__doc__, -"S.rpartition(sep) -> (head, sep, tail)\n\ +"S.rpartition(sep) -> (tail, sep, head)\n\ \n\ Searches for the separator sep in S, starting at the end of S, and returns\n\ the part before it, the separator itself, and the part after it. If the\n\ -separator is not found, returns S and two empty strings."); +separator is not found, returns two empty strings and S."); static PyObject * string_rpartition(PyStringObject *self, PyObject *sep_obj) @@ -4136,7 +4150,8 @@ double x; x = PyFloat_AsDouble(v); if (x == -1.0 && PyErr_Occurred()) { - PyErr_SetString(PyExc_TypeError, "float argument required"); + PyErr_Format(PyExc_TypeError, "float argument required, " + "not %.200s", v->ob_type->tp_name); return -1; } if (prec < 0) @@ -4237,7 +4252,7 @@ return NULL; } llen = PyString_Size(result); - if (llen > PY_SSIZE_T_MAX) { + if (llen > INT_MAX) { PyErr_SetString(PyExc_ValueError, "string too large in _PyString_FormatLong"); return NULL; } @@ -4331,7 +4346,8 @@ x = PyInt_AsLong(v); if (x == -1 && PyErr_Occurred()) { - PyErr_SetString(PyExc_TypeError, "int argument required"); + PyErr_Format(PyExc_TypeError, "int argument required, not %.200s", + v->ob_type->tp_name); return -1; } if (x < 0 && type == 'u') { @@ -4726,9 +4742,10 @@ default: PyErr_Format(PyExc_ValueError, "unsupported format character '%c' (0x%x) " - "at index %i", + "at index %zd", c, c, - (int)(fmt - 1 - PyString_AsString(format))); + (Py_ssize_t)(fmt - 1 - + PyString_AsString(format))); goto error; } if (sign) { Modified: python/branches/p3yk/Objects/tupleobject.c ============================================================================== --- python/branches/p3yk/Objects/tupleobject.c (original) +++ python/branches/p3yk/Objects/tupleobject.c Wed Dec 13 05:49:30 2006 @@ -620,8 +620,9 @@ } } else { - PyErr_SetString(PyExc_TypeError, - "tuple indices must be integers"); + PyErr_Format(PyExc_TypeError, + "tuple indices must be integers, not %.200s", + item->ob_type->tp_name); return NULL; } } Modified: python/branches/p3yk/Objects/typeobject.c ============================================================================== --- python/branches/p3yk/Objects/typeobject.c (original) +++ python/branches/p3yk/Objects/typeobject.c Wed Dec 13 05:49:30 2006 @@ -98,7 +98,7 @@ s = strrchr(type->tp_name, '.'); if (s != NULL) return PyString_FromStringAndSize( - type->tp_name, (int)(s - type->tp_name)); + type->tp_name, (Py_ssize_t)(s - type->tp_name)); return PyString_FromString("__builtin__"); } } @@ -3644,7 +3644,7 @@ while (type && type->tp_flags & Py_TPFLAGS_HEAPTYPE) type = type->tp_base; /* If type is NULL now, this is a really weird type. - In the same of backwards compatibility (?), just shut up. */ + In the spirit of backwards compatibility (?), just shut up. */ if (type && type->tp_setattro != func) { PyErr_Format(PyExc_TypeError, "can't apply this %s to %s object", @@ -3861,7 +3861,7 @@ while (staticbase && (staticbase->tp_flags & Py_TPFLAGS_HEAPTYPE)) staticbase = staticbase->tp_base; /* If staticbase is NULL now, it is a really weird type. - In the same of backwards compatibility (?), just shut up. */ + In the spirit of backwards compatibility (?), just shut up. */ if (staticbase && staticbase->tp_new != type->tp_new) { PyErr_Format(PyExc_TypeError, "%s.__new__(%s) is not safe, use %s.__new__()", @@ -4017,19 +4017,10 @@ return -1; len = PyInt_AsSsize_t(res); Py_DECREF(res); - if (len == -1 && PyErr_Occurred()) - return -1; -#if SIZEOF_SIZE_T < SIZEOF_INT - /* Overflow check -- range of PyInt is more than C ssize_t */ - if (len != (int)len) { - PyErr_SetString(PyExc_OverflowError, - "__len__() should return 0 <= outcome < 2**31"); - return -1; - } -#endif if (len < 0) { - PyErr_SetString(PyExc_ValueError, - "__len__() should return >= 0"); + if (!PyErr_Occurred()) + PyErr_SetString(PyExc_ValueError, + "__len__() should return >= 0"); return -1; } return len; @@ -5583,6 +5574,8 @@ PyObject *obj = NULL; PyTypeObject *obj_type = NULL; + if (!_PyArg_NoKeywords("super", kwds)) + return -1; if (!PyArg_ParseTuple(args, "O!|O:super", &PyType_Type, &type, &obj)) return -1; if (obj == Py_None) Modified: python/branches/p3yk/Objects/unicodeobject.c ============================================================================== --- python/branches/p3yk/Objects/unicodeobject.c (original) +++ python/branches/p3yk/Objects/unicodeobject.c Wed Dec 13 05:49:30 2006 @@ -2040,7 +2040,32 @@ static const char *hexdigit = "0123456789abcdef"; - repr = PyString_FromStringAndSize(NULL, 2 + 6*size + 1); + /* XXX(nnorwitz): rather than over-allocating, it would be + better to choose a different scheme. Perhaps scan the + first N-chars of the string and allocate based on that size. + */ + /* Initial allocation is based on the longest-possible unichr + escape. + + In wide (UTF-32) builds '\U00xxxxxx' is 10 chars per source + unichr, so in this case it's the longest unichr escape. In + narrow (UTF-16) builds this is five chars per source unichr + since there are two unichrs in the surrogate pair, so in narrow + (UTF-16) builds it's not the longest unichr escape. + + In wide or narrow builds '\uxxxx' is 6 chars per source unichr, + so in the narrow (UTF-16) build case it's the longest unichr + escape. + */ + + repr = PyString_FromStringAndSize(NULL, + 2 +#ifdef Py_UNICODE_WIDE + + 10*size +#else + + 6*size +#endif + + 1); if (repr == NULL) return NULL; @@ -2065,15 +2090,6 @@ #ifdef Py_UNICODE_WIDE /* Map 21-bit characters to '\U00xxxxxx' */ else if (ch >= 0x10000) { - Py_ssize_t offset = p - PyString_AS_STRING(repr); - - /* Resize the string if necessary */ - if (offset + 12 > PyString_GET_SIZE(repr)) { - if (_PyString_Resize(&repr, PyString_GET_SIZE(repr) + 100)) - return NULL; - p = PyString_AS_STRING(repr) + offset; - } - *p++ = '\\'; *p++ = 'U'; *p++ = hexdigit[(ch >> 28) & 0x0000000F]; @@ -2086,8 +2102,8 @@ *p++ = hexdigit[ch & 0x0000000F]; continue; } -#endif - /* Map UTF-16 surrogate pairs to Unicode \UXXXXXXXX escapes */ +#else + /* Map UTF-16 surrogate pairs to '\U00xxxxxx' */ else if (ch >= 0xD800 && ch < 0xDC00) { Py_UNICODE ch2; Py_UCS4 ucs; @@ -2112,6 +2128,7 @@ s--; size++; } +#endif /* Map 16-bit characters to '\uxxxx' */ if (ch >= 256) { @@ -2367,6 +2384,7 @@ Py_UNICODE unimax = PyUnicode_GetMax(); #endif + /* XXX overflow detection missing */ v = _PyUnicode_New((size+Py_UNICODE_SIZE-1)/ Py_UNICODE_SIZE); if (v == NULL) goto onError; @@ -3153,6 +3171,7 @@ Py_ssize_t needed = (targetsize - extrachars) + \ (targetsize << 2); extrachars += needed; + /* XXX overflow detection missing */ if (_PyUnicode_Resize(&v, PyUnicode_GET_SIZE(v) + needed) < 0) { Py_DECREF(x); @@ -6695,11 +6714,11 @@ } PyDoc_STRVAR(rpartition__doc__, -"S.rpartition(sep) -> (head, sep, tail)\n\ +"S.rpartition(sep) -> (tail, sep, head)\n\ \n\ Searches for the separator sep in S, starting at the end of S, and returns\n\ the part before it, the separator itself, and the part after it. If the\n\ -separator is not found, returns S and two empty strings."); +separator is not found, returns two empty strings and S."); static PyObject* unicode_rpartition(PyUnicodeObject *self, PyObject *separator) @@ -7744,10 +7763,11 @@ default: PyErr_Format(PyExc_ValueError, "unsupported format character '%c' (0x%x) " - "at index %i", + "at index %zd", (31<=c && c<=126) ? (char)c : '?', (int)c, - (int)(fmt -1 - PyUnicode_AS_UNICODE(uformat))); + (Py_ssize_t)(fmt - 1 - + PyUnicode_AS_UNICODE(uformat))); goto onError; } if (sign) { Modified: python/branches/p3yk/PC/VC6/_bsddb.dsp ============================================================================== Binary files. No diff available. Modified: python/branches/p3yk/PC/VC6/_ssl.mak ============================================================================== --- python/branches/p3yk/PC/VC6/_ssl.mak (original) +++ python/branches/p3yk/PC/VC6/_ssl.mak Wed Dec 13 05:49:30 2006 @@ -2,17 +2,17 @@ !IFDEF DEBUG MODULE=_ssl_d.pyd TEMP_DIR=x86-temp-debug/_ssl -CFLAGS=/Od /Zi /MDd /LDd /DDEBUG /D_DEBUG +CFLAGS=/Od /Zi /MDd /LDd /DDEBUG /D_DEBUG /DWIN32 SSL_LIB_DIR=$(SSL_DIR)/out32.dbg !ELSE MODULE=_ssl.pyd TEMP_DIR=x86-temp-release/_ssl -CFLAGS=/Ox /MD /LD +CFLAGS=/Ox /MD /LD /DWIN32 SSL_LIB_DIR=$(SSL_DIR)/out32 !ENDIF INCLUDES=-I ../../Include -I .. -I $(SSL_DIR)/inc32 -LIBS=gdi32.lib wsock32.lib /libpath:$(SSL_LIB_DIR) libeay32.lib ssleay32.lib +LIBS=gdi32.lib wsock32.lib user32.lib advapi32.lib /libpath:$(SSL_LIB_DIR) libeay32.lib ssleay32.lib SOURCE=../../Modules/_ssl.c $(SSL_LIB_DIR)/libeay32.lib $(SSL_LIB_DIR)/ssleay32.lib Modified: python/branches/p3yk/PC/VC6/_tkinter.dsp ============================================================================== Binary files. No diff available. Modified: python/branches/p3yk/PC/VC6/bz2.dsp ============================================================================== Binary files. No diff available. Modified: python/branches/p3yk/PC/VC6/pcbuild.dsw ============================================================================== Binary files. No diff available. Modified: python/branches/p3yk/PC/VC6/pythoncore.dsp ============================================================================== Binary files. No diff available. Modified: python/branches/p3yk/PC/VC6/readme.txt ============================================================================== --- python/branches/p3yk/PC/VC6/readme.txt (original) +++ python/branches/p3yk/PC/VC6/readme.txt Wed Dec 13 05:49:30 2006 @@ -62,40 +62,37 @@ _tkinter Python wrapper for the Tk windowing system. Requires building - Tcl/Tk first. Following are instructions for Tcl/Tk 8.4.3: + Tcl/Tk first. Following are instructions for Tcl/Tk 8.4.12. Get source ---------- - Go to - http://prdownloads.sourceforge.net/tcl/ - and download - tcl843-src.zip - tk843-src.zip - Unzip into - dist\tcl8.4.3\ - dist\tk8.4.3\ - respectively. + In the dist directory, run + svn export http://svn.python.org/projects/external/tcl8.4.12 + svn export http://svn.python.org/projects/external/tk8.4.12 + svn export http://svn.python.org/projects/external/tix-8.4.0 - Build Tcl first (done here w/ MSVC 6 on Win98SE) + Build Tcl first (done here w/ MSVC 6 on Win2K) --------------- - cd dist\tcl8.4.3\win - run vcvars32.bat [necessary even on Win2K] + cd dist\tcl8.4.12\win + run vcvars32.bat nmake -f makefile.vc - nmake -f makefile.vc INSTALLDIR=..\..\tcl84 install + nmake -f makefile.vc INSTALLDIR=..\..\tcltk install XXX Should we compile with OPTS=threads? - XXX Some tests failed in "nmake -f makefile.vc test". - XXX all.tcl: Total 10480 Passed 9743 Skipped 719 Failed 18 - XXX - XXX That was on Win98SE. On Win2K: - XXX all.tcl Total 10480 Passed 9781 Skipped 698 Failed 1 + Optional: run tests, via + nmake -f makefile.vc test + + all.tcl: Total 10835 Passed 10096 Skipped 732 Failed 7 + Sourced 129 Test Files. + Files with failing tests: exec.test expr.test io.test main.test string.test stri + ngObj.test Build Tk -------- - cd dist\tk8.4.3\win - nmake -f makefile.vc TCLDIR=..\..\tcl8.4.3 - nmake -f makefile.vc TCLDIR=..\..\tcl8.4.3 INSTALLDIR=..\..\tcl84 install + cd dist\tk8.4.12\win + nmake -f makefile.vc TCLDIR=..\..\tcl8.4.12 + nmake -f makefile.vc TCLDIR=..\..\tcl8.4.12 INSTALLDIR=..\..\tcltk install XXX Should we compile with OPTS=threads? @@ -103,96 +100,59 @@ XXX failed. It popped up tons of little windows, and did lots of XXX stuff, and nothing blew up. - XXX Our installer copies a lot of stuff out of the Tcl/Tk install - XXX directory. Is all of that really needed for Python use of Tcl/Tk? - - Make sure the installer matches - ------------------------------- - Ensure that the Wise compiler vrbl _TCLDIR_ is set to the name of - the common Tcl/Tk installation directory (tcl84 for the instructions - above). This is needed so the installer can copy various Tcl/Tk - files into the Python distribution. - - -zlib - Python wrapper for the zlib compression library. Get the source code - for version 1.1.4 from a convenient mirror at: - http://www.gzip.org/zlib/ - Unpack into dist\zlib-1.1.4. - A custom pre-link step in the zlib project settings should manage to - build zlib-1.1.4\zlib.lib by magic before zlib.pyd (or zlib_d.pyd) is - linked in PCbuild\. - However, the zlib project is not smart enough to remove anything under - zlib-1.1.4\ when you do a clean, so if you want to rebuild zlib.lib - you need to clean up zlib-1.1.4\ by hand. + Built Tix + --------- + cd dist\tix-8.4.0\win + nmake -f python.mak + nmake -f python.mak install bz2 Python wrapper for the libbz2 compression library. Homepage http://sources.redhat.com/bzip2/ - Download the source tarball, bzip2-1.0.2.tar.gz. - Unpack into dist\bzip2-1.0.2. WARNING: If you're using WinZip, you - must disable its "TAR file smart CR/LF conversion" feature (under - Options -> Configuration -> Miscellaneous -> Other) for the duration. - - A custom pre-link step in the bz2 project settings should manage to - build bzip2-1.0.2\libbz2.lib by magic before bz2.pyd (or bz2_d.pyd) is - linked in PCbuild\. - However, the bz2 project is not smart enough to remove anything under - bzip2-1.0.2\ when you do a clean, so if you want to rebuild bzip2.lib - you need to clean up bzip2-1.0.2\ by hand. - - The build step shouldn't yield any warnings or errors, and should end - by displaying 6 blocks each terminated with - FC: no differences encountered - If FC finds differences, see the warning abou WinZip above (when I - first tried it, sample3.ref failed due to CRLF conversion). + Download the source from the python.org copy into the dist + directory: + + svn export http://svn.python.org/projects/external/bzip2-1.0.3 + + And requires building bz2 first. - All of this managed to build bzip2-1.0.2\libbz2.lib, which the Python + cd dist\bzip2-1.0.3 + nmake -f makefile.msc + + All of this managed to build bzip2-1.0.3\libbz2.lib, which the Python project links in. _bsddb - Go to Sleepycat's download page: - http://www.sleepycat.com/download/ + To use the version of bsddb that Python is built with by default, invoke + (in the dist directory) + + svn export http://svn.python.org/projects/external/db-4.4.20 + + Then open db-4.4.20\build_win32\Berkeley_DB.dsw and build the "db_static" + project for "Release" mode. + + Alternatively, if you want to start with the original sources, + go to Sleepycat's download page: + http://www.sleepycat.com/downloads/releasehistorybdb.html + + and download version 4.4.20. - and download version 4.1.25. The file name is db-4.1.25.NC.zip. - XXX with or without strong cryptography? I picked "without". + With or without strong cryptography? You can choose either with or + without strong cryptography, as per the instructions below. By + default, Python is built and distributed WITHOUT strong crypto. - Unpack into - dist\db-4.1.25 + Unpack the sources; if you downloaded the non-crypto version, rename + the directory from db-4.4.20.NC to db-4.4.20. - [If using WinZip to unpack the db-4.1.25.NC distro, that requires - renaming the directory (to remove ".NC") after unpacking. - ] - - Open - dist\db-4.1.25\docs\index.html - - and follow the Windows instructions for building the Sleepycat - software. Note that Berkeley_DB.dsw is in the build_win32 subdirectory. - Build the Release version ("build_all -- Win32 Release"). - - XXX We're actually linking against Release_static\libdb41s.lib. - XXX This yields the following warnings: -""" -Compiling... -_bsddb.c -Linking... - Creating library ./_bsddb.lib and object ./_bsddb.exp -LINK : warning LNK4049: locally defined symbol "_malloc" imported -LINK : warning LNK4049: locally defined symbol "_free" imported -LINK : warning LNK4049: locally defined symbol "_fclose" imported -LINK : warning LNK4049: locally defined symbol "_fopen" imported -_bsddb.pyd - 0 error(s), 4 warning(s) -""" - XXX This isn't encouraging, but I don't know what to do about it. + Now apply any patches that apply to your version. To run extensive tests, pass "-u bsddb" to regrtest.py. test_bsddb3.py is then enabled. Running in verbose mode may be helpful. XXX The test_bsddb3 tests don't always pass, on Windows (according to - XXX me) or on Linux (according to Barry). I had much better luck - XXX on Win2K than on Win98SE. The common failure mode across platforms + XXX me) or on Linux (according to Barry). (I had much better luck + XXX on Win2K than on Win98SE.) The common failure mode across platforms XXX is XXX DBAgainError: (11, 'Resource temporarily unavailable -- unable XXX to join the environment') Deleted: /python/branches/p3yk/PC/VC6/zlib.dsp ============================================================================== Binary file. No diff available. Modified: python/branches/p3yk/PC/_msi.c ============================================================================== --- python/branches/p3yk/PC/_msi.c (original) +++ python/branches/p3yk/PC/_msi.c Wed Dec 13 05:49:30 2006 @@ -495,7 +495,7 @@ status = MsiSummaryInfoGetProperty(si->h, field, &type, &ival, &fval, sval, &ssize); - if (status = ERROR_MORE_DATA) { + if (status == ERROR_MORE_DATA) { sval = malloc(ssize); status = MsiSummaryInfoGetProperty(si->h, field, &type, &ival, &fval, sval, &ssize); Modified: python/branches/p3yk/PC/example_nt/example.vcproj ============================================================================== --- python/branches/p3yk/PC/example_nt/example.vcproj (original) +++ python/branches/p3yk/PC/example_nt/example.vcproj Wed Dec 13 05:49:30 2006 @@ -39,7 +39,7 @@ + + + + + + + + + + + + + + + + + Modified: python/branches/p3yk/PCbuild/pythoncore.vcproj ============================================================================== --- python/branches/p3yk/PCbuild/pythoncore.vcproj (original) +++ python/branches/p3yk/PCbuild/pythoncore.vcproj Wed Dec 13 05:49:30 2006 @@ -683,6 +683,9 @@ RelativePath="..\Parser\parsetok.c"> + + - - - - + + + @@ -236,17 +236,17 @@ /> @@ -327,17 +325,17 @@ /> + + @@ -238,18 +238,18 @@ /> @@ -330,18 +327,18 @@ /> #include -/* This file creates the getbuildinfo.o object, by first - invoking subwcrev.exe (if found), and then invoking cl.exe. - As a side effect, it might generate PCBuild\getbuildinfo2.c - also. If this isn't a subversion checkout, or subwcrev isn't - found, it compiles ..\\Modules\\getbuildinfo.c instead. +/* This file creates the getbuildinfo2.c file, by + invoking subwcrev.exe (if found). + If this isn't a subversion checkout, or subwcrev isn't + found, it copies ..\\Modules\\getbuildinfo.c instead. + + A file, getbuildinfo2.h is then updated to define + SUBWCREV if it was a subversion checkout. + + getbuildinfo2.c is part of the pythoncore project with + getbuildinfo2.h as a forced include. This helps + VisualStudio refrain from unnecessary compiles much of the + time. Currently, subwcrev.exe is found from the registry entries of TortoiseSVN. - No attempt is made to place getbuildinfo.o into the proper - binary directory. This isn't necessary, as this tool is - invoked as a pre-link step for pythoncore, so that overwrites - any previous getbuildinfo.o. + make_buildinfo.exe is called as a pre-build step for pythoncore. */ @@ -40,11 +44,11 @@ type != REG_SZ) /* Registry corrupted */ return 0; - strcat(command, "bin\\subwcrev.exe"); + strcat_s(command, sizeof(command), "bin\\subwcrev.exe"); if (_stat(command+1, &st) < 0) /* subwcrev.exe not part of the release */ return 0; - strcat(command, "\" .. ..\\Modules\\getbuildinfo.c getbuildinfo2.c"); + strcat_s(command, sizeof(command), "\" .. ..\\Modules\\getbuildinfo.c getbuildinfo2.c"); puts(command); fflush(stdout); if (system(command) < 0) return 0; @@ -53,40 +57,25 @@ int main(int argc, char*argv[]) { - char command[500] = "cl.exe -c -D_WIN32 -DUSE_DL_EXPORT -D_WINDOWS -DWIN32 -D_WINDLL "; - int do_unlink, result; - if (argc != 2) { - fprintf(stderr, "make_buildinfo $(ConfigurationName)\n"); - return EXIT_FAILURE; - } - if (strcmp(argv[1], "Release") == 0) { - strcat(command, "-MD "); - } - else if (strcmp(argv[1], "Debug") == 0) { - strcat(command, "-D_DEBUG -MDd "); - } - else if (strcmp(argv[1], "ReleaseItanium") == 0) { - strcat(command, "-MD /USECL:MS_ITANIUM "); - } - else if (strcmp(argv[1], "ReleaseAMD64") == 0) { - strcat(command, "-MD "); - strcat(command, "-MD /USECL:MS_OPTERON "); - } - else { - fprintf(stderr, "unsupported configuration %s\n", argv[1]); - return EXIT_FAILURE; - } + char command[500] = ""; + int svn; + FILE *f; - if ((do_unlink = make_buildinfo2())) - strcat(command, "getbuildinfo2.c -DSUBWCREV "); - else - strcat(command, "..\\Modules\\getbuildinfo.c"); - strcat(command, " -Fogetbuildinfo.o -I..\\Include -I..\\PC"); - puts(command); fflush(stdout); - result = system(command); - if (do_unlink) - unlink("getbuildinfo2.c"); - if (result < 0) + if (fopen_s(&f, "getbuildinfo2.h", "w")) return EXIT_FAILURE; + /* Get getbuildinfo.c from svn as getbuildinfo2.c */ + svn = make_buildinfo2(); + if (svn) { + puts("got getbuildinfo2.c from svn. Updating getbuildinfo2.h"); + /* yes. make sure SUBWCREV is defined */ + fprintf(f, "#define SUBWCREV\n"); + } else { + puts("didn't get getbuildinfo2.c from svn. Copying from Modules and clearing getbuildinfo2.h"); + strcat_s(command, sizeof(command), "copy ..\\Modules\\getbuildinfo.c getbuildinfo2.c"); + puts(command); fflush(stdout); + if (system(command) < 0) + return EXIT_FAILURE; + } + fclose(f); return 0; } \ No newline at end of file Modified: python/branches/p3yk/PCbuild8/make_buildinfo.vcproj ============================================================================== --- python/branches/p3yk/PCbuild8/make_buildinfo.vcproj (original) +++ python/branches/p3yk/PCbuild8/make_buildinfo.vcproj Wed Dec 13 05:49:30 2006 @@ -4,6 +4,7 @@ Version="8,00" Name="make_buildinfo" ProjectGUID="{C73F0EC1-358B-4177-940F-0846AC8B04CD}" + RootNamespace="make_buildinfo" Keyword="Win32Proj" > @@ -40,7 +41,7 @@ - - - - - - - - - - - - - - - - - - - - Modified: python/branches/p3yk/PCbuild8/pcbuild.sln ============================================================================== --- python/branches/p3yk/PCbuild8/pcbuild.sln (original) +++ python/branches/p3yk/PCbuild8/pcbuild.sln Wed Dec 13 05:49:30 2006 @@ -2,8 +2,8 @@ # Visual Studio 2005 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "pythoncore", "pythoncore.vcproj", "{CF7AC3D1-E2DF-41D2-BEA6-1E2556CDEA26}" ProjectSection(ProjectDependencies) = postProject - {C73F0EC1-358B-4177-940F-0846AC8B04CD} = {C73F0EC1-358B-4177-940F-0846AC8B04CD} {F0E0541E-F17D-430B-97C4-93ADF0DD284E} = {F0E0541E-F17D-430B-97C4-93ADF0DD284E} + {C73F0EC1-358B-4177-940F-0846AC8B04CD} = {C73F0EC1-358B-4177-940F-0846AC8B04CD} EndProjectSection EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "pythonw", "pythonw.vcproj", "{F4229CC3-873C-49AE-9729-DD308ED4CD4A}" @@ -61,137 +61,244 @@ readme.txt = readme.txt EndProjectSection EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "pythoncore_pgo", "pythoncore_pgo.vcproj", "{8B59C1FF-2439-4BE9-9F24-84D4982D28D4}" +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "python", "python.vcproj", "{B11D750F-CD1F-4A96-85CE-E69A5C5259F9}" ProjectSection(ProjectDependencies) = postProject {CF7AC3D1-E2DF-41D2-BEA6-1E2556CDEA26} = {CF7AC3D1-E2DF-41D2-BEA6-1E2556CDEA26} EndProjectSection EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "python", "python.vcproj", "{B11D750F-CD1F-4A96-85CE-E69A5C5259F9}" -EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "make_versioninfo", "make_versioninfo.vcproj", "{F0E0541E-F17D-430B-97C4-93ADF0DD284E}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Win32 = Debug|Win32 + Debug|x64 = Debug|x64 + PGIRelease|Win32 = PGIRelease|Win32 + PGIRelease|x64 = PGIRelease|x64 + PGORelease|Win32 = PGORelease|Win32 + PGORelease|x64 = PGORelease|x64 Release|Win32 = Release|Win32 - ReleaseAMD64|Win32 = ReleaseAMD64|Win32 - ReleaseItanium|Win32 = ReleaseItanium|Win32 + Release|x64 = Release|x64 EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution {CF7AC3D1-E2DF-41D2-BEA6-1E2556CDEA26}.Debug|Win32.ActiveCfg = Debug|Win32 {CF7AC3D1-E2DF-41D2-BEA6-1E2556CDEA26}.Debug|Win32.Build.0 = Debug|Win32 + {CF7AC3D1-E2DF-41D2-BEA6-1E2556CDEA26}.Debug|x64.ActiveCfg = Debug|x64 + {CF7AC3D1-E2DF-41D2-BEA6-1E2556CDEA26}.Debug|x64.Build.0 = Debug|x64 + {CF7AC3D1-E2DF-41D2-BEA6-1E2556CDEA26}.PGIRelease|Win32.ActiveCfg = PGIRelease|Win32 + {CF7AC3D1-E2DF-41D2-BEA6-1E2556CDEA26}.PGIRelease|Win32.Build.0 = PGIRelease|Win32 + {CF7AC3D1-E2DF-41D2-BEA6-1E2556CDEA26}.PGIRelease|x64.ActiveCfg = PGIRelease|x64 + {CF7AC3D1-E2DF-41D2-BEA6-1E2556CDEA26}.PGIRelease|x64.Build.0 = PGIRelease|x64 + {CF7AC3D1-E2DF-41D2-BEA6-1E2556CDEA26}.PGORelease|Win32.ActiveCfg = PGORelease|Win32 + {CF7AC3D1-E2DF-41D2-BEA6-1E2556CDEA26}.PGORelease|Win32.Build.0 = PGORelease|Win32 + {CF7AC3D1-E2DF-41D2-BEA6-1E2556CDEA26}.PGORelease|x64.ActiveCfg = PGORelease|x64 + {CF7AC3D1-E2DF-41D2-BEA6-1E2556CDEA26}.PGORelease|x64.Build.0 = PGORelease|x64 {CF7AC3D1-E2DF-41D2-BEA6-1E2556CDEA26}.Release|Win32.ActiveCfg = Release|Win32 {CF7AC3D1-E2DF-41D2-BEA6-1E2556CDEA26}.Release|Win32.Build.0 = Release|Win32 - {CF7AC3D1-E2DF-41D2-BEA6-1E2556CDEA26}.ReleaseAMD64|Win32.ActiveCfg = ReleaseAMD64|Win32 - {CF7AC3D1-E2DF-41D2-BEA6-1E2556CDEA26}.ReleaseAMD64|Win32.Build.0 = ReleaseAMD64|Win32 - {CF7AC3D1-E2DF-41D2-BEA6-1E2556CDEA26}.ReleaseItanium|Win32.ActiveCfg = ReleaseItanium|Win32 - {CF7AC3D1-E2DF-41D2-BEA6-1E2556CDEA26}.ReleaseItanium|Win32.Build.0 = ReleaseItanium|Win32 + {CF7AC3D1-E2DF-41D2-BEA6-1E2556CDEA26}.Release|x64.ActiveCfg = Release|x64 + {CF7AC3D1-E2DF-41D2-BEA6-1E2556CDEA26}.Release|x64.Build.0 = Release|x64 {F4229CC3-873C-49AE-9729-DD308ED4CD4A}.Debug|Win32.ActiveCfg = Debug|Win32 {F4229CC3-873C-49AE-9729-DD308ED4CD4A}.Debug|Win32.Build.0 = Debug|Win32 + {F4229CC3-873C-49AE-9729-DD308ED4CD4A}.Debug|x64.ActiveCfg = Debug|x64 + {F4229CC3-873C-49AE-9729-DD308ED4CD4A}.Debug|x64.Build.0 = Debug|x64 + {F4229CC3-873C-49AE-9729-DD308ED4CD4A}.PGIRelease|Win32.ActiveCfg = Release|Win32 + {F4229CC3-873C-49AE-9729-DD308ED4CD4A}.PGIRelease|Win32.Build.0 = Release|Win32 + {F4229CC3-873C-49AE-9729-DD308ED4CD4A}.PGIRelease|x64.ActiveCfg = Release|x64 + {F4229CC3-873C-49AE-9729-DD308ED4CD4A}.PGIRelease|x64.Build.0 = Release|x64 + {F4229CC3-873C-49AE-9729-DD308ED4CD4A}.PGORelease|Win32.ActiveCfg = Release|Win32 + {F4229CC3-873C-49AE-9729-DD308ED4CD4A}.PGORelease|Win32.Build.0 = Release|Win32 + {F4229CC3-873C-49AE-9729-DD308ED4CD4A}.PGORelease|x64.ActiveCfg = Release|x64 + {F4229CC3-873C-49AE-9729-DD308ED4CD4A}.PGORelease|x64.Build.0 = Release|x64 {F4229CC3-873C-49AE-9729-DD308ED4CD4A}.Release|Win32.ActiveCfg = Release|Win32 {F4229CC3-873C-49AE-9729-DD308ED4CD4A}.Release|Win32.Build.0 = Release|Win32 - {F4229CC3-873C-49AE-9729-DD308ED4CD4A}.ReleaseAMD64|Win32.ActiveCfg = ReleaseAMD64|Win32 - {F4229CC3-873C-49AE-9729-DD308ED4CD4A}.ReleaseAMD64|Win32.Build.0 = ReleaseAMD64|Win32 - {F4229CC3-873C-49AE-9729-DD308ED4CD4A}.ReleaseItanium|Win32.ActiveCfg = ReleaseItanium|Win32 - {F4229CC3-873C-49AE-9729-DD308ED4CD4A}.ReleaseItanium|Win32.Build.0 = ReleaseItanium|Win32 + {F4229CC3-873C-49AE-9729-DD308ED4CD4A}.Release|x64.ActiveCfg = Release|x64 + {F4229CC3-873C-49AE-9729-DD308ED4CD4A}.Release|x64.Build.0 = Release|x64 {97239A56-DBC0-41D2-BC14-C87D9B97D63B}.Debug|Win32.ActiveCfg = Debug|Win32 {97239A56-DBC0-41D2-BC14-C87D9B97D63B}.Debug|Win32.Build.0 = Debug|Win32 + {97239A56-DBC0-41D2-BC14-C87D9B97D63B}.Debug|x64.ActiveCfg = Debug|x64 + {97239A56-DBC0-41D2-BC14-C87D9B97D63B}.Debug|x64.Build.0 = Debug|x64 + {97239A56-DBC0-41D2-BC14-C87D9B97D63B}.PGIRelease|Win32.ActiveCfg = Release|Win32 + {97239A56-DBC0-41D2-BC14-C87D9B97D63B}.PGIRelease|Win32.Build.0 = Release|Win32 + {97239A56-DBC0-41D2-BC14-C87D9B97D63B}.PGIRelease|x64.ActiveCfg = Release|x64 + {97239A56-DBC0-41D2-BC14-C87D9B97D63B}.PGIRelease|x64.Build.0 = Release|x64 + {97239A56-DBC0-41D2-BC14-C87D9B97D63B}.PGORelease|Win32.ActiveCfg = Release|Win32 + {97239A56-DBC0-41D2-BC14-C87D9B97D63B}.PGORelease|Win32.Build.0 = Release|Win32 + {97239A56-DBC0-41D2-BC14-C87D9B97D63B}.PGORelease|x64.ActiveCfg = Release|x64 + {97239A56-DBC0-41D2-BC14-C87D9B97D63B}.PGORelease|x64.Build.0 = Release|x64 {97239A56-DBC0-41D2-BC14-C87D9B97D63B}.Release|Win32.ActiveCfg = Release|Win32 {97239A56-DBC0-41D2-BC14-C87D9B97D63B}.Release|Win32.Build.0 = Release|Win32 - {97239A56-DBC0-41D2-BC14-C87D9B97D63B}.ReleaseAMD64|Win32.ActiveCfg = ReleaseAMD64|Win32 - {97239A56-DBC0-41D2-BC14-C87D9B97D63B}.ReleaseAMD64|Win32.Build.0 = ReleaseAMD64|Win32 - {97239A56-DBC0-41D2-BC14-C87D9B97D63B}.ReleaseItanium|Win32.ActiveCfg = ReleaseItanium|Win32 - {97239A56-DBC0-41D2-BC14-C87D9B97D63B}.ReleaseItanium|Win32.Build.0 = ReleaseItanium|Win32 + {97239A56-DBC0-41D2-BC14-C87D9B97D63B}.Release|x64.ActiveCfg = Release|x64 + {97239A56-DBC0-41D2-BC14-C87D9B97D63B}.Release|x64.Build.0 = Release|x64 {FA5FC7EB-C72F-415F-AE42-91DD605ABDDA}.Debug|Win32.ActiveCfg = Debug|Win32 {FA5FC7EB-C72F-415F-AE42-91DD605ABDDA}.Debug|Win32.Build.0 = Debug|Win32 + {FA5FC7EB-C72F-415F-AE42-91DD605ABDDA}.Debug|x64.ActiveCfg = Debug|x64 + {FA5FC7EB-C72F-415F-AE42-91DD605ABDDA}.Debug|x64.Build.0 = Debug|x64 + {FA5FC7EB-C72F-415F-AE42-91DD605ABDDA}.PGIRelease|Win32.ActiveCfg = Release|Win32 + {FA5FC7EB-C72F-415F-AE42-91DD605ABDDA}.PGIRelease|Win32.Build.0 = Release|Win32 + {FA5FC7EB-C72F-415F-AE42-91DD605ABDDA}.PGIRelease|x64.ActiveCfg = Release|x64 + {FA5FC7EB-C72F-415F-AE42-91DD605ABDDA}.PGIRelease|x64.Build.0 = Release|x64 + {FA5FC7EB-C72F-415F-AE42-91DD605ABDDA}.PGORelease|Win32.ActiveCfg = Release|Win32 + {FA5FC7EB-C72F-415F-AE42-91DD605ABDDA}.PGORelease|Win32.Build.0 = Release|Win32 + {FA5FC7EB-C72F-415F-AE42-91DD605ABDDA}.PGORelease|x64.ActiveCfg = Release|x64 + {FA5FC7EB-C72F-415F-AE42-91DD605ABDDA}.PGORelease|x64.Build.0 = Release|x64 {FA5FC7EB-C72F-415F-AE42-91DD605ABDDA}.Release|Win32.ActiveCfg = Release|Win32 {FA5FC7EB-C72F-415F-AE42-91DD605ABDDA}.Release|Win32.Build.0 = Release|Win32 - {FA5FC7EB-C72F-415F-AE42-91DD605ABDDA}.ReleaseAMD64|Win32.ActiveCfg = ReleaseAMD64|Win32 - {FA5FC7EB-C72F-415F-AE42-91DD605ABDDA}.ReleaseAMD64|Win32.Build.0 = ReleaseAMD64|Win32 - {FA5FC7EB-C72F-415F-AE42-91DD605ABDDA}.ReleaseItanium|Win32.ActiveCfg = ReleaseItanium|Win32 - {FA5FC7EB-C72F-415F-AE42-91DD605ABDDA}.ReleaseItanium|Win32.Build.0 = ReleaseItanium|Win32 + {FA5FC7EB-C72F-415F-AE42-91DD605ABDDA}.Release|x64.ActiveCfg = Release|x64 + {FA5FC7EB-C72F-415F-AE42-91DD605ABDDA}.Release|x64.Build.0 = Release|x64 {E9E0A1F6-0009-4E8C-B8F8-1B8F5D49A058}.Debug|Win32.ActiveCfg = Debug|Win32 {E9E0A1F6-0009-4E8C-B8F8-1B8F5D49A058}.Debug|Win32.Build.0 = Debug|Win32 + {E9E0A1F6-0009-4E8C-B8F8-1B8F5D49A058}.Debug|x64.ActiveCfg = Debug|x64 + {E9E0A1F6-0009-4E8C-B8F8-1B8F5D49A058}.Debug|x64.Build.0 = Debug|x64 + {E9E0A1F6-0009-4E8C-B8F8-1B8F5D49A058}.PGIRelease|Win32.ActiveCfg = Release|Win32 + {E9E0A1F6-0009-4E8C-B8F8-1B8F5D49A058}.PGIRelease|Win32.Build.0 = Release|Win32 + {E9E0A1F6-0009-4E8C-B8F8-1B8F5D49A058}.PGIRelease|x64.ActiveCfg = Release|x64 + {E9E0A1F6-0009-4E8C-B8F8-1B8F5D49A058}.PGIRelease|x64.Build.0 = Release|x64 + {E9E0A1F6-0009-4E8C-B8F8-1B8F5D49A058}.PGORelease|Win32.ActiveCfg = Release|Win32 + {E9E0A1F6-0009-4E8C-B8F8-1B8F5D49A058}.PGORelease|Win32.Build.0 = Release|Win32 + {E9E0A1F6-0009-4E8C-B8F8-1B8F5D49A058}.PGORelease|x64.ActiveCfg = Release|x64 + {E9E0A1F6-0009-4E8C-B8F8-1B8F5D49A058}.PGORelease|x64.Build.0 = Release|x64 {E9E0A1F6-0009-4E8C-B8F8-1B8F5D49A058}.Release|Win32.ActiveCfg = Release|Win32 {E9E0A1F6-0009-4E8C-B8F8-1B8F5D49A058}.Release|Win32.Build.0 = Release|Win32 - {E9E0A1F6-0009-4E8C-B8F8-1B8F5D49A058}.ReleaseAMD64|Win32.ActiveCfg = Release|Win32 - {E9E0A1F6-0009-4E8C-B8F8-1B8F5D49A058}.ReleaseItanium|Win32.ActiveCfg = Release|Win32 + {E9E0A1F6-0009-4E8C-B8F8-1B8F5D49A058}.Release|x64.ActiveCfg = Release|x64 + {E9E0A1F6-0009-4E8C-B8F8-1B8F5D49A058}.Release|x64.Build.0 = Release|x64 {51F35FAE-FB92-4B2C-9187-1542C065AD77}.Debug|Win32.ActiveCfg = Debug|Win32 {51F35FAE-FB92-4B2C-9187-1542C065AD77}.Debug|Win32.Build.0 = Debug|Win32 + {51F35FAE-FB92-4B2C-9187-1542C065AD77}.Debug|x64.ActiveCfg = Debug|x64 + {51F35FAE-FB92-4B2C-9187-1542C065AD77}.Debug|x64.Build.0 = Debug|x64 + {51F35FAE-FB92-4B2C-9187-1542C065AD77}.PGIRelease|Win32.ActiveCfg = Release|Win32 + {51F35FAE-FB92-4B2C-9187-1542C065AD77}.PGIRelease|Win32.Build.0 = Release|Win32 + {51F35FAE-FB92-4B2C-9187-1542C065AD77}.PGIRelease|x64.ActiveCfg = Release|x64 + {51F35FAE-FB92-4B2C-9187-1542C065AD77}.PGIRelease|x64.Build.0 = Release|x64 + {51F35FAE-FB92-4B2C-9187-1542C065AD77}.PGORelease|Win32.ActiveCfg = Release|Win32 + {51F35FAE-FB92-4B2C-9187-1542C065AD77}.PGORelease|Win32.Build.0 = Release|Win32 + {51F35FAE-FB92-4B2C-9187-1542C065AD77}.PGORelease|x64.ActiveCfg = Release|x64 + {51F35FAE-FB92-4B2C-9187-1542C065AD77}.PGORelease|x64.Build.0 = Release|x64 {51F35FAE-FB92-4B2C-9187-1542C065AD77}.Release|Win32.ActiveCfg = Release|Win32 {51F35FAE-FB92-4B2C-9187-1542C065AD77}.Release|Win32.Build.0 = Release|Win32 - {51F35FAE-FB92-4B2C-9187-1542C065AD77}.ReleaseAMD64|Win32.ActiveCfg = ReleaseAMD64|Win32 - {51F35FAE-FB92-4B2C-9187-1542C065AD77}.ReleaseAMD64|Win32.Build.0 = ReleaseAMD64|Win32 - {51F35FAE-FB92-4B2C-9187-1542C065AD77}.ReleaseItanium|Win32.ActiveCfg = ReleaseItanium|Win32 - {51F35FAE-FB92-4B2C-9187-1542C065AD77}.ReleaseItanium|Win32.Build.0 = ReleaseItanium|Win32 + {51F35FAE-FB92-4B2C-9187-1542C065AD77}.Release|x64.ActiveCfg = Release|x64 + {51F35FAE-FB92-4B2C-9187-1542C065AD77}.Release|x64.Build.0 = Release|x64 {1966DDE2-4AB7-4E4E-ACC9-C121E4D37F8E}.Debug|Win32.ActiveCfg = Debug|Win32 {1966DDE2-4AB7-4E4E-ACC9-C121E4D37F8E}.Debug|Win32.Build.0 = Debug|Win32 + {1966DDE2-4AB7-4E4E-ACC9-C121E4D37F8E}.Debug|x64.ActiveCfg = Debug|x64 + {1966DDE2-4AB7-4E4E-ACC9-C121E4D37F8E}.Debug|x64.Build.0 = Debug|x64 + {1966DDE2-4AB7-4E4E-ACC9-C121E4D37F8E}.PGIRelease|Win32.ActiveCfg = Release|Win32 + {1966DDE2-4AB7-4E4E-ACC9-C121E4D37F8E}.PGIRelease|Win32.Build.0 = Release|Win32 + {1966DDE2-4AB7-4E4E-ACC9-C121E4D37F8E}.PGIRelease|x64.ActiveCfg = Release|x64 + {1966DDE2-4AB7-4E4E-ACC9-C121E4D37F8E}.PGIRelease|x64.Build.0 = Release|x64 + {1966DDE2-4AB7-4E4E-ACC9-C121E4D37F8E}.PGORelease|Win32.ActiveCfg = Release|Win32 + {1966DDE2-4AB7-4E4E-ACC9-C121E4D37F8E}.PGORelease|Win32.Build.0 = Release|Win32 + {1966DDE2-4AB7-4E4E-ACC9-C121E4D37F8E}.PGORelease|x64.ActiveCfg = Release|x64 + {1966DDE2-4AB7-4E4E-ACC9-C121E4D37F8E}.PGORelease|x64.Build.0 = Release|x64 {1966DDE2-4AB7-4E4E-ACC9-C121E4D37F8E}.Release|Win32.ActiveCfg = Release|Win32 {1966DDE2-4AB7-4E4E-ACC9-C121E4D37F8E}.Release|Win32.Build.0 = Release|Win32 - {1966DDE2-4AB7-4E4E-ACC9-C121E4D37F8E}.ReleaseAMD64|Win32.ActiveCfg = ReleaseAMD64|Win32 - {1966DDE2-4AB7-4E4E-ACC9-C121E4D37F8E}.ReleaseAMD64|Win32.Build.0 = ReleaseAMD64|Win32 - {1966DDE2-4AB7-4E4E-ACC9-C121E4D37F8E}.ReleaseItanium|Win32.ActiveCfg = ReleaseItanium|Win32 - {1966DDE2-4AB7-4E4E-ACC9-C121E4D37F8E}.ReleaseItanium|Win32.Build.0 = ReleaseItanium|Win32 + {1966DDE2-4AB7-4E4E-ACC9-C121E4D37F8E}.Release|x64.ActiveCfg = Release|x64 + {1966DDE2-4AB7-4E4E-ACC9-C121E4D37F8E}.Release|x64.Build.0 = Release|x64 {C73F0EC1-358B-4177-940F-0846AC8B04CD}.Debug|Win32.ActiveCfg = Debug|Win32 {C73F0EC1-358B-4177-940F-0846AC8B04CD}.Debug|Win32.Build.0 = Debug|Win32 - {C73F0EC1-358B-4177-940F-0846AC8B04CD}.Release|Win32.ActiveCfg = Release|Win32 - {C73F0EC1-358B-4177-940F-0846AC8B04CD}.Release|Win32.Build.0 = Release|Win32 - {C73F0EC1-358B-4177-940F-0846AC8B04CD}.ReleaseAMD64|Win32.ActiveCfg = Release|Win32 - {C73F0EC1-358B-4177-940F-0846AC8B04CD}.ReleaseAMD64|Win32.Build.0 = Release|Win32 - {C73F0EC1-358B-4177-940F-0846AC8B04CD}.ReleaseItanium|Win32.ActiveCfg = Release|Win32 - {C73F0EC1-358B-4177-940F-0846AC8B04CD}.ReleaseItanium|Win32.Build.0 = Release|Win32 + {C73F0EC1-358B-4177-940F-0846AC8B04CD}.Debug|x64.ActiveCfg = Debug|Win32 + {C73F0EC1-358B-4177-940F-0846AC8B04CD}.Debug|x64.Build.0 = Debug|Win32 + {C73F0EC1-358B-4177-940F-0846AC8B04CD}.PGIRelease|Win32.ActiveCfg = Debug|Win32 + {C73F0EC1-358B-4177-940F-0846AC8B04CD}.PGIRelease|Win32.Build.0 = Debug|Win32 + {C73F0EC1-358B-4177-940F-0846AC8B04CD}.PGIRelease|x64.ActiveCfg = Debug|Win32 + {C73F0EC1-358B-4177-940F-0846AC8B04CD}.PGORelease|Win32.ActiveCfg = Debug|Win32 + {C73F0EC1-358B-4177-940F-0846AC8B04CD}.PGORelease|Win32.Build.0 = Debug|Win32 + {C73F0EC1-358B-4177-940F-0846AC8B04CD}.PGORelease|x64.ActiveCfg = Debug|Win32 + {C73F0EC1-358B-4177-940F-0846AC8B04CD}.Release|Win32.ActiveCfg = Debug|Win32 + {C73F0EC1-358B-4177-940F-0846AC8B04CD}.Release|Win32.Build.0 = Debug|Win32 + {C73F0EC1-358B-4177-940F-0846AC8B04CD}.Release|x64.ActiveCfg = Debug|Win32 + {C73F0EC1-358B-4177-940F-0846AC8B04CD}.Release|x64.Build.0 = Debug|Win32 {2C0BEFB9-70E2-4F80-AC5B-4AB8EE023574}.Debug|Win32.ActiveCfg = Debug|Win32 {2C0BEFB9-70E2-4F80-AC5B-4AB8EE023574}.Debug|Win32.Build.0 = Debug|Win32 + {2C0BEFB9-70E2-4F80-AC5B-4AB8EE023574}.Debug|x64.ActiveCfg = Debug|x64 + {2C0BEFB9-70E2-4F80-AC5B-4AB8EE023574}.Debug|x64.Build.0 = Debug|x64 + {2C0BEFB9-70E2-4F80-AC5B-4AB8EE023574}.PGIRelease|Win32.ActiveCfg = Release|Win32 + {2C0BEFB9-70E2-4F80-AC5B-4AB8EE023574}.PGIRelease|Win32.Build.0 = Release|Win32 + {2C0BEFB9-70E2-4F80-AC5B-4AB8EE023574}.PGIRelease|x64.ActiveCfg = Release|x64 + {2C0BEFB9-70E2-4F80-AC5B-4AB8EE023574}.PGIRelease|x64.Build.0 = Release|x64 + {2C0BEFB9-70E2-4F80-AC5B-4AB8EE023574}.PGORelease|Win32.ActiveCfg = Release|Win32 + {2C0BEFB9-70E2-4F80-AC5B-4AB8EE023574}.PGORelease|Win32.Build.0 = Release|Win32 + {2C0BEFB9-70E2-4F80-AC5B-4AB8EE023574}.PGORelease|x64.ActiveCfg = Release|x64 + {2C0BEFB9-70E2-4F80-AC5B-4AB8EE023574}.PGORelease|x64.Build.0 = Release|x64 {2C0BEFB9-70E2-4F80-AC5B-4AB8EE023574}.Release|Win32.ActiveCfg = Release|Win32 {2C0BEFB9-70E2-4F80-AC5B-4AB8EE023574}.Release|Win32.Build.0 = Release|Win32 - {2C0BEFB9-70E2-4F80-AC5B-4AB8EE023574}.ReleaseAMD64|Win32.ActiveCfg = ReleaseAMD64|Win32 - {2C0BEFB9-70E2-4F80-AC5B-4AB8EE023574}.ReleaseAMD64|Win32.Build.0 = ReleaseAMD64|Win32 - {2C0BEFB9-70E2-4F80-AC5B-4AB8EE023574}.ReleaseItanium|Win32.ActiveCfg = ReleaseItanium|Win32 - {2C0BEFB9-70E2-4F80-AC5B-4AB8EE023574}.ReleaseItanium|Win32.Build.0 = ReleaseItanium|Win32 + {2C0BEFB9-70E2-4F80-AC5B-4AB8EE023574}.Release|x64.ActiveCfg = Release|x64 + {2C0BEFB9-70E2-4F80-AC5B-4AB8EE023574}.Release|x64.Build.0 = Release|x64 {F22F40F4-D318-40DC-96B3-88DC81CE0894}.Debug|Win32.ActiveCfg = Debug|Win32 {F22F40F4-D318-40DC-96B3-88DC81CE0894}.Debug|Win32.Build.0 = Debug|Win32 + {F22F40F4-D318-40DC-96B3-88DC81CE0894}.Debug|x64.ActiveCfg = Debug|x64 + {F22F40F4-D318-40DC-96B3-88DC81CE0894}.Debug|x64.Build.0 = Debug|x64 + {F22F40F4-D318-40DC-96B3-88DC81CE0894}.PGIRelease|Win32.ActiveCfg = Release|Win32 + {F22F40F4-D318-40DC-96B3-88DC81CE0894}.PGIRelease|Win32.Build.0 = Release|Win32 + {F22F40F4-D318-40DC-96B3-88DC81CE0894}.PGIRelease|x64.ActiveCfg = Release|x64 + {F22F40F4-D318-40DC-96B3-88DC81CE0894}.PGIRelease|x64.Build.0 = Release|x64 + {F22F40F4-D318-40DC-96B3-88DC81CE0894}.PGORelease|Win32.ActiveCfg = Release|Win32 + {F22F40F4-D318-40DC-96B3-88DC81CE0894}.PGORelease|Win32.Build.0 = Release|Win32 + {F22F40F4-D318-40DC-96B3-88DC81CE0894}.PGORelease|x64.ActiveCfg = Release|x64 + {F22F40F4-D318-40DC-96B3-88DC81CE0894}.PGORelease|x64.Build.0 = Release|x64 {F22F40F4-D318-40DC-96B3-88DC81CE0894}.Release|Win32.ActiveCfg = Release|Win32 {F22F40F4-D318-40DC-96B3-88DC81CE0894}.Release|Win32.Build.0 = Release|Win32 - {F22F40F4-D318-40DC-96B3-88DC81CE0894}.ReleaseAMD64|Win32.ActiveCfg = ReleaseAMD64|Win32 - {F22F40F4-D318-40DC-96B3-88DC81CE0894}.ReleaseItanium|Win32.ActiveCfg = ReleaseItanium|Win32 + {F22F40F4-D318-40DC-96B3-88DC81CE0894}.Release|x64.ActiveCfg = Release|x64 {8CF334D9-4F82-42EB-97AF-83592C5AFD2F}.Debug|Win32.ActiveCfg = Debug|Win32 {8CF334D9-4F82-42EB-97AF-83592C5AFD2F}.Debug|Win32.Build.0 = Debug|Win32 + {8CF334D9-4F82-42EB-97AF-83592C5AFD2F}.Debug|x64.ActiveCfg = Debug|x64 + {8CF334D9-4F82-42EB-97AF-83592C5AFD2F}.Debug|x64.Build.0 = Debug|x64 + {8CF334D9-4F82-42EB-97AF-83592C5AFD2F}.PGIRelease|Win32.ActiveCfg = Release|Win32 + {8CF334D9-4F82-42EB-97AF-83592C5AFD2F}.PGIRelease|Win32.Build.0 = Release|Win32 + {8CF334D9-4F82-42EB-97AF-83592C5AFD2F}.PGIRelease|x64.ActiveCfg = Release|x64 + {8CF334D9-4F82-42EB-97AF-83592C5AFD2F}.PGIRelease|x64.Build.0 = Release|x64 + {8CF334D9-4F82-42EB-97AF-83592C5AFD2F}.PGORelease|Win32.ActiveCfg = Release|Win32 + {8CF334D9-4F82-42EB-97AF-83592C5AFD2F}.PGORelease|Win32.Build.0 = Release|Win32 + {8CF334D9-4F82-42EB-97AF-83592C5AFD2F}.PGORelease|x64.ActiveCfg = Release|x64 + {8CF334D9-4F82-42EB-97AF-83592C5AFD2F}.PGORelease|x64.Build.0 = Release|x64 {8CF334D9-4F82-42EB-97AF-83592C5AFD2F}.Release|Win32.ActiveCfg = Release|Win32 {8CF334D9-4F82-42EB-97AF-83592C5AFD2F}.Release|Win32.Build.0 = Release|Win32 - {8CF334D9-4F82-42EB-97AF-83592C5AFD2F}.ReleaseAMD64|Win32.ActiveCfg = ReleaseAMD64|Win32 - {8CF334D9-4F82-42EB-97AF-83592C5AFD2F}.ReleaseItanium|Win32.ActiveCfg = ReleaseItanium|Win32 + {8CF334D9-4F82-42EB-97AF-83592C5AFD2F}.Release|x64.ActiveCfg = Release|x64 + {8CF334D9-4F82-42EB-97AF-83592C5AFD2F}.Release|x64.Build.0 = Release|x64 {2FF0A312-22F9-4C34-B070-842916DE27A9}.Debug|Win32.ActiveCfg = Debug|Win32 {2FF0A312-22F9-4C34-B070-842916DE27A9}.Debug|Win32.Build.0 = Debug|Win32 + {2FF0A312-22F9-4C34-B070-842916DE27A9}.Debug|x64.ActiveCfg = Debug|x64 + {2FF0A312-22F9-4C34-B070-842916DE27A9}.Debug|x64.Build.0 = Debug|x64 + {2FF0A312-22F9-4C34-B070-842916DE27A9}.PGIRelease|Win32.ActiveCfg = Release|Win32 + {2FF0A312-22F9-4C34-B070-842916DE27A9}.PGIRelease|Win32.Build.0 = Release|Win32 + {2FF0A312-22F9-4C34-B070-842916DE27A9}.PGIRelease|x64.ActiveCfg = Release|x64 + {2FF0A312-22F9-4C34-B070-842916DE27A9}.PGIRelease|x64.Build.0 = Release|x64 + {2FF0A312-22F9-4C34-B070-842916DE27A9}.PGORelease|Win32.ActiveCfg = Release|Win32 + {2FF0A312-22F9-4C34-B070-842916DE27A9}.PGORelease|Win32.Build.0 = Release|Win32 + {2FF0A312-22F9-4C34-B070-842916DE27A9}.PGORelease|x64.ActiveCfg = Release|x64 + {2FF0A312-22F9-4C34-B070-842916DE27A9}.PGORelease|x64.Build.0 = Release|x64 {2FF0A312-22F9-4C34-B070-842916DE27A9}.Release|Win32.ActiveCfg = Release|Win32 {2FF0A312-22F9-4C34-B070-842916DE27A9}.Release|Win32.Build.0 = Release|Win32 - {2FF0A312-22F9-4C34-B070-842916DE27A9}.ReleaseAMD64|Win32.ActiveCfg = ReleaseAMD64|Win32 - {2FF0A312-22F9-4C34-B070-842916DE27A9}.ReleaseAMD64|Win32.Build.0 = ReleaseAMD64|Win32 - {2FF0A312-22F9-4C34-B070-842916DE27A9}.ReleaseItanium|Win32.ActiveCfg = ReleaseItanium|Win32 - {2FF0A312-22F9-4C34-B070-842916DE27A9}.ReleaseItanium|Win32.Build.0 = ReleaseItanium|Win32 - {8B59C1FF-2439-4BE9-9F24-84D4982D28D4}.Debug|Win32.ActiveCfg = Release|Win32 - {8B59C1FF-2439-4BE9-9F24-84D4982D28D4}.Debug|Win32.Build.0 = Release|Win32 - {8B59C1FF-2439-4BE9-9F24-84D4982D28D4}.Release|Win32.ActiveCfg = Release|Win32 - {8B59C1FF-2439-4BE9-9F24-84D4982D28D4}.Release|Win32.Build.0 = Release|Win32 - {8B59C1FF-2439-4BE9-9F24-84D4982D28D4}.ReleaseAMD64|Win32.ActiveCfg = Release|Win32 - {8B59C1FF-2439-4BE9-9F24-84D4982D28D4}.ReleaseAMD64|Win32.Build.0 = Release|Win32 - {8B59C1FF-2439-4BE9-9F24-84D4982D28D4}.ReleaseItanium|Win32.ActiveCfg = Release|Win32 - {8B59C1FF-2439-4BE9-9F24-84D4982D28D4}.ReleaseItanium|Win32.Build.0 = Release|Win32 + {2FF0A312-22F9-4C34-B070-842916DE27A9}.Release|x64.ActiveCfg = Release|x64 + {2FF0A312-22F9-4C34-B070-842916DE27A9}.Release|x64.Build.0 = Release|x64 {B11D750F-CD1F-4A96-85CE-E69A5C5259F9}.Debug|Win32.ActiveCfg = Debug|Win32 {B11D750F-CD1F-4A96-85CE-E69A5C5259F9}.Debug|Win32.Build.0 = Debug|Win32 + {B11D750F-CD1F-4A96-85CE-E69A5C5259F9}.Debug|x64.ActiveCfg = Debug|x64 + {B11D750F-CD1F-4A96-85CE-E69A5C5259F9}.Debug|x64.Build.0 = Debug|x64 + {B11D750F-CD1F-4A96-85CE-E69A5C5259F9}.PGIRelease|Win32.ActiveCfg = Release|Win32 + {B11D750F-CD1F-4A96-85CE-E69A5C5259F9}.PGIRelease|Win32.Build.0 = Release|Win32 + {B11D750F-CD1F-4A96-85CE-E69A5C5259F9}.PGIRelease|x64.ActiveCfg = Release|x64 + {B11D750F-CD1F-4A96-85CE-E69A5C5259F9}.PGIRelease|x64.Build.0 = Release|x64 + {B11D750F-CD1F-4A96-85CE-E69A5C5259F9}.PGORelease|Win32.ActiveCfg = Release|Win32 + {B11D750F-CD1F-4A96-85CE-E69A5C5259F9}.PGORelease|Win32.Build.0 = Release|Win32 + {B11D750F-CD1F-4A96-85CE-E69A5C5259F9}.PGORelease|x64.ActiveCfg = Release|x64 + {B11D750F-CD1F-4A96-85CE-E69A5C5259F9}.PGORelease|x64.Build.0 = Release|x64 {B11D750F-CD1F-4A96-85CE-E69A5C5259F9}.Release|Win32.ActiveCfg = Release|Win32 {B11D750F-CD1F-4A96-85CE-E69A5C5259F9}.Release|Win32.Build.0 = Release|Win32 - {B11D750F-CD1F-4A96-85CE-E69A5C5259F9}.ReleaseAMD64|Win32.ActiveCfg = ReleaseAMD64|Win32 - {B11D750F-CD1F-4A96-85CE-E69A5C5259F9}.ReleaseAMD64|Win32.Build.0 = ReleaseAMD64|Win32 - {B11D750F-CD1F-4A96-85CE-E69A5C5259F9}.ReleaseItanium|Win32.ActiveCfg = ReleaseItanium|Win32 - {B11D750F-CD1F-4A96-85CE-E69A5C5259F9}.ReleaseItanium|Win32.Build.0 = ReleaseItanium|Win32 + {B11D750F-CD1F-4A96-85CE-E69A5C5259F9}.Release|x64.ActiveCfg = Release|x64 + {B11D750F-CD1F-4A96-85CE-E69A5C5259F9}.Release|x64.Build.0 = Release|x64 {F0E0541E-F17D-430B-97C4-93ADF0DD284E}.Debug|Win32.ActiveCfg = Debug|Win32 {F0E0541E-F17D-430B-97C4-93ADF0DD284E}.Debug|Win32.Build.0 = Debug|Win32 + {F0E0541E-F17D-430B-97C4-93ADF0DD284E}.Debug|x64.ActiveCfg = Debug|Win32 + {F0E0541E-F17D-430B-97C4-93ADF0DD284E}.Debug|x64.Build.0 = Debug|Win32 + {F0E0541E-F17D-430B-97C4-93ADF0DD284E}.PGIRelease|Win32.ActiveCfg = Release|Win32 + {F0E0541E-F17D-430B-97C4-93ADF0DD284E}.PGIRelease|Win32.Build.0 = Release|Win32 + {F0E0541E-F17D-430B-97C4-93ADF0DD284E}.PGIRelease|x64.ActiveCfg = Release|Win32 + {F0E0541E-F17D-430B-97C4-93ADF0DD284E}.PGORelease|Win32.ActiveCfg = Release|Win32 + {F0E0541E-F17D-430B-97C4-93ADF0DD284E}.PGORelease|Win32.Build.0 = Release|Win32 + {F0E0541E-F17D-430B-97C4-93ADF0DD284E}.PGORelease|x64.ActiveCfg = Release|Win32 {F0E0541E-F17D-430B-97C4-93ADF0DD284E}.Release|Win32.ActiveCfg = Release|Win32 {F0E0541E-F17D-430B-97C4-93ADF0DD284E}.Release|Win32.Build.0 = Release|Win32 - {F0E0541E-F17D-430B-97C4-93ADF0DD284E}.ReleaseAMD64|Win32.ActiveCfg = Release|Win32 - {F0E0541E-F17D-430B-97C4-93ADF0DD284E}.ReleaseAMD64|Win32.Build.0 = Release|Win32 - {F0E0541E-F17D-430B-97C4-93ADF0DD284E}.ReleaseItanium|Win32.ActiveCfg = Release|Win32 - {F0E0541E-F17D-430B-97C4-93ADF0DD284E}.ReleaseItanium|Win32.Build.0 = Release|Win32 + {F0E0541E-F17D-430B-97C4-93ADF0DD284E}.Release|x64.ActiveCfg = Release|Win32 + {F0E0541E-F17D-430B-97C4-93ADF0DD284E}.Release|x64.Build.0 = Release|Win32 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE Modified: python/branches/p3yk/PCbuild8/python.vcproj ============================================================================== --- python/branches/p3yk/PCbuild8/python.vcproj (original) +++ python/branches/p3yk/PCbuild8/python.vcproj Wed Dec 13 05:49:30 2006 @@ -4,19 +4,23 @@ Version="8,00" Name="python" ProjectGUID="{B11D750F-CD1F-4A96-85CE-E69A5C5259F9}" + RootNamespace="python" > + @@ -239,25 +241,26 @@ /> @@ -333,25 +331,26 @@ /> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -253,23 +440,21 @@ /> @@ -350,23 +537,21 @@ /> - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -558,6 +1297,10 @@ > + + @@ -738,6 +1481,74 @@ > + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -797,6 +1608,14 @@ /> + + + + + + + + + + + + + + Deleted: /python/branches/p3yk/PCbuild8/pythoncore_pgo.vcproj ============================================================================== --- /python/branches/p3yk/PCbuild8/pythoncore_pgo.vcproj Wed Dec 13 05:49:30 2006 +++ (empty file) @@ -1,781 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Deleted: /python/branches/p3yk/PCbuild8/pythoncore_pgo_link.txt ============================================================================== --- /python/branches/p3yk/PCbuild8/pythoncore_pgo_link.txt Wed Dec 13 05:49:30 2006 +++ (empty file) @@ -1,311 +0,0 @@ -/OUT:".\pythoncore_pgo/python25.dll" /INCREMENTAL:NO /DLL /MANIFEST /MANIFESTFILE:".\x86-temp-release\pythoncore_pgo\python25.dll.intermediate.manifest" /NODEFAULTLIB:"libc" /DEBUG /PDB:".\pythoncore_pgo/python25.pdb" /SUBSYSTEM:WINDOWS /LTCG:PGINSTRUMENT /PGD:".\pythoncore_pgo\python25.pgd" /BASE:"0x1e000000" /IMPLIB:"pythoncore_pgo/python25.lib" /MACHINE:X86 getbuildinfo.o kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib - -".\x86-temp-release\pythoncore_pgo\adler32.obj" - -".\x86-temp-release\pythoncore_pgo\compress.obj" - -".\x86-temp-release\pythoncore_pgo\crc32.obj" - -".\x86-temp-release\pythoncore_pgo\deflate.obj" - -".\x86-temp-release\pythoncore_pgo\gzio.obj" - -".\x86-temp-release\pythoncore_pgo\infback.obj" - -".\x86-temp-release\pythoncore_pgo\inffast.obj" - -".\x86-temp-release\pythoncore_pgo\inflate.obj" - -".\x86-temp-release\pythoncore_pgo\inftrees.obj" - -".\x86-temp-release\pythoncore_pgo\trees.obj" - -".\x86-temp-release\pythoncore_pgo\uncompr.obj" - -".\x86-temp-release\pythoncore_pgo\zlibmodule.obj" - -".\x86-temp-release\pythoncore_pgo\zutil.obj" - -".\x86-temp-release\pythoncore_pgo\_bisectmodule.obj" - -".\x86-temp-release\pythoncore_pgo\_codecs_cn.obj" - -".\x86-temp-release\pythoncore_pgo\_codecs_hk.obj" - -".\x86-temp-release\pythoncore_pgo\_codecs_iso2022.obj" - -".\x86-temp-release\pythoncore_pgo\_codecs_jp.obj" - -".\x86-temp-release\pythoncore_pgo\_codecs_kr.obj" - -".\x86-temp-release\pythoncore_pgo\_codecs_tw.obj" - -".\x86-temp-release\pythoncore_pgo\_codecsmodule.obj" - -".\x86-temp-release\pythoncore_pgo\_csv.obj" - -".\x86-temp-release\pythoncore_pgo\_functoolsmodule.obj" - -".\x86-temp-release\pythoncore_pgo\_heapqmodule.obj" - -".\x86-temp-release\pythoncore_pgo\_hotshot.obj" - -".\x86-temp-release\pythoncore_pgo\_localemodule.obj" - -".\x86-temp-release\pythoncore_pgo\_lsprof.obj" - -".\x86-temp-release\pythoncore_pgo\_randommodule.obj" - -".\x86-temp-release\pythoncore_pgo\_sre.obj" - -".\x86-temp-release\pythoncore_pgo\_struct.obj" - -".\x86-temp-release\pythoncore_pgo\_subprocess.obj" - -".\x86-temp-release\pythoncore_pgo\_weakref.obj" - -".\x86-temp-release\pythoncore_pgo\_winreg.obj" - -".\x86-temp-release\pythoncore_pgo\abstract.obj" - -".\x86-temp-release\pythoncore_pgo\acceler.obj" - -".\x86-temp-release\pythoncore_pgo\arraymodule.obj" - -".\x86-temp-release\pythoncore_pgo\asdl.obj" - -".\x86-temp-release\pythoncore_pgo\ast.obj" - -".\x86-temp-release\pythoncore_pgo\audioop.obj" - -".\x86-temp-release\pythoncore_pgo\binascii.obj" - -".\x86-temp-release\pythoncore_pgo\bitset.obj" - -".\x86-temp-release\pythoncore_pgo\bltinmodule.obj" - -".\x86-temp-release\pythoncore_pgo\boolobject.obj" - -".\x86-temp-release\pythoncore_pgo\bufferobject.obj" - -".\x86-temp-release\pythoncore_pgo\cellobject.obj" - -".\x86-temp-release\pythoncore_pgo\ceval.obj" - -".\x86-temp-release\pythoncore_pgo\classobject.obj" - -".\x86-temp-release\pythoncore_pgo\cmathmodule.obj" - -".\x86-temp-release\pythoncore_pgo\cobject.obj" - -".\x86-temp-release\pythoncore_pgo\codecs.obj" - -".\x86-temp-release\pythoncore_pgo\codeobject.obj" - -".\x86-temp-release\pythoncore_pgo\collectionsmodule.obj" - -".\x86-temp-release\pythoncore_pgo\compile.obj" - -".\x86-temp-release\pythoncore_pgo\complexobject.obj" - -".\x86-temp-release\pythoncore_pgo\config.obj" - -".\x86-temp-release\pythoncore_pgo\cPickle.obj" - -".\x86-temp-release\pythoncore_pgo\cStringIO.obj" - -".\x86-temp-release\pythoncore_pgo\datetimemodule.obj" - -".\x86-temp-release\pythoncore_pgo\descrobject.obj" - -".\x86-temp-release\pythoncore_pgo\dictobject.obj" - -".\x86-temp-release\pythoncore_pgo\dl_nt.obj" - -".\x86-temp-release\pythoncore_pgo\dynload_win.obj" - -".\x86-temp-release\pythoncore_pgo\enumobject.obj" - -".\x86-temp-release\pythoncore_pgo\errnomodule.obj" - -".\x86-temp-release\pythoncore_pgo\errors.obj" - -".\x86-temp-release\pythoncore_pgo\exceptions.obj" - -".\x86-temp-release\pythoncore_pgo\fileobject.obj" - -".\x86-temp-release\pythoncore_pgo\firstsets.obj" - -".\x86-temp-release\pythoncore_pgo\floatobject.obj" - -".\x86-temp-release\pythoncore_pgo\frameobject.obj" - -".\x86-temp-release\pythoncore_pgo\frozen.obj" - -".\x86-temp-release\pythoncore_pgo\funcobject.obj" - -".\x86-temp-release\pythoncore_pgo\future.obj" - -".\x86-temp-release\pythoncore_pgo\gcmodule.obj" - -".\x86-temp-release\pythoncore_pgo\genobject.obj" - -".\x86-temp-release\pythoncore_pgo\getargs.obj" - -".\x86-temp-release\pythoncore_pgo\getcompiler.obj" - -".\x86-temp-release\pythoncore_pgo\getcopyright.obj" - -".\x86-temp-release\pythoncore_pgo\getmtime.obj" - -".\x86-temp-release\pythoncore_pgo\getopt.obj" - -".\x86-temp-release\pythoncore_pgo\getpathp.obj" - -".\x86-temp-release\pythoncore_pgo\getplatform.obj" - -".\x86-temp-release\pythoncore_pgo\getversion.obj" - -".\x86-temp-release\pythoncore_pgo\graminit.obj" - -".\x86-temp-release\pythoncore_pgo\grammar.obj" - -".\x86-temp-release\pythoncore_pgo\grammar1.obj" - -".\x86-temp-release\pythoncore_pgo\imageop.obj" - -".\x86-temp-release\pythoncore_pgo\import.obj" - -".\x86-temp-release\pythoncore_pgo\import_nt.obj" - -".\x86-temp-release\pythoncore_pgo\importdl.obj" - -".\x86-temp-release\pythoncore_pgo\intobject.obj" - -".\x86-temp-release\pythoncore_pgo\iterobject.obj" - -".\x86-temp-release\pythoncore_pgo\itertoolsmodule.obj" - -".\x86-temp-release\pythoncore_pgo\listnode.obj" - -".\x86-temp-release\pythoncore_pgo\listobject.obj" - -".\x86-temp-release\pythoncore_pgo\longobject.obj" - -".\x86-temp-release\pythoncore_pgo\main.obj" - -".\x86-temp-release\pythoncore_pgo\marshal.obj" - -".\x86-temp-release\pythoncore_pgo\mathmodule.obj" - -".\x86-temp-release\pythoncore_pgo\md5.obj" - -".\x86-temp-release\pythoncore_pgo\md5module.obj" - -".\x86-temp-release\pythoncore_pgo\metagrammar.obj" - -".\x86-temp-release\pythoncore_pgo\methodobject.obj" - -".\x86-temp-release\pythoncore_pgo\mmapmodule.obj" - -".\x86-temp-release\pythoncore_pgo\modsupport.obj" - -".\x86-temp-release\pythoncore_pgo\moduleobject.obj" - -".\x86-temp-release\pythoncore_pgo\msvcrtmodule.obj" - -".\x86-temp-release\pythoncore_pgo\multibytecodec.obj" - -".\x86-temp-release\pythoncore_pgo\myreadline.obj" - -".\x86-temp-release\pythoncore_pgo\mysnprintf.obj" - -".\x86-temp-release\pythoncore_pgo\mystrtoul.obj" - -".\x86-temp-release\pythoncore_pgo\node.obj" - -".\x86-temp-release\pythoncore_pgo\object.obj" - -".\x86-temp-release\pythoncore_pgo\obmalloc.obj" - -".\x86-temp-release\pythoncore_pgo\operator.obj" - -".\x86-temp-release\pythoncore_pgo\parser.obj" - -".\x86-temp-release\pythoncore_pgo\parsermodule.obj" - -".\x86-temp-release\pythoncore_pgo\parsetok.obj" - -".\x86-temp-release\pythoncore_pgo\posixmodule.obj" - -".\x86-temp-release\pythoncore_pgo\pyarena.obj" - -".\x86-temp-release\pythoncore_pgo\pyfpe.obj" - -".\x86-temp-release\pythoncore_pgo\pystate.obj" - -".\x86-temp-release\pythoncore_pgo\pystrtod.obj" - -".\x86-temp-release\pythoncore_pgo\Python-ast.obj" - -".\x86-temp-release\pythoncore_pgo\python_nt.res" - -".\x86-temp-release\pythoncore_pgo\pythonrun.obj" - -".\x86-temp-release\pythoncore_pgo\rangeobject.obj" - -".\x86-temp-release\pythoncore_pgo\rgbimgmodule.obj" - -".\x86-temp-release\pythoncore_pgo\rotatingtree.obj" - -".\x86-temp-release\pythoncore_pgo\setobject.obj" - -".\x86-temp-release\pythoncore_pgo\sha256module.obj" - -".\x86-temp-release\pythoncore_pgo\sha512module.obj" - -".\x86-temp-release\pythoncore_pgo\shamodule.obj" - -".\x86-temp-release\pythoncore_pgo\signalmodule.obj" - -".\x86-temp-release\pythoncore_pgo\sliceobject.obj" - -".\x86-temp-release\pythoncore_pgo\stringobject.obj" - -".\x86-temp-release\pythoncore_pgo\stropmodule.obj" - -".\x86-temp-release\pythoncore_pgo\structmember.obj" - -".\x86-temp-release\pythoncore_pgo\structseq.obj" - -".\x86-temp-release\pythoncore_pgo\symtable.obj" - -".\x86-temp-release\pythoncore_pgo\symtablemodule.obj" - -".\x86-temp-release\pythoncore_pgo\sysmodule.obj" - -".\x86-temp-release\pythoncore_pgo\thread.obj" - -".\x86-temp-release\pythoncore_pgo\threadmodule.obj" - -".\x86-temp-release\pythoncore_pgo\timemodule.obj" - -".\x86-temp-release\pythoncore_pgo\tokenizer.obj" - -".\x86-temp-release\pythoncore_pgo\traceback.obj" - -".\x86-temp-release\pythoncore_pgo\tupleobject.obj" - -".\x86-temp-release\pythoncore_pgo\typeobject.obj" - -".\x86-temp-release\pythoncore_pgo\unicodectype.obj" - -".\x86-temp-release\pythoncore_pgo\unicodeobject.obj" - -".\x86-temp-release\pythoncore_pgo\weakrefobject.obj" - -".\x86-temp-release\pythoncore_pgo\xxsubtype.obj" - -".\x86-temp-release\pythoncore_pgo\yuvconvert.obj" - -".\x86-temp-release\pythoncore_pgo\zipimport.obj" Modified: python/branches/p3yk/PCbuild8/pythonw.vcproj ============================================================================== --- python/branches/p3yk/PCbuild8/pythonw.vcproj (original) +++ python/branches/p3yk/PCbuild8/pythonw.vcproj Wed Dec 13 05:49:30 2006 @@ -4,19 +4,23 @@ Version="8,00" Name="pythonw" ProjectGUID="{F4229CC3-873C-49AE-9729-DD308ED4CD4A}" + RootNamespace="pythonw" > + @@ -240,16 +240,16 @@ /> @@ -332,16 +329,16 @@ /> + @@ -238,18 +241,18 @@ /> @@ -330,18 +327,18 @@ /> + @@ -234,14 +237,15 @@ /> @@ -323,14 +322,15 @@ /> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Modified: python/branches/p3yk/PCbuild8/winsound.vcproj ============================================================================== --- python/branches/p3yk/PCbuild8/winsound.vcproj (original) +++ python/branches/p3yk/PCbuild8/winsound.vcproj Wed Dec 13 05:49:30 2006 @@ -4,19 +4,23 @@ Version="8,00" Name="winsound" ProjectGUID="{51F35FAE-FB92-4B2C-9187-1542C065AD77}" + RootNamespace="winsound" > + p_stack.s_top->s_parent; - node *ch; + node *ch, *cch; int i; /* from __future__ import ..., must have at least 4 children */ @@ -197,15 +197,17 @@ if (NCH(ch) == 1 && STR(CHILD(ch, 0)) && strcmp(STR(CHILD(ch, 0)), "__future__") != 0) return; - for (i = 3; i < NCH(n); i += 2) { - /* XXX: assume we don't have parentheses in import: - from __future__ import (x, y, z) - */ - ch = CHILD(n, i); - if (NCH(ch) == 1) - ch = CHILD(ch, 0); - if (NCH(ch) >= 1 && TYPE(CHILD(ch, 0)) == NAME && - strcmp(STR(CHILD(ch, 0)), "with_statement") == 0) { + ch = CHILD(n, 3); + /* ch can be a star, a parenthesis or import_as_names */ + if (TYPE(ch) == STAR) + return; + if (TYPE(ch) == LPAR) + ch = CHILD(n, 4); + + for (i = 0; i < NCH(ch); i += 2) { + cch = CHILD(ch, i); + if (NCH(cch) >= 1 && TYPE(CHILD(cch, 0)) == NAME && + strcmp(STR(CHILD(cch, 0)), "with_statement") == 0) { ps->p_flags |= CO_FUTURE_WITH_STATEMENT; break; } Modified: python/branches/p3yk/Parser/parsetok.c ============================================================================== --- python/branches/p3yk/Parser/parsetok.c (original) +++ python/branches/p3yk/Parser/parsetok.c Wed Dec 13 05:49:30 2006 @@ -82,9 +82,6 @@ return parsetok(tok, g, start, err_ret, flags); } -/* Parse input coming from the given tokenizer structure. - Return error code. */ - #ifdef PY_PARSER_REQUIRES_FUTURE_KEYWORD static char with_msg[] = "%s:%d: Warning: 'with' will become a reserved keyword in Python 2.6\n"; @@ -101,6 +98,9 @@ } #endif +/* Parse input coming from the given tokenizer structure. + Return error code. */ + static node * parsetok(struct tok_state *tok, grammar *g, int start, perrdetail *err_ret, int flags) Modified: python/branches/p3yk/Parser/tokenizer.c ============================================================================== --- python/branches/p3yk/Parser/tokenizer.c (original) +++ python/branches/p3yk/Parser/tokenizer.c Wed Dec 13 05:49:30 2006 @@ -896,7 +896,7 @@ tok->cur = tok->buf + cur; tok->line_start = tok->cur; /* replace "\r\n" with "\n" */ - /* For Mac leave the \r, giving syntax error */ + /* For Mac leave the \r, giving a syntax error */ pt = tok->inp - 2; if (pt >= tok->buf && *pt == '\r') { *pt++ = '\n'; Modified: python/branches/p3yk/Python/ast.c ============================================================================== --- python/branches/p3yk/Python/ast.c (original) +++ python/branches/p3yk/Python/ast.c Wed Dec 13 05:49:30 2006 @@ -15,12 +15,6 @@ #include -/* XXX TO DO - - re-indent this file (should be done) - - internal error checking (freeing memory, etc.) - - syntax errors -*/ - /* Data structure used internally */ struct compiling { char *c_encoding; /* source encoding */ @@ -43,7 +37,7 @@ static PyObject *parsestrplus(struct compiling *, const node *n); #ifndef LINENO -#define LINENO(n) ((n)->n_lineno) +#define LINENO(n) ((n)->n_lineno) #endif static identifier @@ -68,7 +62,7 @@ { PyObject *u = Py_BuildValue("zi", errstr, LINENO(n)); if (!u) - return 0; + return 0; PyErr_SetObject(PyExc_SyntaxError, u); Py_DECREF(u); return 0; @@ -82,36 +76,36 @@ assert(PyErr_Occurred()); if (!PyErr_ExceptionMatches(PyExc_SyntaxError)) - return; + return; PyErr_Fetch(&type, &value, &tback); errstr = PyTuple_GetItem(value, 0); if (!errstr) - return; + return; Py_INCREF(errstr); lineno = PyInt_AsLong(PyTuple_GetItem(value, 1)); if (lineno == -1) { - Py_DECREF(errstr); - return; + Py_DECREF(errstr); + return; } Py_DECREF(value); loc = PyErr_ProgramText(filename, lineno); if (!loc) { - Py_INCREF(Py_None); - loc = Py_None; + Py_INCREF(Py_None); + loc = Py_None; } tmp = Py_BuildValue("(zlOO)", filename, lineno, Py_None, loc); Py_DECREF(loc); if (!tmp) { - Py_DECREF(errstr); - return; + Py_DECREF(errstr); + return; } value = PyTuple_Pack(2, errstr, tmp); Py_DECREF(errstr); Py_DECREF(tmp); if (!value) - return; + return; PyErr_Restore(type, value, tback); } @@ -246,7 +240,7 @@ if (TYPE(CHILD(n, 0)) == NEWLINE) { stmts = asdl_seq_new(1, arena); if (!stmts) - goto error; + goto error; asdl_seq_SET(stmts, 0, Pass(n->n_lineno, n->n_col_offset, arena)); return Interactive(stmts, arena); @@ -256,11 +250,11 @@ num = num_stmts(n); stmts = asdl_seq_new(num, arena); if (!stmts) - goto error; + goto error; if (num == 1) { - s = ast_for_stmt(&c, n); - if (!s) - goto error; + s = ast_for_stmt(&c, n); + if (!s) + goto error; asdl_seq_SET(stmts, 0, s); } else { @@ -347,38 +341,38 @@ switch (e->kind) { case Attribute_kind: - if (ctx == Store && - !strcmp(PyString_AS_STRING(e->v.Attribute.attr), "None")) { - return ast_error(n, "assignment to None"); - } - e->v.Attribute.ctx = ctx; - break; + if (ctx == Store && + !strcmp(PyString_AS_STRING(e->v.Attribute.attr), "None")) { + return ast_error(n, "assignment to None"); + } + e->v.Attribute.ctx = ctx; + break; case Subscript_kind: - e->v.Subscript.ctx = ctx; - break; + e->v.Subscript.ctx = ctx; + break; case Name_kind: - if (ctx == Store && - !strcmp(PyString_AS_STRING(e->v.Name.id), "None")) { - return ast_error(n, "assignment to None"); - } - e->v.Name.ctx = ctx; - break; + if (ctx == Store && + !strcmp(PyString_AS_STRING(e->v.Name.id), "None")) { + return ast_error(n, "assignment to None"); + } + e->v.Name.ctx = ctx; + break; case List_kind: - e->v.List.ctx = ctx; - s = e->v.List.elts; - break; + e->v.List.ctx = ctx; + s = e->v.List.elts; + break; case Tuple_kind: if (asdl_seq_LEN(e->v.Tuple.elts) == 0) return ast_error(n, "can't assign to ()"); - e->v.Tuple.ctx = ctx; - s = e->v.Tuple.elts; - break; + e->v.Tuple.ctx = ctx; + s = e->v.Tuple.elts; + break; case Lambda_kind: expr_name = "lambda"; break; case Call_kind: expr_name = "function call"; - break; + break; case BoolOp_kind: case BinOp_kind: case UnaryOp_kind: @@ -428,12 +422,12 @@ context for all the contained elements. */ if (s) { - int i; + int i; - for (i = 0; i < asdl_seq_LEN(s); i++) { - if (!set_context((expr_ty)asdl_seq_GET(s, i), ctx, n)) - return 0; - } + for (i = 0; i < asdl_seq_LEN(s); i++) { + if (!set_context((expr_ty)asdl_seq_GET(s, i), ctx, n)) + return 0; + } } return 1; } @@ -484,13 +478,13 @@ */ REQ(n, comp_op); if (NCH(n) == 1) { - n = CHILD(n, 0); - switch (TYPE(n)) { + n = CHILD(n, 0); + switch (TYPE(n)) { case LESS: return Lt; case GREATER: return Gt; - case EQEQUAL: /* == */ + case EQEQUAL: /* == */ return Eq; case LESSEQUAL: return LtE; @@ -507,11 +501,11 @@ PyErr_Format(PyExc_SystemError, "invalid comp_op: %s", STR(n)); return (cmpop_ty)0; - } + } } else if (NCH(n) == 2) { - /* handle "not in" and "is not" */ - switch (TYPE(CHILD(n, 0))) { + /* handle "not in" and "is not" */ + switch (TYPE(CHILD(n, 0))) { case NAME: if (strcmp(STR(CHILD(n, 1)), "in") == 0) return NotIn; @@ -521,7 +515,7 @@ PyErr_Format(PyExc_SystemError, "invalid comp_op: %s %s", STR(CHILD(n, 0)), STR(CHILD(n, 1))); return (cmpop_ty)0; - } + } } PyErr_Format(PyExc_SystemError, "invalid comp_op: has %d children", NCH(n)); @@ -536,10 +530,11 @@ expr_ty expression; int i; assert(TYPE(n) == testlist - || TYPE(n) == listmaker - || TYPE(n) == testlist_gexp - || TYPE(n) == testlist_safe - ); + || TYPE(n) == listmaker + || TYPE(n) == testlist_gexp + || TYPE(n) == testlist_safe + || TYPE(n) == testlist1 + ); seq = asdl_seq_new((NCH(n) + 1) / 2, c->c_arena); if (!seq) @@ -567,20 +562,37 @@ if (!args) return NULL; + /* fpdef: NAME | '(' fplist ')' + fplist: fpdef (',' fpdef)* [','] + */ REQ(n, fplist); for (i = 0; i < len; i++) { - const node *child = CHILD(CHILD(n, 2*i), 0); + const node *fpdef_node = CHILD(n, 2*i); + const node *child; expr_ty arg; +set_name: + /* fpdef_node is either a NAME or an fplist */ + child = CHILD(fpdef_node, 0); if (TYPE(child) == NAME) { - if (!strcmp(STR(child), "None")) { - ast_error(child, "assignment to None"); - return NULL; - } + if (!strcmp(STR(child), "None")) { + ast_error(child, "assignment to None"); + return NULL; + } arg = Name(NEW_IDENTIFIER(child), Store, LINENO(child), child->n_col_offset, c->c_arena); - } + } else { - arg = compiler_complex_args(c, CHILD(CHILD(n, 2*i), 1)); + assert(TYPE(fpdef_node) == fpdef); + /* fpdef_node[0] is not a name, so it must be a '(', get CHILD[1] */ + child = CHILD(fpdef_node, 1); + assert(TYPE(child) == fplist); + /* NCH == 1 means we have (x), we need to elide the extra parens */ + if (NCH(child) == 1) { + fpdef_node = CHILD(child, 0); + assert(TYPE(fpdef_node) == fpdef); + goto set_name; + } + arg = compiler_complex_args(c, child); } asdl_seq_SET(args, i, arg); } @@ -731,6 +743,7 @@ ch = CHILD(n, i); switch (TYPE(ch)) { case fpdef: + handle_fpdef: /* XXX Need to worry about checking if TYPE(CHILD(n, i+1)) is anything other than EQUAL or a comma? */ /* XXX Should NCH(n) check be made a separate check? */ @@ -758,7 +771,11 @@ compiler_complex_args(c, ch)); } else { /* def foo((x)): setup for checking NAME below. */ + /* Loop because there can be many parens and tuple + unpacking mixed in. */ ch = CHILD(ch, 0); + assert(TYPE(ch) == fpdef); + goto handle_fpdef; } } if (TYPE(CHILD(ch, 0)) == NAME) { @@ -773,7 +790,7 @@ if (!name) goto error; asdl_seq_SET(posargs, k++, name); - + } i += 2; /* the name and the comma */ break; @@ -847,15 +864,15 @@ return NULL; e = Name(id, Load, lineno, col_offset, c->c_arena); if (!e) - return NULL; + return NULL; for (i = 2; i < NCH(n); i+=2) { id = NEW_IDENTIFIER(CHILD(n, i)); - if (!id) - return NULL; - e = Attribute(e, id, Load, lineno, col_offset, c->c_arena); - if (!e) - return NULL; + if (!id) + return NULL; + e = Attribute(e, id, Load, lineno, col_offset, c->c_arena); + if (!e) + return NULL; } return e; @@ -874,24 +891,24 @@ name_expr = ast_for_dotted_name(c, CHILD(n, 1)); if (!name_expr) - return NULL; - + return NULL; + if (NCH(n) == 3) { /* No arguments */ - d = name_expr; - name_expr = NULL; + d = name_expr; + name_expr = NULL; } else if (NCH(n) == 5) { /* Call with no arguments */ - d = Call(name_expr, NULL, NULL, NULL, NULL, LINENO(n), + d = Call(name_expr, NULL, NULL, NULL, NULL, LINENO(n), n->n_col_offset, c->c_arena); - if (!d) - return NULL; - name_expr = NULL; + if (!d) + return NULL; + name_expr = NULL; } else { - d = ast_for_call(c, CHILD(n, 3), name_expr); - if (!d) - return NULL; - name_expr = NULL; + d = ast_for_call(c, CHILD(n, 3), name_expr); + if (!d) + return NULL; + name_expr = NULL; } return d; @@ -908,12 +925,12 @@ decorator_seq = asdl_seq_new(NCH(n), c->c_arena); if (!decorator_seq) return NULL; - + for (i = 0; i < NCH(n); i++) { d = ast_for_decorator(c, CHILD(n, i)); - if (!d) - return NULL; - asdl_seq_SET(decorator_seq, i, d); + if (!d) + return NULL; + asdl_seq_SET(decorator_seq, i, d); } return decorator_seq; } @@ -931,28 +948,28 @@ REQ(n, funcdef); if (NCH(n) == 6) { /* decorators are present */ - decorator_seq = ast_for_decorators(c, CHILD(n, 0)); - if (!decorator_seq) - return NULL; - name_i = 2; + decorator_seq = ast_for_decorators(c, CHILD(n, 0)); + if (!decorator_seq) + return NULL; + name_i = 2; } else { - name_i = 1; + name_i = 1; } name = NEW_IDENTIFIER(CHILD(n, name_i)); if (!name) - return NULL; + return NULL; else if (!strcmp(STR(CHILD(n, name_i)), "None")) { - ast_error(CHILD(n, name_i), "assignment to None"); - return NULL; + ast_error(CHILD(n, name_i), "assignment to None"); + return NULL; } args = ast_for_arguments(c, CHILD(n, name_i + 1)); if (!args) - return NULL; + return NULL; body = ast_for_suite(c, CHILD(n, name_i + 3)); if (!body) - return NULL; + return NULL; return FunctionDef(name, args, body, decorator_seq, LINENO(n), n->n_col_offset, c->c_arena); @@ -994,17 +1011,22 @@ assert(NCH(n) == 5); body = ast_for_expr(c, CHILD(n, 0)); if (!body) - return NULL; + return NULL; expression = ast_for_expr(c, CHILD(n, 2)); if (!expression) - return NULL; + return NULL; orelse = ast_for_expr(c, CHILD(n, 4)); if (!orelse) - return NULL; + return NULL; return IfExp(expression, body, orelse, LINENO(n), n->n_col_offset, c->c_arena); } +/* XXX(nnorwitz): the listcomp and genexpr code should be refactored + so there is only a single version. Possibly for loops can also re-use + the code. +*/ + /* Count the number of 'for' loop in a list comprehension. Helper for ast_for_listcomp(). @@ -1020,14 +1042,14 @@ n_fors++; REQ(ch, list_for); if (NCH(ch) == 5) - ch = CHILD(ch, 4); + ch = CHILD(ch, 4); else - return n_fors; + return n_fors; count_list_iter: REQ(ch, list_iter); ch = CHILD(ch, 0); if (TYPE(ch) == list_for) - goto count_list_for; + goto count_list_for; else if (TYPE(ch) == list_if) { if (NCH(ch) == 3) { ch = CHILD(ch, 2); @@ -1055,12 +1077,12 @@ count_list_iter: REQ(n, list_iter); if (TYPE(CHILD(n, 0)) == list_for) - return n_ifs; + return n_ifs; n = CHILD(n, 0); REQ(n, list_if); n_ifs++; if (NCH(n) == 2) - return n_ifs; + return n_ifs; n = CHILD(n, 2); goto count_list_iter; } @@ -1092,61 +1114,65 @@ listcomps = asdl_seq_new(n_fors, c->c_arena); if (!listcomps) - return NULL; + return NULL; ch = CHILD(n, 1); for (i = 0; i < n_fors; i++) { - comprehension_ty lc; - asdl_seq *t; + comprehension_ty lc; + asdl_seq *t; expr_ty expression; + node *for_ch; - REQ(ch, list_for); + REQ(ch, list_for); - t = ast_for_exprlist(c, CHILD(ch, 1), Store); + for_ch = CHILD(ch, 1); + t = ast_for_exprlist(c, for_ch, Store); if (!t) return NULL; expression = ast_for_testlist(c, CHILD(ch, 3)); if (!expression) return NULL; - if (asdl_seq_LEN(t) == 1) - lc = comprehension((expr_ty)asdl_seq_GET(t, 0), expression, NULL, + /* Check the # of children rather than the length of t, since + [x for x, in ... ] has 1 element in t, but still requires a Tuple. */ + if (NCH(for_ch) == 1) + lc = comprehension((expr_ty)asdl_seq_GET(t, 0), expression, NULL, c->c_arena); - else - lc = comprehension(Tuple(t, Store, LINENO(ch), ch->n_col_offset, + else + lc = comprehension(Tuple(t, Store, LINENO(ch), ch->n_col_offset, c->c_arena), expression, NULL, c->c_arena); if (!lc) return NULL; - if (NCH(ch) == 5) { - int j, n_ifs; - asdl_seq *ifs; + if (NCH(ch) == 5) { + int j, n_ifs; + asdl_seq *ifs; - ch = CHILD(ch, 4); - n_ifs = count_list_ifs(ch); + ch = CHILD(ch, 4); + n_ifs = count_list_ifs(ch); if (n_ifs == -1) return NULL; - ifs = asdl_seq_new(n_ifs, c->c_arena); - if (!ifs) - return NULL; + ifs = asdl_seq_new(n_ifs, c->c_arena); + if (!ifs) + return NULL; - for (j = 0; j < n_ifs; j++) { + for (j = 0; j < n_ifs; j++) { REQ(ch, list_iter); - ch = CHILD(ch, 0); - REQ(ch, list_if); + ch = CHILD(ch, 0); + REQ(ch, list_if); - asdl_seq_SET(ifs, j, ast_for_expr(c, CHILD(ch, 1))); - if (NCH(ch) == 3) - ch = CHILD(ch, 2); - } - /* on exit, must guarantee that ch is a list_for */ - if (TYPE(ch) == list_iter) - ch = CHILD(ch, 0); + asdl_seq_SET(ifs, j, ast_for_expr(c, CHILD(ch, 1))); + if (NCH(ch) == 3) + ch = CHILD(ch, 2); + } + /* on exit, must guarantee that ch is a list_for */ + if (TYPE(ch) == list_iter) + ch = CHILD(ch, 0); lc->ifs = ifs; - } - asdl_seq_SET(listcomps, i, lc); + } + asdl_seq_SET(listcomps, i, lc); } return ListComp(elt, listcomps, LINENO(n), n->n_col_offset, c->c_arena); @@ -1161,34 +1187,34 @@ static int count_gen_fors(const node *n) { - int n_fors = 0; - node *ch = CHILD(n, 1); + int n_fors = 0; + node *ch = CHILD(n, 1); count_gen_for: - n_fors++; - REQ(ch, gen_for); - if (NCH(ch) == 5) - ch = CHILD(ch, 4); - else - return n_fors; + n_fors++; + REQ(ch, gen_for); + if (NCH(ch) == 5) + ch = CHILD(ch, 4); + else + return n_fors; count_gen_iter: - REQ(ch, gen_iter); - ch = CHILD(ch, 0); - if (TYPE(ch) == gen_for) - goto count_gen_for; - else if (TYPE(ch) == gen_if) { - if (NCH(ch) == 3) { - ch = CHILD(ch, 2); - goto count_gen_iter; - } - else - return n_fors; - } - - /* Should never be reached */ - PyErr_SetString(PyExc_SystemError, - "logic error in count_gen_fors"); - return -1; + REQ(ch, gen_iter); + ch = CHILD(ch, 0); + if (TYPE(ch) == gen_for) + goto count_gen_for; + else if (TYPE(ch) == gen_if) { + if (NCH(ch) == 3) { + ch = CHILD(ch, 2); + goto count_gen_iter; + } + else + return n_fors; + } + + /* Should never be reached */ + PyErr_SetString(PyExc_SystemError, + "logic error in count_gen_fors"); + return -1; } /* Count the number of 'if' statements in a generator expression. @@ -1199,19 +1225,19 @@ static int count_gen_ifs(const node *n) { - int n_ifs = 0; + int n_ifs = 0; - while (1) { - REQ(n, gen_iter); - if (TYPE(CHILD(n, 0)) == gen_for) - return n_ifs; - n = CHILD(n, 0); - REQ(n, gen_if); - n_ifs++; - if (NCH(n) == 2) - return n_ifs; - n = CHILD(n, 2); - } + while (1) { + REQ(n, gen_iter); + if (TYPE(CHILD(n, 0)) == gen_for) + return n_ifs; + n = CHILD(n, 0); + REQ(n, gen_if); + n_ifs++; + if (NCH(n) == 2) + return n_ifs; + n = CHILD(n, 2); + } } /* TODO(jhylton): Combine with list comprehension code? */ @@ -1219,7 +1245,7 @@ ast_for_genexp(struct compiling *c, const node *n) { /* testlist_gexp: test ( gen_for | (',' test)* [','] ) - argument: [test '='] test [gen_for] # Really [keyword '='] test */ + argument: [test '='] test [gen_for] # Really [keyword '='] test */ expr_ty elt; asdl_seq *genexps; int i, n_fors; @@ -1245,17 +1271,21 @@ comprehension_ty ge; asdl_seq *t; expr_ty expression; + node *for_ch; REQ(ch, gen_for); - t = ast_for_exprlist(c, CHILD(ch, 1), Store); + for_ch = CHILD(ch, 1); + t = ast_for_exprlist(c, for_ch, Store); if (!t) return NULL; expression = ast_for_expr(c, CHILD(ch, 3)); if (!expression) return NULL; - if (asdl_seq_LEN(t) == 1) + /* Check the # of children rather than the length of t, since + (x for x, in ...) has 1 element in t, but still requires a Tuple. */ + if (NCH(for_ch) == 1) ge = comprehension((expr_ty)asdl_seq_GET(t, 0), expression, NULL, c->c_arena); else @@ -1312,57 +1342,57 @@ switch (TYPE(ch)) { case NAME: - /* All names start in Load context, but may later be - changed. */ - return Name(NEW_IDENTIFIER(ch), Load, LINENO(n), n->n_col_offset, c->c_arena); + /* All names start in Load context, but may later be + changed. */ + return Name(NEW_IDENTIFIER(ch), Load, LINENO(n), n->n_col_offset, c->c_arena); case STRING: { - PyObject *str = parsestrplus(c, n); - if (!str) - return NULL; + PyObject *str = parsestrplus(c, n); + if (!str) + return NULL; - PyArena_AddPyObject(c->c_arena, str); - return Str(str, LINENO(n), n->n_col_offset, c->c_arena); + PyArena_AddPyObject(c->c_arena, str); + return Str(str, LINENO(n), n->n_col_offset, c->c_arena); } case NUMBER: { - PyObject *pynum = parsenumber(STR(ch)); - if (!pynum) - return NULL; + PyObject *pynum = parsenumber(STR(ch)); + if (!pynum) + return NULL; - PyArena_AddPyObject(c->c_arena, pynum); - return Num(pynum, LINENO(n), n->n_col_offset, c->c_arena); + PyArena_AddPyObject(c->c_arena, pynum); + return Num(pynum, LINENO(n), n->n_col_offset, c->c_arena); } case DOT: /* Ellipsis */ return Ellipsis(LINENO(n), n->n_col_offset, c->c_arena); case LPAR: /* some parenthesized expressions */ - ch = CHILD(n, 1); - - if (TYPE(ch) == RPAR) - return Tuple(NULL, Load, LINENO(n), n->n_col_offset, c->c_arena); - - if (TYPE(ch) == yield_expr) - return ast_for_expr(c, ch); - - if ((NCH(ch) > 1) && (TYPE(CHILD(ch, 1)) == gen_for)) - return ast_for_genexp(c, ch); - - return ast_for_testlist_gexp(c, ch); + ch = CHILD(n, 1); + + if (TYPE(ch) == RPAR) + return Tuple(NULL, Load, LINENO(n), n->n_col_offset, c->c_arena); + + if (TYPE(ch) == yield_expr) + return ast_for_expr(c, ch); + + if ((NCH(ch) > 1) && (TYPE(CHILD(ch, 1)) == gen_for)) + return ast_for_genexp(c, ch); + + return ast_for_testlist_gexp(c, ch); case LSQB: /* list (or list comprehension) */ - ch = CHILD(n, 1); - - if (TYPE(ch) == RSQB) - return List(NULL, Load, LINENO(n), n->n_col_offset, c->c_arena); - - REQ(ch, listmaker); - if (NCH(ch) == 1 || TYPE(CHILD(ch, 1)) == COMMA) { - asdl_seq *elts = seq_for_testlist(c, ch); - if (!elts) - return NULL; + ch = CHILD(n, 1); + + if (TYPE(ch) == RSQB) + return List(NULL, Load, LINENO(n), n->n_col_offset, c->c_arena); + + REQ(ch, listmaker); + if (NCH(ch) == 1 || TYPE(CHILD(ch, 1)) == COMMA) { + asdl_seq *elts = seq_for_testlist(c, ch); + if (!elts) + return NULL; - return List(elts, Load, LINENO(n), n->n_col_offset, c->c_arena); - } - else - return ast_for_listcomp(c, ch); + return List(elts, Load, LINENO(n), n->n_col_offset, c->c_arena); + } + else + return ast_for_listcomp(c, ch); case LBRACE: { /* dictsetmaker: test ':' test (',' test ':' test)* [','] | * test (',' test)* [','] */ @@ -1415,8 +1445,8 @@ } } default: - PyErr_Format(PyExc_SystemError, "unhandled atom %d", TYPE(ch)); - return NULL; + PyErr_Format(PyExc_SystemError, "unhandled atom %d", TYPE(ch)); + return NULL; } } @@ -1440,31 +1470,31 @@ if (!step) return NULL; - return Index(step, c->c_arena); + return Index(step, c->c_arena); } if (TYPE(ch) == test) { - lower = ast_for_expr(c, ch); + lower = ast_for_expr(c, ch); if (!lower) return NULL; } /* If there's an upper bound it's in the second or third position. */ if (TYPE(ch) == COLON) { - if (NCH(n) > 1) { - node *n2 = CHILD(n, 1); + if (NCH(n) > 1) { + node *n2 = CHILD(n, 1); - if (TYPE(n2) == test) { - upper = ast_for_expr(c, n2); + if (TYPE(n2) == test) { + upper = ast_for_expr(c, n2); if (!upper) return NULL; } - } + } } else if (NCH(n) > 2) { - node *n2 = CHILD(n, 2); + node *n2 = CHILD(n, 2); - if (TYPE(n2) == test) { - upper = ast_for_expr(c, n2); + if (TYPE(n2) == test) { + upper = ast_for_expr(c, n2); if (!upper) return NULL; } @@ -1495,13 +1525,13 @@ static expr_ty ast_for_binop(struct compiling *c, const node *n) { - /* Must account for a sequence of expressions. - How should A op B op C by represented? - BinOp(BinOp(A, op, B), op, C). - */ + /* Must account for a sequence of expressions. + How should A op B op C by represented? + BinOp(BinOp(A, op, B), op, C). + */ - int i, nops; - expr_ty expr1, expr2, result; + int i, nops; + expr_ty expr1, expr2, result; operator_ty newoperator; expr1 = ast_for_expr(c, CHILD(n, 0)); @@ -1516,17 +1546,17 @@ if (!newoperator) return NULL; - result = BinOp(expr1, newoperator, expr2, LINENO(n), n->n_col_offset, + result = BinOp(expr1, newoperator, expr2, LINENO(n), n->n_col_offset, c->c_arena); - if (!result) + if (!result) return NULL; - nops = (NCH(n) - 1) / 2; - for (i = 1; i < nops; i++) { - expr_ty tmp_result, tmp; - const node* next_oper = CHILD(n, i * 2 + 1); + nops = (NCH(n) - 1) / 2; + for (i = 1; i < nops; i++) { + expr_ty tmp_result, tmp; + const node* next_oper = CHILD(n, i * 2 + 1); - newoperator = get_operator(next_oper); + newoperator = get_operator(next_oper); if (!newoperator) return NULL; @@ -1535,13 +1565,13 @@ return NULL; tmp_result = BinOp(result, newoperator, tmp, - LINENO(next_oper), next_oper->n_col_offset, + LINENO(next_oper), next_oper->n_col_offset, c->c_arena); - if (!tmp) - return NULL; - result = tmp_result; - } - return result; + if (!tmp) + return NULL; + result = tmp_result; + } + return result; } static expr_ty @@ -1688,8 +1718,8 @@ tmp = ast_for_trailer(c, ch, e); if (!tmp) return NULL; - tmp->lineno = e->lineno; - tmp->col_offset = e->col_offset; + tmp->lineno = e->lineno; + tmp->col_offset = e->col_offset; e = tmp; } if (TYPE(CHILD(n, NCH(n) - 1)) == factor) { @@ -1747,8 +1777,8 @@ return ast_for_lambdef(c, CHILD(n, 0)); else if (NCH(n) > 1) return ast_for_ifexpr(c, n); - /* Fallthrough */ - case or_test: + /* Fallthrough */ + case or_test: case and_test: if (NCH(n) == 1) { n = CHILD(n, 0); @@ -1789,7 +1819,7 @@ else { expr_ty expression; asdl_int_seq *ops; - asdl_seq *cmps; + asdl_seq *cmps; ops = asdl_int_seq_new(NCH(n) / 2, c->c_arena); if (!ops) return NULL; @@ -1803,12 +1833,12 @@ newoperator = ast_for_comp_op(CHILD(n, i)); if (!newoperator) { return NULL; - } + } expression = ast_for_expr(c, CHILD(n, i + 1)); if (!expression) { return NULL; - } + } asdl_seq_SET(ops, i / 2, newoperator); asdl_seq_SET(cmps, i / 2, expression); @@ -1816,7 +1846,7 @@ expression = ast_for_expr(c, CHILD(n, 0)); if (!expression) { return NULL; - } + } return Compare(expression, ops, cmps, LINENO(n), n->n_col_offset, c->c_arena); @@ -1839,20 +1869,20 @@ } return ast_for_binop(c, n); case yield_expr: { - expr_ty exp = NULL; - if (NCH(n) == 2) { - exp = ast_for_testlist(c, CHILD(n, 1)); - if (!exp) - return NULL; - } - return Yield(exp, LINENO(n), n->n_col_offset, c->c_arena); - } + expr_ty exp = NULL; + if (NCH(n) == 2) { + exp = ast_for_testlist(c, CHILD(n, 1)); + if (!exp) + return NULL; + } + return Yield(exp, LINENO(n), n->n_col_offset, c->c_arena); + } case factor: if (NCH(n) == 1) { n = CHILD(n, 0); goto loop; } - return ast_for_factor(c, n); + return ast_for_factor(c, n); case power: return ast_for_power(c, n); default: @@ -1869,7 +1899,7 @@ /* arglist: (argument ',')* (argument [',']| '*' test [',' '**' test] | '**' test) - argument: [test '='] test [gen_for] # Really [keyword '='] test + argument: [test '='] test [gen_for] # Really [keyword '='] test */ int i, nargs, nkeywords, ngens; @@ -1883,20 +1913,20 @@ nkeywords = 0; ngens = 0; for (i = 0; i < NCH(n); i++) { - node *ch = CHILD(n, i); - if (TYPE(ch) == argument) { - if (NCH(ch) == 1) - nargs++; - else if (TYPE(CHILD(ch, 1)) == gen_for) - ngens++; + node *ch = CHILD(n, i); + if (TYPE(ch) == argument) { + if (NCH(ch) == 1) + nargs++; + else if (TYPE(CHILD(ch, 1)) == gen_for) + ngens++; else - nkeywords++; - } + nkeywords++; + } } if (ngens > 1 || (ngens && (nargs || nkeywords))) { ast_error(n, "Generator expression must be parenthesized " - "if not sole argument"); - return NULL; + "if not sole argument"); + return NULL; } if (nargs + nkeywords + ngens > 255) { @@ -1913,32 +1943,32 @@ nargs = 0; nkeywords = 0; for (i = 0; i < NCH(n); i++) { - node *ch = CHILD(n, i); - if (TYPE(ch) == argument) { - expr_ty e; - if (NCH(ch) == 1) { - if (nkeywords) { - ast_error(CHILD(ch, 0), - "non-keyword arg after keyword arg"); - return NULL; - } - e = ast_for_expr(c, CHILD(ch, 0)); + node *ch = CHILD(n, i); + if (TYPE(ch) == argument) { + expr_ty e; + if (NCH(ch) == 1) { + if (nkeywords) { + ast_error(CHILD(ch, 0), + "non-keyword arg after keyword arg"); + return NULL; + } + e = ast_for_expr(c, CHILD(ch, 0)); if (!e) return NULL; - asdl_seq_SET(args, nargs++, e); - } - else if (TYPE(CHILD(ch, 1)) == gen_for) { - e = ast_for_genexp(c, ch); + asdl_seq_SET(args, nargs++, e); + } + else if (TYPE(CHILD(ch, 1)) == gen_for) { + e = ast_for_genexp(c, ch); if (!e) return NULL; - asdl_seq_SET(args, nargs++, e); + asdl_seq_SET(args, nargs++, e); } - else { - keyword_ty kw; - identifier key; + else { + keyword_ty kw; + identifier key; - /* CHILD(ch, 0) is test, but must be an identifier? */ - e = ast_for_expr(c, CHILD(ch, 0)); + /* CHILD(ch, 0) is test, but must be an identifier? */ + e = ast_for_expr(c, CHILD(ch, 0)); if (!e) return NULL; /* f(lambda x: x[0] = 3) ends up getting parsed with @@ -1953,24 +1983,24 @@ ast_error(CHILD(ch, 0), "keyword can't be an expression"); return NULL; } - key = e->v.Name.id; - e = ast_for_expr(c, CHILD(ch, 2)); + key = e->v.Name.id; + e = ast_for_expr(c, CHILD(ch, 2)); if (!e) return NULL; - kw = keyword(key, e, c->c_arena); + kw = keyword(key, e, c->c_arena); if (!kw) return NULL; - asdl_seq_SET(keywords, nkeywords++, kw); - } - } - else if (TYPE(ch) == STAR) { - vararg = ast_for_expr(c, CHILD(n, i+1)); - i++; - } - else if (TYPE(ch) == DOUBLESTAR) { - kwarg = ast_for_expr(c, CHILD(n, i+1)); - i++; - } + asdl_seq_SET(keywords, nkeywords++, kw); + } + } + else if (TYPE(ch) == STAR) { + vararg = ast_for_expr(c, CHILD(n, i+1)); + i++; + } + else if (TYPE(ch) == DOUBLESTAR) { + kwarg = ast_for_expr(c, CHILD(n, i+1)); + i++; + } } return Call(func, args, keywords, vararg, kwarg, func->lineno, func->col_offset, c->c_arena); @@ -1994,12 +2024,12 @@ TYPE(n) == testlist1); } if (NCH(n) == 1) - return ast_for_expr(c, CHILD(n, 0)); + return ast_for_expr(c, CHILD(n, 0)); else { asdl_seq *tmp = seq_for_testlist(c, n); if (!tmp) return NULL; - return Tuple(tmp, Load, LINENO(n), n->n_col_offset, c->c_arena); + return Tuple(tmp, Load, LINENO(n), n->n_col_offset, c->c_arena); } } @@ -2010,7 +2040,7 @@ /* argument: test [ gen_for ] */ assert(TYPE(n) == testlist_gexp || TYPE(n) == argument); if (NCH(n) > 1 && TYPE(CHILD(n, 1)) == gen_for) - return ast_for_genexp(c, n); + return ast_for_genexp(c, n); return ast_for_testlist(c, n); } @@ -2044,23 +2074,23 @@ | ('=' (yield_expr|testlist))*) testlist: test (',' test)* [','] augassign: '+=' | '-=' | '*=' | '/=' | '%=' | '&=' | '|=' | '^=' - | '<<=' | '>>=' | '**=' | '//=' + | '<<=' | '>>=' | '**=' | '//=' test: ... here starts the operator precendence dance */ if (NCH(n) == 1) { - expr_ty e = ast_for_testlist(c, CHILD(n, 0)); + expr_ty e = ast_for_testlist(c, CHILD(n, 0)); if (!e) return NULL; - return Expr(e, LINENO(n), n->n_col_offset, c->c_arena); + return Expr(e, LINENO(n), n->n_col_offset, c->c_arena); } else if (TYPE(CHILD(n, 1)) == augassign) { expr_ty expr1, expr2; operator_ty newoperator; - node *ch = CHILD(n, 0); + node *ch = CHILD(n, 0); - expr1 = ast_for_testlist(c, ch); + expr1 = ast_for_testlist(c, ch); if (!expr1) return NULL; /* TODO(nas): Remove duplicated error checks (set_context does it) */ @@ -2089,13 +2119,13 @@ "assignment"); return NULL; } - set_context(expr1, Store, ch); + set_context(expr1, Store, ch); - ch = CHILD(n, 2); - if (TYPE(ch) == testlist) - expr2 = ast_for_testlist(c, ch); - else - expr2 = ast_for_expr(c, ch); + ch = CHILD(n, 2); + if (TYPE(ch) == testlist) + expr2 = ast_for_testlist(c, ch); + else + expr2 = ast_for_expr(c, ch); if (!expr2) return NULL; @@ -2103,45 +2133,45 @@ if (!newoperator) return NULL; - return AugAssign(expr1, newoperator, expr2, LINENO(n), n->n_col_offset, c->c_arena); + return AugAssign(expr1, newoperator, expr2, LINENO(n), n->n_col_offset, c->c_arena); } else { - int i; - asdl_seq *targets; - node *value; + int i; + asdl_seq *targets; + node *value; expr_ty expression; - /* a normal assignment */ - REQ(CHILD(n, 1), EQUAL); - targets = asdl_seq_new(NCH(n) / 2, c->c_arena); - if (!targets) - return NULL; - for (i = 0; i < NCH(n) - 2; i += 2) { - expr_ty e; - node *ch = CHILD(n, i); - if (TYPE(ch) == yield_expr) { - ast_error(ch, "assignment to yield expression not possible"); - return NULL; - } - e = ast_for_testlist(c, ch); + /* a normal assignment */ + REQ(CHILD(n, 1), EQUAL); + targets = asdl_seq_new(NCH(n) / 2, c->c_arena); + if (!targets) + return NULL; + for (i = 0; i < NCH(n) - 2; i += 2) { + expr_ty e; + node *ch = CHILD(n, i); + if (TYPE(ch) == yield_expr) { + ast_error(ch, "assignment to yield expression not possible"); + return NULL; + } + e = ast_for_testlist(c, ch); + + /* set context to assign */ + if (!e) + return NULL; + + if (!set_context(e, Store, CHILD(n, i))) + return NULL; - /* set context to assign */ - if (!e) - return NULL; - - if (!set_context(e, Store, CHILD(n, i))) - return NULL; - - asdl_seq_SET(targets, i / 2, e); - } - value = CHILD(n, NCH(n) - 1); - if (TYPE(value) == testlist) - expression = ast_for_testlist(c, value); - else - expression = ast_for_expr(c, value); - if (!expression) - return NULL; - return Assign(targets, expression, LINENO(n), n->n_col_offset, c->c_arena); + asdl_seq_SET(targets, i / 2, e); + } + value = CHILD(n, NCH(n) - 1); + if (TYPE(value) == testlist) + expression = ast_for_testlist(c, value); + else + expression = ast_for_expr(c, value); + if (!expression) + return NULL; + return Assign(targets, expression, LINENO(n), n->n_col_offset, c->c_arena); } } @@ -2158,19 +2188,19 @@ REQ(n, print_stmt); if (NCH(n) >= 2 && TYPE(CHILD(n, 1)) == RIGHTSHIFT) { - dest = ast_for_expr(c, CHILD(n, 2)); + dest = ast_for_expr(c, CHILD(n, 2)); if (!dest) return NULL; - start = 4; + start = 4; } seq = asdl_seq_new((NCH(n) + 1 - start) / 2, c->c_arena); if (!seq) - return NULL; + return NULL; for (i = start, j = 0; i < NCH(n); i += 2, ++j) { expression = ast_for_expr(c, CHILD(n, i)); if (!expression) return NULL; - asdl_seq_SET(seq, j, expression); + asdl_seq_SET(seq, j, expression); } nl = (TYPE(CHILD(n, NCH(n) - 1)) == COMMA) ? false : true; return Print(dest, seq, nl, LINENO(n), n->n_col_offset, c->c_arena); @@ -2187,14 +2217,14 @@ seq = asdl_seq_new((NCH(n) + 1) / 2, c->c_arena); if (!seq) - return NULL; + return NULL; for (i = 0; i < NCH(n); i += 2) { - e = ast_for_expr(c, CHILD(n, i)); - if (!e) - return NULL; - asdl_seq_SET(seq, i / 2, e); - if (context && !set_context(e, context, CHILD(n, i))) - return NULL; + e = ast_for_expr(c, CHILD(n, i)); + if (!e) + return NULL; + asdl_seq_SET(seq, i / 2, e); + if (context && !set_context(e, context, CHILD(n, i))) + return NULL; } return seq; } @@ -2236,9 +2266,9 @@ case continue_stmt: return Continue(LINENO(n), n->n_col_offset, c->c_arena); case yield_stmt: { /* will reduce to yield_expr */ - expr_ty exp = ast_for_expr(c, CHILD(ch, 0)); - if (!exp) - return NULL; + expr_ty exp = ast_for_expr(c, CHILD(ch, 0)); + if (!exp) + return NULL; return Expr(exp, LINENO(n), n->n_col_offset, c->c_arena); } case return_stmt: @@ -2311,10 +2341,6 @@ case import_as_name: str = NULL; if (NCH(n) == 3) { - if (strcmp(STR(CHILD(n, 1)), "as") != 0) { - ast_error(n, "must use 'as' in import"); - return NULL; - } str = NEW_IDENTIFIER(CHILD(n, 2)); } return alias(NEW_IDENTIFIER(CHILD(n, 0)), str, c->c_arena); @@ -2327,10 +2353,6 @@ alias_ty a = alias_for_import_name(c, CHILD(n, 0)); if (!a) return NULL; - if (strcmp(STR(CHILD(n, 1)), "as") != 0) { - ast_error(n, "must use 'as' in import"); - return NULL; - } assert(!a->asname); a->asname = NEW_IDENTIFIER(CHILD(n, 2)); return a; @@ -2365,13 +2387,13 @@ --s; *s = '\0'; PyString_InternInPlace(&str); - PyArena_AddPyObject(c->c_arena, str); + PyArena_AddPyObject(c->c_arena, str); return alias(str, NULL, c->c_arena); } break; case STAR: - str = PyString_InternFromString("*"); - PyArena_AddPyObject(c->c_arena, str); + str = PyString_InternFromString("*"); + PyArena_AddPyObject(c->c_arena, str); return alias(str, NULL, c->c_arena); default: PyErr_Format(PyExc_SystemError, @@ -2403,69 +2425,69 @@ n = CHILD(n, 0); if (TYPE(n) == import_name) { n = CHILD(n, 1); - REQ(n, dotted_as_names); - aliases = asdl_seq_new((NCH(n) + 1) / 2, c->c_arena); - if (!aliases) - return NULL; - for (i = 0; i < NCH(n); i += 2) { + REQ(n, dotted_as_names); + aliases = asdl_seq_new((NCH(n) + 1) / 2, c->c_arena); + if (!aliases) + return NULL; + for (i = 0; i < NCH(n); i += 2) { alias_ty import_alias = alias_for_import_name(c, CHILD(n, i)); if (!import_alias) return NULL; - asdl_seq_SET(aliases, i / 2, import_alias); + asdl_seq_SET(aliases, i / 2, import_alias); } - return Import(aliases, lineno, col_offset, c->c_arena); + return Import(aliases, lineno, col_offset, c->c_arena); } else if (TYPE(n) == import_from) { int n_children; - int idx, ndots = 0; - alias_ty mod = NULL; - identifier modname; - + int idx, ndots = 0; + alias_ty mod = NULL; + identifier modname; + /* Count the number of dots (for relative imports) and check for the optional module name */ - for (idx = 1; idx < NCH(n); idx++) { - if (TYPE(CHILD(n, idx)) == dotted_name) { - mod = alias_for_import_name(c, CHILD(n, idx)); - idx++; - break; - } else if (TYPE(CHILD(n, idx)) != DOT) { - break; - } - ndots++; - } - idx++; /* skip over the 'import' keyword */ + for (idx = 1; idx < NCH(n); idx++) { + if (TYPE(CHILD(n, idx)) == dotted_name) { + mod = alias_for_import_name(c, CHILD(n, idx)); + idx++; + break; + } else if (TYPE(CHILD(n, idx)) != DOT) { + break; + } + ndots++; + } + idx++; /* skip over the 'import' keyword */ switch (TYPE(CHILD(n, idx))) { case STAR: /* from ... import * */ - n = CHILD(n, idx); - n_children = 1; - if (ndots) { - ast_error(n, "'import *' not allowed with 'from .'"); - return NULL; - } - break; - case LPAR: - /* from ... import (x, y, z) */ - n = CHILD(n, idx + 1); - n_children = NCH(n); - break; - case import_as_names: - /* from ... import x, y, z */ - n = CHILD(n, idx); - n_children = NCH(n); + n = CHILD(n, idx); + n_children = 1; + if (ndots) { + ast_error(n, "'import *' not allowed with 'from .'"); + return NULL; + } + break; + case LPAR: + /* from ... import (x, y, z) */ + n = CHILD(n, idx + 1); + n_children = NCH(n); + break; + case import_as_names: + /* from ... import x, y, z */ + n = CHILD(n, idx); + n_children = NCH(n); if (n_children % 2 == 0) { ast_error(n, "trailing comma not allowed without" " surrounding parentheses"); return NULL; } - break; - default: - ast_error(n, "Unexpected node-type in from-import"); - return NULL; - } + break; + default: + ast_error(n, "Unexpected node-type in from-import"); + return NULL; + } - aliases = asdl_seq_new((n_children + 1) / 2, c->c_arena); - if (!aliases) + aliases = asdl_seq_new((n_children + 1) / 2, c->c_arena); + if (!aliases) return NULL; /* handle "from ... import *" special b/c there's no children */ @@ -2473,14 +2495,14 @@ alias_ty import_alias = alias_for_import_name(c, n); if (!import_alias) return NULL; - asdl_seq_SET(aliases, 0, import_alias); + asdl_seq_SET(aliases, 0, import_alias); } else { - for (i = 0; i < NCH(n); i += 2) { + for (i = 0; i < NCH(n); i += 2) { alias_ty import_alias = alias_for_import_name(c, CHILD(n, i)); if (!import_alias) return NULL; - asdl_seq_SET(aliases, i / 2, import_alias); + asdl_seq_SET(aliases, i / 2, import_alias); } } if (mod != NULL) @@ -2507,12 +2529,12 @@ REQ(n, global_stmt); s = asdl_seq_new(NCH(n) / 2, c->c_arena); if (!s) - return NULL; + return NULL; for (i = 1; i < NCH(n); i += 2) { - name = NEW_IDENTIFIER(CHILD(n, i)); - if (!name) - return NULL; - asdl_seq_SET(s, i / 2, name); + name = NEW_IDENTIFIER(CHILD(n, i)); + if (!name) + return NULL; + asdl_seq_SET(s, i / 2, name); } return Global(s, LINENO(n), n->n_col_offset, c->c_arena); } @@ -2526,7 +2548,7 @@ expr_ty expression = ast_for_expr(c, CHILD(n, 1)); if (!expression) return NULL; - return Assert(expression, NULL, LINENO(n), n->n_col_offset, c->c_arena); + return Assert(expression, NULL, LINENO(n), n->n_col_offset, c->c_arena); } else if (NCH(n) == 4) { expr_ty expr1, expr2; @@ -2538,7 +2560,7 @@ if (!expr2) return NULL; - return Assert(expr1, expr2, LINENO(n), n->n_col_offset, c->c_arena); + return Assert(expr1, expr2, LINENO(n), n->n_col_offset, c->c_arena); } PyErr_Format(PyExc_SystemError, "improper number of parts to 'assert' statement: %d", @@ -2560,53 +2582,53 @@ total = num_stmts(n); seq = asdl_seq_new(total, c->c_arena); if (!seq) - return NULL; + return NULL; if (TYPE(CHILD(n, 0)) == simple_stmt) { - n = CHILD(n, 0); - /* simple_stmt always ends with a NEWLINE, - and may have a trailing SEMI - */ - end = NCH(n) - 1; - if (TYPE(CHILD(n, end - 1)) == SEMI) - end--; + n = CHILD(n, 0); + /* simple_stmt always ends with a NEWLINE, + and may have a trailing SEMI + */ + end = NCH(n) - 1; + if (TYPE(CHILD(n, end - 1)) == SEMI) + end--; /* loop by 2 to skip semi-colons */ - for (i = 0; i < end; i += 2) { - ch = CHILD(n, i); - s = ast_for_stmt(c, ch); - if (!s) - return NULL; - asdl_seq_SET(seq, pos++, s); - } + for (i = 0; i < end; i += 2) { + ch = CHILD(n, i); + s = ast_for_stmt(c, ch); + if (!s) + return NULL; + asdl_seq_SET(seq, pos++, s); + } } else { - for (i = 2; i < (NCH(n) - 1); i++) { - ch = CHILD(n, i); - REQ(ch, stmt); - num = num_stmts(ch); - if (num == 1) { - /* small_stmt or compound_stmt with only one child */ - s = ast_for_stmt(c, ch); - if (!s) - return NULL; - asdl_seq_SET(seq, pos++, s); - } - else { - int j; - ch = CHILD(ch, 0); - REQ(ch, simple_stmt); - for (j = 0; j < NCH(ch); j += 2) { - /* statement terminates with a semi-colon ';' */ - if (NCH(CHILD(ch, j)) == 0) { - assert((j + 1) == NCH(ch)); - break; - } - s = ast_for_stmt(c, CHILD(ch, j)); - if (!s) - return NULL; - asdl_seq_SET(seq, pos++, s); - } - } - } + for (i = 2; i < (NCH(n) - 1); i++) { + ch = CHILD(n, i); + REQ(ch, stmt); + num = num_stmts(ch); + if (num == 1) { + /* small_stmt or compound_stmt with only one child */ + s = ast_for_stmt(c, ch); + if (!s) + return NULL; + asdl_seq_SET(seq, pos++, s); + } + else { + int j; + ch = CHILD(ch, 0); + REQ(ch, simple_stmt); + for (j = 0; j < NCH(ch); j += 2) { + /* statement terminates with a semi-colon ';' */ + if (NCH(CHILD(ch, j)) == 0) { + assert((j + 1) == NCH(ch)); + break; + } + s = ast_for_stmt(c, CHILD(ch, j)); + if (!s) + return NULL; + asdl_seq_SET(seq, pos++, s); + } + } + } } assert(pos == seq->size); return seq; @@ -2633,7 +2655,7 @@ if (!suite_seq) return NULL; - return If(expression, suite_seq, NULL, LINENO(n), n->n_col_offset, c->c_arena); + return If(expression, suite_seq, NULL, LINENO(n), n->n_col_offset, c->c_arena); } s = STR(CHILD(n, 4)); @@ -2655,28 +2677,28 @@ if (!seq2) return NULL; - return If(expression, seq1, seq2, LINENO(n), n->n_col_offset, c->c_arena); + return If(expression, seq1, seq2, LINENO(n), n->n_col_offset, c->c_arena); } else if (s[2] == 'i') { - int i, n_elif, has_else = 0; - asdl_seq *orelse = NULL; - n_elif = NCH(n) - 4; + int i, n_elif, has_else = 0; + asdl_seq *orelse = NULL; + n_elif = NCH(n) - 4; /* must reference the child n_elif+1 since 'else' token is third, not fourth, child from the end. */ - if (TYPE(CHILD(n, (n_elif + 1))) == NAME - && STR(CHILD(n, (n_elif + 1)))[2] == 's') { - has_else = 1; - n_elif -= 3; - } - n_elif /= 4; + if (TYPE(CHILD(n, (n_elif + 1))) == NAME + && STR(CHILD(n, (n_elif + 1)))[2] == 's') { + has_else = 1; + n_elif -= 3; + } + n_elif /= 4; - if (has_else) { + if (has_else) { expr_ty expression; asdl_seq *seq1, *seq2; - orelse = asdl_seq_new(1, c->c_arena); - if (!orelse) - return NULL; + orelse = asdl_seq_new(1, c->c_arena); + if (!orelse) + return NULL; expression = ast_for_expr(c, CHILD(n, NCH(n) - 6)); if (!expression) return NULL; @@ -2687,20 +2709,20 @@ if (!seq2) return NULL; - asdl_seq_SET(orelse, 0, If(expression, seq1, seq2, - LINENO(CHILD(n, NCH(n) - 6)), CHILD(n, NCH(n) - 6)->n_col_offset, + asdl_seq_SET(orelse, 0, If(expression, seq1, seq2, + LINENO(CHILD(n, NCH(n) - 6)), CHILD(n, NCH(n) - 6)->n_col_offset, c->c_arena)); - /* the just-created orelse handled the last elif */ - n_elif--; - } + /* the just-created orelse handled the last elif */ + n_elif--; + } - for (i = 0; i < n_elif; i++) { - int off = 5 + (n_elif - i - 1) * 4; + for (i = 0; i < n_elif; i++) { + int off = 5 + (n_elif - i - 1) * 4; expr_ty expression; asdl_seq *suite_seq; - asdl_seq *newobj = asdl_seq_new(1, c->c_arena); - if (!newobj) - return NULL; + asdl_seq *newobj = asdl_seq_new(1, c->c_arena); + if (!newobj) + return NULL; expression = ast_for_expr(c, CHILD(n, off)); if (!expression) return NULL; @@ -2708,14 +2730,14 @@ if (!suite_seq) return NULL; - asdl_seq_SET(newobj, 0, - If(expression, suite_seq, orelse, - LINENO(CHILD(n, off)), CHILD(n, off)->n_col_offset, c->c_arena)); - orelse = newobj; - } - return If(ast_for_expr(c, CHILD(n, 1)), - ast_for_suite(c, CHILD(n, 3)), - orelse, LINENO(n), n->n_col_offset, c->c_arena); + asdl_seq_SET(newobj, 0, + If(expression, suite_seq, orelse, + LINENO(CHILD(n, off)), CHILD(n, off)->n_col_offset, c->c_arena)); + orelse = newobj; + } + return If(ast_for_expr(c, CHILD(n, 1)), + ast_for_suite(c, CHILD(n, 3)), + orelse, LINENO(n), n->n_col_offset, c->c_arena); } PyErr_Format(PyExc_SystemError, @@ -2739,7 +2761,7 @@ suite_seq = ast_for_suite(c, CHILD(n, 3)); if (!suite_seq) return NULL; - return While(expression, suite_seq, NULL, LINENO(n), n->n_col_offset, c->c_arena); + return While(expression, suite_seq, NULL, LINENO(n), n->n_col_offset, c->c_arena); } else if (NCH(n) == 7) { expr_ty expression; @@ -2755,7 +2777,7 @@ if (!seq2) return NULL; - return While(expression, seq1, seq2, LINENO(n), n->n_col_offset, c->c_arena); + return While(expression, seq1, seq2, LINENO(n), n->n_col_offset, c->c_arena); } PyErr_Format(PyExc_SystemError, @@ -2775,7 +2797,7 @@ REQ(n, for_stmt); if (NCH(n) == 9) { - seq = ast_for_suite(c, CHILD(n, 8)); + seq = ast_for_suite(c, CHILD(n, 8)); if (!seq) return NULL; } @@ -2787,9 +2809,9 @@ /* Check the # of children rather than the length of _target, since for x, in ... has 1 element in _target, but still requires a Tuple. */ if (NCH(node_target) == 1) - target = (expr_ty)asdl_seq_GET(_target, 0); + target = (expr_ty)asdl_seq_GET(_target, 0); else - target = Tuple(_target, Store, LINENO(n), n->n_col_offset, c->c_arena); + target = Tuple(_target, Store, LINENO(n), n->n_col_offset, c->c_arena); expression = ast_for_testlist(c, CHILD(n, 3)); if (!expression) @@ -2814,7 +2836,7 @@ if (!suite_seq) return NULL; - return excepthandler(NULL, NULL, suite_seq, LINENO(exc), + return excepthandler(NULL, NULL, suite_seq, LINENO(exc), exc->n_col_offset, c->c_arena); } else if (NCH(exc) == 2) { @@ -2828,16 +2850,16 @@ if (!suite_seq) return NULL; - return excepthandler(expression, NULL, suite_seq, LINENO(exc), + return excepthandler(expression, NULL, suite_seq, LINENO(exc), exc->n_col_offset, c->c_arena); } else if (NCH(exc) == 4) { asdl_seq *suite_seq; expr_ty expression; - expr_ty e = ast_for_expr(c, CHILD(exc, 3)); - if (!e) + expr_ty e = ast_for_expr(c, CHILD(exc, 3)); + if (!e) return NULL; - if (!set_context(e, Store, CHILD(exc, 3))) + if (!set_context(e, Store, CHILD(exc, 3))) return NULL; expression = ast_for_expr(c, CHILD(exc, 1)); if (!expression) @@ -2846,7 +2868,7 @@ if (!suite_seq) return NULL; - return excepthandler(expression, e, suite_seq, LINENO(exc), + return excepthandler(expression, e, suite_seq, LINENO(exc), exc->n_col_offset, c->c_arena); } @@ -2901,8 +2923,8 @@ } if (n_except > 0) { - int i; - stmt_ty except_st; + int i; + stmt_ty except_st; /* process except statements to create a try ... except */ asdl_seq *handlers = asdl_seq_new(n_except, c->c_arena); if (handlers == NULL) @@ -2916,17 +2938,17 @@ asdl_seq_SET(handlers, i, e); } - except_st = TryExcept(body, handlers, orelse, LINENO(n), + except_st = TryExcept(body, handlers, orelse, LINENO(n), n->n_col_offset, c->c_arena); if (!finally) - return except_st; + return except_st; /* if a 'finally' is present too, we nest the TryExcept within a TryFinally to emulate try ... except ... finally */ - body = asdl_seq_new(1, c->c_arena); - if (body == NULL) - return NULL; - asdl_seq_SET(body, 0, except_st); + body = asdl_seq_new(1, c->c_arena); + if (body == NULL) + return NULL; + asdl_seq_SET(body, 0, except_st); } /* must be a try ... finally (except clauses are in body, if any exist) */ @@ -2938,10 +2960,6 @@ ast_for_with_var(struct compiling *c, const node *n) { REQ(n, with_var); - if (strcmp(STR(CHILD(n, 0)), "as") != 0) { - ast_error(n, "expected \"with [expr] as [var]\""); - return NULL; - } return ast_for_expr(c, CHILD(n, 1)); } @@ -2961,9 +2979,9 @@ if (!optional_vars) { return NULL; } - if (!set_context(optional_vars, Store, n)) { - return NULL; - } + if (!set_context(optional_vars, Store, n)) { + return NULL; + } suite_index = 4; } @@ -2972,7 +2990,7 @@ return NULL; } return With(context_expr, optional_vars, suite_seq, LINENO(n), - n->n_col_offset, c->c_arena); + n->n_col_offset, c->c_arena); } static stmt_ty @@ -2984,23 +3002,23 @@ REQ(n, classdef); if (!strcmp(STR(CHILD(n, 1)), "None")) { - ast_error(n, "assignment to None"); - return NULL; + ast_error(n, "assignment to None"); + return NULL; } if (NCH(n) == 4) { s = ast_for_suite(c, CHILD(n, 3)); if (!s) return NULL; - return ClassDef(NEW_IDENTIFIER(CHILD(n, 1)), NULL, s, LINENO(n), + return ClassDef(NEW_IDENTIFIER(CHILD(n, 1)), NULL, s, LINENO(n), n->n_col_offset, c->c_arena); } /* check for empty base list */ if (TYPE(CHILD(n,3)) == RPAR) { - s = ast_for_suite(c, CHILD(n,5)); - if (!s) - return NULL; - return ClassDef(NEW_IDENTIFIER(CHILD(n, 1)), NULL, s, LINENO(n), + s = ast_for_suite(c, CHILD(n,5)); + if (!s) + return NULL; + return ClassDef(NEW_IDENTIFIER(CHILD(n, 1)), NULL, s, LINENO(n), n->n_col_offset, c->c_arena); } @@ -3020,20 +3038,20 @@ ast_for_stmt(struct compiling *c, const node *n) { if (TYPE(n) == stmt) { - assert(NCH(n) == 1); - n = CHILD(n, 0); + assert(NCH(n) == 1); + n = CHILD(n, 0); } if (TYPE(n) == simple_stmt) { - assert(num_stmts(n) == 1); - n = CHILD(n, 0); + assert(num_stmts(n) == 1); + n = CHILD(n, 0); } if (TYPE(n) == small_stmt) { REQ(n, small_stmt); n = CHILD(n, 0); /* small_stmt: expr_stmt | print_stmt | del_stmt | pass_stmt | flow_stmt | import_stmt | global_stmt | assert_stmt - */ - switch (TYPE(n)) { + */ + switch (TYPE(n)) { case expr_stmt: return ast_for_expr_stmt(c, n); case print_stmt: @@ -3059,11 +3077,11 @@ } else { /* compound_stmt: if_stmt | while_stmt | for_stmt | try_stmt - | funcdef | classdef - */ - node *ch = CHILD(n, 0); - REQ(n, compound_stmt); - switch (TYPE(ch)) { + | funcdef | classdef + */ + node *ch = CHILD(n, 0); + REQ(n, compound_stmt); + switch (TYPE(ch)) { case if_stmt: return ast_for_if_stmt(c, ch); case while_stmt: @@ -3083,144 +3101,144 @@ "unhandled small_stmt: TYPE=%d NCH=%d\n", TYPE(n), NCH(n)); return NULL; - } + } } } static PyObject * parsenumber(const char *s) { - const char *end; - long x; - double dx; + const char *end; + long x; + double dx; #ifndef WITHOUT_COMPLEX - Py_complex c; - int imflag; + Py_complex c; + int imflag; #endif - errno = 0; - end = s + strlen(s) - 1; + errno = 0; + end = s + strlen(s) - 1; #ifndef WITHOUT_COMPLEX - imflag = *end == 'j' || *end == 'J'; + imflag = *end == 'j' || *end == 'J'; #endif - if (*end == 'l' || *end == 'L') - return PyLong_FromString((char *)s, (char **)0, 0); - if (s[0] == '0') { - x = (long) PyOS_strtoul((char *)s, (char **)&end, 0); - if (x < 0 && errno == 0) { - return PyLong_FromString((char *)s, - (char **)0, - 0); - } - } - else - x = PyOS_strtol((char *)s, (char **)&end, 0); - if (*end == '\0') { - if (errno != 0) - return PyLong_FromString((char *)s, (char **)0, 0); - return PyInt_FromLong(x); - } - /* XXX Huge floats may silently fail */ + if (*end == 'l' || *end == 'L') + return PyLong_FromString((char *)s, (char **)0, 0); + if (s[0] == '0') { + x = (long) PyOS_strtoul((char *)s, (char **)&end, 0); + if (x < 0 && errno == 0) { + return PyLong_FromString((char *)s, + (char **)0, + 0); + } + } + else + x = PyOS_strtol((char *)s, (char **)&end, 0); + if (*end == '\0') { + if (errno != 0) + return PyLong_FromString((char *)s, (char **)0, 0); + return PyInt_FromLong(x); + } + /* XXX Huge floats may silently fail */ #ifndef WITHOUT_COMPLEX - if (imflag) { - c.real = 0.; - PyFPE_START_PROTECT("atof", return 0) - c.imag = PyOS_ascii_atof(s); - PyFPE_END_PROTECT(c) - return PyComplex_FromCComplex(c); - } - else + if (imflag) { + c.real = 0.; + PyFPE_START_PROTECT("atof", return 0) + c.imag = PyOS_ascii_atof(s); + PyFPE_END_PROTECT(c) + return PyComplex_FromCComplex(c); + } + else #endif - { - PyFPE_START_PROTECT("atof", return 0) - dx = PyOS_ascii_atof(s); - PyFPE_END_PROTECT(dx) - return PyFloat_FromDouble(dx); - } + { + PyFPE_START_PROTECT("atof", return 0) + dx = PyOS_ascii_atof(s); + PyFPE_END_PROTECT(dx) + return PyFloat_FromDouble(dx); + } } static PyObject * decode_utf8(const char **sPtr, const char *end, char* encoding) { #ifndef Py_USING_UNICODE - Py_FatalError("decode_utf8 should not be called in this build."); + Py_FatalError("decode_utf8 should not be called in this build."); return NULL; #else - PyObject *u, *v; - char *s, *t; - t = s = (char *)*sPtr; - /* while (s < end && *s != '\\') s++; */ /* inefficient for u".." */ - while (s < end && (*s & 0x80)) s++; - *sPtr = s; - u = PyUnicode_DecodeUTF8(t, s - t, NULL); - if (u == NULL) - return NULL; - v = PyUnicode_AsEncodedString(u, encoding, NULL); - Py_DECREF(u); - return v; + PyObject *u, *v; + char *s, *t; + t = s = (char *)*sPtr; + /* while (s < end && *s != '\\') s++; */ /* inefficient for u".." */ + while (s < end && (*s & 0x80)) s++; + *sPtr = s; + u = PyUnicode_DecodeUTF8(t, s - t, NULL); + if (u == NULL) + return NULL; + v = PyUnicode_AsEncodedString(u, encoding, NULL); + Py_DECREF(u); + return v; #endif } static PyObject * decode_unicode(const char *s, size_t len, int rawmode, const char *encoding) { - PyObject *v, *u; - char *buf; - char *p; - const char *end; - if (encoding == NULL) { - buf = (char *)s; - u = NULL; - } else if (strcmp(encoding, "iso-8859-1") == 0) { - buf = (char *)s; - u = NULL; - } else { - /* "\XX" may become "\u005c\uHHLL" (12 bytes) */ - u = PyString_FromStringAndSize((char *)NULL, len * 4); - if (u == NULL) - return NULL; - p = buf = PyString_AsString(u); - end = s + len; - while (s < end) { - if (*s == '\\') { - *p++ = *s++; - if (*s & 0x80) { - strcpy(p, "u005c"); - p += 5; - } - } - if (*s & 0x80) { /* XXX inefficient */ - PyObject *w; - char *r; - Py_ssize_t rn, i; - w = decode_utf8(&s, end, "utf-16-be"); - if (w == NULL) { - Py_DECREF(u); - return NULL; - } - r = PyString_AsString(w); - rn = PyString_Size(w); - assert(rn % 2 == 0); - for (i = 0; i < rn; i += 2) { - sprintf(p, "\\u%02x%02x", - r[i + 0] & 0xFF, - r[i + 1] & 0xFF); - p += 6; - } - Py_DECREF(w); - } else { - *p++ = *s++; - } - } - len = p - buf; - s = buf; - } - if (rawmode) - v = PyUnicode_DecodeRawUnicodeEscape(s, len, NULL); - else - v = PyUnicode_DecodeUnicodeEscape(s, len, NULL); - Py_XDECREF(u); - return v; + PyObject *v, *u; + char *buf; + char *p; + const char *end; + if (encoding == NULL) { + buf = (char *)s; + u = NULL; + } else if (strcmp(encoding, "iso-8859-1") == 0) { + buf = (char *)s; + u = NULL; + } else { + /* "\XX" may become "\u005c\uHHLL" (12 bytes) */ + u = PyString_FromStringAndSize((char *)NULL, len * 4); + if (u == NULL) + return NULL; + p = buf = PyString_AsString(u); + end = s + len; + while (s < end) { + if (*s == '\\') { + *p++ = *s++; + if (*s & 0x80) { + strcpy(p, "u005c"); + p += 5; + } + } + if (*s & 0x80) { /* XXX inefficient */ + PyObject *w; + char *r; + Py_ssize_t rn, i; + w = decode_utf8(&s, end, "utf-16-be"); + if (w == NULL) { + Py_DECREF(u); + return NULL; + } + r = PyString_AsString(w); + rn = PyString_Size(w); + assert(rn % 2 == 0); + for (i = 0; i < rn; i += 2) { + sprintf(p, "\\u%02x%02x", + r[i + 0] & 0xFF, + r[i + 1] & 0xFF); + p += 6; + } + Py_DECREF(w); + } else { + *p++ = *s++; + } + } + len = p - buf; + s = buf; + } + if (rawmode) + v = PyUnicode_DecodeRawUnicodeEscape(s, len, NULL); + else + v = PyUnicode_DecodeUnicodeEscape(s, len, NULL); + Py_XDECREF(u); + return v; } /* s is a Python string literal, including the bracketing quote characters, @@ -3230,75 +3248,75 @@ static PyObject * parsestr(const char *s, const char *encoding) { - size_t len; - int quote = Py_CHARMASK(*s); - int rawmode = 0; - int need_encoding; - int unicode = 0; - - if (isalpha(quote) || quote == '_') { - if (quote == 'u' || quote == 'U') { - quote = *++s; - unicode = 1; - } - if (quote == 'r' || quote == 'R') { - quote = *++s; - rawmode = 1; - } - } - if (quote != '\'' && quote != '\"') { - PyErr_BadInternalCall(); - return NULL; - } - s++; - len = strlen(s); - if (len > INT_MAX) { - PyErr_SetString(PyExc_OverflowError, - "string to parse is too long"); - return NULL; - } - if (s[--len] != quote) { - PyErr_BadInternalCall(); - return NULL; - } - if (len >= 4 && s[0] == quote && s[1] == quote) { - s += 2; - len -= 2; - if (s[--len] != quote || s[--len] != quote) { - PyErr_BadInternalCall(); - return NULL; - } - } + size_t len; + int quote = Py_CHARMASK(*s); + int rawmode = 0; + int need_encoding; + int unicode = 0; + + if (isalpha(quote) || quote == '_') { + if (quote == 'u' || quote == 'U') { + quote = *++s; + unicode = 1; + } + if (quote == 'r' || quote == 'R') { + quote = *++s; + rawmode = 1; + } + } + if (quote != '\'' && quote != '\"') { + PyErr_BadInternalCall(); + return NULL; + } + s++; + len = strlen(s); + if (len > INT_MAX) { + PyErr_SetString(PyExc_OverflowError, + "string to parse is too long"); + return NULL; + } + if (s[--len] != quote) { + PyErr_BadInternalCall(); + return NULL; + } + if (len >= 4 && s[0] == quote && s[1] == quote) { + s += 2; + len -= 2; + if (s[--len] != quote || s[--len] != quote) { + PyErr_BadInternalCall(); + return NULL; + } + } #ifdef Py_USING_UNICODE - if (unicode || Py_UnicodeFlag) { - return decode_unicode(s, len, rawmode, encoding); - } + if (unicode || Py_UnicodeFlag) { + return decode_unicode(s, len, rawmode, encoding); + } #endif - need_encoding = (encoding != NULL && - strcmp(encoding, "utf-8") != 0 && - strcmp(encoding, "iso-8859-1") != 0); - if (rawmode || strchr(s, '\\') == NULL) { - if (need_encoding) { + need_encoding = (encoding != NULL && + strcmp(encoding, "utf-8") != 0 && + strcmp(encoding, "iso-8859-1") != 0); + if (rawmode || strchr(s, '\\') == NULL) { + if (need_encoding) { #ifndef Py_USING_UNICODE - /* This should not happen - we never see any other - encoding. */ - Py_FatalError( + /* This should not happen - we never see any other + encoding. */ + Py_FatalError( "cannot deal with encodings in this build."); #else - PyObject *v, *u = PyUnicode_DecodeUTF8(s, len, NULL); - if (u == NULL) - return NULL; - v = PyUnicode_AsEncodedString(u, encoding, NULL); - Py_DECREF(u); - return v; + PyObject *v, *u = PyUnicode_DecodeUTF8(s, len, NULL); + if (u == NULL) + return NULL; + v = PyUnicode_AsEncodedString(u, encoding, NULL); + Py_DECREF(u); + return v; #endif - } else { - return PyString_FromStringAndSize(s, len); - } - } + } else { + return PyString_FromStringAndSize(s, len); + } + } - return PyString_DecodeEscape(s, len, NULL, unicode, - need_encoding ? encoding : NULL); + return PyString_DecodeEscape(s, len, NULL, unicode, + need_encoding ? encoding : NULL); } /* Build a Python string object out of a STRING atom. This takes care of @@ -3308,36 +3326,36 @@ static PyObject * parsestrplus(struct compiling *c, const node *n) { - PyObject *v; - int i; - REQ(CHILD(n, 0), STRING); - if ((v = parsestr(STR(CHILD(n, 0)), c->c_encoding)) != NULL) { - /* String literal concatenation */ - for (i = 1; i < NCH(n); i++) { - PyObject *s; - s = parsestr(STR(CHILD(n, i)), c->c_encoding); - if (s == NULL) - goto onError; - if (PyString_Check(v) && PyString_Check(s)) { - PyString_ConcatAndDel(&v, s); - if (v == NULL) - goto onError; - } + PyObject *v; + int i; + REQ(CHILD(n, 0), STRING); + if ((v = parsestr(STR(CHILD(n, 0)), c->c_encoding)) != NULL) { + /* String literal concatenation */ + for (i = 1; i < NCH(n); i++) { + PyObject *s; + s = parsestr(STR(CHILD(n, i)), c->c_encoding); + if (s == NULL) + goto onError; + if (PyString_Check(v) && PyString_Check(s)) { + PyString_ConcatAndDel(&v, s); + if (v == NULL) + goto onError; + } #ifdef Py_USING_UNICODE - else { - PyObject *temp = PyUnicode_Concat(v, s); - Py_DECREF(s); - Py_DECREF(v); - v = temp; - if (v == NULL) - goto onError; - } + else { + PyObject *temp = PyUnicode_Concat(v, s); + Py_DECREF(s); + Py_DECREF(v); + v = temp; + if (v == NULL) + goto onError; + } #endif - } - } - return v; + } + } + return v; onError: - Py_XDECREF(v); - return NULL; + Py_XDECREF(v); + return NULL; } Modified: python/branches/p3yk/Python/bltinmodule.c ============================================================================== --- python/branches/p3yk/Python/bltinmodule.c (original) +++ python/branches/p3yk/Python/bltinmodule.c Wed Dec 13 05:49:30 2006 @@ -539,7 +539,7 @@ Evaluate the source in the context of globals and locals.\n\ The source may be a string representing a Python expression\n\ or a code object as returned by compile().\n\ -The globals must be a dictionary and locals can be any mappping,\n\ +The globals must be a dictionary and locals can be any mapping,\n\ defaulting to the current globals and locals.\n\ If only globals is given, locals defaults to it.\n"); @@ -1972,10 +1972,11 @@ } PyDoc_STRVAR(sum_doc, -"sum(sequence, start=0) -> value\n\ +"sum(sequence[, start]) -> value\n\ \n\ Returns the sum of a sequence of numbers (NOT strings) plus the value\n\ -of parameter 'start'. When the sequence is empty, returns start."); +of parameter 'start' (which defaults to 0). When the sequence is\n\ +empty, returns start."); static PyObject * Modified: python/branches/p3yk/Python/ceval.c ============================================================================== --- python/branches/p3yk/Python/ceval.c (original) +++ python/branches/p3yk/Python/ceval.c Wed Dec 13 05:49:30 2006 @@ -184,10 +184,10 @@ PyObject * PyEval_GetCallStats(PyObject *self) { - return Py_BuildValue("iiiiiiiiii", + return Py_BuildValue("iiiiiiiiiii", pcall[0], pcall[1], pcall[2], pcall[3], pcall[4], pcall[5], pcall[6], pcall[7], - pcall[8], pcall[9]); + pcall[8], pcall[9], pcall[10]); } #else #define PCALL(O) @@ -4043,8 +4043,10 @@ value = PyObject_GetAttr(v, name); if (value == NULL) err = -1; - else + else if (PyDict_CheckExact(locals)) err = PyDict_SetItem(locals, name, value); + else + err = PyObject_SetItem(locals, name, value); Py_DECREF(name); Py_XDECREF(value); if (err != 0) Modified: python/branches/p3yk/Python/compile.c ============================================================================== --- python/branches/p3yk/Python/compile.c (original) +++ python/branches/p3yk/Python/compile.c Wed Dec 13 05:49:30 2006 @@ -6,9 +6,10 @@ * object: * 1. Checks for future statements. See future.c * 2. Builds a symbol table. See symtable.c. - * 3. Generate code for basic blocks. See compiler_mod() in this file. + * 3. Generate code for basic blocks. See compiler_mod() in this file. * 4. Assemble the basic blocks into final code. See assemble() in - * this file. + * this file. + * 5. Optimize the byte code (peephole optimizations). See peephole.c * * Note that compiler_mod() suggests module, but the module ast type * (mod_ty) has cases for expressions and interactive statements. @@ -16,7 +17,8 @@ * CAUTION: The VISIT_* macros abort the current function when they * encounter a problem. So don't invoke them when there is memory * which needs to be released. Code blocks are OK, as the compiler - * structure takes care of releasing those. + * structure takes care of releasing those. Use the arena to manage + * objects. */ #include "Python.h" @@ -32,16 +34,6 @@ int Py_OptimizeFlag = 0; -/* - ISSUES: - - opcode_stack_effect() function should be reviewed since stack depth bugs - could be really hard to find later. - - Dead code is being generated (i.e. after unconditional jumps). - XXX(nnorwitz): not sure this is still true -*/ - #define DEFAULT_BLOCK_SIZE 16 #define DEFAULT_BLOCKS 8 #define DEFAULT_CODE_SIZE 128 @@ -116,11 +108,11 @@ int u_argcount; /* number of arguments for block */ int u_kwonlyargcount; /* number of keyword only arguments for block */ - /* Pointer to the most recently allocated block. By following b_list - members, you can reach all early allocated blocks. */ + /* Pointer to the most recently allocated block. By following b_list + members, you can reach all early allocated blocks. */ basicblock *u_blocks; basicblock *u_curblock; /* pointer to current block */ - int u_tmpname; /* temporary variables for list comps */ + int u_tmpname; /* temporary variables for list comps */ int u_nfblocks; struct fblockinfo u_fblock[CO_MAXBLOCKS]; @@ -153,17 +145,6 @@ PyArena *c_arena; /* pointer to memory allocation arena */ }; -struct assembler { - PyObject *a_bytecode; /* string containing bytecode */ - int a_offset; /* offset into bytecode */ - int a_nblocks; /* number of reachable blocks */ - basicblock **a_postorder; /* list of blocks in dfs postorder */ - PyObject *a_lnotab; /* string containing lnotab */ - int a_lnotab_off; /* offset into lnotab */ - int a_lineno; /* last lineno of emitted instruction */ - int a_lineno_off; /* bytecode offset of last lineno */ -}; - static int compiler_enter_scope(struct compiler *, identifier, void *, int); static void compiler_free(struct compiler *); static basicblock *compiler_new_block(struct compiler *); @@ -188,6 +169,8 @@ basicblock *); static void compiler_pop_fblock(struct compiler *, enum fblocktype, basicblock *); +/* Returns true if there is a loop on the fblock stack. */ +static int compiler_in_loop(struct compiler *); static int inplace_binop(struct compiler *, operator_ty); static int expr_constant(expr_ty e); @@ -395,47 +378,6 @@ return dest; } -/* - -Leave this debugging code for just a little longer. - -static void -compiler_display_symbols(PyObject *name, PyObject *symbols) -{ -PyObject *key, *value; -int flags; -Py_ssize_t pos = 0; - -fprintf(stderr, "block %s\n", PyString_AS_STRING(name)); -while (PyDict_Next(symbols, &pos, &key, &value)) { -flags = PyInt_AsLong(value); -fprintf(stderr, "var %s:", PyString_AS_STRING(key)); -if (flags & DEF_GLOBAL) -fprintf(stderr, " declared_global"); -if (flags & DEF_LOCAL) -fprintf(stderr, " local"); -if (flags & DEF_PARAM) -fprintf(stderr, " param"); -if (flags & DEF_STAR) -fprintf(stderr, " stararg"); -if (flags & DEF_DOUBLESTAR) -fprintf(stderr, " starstar"); -if (flags & DEF_INTUPLE) -fprintf(stderr, " tuple"); -if (flags & DEF_FREE) -fprintf(stderr, " free"); -if (flags & DEF_FREE_GLOBAL) -fprintf(stderr, " global"); -if (flags & DEF_FREE_CLASS) -fprintf(stderr, " free/class"); -if (flags & DEF_IMPORT) -fprintf(stderr, " import"); -fprintf(stderr, "\n"); -} - fprintf(stderr, "\n"); -} -*/ - static void compiler_unit_check(struct compiler_unit *u) { @@ -610,7 +552,7 @@ return NULL; } memset((void *)b, 0, sizeof(basicblock)); - /* Extend the singly linked list of blocks with new block. */ + /* Extend the singly linked list of blocks with new block. */ b->b_list = u->u_blocks; u->u_blocks = b; return b; @@ -649,7 +591,7 @@ /* Returns the offset of the next instruction in the current block's b_instr array. Resizes the b_instr as necessary. Returns -1 on failure. - */ +*/ static int compiler_next_instr(struct compiler *c, basicblock *b) @@ -693,7 +635,7 @@ already been set. If it has been set, the call has no effect. Every time a new node is b - */ +*/ static void compiler_set_lineno(struct compiler *c, int off) @@ -1053,8 +995,8 @@ from the current block to the new block. */ -/* XXX The returns inside these macros make it impossible to decref - objects created in the local function. +/* The returns inside these macros make it impossible to decref objects + created in the local function. Local objects should use the arena. */ @@ -1722,6 +1664,8 @@ compiler_continue(struct compiler *c) { static const char LOOP_ERROR_MSG[] = "'continue' not properly in loop"; + static const char IN_FINALLY_ERROR_MSG[] = + "'continue' not supported inside 'finally' clause"; int i; if (!c->u->u_nfblocks) @@ -1733,15 +1677,18 @@ break; case EXCEPT: case FINALLY_TRY: - while (--i >= 0 && c->u->u_fblock[i].fb_type != LOOP) - ; + while (--i >= 0 && c->u->u_fblock[i].fb_type != LOOP) { + /* Prevent continue anywhere under a finally + even if hidden in a sub-try or except. */ + if (c->u->u_fblock[i].fb_type == FINALLY_END) + return compiler_error(c, IN_FINALLY_ERROR_MSG); + } if (i == -1) return compiler_error(c, LOOP_ERROR_MSG); ADDOP_JABS(c, CONTINUE_LOOP, c->u->u_fblock[i].fb_block); break; case FINALLY_END: - return compiler_error(c, - "'continue' not supported inside 'finally' clause"); + return compiler_error(c, IN_FINALLY_ERROR_MSG); } return 1; @@ -2084,7 +2031,7 @@ { int i, n; - /* Always assign a lineno to the next instruction for a stmt. */ + /* Always assign a lineno to the next instruction for a stmt. */ c->u->u_lineno = s->lineno; c->u->u_lineno_set = false; @@ -2168,7 +2115,7 @@ case Pass_kind: break; case Break_kind: - if (!c->u->u_nfblocks) + if (!compiler_in_loop(c)) return compiler_error(c, "'break' outside loop"); ADDOP(c, BREAK_LOOP); break; @@ -2522,7 +2469,6 @@ } return 1; } -#undef CMPCAST static int compiler_call(struct compiler *c, expr_ty e) @@ -2622,7 +2568,7 @@ } ADDOP_JABS(c, JUMP_ABSOLUTE, start); compiler_use_next_block(c, anchor); - /* delete the append method added to locals */ + /* delete the temporary list name added to locals */ if (gen_index == 1) if (!compiler_nameop(c, tmpname, Del)) return 0; @@ -2635,15 +2581,9 @@ { identifier tmp; int rc = 0; - static identifier append; asdl_seq *generators = e->v.ListComp.generators; assert(e->kind == ListComp_kind); - if (!append) { - append = PyString_InternFromString("append"); - if (!append) - return 0; - } tmp = compiler_new_tmpname(c); if (!tmp) return 0; @@ -2944,9 +2884,9 @@ { int i, n; - /* If expr e has a different line number than the last expr/stmt, - set a new line number for the next instruction. - */ + /* If expr e has a different line number than the last expr/stmt, + set a new line number for the next instruction. + */ if (e->lineno > c->u->u_lineno) { c->u->u_lineno = e->lineno; c->u->u_lineno_set = false; @@ -2995,14 +2935,6 @@ case Yield_kind: if (c->u->u_ste->ste_type != FunctionBlock) return compiler_error(c, "'yield' outside function"); - /* - for (i = 0; i < c->u->u_nfblocks; i++) { - if (c->u->u_fblock[i].fb_type == FINALLY_TRY) - return compiler_error( - c, "'yield' not allowed in a 'try' " - "block with a 'finally' clause"); - } - */ if (e->v.Yield.value) { VISIT(c, expr, e->v.Yield.value); } @@ -3140,8 +3072,11 @@ compiler_push_fblock(struct compiler *c, enum fblocktype t, basicblock *b) { struct fblockinfo *f; - if (c->u->u_nfblocks >= CO_MAXBLOCKS) + if (c->u->u_nfblocks >= CO_MAXBLOCKS) { + PyErr_SetString(PyExc_SystemError, + "too many statically nested blocks"); return 0; + } f = &c->u->u_fblock[c->u->u_nfblocks++]; f->fb_type = t; f->fb_block = b; @@ -3158,6 +3093,16 @@ assert(u->u_fblock[u->u_nfblocks].fb_block == b); } +static int +compiler_in_loop(struct compiler *c) { + int i; + struct compiler_unit *u = c->u; + for (i = 0; i < u->u_nfblocks; ++i) { + if (u->u_fblock[i].fb_type == LOOP) + return 1; + } + return 0; +} /* Raises a SyntaxError and returns 0. If something goes wrong, a different exception may be raised. */ @@ -3316,7 +3261,6 @@ return 1; } - static int compiler_visit_slice(struct compiler *c, slice_ty s, expr_context_ty ctx) { @@ -3358,12 +3302,26 @@ return compiler_handle_subscr(c, kindname, ctx); } + +/* End of the compiler section, beginning of the assembler section */ + /* do depth-first search of basic block graph, starting with block. post records the block indices in post-order. XXX must handle implicit jumps from one block to next */ +struct assembler { + PyObject *a_bytecode; /* string containing bytecode */ + int a_offset; /* offset into bytecode */ + int a_nblocks; /* number of reachable blocks */ + basicblock **a_postorder; /* list of blocks in dfs postorder */ + PyObject *a_lnotab; /* string containing lnotab */ + int a_lnotab_off; /* offset into lnotab */ + int a_lineno; /* last lineno of emitted instruction */ + int a_lineno_off; /* bytecode offset of last lineno */ +}; + static void dfs(struct compiler *c, basicblock *b, struct assembler *a) { Modified: python/branches/p3yk/Python/errors.c ============================================================================== --- python/branches/p3yk/Python/errors.c (original) +++ python/branches/p3yk/Python/errors.c Wed Dec 13 05:49:30 2006 @@ -560,7 +560,8 @@ goto failure; } if (PyDict_GetItemString(dict, "__module__") == NULL) { - modulename = PyString_FromStringAndSize(name, (int)(dot-name)); + modulename = PyString_FromStringAndSize(name, + (Py_ssize_t)(dot-name)); if (modulename == NULL) goto failure; if (PyDict_SetItemString(dict, "__module__", modulename) != 0) Modified: python/branches/p3yk/Python/getargs.c ============================================================================== --- python/branches/p3yk/Python/getargs.c (original) +++ python/branches/p3yk/Python/getargs.c Wed Dec 13 05:49:30 2006 @@ -816,7 +816,7 @@ #endif else return converterr("string", arg, msgbuf, bufsize); - if ((int)strlen(*p) != PyString_Size(arg)) + if ((Py_ssize_t)strlen(*p) != PyString_Size(arg)) return converterr("string without null bytes", arg, msgbuf, bufsize); } @@ -883,7 +883,7 @@ format++; } else if (*p != NULL && - (int)strlen(*p) != PyString_Size(arg)) + (Py_ssize_t)strlen(*p) != PyString_Size(arg)) return converterr( "string without null bytes or None", arg, msgbuf, bufsize); @@ -1030,7 +1030,8 @@ PyMem_Free()ing it after usage */ - if ((int)strlen(PyString_AS_STRING(s)) != size) { + if ((Py_ssize_t)strlen(PyString_AS_STRING(s)) + != size) { Py_DECREF(s); return converterr( "(encoded string without NULL bytes)", @@ -1746,7 +1747,7 @@ /* For type constructors that don't take keyword args * * Sets a TypeError and returns 0 if the kwds dict is - * not emtpy, returns 1 otherwise + * not empty, returns 1 otherwise */ int _PyArg_NoKeywords(const char *funcname, PyObject *kw) Modified: python/branches/p3yk/Python/import.c ============================================================================== --- python/branches/p3yk/Python/import.c (original) +++ python/branches/p3yk/Python/import.c Wed Dec 13 05:49:30 2006 @@ -64,6 +64,8 @@ Python 2.5b3: 62111 (fix wrong code: x += yield) Python 2.5c1: 62121 (fix wrong lnotab with for loops and storing constants that should have been removed) + Python 2.5c2: 62131 (fix wrong code: for x, in ... in listcomp/genexp) + Python 2.6a0: 62141 (peephole optimizations) Python 3000: 3000 3010 (removed UNARY_CONVERT) 3020 (added BUILD_SET) @@ -799,14 +801,16 @@ { PyCodeObject *co = NULL; mod_ty mod; - PyArena *arena = PyArena_New(); + PyArena *arena = PyArena_New(); + if (arena == NULL) + return NULL; mod = PyParser_ASTFromFile(fp, pathname, Py_file_input, 0, 0, 0, NULL, arena); if (mod) { co = PyAST_Compile(mod, pathname, NULL, arena); } - PyArena_Free(arena); + PyArena_Free(arena); return co; } @@ -1030,7 +1034,7 @@ /* Return an importer object for a sys.path/pkg.__path__ item 'p', possibly by fetching it from the path_importer_cache dict. If it - wasn't yet cached, traverse path_hooks until it a hook is found + wasn't yet cached, traverse path_hooks until a hook is found that can handle the path item. Return None if no hook could; this tells our caller it should fall back to the builtin import mechanism. Cache the result in path_importer_cache. @@ -1802,7 +1806,7 @@ /* Initialize a built-in module. - Return 1 for succes, 0 if the module is not found, and -1 with + Return 1 for success, 0 if the module is not found, and -1 with an exception set if the initialization failed. */ static int @@ -2117,7 +2121,7 @@ size_t len; if (lastdot == NULL && level > 0) { PyErr_SetString(PyExc_ValueError, - "Relative importpath too deep"); + "Attempted relative import in non-package"); return NULL; } if (lastdot == NULL) @@ -2136,7 +2140,8 @@ char *dot = strrchr(buf, '.'); if (dot == NULL) { PyErr_SetString(PyExc_ValueError, - "Relative importpath too deep"); + "Attempted relative import beyond " + "toplevel package"); return NULL; } *dot = '\0'; Modified: python/branches/p3yk/Python/marshal.c ============================================================================== --- python/branches/p3yk/Python/marshal.c (original) +++ python/branches/p3yk/Python/marshal.c Wed Dec 13 05:49:30 2006 @@ -547,6 +547,11 @@ int size; PyLongObject *ob; n = r_long(p); + if (n < -INT_MAX || n > INT_MAX) { + PyErr_SetString(PyExc_ValueError, + "bad marshal data"); + return NULL; + } size = n<0 ? -n : n; ob = _PyLong_New(size); if (ob == NULL) @@ -655,7 +660,7 @@ case TYPE_INTERNED: case TYPE_STRING: n = r_long(p); - if (n < 0) { + if (n < 0 || n > INT_MAX) { PyErr_SetString(PyExc_ValueError, "bad marshal data"); return NULL; } @@ -690,7 +695,7 @@ char *buffer; n = r_long(p); - if (n < 0) { + if (n < 0 || n > INT_MAX) { PyErr_SetString(PyExc_ValueError, "bad marshal data"); return NULL; } @@ -711,7 +716,7 @@ case TYPE_TUPLE: n = r_long(p); - if (n < 0) { + if (n < 0 || n > INT_MAX) { PyErr_SetString(PyExc_ValueError, "bad marshal data"); return NULL; } @@ -734,7 +739,7 @@ case TYPE_LIST: n = r_long(p); - if (n < 0) { + if (n < 0 || n > INT_MAX) { PyErr_SetString(PyExc_ValueError, "bad marshal data"); return NULL; } @@ -833,11 +838,12 @@ v = NULL; - argcount = r_long(p); - kwonlyargcount = r_long(p); - nlocals = r_long(p); - stacksize = r_long(p); - flags = r_long(p); + /* XXX ignore long->int overflows for now */ + argcount = (int)r_long(p); + kwonlyargcount = (int)r_long(p); + nlocals = (int)r_long(p); + stacksize = (int)r_long(p); + flags = (int)r_long(p); code = r_object(p); if (code == NULL) goto code_error; @@ -862,7 +868,7 @@ name = r_object(p); if (name == NULL) goto code_error; - firstlineno = r_long(p); + firstlineno = (int)r_long(p); lnotab = r_object(p); if (lnotab == NULL) goto code_error; @@ -1035,10 +1041,16 @@ wf.strings = (version > 0) ? PyDict_New() : NULL; w_object(x, &wf); Py_XDECREF(wf.strings); - if (wf.str != NULL) - _PyString_Resize(&wf.str, - (int) (wf.ptr - - PyString_AS_STRING((PyStringObject *)wf.str))); + if (wf.str != NULL) { + char *base = PyString_AS_STRING((PyStringObject *)wf.str); + if (wf.ptr - base > PY_SSIZE_T_MAX) { + Py_DECREF(wf.str); + PyErr_SetString(PyExc_OverflowError, + "too much marshall data for a string"); + return NULL; + } + _PyString_Resize(&wf.str, (Py_ssize_t)(wf.ptr - base)); + } if (wf.error) { Py_XDECREF(wf.str); PyErr_SetString(PyExc_ValueError, Modified: python/branches/p3yk/Python/modsupport.c ============================================================================== --- python/branches/p3yk/Python/modsupport.c (original) +++ python/branches/p3yk/Python/modsupport.c Wed Dec 13 05:49:30 2006 @@ -421,7 +421,7 @@ "string too long for Python string"); return NULL; } - n = (int)m; + n = (Py_ssize_t)m; } v = PyString_FromStringAndSize(str, n); } Modified: python/branches/p3yk/Python/mystrtoul.c ============================================================================== --- python/branches/p3yk/Python/mystrtoul.c (original) +++ python/branches/p3yk/Python/mystrtoul.c Wed Dec 13 05:49:30 2006 @@ -195,13 +195,10 @@ return (unsigned long)-1; } -/* Checking for overflow in PyOS_strtol is a PITA since C doesn't define - * anything about what happens when a signed integer operation overflows, - * and some compilers think they're doing you a favor by being "clever" - * then. Python assumes a 2's-complement representation, so that the bit - * pattern for the largest postive signed long is LONG_MAX, and for - * the smallest negative signed long is LONG_MAX + 1. +/* Checking for overflow in PyOS_strtol is a PITA; see comments + * about PY_ABS_LONG_MIN in longobject.c. */ +#define PY_ABS_LONG_MIN (0-(unsigned long)LONG_MIN) long PyOS_strtol(char *str, char **ptr, int base) @@ -224,8 +221,7 @@ if (sign == '-') result = -result; } - else if (sign == '-' && uresult == (unsigned long)LONG_MAX + 1) { - assert(LONG_MIN == -LONG_MAX-1); + else if (sign == '-' && uresult == PY_ABS_LONG_MIN) { result = LONG_MIN; } else { Modified: python/branches/p3yk/Python/peephole.c ============================================================================== --- python/branches/p3yk/Python/peephole.c (original) +++ python/branches/p3yk/Python/peephole.c Wed Dec 13 05:49:30 2006 @@ -514,6 +514,13 @@ case SETUP_EXCEPT: case SETUP_FINALLY: tgt = GETJUMPTGT(codestr, i); + /* Replace JUMP_* to a RETURN into just a RETURN */ + if (UNCONDITIONAL_JUMP(opcode) && + codestr[tgt] == RETURN_VALUE) { + codestr[i] = RETURN_VALUE; + memset(codestr+i+1, NOP, 2); + continue; + } if (!UNCONDITIONAL_JUMP(codestr[tgt])) continue; tgttgt = GETJUMPTGT(codestr, tgt); @@ -531,12 +538,16 @@ goto exitUnchanged; /* Replace RETURN LOAD_CONST None RETURN with just RETURN */ + /* Remove unreachable JUMPs after RETURN */ case RETURN_VALUE: - if (i+4 >= codelen || - codestr[i+4] != RETURN_VALUE || - !ISBASICBLOCK(blocks,i,5)) + if (i+4 >= codelen) continue; - memset(codestr+i+1, NOP, 4); + if (codestr[i+4] == RETURN_VALUE && + ISBASICBLOCK(blocks,i,5)) + memset(codestr+i+1, NOP, 4); + else if (UNCONDITIONAL_JUMP(codestr[i+1]) && + ISBASICBLOCK(blocks,i,4)) + memset(codestr+i+1, NOP, 3); break; } } Modified: python/branches/p3yk/Python/pystate.c ============================================================================== --- python/branches/p3yk/Python/pystate.c (original) +++ python/branches/p3yk/Python/pystate.c Wed Dec 13 05:49:30 2006 @@ -309,9 +309,14 @@ */ #if defined(Py_DEBUG) && defined(WITH_THREAD) if (newts) { + /* This can be called from PyEval_RestoreThread(). Similar + to it, we need to ensure errno doesn't change. + */ + int err = errno; PyThreadState *check = PyGILState_GetThisThreadState(); if (check && check->interp == newts->interp && check != newts) Py_FatalError("Invalid thread state for this thread"); + errno = err; } #endif return oldts; @@ -496,7 +501,7 @@ { PyThread_delete_key(autoTLSkey); autoTLSkey = 0; - autoInterpreterState = NULL;; + autoInterpreterState = NULL; } /* When a thread state is created for a thread by some mechanism other than @@ -504,7 +509,7 @@ it so it doesn't try to create another thread state for the thread (this is a better fix for SF bug #1010677 than the first one attempted). */ -void +static void _PyGILState_NoteThreadState(PyThreadState* tstate) { /* If autoTLSkey is 0, this must be the very first threadstate created Modified: python/branches/p3yk/Python/pythonrun.c ============================================================================== --- python/branches/p3yk/Python/pythonrun.c (original) +++ python/branches/p3yk/Python/pythonrun.c Wed Dec 13 05:49:30 2006 @@ -527,11 +527,15 @@ bimod = _PyImport_FindExtension("__builtin__", "__builtin__"); if (bimod != NULL) { interp->builtins = PyModule_GetDict(bimod); + if (interp->builtins == NULL) + goto handle_error; Py_INCREF(interp->builtins); } sysmod = _PyImport_FindExtension("sys", "sys"); if (bimod != NULL && sysmod != NULL) { interp->sysdict = PyModule_GetDict(sysmod); + if (interp->sysdict == NULL) + goto handle_error; Py_INCREF(interp->sysdict); PySys_SetPath(Py_GetPath()); PyDict_SetItemString(interp->sysdict, "modules", @@ -545,6 +549,7 @@ if (!PyErr_Occurred()) return tstate; +handle_error: /* Oops, it didn't work. Undo it all. */ PyErr_Print(); @@ -718,6 +723,15 @@ ((flags) ? ((((flags)->cf_flags & PyCF_DONT_IMPLY_DEDENT) ? \ PyPARSE_DONT_IMPLY_DEDENT : 0)) : 0) +#if 0 +/* Keep an example of flags with future keyword support. */ +#define PARSER_FLAGS(flags) \ + ((flags) ? ((((flags)->cf_flags & PyCF_DONT_IMPLY_DEDENT) ? \ + PyPARSE_DONT_IMPLY_DEDENT : 0) \ + | ((flags)->cf_flags & CO_FUTURE_WITH_STATEMENT ? \ + PyPARSE_WITH_IS_KEYWORD : 0)) : 0) +#endif + int PyRun_InteractiveOneFlags(FILE *fp, const char *filename, PyCompilerFlags *flags) { Modified: python/branches/p3yk/Python/structmember.c ============================================================================== --- python/branches/p3yk/Python/structmember.c (original) +++ python/branches/p3yk/Python/structmember.c Wed Dec 13 05:49:30 2006 @@ -62,29 +62,28 @@ addr += l->offset; switch (l->type) { case T_BYTE: - v = PyInt_FromLong( - (long) (((*(char*)addr & 0xff) ^ 0x80) - 0x80)); + v = PyInt_FromLong(*(char*)addr); break; case T_UBYTE: - v = PyInt_FromLong((long) *(char*)addr & 0xff); + v = PyLong_FromUnsignedLong(*(unsigned char*)addr); break; case T_SHORT: - v = PyInt_FromLong((long) *(short*)addr); + v = PyInt_FromLong(*(short*)addr); break; case T_USHORT: - v = PyInt_FromLong((long) *(unsigned short*)addr); + v = PyLong_FromUnsignedLong(*(unsigned short*)addr); break; case T_INT: - v = PyInt_FromLong((long) *(int*)addr); + v = PyInt_FromLong(*(int*)addr); break; case T_UINT: - v = PyInt_FromLong((long) *(unsigned int*)addr); + v = PyLong_FromUnsignedLong(*(unsigned int*)addr); break; case T_LONG: v = PyInt_FromLong(*(long*)addr); break; case T_ULONG: - v = PyLong_FromDouble((double) *(unsigned long*)addr); + v = PyLong_FromUnsignedLong(*(unsigned long*)addr); break; case T_FLOAT: v = PyFloat_FromDouble((double)*(float*)addr); @@ -179,68 +178,107 @@ } addr += l->offset; switch (l->type) { - case T_BYTE: - case T_UBYTE: - if (!PyInt_Check(v)) { - PyErr_BadArgument(); + case T_BYTE:{ + long long_val; + long_val = PyInt_AsLong(v); + if ((long_val == -1) && PyErr_Occurred()) return -1; - } - *(char*)addr = (char) PyInt_AsLong(v); + /* XXX: For compatibility, only warn about truncations + for now. */ + if ((long_val > CHAR_MAX) || (long_val < CHAR_MIN)) + PyErr_Warn(PyExc_RuntimeWarning, "Truncation of value to char"); + *(char*)addr = (char)long_val; break; - case T_SHORT: - case T_USHORT: - if (!PyInt_Check(v)) { - PyErr_BadArgument(); - return -1; } - *(short*)addr = (short) PyInt_AsLong(v); - break; - case T_UINT: - case T_INT: - if (!PyInt_Check(v)) { - PyErr_BadArgument(); + case T_UBYTE:{ + long long_val; + long_val = PyInt_AsLong(v); + if ((long_val == -1) && PyErr_Occurred()) return -1; - } - *(int*)addr = (int) PyInt_AsLong(v); + if ((long_val > UCHAR_MAX) || (long_val < 0)) + PyErr_Warn(PyExc_RuntimeWarning, "Truncation of value to unsigned char"); + *(unsigned char*)addr = (unsigned char)long_val; break; - case T_LONG: - if (!PyInt_Check(v)) { - PyErr_BadArgument(); + } + case T_SHORT:{ + long long_val; + long_val = PyInt_AsLong(v); + if ((long_val == -1) && PyErr_Occurred()) return -1; + if ((long_val > SHRT_MAX) || (long_val < SHRT_MIN)) + PyErr_Warn(PyExc_RuntimeWarning, "Truncation of value to short"); + *(short*)addr = (short)long_val; + break; } - *(long*)addr = PyInt_AsLong(v); + case T_USHORT:{ + long long_val; + long_val = PyInt_AsLong(v); + if ((long_val == -1) && PyErr_Occurred()) + return -1; + if ((long_val > USHRT_MAX) || (long_val < 0)) + PyErr_Warn(PyExc_RuntimeWarning, "Truncation of value to unsigned short"); + *(unsigned short*)addr = (unsigned short)long_val; break; - case T_ULONG: - if (PyInt_Check(v)) - *(long*)addr = PyInt_AsLong(v); - else if (PyLong_Check(v)) - *(long*)addr = PyLong_AsLong(v); - else { - PyErr_BadArgument(); + } + case T_INT:{ + long long_val; + long_val = PyInt_AsLong(v); + if ((long_val == -1) && PyErr_Occurred()) return -1; + if ((long_val > INT_MAX) || (long_val < INT_MIN)) + PyErr_Warn(PyExc_RuntimeWarning, "Truncation of value to int"); + *(int *)addr = (int)long_val; + break; + } + case T_UINT:{ + unsigned long ulong_val; + ulong_val = PyLong_AsUnsignedLong(v); + if ((ulong_val == (unsigned int)-1) && PyErr_Occurred()) { + /* XXX: For compatibility, accept negative int values + as well. */ + PyErr_Clear(); + ulong_val = PyLong_AsLong(v); + if ((ulong_val == (unsigned int)-1) && PyErr_Occurred()) + return -1; + PyErr_Warn(PyExc_RuntimeWarning, "Writing negative value into unsigned field"); + } + if (ulong_val > UINT_MAX) + PyErr_Warn(PyExc_RuntimeWarning, "Truncation of value to unsigned int"); + *(unsigned int *)addr = (unsigned int)ulong_val; + break; + } + case T_LONG:{ + *(long*)addr = PyLong_AsLong(v); + if ((*(long*)addr == -1) && PyErr_Occurred()) + return -1; + break; + } + case T_ULONG:{ + *(unsigned long*)addr = PyLong_AsUnsignedLong(v); + if ((*(unsigned long*)addr == (unsigned long)-1) + && PyErr_Occurred()) { + /* XXX: For compatibility, accept negative int values + as well. */ + PyErr_Clear(); + *(unsigned long*)addr = PyLong_AsLong(v); + if ((*(unsigned long*)addr == (unsigned int)-1) && PyErr_Occurred()) + return -1; + PyErr_Warn(PyExc_RuntimeWarning, "Writing negative value into unsigned field"); } break; - case T_FLOAT: - if (PyInt_Check(v)) - *(float*)addr = - (float) PyInt_AsLong(v); - else if (PyFloat_Check(v)) - *(float*)addr = - (float) PyFloat_AsDouble(v); - else { - PyErr_BadArgument(); - return -1; } + case T_FLOAT:{ + double double_val; + double_val = PyFloat_AsDouble(v); + if ((double_val == -1) && PyErr_Occurred()) + return -1; + *(float*)addr = (float)double_val; break; + } case T_DOUBLE: - if (PyInt_Check(v)) - *(double*)addr = (double) PyInt_AsLong(v); - else if (PyFloat_Check(v)) - *(double*)addr = PyFloat_AsDouble(v); - else { - PyErr_BadArgument(); + *(double*)addr = PyFloat_AsDouble(v); + if ((*(double*)addr == -1) && PyErr_Occurred()) return -1; - } break; case T_OBJECT: case T_OBJECT_EX: Modified: python/branches/p3yk/Python/sysmodule.c ============================================================================== --- python/branches/p3yk/Python/sysmodule.c (original) +++ python/branches/p3yk/Python/sysmodule.c Wed Dec 13 05:49:30 2006 @@ -979,6 +979,8 @@ br_start = python + 8; br_end = strchr(br_start, '/'); + assert(br_end); + /* Works even for trunk, as we are in trunk/Python/sysmodule.c */ br_end2 = strchr(br_end+1, '/'); @@ -991,6 +993,8 @@ } else if (istag || strncmp(br_start, "branches", 8) == 0) { len = br_end2 - br_start; + assert(len >= 13); + assert(len < (sizeof(patchlevel_revision) - 13)); strncpy(branch, br_start, len); branch[len] = '\0'; @@ -1221,7 +1225,7 @@ p = strchr(path, delim); if (p == NULL) p = strchr(path, '\0'); /* End of string */ - w = PyString_FromStringAndSize(path, (int) (p - path)); + w = PyString_FromStringAndSize(path, (Py_ssize_t) (p - path)); if (w == NULL) { Py_DECREF(v); return NULL; Modified: python/branches/p3yk/README ============================================================================== --- python/branches/p3yk/README (original) +++ python/branches/p3yk/README Wed Dec 13 05:49:30 2006 @@ -231,6 +231,11 @@ available for all modern systems, either in the form of updated compilers from the vendor, or one of the free compilers (gcc). +If "make install" fails mysteriously during the "compiling the library" +step, make sure that you don't have any of the PYTHONPATH or PYTHONHOME +environment variables set, as they may interfere with the newly built +executable which is compiling the library. + Unsupported systems ------------------- Modified: python/branches/p3yk/Tools/msi/msi.py ============================================================================== --- python/branches/p3yk/Tools/msi/msi.py (original) +++ python/branches/p3yk/Tools/msi/msi.py Wed Dec 13 05:49:30 2006 @@ -872,6 +872,12 @@ version=version, language=lang) tmpfiles.append("msvcr71.dll") + # Check if _ctypes.pyd exists + have_ctypes = os.path.exists(srcdir+"/PCBuild/_ctypes.pyd") + if not have_ctypes: + print "WARNING: _ctypes.pyd not found, ctypes will not be included" + extensions.remove("_ctypes.pyd") + # Add all .py files in Lib, except lib-tk, test dirs={} pydirs = [(root,"Lib")] @@ -889,6 +895,8 @@ # data: Lib/email/test # output: Lib/test testsuite.set_current() + elif not have_ctypes and dir == "ctypes": + continue else: default_feature.set_current() lib = PyDirectory(db, cab, parent, dir, dir, "%s|%s" % (parent.make_short(dir), dir)) @@ -913,6 +921,7 @@ lib.add_file("185test.db") lib.add_file("audiotest.au") lib.add_file("cfgparser.1") + lib.add_file("sgml_input.html") lib.add_file("test.xml") lib.add_file("test.xml.out") lib.add_file("testtar.tar") Modified: python/branches/p3yk/Tools/msi/uuids.py ============================================================================== --- python/branches/p3yk/Tools/msi/uuids.py (original) +++ python/branches/p3yk/Tools/msi/uuids.py Wed Dec 13 05:49:30 2006 @@ -22,6 +22,8 @@ '2.4.2150':'{b191e49c-ea23-43b2-b28a-14e0784069b8}', # 2.4.2 '2.4.3121':'{f669ed4d-1dce-41c4-9617-d985397187a1}', # 2.4.3c1 '2.4.3150':'{75e71add-042c-4f30-bfac-a9ec42351313}', # 2.4.3 + '2.4.4121':'{cd2862db-22a4-4688-8772-85407ea21550}', # 2.4.4c1 + '2.4.4150':'{60e2c8c9-6cf3-4b1a-9618-e304946c94e6}', # 2.4.4 '2.5.101': '{bc14ce3e-5e72-4a64-ac1f-bf59a571898c}', # 2.5a1 '2.5.102': '{5eed51c1-8e9d-4071-94c5-b40de5d49ba5}', # 2.5a2 '2.5.103': '{73dcd966-ffec-415f-bb39-8342c1f47017}', # 2.5a3 Modified: python/branches/p3yk/Tools/pybench/pybench.py ============================================================================== --- python/branches/p3yk/Tools/pybench/pybench.py (original) +++ python/branches/p3yk/Tools/pybench/pybench.py Wed Dec 13 05:49:30 2006 @@ -885,7 +885,7 @@ else: bench.print_benchmark(hidenoise=hidenoise, limitnames=limitnames) - except IOError: + except IOError, reason: print '* Error opening/reading file %s: %s' % ( repr(show_bench), reason) @@ -931,8 +931,13 @@ bench.name = reportfile pickle.dump(bench,f) f.close() - except IOError: + except IOError, reason: print '* Error opening/writing reportfile' + except IOError, reason: + print '* Error opening/writing reportfile %s: %s' % ( + reportfile, + reason) + print if __name__ == '__main__': PyBenchCmdline() Modified: python/branches/p3yk/Tools/scripts/findnocoding.py ============================================================================== --- python/branches/p3yk/Tools/scripts/findnocoding.py (original) +++ python/branches/p3yk/Tools/scripts/findnocoding.py Wed Dec 13 05:49:30 2006 @@ -5,7 +5,7 @@ Usage: nocoding.py dir1 [dir2...] """ -__author__ = "Oleg Broytmann, Reinhold Birkenfeld" +__author__ = "Oleg Broytmann, Georg Brandl" import sys, os, re, getopt Modified: python/branches/p3yk/Tools/scripts/pysource.py ============================================================================== --- python/branches/p3yk/Tools/scripts/pysource.py (original) +++ python/branches/p3yk/Tools/scripts/pysource.py Wed Dec 13 05:49:30 2006 @@ -15,7 +15,7 @@ walk_python_files() recursively lists all Python files under the given directories. """ -__author__ = "Oleg Broytmann, Reinhold Birkenfeld" +__author__ = "Oleg Broytmann, Georg Brandl" __all__ = ["has_python_ext", "looks_like_python", "can_be_compiled", "walk_python_files"] Modified: python/branches/p3yk/configure ============================================================================== --- python/branches/p3yk/configure (original) +++ python/branches/p3yk/configure Wed Dec 13 05:49:30 2006 @@ -1,7 +1,7 @@ #! /bin/sh -# From configure.in Revision: 46754 . +# From configure.in Revision: 51211 . # Guess values for system-dependent variables and create Makefiles. -# Generated by GNU Autoconf 2.60 for python 3.0. +# Generated by GNU Autoconf 2.61 for python 3.0. # # Report bugs to . # @@ -13,7 +13,8 @@ ## M4sh Initialization. ## ## --------------------- ## -# Be Bourne compatible +# Be more Bourne compatible +DUALCASE=1; export DUALCASE # for MKS sh if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then emulate sh NULLCMD=: @@ -22,10 +23,13 @@ alias -g '${1+"$@"}'='"$@"' setopt NO_GLOB_SUBST else - case `(set -o) 2>/dev/null` in *posix*) set -o posix;; esac + case `(set -o) 2>/dev/null` in + *posix*) set -o posix ;; +esac + fi -BIN_SH=xpg4; export BIN_SH # for Tru64 -DUALCASE=1; export DUALCASE # for MKS sh + + # PATH needs CR @@ -218,7 +222,7 @@ else as_candidate_shells= as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in /usr/bin/posix$PATH_SEPARATOR/bin$PATH_SEPARATOR/usr/bin$PATH_SEPARATOR$PATH +for as_dir in /bin$PATH_SEPARATOR/usr/bin$PATH_SEPARATOR$PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. @@ -236,7 +240,6 @@ # Try only shells that exist, to save several forks. if { test -f "$as_shell" || test -f "$as_shell.exe"; } && { ("$as_shell") 2> /dev/null <<\_ASEOF -# Be Bourne compatible if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then emulate sh NULLCMD=: @@ -245,10 +248,12 @@ alias -g '${1+"$@"}'='"$@"' setopt NO_GLOB_SUBST else - case `(set -o) 2>/dev/null` in *posix*) set -o posix;; esac + case `(set -o) 2>/dev/null` in + *posix*) set -o posix ;; +esac + fi -BIN_SH=xpg4; export BIN_SH # for Tru64 -DUALCASE=1; export DUALCASE # for MKS sh + : _ASEOF @@ -256,7 +261,6 @@ CONFIG_SHELL=$as_shell as_have_required=yes if { "$as_shell" 2> /dev/null <<\_ASEOF -# Be Bourne compatible if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then emulate sh NULLCMD=: @@ -265,10 +269,12 @@ alias -g '${1+"$@"}'='"$@"' setopt NO_GLOB_SUBST else - case `(set -o) 2>/dev/null` in *posix*) set -o posix;; esac + case `(set -o) 2>/dev/null` in + *posix*) set -o posix ;; +esac + fi -BIN_SH=xpg4; export BIN_SH # for Tru64 -DUALCASE=1; export DUALCASE # for MKS sh + : (as_func_return () { @@ -515,19 +521,28 @@ as_mkdir_p=false fi -# Find out whether ``test -x'' works. Don't use a zero-byte file, as -# systems may use methods other than mode bits to determine executability. -cat >conf$$.file <<_ASEOF -#! /bin/sh -exit 0 -_ASEOF -chmod +x conf$$.file -if test -x conf$$.file >/dev/null 2>&1; then - as_executable_p="test -x" +if test -x / >/dev/null 2>&1; then + as_test_x='test -x' else - as_executable_p=: + if ls -dL / >/dev/null 2>&1; then + as_ls_L_option=L + else + as_ls_L_option= + fi + as_test_x=' + eval sh -c '\'' + if test -d "$1"; then + test -d "$1/."; + else + case $1 in + -*)set "./$1";; + esac; + case `ls -ld'$as_ls_L_option' "$1" 2>/dev/null` in + ???[sx]*):;;*)false;;esac;fi + '\'' sh + ' fi -rm -f conf$$.file +as_executable_p=$as_test_x # Sed expression to map a string onto a valid CPP name. as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'" @@ -568,36 +583,36 @@ # Factoring default headers for most tests. ac_includes_default="\ #include -#if HAVE_SYS_TYPES_H +#ifdef HAVE_SYS_TYPES_H # include #endif -#if HAVE_SYS_STAT_H +#ifdef HAVE_SYS_STAT_H # include #endif -#if STDC_HEADERS +#ifdef STDC_HEADERS # include # include #else -# if HAVE_STDLIB_H +# ifdef HAVE_STDLIB_H # include # endif #endif -#if HAVE_STRING_H -# if !STDC_HEADERS && HAVE_MEMORY_H +#ifdef HAVE_STRING_H +# if !defined STDC_HEADERS && defined HAVE_MEMORY_H # include # endif # include #endif -#if HAVE_STRINGS_H +#ifdef HAVE_STRINGS_H # include #endif -#if HAVE_INTTYPES_H +#ifdef HAVE_INTTYPES_H # include #endif -#if HAVE_STDINT_H +#ifdef HAVE_STDINT_H # include #endif -#if HAVE_UNISTD_H +#ifdef HAVE_UNISTD_H # include #endif" @@ -724,6 +739,7 @@ CC CFLAGS LDFLAGS +LIBS CPPFLAGS CPP' @@ -831,10 +847,10 @@ -disable-* | --disable-*) ac_feature=`expr "x$ac_option" : 'x-*disable-\(.*\)'` # Reject names that are not valid shell variable names. - expr "x$ac_feature" : ".*[^-_$as_cr_alnum]" >/dev/null && + expr "x$ac_feature" : ".*[^-._$as_cr_alnum]" >/dev/null && { echo "$as_me: error: invalid feature name: $ac_feature" >&2 { (exit 1); exit 1; }; } - ac_feature=`echo $ac_feature | sed 's/-/_/g'` + ac_feature=`echo $ac_feature | sed 's/[-.]/_/g'` eval enable_$ac_feature=no ;; -docdir | --docdir | --docdi | --doc | --do) @@ -850,10 +866,10 @@ -enable-* | --enable-*) ac_feature=`expr "x$ac_option" : 'x-*enable-\([^=]*\)'` # Reject names that are not valid shell variable names. - expr "x$ac_feature" : ".*[^-_$as_cr_alnum]" >/dev/null && + expr "x$ac_feature" : ".*[^-._$as_cr_alnum]" >/dev/null && { echo "$as_me: error: invalid feature name: $ac_feature" >&2 { (exit 1); exit 1; }; } - ac_feature=`echo $ac_feature | sed 's/-/_/g'` + ac_feature=`echo $ac_feature | sed 's/[-.]/_/g'` eval enable_$ac_feature=\$ac_optarg ;; -exec-prefix | --exec_prefix | --exec-prefix | --exec-prefi \ @@ -1047,19 +1063,19 @@ -with-* | --with-*) ac_package=`expr "x$ac_option" : 'x-*with-\([^=]*\)'` # Reject names that are not valid shell variable names. - expr "x$ac_package" : ".*[^-_$as_cr_alnum]" >/dev/null && + expr "x$ac_package" : ".*[^-._$as_cr_alnum]" >/dev/null && { echo "$as_me: error: invalid package name: $ac_package" >&2 { (exit 1); exit 1; }; } - ac_package=`echo $ac_package| sed 's/-/_/g'` + ac_package=`echo $ac_package | sed 's/[-.]/_/g'` eval with_$ac_package=\$ac_optarg ;; -without-* | --without-*) ac_package=`expr "x$ac_option" : 'x-*without-\(.*\)'` # Reject names that are not valid shell variable names. - expr "x$ac_package" : ".*[^-_$as_cr_alnum]" >/dev/null && + expr "x$ac_package" : ".*[^-._$as_cr_alnum]" >/dev/null && { echo "$as_me: error: invalid package name: $ac_package" >&2 { (exit 1); exit 1; }; } - ac_package=`echo $ac_package | sed 's/-/_/g'` + ac_package=`echo $ac_package | sed 's/[-.]/_/g'` eval with_$ac_package=no ;; --x) @@ -1339,6 +1355,7 @@ CFLAGS C compiler flags LDFLAGS linker flags, e.g. -L if you have libraries in a nonstandard directory + LIBS libraries to pass to the linker, e.g. -l CPPFLAGS C/C++/Objective C preprocessor flags, e.g. -I if you have headers in a nonstandard directory CPP C preprocessor @@ -1408,7 +1425,7 @@ if $ac_init_version; then cat <<\_ACEOF python configure 3.0 -generated by GNU Autoconf 2.60 +generated by GNU Autoconf 2.61 Copyright (C) 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006 Free Software Foundation, Inc. @@ -1422,7 +1439,7 @@ running configure, to aid debugging if configure makes a mistake. It was created by python $as_me 3.0, which was -generated by GNU Autoconf 2.60. Invocation command line was +generated by GNU Autoconf 2.61. Invocation command line was $ $0 $@ @@ -1986,7 +2003,12 @@ # On OpenBSD, select(2) is not available if _XOPEN_SOURCE is defined, # even though select is a POSIX function. Reported by J. Ribbens. # Reconfirmed for OpenBSD 3.3 by Zachary Hamm, for 3.4 by Jason Ish. - OpenBSD/2.* | OpenBSD/3.[0123456789]) + OpenBSD/2.* | OpenBSD/3.[0123456789] | OpenBSD/4.[0]) + define_xopen_source=no;; + # Defining _XOPEN_SOURCE on NetBSD version prior to the introduction of + # _NETBSD_SOURCE disables certain features (eg. setgroups). Reported by + # Marc Recht + NetBSD/1.5 | NetBSD/1.5.* | NetBSD/1.6 | NetBSD/1.6.* | NetBSD/1.6A-S) define_xopen_source=no;; # On Solaris 2.6, sys/wait.h is inconsistent in the usage # of union __?sigval. Reported by Stuart Bishop. @@ -2218,7 +2240,7 @@ IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; }; then + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_CC="${ac_tool_prefix}gcc" echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 @@ -2258,7 +2280,7 @@ IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; }; then + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_ac_ct_CC="gcc" echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 @@ -2315,7 +2337,7 @@ IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; }; then + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_CC="${ac_tool_prefix}cc" echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 @@ -2356,7 +2378,7 @@ IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; }; then + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then if test "$as_dir/$ac_word$ac_exec_ext" = "/usr/ucb/cc"; then ac_prog_rejected=yes continue @@ -2414,7 +2436,7 @@ IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; }; then + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_CC="$ac_tool_prefix$ac_prog" echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 @@ -2458,7 +2480,7 @@ IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; }; then + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_ac_ct_CC="$ac_prog" echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 @@ -2599,7 +2621,7 @@ # in a Makefile. We should not override ac_cv_exeext if it was cached, # so that the user can short-circuit this test for compilers unknown to # Autoconf. -for ac_file in $ac_files +for ac_file in $ac_files '' do test -f "$ac_file" || continue case $ac_file in @@ -2627,6 +2649,12 @@ test "$ac_cv_exeext" = no && ac_cv_exeext= else + ac_file='' +fi + +{ echo "$as_me:$LINENO: result: $ac_file" >&5 +echo "${ECHO_T}$ac_file" >&6; } +if test -z "$ac_file"; then echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 @@ -2638,8 +2666,6 @@ fi ac_exeext=$ac_cv_exeext -{ echo "$as_me:$LINENO: result: $ac_file" >&5 -echo "${ECHO_T}$ac_file" >&6; } # Check that the compiler produces executables we can run. If not, either # the compiler is broken, or we cross compile. @@ -2817,27 +2843,10 @@ rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then ac_compiler_gnu=yes else echo "$as_me: failed program was:" >&5 @@ -2892,27 +2901,10 @@ rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then ac_cv_prog_cc_g=yes else echo "$as_me: failed program was:" >&5 @@ -2947,27 +2939,10 @@ rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then : else echo "$as_me: failed program was:" >&5 @@ -3003,27 +2978,10 @@ rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then ac_cv_prog_cc_g=yes else echo "$as_me: failed program was:" >&5 @@ -3139,27 +3097,10 @@ rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then ac_cv_prog_cc_c89=$ac_arg else echo "$as_me: failed program was:" >&5 @@ -3250,7 +3191,7 @@ IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; }; then + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_path_CXX="$as_dir/$ac_word$ac_exec_ext" echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 @@ -3291,7 +3232,7 @@ IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; }; then + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_path_CXX="$as_dir/$ac_word$ac_exec_ext" echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 @@ -3340,7 +3281,7 @@ IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; }; then + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_CXX="$ac_prog" echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 @@ -3439,17 +3380,10 @@ rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } >/dev/null; then - if test -s conftest.err; then - ac_cpp_err=$ac_c_preproc_warn_flag - ac_cpp_err=$ac_cpp_err$ac_c_werror_flag - else - ac_cpp_err= - fi -else - ac_cpp_err=yes -fi -if test -z "$ac_cpp_err"; then + (exit $ac_status); } >/dev/null && { + test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || + test ! -s conftest.err + }; then : else echo "$as_me: failed program was:" >&5 @@ -3483,17 +3417,10 @@ rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } >/dev/null; then - if test -s conftest.err; then - ac_cpp_err=$ac_c_preproc_warn_flag - ac_cpp_err=$ac_cpp_err$ac_c_werror_flag - else - ac_cpp_err= - fi -else - ac_cpp_err=yes -fi -if test -z "$ac_cpp_err"; then + (exit $ac_status); } >/dev/null && { + test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || + test ! -s conftest.err + }; then # Broken: success on invalid input. continue else @@ -3558,17 +3485,10 @@ rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } >/dev/null; then - if test -s conftest.err; then - ac_cpp_err=$ac_c_preproc_warn_flag - ac_cpp_err=$ac_cpp_err$ac_c_werror_flag - else - ac_cpp_err= - fi -else - ac_cpp_err=yes -fi -if test -z "$ac_cpp_err"; then + (exit $ac_status); } >/dev/null && { + test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || + test ! -s conftest.err + }; then : else echo "$as_me: failed program was:" >&5 @@ -3602,17 +3522,10 @@ rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } >/dev/null; then - if test -s conftest.err; then - ac_cpp_err=$ac_c_preproc_warn_flag - ac_cpp_err=$ac_cpp_err$ac_c_werror_flag - else - ac_cpp_err= - fi -else - ac_cpp_err=yes -fi -if test -z "$ac_cpp_err"; then + (exit $ac_status); } >/dev/null && { + test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || + test ! -s conftest.err + }; then # Broken: success on invalid input. continue else @@ -3667,7 +3580,7 @@ for ac_prog in grep ggrep; do for ac_exec_ext in '' $ac_executable_extensions; do ac_path_GREP="$as_dir/$ac_prog$ac_exec_ext" - { test -f "$ac_path_GREP" && $as_executable_p "$ac_path_GREP"; } || continue + { test -f "$ac_path_GREP" && $as_test_x "$ac_path_GREP"; } || continue # Check for GNU ac_path_GREP and select it if it is found. # Check for GNU $ac_path_GREP case `"$ac_path_GREP" --version 2>&1` in @@ -3749,7 +3662,7 @@ for ac_prog in egrep; do for ac_exec_ext in '' $ac_executable_extensions; do ac_path_EGREP="$as_dir/$ac_prog$ac_exec_ext" - { test -f "$ac_path_EGREP" && $as_executable_p "$ac_path_EGREP"; } || continue + { test -f "$ac_path_EGREP" && $as_test_x "$ac_path_EGREP"; } || continue # Check for GNU ac_path_EGREP and select it if it is found. # Check for GNU $ac_path_EGREP case `"$ac_path_EGREP" --version 2>&1` in @@ -4159,7 +4072,7 @@ IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; }; then + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_RANLIB="${ac_tool_prefix}ranlib" echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 @@ -4199,7 +4112,7 @@ IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; }; then + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_ac_ct_RANLIB="ranlib" echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 @@ -4257,7 +4170,7 @@ IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; }; then + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_AR="$ac_prog" echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 @@ -4300,7 +4213,7 @@ IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; }; then + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_SVNVERSION="found" echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 @@ -4404,7 +4317,7 @@ # by default. for ac_prog in ginstall scoinst install; do for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_prog$ac_exec_ext" && $as_executable_p "$as_dir/$ac_prog$ac_exec_ext"; }; then + if { test -f "$as_dir/$ac_prog$ac_exec_ext" && $as_test_x "$as_dir/$ac_prog$ac_exec_ext"; }; then if test $ac_prog = install && grep dspmsg "$as_dir/$ac_prog$ac_exec_ext" >/dev/null 2>&1; then # AIX install. It has an incompatible calling convention. @@ -4785,6 +4698,67 @@ fi fi +# Check whether GCC supports PyArg_ParseTuple format +if test "$GCC" = "yes" +then + { echo "$as_me:$LINENO: checking whether gcc supports ParseTuple __format__" >&5 +echo $ECHO_N "checking whether gcc supports ParseTuple __format__... $ECHO_C" >&6; } + save_CFLAGS=$CFLAGS + CFLAGS="$CFLAGS -Werror" + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + + void f(char*,...)__attribute((format(PyArg_ParseTuple, 1, 2))); + +int +main () +{ + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_compile") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then + +cat >>confdefs.h <<\_ACEOF +#define HAVE_ATTRIBUTE_FORMAT_PARSETUPLE 1 +_ACEOF + + { echo "$as_me:$LINENO: result: yes" >&5 +echo "${ECHO_T}yes" >&6; } +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + { echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6; } + +fi + +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + CFLAGS=$save_CFLAGS +fi + # On some compilers, pthreads are available without further options # (e.g. MacOS X). On some of these systems, the compiler will not # complain if unaccepted options are passed (e.g. gcc on Mac OS X). @@ -5175,27 +5149,10 @@ rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then ac_cv_header_stdc=yes else echo "$as_me: failed program was:" >&5 @@ -5371,27 +5328,10 @@ rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then eval "$as_ac_Header=yes" else echo "$as_me: failed program was:" >&5 @@ -5463,10 +5403,11 @@ + for ac_header in asm/types.h conio.h curses.h direct.h dlfcn.h errno.h \ fcntl.h grp.h \ -shadow.h io.h langinfo.h libintl.h ncurses.h poll.h process.h pthread.h \ -signal.h stropts.h termios.h thread.h \ +io.h langinfo.h libintl.h ncurses.h poll.h process.h pthread.h \ +shadow.h signal.h stdint.h stropts.h termios.h thread.h \ unistd.h utime.h \ sys/audioio.h sys/bsdtty.h sys/file.h sys/loadavg.h sys/lock.h sys/mkdev.h \ sys/modem.h \ @@ -5512,27 +5453,10 @@ rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then ac_header_compiler=yes else echo "$as_me: failed program was:" >&5 @@ -5568,17 +5492,10 @@ rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } >/dev/null; then - if test -s conftest.err; then - ac_cpp_err=$ac_c_preproc_warn_flag - ac_cpp_err=$ac_cpp_err$ac_c_werror_flag - else - ac_cpp_err= - fi -else - ac_cpp_err=yes -fi -if test -z "$ac_cpp_err"; then + (exit $ac_status); } >/dev/null && { + test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || + test ! -s conftest.err + }; then ac_header_preproc=yes else echo "$as_me: failed program was:" >&5 @@ -5686,27 +5603,10 @@ rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then eval "$as_ac_Header=yes" else echo "$as_me: failed program was:" >&5 @@ -5779,27 +5679,11 @@ rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest$ac_exeext' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest$ac_exeext && + $as_test_x conftest$ac_exeext; then ac_cv_search_opendir=$ac_res else echo "$as_me: failed program was:" >&5 @@ -5808,7 +5692,7 @@ fi -rm -f core conftest.err conftest.$ac_objext \ +rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ conftest$ac_exeext if test "${ac_cv_search_opendir+set}" = set; then break @@ -5879,27 +5763,11 @@ rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest$ac_exeext' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest$ac_exeext && + $as_test_x conftest$ac_exeext; then ac_cv_search_opendir=$ac_res else echo "$as_me: failed program was:" >&5 @@ -5908,7 +5776,7 @@ fi -rm -f core conftest.err conftest.$ac_objext \ +rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ conftest$ac_exeext if test "${ac_cv_search_opendir+set}" = set; then break @@ -5965,27 +5833,11 @@ rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest$ac_exeext' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest$ac_exeext && + $as_test_x conftest$ac_exeext; then ac_cv_header_sys_types_h_makedev=yes else echo "$as_me: failed program was:" >&5 @@ -5994,7 +5846,7 @@ ac_cv_header_sys_types_h_makedev=no fi -rm -f core conftest.err conftest.$ac_objext \ +rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ conftest$ac_exeext conftest.$ac_ext fi @@ -6036,27 +5888,10 @@ rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then ac_header_compiler=yes else echo "$as_me: failed program was:" >&5 @@ -6092,17 +5927,10 @@ rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } >/dev/null; then - if test -s conftest.err; then - ac_cpp_err=$ac_c_preproc_warn_flag - ac_cpp_err=$ac_cpp_err$ac_c_werror_flag - else - ac_cpp_err= - fi -else - ac_cpp_err=yes -fi -if test -z "$ac_cpp_err"; then + (exit $ac_status); } >/dev/null && { + test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || + test ! -s conftest.err + }; then ac_header_preproc=yes else echo "$as_me: failed program was:" >&5 @@ -6201,27 +6029,10 @@ rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then ac_header_compiler=yes else echo "$as_me: failed program was:" >&5 @@ -6257,17 +6068,10 @@ rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } >/dev/null; then - if test -s conftest.err; then - ac_cpp_err=$ac_c_preproc_warn_flag - ac_cpp_err=$ac_cpp_err$ac_c_werror_flag - else - ac_cpp_err= - fi -else - ac_cpp_err=yes -fi -if test -z "$ac_cpp_err"; then + (exit $ac_status); } >/dev/null && { + test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || + test ! -s conftest.err + }; then ac_header_preproc=yes else echo "$as_me: failed program was:" >&5 @@ -6371,27 +6175,10 @@ rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then eval "$as_ac_Header=yes" else echo "$as_me: failed program was:" >&5 @@ -6455,27 +6242,10 @@ rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then eval "$as_ac_Header=yes" else echo "$as_me: failed program was:" >&5 @@ -6560,27 +6330,11 @@ rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest$ac_exeext' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest$ac_exeext && + $as_test_x conftest$ac_exeext; then ac_cv_has_makedev=yes else echo "$as_me: failed program was:" >&5 @@ -6589,7 +6343,7 @@ ac_cv_has_makedev=no fi -rm -f core conftest.err conftest.$ac_objext \ +rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ conftest$ac_exeext conftest.$ac_ext if test "$ac_cv_has_makedev" = "no"; then # we didn't link, try if _OSF_SOURCE will allow us to link @@ -6624,27 +6378,11 @@ rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest$ac_exeext' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest$ac_exeext && + $as_test_x conftest$ac_exeext; then ac_cv_has_makedev=yes else echo "$as_me: failed program was:" >&5 @@ -6653,7 +6391,7 @@ ac_cv_has_makedev=no fi -rm -f core conftest.err conftest.$ac_objext \ +rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ conftest$ac_exeext conftest.$ac_ext if test "$ac_cv_has_makedev" = "yes"; then @@ -6715,27 +6453,10 @@ rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then sol_lfs_bug=no else echo "$as_me: failed program was:" >&5 @@ -6811,27 +6532,10 @@ rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then ac_cv_type_mode_t=yes else echo "$as_me: failed program was:" >&5 @@ -6891,27 +6595,10 @@ rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then ac_cv_type_off_t=yes else echo "$as_me: failed program was:" >&5 @@ -6971,27 +6658,10 @@ rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then ac_cv_type_pid_t=yes else echo "$as_me: failed program was:" >&5 @@ -7049,27 +6719,10 @@ rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then ac_cv_type_signal=int else echo "$as_me: failed program was:" >&5 @@ -7125,27 +6778,10 @@ rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then ac_cv_type_size_t=yes else echo "$as_me: failed program was:" >&5 @@ -7243,27 +6879,10 @@ rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then ac_cv_type_ssize_t=yes else echo "$as_me: failed program was:" >&5 @@ -7324,27 +6943,10 @@ rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then ac_cv_type_int=yes else echo "$as_me: failed program was:" >&5 @@ -7358,16 +6960,15 @@ { echo "$as_me:$LINENO: result: $ac_cv_type_int" >&5 echo "${ECHO_T}$ac_cv_type_int" >&6; } +# The cast to long int works around a bug in the HP C Compiler +# version HP92453-01 B.11.11.23709.GP, which incorrectly rejects +# declarations like `int a3[[(sizeof (unsigned char)) >= 0]];'. +# This bug is HP SR number 8606223364. { echo "$as_me:$LINENO: checking size of int" >&5 echo $ECHO_N "checking size of int... $ECHO_C" >&6; } if test "${ac_cv_sizeof_int+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else - if test "$ac_cv_type_int" = yes; then - # The cast to long int works around a bug in the HP C Compiler - # version HP92453-01 B.11.11.23709.GP, which incorrectly rejects - # declarations like `int a3[[(sizeof (unsigned char)) >= 0]];'. - # This bug is HP SR number 8606223364. if test "$cross_compiling" = yes; then # Depending upon the size, compute the lo and hi bounds. cat >conftest.$ac_ext <<_ACEOF @@ -7377,7 +6978,7 @@ cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ $ac_includes_default - typedef int ac__type_sizeof_; + typedef int ac__type_sizeof_; int main () { @@ -7401,27 +7002,10 @@ rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then ac_lo=0 ac_mid=0 while :; do cat >conftest.$ac_ext <<_ACEOF @@ -7431,7 +7015,7 @@ cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ $ac_includes_default - typedef int ac__type_sizeof_; + typedef int ac__type_sizeof_; int main () { @@ -7455,27 +7039,10 @@ rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then ac_hi=$ac_mid; break else echo "$as_me: failed program was:" >&5 @@ -7502,7 +7069,7 @@ cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ $ac_includes_default - typedef int ac__type_sizeof_; + typedef int ac__type_sizeof_; int main () { @@ -7526,27 +7093,10 @@ rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then ac_hi=-1 ac_mid=-1 while :; do cat >conftest.$ac_ext <<_ACEOF @@ -7556,7 +7106,7 @@ cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ $ac_includes_default - typedef int ac__type_sizeof_; + typedef int ac__type_sizeof_; int main () { @@ -7580,27 +7130,10 @@ rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then ac_lo=$ac_mid; break else echo "$as_me: failed program was:" >&5 @@ -7637,7 +7170,7 @@ cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ $ac_includes_default - typedef int ac__type_sizeof_; + typedef int ac__type_sizeof_; int main () { @@ -7661,27 +7194,10 @@ rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then ac_hi=$ac_mid else echo "$as_me: failed program was:" >&5 @@ -7694,11 +7210,15 @@ done case $ac_lo in ?*) ac_cv_sizeof_int=$ac_lo;; -'') { { echo "$as_me:$LINENO: error: cannot compute sizeof (int) +'') if test "$ac_cv_type_int" = yes; then + { { echo "$as_me:$LINENO: error: cannot compute sizeof (int) See \`config.log' for more details." >&5 echo "$as_me: error: cannot compute sizeof (int) See \`config.log' for more details." >&2;} - { (exit 77); exit 77; }; } ;; + { (exit 77); exit 77; }; } + else + ac_cv_sizeof_int=0 + fi ;; esac else cat >conftest.$ac_ext <<_ACEOF @@ -7708,7 +7228,7 @@ cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ $ac_includes_default - typedef int ac__type_sizeof_; + typedef int ac__type_sizeof_; static long int longval () { return (long int) (sizeof (ac__type_sizeof_)); } static unsigned long int ulongval () { return (long int) (sizeof (ac__type_sizeof_)); } #include @@ -7767,21 +7287,25 @@ sed 's/^/| /' conftest.$ac_ext >&5 ( exit $ac_status ) -{ { echo "$as_me:$LINENO: error: cannot compute sizeof (int) +if test "$ac_cv_type_int" = yes; then + { { echo "$as_me:$LINENO: error: cannot compute sizeof (int) See \`config.log' for more details." >&5 echo "$as_me: error: cannot compute sizeof (int) See \`config.log' for more details." >&2;} { (exit 77); exit 77; }; } + else + ac_cv_sizeof_int=0 + fi fi rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext fi rm -f conftest.val -else - ac_cv_sizeof_int=0 -fi fi { echo "$as_me:$LINENO: result: $ac_cv_sizeof_int" >&5 echo "${ECHO_T}$ac_cv_sizeof_int" >&6; } + + + cat >>confdefs.h <<_ACEOF #define SIZEOF_INT $ac_cv_sizeof_int _ACEOF @@ -7824,27 +7348,10 @@ rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then ac_cv_type_long=yes else echo "$as_me: failed program was:" >&5 @@ -7858,16 +7365,15 @@ { echo "$as_me:$LINENO: result: $ac_cv_type_long" >&5 echo "${ECHO_T}$ac_cv_type_long" >&6; } +# The cast to long int works around a bug in the HP C Compiler +# version HP92453-01 B.11.11.23709.GP, which incorrectly rejects +# declarations like `int a3[[(sizeof (unsigned char)) >= 0]];'. +# This bug is HP SR number 8606223364. { echo "$as_me:$LINENO: checking size of long" >&5 echo $ECHO_N "checking size of long... $ECHO_C" >&6; } if test "${ac_cv_sizeof_long+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else - if test "$ac_cv_type_long" = yes; then - # The cast to long int works around a bug in the HP C Compiler - # version HP92453-01 B.11.11.23709.GP, which incorrectly rejects - # declarations like `int a3[[(sizeof (unsigned char)) >= 0]];'. - # This bug is HP SR number 8606223364. if test "$cross_compiling" = yes; then # Depending upon the size, compute the lo and hi bounds. cat >conftest.$ac_ext <<_ACEOF @@ -7877,7 +7383,7 @@ cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ $ac_includes_default - typedef long ac__type_sizeof_; + typedef long ac__type_sizeof_; int main () { @@ -7901,27 +7407,10 @@ rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then ac_lo=0 ac_mid=0 while :; do cat >conftest.$ac_ext <<_ACEOF @@ -7931,7 +7420,7 @@ cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ $ac_includes_default - typedef long ac__type_sizeof_; + typedef long ac__type_sizeof_; int main () { @@ -7955,27 +7444,10 @@ rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then ac_hi=$ac_mid; break else echo "$as_me: failed program was:" >&5 @@ -8002,7 +7474,7 @@ cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ $ac_includes_default - typedef long ac__type_sizeof_; + typedef long ac__type_sizeof_; int main () { @@ -8026,27 +7498,10 @@ rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then ac_hi=-1 ac_mid=-1 while :; do cat >conftest.$ac_ext <<_ACEOF @@ -8056,7 +7511,7 @@ cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ $ac_includes_default - typedef long ac__type_sizeof_; + typedef long ac__type_sizeof_; int main () { @@ -8080,27 +7535,10 @@ rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then ac_lo=$ac_mid; break else echo "$as_me: failed program was:" >&5 @@ -8137,7 +7575,7 @@ cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ $ac_includes_default - typedef long ac__type_sizeof_; + typedef long ac__type_sizeof_; int main () { @@ -8161,27 +7599,10 @@ rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then ac_hi=$ac_mid else echo "$as_me: failed program was:" >&5 @@ -8194,11 +7615,15 @@ done case $ac_lo in ?*) ac_cv_sizeof_long=$ac_lo;; -'') { { echo "$as_me:$LINENO: error: cannot compute sizeof (long) +'') if test "$ac_cv_type_long" = yes; then + { { echo "$as_me:$LINENO: error: cannot compute sizeof (long) See \`config.log' for more details." >&5 echo "$as_me: error: cannot compute sizeof (long) See \`config.log' for more details." >&2;} - { (exit 77); exit 77; }; } ;; + { (exit 77); exit 77; }; } + else + ac_cv_sizeof_long=0 + fi ;; esac else cat >conftest.$ac_ext <<_ACEOF @@ -8208,7 +7633,7 @@ cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ $ac_includes_default - typedef long ac__type_sizeof_; + typedef long ac__type_sizeof_; static long int longval () { return (long int) (sizeof (ac__type_sizeof_)); } static unsigned long int ulongval () { return (long int) (sizeof (ac__type_sizeof_)); } #include @@ -8267,21 +7692,25 @@ sed 's/^/| /' conftest.$ac_ext >&5 ( exit $ac_status ) -{ { echo "$as_me:$LINENO: error: cannot compute sizeof (long) +if test "$ac_cv_type_long" = yes; then + { { echo "$as_me:$LINENO: error: cannot compute sizeof (long) See \`config.log' for more details." >&5 echo "$as_me: error: cannot compute sizeof (long) See \`config.log' for more details." >&2;} { (exit 77); exit 77; }; } + else + ac_cv_sizeof_long=0 + fi fi rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext fi rm -f conftest.val -else - ac_cv_sizeof_long=0 -fi fi { echo "$as_me:$LINENO: result: $ac_cv_sizeof_long" >&5 echo "${ECHO_T}$ac_cv_sizeof_long" >&6; } + + + cat >>confdefs.h <<_ACEOF #define SIZEOF_LONG $ac_cv_sizeof_long _ACEOF @@ -8324,27 +7753,10 @@ rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then ac_cv_type_void_p=yes else echo "$as_me: failed program was:" >&5 @@ -8358,16 +7770,15 @@ { echo "$as_me:$LINENO: result: $ac_cv_type_void_p" >&5 echo "${ECHO_T}$ac_cv_type_void_p" >&6; } +# The cast to long int works around a bug in the HP C Compiler +# version HP92453-01 B.11.11.23709.GP, which incorrectly rejects +# declarations like `int a3[[(sizeof (unsigned char)) >= 0]];'. +# This bug is HP SR number 8606223364. { echo "$as_me:$LINENO: checking size of void *" >&5 echo $ECHO_N "checking size of void *... $ECHO_C" >&6; } if test "${ac_cv_sizeof_void_p+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else - if test "$ac_cv_type_void_p" = yes; then - # The cast to long int works around a bug in the HP C Compiler - # version HP92453-01 B.11.11.23709.GP, which incorrectly rejects - # declarations like `int a3[[(sizeof (unsigned char)) >= 0]];'. - # This bug is HP SR number 8606223364. if test "$cross_compiling" = yes; then # Depending upon the size, compute the lo and hi bounds. cat >conftest.$ac_ext <<_ACEOF @@ -8377,7 +7788,7 @@ cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ $ac_includes_default - typedef void * ac__type_sizeof_; + typedef void * ac__type_sizeof_; int main () { @@ -8401,27 +7812,10 @@ rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then ac_lo=0 ac_mid=0 while :; do cat >conftest.$ac_ext <<_ACEOF @@ -8431,7 +7825,7 @@ cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ $ac_includes_default - typedef void * ac__type_sizeof_; + typedef void * ac__type_sizeof_; int main () { @@ -8455,27 +7849,10 @@ rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then ac_hi=$ac_mid; break else echo "$as_me: failed program was:" >&5 @@ -8502,7 +7879,7 @@ cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ $ac_includes_default - typedef void * ac__type_sizeof_; + typedef void * ac__type_sizeof_; int main () { @@ -8526,27 +7903,10 @@ rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then ac_hi=-1 ac_mid=-1 while :; do cat >conftest.$ac_ext <<_ACEOF @@ -8556,7 +7916,7 @@ cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ $ac_includes_default - typedef void * ac__type_sizeof_; + typedef void * ac__type_sizeof_; int main () { @@ -8580,27 +7940,10 @@ rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then ac_lo=$ac_mid; break else echo "$as_me: failed program was:" >&5 @@ -8637,7 +7980,7 @@ cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ $ac_includes_default - typedef void * ac__type_sizeof_; + typedef void * ac__type_sizeof_; int main () { @@ -8661,27 +8004,10 @@ rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then ac_hi=$ac_mid else echo "$as_me: failed program was:" >&5 @@ -8694,11 +8020,15 @@ done case $ac_lo in ?*) ac_cv_sizeof_void_p=$ac_lo;; -'') { { echo "$as_me:$LINENO: error: cannot compute sizeof (void *) +'') if test "$ac_cv_type_void_p" = yes; then + { { echo "$as_me:$LINENO: error: cannot compute sizeof (void *) See \`config.log' for more details." >&5 echo "$as_me: error: cannot compute sizeof (void *) See \`config.log' for more details." >&2;} - { (exit 77); exit 77; }; } ;; + { (exit 77); exit 77; }; } + else + ac_cv_sizeof_void_p=0 + fi ;; esac else cat >conftest.$ac_ext <<_ACEOF @@ -8708,7 +8038,7 @@ cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ $ac_includes_default - typedef void * ac__type_sizeof_; + typedef void * ac__type_sizeof_; static long int longval () { return (long int) (sizeof (ac__type_sizeof_)); } static unsigned long int ulongval () { return (long int) (sizeof (ac__type_sizeof_)); } #include @@ -8767,21 +8097,25 @@ sed 's/^/| /' conftest.$ac_ext >&5 ( exit $ac_status ) -{ { echo "$as_me:$LINENO: error: cannot compute sizeof (void *) +if test "$ac_cv_type_void_p" = yes; then + { { echo "$as_me:$LINENO: error: cannot compute sizeof (void *) See \`config.log' for more details." >&5 echo "$as_me: error: cannot compute sizeof (void *) See \`config.log' for more details." >&2;} { (exit 77); exit 77; }; } + else + ac_cv_sizeof_void_p=0 + fi fi rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext fi rm -f conftest.val -else - ac_cv_sizeof_void_p=0 -fi fi { echo "$as_me:$LINENO: result: $ac_cv_sizeof_void_p" >&5 echo "${ECHO_T}$ac_cv_sizeof_void_p" >&6; } + + + cat >>confdefs.h <<_ACEOF #define SIZEOF_VOID_P $ac_cv_sizeof_void_p _ACEOF @@ -8824,27 +8158,10 @@ rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then ac_cv_type_short=yes else echo "$as_me: failed program was:" >&5 @@ -8858,16 +8175,15 @@ { echo "$as_me:$LINENO: result: $ac_cv_type_short" >&5 echo "${ECHO_T}$ac_cv_type_short" >&6; } +# The cast to long int works around a bug in the HP C Compiler +# version HP92453-01 B.11.11.23709.GP, which incorrectly rejects +# declarations like `int a3[[(sizeof (unsigned char)) >= 0]];'. +# This bug is HP SR number 8606223364. { echo "$as_me:$LINENO: checking size of short" >&5 echo $ECHO_N "checking size of short... $ECHO_C" >&6; } if test "${ac_cv_sizeof_short+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else - if test "$ac_cv_type_short" = yes; then - # The cast to long int works around a bug in the HP C Compiler - # version HP92453-01 B.11.11.23709.GP, which incorrectly rejects - # declarations like `int a3[[(sizeof (unsigned char)) >= 0]];'. - # This bug is HP SR number 8606223364. if test "$cross_compiling" = yes; then # Depending upon the size, compute the lo and hi bounds. cat >conftest.$ac_ext <<_ACEOF @@ -8877,7 +8193,7 @@ cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ $ac_includes_default - typedef short ac__type_sizeof_; + typedef short ac__type_sizeof_; int main () { @@ -8901,27 +8217,10 @@ rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then ac_lo=0 ac_mid=0 while :; do cat >conftest.$ac_ext <<_ACEOF @@ -8931,7 +8230,7 @@ cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ $ac_includes_default - typedef short ac__type_sizeof_; + typedef short ac__type_sizeof_; int main () { @@ -8955,27 +8254,10 @@ rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then ac_hi=$ac_mid; break else echo "$as_me: failed program was:" >&5 @@ -9002,7 +8284,7 @@ cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ $ac_includes_default - typedef short ac__type_sizeof_; + typedef short ac__type_sizeof_; int main () { @@ -9026,27 +8308,10 @@ rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then ac_hi=-1 ac_mid=-1 while :; do cat >conftest.$ac_ext <<_ACEOF @@ -9056,7 +8321,7 @@ cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ $ac_includes_default - typedef short ac__type_sizeof_; + typedef short ac__type_sizeof_; int main () { @@ -9080,27 +8345,10 @@ rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then ac_lo=$ac_mid; break else echo "$as_me: failed program was:" >&5 @@ -9137,7 +8385,7 @@ cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ $ac_includes_default - typedef short ac__type_sizeof_; + typedef short ac__type_sizeof_; int main () { @@ -9161,27 +8409,10 @@ rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then ac_hi=$ac_mid else echo "$as_me: failed program was:" >&5 @@ -9194,11 +8425,15 @@ done case $ac_lo in ?*) ac_cv_sizeof_short=$ac_lo;; -'') { { echo "$as_me:$LINENO: error: cannot compute sizeof (short) +'') if test "$ac_cv_type_short" = yes; then + { { echo "$as_me:$LINENO: error: cannot compute sizeof (short) See \`config.log' for more details." >&5 echo "$as_me: error: cannot compute sizeof (short) See \`config.log' for more details." >&2;} - { (exit 77); exit 77; }; } ;; + { (exit 77); exit 77; }; } + else + ac_cv_sizeof_short=0 + fi ;; esac else cat >conftest.$ac_ext <<_ACEOF @@ -9208,7 +8443,7 @@ cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ $ac_includes_default - typedef short ac__type_sizeof_; + typedef short ac__type_sizeof_; static long int longval () { return (long int) (sizeof (ac__type_sizeof_)); } static unsigned long int ulongval () { return (long int) (sizeof (ac__type_sizeof_)); } #include @@ -9267,21 +8502,25 @@ sed 's/^/| /' conftest.$ac_ext >&5 ( exit $ac_status ) -{ { echo "$as_me:$LINENO: error: cannot compute sizeof (short) +if test "$ac_cv_type_short" = yes; then + { { echo "$as_me:$LINENO: error: cannot compute sizeof (short) See \`config.log' for more details." >&5 echo "$as_me: error: cannot compute sizeof (short) See \`config.log' for more details." >&2;} { (exit 77); exit 77; }; } + else + ac_cv_sizeof_short=0 + fi fi rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext fi rm -f conftest.val -else - ac_cv_sizeof_short=0 -fi fi { echo "$as_me:$LINENO: result: $ac_cv_sizeof_short" >&5 echo "${ECHO_T}$ac_cv_sizeof_short" >&6; } + + + cat >>confdefs.h <<_ACEOF #define SIZEOF_SHORT $ac_cv_sizeof_short _ACEOF @@ -9324,27 +8563,10 @@ rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then ac_cv_type_float=yes else echo "$as_me: failed program was:" >&5 @@ -9358,16 +8580,15 @@ { echo "$as_me:$LINENO: result: $ac_cv_type_float" >&5 echo "${ECHO_T}$ac_cv_type_float" >&6; } +# The cast to long int works around a bug in the HP C Compiler +# version HP92453-01 B.11.11.23709.GP, which incorrectly rejects +# declarations like `int a3[[(sizeof (unsigned char)) >= 0]];'. +# This bug is HP SR number 8606223364. { echo "$as_me:$LINENO: checking size of float" >&5 echo $ECHO_N "checking size of float... $ECHO_C" >&6; } if test "${ac_cv_sizeof_float+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else - if test "$ac_cv_type_float" = yes; then - # The cast to long int works around a bug in the HP C Compiler - # version HP92453-01 B.11.11.23709.GP, which incorrectly rejects - # declarations like `int a3[[(sizeof (unsigned char)) >= 0]];'. - # This bug is HP SR number 8606223364. if test "$cross_compiling" = yes; then # Depending upon the size, compute the lo and hi bounds. cat >conftest.$ac_ext <<_ACEOF @@ -9377,7 +8598,7 @@ cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ $ac_includes_default - typedef float ac__type_sizeof_; + typedef float ac__type_sizeof_; int main () { @@ -9401,27 +8622,10 @@ rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then ac_lo=0 ac_mid=0 while :; do cat >conftest.$ac_ext <<_ACEOF @@ -9431,7 +8635,7 @@ cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ $ac_includes_default - typedef float ac__type_sizeof_; + typedef float ac__type_sizeof_; int main () { @@ -9455,27 +8659,10 @@ rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then ac_hi=$ac_mid; break else echo "$as_me: failed program was:" >&5 @@ -9502,7 +8689,7 @@ cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ $ac_includes_default - typedef float ac__type_sizeof_; + typedef float ac__type_sizeof_; int main () { @@ -9526,27 +8713,10 @@ rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then ac_hi=-1 ac_mid=-1 while :; do cat >conftest.$ac_ext <<_ACEOF @@ -9556,7 +8726,7 @@ cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ $ac_includes_default - typedef float ac__type_sizeof_; + typedef float ac__type_sizeof_; int main () { @@ -9580,27 +8750,10 @@ rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then ac_lo=$ac_mid; break else echo "$as_me: failed program was:" >&5 @@ -9637,7 +8790,7 @@ cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ $ac_includes_default - typedef float ac__type_sizeof_; + typedef float ac__type_sizeof_; int main () { @@ -9661,27 +8814,10 @@ rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then ac_hi=$ac_mid else echo "$as_me: failed program was:" >&5 @@ -9694,11 +8830,15 @@ done case $ac_lo in ?*) ac_cv_sizeof_float=$ac_lo;; -'') { { echo "$as_me:$LINENO: error: cannot compute sizeof (float) +'') if test "$ac_cv_type_float" = yes; then + { { echo "$as_me:$LINENO: error: cannot compute sizeof (float) See \`config.log' for more details." >&5 echo "$as_me: error: cannot compute sizeof (float) See \`config.log' for more details." >&2;} - { (exit 77); exit 77; }; } ;; + { (exit 77); exit 77; }; } + else + ac_cv_sizeof_float=0 + fi ;; esac else cat >conftest.$ac_ext <<_ACEOF @@ -9708,7 +8848,7 @@ cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ $ac_includes_default - typedef float ac__type_sizeof_; + typedef float ac__type_sizeof_; static long int longval () { return (long int) (sizeof (ac__type_sizeof_)); } static unsigned long int ulongval () { return (long int) (sizeof (ac__type_sizeof_)); } #include @@ -9767,21 +8907,25 @@ sed 's/^/| /' conftest.$ac_ext >&5 ( exit $ac_status ) -{ { echo "$as_me:$LINENO: error: cannot compute sizeof (float) +if test "$ac_cv_type_float" = yes; then + { { echo "$as_me:$LINENO: error: cannot compute sizeof (float) See \`config.log' for more details." >&5 echo "$as_me: error: cannot compute sizeof (float) See \`config.log' for more details." >&2;} { (exit 77); exit 77; }; } + else + ac_cv_sizeof_float=0 + fi fi rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext fi rm -f conftest.val -else - ac_cv_sizeof_float=0 -fi fi { echo "$as_me:$LINENO: result: $ac_cv_sizeof_float" >&5 echo "${ECHO_T}$ac_cv_sizeof_float" >&6; } + + + cat >>confdefs.h <<_ACEOF #define SIZEOF_FLOAT $ac_cv_sizeof_float _ACEOF @@ -9824,27 +8968,10 @@ rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then ac_cv_type_double=yes else echo "$as_me: failed program was:" >&5 @@ -9858,16 +8985,15 @@ { echo "$as_me:$LINENO: result: $ac_cv_type_double" >&5 echo "${ECHO_T}$ac_cv_type_double" >&6; } +# The cast to long int works around a bug in the HP C Compiler +# version HP92453-01 B.11.11.23709.GP, which incorrectly rejects +# declarations like `int a3[[(sizeof (unsigned char)) >= 0]];'. +# This bug is HP SR number 8606223364. { echo "$as_me:$LINENO: checking size of double" >&5 echo $ECHO_N "checking size of double... $ECHO_C" >&6; } if test "${ac_cv_sizeof_double+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else - if test "$ac_cv_type_double" = yes; then - # The cast to long int works around a bug in the HP C Compiler - # version HP92453-01 B.11.11.23709.GP, which incorrectly rejects - # declarations like `int a3[[(sizeof (unsigned char)) >= 0]];'. - # This bug is HP SR number 8606223364. if test "$cross_compiling" = yes; then # Depending upon the size, compute the lo and hi bounds. cat >conftest.$ac_ext <<_ACEOF @@ -9877,7 +9003,7 @@ cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ $ac_includes_default - typedef double ac__type_sizeof_; + typedef double ac__type_sizeof_; int main () { @@ -9901,27 +9027,10 @@ rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then ac_lo=0 ac_mid=0 while :; do cat >conftest.$ac_ext <<_ACEOF @@ -9931,7 +9040,7 @@ cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ $ac_includes_default - typedef double ac__type_sizeof_; + typedef double ac__type_sizeof_; int main () { @@ -9955,27 +9064,10 @@ rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then ac_hi=$ac_mid; break else echo "$as_me: failed program was:" >&5 @@ -10002,7 +9094,7 @@ cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ $ac_includes_default - typedef double ac__type_sizeof_; + typedef double ac__type_sizeof_; int main () { @@ -10026,27 +9118,10 @@ rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then ac_hi=-1 ac_mid=-1 while :; do cat >conftest.$ac_ext <<_ACEOF @@ -10056,7 +9131,7 @@ cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ $ac_includes_default - typedef double ac__type_sizeof_; + typedef double ac__type_sizeof_; int main () { @@ -10080,27 +9155,10 @@ rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then ac_lo=$ac_mid; break else echo "$as_me: failed program was:" >&5 @@ -10137,7 +9195,7 @@ cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ $ac_includes_default - typedef double ac__type_sizeof_; + typedef double ac__type_sizeof_; int main () { @@ -10161,27 +9219,10 @@ rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then ac_hi=$ac_mid else echo "$as_me: failed program was:" >&5 @@ -10194,11 +9235,15 @@ done case $ac_lo in ?*) ac_cv_sizeof_double=$ac_lo;; -'') { { echo "$as_me:$LINENO: error: cannot compute sizeof (double) +'') if test "$ac_cv_type_double" = yes; then + { { echo "$as_me:$LINENO: error: cannot compute sizeof (double) See \`config.log' for more details." >&5 echo "$as_me: error: cannot compute sizeof (double) See \`config.log' for more details." >&2;} - { (exit 77); exit 77; }; } ;; + { (exit 77); exit 77; }; } + else + ac_cv_sizeof_double=0 + fi ;; esac else cat >conftest.$ac_ext <<_ACEOF @@ -10208,7 +9253,7 @@ cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ $ac_includes_default - typedef double ac__type_sizeof_; + typedef double ac__type_sizeof_; static long int longval () { return (long int) (sizeof (ac__type_sizeof_)); } static unsigned long int ulongval () { return (long int) (sizeof (ac__type_sizeof_)); } #include @@ -10267,21 +9312,25 @@ sed 's/^/| /' conftest.$ac_ext >&5 ( exit $ac_status ) -{ { echo "$as_me:$LINENO: error: cannot compute sizeof (double) +if test "$ac_cv_type_double" = yes; then + { { echo "$as_me:$LINENO: error: cannot compute sizeof (double) See \`config.log' for more details." >&5 echo "$as_me: error: cannot compute sizeof (double) See \`config.log' for more details." >&2;} { (exit 77); exit 77; }; } + else + ac_cv_sizeof_double=0 + fi fi rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext fi rm -f conftest.val -else - ac_cv_sizeof_double=0 -fi fi { echo "$as_me:$LINENO: result: $ac_cv_sizeof_double" >&5 echo "${ECHO_T}$ac_cv_sizeof_double" >&6; } + + + cat >>confdefs.h <<_ACEOF #define SIZEOF_DOUBLE $ac_cv_sizeof_double _ACEOF @@ -10324,27 +9373,10 @@ rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then ac_cv_type_fpos_t=yes else echo "$as_me: failed program was:" >&5 @@ -10358,16 +9390,15 @@ { echo "$as_me:$LINENO: result: $ac_cv_type_fpos_t" >&5 echo "${ECHO_T}$ac_cv_type_fpos_t" >&6; } +# The cast to long int works around a bug in the HP C Compiler +# version HP92453-01 B.11.11.23709.GP, which incorrectly rejects +# declarations like `int a3[[(sizeof (unsigned char)) >= 0]];'. +# This bug is HP SR number 8606223364. { echo "$as_me:$LINENO: checking size of fpos_t" >&5 echo $ECHO_N "checking size of fpos_t... $ECHO_C" >&6; } if test "${ac_cv_sizeof_fpos_t+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else - if test "$ac_cv_type_fpos_t" = yes; then - # The cast to long int works around a bug in the HP C Compiler - # version HP92453-01 B.11.11.23709.GP, which incorrectly rejects - # declarations like `int a3[[(sizeof (unsigned char)) >= 0]];'. - # This bug is HP SR number 8606223364. if test "$cross_compiling" = yes; then # Depending upon the size, compute the lo and hi bounds. cat >conftest.$ac_ext <<_ACEOF @@ -10377,7 +9408,7 @@ cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ $ac_includes_default - typedef fpos_t ac__type_sizeof_; + typedef fpos_t ac__type_sizeof_; int main () { @@ -10401,27 +9432,10 @@ rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then ac_lo=0 ac_mid=0 while :; do cat >conftest.$ac_ext <<_ACEOF @@ -10431,7 +9445,7 @@ cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ $ac_includes_default - typedef fpos_t ac__type_sizeof_; + typedef fpos_t ac__type_sizeof_; int main () { @@ -10455,27 +9469,10 @@ rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then ac_hi=$ac_mid; break else echo "$as_me: failed program was:" >&5 @@ -10502,7 +9499,7 @@ cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ $ac_includes_default - typedef fpos_t ac__type_sizeof_; + typedef fpos_t ac__type_sizeof_; int main () { @@ -10526,27 +9523,10 @@ rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then ac_hi=-1 ac_mid=-1 while :; do cat >conftest.$ac_ext <<_ACEOF @@ -10556,7 +9536,7 @@ cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ $ac_includes_default - typedef fpos_t ac__type_sizeof_; + typedef fpos_t ac__type_sizeof_; int main () { @@ -10580,27 +9560,10 @@ rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then ac_lo=$ac_mid; break else echo "$as_me: failed program was:" >&5 @@ -10637,7 +9600,7 @@ cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ $ac_includes_default - typedef fpos_t ac__type_sizeof_; + typedef fpos_t ac__type_sizeof_; int main () { @@ -10661,27 +9624,10 @@ rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then ac_hi=$ac_mid else echo "$as_me: failed program was:" >&5 @@ -10694,11 +9640,15 @@ done case $ac_lo in ?*) ac_cv_sizeof_fpos_t=$ac_lo;; -'') { { echo "$as_me:$LINENO: error: cannot compute sizeof (fpos_t) +'') if test "$ac_cv_type_fpos_t" = yes; then + { { echo "$as_me:$LINENO: error: cannot compute sizeof (fpos_t) See \`config.log' for more details." >&5 echo "$as_me: error: cannot compute sizeof (fpos_t) See \`config.log' for more details." >&2;} - { (exit 77); exit 77; }; } ;; + { (exit 77); exit 77; }; } + else + ac_cv_sizeof_fpos_t=0 + fi ;; esac else cat >conftest.$ac_ext <<_ACEOF @@ -10708,7 +9658,7 @@ cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ $ac_includes_default - typedef fpos_t ac__type_sizeof_; + typedef fpos_t ac__type_sizeof_; static long int longval () { return (long int) (sizeof (ac__type_sizeof_)); } static unsigned long int ulongval () { return (long int) (sizeof (ac__type_sizeof_)); } #include @@ -10767,21 +9717,25 @@ sed 's/^/| /' conftest.$ac_ext >&5 ( exit $ac_status ) -{ { echo "$as_me:$LINENO: error: cannot compute sizeof (fpos_t) +if test "$ac_cv_type_fpos_t" = yes; then + { { echo "$as_me:$LINENO: error: cannot compute sizeof (fpos_t) See \`config.log' for more details." >&5 echo "$as_me: error: cannot compute sizeof (fpos_t) See \`config.log' for more details." >&2;} { (exit 77); exit 77; }; } + else + ac_cv_sizeof_fpos_t=0 + fi fi rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext fi rm -f conftest.val -else - ac_cv_sizeof_fpos_t=0 -fi fi { echo "$as_me:$LINENO: result: $ac_cv_sizeof_fpos_t" >&5 echo "${ECHO_T}$ac_cv_sizeof_fpos_t" >&6; } + + + cat >>confdefs.h <<_ACEOF #define SIZEOF_FPOS_T $ac_cv_sizeof_fpos_t _ACEOF @@ -10824,27 +9778,10 @@ rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then ac_cv_type_size_t=yes else echo "$as_me: failed program was:" >&5 @@ -10858,16 +9795,15 @@ { echo "$as_me:$LINENO: result: $ac_cv_type_size_t" >&5 echo "${ECHO_T}$ac_cv_type_size_t" >&6; } +# The cast to long int works around a bug in the HP C Compiler +# version HP92453-01 B.11.11.23709.GP, which incorrectly rejects +# declarations like `int a3[[(sizeof (unsigned char)) >= 0]];'. +# This bug is HP SR number 8606223364. { echo "$as_me:$LINENO: checking size of size_t" >&5 echo $ECHO_N "checking size of size_t... $ECHO_C" >&6; } if test "${ac_cv_sizeof_size_t+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else - if test "$ac_cv_type_size_t" = yes; then - # The cast to long int works around a bug in the HP C Compiler - # version HP92453-01 B.11.11.23709.GP, which incorrectly rejects - # declarations like `int a3[[(sizeof (unsigned char)) >= 0]];'. - # This bug is HP SR number 8606223364. if test "$cross_compiling" = yes; then # Depending upon the size, compute the lo and hi bounds. cat >conftest.$ac_ext <<_ACEOF @@ -10877,7 +9813,7 @@ cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ $ac_includes_default - typedef size_t ac__type_sizeof_; + typedef size_t ac__type_sizeof_; int main () { @@ -10901,27 +9837,10 @@ rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then ac_lo=0 ac_mid=0 while :; do cat >conftest.$ac_ext <<_ACEOF @@ -10931,7 +9850,7 @@ cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ $ac_includes_default - typedef size_t ac__type_sizeof_; + typedef size_t ac__type_sizeof_; int main () { @@ -10955,27 +9874,10 @@ rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then ac_hi=$ac_mid; break else echo "$as_me: failed program was:" >&5 @@ -11002,7 +9904,7 @@ cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ $ac_includes_default - typedef size_t ac__type_sizeof_; + typedef size_t ac__type_sizeof_; int main () { @@ -11026,27 +9928,10 @@ rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then ac_hi=-1 ac_mid=-1 while :; do cat >conftest.$ac_ext <<_ACEOF @@ -11056,7 +9941,7 @@ cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ $ac_includes_default - typedef size_t ac__type_sizeof_; + typedef size_t ac__type_sizeof_; int main () { @@ -11080,27 +9965,10 @@ rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then ac_lo=$ac_mid; break else echo "$as_me: failed program was:" >&5 @@ -11137,7 +10005,7 @@ cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ $ac_includes_default - typedef size_t ac__type_sizeof_; + typedef size_t ac__type_sizeof_; int main () { @@ -11161,27 +10029,10 @@ rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then ac_hi=$ac_mid else echo "$as_me: failed program was:" >&5 @@ -11194,11 +10045,15 @@ done case $ac_lo in ?*) ac_cv_sizeof_size_t=$ac_lo;; -'') { { echo "$as_me:$LINENO: error: cannot compute sizeof (size_t) +'') if test "$ac_cv_type_size_t" = yes; then + { { echo "$as_me:$LINENO: error: cannot compute sizeof (size_t) See \`config.log' for more details." >&5 echo "$as_me: error: cannot compute sizeof (size_t) See \`config.log' for more details." >&2;} - { (exit 77); exit 77; }; } ;; + { (exit 77); exit 77; }; } + else + ac_cv_sizeof_size_t=0 + fi ;; esac else cat >conftest.$ac_ext <<_ACEOF @@ -11208,7 +10063,7 @@ cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ $ac_includes_default - typedef size_t ac__type_sizeof_; + typedef size_t ac__type_sizeof_; static long int longval () { return (long int) (sizeof (ac__type_sizeof_)); } static unsigned long int ulongval () { return (long int) (sizeof (ac__type_sizeof_)); } #include @@ -11267,21 +10122,25 @@ sed 's/^/| /' conftest.$ac_ext >&5 ( exit $ac_status ) -{ { echo "$as_me:$LINENO: error: cannot compute sizeof (size_t) +if test "$ac_cv_type_size_t" = yes; then + { { echo "$as_me:$LINENO: error: cannot compute sizeof (size_t) See \`config.log' for more details." >&5 echo "$as_me: error: cannot compute sizeof (size_t) See \`config.log' for more details." >&2;} { (exit 77); exit 77; }; } + else + ac_cv_sizeof_size_t=0 + fi fi rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext fi rm -f conftest.val -else - ac_cv_sizeof_size_t=0 -fi fi { echo "$as_me:$LINENO: result: $ac_cv_sizeof_size_t" >&5 echo "${ECHO_T}$ac_cv_sizeof_size_t" >&6; } + + + cat >>confdefs.h <<_ACEOF #define SIZEOF_SIZE_T $ac_cv_sizeof_size_t _ACEOF @@ -11319,27 +10178,10 @@ rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then cat >>confdefs.h <<\_ACEOF @@ -11396,27 +10238,10 @@ rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then ac_cv_type_long_long=yes else echo "$as_me: failed program was:" >&5 @@ -11430,16 +10255,15 @@ { echo "$as_me:$LINENO: result: $ac_cv_type_long_long" >&5 echo "${ECHO_T}$ac_cv_type_long_long" >&6; } +# The cast to long int works around a bug in the HP C Compiler +# version HP92453-01 B.11.11.23709.GP, which incorrectly rejects +# declarations like `int a3[[(sizeof (unsigned char)) >= 0]];'. +# This bug is HP SR number 8606223364. { echo "$as_me:$LINENO: checking size of long long" >&5 echo $ECHO_N "checking size of long long... $ECHO_C" >&6; } if test "${ac_cv_sizeof_long_long+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else - if test "$ac_cv_type_long_long" = yes; then - # The cast to long int works around a bug in the HP C Compiler - # version HP92453-01 B.11.11.23709.GP, which incorrectly rejects - # declarations like `int a3[[(sizeof (unsigned char)) >= 0]];'. - # This bug is HP SR number 8606223364. if test "$cross_compiling" = yes; then # Depending upon the size, compute the lo and hi bounds. cat >conftest.$ac_ext <<_ACEOF @@ -11449,7 +10273,7 @@ cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ $ac_includes_default - typedef long long ac__type_sizeof_; + typedef long long ac__type_sizeof_; int main () { @@ -11473,27 +10297,10 @@ rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then ac_lo=0 ac_mid=0 while :; do cat >conftest.$ac_ext <<_ACEOF @@ -11503,7 +10310,7 @@ cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ $ac_includes_default - typedef long long ac__type_sizeof_; + typedef long long ac__type_sizeof_; int main () { @@ -11527,27 +10334,10 @@ rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then ac_hi=$ac_mid; break else echo "$as_me: failed program was:" >&5 @@ -11574,7 +10364,7 @@ cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ $ac_includes_default - typedef long long ac__type_sizeof_; + typedef long long ac__type_sizeof_; int main () { @@ -11598,27 +10388,10 @@ rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then ac_hi=-1 ac_mid=-1 while :; do cat >conftest.$ac_ext <<_ACEOF @@ -11628,7 +10401,7 @@ cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ $ac_includes_default - typedef long long ac__type_sizeof_; + typedef long long ac__type_sizeof_; int main () { @@ -11652,27 +10425,10 @@ rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then ac_lo=$ac_mid; break else echo "$as_me: failed program was:" >&5 @@ -11709,7 +10465,7 @@ cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ $ac_includes_default - typedef long long ac__type_sizeof_; + typedef long long ac__type_sizeof_; int main () { @@ -11733,27 +10489,10 @@ rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then ac_hi=$ac_mid else echo "$as_me: failed program was:" >&5 @@ -11766,11 +10505,15 @@ done case $ac_lo in ?*) ac_cv_sizeof_long_long=$ac_lo;; -'') { { echo "$as_me:$LINENO: error: cannot compute sizeof (long long) +'') if test "$ac_cv_type_long_long" = yes; then + { { echo "$as_me:$LINENO: error: cannot compute sizeof (long long) See \`config.log' for more details." >&5 echo "$as_me: error: cannot compute sizeof (long long) See \`config.log' for more details." >&2;} - { (exit 77); exit 77; }; } ;; + { (exit 77); exit 77; }; } + else + ac_cv_sizeof_long_long=0 + fi ;; esac else cat >conftest.$ac_ext <<_ACEOF @@ -11780,7 +10523,7 @@ cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ $ac_includes_default - typedef long long ac__type_sizeof_; + typedef long long ac__type_sizeof_; static long int longval () { return (long int) (sizeof (ac__type_sizeof_)); } static unsigned long int ulongval () { return (long int) (sizeof (ac__type_sizeof_)); } #include @@ -11839,21 +10582,25 @@ sed 's/^/| /' conftest.$ac_ext >&5 ( exit $ac_status ) -{ { echo "$as_me:$LINENO: error: cannot compute sizeof (long long) +if test "$ac_cv_type_long_long" = yes; then + { { echo "$as_me:$LINENO: error: cannot compute sizeof (long long) See \`config.log' for more details." >&5 echo "$as_me: error: cannot compute sizeof (long long) See \`config.log' for more details." >&2;} { (exit 77); exit 77; }; } + else + ac_cv_sizeof_long_long=0 + fi fi rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext fi rm -f conftest.val -else - ac_cv_sizeof_long_long=0 -fi fi { echo "$as_me:$LINENO: result: $ac_cv_sizeof_long_long" >&5 echo "${ECHO_T}$ac_cv_sizeof_long_long" >&6; } + + + cat >>confdefs.h <<_ACEOF #define SIZEOF_LONG_LONG $ac_cv_sizeof_long_long _ACEOF @@ -11861,20 +10608,29 @@ fi -{ echo "$as_me:$LINENO: checking for uintptr_t support" >&5 -echo $ECHO_N "checking for uintptr_t support... $ECHO_C" >&6; } -have_uintptr_t=no -cat >conftest.$ac_ext <<_ACEOF +{ echo "$as_me:$LINENO: checking for uintptr_t" >&5 +echo $ECHO_N "checking for uintptr_t... $ECHO_C" >&6; } +if test "${ac_cv_type_uintptr_t+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ +#ifdef HAVE_STDINT_H + #include + #endif +typedef uintptr_t ac__type_new_; int main () { -uintptr_t x; x = (uintptr_t)0; +if ((ac__type_new_ *) 0) + return 0; +if (sizeof (ac__type_new_)) + return 0; ; return 0; } @@ -11892,46 +10648,28 @@ rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then - - -cat >>confdefs.h <<\_ACEOF -#define HAVE_UINTPTR_T 1 -_ACEOF - - have_uintptr_t=yes - + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then + ac_cv_type_uintptr_t=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 - + ac_cv_type_uintptr_t=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext -{ echo "$as_me:$LINENO: result: $have_uintptr_t" >&5 -echo "${ECHO_T}$have_uintptr_t" >&6; } -if test "$have_uintptr_t" = yes ; then +fi +{ echo "$as_me:$LINENO: result: $ac_cv_type_uintptr_t" >&5 +echo "${ECHO_T}$ac_cv_type_uintptr_t" >&6; } +if test $ac_cv_type_uintptr_t = yes; then + +cat >>confdefs.h <<_ACEOF +#define HAVE_UINTPTR_T 1 +_ACEOF + { echo "$as_me:$LINENO: checking for uintptr_t" >&5 echo $ECHO_N "checking for uintptr_t... $ECHO_C" >&6; } if test "${ac_cv_type_uintptr_t+set}" = set; then @@ -11969,27 +10707,10 @@ rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then ac_cv_type_uintptr_t=yes else echo "$as_me: failed program was:" >&5 @@ -12003,16 +10724,15 @@ { echo "$as_me:$LINENO: result: $ac_cv_type_uintptr_t" >&5 echo "${ECHO_T}$ac_cv_type_uintptr_t" >&6; } +# The cast to long int works around a bug in the HP C Compiler +# version HP92453-01 B.11.11.23709.GP, which incorrectly rejects +# declarations like `int a3[[(sizeof (unsigned char)) >= 0]];'. +# This bug is HP SR number 8606223364. { echo "$as_me:$LINENO: checking size of uintptr_t" >&5 echo $ECHO_N "checking size of uintptr_t... $ECHO_C" >&6; } if test "${ac_cv_sizeof_uintptr_t+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else - if test "$ac_cv_type_uintptr_t" = yes; then - # The cast to long int works around a bug in the HP C Compiler - # version HP92453-01 B.11.11.23709.GP, which incorrectly rejects - # declarations like `int a3[[(sizeof (unsigned char)) >= 0]];'. - # This bug is HP SR number 8606223364. if test "$cross_compiling" = yes; then # Depending upon the size, compute the lo and hi bounds. cat >conftest.$ac_ext <<_ACEOF @@ -12022,7 +10742,7 @@ cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ $ac_includes_default - typedef uintptr_t ac__type_sizeof_; + typedef uintptr_t ac__type_sizeof_; int main () { @@ -12046,27 +10766,10 @@ rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then ac_lo=0 ac_mid=0 while :; do cat >conftest.$ac_ext <<_ACEOF @@ -12076,7 +10779,7 @@ cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ $ac_includes_default - typedef uintptr_t ac__type_sizeof_; + typedef uintptr_t ac__type_sizeof_; int main () { @@ -12100,27 +10803,10 @@ rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then ac_hi=$ac_mid; break else echo "$as_me: failed program was:" >&5 @@ -12147,7 +10833,7 @@ cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ $ac_includes_default - typedef uintptr_t ac__type_sizeof_; + typedef uintptr_t ac__type_sizeof_; int main () { @@ -12171,27 +10857,10 @@ rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then ac_hi=-1 ac_mid=-1 while :; do cat >conftest.$ac_ext <<_ACEOF @@ -12201,7 +10870,7 @@ cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ $ac_includes_default - typedef uintptr_t ac__type_sizeof_; + typedef uintptr_t ac__type_sizeof_; int main () { @@ -12225,27 +10894,10 @@ rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then ac_lo=$ac_mid; break else echo "$as_me: failed program was:" >&5 @@ -12282,7 +10934,7 @@ cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ $ac_includes_default - typedef uintptr_t ac__type_sizeof_; + typedef uintptr_t ac__type_sizeof_; int main () { @@ -12306,27 +10958,10 @@ rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then ac_hi=$ac_mid else echo "$as_me: failed program was:" >&5 @@ -12339,11 +10974,15 @@ done case $ac_lo in ?*) ac_cv_sizeof_uintptr_t=$ac_lo;; -'') { { echo "$as_me:$LINENO: error: cannot compute sizeof (uintptr_t) +'') if test "$ac_cv_type_uintptr_t" = yes; then + { { echo "$as_me:$LINENO: error: cannot compute sizeof (uintptr_t) See \`config.log' for more details." >&5 echo "$as_me: error: cannot compute sizeof (uintptr_t) See \`config.log' for more details." >&2;} - { (exit 77); exit 77; }; } ;; + { (exit 77); exit 77; }; } + else + ac_cv_sizeof_uintptr_t=0 + fi ;; esac else cat >conftest.$ac_ext <<_ACEOF @@ -12353,7 +10992,7 @@ cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ $ac_includes_default - typedef uintptr_t ac__type_sizeof_; + typedef uintptr_t ac__type_sizeof_; static long int longval () { return (long int) (sizeof (ac__type_sizeof_)); } static unsigned long int ulongval () { return (long int) (sizeof (ac__type_sizeof_)); } #include @@ -12412,21 +11051,25 @@ sed 's/^/| /' conftest.$ac_ext >&5 ( exit $ac_status ) -{ { echo "$as_me:$LINENO: error: cannot compute sizeof (uintptr_t) +if test "$ac_cv_type_uintptr_t" = yes; then + { { echo "$as_me:$LINENO: error: cannot compute sizeof (uintptr_t) See \`config.log' for more details." >&5 echo "$as_me: error: cannot compute sizeof (uintptr_t) See \`config.log' for more details." >&2;} { (exit 77); exit 77; }; } + else + ac_cv_sizeof_uintptr_t=0 + fi fi rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext fi rm -f conftest.val -else - ac_cv_sizeof_uintptr_t=0 -fi fi { echo "$as_me:$LINENO: result: $ac_cv_sizeof_uintptr_t" >&5 echo "${ECHO_T}$ac_cv_sizeof_uintptr_t" >&6; } + + + cat >>confdefs.h <<_ACEOF #define SIZEOF_UINTPTR_T $ac_cv_sizeof_uintptr_t _ACEOF @@ -12434,6 +11077,8 @@ fi + + # Hmph. AC_CHECK_SIZEOF() doesn't include . { echo "$as_me:$LINENO: checking size of off_t" >&5 echo $ECHO_N "checking size of off_t... $ECHO_C" >&6; } @@ -12630,27 +11275,10 @@ rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then have_pthread_t=yes else echo "$as_me: failed program was:" >&5 @@ -13168,27 +11796,11 @@ rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest$ac_exeext' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest$ac_exeext && + $as_test_x conftest$ac_exeext; then ac_cv_lib_dl_dlopen=yes else echo "$as_me: failed program was:" >&5 @@ -13197,7 +11809,7 @@ ac_cv_lib_dl_dlopen=no fi -rm -f core conftest.err conftest.$ac_objext \ +rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi @@ -13255,27 +11867,11 @@ rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest$ac_exeext' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest$ac_exeext && + $as_test_x conftest$ac_exeext; then ac_cv_lib_dld_shl_load=yes else echo "$as_me: failed program was:" >&5 @@ -13284,7 +11880,7 @@ ac_cv_lib_dld_shl_load=no fi -rm -f core conftest.err conftest.$ac_objext \ +rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi @@ -13350,27 +11946,11 @@ rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest$ac_exeext' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest$ac_exeext && + $as_test_x conftest$ac_exeext; then ac_cv_search_sem_init=$ac_res else echo "$as_me: failed program was:" >&5 @@ -13379,7 +11959,7 @@ fi -rm -f core conftest.err conftest.$ac_objext \ +rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ conftest$ac_exeext if test "${ac_cv_search_sem_init+set}" = set; then break @@ -13448,27 +12028,11 @@ rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest$ac_exeext' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest$ac_exeext && + $as_test_x conftest$ac_exeext; then ac_cv_lib_intl_textdomain=yes else echo "$as_me: failed program was:" >&5 @@ -13477,7 +12041,7 @@ ac_cv_lib_intl_textdomain=no fi -rm -f core conftest.err conftest.$ac_objext \ +rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi @@ -13524,27 +12088,11 @@ rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest$ac_exeext' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest$ac_exeext && + $as_test_x conftest$ac_exeext; then cat >>confdefs.h <<\_ACEOF #define AIX_GENUINE_CPLUSPLUS 1 @@ -13560,7 +12108,7 @@ echo "${ECHO_T}no" >&6; } fi -rm -f core conftest.err conftest.$ac_objext \ +rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ conftest$ac_exeext conftest.$ac_ext;; *) ;; esac @@ -13609,27 +12157,11 @@ rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest$ac_exeext' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest$ac_exeext && + $as_test_x conftest$ac_exeext; then ac_cv_lib_nsl_t_open=yes else echo "$as_me: failed program was:" >&5 @@ -13638,7 +12170,7 @@ ac_cv_lib_nsl_t_open=no fi -rm -f core conftest.err conftest.$ac_objext \ +rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi @@ -13690,27 +12222,11 @@ rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest$ac_exeext' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest$ac_exeext && + $as_test_x conftest$ac_exeext; then ac_cv_lib_socket_socket=yes else echo "$as_me: failed program was:" >&5 @@ -13719,7 +12235,7 @@ ac_cv_lib_socket_socket=no fi -rm -f core conftest.err conftest.$ac_objext \ +rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi @@ -13774,27 +12290,11 @@ rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest$ac_exeext' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest$ac_exeext && + $as_test_x conftest$ac_exeext; then ac_cv_lib_net_socket=yes else echo "$as_me: failed program was:" >&5 @@ -13803,7 +12303,7 @@ ac_cv_lib_net_socket=no fi -rm -f core conftest.err conftest.$ac_objext \ +rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi @@ -14057,27 +12557,10 @@ rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then ac_header_compiler=yes else echo "$as_me: failed program was:" >&5 @@ -14113,17 +12596,10 @@ rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } >/dev/null; then - if test -s conftest.err; then - ac_cpp_err=$ac_c_preproc_warn_flag - ac_cpp_err=$ac_cpp_err$ac_c_werror_flag - else - ac_cpp_err= - fi -else - ac_cpp_err=yes -fi -if test -z "$ac_cpp_err"; then + (exit $ac_status); } >/dev/null && { + test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || + test ! -s conftest.err + }; then ac_header_preproc=yes else echo "$as_me: failed program was:" >&5 @@ -14229,27 +12705,10 @@ rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then ac_header_compiler=yes else echo "$as_me: failed program was:" >&5 @@ -14285,17 +12744,10 @@ rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } >/dev/null; then - if test -s conftest.err; then - ac_cpp_err=$ac_c_preproc_warn_flag - ac_cpp_err=$ac_cpp_err$ac_c_werror_flag - else - ac_cpp_err= - fi -else - ac_cpp_err=yes -fi -if test -z "$ac_cpp_err"; then + (exit $ac_status); } >/dev/null && { + test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || + test ! -s conftest.err + }; then ac_header_preproc=yes else echo "$as_me: failed program was:" >&5 @@ -14426,27 +12878,11 @@ rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest$ac_exeext' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest$ac_exeext && + $as_test_x conftest$ac_exeext; then { echo "$as_me:$LINENO: result: yes" >&5 echo "${ECHO_T}yes" >&6; } @@ -14525,27 +12961,11 @@ rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest$ac_exeext' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest$ac_exeext && + $as_test_x conftest$ac_exeext; then ac_cv_func_pthread_detach=yes else echo "$as_me: failed program was:" >&5 @@ -14554,7 +12974,7 @@ ac_cv_func_pthread_detach=no fi -rm -f core conftest.err conftest.$ac_objext \ +rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ conftest$ac_exeext conftest.$ac_ext fi { echo "$as_me:$LINENO: result: $ac_cv_func_pthread_detach" >&5 @@ -14602,27 +13022,10 @@ rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then ac_header_compiler=yes else echo "$as_me: failed program was:" >&5 @@ -14658,17 +13061,10 @@ rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } >/dev/null; then - if test -s conftest.err; then - ac_cpp_err=$ac_c_preproc_warn_flag - ac_cpp_err=$ac_cpp_err$ac_c_werror_flag - else - ac_cpp_err= - fi -else - ac_cpp_err=yes -fi -if test -z "$ac_cpp_err"; then + (exit $ac_status); } >/dev/null && { + test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || + test ! -s conftest.err + }; then ac_header_preproc=yes else echo "$as_me: failed program was:" >&5 @@ -14769,27 +13165,10 @@ rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then ac_header_compiler=yes else echo "$as_me: failed program was:" >&5 @@ -14825,17 +13204,10 @@ rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } >/dev/null; then - if test -s conftest.err; then - ac_cpp_err=$ac_c_preproc_warn_flag - ac_cpp_err=$ac_cpp_err$ac_c_werror_flag - else - ac_cpp_err= - fi -else - ac_cpp_err=yes -fi -if test -z "$ac_cpp_err"; then + (exit $ac_status); } >/dev/null && { + test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || + test ! -s conftest.err + }; then ac_header_preproc=yes else echo "$as_me: failed program was:" >&5 @@ -14944,27 +13316,11 @@ rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest$ac_exeext' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest$ac_exeext && + $as_test_x conftest$ac_exeext; then ac_cv_lib_pthreads_pthread_create=yes else echo "$as_me: failed program was:" >&5 @@ -14973,7 +13329,7 @@ ac_cv_lib_pthreads_pthread_create=no fi -rm -f core conftest.err conftest.$ac_objext \ +rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi @@ -15031,27 +13387,11 @@ rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest$ac_exeext' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest$ac_exeext && + $as_test_x conftest$ac_exeext; then ac_cv_lib_c_r_pthread_create=yes else echo "$as_me: failed program was:" >&5 @@ -15060,7 +13400,7 @@ ac_cv_lib_c_r_pthread_create=no fi -rm -f core conftest.err conftest.$ac_objext \ +rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi @@ -15118,27 +13458,11 @@ rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest$ac_exeext' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest$ac_exeext && + $as_test_x conftest$ac_exeext; then ac_cv_lib_pthread___pthread_create_system=yes else echo "$as_me: failed program was:" >&5 @@ -15147,7 +13471,7 @@ ac_cv_lib_pthread___pthread_create_system=no fi -rm -f core conftest.err conftest.$ac_objext \ +rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi @@ -15205,27 +13529,11 @@ rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest$ac_exeext' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest$ac_exeext && + $as_test_x conftest$ac_exeext; then ac_cv_lib_cma_pthread_create=yes else echo "$as_me: failed program was:" >&5 @@ -15234,7 +13542,7 @@ ac_cv_lib_cma_pthread_create=no fi -rm -f core conftest.err conftest.$ac_objext \ +rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi @@ -15270,7 +13578,7 @@ fi -rm -f core conftest.err conftest.$ac_objext \ +rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ conftest$ac_exeext conftest.$ac_ext fi @@ -15323,27 +13631,11 @@ rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest$ac_exeext' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest$ac_exeext && + $as_test_x conftest$ac_exeext; then ac_cv_lib_mpc_usconfig=yes else echo "$as_me: failed program was:" >&5 @@ -15352,7 +13644,7 @@ ac_cv_lib_mpc_usconfig=no fi -rm -f core conftest.err conftest.$ac_objext \ +rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi @@ -15412,27 +13704,11 @@ rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest$ac_exeext' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest$ac_exeext && + $as_test_x conftest$ac_exeext; then ac_cv_lib_thread_thr_create=yes else echo "$as_me: failed program was:" >&5 @@ -15441,7 +13717,7 @@ ac_cv_lib_thread_thr_create=no fi -rm -f core conftest.err conftest.$ac_objext \ +rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi @@ -15633,27 +13909,11 @@ rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest$ac_exeext' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest$ac_exeext && + $as_test_x conftest$ac_exeext; then eval "$as_ac_var=yes" else echo "$as_me: failed program was:" >&5 @@ -15662,7 +13922,7 @@ eval "$as_ac_var=no" fi -rm -f core conftest.err conftest.$ac_objext \ +rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ conftest$ac_exeext conftest.$ac_ext fi ac_res=`eval echo '${'$as_ac_var'}'` @@ -15806,27 +14066,10 @@ rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then { echo "$as_me:$LINENO: result: yes" >&5 echo "${ECHO_T}yes" >&6; } ipv6=yes @@ -16205,27 +14448,11 @@ rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest$ac_exeext' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest$ac_exeext && + $as_test_x conftest$ac_exeext; then eval "$as_ac_var=yes" else echo "$as_me: failed program was:" >&5 @@ -16234,7 +14461,7 @@ eval "$as_ac_var=no" fi -rm -f core conftest.err conftest.$ac_objext \ +rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ conftest$ac_exeext conftest.$ac_ext fi ac_res=`eval echo '${'$as_ac_var'}'` @@ -16457,27 +14684,11 @@ rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest$ac_exeext' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest$ac_exeext && + $as_test_x conftest$ac_exeext; then eval "$as_ac_var=yes" else echo "$as_me: failed program was:" >&5 @@ -16486,7 +14697,7 @@ eval "$as_ac_var=no" fi -rm -f core conftest.err conftest.$ac_objext \ +rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ conftest$ac_exeext conftest.$ac_ext fi ac_res=`eval echo '${'$as_ac_var'}'` @@ -16533,27 +14744,10 @@ rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then cat >>confdefs.h <<\_ACEOF #define HAVE_CHROOT 1 @@ -16601,27 +14795,10 @@ rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then cat >>confdefs.h <<\_ACEOF #define HAVE_LINK 1 @@ -16669,27 +14846,10 @@ rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then cat >>confdefs.h <<\_ACEOF #define HAVE_SYMLINK 1 @@ -16737,27 +14897,10 @@ rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then cat >>confdefs.h <<\_ACEOF #define HAVE_FCHDIR 1 @@ -16805,27 +14948,10 @@ rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then cat >>confdefs.h <<\_ACEOF #define HAVE_FSYNC 1 @@ -16873,27 +14999,10 @@ rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then cat >>confdefs.h <<\_ACEOF #define HAVE_FDATASYNC 1 @@ -16951,27 +15060,10 @@ rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then cat >>confdefs.h <<\_ACEOF #define HAVE_CTERMID_R 1 @@ -17023,27 +15115,10 @@ rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then cat >>confdefs.h <<\_ACEOF #define HAVE_FLOCK 1 @@ -17095,27 +15170,10 @@ rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then cat >>confdefs.h <<\_ACEOF #define HAVE_GETPAGESIZE 1 @@ -17152,7 +15210,7 @@ IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; }; then + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_TRUE="$ac_prog" echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 @@ -17220,27 +15278,11 @@ rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest$ac_exeext' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest$ac_exeext && + $as_test_x conftest$ac_exeext; then ac_cv_lib_c_inet_aton=yes else echo "$as_me: failed program was:" >&5 @@ -17249,7 +15291,7 @@ ac_cv_lib_c_inet_aton=no fi -rm -f core conftest.err conftest.$ac_objext \ +rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi @@ -17301,27 +15343,11 @@ rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest$ac_exeext' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest$ac_exeext && + $as_test_x conftest$ac_exeext; then ac_cv_lib_resolv_inet_aton=yes else echo "$as_me: failed program was:" >&5 @@ -17330,7 +15356,7 @@ ac_cv_lib_resolv_inet_aton=no fi -rm -f core conftest.err conftest.$ac_objext \ +rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi @@ -17400,27 +15426,11 @@ rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest$ac_exeext' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest$ac_exeext && + $as_test_x conftest$ac_exeext; then ac_cv_lib_z_inflateCopy=yes else echo "$as_me: failed program was:" >&5 @@ -17429,7 +15439,7 @@ ac_cv_lib_z_inflateCopy=no fi -rm -f core conftest.err conftest.$ac_objext \ +rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi @@ -17484,27 +15494,11 @@ rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest$ac_exeext' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest$ac_exeext && + $as_test_x conftest$ac_exeext; then cat >>confdefs.h <<\_ACEOF #define HAVE_HSTRERROR 1 @@ -17521,7 +15515,7 @@ fi -rm -f core conftest.err conftest.$ac_objext \ +rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ conftest$ac_exeext conftest.$ac_ext { echo "$as_me:$LINENO: checking for inet_aton" >&5 @@ -17560,27 +15554,11 @@ rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest$ac_exeext' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest$ac_exeext && + $as_test_x conftest$ac_exeext; then cat >>confdefs.h <<\_ACEOF #define HAVE_INET_ATON 1 @@ -17597,7 +15575,7 @@ fi -rm -f core conftest.err conftest.$ac_objext \ +rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ conftest$ac_exeext conftest.$ac_ext { echo "$as_me:$LINENO: checking for inet_pton" >&5 @@ -17636,27 +15614,10 @@ rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then cat >>confdefs.h <<\_ACEOF #define HAVE_INET_PTON 1 @@ -17712,27 +15673,10 @@ rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then cat >>confdefs.h <<\_ACEOF #define HAVE_SETGROUPS 1 @@ -17820,27 +15764,11 @@ rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest$ac_exeext' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest$ac_exeext && + $as_test_x conftest$ac_exeext; then eval "$as_ac_var=yes" else echo "$as_me: failed program was:" >&5 @@ -17849,7 +15777,7 @@ eval "$as_ac_var=no" fi -rm -f core conftest.err conftest.$ac_objext \ +rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ conftest$ac_exeext conftest.$ac_ext fi ac_res=`eval echo '${'$as_ac_var'}'` @@ -17903,27 +15831,11 @@ rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest$ac_exeext' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest$ac_exeext && + $as_test_x conftest$ac_exeext; then ac_cv_lib_util_openpty=yes else echo "$as_me: failed program was:" >&5 @@ -17932,7 +15844,7 @@ ac_cv_lib_util_openpty=no fi -rm -f core conftest.err conftest.$ac_objext \ +rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi @@ -17986,27 +15898,11 @@ rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest$ac_exeext' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest$ac_exeext && + $as_test_x conftest$ac_exeext; then ac_cv_lib_bsd_openpty=yes else echo "$as_me: failed program was:" >&5 @@ -18015,7 +15911,7 @@ ac_cv_lib_bsd_openpty=no fi -rm -f core conftest.err conftest.$ac_objext \ +rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi @@ -18102,27 +15998,11 @@ rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest$ac_exeext' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest$ac_exeext && + $as_test_x conftest$ac_exeext; then eval "$as_ac_var=yes" else echo "$as_me: failed program was:" >&5 @@ -18131,7 +16011,7 @@ eval "$as_ac_var=no" fi -rm -f core conftest.err conftest.$ac_objext \ +rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ conftest$ac_exeext conftest.$ac_ext fi ac_res=`eval echo '${'$as_ac_var'}'` @@ -18185,27 +16065,11 @@ rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest$ac_exeext' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest$ac_exeext && + $as_test_x conftest$ac_exeext; then ac_cv_lib_util_forkpty=yes else echo "$as_me: failed program was:" >&5 @@ -18214,7 +16078,7 @@ ac_cv_lib_util_forkpty=no fi -rm -f core conftest.err conftest.$ac_objext \ +rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi @@ -18268,27 +16132,11 @@ rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest$ac_exeext' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest$ac_exeext && + $as_test_x conftest$ac_exeext; then ac_cv_lib_bsd_forkpty=yes else echo "$as_me: failed program was:" >&5 @@ -18297,7 +16145,7 @@ ac_cv_lib_bsd_forkpty=no fi -rm -f core conftest.err conftest.$ac_objext \ +rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi @@ -18391,27 +16239,11 @@ rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest$ac_exeext' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest$ac_exeext && + $as_test_x conftest$ac_exeext; then eval "$as_ac_var=yes" else echo "$as_me: failed program was:" >&5 @@ -18420,7 +16252,7 @@ eval "$as_ac_var=no" fi -rm -f core conftest.err conftest.$ac_objext \ +rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ conftest$ac_exeext conftest.$ac_ext fi ac_res=`eval echo '${'$as_ac_var'}'` @@ -18506,27 +16338,11 @@ rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest$ac_exeext' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest$ac_exeext && + $as_test_x conftest$ac_exeext; then eval "$as_ac_var=yes" else echo "$as_me: failed program was:" >&5 @@ -18535,7 +16351,7 @@ eval "$as_ac_var=no" fi -rm -f core conftest.err conftest.$ac_objext \ +rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ conftest$ac_exeext conftest.$ac_ext fi ac_res=`eval echo '${'$as_ac_var'}'` @@ -18624,27 +16440,11 @@ rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest$ac_exeext' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest$ac_exeext && + $as_test_x conftest$ac_exeext; then eval "$as_ac_var=yes" else echo "$as_me: failed program was:" >&5 @@ -18653,7 +16453,7 @@ eval "$as_ac_var=no" fi -rm -f core conftest.err conftest.$ac_objext \ +rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ conftest$ac_exeext conftest.$ac_ext fi ac_res=`eval echo '${'$as_ac_var'}'` @@ -18691,27 +16491,10 @@ rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then cat >>confdefs.h <<\_ACEOF #define GETPGRP_HAVE_ARG 1 @@ -18797,27 +16580,11 @@ rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest$ac_exeext' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest$ac_exeext && + $as_test_x conftest$ac_exeext; then eval "$as_ac_var=yes" else echo "$as_me: failed program was:" >&5 @@ -18826,7 +16593,7 @@ eval "$as_ac_var=no" fi -rm -f core conftest.err conftest.$ac_objext \ +rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ conftest$ac_exeext conftest.$ac_ext fi ac_res=`eval echo '${'$as_ac_var'}'` @@ -18864,27 +16631,10 @@ rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then cat >>confdefs.h <<\_ACEOF #define SETPGRP_HAVE_ARG 1 @@ -18970,27 +16720,11 @@ rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest$ac_exeext' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest$ac_exeext && + $as_test_x conftest$ac_exeext; then eval "$as_ac_var=yes" else echo "$as_me: failed program was:" >&5 @@ -18999,7 +16733,7 @@ eval "$as_ac_var=no" fi -rm -f core conftest.err conftest.$ac_objext \ +rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ conftest$ac_exeext conftest.$ac_ext fi ac_res=`eval echo '${'$as_ac_var'}'` @@ -19037,27 +16771,10 @@ rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then : else echo "$as_me: failed program was:" >&5 @@ -19117,27 +16834,11 @@ rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest$ac_exeext' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest$ac_exeext && + $as_test_x conftest$ac_exeext; then cat >>confdefs.h <<\_ACEOF @@ -19157,7 +16858,7 @@ fi -rm -f core conftest.err conftest.$ac_objext \ +rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ conftest$ac_exeext conftest.$ac_ext # On OSF/1 V5.1, getaddrinfo is available, but a define @@ -19199,27 +16900,11 @@ rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest$ac_exeext' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest$ac_exeext && + $as_test_x conftest$ac_exeext; then { echo "$as_me:$LINENO: result: yes" >&5 echo "${ECHO_T}yes" >&6; } @@ -19372,7 +17057,7 @@ fi -rm -f core conftest.err conftest.$ac_objext \ +rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ conftest$ac_exeext conftest.$ac_ext if test "$buggygetaddrinfo" = "yes"; then @@ -19455,27 +17140,11 @@ rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest$ac_exeext' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest$ac_exeext && + $as_test_x conftest$ac_exeext; then eval "$as_ac_var=yes" else echo "$as_me: failed program was:" >&5 @@ -19484,7 +17153,7 @@ eval "$as_ac_var=no" fi -rm -f core conftest.err conftest.$ac_objext \ +rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ conftest$ac_exeext conftest.$ac_ext fi ac_res=`eval echo '${'$as_ac_var'}'` @@ -19537,27 +17206,10 @@ rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then ac_cv_header_time=yes else echo "$as_me: failed program was:" >&5 @@ -19595,7 +17247,9 @@ int main () { -struct tm *tp; tp->tm_sec; +struct tm tm; + int *p = &tm.tm_sec; + return !p; ; return 0; } @@ -19613,27 +17267,10 @@ rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then ac_cv_struct_tm=time.h else echo "$as_me: failed program was:" >&5 @@ -19692,27 +17329,10 @@ rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then ac_cv_member_struct_tm_tm_zone=yes else echo "$as_me: failed program was:" >&5 @@ -19751,27 +17371,10 @@ rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then ac_cv_member_struct_tm_tm_zone=yes else echo "$as_me: failed program was:" >&5 @@ -19820,8 +17423,7 @@ main () { #ifndef tzname - char *p = (char *) tzname; - return !p; + (void) tzname; #endif ; @@ -19841,27 +17443,10 @@ rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then ac_cv_have_decl_tzname=yes else echo "$as_me: failed program was:" >&5 @@ -19927,27 +17512,11 @@ rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest$ac_exeext' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest$ac_exeext && + $as_test_x conftest$ac_exeext; then ac_cv_var_tzname=yes else echo "$as_me: failed program was:" >&5 @@ -19956,7 +17525,7 @@ ac_cv_var_tzname=no fi -rm -f core conftest.err conftest.$ac_objext \ +rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ conftest$ac_exeext conftest.$ac_ext fi { echo "$as_me:$LINENO: result: $ac_cv_var_tzname" >&5 @@ -20005,27 +17574,10 @@ rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then ac_cv_member_struct_stat_st_rdev=yes else echo "$as_me: failed program was:" >&5 @@ -20061,27 +17613,10 @@ rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then ac_cv_member_struct_stat_st_rdev=yes else echo "$as_me: failed program was:" >&5 @@ -20141,27 +17676,10 @@ rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then ac_cv_member_struct_stat_st_blksize=yes else echo "$as_me: failed program was:" >&5 @@ -20197,27 +17715,10 @@ rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then ac_cv_member_struct_stat_st_blksize=yes else echo "$as_me: failed program was:" >&5 @@ -20277,27 +17778,10 @@ rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then ac_cv_member_struct_stat_st_flags=yes else echo "$as_me: failed program was:" >&5 @@ -20333,27 +17817,10 @@ rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then ac_cv_member_struct_stat_st_flags=yes else echo "$as_me: failed program was:" >&5 @@ -20413,27 +17880,10 @@ rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then ac_cv_member_struct_stat_st_gen=yes else echo "$as_me: failed program was:" >&5 @@ -20469,27 +17919,10 @@ rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then ac_cv_member_struct_stat_st_gen=yes else echo "$as_me: failed program was:" >&5 @@ -20549,27 +17982,10 @@ rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then ac_cv_member_struct_stat_st_birthtime=yes else echo "$as_me: failed program was:" >&5 @@ -20605,27 +18021,10 @@ rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then ac_cv_member_struct_stat_st_birthtime=yes else echo "$as_me: failed program was:" >&5 @@ -20685,27 +18084,10 @@ rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then ac_cv_member_struct_stat_st_blocks=yes else echo "$as_me: failed program was:" >&5 @@ -20741,27 +18123,10 @@ rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then ac_cv_member_struct_stat_st_blocks=yes else echo "$as_me: failed program was:" >&5 @@ -20832,27 +18197,10 @@ rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then ac_cv_header_time_altzone=yes else echo "$as_me: failed program was:" >&5 @@ -20909,27 +18257,10 @@ rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then cat >>confdefs.h <<\_ACEOF @@ -20983,27 +18314,10 @@ rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then ac_cv_struct_addrinfo=yes else echo "$as_me: failed program was:" >&5 @@ -21060,27 +18374,10 @@ rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then ac_cv_struct_sockaddr_storage=yes else echo "$as_me: failed program was:" >&5 @@ -21140,27 +18437,10 @@ rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then ac_cv_c_char_unsigned=no else echo "$as_me: failed program was:" >&5 @@ -21199,10 +18479,10 @@ #ifndef __cplusplus /* Ultrix mips cc rejects this. */ typedef int charset[2]; - const charset x; + const charset cs; /* SunOS 4.1.1 cc rejects this. */ - char const *const *ccp; - char **p; + char const *const *pcpcc; + char **ppc; /* NEC SVR4.0.2 mips cc rejects this. */ struct point {int x, y;}; static struct point const zero = {0,0}; @@ -21211,11 +18491,11 @@ an arm of an if-expression whose if-part is not a constant expression */ const char *g = "string"; - ccp = &g + (g ? g-g : 0); + pcpcc = &g + (g ? g-g : 0); /* HPUX 7.0 cc rejects these. */ - ++ccp; - p = (char**) ccp; - ccp = (char const *const *) p; + ++pcpcc; + ppc = (char**) pcpcc; + pcpcc = (char const *const *) ppc; { /* SCO 3.2v4 cc rejects this. */ char *t; char const *s = 0 ? (char *) 0 : (char const *) 0; @@ -21242,7 +18522,7 @@ const int foo = 10; if (!foo) return 0; } - return !x[0] && !zero.x; + return !cs[0] && !zero.x; #endif ; @@ -21262,27 +18542,10 @@ rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then ac_cv_c_const=yes else echo "$as_me: failed program was:" >&5 @@ -21335,27 +18598,10 @@ rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then works=yes else echo "$as_me: failed program was:" >&5 @@ -21404,27 +18650,10 @@ rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then works=yes else echo "$as_me: failed program was:" >&5 @@ -21473,27 +18702,10 @@ rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then cat >>confdefs.h <<\_ACEOF @@ -21538,43 +18750,26 @@ { return foo(10, "", 3.14); ; - return 0; -} -_ACEOF -rm -f conftest.$ac_objext -if { (ac_try="$ac_compile" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_compile") 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (case "(($ac_try" in + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (ac_try="$ac_compile" +case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 + (eval "$ac_compile") 2>conftest.er1 ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then cat >>confdefs.h <<\_ACEOF @@ -21628,27 +18823,10 @@ rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then cat >>confdefs.h <<\_ACEOF #define HAVE_SOCKETPAIR 1 @@ -21700,27 +18878,10 @@ rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then { echo "$as_me:$LINENO: result: yes" >&5 echo "${ECHO_T}yes" >&6; } @@ -21775,27 +18936,10 @@ rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then : else echo "$as_me: failed program was:" >&5 @@ -21882,27 +19026,11 @@ rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest$ac_exeext' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest$ac_exeext && + $as_test_x conftest$ac_exeext; then ac_cv_func_gethostbyname_r=yes else echo "$as_me: failed program was:" >&5 @@ -21911,7 +19039,7 @@ ac_cv_func_gethostbyname_r=no fi -rm -f core conftest.err conftest.$ac_objext \ +rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ conftest$ac_exeext conftest.$ac_ext fi { echo "$as_me:$LINENO: result: $ac_cv_func_gethostbyname_r" >&5 @@ -21964,27 +19092,10 @@ rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then cat >>confdefs.h <<\_ACEOF #define HAVE_GETHOSTBYNAME_R 1 @@ -22045,27 +19156,10 @@ rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then cat >>confdefs.h <<\_ACEOF #define HAVE_GETHOSTBYNAME_R 1 @@ -22124,27 +19218,10 @@ rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then cat >>confdefs.h <<\_ACEOF #define HAVE_GETHOSTBYNAME_R 1 @@ -22248,27 +19325,11 @@ rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest$ac_exeext' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest$ac_exeext && + $as_test_x conftest$ac_exeext; then eval "$as_ac_var=yes" else echo "$as_me: failed program was:" >&5 @@ -22277,7 +19338,7 @@ eval "$as_ac_var=no" fi -rm -f core conftest.err conftest.$ac_objext \ +rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ conftest$ac_exeext conftest.$ac_ext fi ac_res=`eval echo '${'$as_ac_var'}'` @@ -22367,27 +19428,11 @@ rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest$ac_exeext' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest$ac_exeext && + $as_test_x conftest$ac_exeext; then ac_cv_func___fpu_control=yes else echo "$as_me: failed program was:" >&5 @@ -22396,7 +19441,7 @@ ac_cv_func___fpu_control=no fi -rm -f core conftest.err conftest.$ac_objext \ +rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ conftest$ac_exeext conftest.$ac_ext fi { echo "$as_me:$LINENO: result: $ac_cv_func___fpu_control" >&5 @@ -22447,27 +19492,11 @@ rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest$ac_exeext' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest$ac_exeext && + $as_test_x conftest$ac_exeext; then ac_cv_lib_ieee___fpu_control=yes else echo "$as_me: failed program was:" >&5 @@ -22476,7 +19505,7 @@ ac_cv_lib_ieee___fpu_control=no fi -rm -f core conftest.err conftest.$ac_objext \ +rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi @@ -22647,27 +19676,11 @@ rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest$ac_exeext' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest$ac_exeext && + $as_test_x conftest$ac_exeext; then eval "$as_ac_var=yes" else echo "$as_me: failed program was:" >&5 @@ -22676,7 +19689,7 @@ eval "$as_ac_var=no" fi -rm -f core conftest.err conftest.$ac_objext \ +rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ conftest$ac_exeext conftest.$ac_ext fi ac_res=`eval echo '${'$as_ac_var'}'` @@ -22735,27 +19748,10 @@ rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then ac_header_compiler=yes else echo "$as_me: failed program was:" >&5 @@ -22791,17 +19787,10 @@ rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } >/dev/null; then - if test -s conftest.err; then - ac_cpp_err=$ac_c_preproc_warn_flag - ac_cpp_err=$ac_cpp_err$ac_c_werror_flag - else - ac_cpp_err= - fi -else - ac_cpp_err=yes -fi -if test -z "$ac_cpp_err"; then + (exit $ac_status); } >/dev/null && { + test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || + test ! -s conftest.err + }; then ac_header_preproc=yes else echo "$as_me: failed program was:" >&5 @@ -22912,27 +19901,10 @@ rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then ac_cv_type_wchar_t=yes else echo "$as_me: failed program was:" >&5 @@ -22946,16 +19918,15 @@ { echo "$as_me:$LINENO: result: $ac_cv_type_wchar_t" >&5 echo "${ECHO_T}$ac_cv_type_wchar_t" >&6; } +# The cast to long int works around a bug in the HP C Compiler +# version HP92453-01 B.11.11.23709.GP, which incorrectly rejects +# declarations like `int a3[[(sizeof (unsigned char)) >= 0]];'. +# This bug is HP SR number 8606223364. { echo "$as_me:$LINENO: checking size of wchar_t" >&5 echo $ECHO_N "checking size of wchar_t... $ECHO_C" >&6; } if test "${ac_cv_sizeof_wchar_t+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else - if test "$ac_cv_type_wchar_t" = yes; then - # The cast to long int works around a bug in the HP C Compiler - # version HP92453-01 B.11.11.23709.GP, which incorrectly rejects - # declarations like `int a3[[(sizeof (unsigned char)) >= 0]];'. - # This bug is HP SR number 8606223364. if test "$cross_compiling" = yes; then # Depending upon the size, compute the lo and hi bounds. cat >conftest.$ac_ext <<_ACEOF @@ -22966,7 +19937,7 @@ /* end confdefs.h. */ #include - typedef wchar_t ac__type_sizeof_; + typedef wchar_t ac__type_sizeof_; int main () { @@ -22986,31 +19957,14 @@ eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_compile") 2>conftest.er1 ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then ac_lo=0 ac_mid=0 while :; do cat >conftest.$ac_ext <<_ACEOF @@ -23021,7 +19975,7 @@ /* end confdefs.h. */ #include - typedef wchar_t ac__type_sizeof_; + typedef wchar_t ac__type_sizeof_; int main () { @@ -23045,27 +19999,10 @@ rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then ac_hi=$ac_mid; break else echo "$as_me: failed program was:" >&5 @@ -23093,7 +20030,7 @@ /* end confdefs.h. */ #include - typedef wchar_t ac__type_sizeof_; + typedef wchar_t ac__type_sizeof_; int main () { @@ -23117,27 +20054,10 @@ rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then ac_hi=-1 ac_mid=-1 while :; do cat >conftest.$ac_ext <<_ACEOF @@ -23148,7 +20068,7 @@ /* end confdefs.h. */ #include - typedef wchar_t ac__type_sizeof_; + typedef wchar_t ac__type_sizeof_; int main () { @@ -23172,27 +20092,10 @@ rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then ac_lo=$ac_mid; break else echo "$as_me: failed program was:" >&5 @@ -23230,7 +20133,7 @@ /* end confdefs.h. */ #include - typedef wchar_t ac__type_sizeof_; + typedef wchar_t ac__type_sizeof_; int main () { @@ -23254,27 +20157,10 @@ rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then ac_hi=$ac_mid else echo "$as_me: failed program was:" >&5 @@ -23287,11 +20173,15 @@ done case $ac_lo in ?*) ac_cv_sizeof_wchar_t=$ac_lo;; -'') { { echo "$as_me:$LINENO: error: cannot compute sizeof (wchar_t) +'') if test "$ac_cv_type_wchar_t" = yes; then + { { echo "$as_me:$LINENO: error: cannot compute sizeof (wchar_t) See \`config.log' for more details." >&5 echo "$as_me: error: cannot compute sizeof (wchar_t) See \`config.log' for more details." >&2;} - { (exit 77); exit 77; }; } ;; + { (exit 77); exit 77; }; } + else + ac_cv_sizeof_wchar_t=0 + fi ;; esac else cat >conftest.$ac_ext <<_ACEOF @@ -23302,7 +20192,7 @@ /* end confdefs.h. */ #include - typedef wchar_t ac__type_sizeof_; + typedef wchar_t ac__type_sizeof_; static long int longval () { return (long int) (sizeof (ac__type_sizeof_)); } static unsigned long int ulongval () { return (long int) (sizeof (ac__type_sizeof_)); } #include @@ -23361,21 +20251,25 @@ sed 's/^/| /' conftest.$ac_ext >&5 ( exit $ac_status ) -{ { echo "$as_me:$LINENO: error: cannot compute sizeof (wchar_t) +if test "$ac_cv_type_wchar_t" = yes; then + { { echo "$as_me:$LINENO: error: cannot compute sizeof (wchar_t) See \`config.log' for more details." >&5 echo "$as_me: error: cannot compute sizeof (wchar_t) See \`config.log' for more details." >&2;} { (exit 77); exit 77; }; } + else + ac_cv_sizeof_wchar_t=0 + fi fi rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext fi rm -f conftest.val -else - ac_cv_sizeof_wchar_t=0 -fi fi { echo "$as_me:$LINENO: result: $ac_cv_sizeof_wchar_t" >&5 echo "${ECHO_T}$ac_cv_sizeof_wchar_t" >&6; } + + + cat >>confdefs.h <<_ACEOF #define SIZEOF_WCHAR_T $ac_cv_sizeof_wchar_t _ACEOF @@ -23418,27 +20312,10 @@ rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then cat >>confdefs.h <<\_ACEOF @@ -23634,7 +20511,8 @@ int main () { -#if !BYTE_ORDER || !BIG_ENDIAN || !LITTLE_ENDIAN +#if ! (defined BYTE_ORDER && defined BIG_ENDIAN && defined LITTLE_ENDIAN \ + && BYTE_ORDER && BIG_ENDIAN && LITTLE_ENDIAN) bogus endian macros #endif @@ -23655,27 +20533,10 @@ rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then # It does; now see whether it defined to BIG_ENDIAN or not. cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ @@ -23710,27 +20571,10 @@ rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then ac_cv_c_bigendian=yes else echo "$as_me: failed program was:" >&5 @@ -23781,27 +20625,10 @@ rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then if grep BIGenDianSyS conftest.$ac_objext >/dev/null ; then ac_cv_c_bigendian=yes fi @@ -24015,27 +20842,11 @@ rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest$ac_exeext' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest$ac_exeext && + $as_test_x conftest$ac_exeext; then ac_cv_have_getc_unlocked=yes else echo "$as_me: failed program was:" >&5 @@ -24044,7 +20855,7 @@ ac_cv_have_getc_unlocked=no fi -rm -f core conftest.err conftest.$ac_objext \ +rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ conftest$ac_exeext conftest.$ac_ext fi @@ -24105,27 +20916,11 @@ rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest$ac_exeext' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest$ac_exeext && + $as_test_x conftest$ac_exeext; then ac_cv_lib_readline_readline=yes else echo "$as_me: failed program was:" >&5 @@ -24134,7 +20929,7 @@ ac_cv_lib_readline_readline=no fi -rm -f core conftest.err conftest.$ac_objext \ +rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi @@ -24194,27 +20989,11 @@ rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest$ac_exeext' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest$ac_exeext && + $as_test_x conftest$ac_exeext; then ac_cv_lib_termcap_readline=yes else echo "$as_me: failed program was:" >&5 @@ -24223,7 +21002,7 @@ ac_cv_lib_termcap_readline=no fi -rm -f core conftest.err conftest.$ac_objext \ +rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi @@ -24283,27 +21062,11 @@ rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest$ac_exeext' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest$ac_exeext && + $as_test_x conftest$ac_exeext; then ac_cv_lib_readline_rl_callback_handler_install=yes else echo "$as_me: failed program was:" >&5 @@ -24312,7 +21075,7 @@ ac_cv_lib_readline_rl_callback_handler_install=no fi -rm -f core conftest.err conftest.$ac_objext \ +rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi @@ -24348,17 +21111,10 @@ rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } >/dev/null; then - if test -s conftest.err; then - ac_cpp_err=$ac_c_preproc_warn_flag - ac_cpp_err=$ac_cpp_err$ac_c_werror_flag - else - ac_cpp_err= - fi -else - ac_cpp_err=yes -fi -if test -z "$ac_cpp_err"; then + (exit $ac_status); } >/dev/null && { + test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || + test ! -s conftest.err + }; then have_readline=yes else echo "$as_me: failed program was:" >&5 @@ -24434,27 +21190,11 @@ rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest$ac_exeext' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest$ac_exeext && + $as_test_x conftest$ac_exeext; then ac_cv_lib_readline_rl_pre_input_hook=yes else echo "$as_me: failed program was:" >&5 @@ -24463,7 +21203,7 @@ ac_cv_lib_readline_rl_pre_input_hook=no fi -rm -f core conftest.err conftest.$ac_objext \ +rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi @@ -24518,30 +21258,14 @@ (eval "$ac_link") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest$ac_exeext' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? + rm -f conftest.er1 + cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest$ac_exeext && + $as_test_x conftest$ac_exeext; then ac_cv_lib_readline_rl_completion_matches=yes else echo "$as_me: failed program was:" >&5 @@ -24550,7 +21274,7 @@ ac_cv_lib_readline_rl_completion_matches=no fi -rm -f core conftest.err conftest.$ac_objext \ +rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi @@ -24586,17 +21310,10 @@ rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } >/dev/null; then - if test -s conftest.err; then - ac_cpp_err=$ac_c_preproc_warn_flag - ac_cpp_err=$ac_cpp_err$ac_c_werror_flag - else - ac_cpp_err= - fi -else - ac_cpp_err=yes -fi -if test -z "$ac_cpp_err"; then + (exit $ac_status); } >/dev/null && { + test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || + test ! -s conftest.err + }; then have_readline=yes else echo "$as_me: failed program was:" >&5 @@ -24825,27 +21542,10 @@ rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then ac_cv_member_struct_tm_tm_zone=yes else echo "$as_me: failed program was:" >&5 @@ -24884,27 +21584,10 @@ rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then ac_cv_member_struct_tm_tm_zone=yes else echo "$as_me: failed program was:" >&5 @@ -24953,8 +21636,7 @@ main () { #ifndef tzname - char *p = (char *) tzname; - return !p; + (void) tzname; #endif ; @@ -24974,27 +21656,10 @@ rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then ac_cv_have_decl_tzname=yes else echo "$as_me: failed program was:" >&5 @@ -25060,27 +21725,11 @@ rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest$ac_exeext' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest$ac_exeext && + $as_test_x conftest$ac_exeext; then ac_cv_var_tzname=yes else echo "$as_me: failed program was:" >&5 @@ -25089,7 +21738,7 @@ ac_cv_var_tzname=no fi -rm -f core conftest.err conftest.$ac_objext \ +rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ conftest$ac_exeext conftest.$ac_ext fi { echo "$as_me:$LINENO: result: $ac_cv_var_tzname" >&5 @@ -25268,27 +21917,10 @@ rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then ac_cv_stat_tv_nsec=yes else echo "$as_me: failed program was:" >&5 @@ -25348,27 +21980,10 @@ rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then ac_cv_stat_tv_nsec2=yes else echo "$as_me: failed program was:" >&5 @@ -25428,27 +22043,10 @@ rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then ac_cv_mvwdelch_is_expression=yes else echo "$as_me: failed program was:" >&5 @@ -25508,27 +22106,10 @@ rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then ac_cv_window_has_flags=yes else echo "$as_me: failed program was:" >&5 @@ -25583,27 +22164,10 @@ rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then cat >>confdefs.h <<\_ACEOF #define HAVE_CURSES_IS_TERM_RESIZED 1 @@ -25652,27 +22216,10 @@ rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then cat >>confdefs.h <<\_ACEOF #define HAVE_CURSES_RESIZE_TERM 1 @@ -25721,27 +22268,10 @@ rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then cat >>confdefs.h <<\_ACEOF #define HAVE_CURSES_RESIZETERM 1 @@ -25762,55 +22292,38 @@ { echo "$as_me:$LINENO: checking for /dev/ptmx" >&5 echo $ECHO_N "checking for /dev/ptmx... $ECHO_C" >&6; } -if test "${ac_cv_file__dev_ptmx+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 -else - test "$cross_compiling" = yes && - { { echo "$as_me:$LINENO: error: cannot check for file existence when cross compiling" >&5 -echo "$as_me: error: cannot check for file existence when cross compiling" >&2;} - { (exit 1); exit 1; }; } -if test -r "/dev/ptmx"; then - ac_cv_file__dev_ptmx=yes -else - ac_cv_file__dev_ptmx=no -fi -fi -{ echo "$as_me:$LINENO: result: $ac_cv_file__dev_ptmx" >&5 -echo "${ECHO_T}$ac_cv_file__dev_ptmx" >&6; } -if test $ac_cv_file__dev_ptmx = yes; then + +if test -r /dev/ptmx +then + { echo "$as_me:$LINENO: result: yes" >&5 +echo "${ECHO_T}yes" >&6; } cat >>confdefs.h <<\_ACEOF #define HAVE_DEV_PTMX 1 _ACEOF +else + { echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6; } fi { echo "$as_me:$LINENO: checking for /dev/ptc" >&5 echo $ECHO_N "checking for /dev/ptc... $ECHO_C" >&6; } -if test "${ac_cv_file__dev_ptc+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 -else - test "$cross_compiling" = yes && - { { echo "$as_me:$LINENO: error: cannot check for file existence when cross compiling" >&5 -echo "$as_me: error: cannot check for file existence when cross compiling" >&2;} - { (exit 1); exit 1; }; } -if test -r "/dev/ptc"; then - ac_cv_file__dev_ptc=yes -else - ac_cv_file__dev_ptc=no -fi -fi -{ echo "$as_me:$LINENO: result: $ac_cv_file__dev_ptc" >&5 -echo "${ECHO_T}$ac_cv_file__dev_ptc" >&6; } -if test $ac_cv_file__dev_ptc = yes; then + +if test -r /dev/ptc +then + { echo "$as_me:$LINENO: result: yes" >&5 +echo "${ECHO_T}yes" >&6; } cat >>confdefs.h <<\_ACEOF #define HAVE_DEV_PTC 1 _ACEOF +else + { echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6; } fi - { echo "$as_me:$LINENO: checking for %zd printf() format support" >&5 echo $ECHO_N "checking for %zd printf() format support... $ECHO_C" >&6; } if test "$cross_compiling" = yes; then @@ -25832,12 +22345,26 @@ int main() { - char buffer[4]; + char buffer[256]; + +#ifdef HAVE_SSIZE_T +typedef ssize_t Py_ssize_t; +#elif SIZEOF_VOID_P == SIZEOF_LONG +typedef long Py_ssize_t; +#else +typedef int Py_ssize_t; +#endif if(sprintf(buffer, "%zd", (size_t)123) < 0) return 1; - if (strncmp(buffer, "123", 3)) + if (strcmp(buffer, "123")) + return 1; + + if (sprintf(buffer, "%zd", (Py_ssize_t)-123) < 0) + return 1; + + if (strcmp(buffer, "-123")) return 1; return 0; @@ -25929,27 +22456,10 @@ rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then ac_cv_type_socklen_t=yes else echo "$as_me: failed program was:" >&5 @@ -26115,7 +22625,8 @@ ## M4sh Initialization. ## ## --------------------- ## -# Be Bourne compatible +# Be more Bourne compatible +DUALCASE=1; export DUALCASE # for MKS sh if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then emulate sh NULLCMD=: @@ -26124,10 +22635,13 @@ alias -g '${1+"$@"}'='"$@"' setopt NO_GLOB_SUBST else - case `(set -o) 2>/dev/null` in *posix*) set -o posix;; esac + case `(set -o) 2>/dev/null` in + *posix*) set -o posix ;; +esac + fi -BIN_SH=xpg4; export BIN_SH # for Tru64 -DUALCASE=1; export DUALCASE # for MKS sh + + # PATH needs CR @@ -26351,19 +22865,28 @@ as_mkdir_p=false fi -# Find out whether ``test -x'' works. Don't use a zero-byte file, as -# systems may use methods other than mode bits to determine executability. -cat >conf$$.file <<_ASEOF -#! /bin/sh -exit 0 -_ASEOF -chmod +x conf$$.file -if test -x conf$$.file >/dev/null 2>&1; then - as_executable_p="test -x" +if test -x / >/dev/null 2>&1; then + as_test_x='test -x' else - as_executable_p=: + if ls -dL / >/dev/null 2>&1; then + as_ls_L_option=L + else + as_ls_L_option= + fi + as_test_x=' + eval sh -c '\'' + if test -d "$1"; then + test -d "$1/."; + else + case $1 in + -*)set "./$1";; + esac; + case `ls -ld'$as_ls_L_option' "$1" 2>/dev/null` in + ???[sx]*):;;*)false;;esac;fi + '\'' sh + ' fi -rm -f conf$$.file +as_executable_p=$as_test_x # Sed expression to map a string onto a valid CPP name. as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'" @@ -26379,7 +22902,7 @@ # values after options handling. ac_log=" This file was extended by python $as_me 3.0, which was -generated by GNU Autoconf 2.60. Invocation command line was +generated by GNU Autoconf 2.61. Invocation command line was CONFIG_FILES = $CONFIG_FILES CONFIG_HEADERS = $CONFIG_HEADERS @@ -26407,7 +22930,7 @@ Usage: $0 [OPTIONS] [FILE]... -h, --help print this help, then exit - -V, --version print version number, then exit + -V, --version print version number and configuration settings, then exit -q, --quiet do not print progress messages -d, --debug don't remove temporary files --recheck update $as_me by reconfiguring in the same conditions @@ -26428,7 +22951,7 @@ cat >>$CONFIG_STATUS <<_ACEOF ac_cs_version="\\ python config.status 3.0 -configured by $0, generated by GNU Autoconf 2.60, +configured by $0, generated by GNU Autoconf 2.61, with options \\"`echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`\\" Copyright (C) 2006 Free Software Foundation, Inc. Modified: python/branches/p3yk/configure.in ============================================================================== --- python/branches/p3yk/configure.in (original) +++ python/branches/p3yk/configure.in Wed Dec 13 05:49:30 2006 @@ -201,7 +201,12 @@ # On OpenBSD, select(2) is not available if _XOPEN_SOURCE is defined, # even though select is a POSIX function. Reported by J. Ribbens. # Reconfirmed for OpenBSD 3.3 by Zachary Hamm, for 3.4 by Jason Ish. - OpenBSD/2.* | OpenBSD/3.@<:@0123456789@:>@) + OpenBSD/2.* | OpenBSD/3.@<:@0123456789@:>@ | OpenBSD/4.@<:@0@:>@) + define_xopen_source=no;; + # Defining _XOPEN_SOURCE on NetBSD version prior to the introduction of + # _NETBSD_SOURCE disables certain features (eg. setgroups). Reported by + # Marc Recht + NetBSD/1.5 | NetBSD/1.5.* | NetBSD/1.6 | NetBSD/1.6.* | NetBSD/1.6[A-S]) define_xopen_source=no;; # On Solaris 2.6, sys/wait.h is inconsistent in the usage # of union __?sigval. Reported by Stuart Bishop. @@ -890,6 +895,22 @@ fi fi +# Check whether GCC supports PyArg_ParseTuple format +if test "$GCC" = "yes" +then + AC_MSG_CHECKING(whether gcc supports ParseTuple __format__) + save_CFLAGS=$CFLAGS + CFLAGS="$CFLAGS -Werror" + AC_TRY_COMPILE([ + void f(char*,...)__attribute((format(PyArg_ParseTuple, 1, 2))); + ],, + AC_DEFINE(HAVE_ATTRIBUTE_FORMAT_PARSETUPLE, 1, [Define if GCC supports __attribute__((format(PyArg_ParseTuple, 2, 3)))]) + AC_MSG_RESULT(yes), + AC_MSG_RESULT(no) + ) + CFLAGS=$save_CFLAGS +fi + # On some compilers, pthreads are available without further options # (e.g. MacOS X). On some of these systems, the compiler will not # complain if unaccepted options are passed (e.g. gcc on Mac OS X). @@ -1068,8 +1089,8 @@ AC_HEADER_STDC AC_CHECK_HEADERS(asm/types.h conio.h curses.h direct.h dlfcn.h errno.h \ fcntl.h grp.h \ -shadow.h io.h langinfo.h libintl.h ncurses.h poll.h process.h pthread.h \ -signal.h stropts.h termios.h thread.h \ +io.h langinfo.h libintl.h ncurses.h poll.h process.h pthread.h \ +shadow.h signal.h stdint.h stropts.h termios.h thread.h \ unistd.h utime.h \ sys/audioio.h sys/bsdtty.h sys/file.h sys/loadavg.h sys/lock.h sys/mkdev.h \ sys/modem.h \ @@ -1197,16 +1218,12 @@ AC_CHECK_SIZEOF(long long, 8) fi -AC_MSG_CHECKING(for uintptr_t support) -have_uintptr_t=no -AC_TRY_COMPILE([], [uintptr_t x; x = (uintptr_t)0;], [ - AC_DEFINE(HAVE_UINTPTR_T, 1, [Define this if you have the type uintptr_t.]) - have_uintptr_t=yes -]) -AC_MSG_RESULT($have_uintptr_t) -if test "$have_uintptr_t" = yes ; then -AC_CHECK_SIZEOF(uintptr_t, 4) -fi +AC_CHECK_TYPES(uintptr_t, + [AC_CHECK_SIZEOF(uintptr_t, 4)], + [], [#ifdef HAVE_STDINT_H + #include + #endif]) + # Hmph. AC_CHECK_SIZEOF() doesn't include . AC_MSG_CHECKING(size of off_t) @@ -3342,8 +3359,27 @@ AC_MSG_RESULT(no) ) -AC_CHECK_FILE(/dev/ptmx, AC_DEFINE(HAVE_DEV_PTMX, 1, [Define if we have /dev/ptmx.])) -AC_CHECK_FILE(/dev/ptc, AC_DEFINE(HAVE_DEV_PTC, 1, [Define if we have /dev/ptc.])) +AC_MSG_CHECKING(for /dev/ptmx) + +if test -r /dev/ptmx +then + AC_MSG_RESULT(yes) + AC_DEFINE(HAVE_DEV_PTMX, 1, + [Define if we have /dev/ptmx.]) +else + AC_MSG_RESULT(no) +fi + +AC_MSG_CHECKING(for /dev/ptc) + +if test -r /dev/ptc +then + AC_MSG_RESULT(yes) + AC_DEFINE(HAVE_DEV_PTC, 1, + [Define if we have /dev/ptc.]) +else + AC_MSG_RESULT(no) +fi AC_MSG_CHECKING(for %zd printf() format support) AC_TRY_RUN([#include @@ -3352,14 +3388,28 @@ int main() { - char buffer[4]; + char buffer[256]; + +#ifdef HAVE_SSIZE_T +typedef ssize_t Py_ssize_t; +#elif SIZEOF_VOID_P == SIZEOF_LONG +typedef long Py_ssize_t; +#else +typedef int Py_ssize_t; +#endif if(sprintf(buffer, "%zd", (size_t)123) < 0) return 1; - if (strncmp(buffer, "123", 3)) + if (strcmp(buffer, "123")) return 1; - + + if (sprintf(buffer, "%zd", (Py_ssize_t)-123) < 0) + return 1; + + if (strcmp(buffer, "-123")) + return 1; + return 0; }], [AC_MSG_RESULT(yes) Modified: python/branches/p3yk/pyconfig.h.in ============================================================================== --- python/branches/p3yk/pyconfig.h.in (original) +++ python/branches/p3yk/pyconfig.h.in Wed Dec 13 05:49:30 2006 @@ -40,6 +40,9 @@ /* Define to 1 if you have the header file. */ #undef HAVE_ASM_TYPES_H +/* Define if GCC supports __attribute__((format(PyArg_ParseTuple, 2, 3))) */ +#undef HAVE_ATTRIBUTE_FORMAT_PARSETUPLE + /* Define to 1 if you have the `bind_textdomain_codeset' function. */ #undef HAVE_BIND_TEXTDOMAIN_CODESET @@ -677,7 +680,7 @@ /* Define this if you have tcl and TCL_UTF_MAX==6 */ #undef HAVE_UCS4_TCL -/* Define this if you have the type uintptr_t. */ +/* Define to 1 if the system has the type `uintptr_t'. */ #undef HAVE_UINTPTR_T /* Define to 1 if you have the `uname' function. */ Modified: python/branches/p3yk/setup.py ============================================================================== --- python/branches/p3yk/setup.py (original) +++ python/branches/p3yk/setup.py Wed Dec 13 05:49:30 2006 @@ -679,7 +679,8 @@ # save the include directory with the db.h version # (first occurrance only) db_ver_inc_map[db_ver] = d - print "db.h: found", db_ver, "in", d + if db_setup_debug: + print "db.h: found", db_ver, "in", d else: # we already found a header for this library version if db_setup_debug: print "db.h: ignoring", d @@ -719,8 +720,9 @@ if db_setup_debug: print "db lib: ", dblib, "not found" except db_found: - print "db lib: using", db_ver, dblib - if db_setup_debug: print "db: lib dir", dblib_dir, "inc dir", db_incdir + if db_setup_debug: + print "db lib: using", db_ver, dblib + print "db: lib dir", dblib_dir, "inc dir", db_incdir db_incs = [db_incdir] dblibs = [dblib] # We add the runtime_library_dirs argument because the @@ -741,7 +743,7 @@ dblib_dir = None # The sqlite interface - sqlite_setup_debug = True # verbose debug prints from this script? + sqlite_setup_debug = False # verbose debug prints from this script? # We hunt for #define SQLITE_VERSION "n.n.n" # We need to find >= sqlite version 3.0.8 @@ -773,7 +775,8 @@ for x in sqlite_version.split(".")]) if sqlite_version_tuple >= MIN_SQLITE_VERSION_NUMBER: # we win! - print "%s/sqlite3.h: version %s"%(d, sqlite_version) + if sqlite_setup_debug: + print "%s/sqlite3.h: version %s"%(d, sqlite_version) sqlite_incdir = d break else: From python-checkins at python.org Wed Dec 13 23:31:37 2006 From: python-checkins at python.org (brett.cannon) Date: Wed, 13 Dec 2006 23:31:37 +0100 (CET) Subject: [Python-checkins] r53023 - python/trunk/Lib/test/test_compile.py Message-ID: <20061213223137.DDE2C1E4017@bag.python.org> Author: brett.cannon Date: Wed Dec 13 23:31:37 2006 New Revision: 53023 Modified: python/trunk/Lib/test/test_compile.py Log: Remove an unneeded import of 'warnings'. Modified: python/trunk/Lib/test/test_compile.py ============================================================================== --- python/trunk/Lib/test/test_compile.py (original) +++ python/trunk/Lib/test/test_compile.py Wed Dec 13 23:31:37 2006 @@ -1,5 +1,4 @@ import unittest -import warnings import sys from test import test_support From python-checkins at python.org Wed Dec 13 23:45:53 2006 From: python-checkins at python.org (guido.van.rossum) Date: Wed, 13 Dec 2006 23:45:53 +0100 (CET) Subject: [Python-checkins] r53024 - sandbox/trunk/2to3/refactor.py Message-ID: <20061213224553.3A6121E4006@bag.python.org> Author: guido.van.rossum Date: Wed Dec 13 23:45:52 2006 New Revision: 53024 Modified: sandbox/trunk/2to3/refactor.py Log: Correctly use singular if there was one error. Modified: sandbox/trunk/2to3/refactor.py ============================================================================== --- sandbox/trunk/2to3/refactor.py (original) +++ sandbox/trunk/2to3/refactor.py Wed Dec 13 23:45:52 2006 @@ -257,7 +257,10 @@ for file in self.files: self.log_message(file) if self.errors: - self.log_message("There were %d errors", self.errors) + if self.errors == 1: + self.log_message("There was 1 error") + else: + self.log_message("There were %d errors", self.errors) def diff_texts(a, b, filename): From python-checkins at python.org Thu Dec 14 00:02:39 2006 From: python-checkins at python.org (brett.cannon) Date: Thu, 14 Dec 2006 00:02:39 +0100 (CET) Subject: [Python-checkins] r53025 - python/trunk/Lib/test/test_exceptions.py python/trunk/Lib/test/test_repr.py Message-ID: <20061213230239.5B0441E4006@bag.python.org> Author: brett.cannon Date: Thu Dec 14 00:02:38 2006 New Revision: 53025 Modified: python/trunk/Lib/test/test_exceptions.py python/trunk/Lib/test/test_repr.py Log: Remove unneeded imports of 'warnings'. Modified: python/trunk/Lib/test/test_exceptions.py ============================================================================== --- python/trunk/Lib/test/test_exceptions.py (original) +++ python/trunk/Lib/test/test_exceptions.py Thu Dec 14 00:02:38 2006 @@ -3,7 +3,6 @@ import os import sys import unittest -import warnings import pickle, cPickle from test.test_support import TESTFN, unlink, run_unittest Modified: python/trunk/Lib/test/test_repr.py ============================================================================== --- python/trunk/Lib/test/test_repr.py (original) +++ python/trunk/Lib/test/test_repr.py Thu Dec 14 00:02:38 2006 @@ -136,7 +136,6 @@ ' Author: brett.cannon Date: Thu Dec 14 00:09:53 2006 New Revision: 53026 Modified: python/trunk/Doc/lib/libtest.tex python/trunk/Lib/test/test_import.py python/trunk/Lib/test/test_random.py python/trunk/Lib/test/test_struct.py python/trunk/Lib/test/test_support.py python/trunk/Misc/NEWS Log: Add test.test_support.guard_warnings_filter . This function returns a context manager that protects warnings.filter from being modified once the context is exited. Modified: python/trunk/Doc/lib/libtest.tex ============================================================================== --- python/trunk/Doc/lib/libtest.tex (original) +++ python/trunk/Doc/lib/libtest.tex Thu Dec 14 00:09:53 2006 @@ -263,6 +263,10 @@ This does not equal a failure since it could be the path to the file. \end{funcdesc} +\begin{funcdesc}{guard_warnings_filter}{} +Returns a context manager that guards the \module{warnings} module's +filter settings. + \begin{funcdesc}{run_unittest}{*classes} Execute \class{unittest.TestCase} subclasses passed to the function. The function scans the classes for methods starting with the prefix Modified: python/trunk/Lib/test/test_import.py ============================================================================== --- python/trunk/Lib/test/test_import.py (original) +++ python/trunk/Lib/test/test_import.py Thu Dec 14 00:09:53 2006 @@ -1,10 +1,11 @@ -from test.test_support import TESTFN, run_unittest +from test.test_support import TESTFN, run_unittest, guard_warnings_filter import unittest import os import random import sys import py_compile +import warnings def remove_files(name): @@ -204,15 +205,11 @@ self.assert_(y is test.test_support, y.__name__) def test_import_initless_directory_warning(self): - import warnings - oldfilters = warnings.filters[:] - warnings.simplefilter('error', ImportWarning); - try: + with guard_warnings_filter(): # Just a random non-package directory we always expect to be # somewhere in sys.path... + warnings.simplefilter('error', ImportWarning) self.assertRaises(ImportWarning, __import__, "site-packages") - finally: - warnings.filters = oldfilters def test_main(verbose=None): run_unittest(ImportTest) Modified: python/trunk/Lib/test/test_random.py ============================================================================== --- python/trunk/Lib/test/test_random.py (original) +++ python/trunk/Lib/test/test_random.py Thu Dec 14 00:09:53 2006 @@ -178,10 +178,9 @@ def test_bigrand(self): # Verify warnings are raised when randrange is too large for random() - oldfilters = warnings.filters[:] - warnings.filterwarnings("error", "Underlying random") - self.assertRaises(UserWarning, self.gen.randrange, 2**60) - warnings.filters[:] = oldfilters + with test_support.guard_warnings_filter(): + warnings.filterwarnings("error", "Underlying random") + self.assertRaises(UserWarning, self.gen.randrange, 2**60) class SystemRandom_TestBasicOps(TestBasicOps): gen = random.SystemRandom() Modified: python/trunk/Lib/test/test_struct.py ============================================================================== --- python/trunk/Lib/test/test_struct.py (original) +++ python/trunk/Lib/test/test_struct.py Thu Dec 14 00:09:53 2006 @@ -50,22 +50,17 @@ def with_warning_restore(func): def _with_warning_restore(*args, **kw): - # The `warnings` module doesn't have an advertised way to restore - # its filter list. Cheat. - save_warnings_filters = warnings.filters[:] - # Grrr, we need this function to warn every time. Without removing - # the warningregistry, running test_tarfile then test_struct would fail - # on 64-bit platforms. - globals = func.func_globals - if '__warningregistry__' in globals: - del globals['__warningregistry__'] - warnings.filterwarnings("error", r"""^struct.*""", DeprecationWarning) - warnings.filterwarnings("error", r""".*format requires.*""", - DeprecationWarning) - try: + with test.test_support.guard_warnings_filter(): + # Grrr, we need this function to warn every time. Without removing + # the warningregistry, running test_tarfile then test_struct would fail + # on 64-bit platforms. + globals = func.func_globals + if '__warningregistry__' in globals: + del globals['__warningregistry__'] + warnings.filterwarnings("error", r"""^struct.*""", DeprecationWarning) + warnings.filterwarnings("error", r""".*format requires.*""", + DeprecationWarning) return func(*args, **kw) - finally: - warnings.filters[:] = save_warnings_filters[:] return _with_warning_restore def deprecated_err(func, *args): Modified: python/trunk/Lib/test/test_support.py ============================================================================== --- python/trunk/Lib/test/test_support.py (original) +++ python/trunk/Lib/test/test_support.py Thu Dec 14 00:09:53 2006 @@ -3,7 +3,9 @@ if __name__ != 'test.test_support': raise ImportError, 'test_support must be imported from the test package' +from contextlib import contextmanager import sys +import warnings class Error(Exception): """Base class for regression test exceptions.""" @@ -268,6 +270,16 @@ print >> get_original_stdout(), '\tfetching %s ...' % url fn, _ = urllib.urlretrieve(url, filename) return open(fn) + + at contextmanager +def guard_warnings_filter(): + """Guard the warnings filter from being permanently changed.""" + original_filters = warnings.filters[:] + try: + yield + finally: + warnings.filters = original_filters + #======================================================================= # Decorator for running a function in a different locale, correctly resetting Modified: python/trunk/Misc/NEWS ============================================================================== --- python/trunk/Misc/NEWS (original) +++ python/trunk/Misc/NEWS Thu Dec 14 00:09:53 2006 @@ -302,6 +302,10 @@ Tests ----- +- Added guard_warnings_filter to test.test_support. It returns a context + manager that protects the 'warnings' module's filter from being mutated + once the context has been exited. + - Added some tests for modulefinder. - Converted test_imp to use unittest. From buildbot at python.org Thu Dec 14 00:11:27 2006 From: buildbot at python.org (buildbot at python.org) Date: Wed, 13 Dec 2006 23:11:27 +0000 Subject: [Python-checkins] buildbot warnings in x86 mvlgcc trunk Message-ID: <20061213231127.414661E400A@bag.python.org> The Buildbot has detected a new failure of x86 mvlgcc trunk. Full details are available at: http://www.python.org/dev/buildbot/all/x86%2520mvlgcc%2520trunk/builds/106 Buildbot URL: http://www.python.org/dev/buildbot/all/ Build Reason: Build Source Stamp: [branch trunk] HEAD Blamelist: brett.cannon Build had warnings: warnings test Excerpt from the test logfile: 2 tests failed: test_socket_ssl test_timeout Traceback (most recent call last): File "./Lib/test/regrtest.py", line 554, in runtest_inner indirect_test() File "/home2/buildbot/slave/trunk.loewis-linux/build/Lib/test/test_socket_ssl.py", line 124, in test_main test_basic() File "/home2/buildbot/slave/trunk.loewis-linux/build/Lib/test/test_socket_ssl.py", line 30, in test_basic f = urllib.urlopen('https://sf.net') File "/home2/buildbot/slave/trunk.loewis-linux/build/Lib/urllib.py", line 82, in urlopen return opener.open(url) File "/home2/buildbot/slave/trunk.loewis-linux/build/Lib/urllib.py", line 190, in open return getattr(self, name)(url) File "/home2/buildbot/slave/trunk.loewis-linux/build/Lib/urllib.py", line 421, in open_https return self.http_error(url, fp, errcode, errmsg, headers) File "/home2/buildbot/slave/trunk.loewis-linux/build/Lib/urllib.py", line 347, in http_error result = method(url, fp, errcode, errmsg, headers) File "/home2/buildbot/slave/trunk.loewis-linux/build/Lib/urllib.py", line 622, in http_error_302 data) File "/home2/buildbot/slave/trunk.loewis-linux/build/Lib/urllib.py", line 637, in redirect_internal return self.open(newurl) File "/home2/buildbot/slave/trunk.loewis-linux/build/Lib/urllib.py", line 190, in open return getattr(self, name)(url) File "/home2/buildbot/slave/trunk.loewis-linux/build/Lib/urllib.py", line 412, in open_https h.endheaders() File "/home2/buildbot/slave/trunk.loewis-linux/build/Lib/httplib.py", line 864, in endheaders self._send_output() File "/home2/buildbot/slave/trunk.loewis-linux/build/Lib/httplib.py", line 736, in _send_output self.send(msg) File "/home2/buildbot/slave/trunk.loewis-linux/build/Lib/httplib.py", line 695, in send self.connect() File "/home2/buildbot/slave/trunk.loewis-linux/build/Lib/httplib.py", line 1152, in connect sock.connect((self.host, self.port)) File "", line 1, in connect IOError: [Errno socket error] (-2, 'Name or service not known') ====================================================================== FAIL: testConnectTimeout (test.test_timeout.TimeoutTestCase) ---------------------------------------------------------------------- Traceback (most recent call last): File "/home2/buildbot/slave/trunk.loewis-linux/build/Lib/test/test_timeout.py", line 128, in testConnectTimeout %(_delta, self.fuzz, _timeout)) AssertionError: timeout (5.00371) is more than 2 seconds more than expected (0.001) sincerely, -The Buildbot From python-checkins at python.org Thu Dec 14 00:28:56 2006 From: python-checkins at python.org (brett.cannon) Date: Thu, 14 Dec 2006 00:28:56 +0100 (CET) Subject: [Python-checkins] r53027 - sandbox/trunk/import_in_py/importer.py sandbox/trunk/import_in_py/test_importer.py Message-ID: <20061213232856.178D41E4006@bag.python.org> Author: brett.cannon Date: Thu Dec 14 00:28:55 2006 New Revision: 53027 Modified: sandbox/trunk/import_in_py/importer.py sandbox/trunk/import_in_py/test_importer.py Log: Raise a warning when a directory is found that matches a package name but does not have an __init__.py file. Modified: sandbox/trunk/import_in_py/importer.py ============================================================================== --- sandbox/trunk/import_in_py/importer.py (original) +++ sandbox/trunk/import_in_py/importer.py Thu Dec 14 00:28:55 2006 @@ -123,6 +123,7 @@ import os import contextlib import py_compile +import warnings def _set__import__(): @@ -274,26 +275,30 @@ registered. If the module's name is dotted then only search for the trailing - module's name on the path entry. + module's name on the path entry. An importer is already created + for each directory in __path__ for a package. """ # XXX Does not worry about case-insensitive filesystems. + tail_module = fullname.rsplit('.', 1)[-1] + package_directory = os.path.join(self.path_entry, tail_module) for handler in self.handlers: for file_ext in handler.handles: # XXX Backwards-incompatible to use anything but .py/.pyc # files for __init__? - tail_module = fullname.rsplit('.', 1)[-1] - package_entry = os.path.join(self.path_entry, tail_module) - package_name = os.path.join(package_entry, + package_init = os.path.join(package_directory, '__init__'+file_ext) - file_path = os.path.join(self.path_entry, package_name) - if os.path.isfile(file_path): - return self.loader(file_path, handler, package_entry) + if os.path.isfile(package_init): + return self.loader(package_init, handler, package_directory) file_name = tail_module + file_ext file_path = os.path.join(self.path_entry, file_name) if os.path.isfile(file_path): return self.loader(file_path, handler) else: + if os.path.isdir(package_directory): + warnings.warn("Not importing directory %s: missing __init__.py" + % package_directory, + ImportWarning) return None Modified: sandbox/trunk/import_in_py/test_importer.py ============================================================================== --- sandbox/trunk/import_in_py/test_importer.py (original) +++ sandbox/trunk/import_in_py/test_importer.py Thu Dec 14 00:28:55 2006 @@ -15,6 +15,7 @@ import StringIO import sys import tempfile +import warnings class BuiltinFrozen_Tester(unittest.TestCase): @@ -385,6 +386,15 @@ self.failUnlessEqual(loader.file_path, self.pkg_init_path) finally: os.remove(module_path) + + def test_directory_no_init_warning(self): + # If a directory matches for a package name but lacks an __init__.py + # file then raise ImportWarning. + os.remove(self.pkg_init_path) + with test_support.guard_warnings_filter(): + warnings.simplefilter('error', ImportWarning) + self.failUnlessRaises(ImportWarning, self.importer.find_module, + self.pkg_name) class FileSystemLoaderMockEnv(unittest.TestCase): From python-checkins at python.org Thu Dec 14 00:57:56 2006 From: python-checkins at python.org (paul.dubois) Date: Thu, 14 Dec 2006 00:57:56 +0100 (CET) Subject: [Python-checkins] r53028 - tracker/instances/python-dev/scripts/roundup-summary Message-ID: <20061213235756.96D481E400A@bag.python.org> Author: paul.dubois Date: Thu Dec 14 00:57:56 2006 New Revision: 53028 Modified: tracker/instances/python-dev/scripts/roundup-summary Log: ready for testing again Modified: tracker/instances/python-dev/scripts/roundup-summary ============================================================================== --- tracker/instances/python-dev/scripts/roundup-summary (original) +++ tracker/instances/python-dev/scripts/roundup-summary Thu Dec 14 00:57:56 2006 @@ -9,11 +9,10 @@ import optparse , datetime import cStringIO, MimeWriter, smtplib from roundup.mailer import SMTPConnection -today = roundup.date.Date('.') ### CONFIGURATION # List of statuses to treat as closed -- these don't have to all exist. -resolvedStatusDefault = 'resolved,done,done-cbb,closed' +resolvedStatusDefault = 'resolved,done,done-cbb,closed,faq' # Period of time for report. Uses roundup syntax for ranges. defaultDates = '-1w;' @@ -50,9 +49,9 @@ '-1w;' -- the last week (the default) '-3m;' -- the last 3 months 'from 2006-10-25 to 2006-12-25' -- Thanksgiving to Christmas, 2006 - - resolved is a list of statuses to treat as 'closed'. + mailTo is one or more email addresses, comma delimited. + resolved is a list of statuses to treat as 'closed'. statuses are names of statuses to ignore. Be sure to protect commas and semicolons from the shell with quotes! @@ -77,7 +76,7 @@ 'from 2006-11-1 to 2006-12-1' -- exact period""") parser.add_option('-m','--mail', dest='mailTo', default=defaultMailTo, - help='Mail the report to the address mailTo; if not given, print report.') + help='Mail the report to the address(es) mailTo; if not given, print report.') parser.add_option('-s','--status', dest='ignore', metavar="STATUSES_TO_IGNORE", default=ignoredStatusesDefault, help="Comma-delimited list of statuses to ignore in report.") @@ -107,15 +106,14 @@ db = instance.open('admin') # CUSTOMIZATION -dateWidth = len(roundup.date.Date('30 September 2006').pretty(format=dateFormat)) +dateWidth = len(roundup.date.Date('2006-09-30').pretty(format=dateFormat)) titleWidth = 72 #zero means no limit durationWidth = len('9999 days') +tableStyle = 'border="1" cellspacing="0" cellpadding="3"' def formatDuration(duration): - "Change a roundup duration object into text." - s = duration.as_seconds() - delta = datetime.timedelta(seconds=float(s)) - return str(delta.days) + ' days' + "Change a duration into text." + return "%4.0f days" % (duration.as_seconds()/(3600.*24),) def closedOrBlank(statusID): "CLOSED or a blank" @@ -125,22 +123,20 @@ return "" # Additional filter(s) to use in picking out issues. -# This sort of thing should maybe be command line options -# but it depends on the schema. -# Configuration file also a possibility for this and ignored statuses +# Depends on the schema. +notThese = ('notices', 'faq', 'todo', 'feature', 'wish') +try: + priorityIDS = db.priority.getnodeids(None, retired=None) + priorityNames = [db.priority.get(p, 'name') for p in priorityIDS] + acceptablePriorities = [priorityIDS[i] for i in range(len(priorityIDS)) if \ + priorityNames[i] not in notThese] +except: #for example, priority is not in the schema + acceptablePriorities = [] + def F(**args): "args is the dictionary to return, with additions if desired." - try: - priorityIDS = db.priority.getnodeids(None, retired=None) - priorityNames = [db.priority.get(p, 'name') for p in priorityIDS] - notThese = ('notices', 'faq', 'todo') - acceptable = [priorityIDS[i] for i in range(len(priorityIDS)) if \ - priorityNames[i] not in notThese] - if options.debug: - print 'acceptable priorities', acceptable - args['priority'] = acceptable - except: - pass + if acceptablePriorities: + args['priority'] = acceptablePriorities return args @@ -158,54 +154,55 @@ # The 'Created or Repopened' table, text mode. createdTable = """ titles: - 'Title', 0 + 'Title', titleWidth - dateWidth + 'Date', dateWidth '
    ', 0 'Status', len('CLOSED') - 'issueRef', issueRefWidth + 'Link', linkWidth 'Action', actionWidth 'By', userNameWidth records: title - closedOrBlank(statusID) - link(issueID) (reopenedDate or creation).pretty(format=dateFormat) + closedOrBlank(statusID) + link(issueNumber) + reopened or 'created' reopener or creator """ # The table of closed issues, text mode. closedTable = """ titles: - 'Title', 0 + 'Title', titleWidth - durationWidth + 'Duration', durationWidth '
    ', len('CLOSED') - 'Issue', issueRefWidth + 'Link', linkWidth 'By', userNameWidth - 'Duration', durationWidth records: title - issueRef - actor formatDuration(duration) + link(issueNumber) + actor """ # The table of most discussed issues, text mode. discussedTable = """ titles: - 'N', 3 - 'Title', 0 + 'N', -3 + 'Title', titleWidth - durationWidth + 'Duration', durationWidth '
    ', 0 'Status', statusWidth - 'Issue', issueRefWidth - 'By', userNameWidth - 'Duration', durationWidth + 'Link', linkWidth records: numberOfMessages title - status - issueRef - actor formatDuration(duration) + status + link(issueNumber) """ ### HTML Tables # The 'Created or Repopened' table, html mode. +# Titles are links, use zero on width; limit is applied in hlink htmlCreatedTable = """ titles: 'Title', 0 @@ -214,7 +211,7 @@ 'Action', actionWidth 'By', userNameWidth records: - hlink(issueID, title) + hlink(issueNumber, title) closedOrBlank(statusID) (reopenedDate or creation).pretty(format=dateFormat) reopened or 'created' @@ -227,20 +224,20 @@ 'By', userNameWidth 'Duration', durationWidth records: - hlink(title, issueID) + hlink(issueNumber, title) actor formatDuration(duration) """ # The table of most discussed issues, text mode. htmlDiscussedTable = """ titles: - 'N', 3 + 'N', -3 'Title', 0 'Status', statusWidth 'Duration', durationWidth records: numberOfMessages - hlink(title, issueID) + hlink(issueNumber, title) status formatDuration(duration) """ @@ -252,6 +249,7 @@ """Return dictionaries with the issue's title, etc. Assumes issue was created no later than to_value """ + issueNumber = issueID reopened = '' reopener = '' reopenedDate = '' @@ -278,26 +276,22 @@ activity = activity or activity2 for x,ts,userid,act,data in journal: - if ts < from_value: - break - if ts < to_value: + inPeriod = ts >= from_value and ts < to_value + if inPeriod: statusID = statusID or status2 actorID = actorID or actor2 activity = activity or activity2 if act == 'set': if data.has_key('messages'): - if ts < to_value: + if inPeriod: numberOfMessages += 1 if data.has_key('status'): status1 = data['status'] - if status1 is None: - status1 = createdStatusID if ts < to_value: if (status1 in resolvedStatusIDS) and \ (status2 not in resolvedStatusIDS): - if not reopened: - # want the latest reopener - if issueID not in recentlyCreatedIssueIDS: + if not reopened: # want the latest reopener only + if inPeriod and issueID not in recentlyCreatedIssueIDS: reopenedIssueIDS.append(issueID) reopened = 'reopened' reopener = userMap[userid] @@ -311,18 +305,23 @@ statusID = statusID or status2 activity = activity or activity2 actorID = actorID or actor2 -# calculate the fields for the reports (consider delaying this part -# so as to do it only for reported-upon issues) +# calculate the fields for the reports status = statusMap[statusID] actor = userMap[actorID] - duration = activity - (reopenedDate or creation) title = db.issue.get(issueID, 'title') creation = db.issue.get(issueID, 'creation') creatorID = db.issue.get(issueID, 'creator') creator = userMap[creatorID] + if statusID in resolvedStatusIDS: + duration = activity - (reopenedDate or creation) + else: + duration = to_value - (reopenedDate or creation) + if options.debug: + print >>bugfile, issueID, status, creator, actor, "%4.0f" %(duration.as_seconds()/(3600.24)), \ + activity.pretty(dateFormat), reopenedDate or 'created', creation.pretty(dateFormat) # out of a sense of neatness del status1, status2, actor2, activity2 - del x, ts, userid, act, data, t, journal + del x, ts, userid, act, data, journal # return the dictionary of local values for use in evals of table values. return locals() @@ -333,7 +332,7 @@ def hlink (issueID, title): "html link to url/title of issue whose ID is issueID" - return '''
    %s''' %(link(issueID), title) + return '''%s''' %(link(issueID), title[:titleWidth]) def statusCompare (x, y): """Compare two statusIDs by order.""" @@ -509,14 +508,13 @@ super(htmlTable, self).__init__(caption, issueIDS, tableSpec) def prologue(self, device): - print >>device, """
    -""" % self.caption + print >>device, """
    %s
    +""" % (tableStyle, self.caption) self.writeTitles(device, self.titles, self.fws) def epilogue(self, device): print >>device, '
    %s
    ' - def startTitles(self, device, titles, fws): print >>device, ' ' @@ -584,10 +582,18 @@ (nOpen, nOpen-nOpenOld, nClosed, nClosed-nClosedOld, (nOpen+nClosed), (nOpen+nClosed)-(nOpenOld+nClosedOld)) print >>body, '

    ' + print >>body, "

    " + print >>body, '

    ' + print >>body, "Average duration of open issues:", "%3.0f" % averageDuration, "days." + print >>body, '

    ' + print >>body, "

    " + print >>body, "Median duration of open issues:", "%3.0f" % medianDuration, "days." + print >>body, '

    ' print >>body, '

    ' - print >>body, ''' + print >>body, '''
    %s
    + -''' % caption +''' % (tableStyle, caption) for sid in statusIDS: if sid in resolvedStatusIDS: continue @@ -615,6 +621,9 @@ (nOpen, nOpen-nOpenOld, nClosed, nClosed-nClosedOld, (nOpen+nClosed), (nOpen+nClosed)-(nOpenOld+nClosedOld)) print >>body + print >>body, "Average duration of open issues:", "%3.0f" % averageDuration, "days." + print >>body, "Median duration of open issues:", "%3.0f" % medianDuration, "days." + print >>body print >>body, caption for sid in statusIDS: if sid in resolvedStatusIDS: @@ -627,7 +636,7 @@ def writeTextReport(device): "Write the report in text mode to device." - textSummary(device, "Open Issues Statistics") + textSummary(device, "Open Issues Breakdown") if not options.brief: messages.sort() @@ -644,7 +653,7 @@ def writeHtmlReport(device): "Write the report in html mode to device." - htmlSummary(device, 'Open Issues Statistics') + htmlSummary(device, 'Open Issues Breakdown') if not options.brief: t = htmlTable('Issues Created Or Reopened', createdOrReopenedIDS, htmlCreatedTable) @@ -671,15 +680,24 @@ # Options processing if options.debug: - print options + bugfile = open('bugfile', 'w') + print >>bugfile, options # ...dates dates = roundup.date.Range(options.dates, roundup.date.Date) from_value = dates.from_value to_value = dates.to_value if to_value is None: to_value = roundup.date.Date('.') +if from_value is None: + from_value = roundup.date.Date('1980-1-1') early_period = ';%s'%from_value whole_period = ';%s'%to_value +# ... statuses +ignoredStatuses = [s.strip() for s in options.ignore.split(',')] +if options.debug: + print >>bugfile, "from,to", from_value, to_value + print >>bugfile, 'acceptablePriorities', acceptablePriorities + print >>bugfile, 'ignoredStatuses', ignoredStatuses # ...audit if options.audit: @@ -698,13 +716,8 @@ audit.close() sys.exit(0) -# ... statuses -ignoredStatuses = [s.strip() for s in options.ignore.split(',')] # MAIN -# Find the id of the status an issue gets when created -createdStatusID = db.status.lookup('unread') - # Make lists and maps of things # Users adminUserID = db.user.lookup('admin') @@ -721,10 +734,8 @@ # Make map of statuses / names, including retired ones. # Just doing lookup on names will miss retired ones. statusIDS_ALL = db.status.getnodeids(retired=None) -statusLookup = {} -statusMap = {None: createdStatusID} -statusMap = {None: createdStatusID} - +statusLookup = {'None': None} +statusMap = {None: 'None'} for sid in statusIDS_ALL: name = db.status.get(sid, 'name') statusLookup[name] = sid @@ -741,8 +752,8 @@ pass if options.debug: - print 'statusLookup', statusLookup - print 'resolvedStatusIDS', resolvedStatusIDS + print >>bugfile, 'statusLookup', statusLookup + print >>bugfile, 'resolvedStatusIDS', resolvedStatusIDS statusIDS = [sid for sid in statusIDS_ALL if statusUsable(sid)] statusIDS.sort(statusCompare) @@ -776,7 +787,7 @@ maxIssueID = allIssueIDS[-1] else: maxIssueID = 1000 -issueRefWidth = len(link(maxIssueID)) +linkWidth = len(link(maxIssueID)) messages = [] statusReport = {} issueAttributes = {} @@ -787,6 +798,17 @@ createdOrReopenedIDS = reopenedIssueIDS + recentlyCreatedIssueIDS createdOrReopenedIDS.sort(issueIdCompare) +durations = [issueAttributes[id]['duration'].as_seconds()/(3600*24.) for id in allIssueIDS if \ + id not in closedIssueIDS] +if durations: + if options.debug: + print >>bugfile, 'Min duration:', durations[-1], '; max', durations[0] + averageDuration = sum(durations)/len(durations) + medianDuration = durations[len(durations)/2] +else: + averageDuration = "N/A" + medianDuration = "N/A" + messages.sort() messages.reverse() discussedIDS = [id for (num, id) in messages[:discussionMax] \ @@ -806,19 +828,19 @@ statusReport[sid] = (nNow, nThen) -# Now make the text report +# Now make the reports textReport = cStringIO.StringIO() writeTextReport(textReport) -# Email? Or just print it. -if not options.mailTo: - print textReport.getvalue() -else: - # generate the email message +htmlReport = cStringIO.StringIO() +writeHtmlReport(htmlReport) + +def sendReport (recipient): + "Send the email message." message = cStringIO.StringIO() writer = MimeWriter.MimeWriter(message) writer.addheader('Subject', 'Summary of %s Issues'%db.config.TRACKER_NAME) - writer.addheader('To', options.mailTo) + writer.addheader('To', recipient) writer.addheader('From', '%s <%s>'%(db.config.TRACKER_NAME, db.config.ADMIN_EMAIL)) writer.addheader('Reply-To', '%s <%s>'%(db.config.TRACKER_NAME, 'DONOTREPLY at NOWHERE.ORG')) writer.addheader('MIME-Version', '1.0') @@ -835,7 +857,7 @@ # now the HTML one part = writer.nextpart() body = part.startbody('text/html') - writeHtmlReport(body) + print >>body, htmlReport.getvalue() # finish off the multipart writer.lastpart() # all done, send! @@ -845,3 +867,10 @@ smtp = SMTPConnection(db.config) smtp.sendmail(db.config.ADMIN_EMAIL, options.mailTo, message.getvalue()) +# Email? Or just print it. +if not options.mailTo: + print textReport.getvalue() +else: + for recipient in options.mailTo.split(','): + sendReport(recipient) + From buildbot at python.org Thu Dec 14 01:24:32 2006 From: buildbot at python.org (buildbot at python.org) Date: Thu, 14 Dec 2006 00:24:32 +0000 Subject: [Python-checkins] buildbot warnings in alpha Tru64 5.1 trunk Message-ID: <20061214002432.CF6501E4012@bag.python.org> The Buildbot has detected a new failure of alpha Tru64 5.1 trunk. Full details are available at: http://www.python.org/dev/buildbot/all/alpha%2520Tru64%25205.1%2520trunk/builds/1323 Buildbot URL: http://www.python.org/dev/buildbot/all/ Build Reason: Build Source Stamp: [branch trunk] HEAD Blamelist: brett.cannon Build had warnings: warnings test Excerpt from the test logfile: 2 tests failed: test_signal test_socket sincerely, -The Buildbot From python-checkins at python.org Thu Dec 14 03:22:44 2006 From: python-checkins at python.org (george.yoshida) Date: Thu, 14 Dec 2006 03:22:44 +0100 (CET) Subject: [Python-checkins] r53029 - python/trunk/Doc/lib/libtest.tex Message-ID: <20061214022244.EAA1E1E4006@bag.python.org> Author: george.yoshida Date: Thu Dec 14 03:22:44 2006 New Revision: 53029 Modified: python/trunk/Doc/lib/libtest.tex Log: Note that guard_warnings_filter was added in 2.6 Modified: python/trunk/Doc/lib/libtest.tex ============================================================================== --- python/trunk/Doc/lib/libtest.tex (original) +++ python/trunk/Doc/lib/libtest.tex Thu Dec 14 03:22:44 2006 @@ -266,6 +266,8 @@ \begin{funcdesc}{guard_warnings_filter}{} Returns a context manager that guards the \module{warnings} module's filter settings. +\versionadded{2.6} +\end{funcdesc} \begin{funcdesc}{run_unittest}{*classes} Execute \class{unittest.TestCase} subclasses passed to the function. From python-checkins at python.org Thu Dec 14 09:41:40 2006 From: python-checkins at python.org (vinay.sajip) Date: Thu, 14 Dec 2006 09:41:40 +0100 (CET) Subject: [Python-checkins] r53030 - python/branches/release25-maint/Lib/logging/config.py Message-ID: <20061214084140.409F51E4006@bag.python.org> Author: vinay.sajip Date: Thu Dec 14 09:41:39 2006 New Revision: 53030 Modified: python/branches/release25-maint/Lib/logging/config.py Log: Stripped whitespace from comma-separated values read from config file Modified: python/branches/release25-maint/Lib/logging/config.py ============================================================================== --- python/branches/release25-maint/Lib/logging/config.py (original) +++ python/branches/release25-maint/Lib/logging/config.py Thu Dec 14 09:41:39 2006 @@ -110,7 +110,7 @@ flist = string.split(flist, ",") formatters = {} for form in flist: - sectname = "formatter_%s" % form + sectname = "formatter_%s" % string.strip(form) opts = cp.options(sectname) if "format" in opts: fs = cp.get(sectname, "format", 1) @@ -139,7 +139,7 @@ handlers = {} fixups = [] #for inter-handler references for hand in hlist: - sectname = "handler_%s" % hand + sectname = "handler_%s" % string.strip(hand) klass = cp.get(sectname, "class") opts = cp.options(sectname) if "formatter" in opts: @@ -176,6 +176,7 @@ # configure the root first llist = cp.get("loggers", "keys") llist = string.split(llist, ",") + llist = map(lambda x: string.strip(x), llist) llist.remove("root") sectname = "logger_root" root = logging.root @@ -190,7 +191,7 @@ if len(hlist): hlist = string.split(hlist, ",") for hand in hlist: - log.addHandler(handlers[hand]) + log.addHandler(handlers[string.strip(hand)]) #and now the others... #we don't want to lose the existing loggers, @@ -225,7 +226,7 @@ if len(hlist): hlist = string.split(hlist, ",") for hand in hlist: - logger.addHandler(handlers[hand]) + logger.addHandler(handlers[string.strip(hand)]) #Disable any old loggers. There's no point deleting #them as other threads may continue to hold references From python-checkins at python.org Thu Dec 14 09:53:56 2006 From: python-checkins at python.org (vinay.sajip) Date: Thu, 14 Dec 2006 09:53:56 +0100 (CET) Subject: [Python-checkins] r53031 - python/trunk/Misc/NEWS Message-ID: <20061214085356.2789B1E4006@bag.python.org> Author: vinay.sajip Date: Thu Dec 14 09:53:55 2006 New Revision: 53031 Modified: python/trunk/Misc/NEWS Log: Added news on recent changes to logging Modified: python/trunk/Misc/NEWS ============================================================================== --- python/trunk/Misc/NEWS (original) +++ python/trunk/Misc/NEWS Thu Dec 14 09:53:55 2006 @@ -101,6 +101,12 @@ Library ------- +- Bug #1503765: Fix a problem in logging.config with spaces in comma- + separated lists read from logging config files. + +- Patch #1604907: Fix problems in logging.handlers caused at logging shutdown + when syslog handlers fail to initialize because of syslogd problems. + - Patch #1608267: fix a race condition in os.makedirs() is the directory to be created is already there. @@ -138,14 +144,14 @@ - Patch #1355023: support whence argument for GzipFile.seek. -- Patch #1065257: Support passing open files as body in +- Patch #1065257: Support passing open files as body in HTTPConnection.request(). - Bug #1569790: mailbox.py: Maildir.get_folder() and MH.get_folder() weren't passing the message factory on to newly created Maildir/MH objects. -- Patch #1514543: mailbox.py: In the Maildir class, report errors if there's +- Patch #1514543: mailbox.py: In the Maildir class, report errors if there's a filename clash instead of possibly losing a message. (Patch by David Watson.) @@ -233,7 +239,7 @@ - Patch #1550886: Fix decimal module context management implementation to match the localcontext() example from PEP 343. -- Bug #1545341: The 'classifier' keyword argument to the Distutils setup() +- Bug #1545341: The 'classifier' keyword argument to the Distutils setup() function now accepts tuples as well as lists. - Bug #1541863: uuid.uuid1 failed to generate unique identifiers @@ -350,7 +356,7 @@ - configure now checks whether gcc supports the PyArg_ParseTuple format attribute. -- Bug #1578513: Cross compilation was broken by a change to configure. +- Bug #1578513: Cross compilation was broken by a change to configure. Repair so that it's back to how it was in 2.4.3. - Patch #1576954: Update VC6 build directory; remove redundant From buildbot at python.org Thu Dec 14 10:30:07 2006 From: buildbot at python.org (buildbot at python.org) Date: Thu, 14 Dec 2006 09:30:07 +0000 Subject: [Python-checkins] buildbot failure in x86 XP trunk Message-ID: <20061214093007.3B5B21E400A@bag.python.org> The Buildbot has detected a new failure of x86 XP trunk. Full details are available at: http://www.python.org/dev/buildbot/all/x86%2520XP%2520trunk/builds/95 Buildbot URL: http://www.python.org/dev/buildbot/all/ Build Reason: The web-page 'force build' button was pressed by 'a': a Build Source Stamp: [branch 123] 213 Blamelist: BUILD FAILED: failed svn sincerely, -The Buildbot From buildbot at python.org Thu Dec 14 10:42:24 2006 From: buildbot at python.org (buildbot at python.org) Date: Thu, 14 Dec 2006 09:42:24 +0000 Subject: [Python-checkins] buildbot warnings in alpha Tru64 5.1 2.5 Message-ID: <20061214094224.88C441E4006@bag.python.org> The Buildbot has detected a new failure of alpha Tru64 5.1 2.5. Full details are available at: http://www.python.org/dev/buildbot/all/alpha%2520Tru64%25205.1%25202.5/builds/128 Buildbot URL: http://www.python.org/dev/buildbot/all/ Build Reason: Build Source Stamp: [branch branches/release25-maint] HEAD Blamelist: vinay.sajip Build had warnings: warnings test Excerpt from the test logfile: 1 test failed: test_socket ====================================================================== FAIL: testInterruptedTimeout (test.test_socket.TCPTimeoutTest) ---------------------------------------------------------------------- Traceback (most recent call last): File "/net/ringneck/scratch1/nnorwitz/buildbot/2.5.norwitz-tru64/build/Lib/test/test_socket.py", line 847, in testInterruptedTimeout self.fail("got Alarm in wrong place") AssertionError: got Alarm in wrong place sincerely, -The Buildbot From buildbot at python.org Thu Dec 14 11:03:51 2006 From: buildbot at python.org (buildbot at python.org) Date: Thu, 14 Dec 2006 10:03:51 +0000 Subject: [Python-checkins] buildbot warnings in x86 Ubuntu edgy (icc) 2.5 Message-ID: <20061214100351.EC2FD1E4011@bag.python.org> The Buildbot has detected a new failure of x86 Ubuntu edgy (icc) 2.5. Full details are available at: http://www.python.org/dev/buildbot/all/x86%2520Ubuntu%2520edgy%2520%2528icc%2529%25202.5/builds/125 Buildbot URL: http://www.python.org/dev/buildbot/all/ Build Reason: Build Source Stamp: [branch branches/release25-maint] HEAD Blamelist: vinay.sajip Build had warnings: warnings test Excerpt from the test logfile: 1 test failed: test_timeout ====================================================================== FAIL: testConnectTimeout (test.test_timeout.TimeoutTestCase) ---------------------------------------------------------------------- Traceback (most recent call last): File "/home/buildbot/Buildbot/2.5.baxter-ubuntu/build/Lib/test/test_timeout.py", line 128, in testConnectTimeout %(_delta, self.fuzz, _timeout)) AssertionError: timeout (3.91709) is more than 2 seconds more than expected (0.001) sincerely, -The Buildbot From python-checkins at python.org Thu Dec 14 19:57:54 2006 From: python-checkins at python.org (andrew.kuchling) Date: Thu, 14 Dec 2006 19:57:54 +0100 (CET) Subject: [Python-checkins] r53032 - python/trunk/Lib/mailbox.py Message-ID: <20061214185754.05AAF1E4006@bag.python.org> Author: andrew.kuchling Date: Thu Dec 14 19:57:53 2006 New Revision: 53032 Modified: python/trunk/Lib/mailbox.py Log: [Patch #1599256 from David Watson] check that os.fsync is available before using it Modified: python/trunk/Lib/mailbox.py ============================================================================== --- python/trunk/Lib/mailbox.py (original) +++ python/trunk/Lib/mailbox.py Thu Dec 14 19:57:53 2006 @@ -1887,7 +1887,8 @@ def _sync_flush(f): """Ensure changes to file f are physically on disk.""" f.flush() - os.fsync(f.fileno()) + if hasattr(os, 'fsync'): + os.fsync(f.fileno()) def _sync_close(f): """Close file f, ensuring all changes are physically on disk.""" From python-checkins at python.org Thu Dec 14 19:59:08 2006 From: python-checkins at python.org (andrew.kuchling) Date: Thu, 14 Dec 2006 19:59:08 +0100 (CET) Subject: [Python-checkins] r53033 - python/branches/release25-maint/Lib/mailbox.py Message-ID: <20061214185908.1A2F81E4006@bag.python.org> Author: andrew.kuchling Date: Thu Dec 14 19:59:07 2006 New Revision: 53033 Modified: python/branches/release25-maint/Lib/mailbox.py Log: [Patch #1599256 from David Watson] check that os.fsync is available before using it Modified: python/branches/release25-maint/Lib/mailbox.py ============================================================================== --- python/branches/release25-maint/Lib/mailbox.py (original) +++ python/branches/release25-maint/Lib/mailbox.py Thu Dec 14 19:59:07 2006 @@ -1887,7 +1887,8 @@ def _sync_flush(f): """Ensure changes to file f are physically on disk.""" f.flush() - os.fsync(f.fileno()) + if hasattr(os, 'fsync'): + os.fsync(f.fileno()) def _sync_close(f): """Close file f, ensuring all changes are physically on disk.""" From python-checkins at python.org Thu Dec 14 20:43:33 2006 From: python-checkins at python.org (brett.cannon) Date: Thu, 14 Dec 2006 20:43:33 +0100 (CET) Subject: [Python-checkins] r53034 - sandbox/trunk/import_in_py/importer.py Message-ID: <20061214194333.A21081E4006@bag.python.org> Author: brett.cannon Date: Thu Dec 14 20:43:32 2006 New Revision: 53034 Modified: sandbox/trunk/import_in_py/importer.py Log: Pull out implementation notes out of the module docstring and move to the Google Doc. Also change exception messages to match. Modified: sandbox/trunk/import_in_py/importer.py ============================================================================== --- sandbox/trunk/import_in_py/importer.py (original) +++ sandbox/trunk/import_in_py/importer.py Thu Dec 14 20:43:32 2006 @@ -1,115 +1,22 @@ """Re-implementation of import machinery in Python source code. +XXX See http://docs.google.com/View?docid=dg7fctr4_4d8tdbq on current status. + References on import: * Language reference - http://docs.python.org/ref/import.html + http://docs.python.org/ref/import.html * __import__ function - http://docs.python.org/lib/built-in-funcs.html + http://docs.python.org/lib/built-in-funcs.html * Packages - http://www.python.org/doc/essays/packages.html + http://www.python.org/doc/essays/packages.html * PEP 235: Import on Case-Insensitive Platforms - http://www.python.org/dev/peps/pep-0235 + http://www.python.org/dev/peps/pep-0235 * PEP 275: Import Modules from Zip Archives - http://www.python.org/dev/peps/pep-0273 + http://www.python.org/dev/peps/pep-0273 * PEP 302: New Import Hooks - http://www.python.org/dev/peps/pep-0302/ + http://www.python.org/dev/peps/pep-0302/ * PEP 328: Imports: Multi-line and Absolute/Relative - http://www.python.org/dev/peps/pep-0328 - -Clarifications -============== -* Raise ImportError when load_module() fails to load a module without - raising an exception. -* Is module returned by load_module() actually used for anything? - + Can always just return from sys.modules. -* PEP 302 does not mention if __name__ must be set before any code is executed - or not. - - -XXX See http://docs.google.com/View?docid=dg7fctr4_4d8tdbq on current status. - - -Things to be exposed at the Python level -======================================== -* Python/marshal.c:r_long()/w_long() - + Using own version temporarily. - - -Py3k -==== -Improvements ------------- -* Have a meta_path entry for checking sys.modules to remove need for - loaders or __import__ to do it. -* Put importer objects directly into sys.path to remove need for - sys.path_importer_cache. Could leave string entries on sys.path that do - not have an importer so they can be re-checked the next time a new import - is attempted. - + If __import__ handles sys.modules then the impact from having to - recheck sys.path entries that lack an importer is minimized as it is - only on imports that have not been handled before. - - This has the drawback of making it more difficult for - non-standard modules to be put into sys.modules. Could go other - way and hyper-generalize by having a meta_path importer that - returns entries in sys.path. -* Loaders don't have to return the loaded module. - + Importing the module being imported in a circular import dependency - requires that module added to sys.modules stay consistent from the - point it is added to initialization anyway. - + Can get the module the loader was supposed to handle directly out of - sys.modules. -* Remove any idea of a default importer. - + Removes support for None entries from sys.path_importer_cache. - + Rely on default importers being in sys.path_hooks or sys.meta_path. -* Remove implicit relative import in packages when dealing with '*'. - + Would only require adding an import line for each item in __all__ that is - a module. - + Explicit is better than implicit. - + Can't entire remove without requiring ``import pkg.module as module`` - on imports instead of ``from pkg import module``. -* Any way to replace imp.acquire_lock()/release_lock() with a context manager instead? - -Rejected Ideas --------------- -* Passing in new module to loaders - Creating a new module is minimal and loader might want to use a different - type of object. - - -Use Cases -========= -PTL ---- -* Use filesystem importer and loader. -* Subclass PyPycHandler - + Set source_handles to '.ptl' and bytecode to '.ptlc'. - + code_from_source() - - Handle transforming to pure Python code here. - -sqlite3 -------- -+ DB - - Module name. - - Source code. - - Marshalled code of the source. - * Set to NULL when source code is modified, which removes need of - storing the bytecode's timestamp. - - Magic number for bytecode. - - Anything about handling packages? -+ Importer - - Query DB to see if module is listed. - - Whether it is in bytecode or source form is irrelevant. -+ Loader - - See if bytecode is in DB; if so then have that used, otherwise source. - - Implement API needed by PyPycHandler for free bytecode recreation. -+ Use PyPycHandler. - -zip importer ------------- -+ New importer -+ New loader - - Have write_data be a no-op. -+ Reuse PyPycHandler. + http://www.python.org/dev/peps/pep-0328 """ from __future__ import with_statement @@ -587,7 +494,7 @@ if loader: return loader else: - raise ImportError("%s not found on sys.meta_path" % name) + raise ImportError("No module named %s" % name) def sys_path_importer(self, path_entry): """Return the importer for the specified path. @@ -647,7 +554,7 @@ if loader: return loader else: - raise ImportError("%s not found on sys.path" % name) + raise ImportError("No module found named %s" % name) def import_module(self, name, path=None): """Import the specified module with no handling of parent modules. From python-checkins at python.org Thu Dec 14 22:50:09 2006 From: python-checkins at python.org (brett.cannon) Date: Thu, 14 Dec 2006 22:50:09 +0100 (CET) Subject: [Python-checkins] r53035 - sandbox/trunk/import_in_py/importer.py Message-ID: <20061214215009.49F171E400C@bag.python.org> Author: brett.cannon Date: Thu Dec 14 22:50:08 2006 New Revision: 53035 Modified: sandbox/trunk/import_in_py/importer.py Log: Add a context manager for the import lock. Also add notes in the docstring of what tests fail and why. Modified: sandbox/trunk/import_in_py/importer.py ============================================================================== --- sandbox/trunk/import_in_py/importer.py (original) +++ sandbox/trunk/import_in_py/importer.py Thu Dec 14 22:50:08 2006 @@ -2,7 +2,9 @@ XXX See http://docs.google.com/View?docid=dg7fctr4_4d8tdbq on current status. -References on import: +==================== +References on import +==================== * Language reference http://docs.python.org/ref/import.html * __import__ function @@ -16,7 +18,33 @@ * PEP 302: New Import Hooks http://www.python.org/dev/peps/pep-0302/ * PEP 328: Imports: Multi-line and Absolute/Relative - http://www.python.org/dev/peps/pep-0328 + http://www.python.org/dev/peps/pep-0328 + +============ +Known Issues +============ +* runpy ('-m' command-line option for Python) does not work. + + Requires get_code to be implemented for loaders. + + Uses pkgutil.get_loader which fakes a loader if __loader__ is not defined. + + New loaders do define __loader__ but not get_code, and thus dies on and + AttributeError. + + Fix + - Implement optional interface for loaders. +* warnings and stack level. + + 'warnings' assumes that the import code does not show up in the call + stack. + + Because import now in Python, import does show up in the call stack. + + Trick of specifying that going back two levels will cause the warning + to be raised in the caller for an import statement no longer holds true. + + Fixes + - Special module deprecation function. + - Code in warnings.warn to handle import case. + - Flag on warnings.warn that warning is for an import and ignore stack + level argument. + * Could also infer from type of warning. +* test_pkg + + Old-style test that compares output. + + Setting of __loader__ leads to different output. """ from __future__ import with_statement @@ -455,7 +483,20 @@ if package is not None: module.__path__ = [package] return module - + + +class ImportLockContext(object): + + """Context manager for the import lock.""" + + def __enter__(self): + """Acquire the import lock.""" + imp.acquire_lock() + + def __exit__(self, exc_type, exc_value, exc_traceback): + """Release the import lock regardless of any raised exceptions.""" + imp.release_lock() + class Import(object): @@ -733,8 +774,7 @@ raise ValueError("Empty module name") is_pkg = True if '__path__' in globals else False caller_name = globals.get('__name__') - imp.acquire_lock() - try: + with ImportLockContext(): if level and caller_name: # Handle the classic style of import: relative first, then # absolute. @@ -766,5 +806,3 @@ self.import_full_module(name) relative_name = '' if imported_name == name else name return self.return_module(imported_name, relative_name, fromlist) - finally: - imp.release_lock() From python-checkins at python.org Thu Dec 14 22:54:16 2006 From: python-checkins at python.org (brett.cannon) Date: Thu, 14 Dec 2006 22:54:16 +0100 (CET) Subject: [Python-checkins] r53036 - sandbox/trunk/import_in_py/importer.py Message-ID: <20061214215416.5DDBC1E4006@bag.python.org> Author: brett.cannon Date: Thu Dec 14 22:54:16 2006 New Revision: 53036 Modified: sandbox/trunk/import_in_py/importer.py Log: Note what tests are off because of the warnings issue. Modified: sandbox/trunk/import_in_py/importer.py ============================================================================== --- sandbox/trunk/import_in_py/importer.py (original) +++ sandbox/trunk/import_in_py/importer.py Thu Dec 14 22:54:16 2006 @@ -31,6 +31,9 @@ + Fix - Implement optional interface for loaders. * warnings and stack level. + + Affected tests + - test___all__ + - test_imageop + 'warnings' assumes that the import code does not show up in the call stack. + Because import now in Python, import does show up in the call stack. From python-checkins at python.org Fri Dec 15 01:49:36 2006 From: python-checkins at python.org (brett.cannon) Date: Fri, 15 Dec 2006 01:49:36 +0100 (CET) Subject: [Python-checkins] r53037 - sandbox/trunk/import_in_py/importer.py sandbox/trunk/import_in_py/test_importer.py Message-ID: <20061215004936.3E71F1E4006@bag.python.org> Author: brett.cannon Date: Fri Dec 15 01:49:35 2006 New Revision: 53037 Modified: sandbox/trunk/import_in_py/importer.py sandbox/trunk/import_in_py/test_importer.py Log: Some doc cleanup. Modified: sandbox/trunk/import_in_py/importer.py ============================================================================== --- sandbox/trunk/import_in_py/importer.py (original) +++ sandbox/trunk/import_in_py/importer.py Fri Dec 15 01:49:35 2006 @@ -26,9 +26,9 @@ * runpy ('-m' command-line option for Python) does not work. + Requires get_code to be implemented for loaders. + Uses pkgutil.get_loader which fakes a loader if __loader__ is not defined. - + New loaders do define __loader__ but not get_code, and thus dies on and + + New loaders do define __loader__ but not get_code, and thus dies on an AttributeError. - + Fix + + Possible fix - Implement optional interface for loaders. * warnings and stack level. + Affected tests @@ -39,7 +39,7 @@ + Because import now in Python, import does show up in the call stack. + Trick of specifying that going back two levels will cause the warning to be raised in the caller for an import statement no longer holds true. - + Fixes + + Possible fixes - Special module deprecation function. - Code in warnings.warn to handle import case. - Flag on warnings.warn that warning is for an import and ignore stack @@ -48,6 +48,7 @@ * test_pkg + Old-style test that compares output. + Setting of __loader__ leads to different output. +* PEP 235 not implemented. """ from __future__ import with_statement @@ -105,9 +106,8 @@ """Base class for meta_path importers for built-in and frozen modules. - Subclasses must provide the _find and _load methods. Both expect only the - name of the modules to import. The methods are expected to be defined on - the subclass itself and not on an instance. + Subclasses must provide the _find and _load methods. The methods are + expected to be defined on the subclass itself and not on an instance. """ @@ -378,6 +378,7 @@ is the idea of opaque code objects which are not directly touched by the handler but are passed back to the loader so as to allow for a way to keep state for the loader: + * split_path(path) Take in an opaque path object and split it into a base path and a string representing the type of the path (which should be in the @@ -404,7 +405,7 @@ module = self.new_module(mod_name) sys.modules[mod_name] = module # __file__, __path__, and __loader__ *must* be set on the module before - # any code is executed by the import. + # any code is executed by the import. __name__ is set by new_module. module.__loader__ = loader module.__file__ = path if package is not None: Modified: sandbox/trunk/import_in_py/test_importer.py ============================================================================== --- sandbox/trunk/import_in_py/test_importer.py (original) +++ sandbox/trunk/import_in_py/test_importer.py Fri Dec 15 01:49:35 2006 @@ -1,4 +1,3 @@ -from __future__ import with_statement import importer import unittest @@ -610,7 +609,28 @@ class PyPycHandlerHandleCodeTests(unittest.TestCase): - """Test PyPycHandler.handle_code().""" + """Test PyPycHandler.handle_code(). + + Various situations that must be handled (and thus tested): + * Valid .pyc + + .py exists [test_good_pyc_w_py] + + No .py . + * Invalid .pyc + + Reasons it is invalid + - Bad magic number. + * With .py [test_bad_magic_w_py] + * Without .py [test_bad_magic_no_py] + - .pyc stale based on timestamp. + * Requires .py [test_bad_timestamp_w_py] + - Bytecode is malformed. + * With .py [test_bad_bytecode_w_py] + * Without .py [test_bad_bytecode_no_py] + * No .pyc + + Valid .py + - Regenerate .pyc [test_py_w_pyc] + - Do not create .pyc [test_py_no_pyc] + + """ def test_good_pyc_w_py(self): # Test using a .pyc file that is valid and a .py file exists. @@ -1223,6 +1243,19 @@ * The proper module was returned. * All expected modules were added to sys.modules. * All modules imported by the call have the proper attributes. + + There are currently no tests for the import lock. + + Need to test (both relative and absolute imports as needed): + * import module + * import package + * import package.module + * from module import attribute + * from package import module + * from package import attribute + * from package.module import attribute + * from package import * + + With __all__ """ From python-checkins at python.org Fri Dec 15 04:59:35 2006 From: python-checkins at python.org (thomas.wouters) Date: Fri, 15 Dec 2006 04:59:35 +0100 (CET) Subject: [Python-checkins] r53038 - python/branches/p3yk-noslice Message-ID: <20061215035935.AC3651E4006@bag.python.org> Author: thomas.wouters Date: Fri Dec 15 04:59:35 2006 New Revision: 53038 Modified: python/branches/p3yk-noslice/ (props changed) Log: merge from p3yk branch, not trunk. From python-checkins at python.org Fri Dec 15 05:05:10 2006 From: python-checkins at python.org (thomas.wouters) Date: Fri, 15 Dec 2006 05:05:10 +0100 (CET) Subject: [Python-checkins] r53039 - python/branches/p3yk-noslice Message-ID: <20061215040510.C9A5C1E4006@bag.python.org> Author: thomas.wouters Date: Fri Dec 15 05:05:09 2006 New Revision: 53039 Modified: python/branches/p3yk-noslice/ (props changed) Log: Update already-merged revision to what it's supposed to be. From python-checkins at python.org Fri Dec 15 05:28:21 2006 From: python-checkins at python.org (thomas.wouters) Date: Fri, 15 Dec 2006 05:28:21 +0100 (CET) Subject: [Python-checkins] r53040 - in python/branches/p3yk-noslice: BROKEN Demo/classes/Complex.py Demo/classes/Rat.py Demo/parser/unparse.py Demo/pysvr/pysvr.py Demo/rpc/nfsclient.py Demo/rpc/xdr.py Demo/scripts/lpwatch.py Demo/scripts/primes.py Demo/scripts/update.py Demo/sockets/gopher.py Demo/sockets/rpythond.py Demo/tkinter/guido/ShellWindow.py Doc/Makefile Doc/api/concrete.tex Doc/api/exceptions.tex Doc/api/refcounts.dat Doc/dist/dist.tex Doc/ext/extending.tex Doc/howto/doanddont.tex Doc/howto/functional.rst Doc/howto/regex.tex Doc/inst/inst.tex Doc/lib/asttable.tex Doc/lib/email-unpack.py Doc/lib/libasyncore.tex Doc/lib/libatexit.tex Doc/lib/libbase64.tex Doc/lib/libbsddb.tex Doc/lib/libcfgparser.tex Doc/lib/libcommands.tex Doc/lib/libconsts.tex Doc/lib/libcsv.tex Doc/lib/libctypes.tex Doc/lib/libdatetime.tex Doc/lib/libdecimal.tex Doc/lib/libdis.tex Doc/lib/libetree.tex Doc/lib/libexcs.tex Doc/lib/libfpectl.tex Doc/lib/libfuncs.tex Doc/lib/libfunctools.tex Doc/lib/libgetopt.tex Doc/lib/libhashlib.tex Doc/lib/libheapq.tex Doc/lib/libhotshot.tex Doc/lib/libhttplib.tex Doc/lib/libimp.tex Doc/lib/libitertools.tex Doc/lib/liblogging.tex Doc/lib/libmsilib.tex Doc/lib/liboperator.tex Doc/lib/libos.tex Doc/lib/libparser.tex Doc/lib/libpdb.tex Doc/lib/libpickle.tex Doc/lib/libpopen2.tex Doc/lib/libprofile.tex Doc/lib/libpyexpat.tex Doc/lib/librexec.tex Doc/lib/libsmtplib.tex Doc/lib/libsocket.tex Doc/lib/libsqlite3.tex Doc/lib/libstdtypes.tex Doc/lib/libstdwin.tex Doc/lib/libstring.tex Doc/lib/libsubprocess.tex Doc/lib/libtempfile.tex Doc/lib/libtimeit.tex Doc/lib/libtraceback.tex Doc/lib/libunittest.tex Doc/lib/liburlparse.tex Doc/lib/libuuid.tex Doc/lib/libwinreg.tex Doc/lib/libwsgiref.tex Doc/lib/libxmlrpclib.tex Doc/lib/sqlite3/executescript.py Doc/lib/tkinter.tex Doc/perl/python.perl Doc/ref/ref2.tex Doc/ref/ref3.tex Doc/ref/ref4.tex Doc/ref/ref5.tex Doc/ref/ref6.tex Doc/ref/ref8.tex Doc/ref/reswords.py Doc/tools/py2texi.el Doc/tut/tut.tex Doc/whatsnew/whatsnew25.tex Doc/whatsnew/whatsnew26.tex Grammar/Grammar Include/Python-ast.h Include/abstract.h Include/code.h Include/eval.h Include/funcobject.h Include/graminit.h Include/iterobject.h Include/modsupport.h Include/object.h Include/opcode.h Include/pyport.h Include/symtable.h Include/token.h Lib/Bastion.py Lib/ConfigParser.py Lib/Queue.py Lib/SimpleXMLRPCServer.py Lib/StringIO.py Lib/UserDict.py Lib/UserString.py Lib/_strptime.py Lib/atexit.py Lib/base64.py Lib/bdb.py Lib/bsddb/__init__.py Lib/bsddb/dbtables.py Lib/bsddb/test/test_basics.py Lib/bsddb/test/test_compat.py Lib/bsddb/test/test_dbobj.py Lib/bsddb/test/test_dbshelve.py Lib/bsddb/test/test_recno.py Lib/bsddb/test/test_thread.py Lib/cProfile.py Lib/cgi.py Lib/code.py Lib/codecs.py Lib/colorsys.py Lib/compiler/ast.py Lib/compiler/pyassem.py Lib/compiler/pycodegen.py Lib/compiler/transformer.py Lib/ctypes/__init__.py Lib/ctypes/test/__init__.py Lib/ctypes/test/test_bitfields.py Lib/ctypes/test/test_callbacks.py Lib/ctypes/test/test_cast.py Lib/ctypes/test/test_simplesubclasses.py Lib/ctypes/test/test_structures.py Lib/ctypes/test/test_win32.py Lib/decimal.py Lib/distutils/command/bdist_rpm.py Lib/distutils/command/build_ext.py Lib/distutils/command/install_egg_info.py Lib/distutils/command/register.py Lib/distutils/command/wininst-8.exe Lib/distutils/sysconfig.py Lib/distutils/unixccompiler.py Lib/distutils/version.py Lib/doctest.py Lib/email/base64mime.py Lib/email/charset.py Lib/email/generator.py Lib/email/header.py Lib/email/message.py Lib/email/quoprimime.py Lib/email/test/test_email.py Lib/email/test/test_email_renamed.py Lib/email/utils.py Lib/encodings/__init__.py Lib/encodings/bz2_codec.py Lib/encodings/utf_8_sig.py Lib/encodings/zlib_codec.py Lib/ftplib.py Lib/functools.py Lib/genericpath.py Lib/gzip.py Lib/hashlib.py Lib/httplib.py Lib/idlelib/CodeContext.py Lib/idlelib/ColorDelegator.py Lib/idlelib/EditorWindow.py Lib/idlelib/HyperParser.py Lib/idlelib/NEWS.txt Lib/idlelib/PyShell.py Lib/idlelib/ScriptBinding.py Lib/idlelib/run.py Lib/ihooks.py Lib/imputil.py Lib/inspect.py Lib/keyword.py Lib/lib-tk/Tix.py Lib/lib-tk/Tkinter.py Lib/lib-tk/tkMessageBox.py Lib/lib-tk/tkSimpleDialog.py Lib/lib-tk/turtle.py Lib/logging/__init__.py Lib/logging/config.py Lib/logging/handlers.py Lib/macpath.py Lib/mailbox.py Lib/modulefinder.py Lib/ntpath.py Lib/opcode.py Lib/optparse.py Lib/os.py Lib/os2emxpath.py Lib/pdb.py Lib/plat-irix5/flp.py Lib/plat-irix5/panel.py Lib/plat-irix6/flp.py Lib/plat-irix6/panel.py Lib/plat-mac/FrameWork.py Lib/plat-mac/aetypes.py Lib/plat-mac/appletrawmain.py Lib/plat-mac/buildtools.py Lib/plat-mac/cfmfile.py Lib/plat-mac/gensuitemodule.py Lib/plat-mac/lib-scriptpackages/StdSuites/AppleScript_Suite.py Lib/plat-mac/macerrors.py Lib/plat-mac/pimp.py Lib/plat-mac/plistlib.py Lib/plat-riscos/riscosenviron.py Lib/plat-riscos/rourl2path.py Lib/plat-sunos5/STROPTS.py Lib/posixpath.py Lib/pprint.py Lib/profile.py Lib/pstats.py Lib/pty.py Lib/pyclbr.py Lib/pydoc.py Lib/rexec.py Lib/runpy.py Lib/sgmllib.py Lib/site.py Lib/smtplib.py Lib/socket.py Lib/sqlite3/test/types.py Lib/subprocess.py Lib/symbol.py Lib/symtable.py Lib/tarfile.py Lib/test/README Lib/test/crashers/bogus_code_obj.py Lib/test/crashers/bogus_sre_bytecode.py Lib/test/crashers/infinite_loop_re.py Lib/test/crashers/loosing_mro_ref.py Lib/test/list_tests.py Lib/test/mapping_tests.py Lib/test/output/test_MimeWriter Lib/test/output/test_cProfile Lib/test/output/test_cgi Lib/test/output/test_class Lib/test/output/test_cookie Lib/test/output/test_extcall Lib/test/output/test_global Lib/test/output/test_grammar Lib/test/output/test_httplib Lib/test/output/test_math Lib/test/output/test_mmap Lib/test/output/test_nis Lib/test/output/test_opcodes Lib/test/output/test_openpty Lib/test/output/test_poll Lib/test/output/test_profile Lib/test/output/test_regex Lib/test/output/test_scope Lib/test/output/test_tokenize Lib/test/output/test_types Lib/test/output/test_xdrlib Lib/test/outstanding_bugs.py Lib/test/pickletester.py Lib/test/sgml_input.html Lib/test/string_tests.py Lib/test/test_MimeWriter.py Lib/test/test_StringIO.py Lib/test/test___all__.py Lib/test/test___future__.py Lib/test/test_array.py Lib/test/test_ast.py Lib/test/test_binascii.py Lib/test/test_binop.py Lib/test/test_bisect.py Lib/test/test_bool.py Lib/test/test_bsddb3.py Lib/test/test_buffer.py Lib/test/test_bufio.py Lib/test/test_builtin.py Lib/test/test_bytes.py Lib/test/test_bz2.py Lib/test/test_calendar.py Lib/test/test_cfgparser.py Lib/test/test_cgi.py Lib/test/test_class.py Lib/test/test_code.py Lib/test/test_codecencodings_cn.py Lib/test/test_codecs.py Lib/test/test_codeop.py Lib/test/test_compare.py Lib/test/test_compile.py Lib/test/test_compiler.py Lib/test/test_complex_args.py Lib/test/test_contextlib.py Lib/test/test_cookie.py Lib/test/test_copy.py Lib/test/test_datetime.py Lib/test/test_dbm.py Lib/test/test_decimal.py Lib/test/test_descr.py Lib/test/test_descrtut.py Lib/test/test_dict.py Lib/test/test_dis.py Lib/test/test_doctest.py Lib/test/test_enumerate.py Lib/test/test_exceptions.py Lib/test/test_fcntl.py Lib/test/test_format.py Lib/test/test_frozen.py Lib/test/test_funcattrs.py Lib/test/test_functools.py Lib/test/test_future.py Lib/test/test_gc.py Lib/test/test_gdbm.py Lib/test/test_genericpath.py Lib/test/test_getopt.py Lib/test/test_global.py Lib/test/test_grammar.py Lib/test/test_gzip.py Lib/test/test_heapq.py Lib/test/test_httplib.py Lib/test/test_imp.py Lib/test/test_import.py Lib/test/test_importhooks.py Lib/test/test_inspect.py Lib/test/test_iter.py Lib/test/test_itertools.py Lib/test/test_keywordonlyarg.py Lib/test/test_long.py Lib/test/test_mailbox.py Lib/test/test_marshal.py Lib/test/test_math.py Lib/test/test_mmap.py Lib/test/test_modulefinder.py Lib/test/test_multibytecodec.py Lib/test/test_mutants.py Lib/test/test_new.py Lib/test/test_nis.py Lib/test/test_opcodes.py Lib/test/test_openpty.py Lib/test/test_operations.py Lib/test/test_operator.py Lib/test/test_os.py Lib/test/test_parser.py Lib/test/test_peepholer.py Lib/test/test_pep352.py Lib/test/test_poll.py Lib/test/test_pyclbr.py Lib/test/test_rfc822.py Lib/test/test_richcmp.py Lib/test/test_scope.py Lib/test/test_set.py Lib/test/test_sets.py Lib/test/test_sgmllib.py Lib/test/test_sha.py Lib/test/test_site.py Lib/test/test_slice.py Lib/test/test_socket.py Lib/test/test_sort.py Lib/test/test_structmembers.py Lib/test/test_subprocess.py Lib/test/test_support.py Lib/test/test_syntax.py Lib/test/test_tarfile.py Lib/test/test_tempfile.py Lib/test/test_time.py Lib/test/test_tokenize.py Lib/test/test_traceback.py Lib/test/test_transformer.py Lib/test/test_tuple.py Lib/test/test_types.py Lib/test/test_unicode.py Lib/test/test_unicode_file.py Lib/test/test_unpack.py Lib/test/test_urllib.py Lib/test/test_urllibnet.py Lib/test/test_userdict.py Lib/test/test_weakref.py Lib/test/test_wsgiref.py Lib/test/test_xdrlib.py Lib/test/test_xmlrpc.py Lib/test/time_hashlib.py Lib/test/tokenize_tests.txt Lib/timeit.py Lib/token.py Lib/tokenize.py Lib/trace.py Lib/traceback.py Lib/urllib.py Lib/urllib2.py Lib/uu.py Lib/uuid.py Lib/webbrowser.py Lib/wsgiref/headers.py Lib/wsgiref/simple_server.py Lib/wsgiref/util.py Lib/xdrlib.py Lib/xml/dom/minidom.py Lib/xmlrpclib.py Mac/BuildScript/build-installer.py Mac/BuildScript/scripts/postflight.documentation Mac/BuildScript/scripts/postflight.patch-profile Mac/Makefile.in Mac/PythonLauncher/FileSettings.m Mac/README Mac/Tools/fixapplepython23.py Makefile.pre.in Misc/ACKS Misc/HISTORY Misc/NEWS Misc/SpecialBuilds.txt Misc/Vim/python.vim Misc/Vim/vim_syntax.py Misc/Vim/vimrc Misc/cheatsheet Misc/python-mode.el Misc/vgrindefs Modules/_bsddb.c Modules/_ctypes/_ctypes.c Modules/_ctypes/_ctypes_test.c Modules/_ctypes/callbacks.c Modules/_ctypes/callproc.c Modules/_ctypes/cfield.c Modules/_ctypes/libffi/src/powerpc/ffi_darwin.c Modules/_ctypes/libffi/src/x86/sysv.S Modules/_ctypes/libffi_msvc/ffi.c Modules/_ctypes/libffi_msvc/ffi.h Modules/_ctypes/libffi_msvc/ffitarget.h Modules/_ctypes/libffi_msvc/win64.asm Modules/_ctypes/stgdict.c Modules/_cursesmodule.c Modules/_functoolsmodule.c Modules/_sre.c Modules/_ssl.c Modules/_testcapimodule.c Modules/almodule.c Modules/arraymodule.c Modules/audioop.c Modules/binascii.c Modules/bz2module.c Modules/cPickle.c Modules/cStringIO.c Modules/cgen.py Modules/cjkcodecs/_codecs_cn.c Modules/cjkcodecs/_codecs_iso2022.c Modules/cjkcodecs/cjkcodecs.h Modules/datetimemodule.c Modules/dbmmodule.c Modules/gcmodule.c Modules/itertoolsmodule.c Modules/linuxaudiodev.c Modules/main.c Modules/mathmodule.c Modules/mmapmodule.c Modules/ossaudiodev.c Modules/parsermodule.c Modules/posixmodule.c Modules/pyexpat.c Modules/readline.c Modules/resource.c Modules/socketmodule.c Modules/socketmodule.h Modules/symtablemodule.c Modules/threadmodule.c Modules/unicodedata.c Objects/abstract.c Objects/boolobject.c Objects/bufferobject.c Objects/bytesobject.c Objects/cellobject.c Objects/classobject.c Objects/codeobject.c Objects/complexobject.c Objects/dictobject.c Objects/exceptions.c Objects/fileobject.c Objects/floatobject.c Objects/funcobject.c Objects/intobject.c Objects/iterobject.c Objects/listobject.c Objects/longobject.c Objects/methodobject.c Objects/object.c Objects/obmalloc.c Objects/setobject.c Objects/sliceobject.c Objects/stringlib/partition.h Objects/stringobject.c Objects/tupleobject.c Objects/typeobject.c Objects/unicodeobject.c Objects/weakrefobject.c PC/VC6/_bsddb.dsp PC/VC6/_ctypes.dsp PC/VC6/_ctypes_test.dsp PC/VC6/_elementtree.dsp PC/VC6/_socket.dsp PC/VC6/_sqlite3.dsp PC/VC6/_ssl.dsp PC/VC6/_ssl.mak PC/VC6/_testcapi.dsp PC/VC6/_tkinter.dsp PC/VC6/bz2.dsp PC/VC6/make_versioninfo.dsp PC/VC6/pcbuild.dsw PC/VC6/pyexpat.dsp PC/VC6/python.dsp PC/VC6/pythoncore.dsp PC/VC6/pythonw.dsp PC/VC6/readme.txt PC/VC6/select.dsp PC/VC6/unicodedata.dsp PC/VC6/w9xpopen.dsp PC/VC6/winsound.dsp PC/VC6/zlib.dsp PC/_msi.c PC/_winreg.c PC/bdist_wininst/wininst-8.sln PC/bdist_wininst/wininst-8.vcproj PC/example_nt/example.vcproj PC/pyconfig.h PCbuild/_ctypes.vcproj PCbuild/amd64_ml64.bat PCbuild/pythoncore.vcproj PCbuild8/_ctypes.vcproj PCbuild8/_ctypes_test.vcproj PCbuild8/_elementtree.vcproj PCbuild8/_msi.vcproj PCbuild8/_sqlite3.vcproj PCbuild8/make_buildinfo.c PCbuild8/make_buildinfo.vcproj PCbuild8/pcbuild.sln PCbuild8/python.vcproj PCbuild8/pythoncore.vcproj PCbuild8/pythoncore_pgo.vcproj PCbuild8/pythoncore_pgo_link.txt PCbuild8/pythonw.vcproj PCbuild8/readme.txt PCbuild8/select.vcproj PCbuild8/unicodedata.vcproj PCbuild8/w9xpopen.vcproj PCbuild8/winsound.vcproj Parser/Python.asdl Parser/asdl.py Parser/asdl_c.py Parser/parser.c Parser/parsetok.c Parser/tokenizer.c Python/Python-ast.c Python/ast.c Python/bltinmodule.c Python/ceval.c Python/compile.c Python/errors.c Python/frozen.c Python/getargs.c Python/graminit.c Python/import.c Python/marshal.c Python/modsupport.c Python/mystrtoul.c Python/peephole.c Python/pystate.c Python/pythonrun.c Python/structmember.c Python/symtable.c Python/sysmodule.c README Tools/compiler/ast.txt Tools/compiler/astgen.py Tools/modulator/modulator.py Tools/msi/msi.py Tools/msi/uuids.py Tools/pybench/pybench.py Tools/scripts/byext.py Tools/scripts/findnocoding.py Tools/scripts/fixdiv.py Tools/scripts/h2py.py Tools/scripts/pysource.py configure configure.in pyconfig.h.in setup.py Message-ID: <20061215042821.9CE5B1E4006@bag.python.org> Author: thomas.wouters Date: Fri Dec 15 05:21:50 2006 New Revision: 53040 Added: python/branches/p3yk-noslice/Doc/howto/functional.rst - copied unchanged from r53019, python/branches/p3yk/Doc/howto/functional.rst python/branches/p3yk-noslice/Doc/whatsnew/whatsnew26.tex - copied unchanged from r53019, python/branches/p3yk/Doc/whatsnew/whatsnew26.tex python/branches/p3yk-noslice/Lib/distutils/command/wininst-8.exe - copied unchanged from r53019, python/branches/p3yk/Lib/distutils/command/wininst-8.exe python/branches/p3yk-noslice/Lib/genericpath.py - copied unchanged from r53019, python/branches/p3yk/Lib/genericpath.py python/branches/p3yk-noslice/Lib/test/crashers/bogus_sre_bytecode.py - copied unchanged from r53019, python/branches/p3yk/Lib/test/crashers/bogus_sre_bytecode.py python/branches/p3yk-noslice/Lib/test/crashers/infinite_loop_re.py - copied unchanged from r53019, python/branches/p3yk/Lib/test/crashers/infinite_loop_re.py python/branches/p3yk-noslice/Lib/test/crashers/loosing_mro_ref.py - copied unchanged from r53019, python/branches/p3yk/Lib/test/crashers/loosing_mro_ref.py python/branches/p3yk-noslice/Lib/test/sgml_input.html - copied unchanged from r53019, python/branches/p3yk/Lib/test/sgml_input.html python/branches/p3yk-noslice/Lib/test/test_buffer.py - copied unchanged from r53019, python/branches/p3yk/Lib/test/test_buffer.py python/branches/p3yk-noslice/Lib/test/test_complex_args.py - copied unchanged from r53019, python/branches/p3yk/Lib/test/test_complex_args.py python/branches/p3yk-noslice/Lib/test/test_genericpath.py - copied unchanged from r53019, python/branches/p3yk/Lib/test/test_genericpath.py python/branches/p3yk-noslice/Lib/test/test_keywordonlyarg.py - copied unchanged from r53019, python/branches/p3yk/Lib/test/test_keywordonlyarg.py python/branches/p3yk-noslice/Lib/test/test_modulefinder.py - copied unchanged from r53019, python/branches/p3yk/Lib/test/test_modulefinder.py python/branches/p3yk-noslice/Lib/test/test_structmembers.py - copied unchanged from r53019, python/branches/p3yk/Lib/test/test_structmembers.py python/branches/p3yk-noslice/Modules/_ctypes/libffi_msvc/win64.asm - copied unchanged from r53019, python/branches/p3yk/Modules/_ctypes/libffi_msvc/win64.asm python/branches/p3yk-noslice/PC/VC6/_ctypes.dsp - copied unchanged from r53019, python/branches/p3yk/PC/VC6/_ctypes.dsp python/branches/p3yk-noslice/PC/VC6/_ctypes_test.dsp - copied unchanged from r53019, python/branches/p3yk/PC/VC6/_ctypes_test.dsp python/branches/p3yk-noslice/PC/VC6/_elementtree.dsp - copied unchanged from r53019, python/branches/p3yk/PC/VC6/_elementtree.dsp python/branches/p3yk-noslice/PC/VC6/_sqlite3.dsp - copied unchanged from r53019, python/branches/p3yk/PC/VC6/_sqlite3.dsp python/branches/p3yk-noslice/PC/bdist_wininst/wininst-8.sln - copied unchanged from r53019, python/branches/p3yk/PC/bdist_wininst/wininst-8.sln python/branches/p3yk-noslice/PC/bdist_wininst/wininst-8.vcproj - copied unchanged from r53019, python/branches/p3yk/PC/bdist_wininst/wininst-8.vcproj python/branches/p3yk-noslice/PCbuild/amd64_ml64.bat - copied unchanged from r53019, python/branches/p3yk/PCbuild/amd64_ml64.bat Removed: python/branches/p3yk-noslice/BROKEN python/branches/p3yk-noslice/Lib/test/output/test_MimeWriter python/branches/p3yk-noslice/Lib/test/output/test_cgi python/branches/p3yk-noslice/Lib/test/output/test_cookie python/branches/p3yk-noslice/Lib/test/output/test_global python/branches/p3yk-noslice/Lib/test/output/test_grammar python/branches/p3yk-noslice/Lib/test/output/test_httplib python/branches/p3yk-noslice/Lib/test/output/test_math python/branches/p3yk-noslice/Lib/test/output/test_mmap python/branches/p3yk-noslice/Lib/test/output/test_nis python/branches/p3yk-noslice/Lib/test/output/test_opcodes python/branches/p3yk-noslice/Lib/test/output/test_openpty python/branches/p3yk-noslice/Lib/test/output/test_poll python/branches/p3yk-noslice/Lib/test/output/test_regex python/branches/p3yk-noslice/Lib/test/output/test_scope python/branches/p3yk-noslice/Lib/test/output/test_types python/branches/p3yk-noslice/Lib/test/output/test_xdrlib python/branches/p3yk-noslice/PC/VC6/zlib.dsp python/branches/p3yk-noslice/PCbuild8/pythoncore_pgo.vcproj python/branches/p3yk-noslice/PCbuild8/pythoncore_pgo_link.txt Modified: python/branches/p3yk-noslice/ (props changed) python/branches/p3yk-noslice/Demo/classes/Complex.py python/branches/p3yk-noslice/Demo/classes/Rat.py python/branches/p3yk-noslice/Demo/parser/unparse.py python/branches/p3yk-noslice/Demo/pysvr/pysvr.py python/branches/p3yk-noslice/Demo/rpc/nfsclient.py python/branches/p3yk-noslice/Demo/rpc/xdr.py python/branches/p3yk-noslice/Demo/scripts/lpwatch.py python/branches/p3yk-noslice/Demo/scripts/primes.py python/branches/p3yk-noslice/Demo/scripts/update.py python/branches/p3yk-noslice/Demo/sockets/gopher.py python/branches/p3yk-noslice/Demo/sockets/rpythond.py python/branches/p3yk-noslice/Demo/tkinter/guido/ShellWindow.py python/branches/p3yk-noslice/Doc/Makefile python/branches/p3yk-noslice/Doc/api/concrete.tex python/branches/p3yk-noslice/Doc/api/exceptions.tex python/branches/p3yk-noslice/Doc/api/refcounts.dat python/branches/p3yk-noslice/Doc/dist/dist.tex python/branches/p3yk-noslice/Doc/ext/extending.tex python/branches/p3yk-noslice/Doc/howto/doanddont.tex python/branches/p3yk-noslice/Doc/howto/regex.tex python/branches/p3yk-noslice/Doc/inst/inst.tex python/branches/p3yk-noslice/Doc/lib/asttable.tex python/branches/p3yk-noslice/Doc/lib/email-unpack.py python/branches/p3yk-noslice/Doc/lib/libasyncore.tex python/branches/p3yk-noslice/Doc/lib/libatexit.tex python/branches/p3yk-noslice/Doc/lib/libbase64.tex python/branches/p3yk-noslice/Doc/lib/libbsddb.tex python/branches/p3yk-noslice/Doc/lib/libcfgparser.tex python/branches/p3yk-noslice/Doc/lib/libcommands.tex python/branches/p3yk-noslice/Doc/lib/libconsts.tex python/branches/p3yk-noslice/Doc/lib/libcsv.tex python/branches/p3yk-noslice/Doc/lib/libctypes.tex python/branches/p3yk-noslice/Doc/lib/libdatetime.tex python/branches/p3yk-noslice/Doc/lib/libdecimal.tex python/branches/p3yk-noslice/Doc/lib/libdis.tex python/branches/p3yk-noslice/Doc/lib/libetree.tex python/branches/p3yk-noslice/Doc/lib/libexcs.tex python/branches/p3yk-noslice/Doc/lib/libfpectl.tex python/branches/p3yk-noslice/Doc/lib/libfuncs.tex python/branches/p3yk-noslice/Doc/lib/libfunctools.tex python/branches/p3yk-noslice/Doc/lib/libgetopt.tex python/branches/p3yk-noslice/Doc/lib/libhashlib.tex python/branches/p3yk-noslice/Doc/lib/libheapq.tex python/branches/p3yk-noslice/Doc/lib/libhotshot.tex python/branches/p3yk-noslice/Doc/lib/libhttplib.tex python/branches/p3yk-noslice/Doc/lib/libimp.tex python/branches/p3yk-noslice/Doc/lib/libitertools.tex python/branches/p3yk-noslice/Doc/lib/liblogging.tex python/branches/p3yk-noslice/Doc/lib/libmsilib.tex python/branches/p3yk-noslice/Doc/lib/liboperator.tex python/branches/p3yk-noslice/Doc/lib/libos.tex python/branches/p3yk-noslice/Doc/lib/libparser.tex python/branches/p3yk-noslice/Doc/lib/libpdb.tex python/branches/p3yk-noslice/Doc/lib/libpickle.tex python/branches/p3yk-noslice/Doc/lib/libpopen2.tex python/branches/p3yk-noslice/Doc/lib/libprofile.tex python/branches/p3yk-noslice/Doc/lib/libpyexpat.tex python/branches/p3yk-noslice/Doc/lib/librexec.tex python/branches/p3yk-noslice/Doc/lib/libsmtplib.tex python/branches/p3yk-noslice/Doc/lib/libsocket.tex python/branches/p3yk-noslice/Doc/lib/libsqlite3.tex python/branches/p3yk-noslice/Doc/lib/libstdtypes.tex python/branches/p3yk-noslice/Doc/lib/libstdwin.tex python/branches/p3yk-noslice/Doc/lib/libstring.tex python/branches/p3yk-noslice/Doc/lib/libsubprocess.tex python/branches/p3yk-noslice/Doc/lib/libtempfile.tex python/branches/p3yk-noslice/Doc/lib/libtimeit.tex python/branches/p3yk-noslice/Doc/lib/libtraceback.tex python/branches/p3yk-noslice/Doc/lib/libunittest.tex python/branches/p3yk-noslice/Doc/lib/liburlparse.tex python/branches/p3yk-noslice/Doc/lib/libuuid.tex python/branches/p3yk-noslice/Doc/lib/libwinreg.tex python/branches/p3yk-noslice/Doc/lib/libwsgiref.tex python/branches/p3yk-noslice/Doc/lib/libxmlrpclib.tex python/branches/p3yk-noslice/Doc/lib/sqlite3/executescript.py python/branches/p3yk-noslice/Doc/lib/tkinter.tex python/branches/p3yk-noslice/Doc/perl/python.perl python/branches/p3yk-noslice/Doc/ref/ref2.tex python/branches/p3yk-noslice/Doc/ref/ref3.tex python/branches/p3yk-noslice/Doc/ref/ref4.tex python/branches/p3yk-noslice/Doc/ref/ref5.tex python/branches/p3yk-noslice/Doc/ref/ref6.tex python/branches/p3yk-noslice/Doc/ref/ref8.tex python/branches/p3yk-noslice/Doc/ref/reswords.py python/branches/p3yk-noslice/Doc/tools/py2texi.el python/branches/p3yk-noslice/Doc/tut/tut.tex python/branches/p3yk-noslice/Doc/whatsnew/whatsnew25.tex python/branches/p3yk-noslice/Grammar/Grammar python/branches/p3yk-noslice/Include/Python-ast.h python/branches/p3yk-noslice/Include/abstract.h python/branches/p3yk-noslice/Include/code.h python/branches/p3yk-noslice/Include/eval.h python/branches/p3yk-noslice/Include/funcobject.h python/branches/p3yk-noslice/Include/graminit.h python/branches/p3yk-noslice/Include/iterobject.h python/branches/p3yk-noslice/Include/modsupport.h python/branches/p3yk-noslice/Include/object.h python/branches/p3yk-noslice/Include/opcode.h python/branches/p3yk-noslice/Include/pyport.h python/branches/p3yk-noslice/Include/symtable.h python/branches/p3yk-noslice/Include/token.h python/branches/p3yk-noslice/Lib/Bastion.py python/branches/p3yk-noslice/Lib/ConfigParser.py python/branches/p3yk-noslice/Lib/Queue.py python/branches/p3yk-noslice/Lib/SimpleXMLRPCServer.py python/branches/p3yk-noslice/Lib/StringIO.py python/branches/p3yk-noslice/Lib/UserDict.py python/branches/p3yk-noslice/Lib/UserString.py python/branches/p3yk-noslice/Lib/_strptime.py python/branches/p3yk-noslice/Lib/atexit.py python/branches/p3yk-noslice/Lib/base64.py python/branches/p3yk-noslice/Lib/bdb.py python/branches/p3yk-noslice/Lib/bsddb/__init__.py python/branches/p3yk-noslice/Lib/bsddb/dbtables.py python/branches/p3yk-noslice/Lib/bsddb/test/test_basics.py python/branches/p3yk-noslice/Lib/bsddb/test/test_compat.py python/branches/p3yk-noslice/Lib/bsddb/test/test_dbobj.py python/branches/p3yk-noslice/Lib/bsddb/test/test_dbshelve.py python/branches/p3yk-noslice/Lib/bsddb/test/test_recno.py python/branches/p3yk-noslice/Lib/bsddb/test/test_thread.py python/branches/p3yk-noslice/Lib/cProfile.py python/branches/p3yk-noslice/Lib/cgi.py python/branches/p3yk-noslice/Lib/code.py python/branches/p3yk-noslice/Lib/codecs.py python/branches/p3yk-noslice/Lib/colorsys.py python/branches/p3yk-noslice/Lib/compiler/ast.py python/branches/p3yk-noslice/Lib/compiler/pyassem.py python/branches/p3yk-noslice/Lib/compiler/pycodegen.py python/branches/p3yk-noslice/Lib/compiler/transformer.py python/branches/p3yk-noslice/Lib/ctypes/__init__.py python/branches/p3yk-noslice/Lib/ctypes/test/__init__.py python/branches/p3yk-noslice/Lib/ctypes/test/test_bitfields.py python/branches/p3yk-noslice/Lib/ctypes/test/test_callbacks.py python/branches/p3yk-noslice/Lib/ctypes/test/test_cast.py python/branches/p3yk-noslice/Lib/ctypes/test/test_simplesubclasses.py python/branches/p3yk-noslice/Lib/ctypes/test/test_structures.py python/branches/p3yk-noslice/Lib/ctypes/test/test_win32.py python/branches/p3yk-noslice/Lib/decimal.py python/branches/p3yk-noslice/Lib/distutils/command/bdist_rpm.py python/branches/p3yk-noslice/Lib/distutils/command/build_ext.py python/branches/p3yk-noslice/Lib/distutils/command/install_egg_info.py python/branches/p3yk-noslice/Lib/distutils/command/register.py python/branches/p3yk-noslice/Lib/distutils/sysconfig.py python/branches/p3yk-noslice/Lib/distutils/unixccompiler.py python/branches/p3yk-noslice/Lib/distutils/version.py python/branches/p3yk-noslice/Lib/doctest.py python/branches/p3yk-noslice/Lib/email/base64mime.py python/branches/p3yk-noslice/Lib/email/charset.py python/branches/p3yk-noslice/Lib/email/generator.py python/branches/p3yk-noslice/Lib/email/header.py python/branches/p3yk-noslice/Lib/email/message.py python/branches/p3yk-noslice/Lib/email/quoprimime.py python/branches/p3yk-noslice/Lib/email/test/test_email.py python/branches/p3yk-noslice/Lib/email/test/test_email_renamed.py python/branches/p3yk-noslice/Lib/email/utils.py python/branches/p3yk-noslice/Lib/encodings/__init__.py python/branches/p3yk-noslice/Lib/encodings/bz2_codec.py python/branches/p3yk-noslice/Lib/encodings/utf_8_sig.py python/branches/p3yk-noslice/Lib/encodings/zlib_codec.py python/branches/p3yk-noslice/Lib/ftplib.py python/branches/p3yk-noslice/Lib/functools.py python/branches/p3yk-noslice/Lib/gzip.py python/branches/p3yk-noslice/Lib/hashlib.py python/branches/p3yk-noslice/Lib/httplib.py python/branches/p3yk-noslice/Lib/idlelib/CodeContext.py python/branches/p3yk-noslice/Lib/idlelib/ColorDelegator.py python/branches/p3yk-noslice/Lib/idlelib/EditorWindow.py python/branches/p3yk-noslice/Lib/idlelib/HyperParser.py python/branches/p3yk-noslice/Lib/idlelib/NEWS.txt python/branches/p3yk-noslice/Lib/idlelib/PyShell.py python/branches/p3yk-noslice/Lib/idlelib/ScriptBinding.py python/branches/p3yk-noslice/Lib/idlelib/run.py python/branches/p3yk-noslice/Lib/ihooks.py python/branches/p3yk-noslice/Lib/imputil.py python/branches/p3yk-noslice/Lib/inspect.py python/branches/p3yk-noslice/Lib/keyword.py python/branches/p3yk-noslice/Lib/lib-tk/Tix.py python/branches/p3yk-noslice/Lib/lib-tk/Tkinter.py python/branches/p3yk-noslice/Lib/lib-tk/tkMessageBox.py python/branches/p3yk-noslice/Lib/lib-tk/tkSimpleDialog.py python/branches/p3yk-noslice/Lib/lib-tk/turtle.py python/branches/p3yk-noslice/Lib/logging/__init__.py python/branches/p3yk-noslice/Lib/logging/config.py python/branches/p3yk-noslice/Lib/logging/handlers.py python/branches/p3yk-noslice/Lib/macpath.py python/branches/p3yk-noslice/Lib/mailbox.py python/branches/p3yk-noslice/Lib/modulefinder.py python/branches/p3yk-noslice/Lib/ntpath.py python/branches/p3yk-noslice/Lib/opcode.py python/branches/p3yk-noslice/Lib/optparse.py python/branches/p3yk-noslice/Lib/os.py python/branches/p3yk-noslice/Lib/os2emxpath.py python/branches/p3yk-noslice/Lib/pdb.py python/branches/p3yk-noslice/Lib/plat-irix5/flp.py python/branches/p3yk-noslice/Lib/plat-irix5/panel.py python/branches/p3yk-noslice/Lib/plat-irix6/flp.py python/branches/p3yk-noslice/Lib/plat-irix6/panel.py python/branches/p3yk-noslice/Lib/plat-mac/FrameWork.py python/branches/p3yk-noslice/Lib/plat-mac/aetypes.py python/branches/p3yk-noslice/Lib/plat-mac/appletrawmain.py python/branches/p3yk-noslice/Lib/plat-mac/buildtools.py python/branches/p3yk-noslice/Lib/plat-mac/cfmfile.py python/branches/p3yk-noslice/Lib/plat-mac/gensuitemodule.py python/branches/p3yk-noslice/Lib/plat-mac/lib-scriptpackages/StdSuites/AppleScript_Suite.py python/branches/p3yk-noslice/Lib/plat-mac/macerrors.py python/branches/p3yk-noslice/Lib/plat-mac/pimp.py python/branches/p3yk-noslice/Lib/plat-mac/plistlib.py python/branches/p3yk-noslice/Lib/plat-riscos/riscosenviron.py python/branches/p3yk-noslice/Lib/plat-riscos/rourl2path.py python/branches/p3yk-noslice/Lib/plat-sunos5/STROPTS.py python/branches/p3yk-noslice/Lib/posixpath.py python/branches/p3yk-noslice/Lib/pprint.py python/branches/p3yk-noslice/Lib/profile.py python/branches/p3yk-noslice/Lib/pstats.py python/branches/p3yk-noslice/Lib/pty.py python/branches/p3yk-noslice/Lib/pyclbr.py python/branches/p3yk-noslice/Lib/pydoc.py python/branches/p3yk-noslice/Lib/rexec.py python/branches/p3yk-noslice/Lib/runpy.py python/branches/p3yk-noslice/Lib/sgmllib.py python/branches/p3yk-noslice/Lib/site.py python/branches/p3yk-noslice/Lib/smtplib.py python/branches/p3yk-noslice/Lib/socket.py python/branches/p3yk-noslice/Lib/sqlite3/test/types.py python/branches/p3yk-noslice/Lib/subprocess.py python/branches/p3yk-noslice/Lib/symbol.py python/branches/p3yk-noslice/Lib/symtable.py python/branches/p3yk-noslice/Lib/tarfile.py python/branches/p3yk-noslice/Lib/test/README python/branches/p3yk-noslice/Lib/test/crashers/bogus_code_obj.py python/branches/p3yk-noslice/Lib/test/list_tests.py python/branches/p3yk-noslice/Lib/test/mapping_tests.py python/branches/p3yk-noslice/Lib/test/output/test_cProfile python/branches/p3yk-noslice/Lib/test/output/test_class python/branches/p3yk-noslice/Lib/test/output/test_extcall python/branches/p3yk-noslice/Lib/test/output/test_profile python/branches/p3yk-noslice/Lib/test/output/test_tokenize python/branches/p3yk-noslice/Lib/test/outstanding_bugs.py python/branches/p3yk-noslice/Lib/test/pickletester.py python/branches/p3yk-noslice/Lib/test/string_tests.py python/branches/p3yk-noslice/Lib/test/test_MimeWriter.py python/branches/p3yk-noslice/Lib/test/test_StringIO.py python/branches/p3yk-noslice/Lib/test/test___all__.py python/branches/p3yk-noslice/Lib/test/test___future__.py python/branches/p3yk-noslice/Lib/test/test_array.py python/branches/p3yk-noslice/Lib/test/test_ast.py python/branches/p3yk-noslice/Lib/test/test_binascii.py python/branches/p3yk-noslice/Lib/test/test_binop.py python/branches/p3yk-noslice/Lib/test/test_bisect.py python/branches/p3yk-noslice/Lib/test/test_bool.py python/branches/p3yk-noslice/Lib/test/test_bsddb3.py python/branches/p3yk-noslice/Lib/test/test_bufio.py python/branches/p3yk-noslice/Lib/test/test_builtin.py python/branches/p3yk-noslice/Lib/test/test_bytes.py python/branches/p3yk-noslice/Lib/test/test_bz2.py python/branches/p3yk-noslice/Lib/test/test_calendar.py python/branches/p3yk-noslice/Lib/test/test_cfgparser.py python/branches/p3yk-noslice/Lib/test/test_cgi.py python/branches/p3yk-noslice/Lib/test/test_class.py python/branches/p3yk-noslice/Lib/test/test_code.py python/branches/p3yk-noslice/Lib/test/test_codecencodings_cn.py python/branches/p3yk-noslice/Lib/test/test_codecs.py python/branches/p3yk-noslice/Lib/test/test_codeop.py python/branches/p3yk-noslice/Lib/test/test_compare.py python/branches/p3yk-noslice/Lib/test/test_compile.py python/branches/p3yk-noslice/Lib/test/test_compiler.py python/branches/p3yk-noslice/Lib/test/test_contextlib.py python/branches/p3yk-noslice/Lib/test/test_cookie.py python/branches/p3yk-noslice/Lib/test/test_copy.py python/branches/p3yk-noslice/Lib/test/test_datetime.py python/branches/p3yk-noslice/Lib/test/test_dbm.py python/branches/p3yk-noslice/Lib/test/test_decimal.py python/branches/p3yk-noslice/Lib/test/test_descr.py python/branches/p3yk-noslice/Lib/test/test_descrtut.py python/branches/p3yk-noslice/Lib/test/test_dict.py python/branches/p3yk-noslice/Lib/test/test_dis.py python/branches/p3yk-noslice/Lib/test/test_doctest.py python/branches/p3yk-noslice/Lib/test/test_enumerate.py python/branches/p3yk-noslice/Lib/test/test_exceptions.py python/branches/p3yk-noslice/Lib/test/test_fcntl.py python/branches/p3yk-noslice/Lib/test/test_format.py python/branches/p3yk-noslice/Lib/test/test_frozen.py python/branches/p3yk-noslice/Lib/test/test_funcattrs.py python/branches/p3yk-noslice/Lib/test/test_functools.py python/branches/p3yk-noslice/Lib/test/test_future.py python/branches/p3yk-noslice/Lib/test/test_gc.py python/branches/p3yk-noslice/Lib/test/test_gdbm.py python/branches/p3yk-noslice/Lib/test/test_getopt.py python/branches/p3yk-noslice/Lib/test/test_global.py python/branches/p3yk-noslice/Lib/test/test_grammar.py python/branches/p3yk-noslice/Lib/test/test_gzip.py python/branches/p3yk-noslice/Lib/test/test_heapq.py python/branches/p3yk-noslice/Lib/test/test_httplib.py python/branches/p3yk-noslice/Lib/test/test_imp.py python/branches/p3yk-noslice/Lib/test/test_import.py python/branches/p3yk-noslice/Lib/test/test_importhooks.py python/branches/p3yk-noslice/Lib/test/test_inspect.py python/branches/p3yk-noslice/Lib/test/test_iter.py python/branches/p3yk-noslice/Lib/test/test_itertools.py python/branches/p3yk-noslice/Lib/test/test_long.py python/branches/p3yk-noslice/Lib/test/test_mailbox.py python/branches/p3yk-noslice/Lib/test/test_marshal.py python/branches/p3yk-noslice/Lib/test/test_math.py python/branches/p3yk-noslice/Lib/test/test_mmap.py python/branches/p3yk-noslice/Lib/test/test_multibytecodec.py python/branches/p3yk-noslice/Lib/test/test_mutants.py python/branches/p3yk-noslice/Lib/test/test_new.py python/branches/p3yk-noslice/Lib/test/test_nis.py python/branches/p3yk-noslice/Lib/test/test_opcodes.py python/branches/p3yk-noslice/Lib/test/test_openpty.py python/branches/p3yk-noslice/Lib/test/test_operations.py python/branches/p3yk-noslice/Lib/test/test_operator.py python/branches/p3yk-noslice/Lib/test/test_os.py python/branches/p3yk-noslice/Lib/test/test_parser.py python/branches/p3yk-noslice/Lib/test/test_peepholer.py python/branches/p3yk-noslice/Lib/test/test_pep352.py python/branches/p3yk-noslice/Lib/test/test_poll.py python/branches/p3yk-noslice/Lib/test/test_pyclbr.py python/branches/p3yk-noslice/Lib/test/test_rfc822.py python/branches/p3yk-noslice/Lib/test/test_richcmp.py python/branches/p3yk-noslice/Lib/test/test_scope.py python/branches/p3yk-noslice/Lib/test/test_set.py python/branches/p3yk-noslice/Lib/test/test_sets.py python/branches/p3yk-noslice/Lib/test/test_sgmllib.py python/branches/p3yk-noslice/Lib/test/test_sha.py python/branches/p3yk-noslice/Lib/test/test_site.py python/branches/p3yk-noslice/Lib/test/test_slice.py python/branches/p3yk-noslice/Lib/test/test_socket.py python/branches/p3yk-noslice/Lib/test/test_sort.py python/branches/p3yk-noslice/Lib/test/test_subprocess.py python/branches/p3yk-noslice/Lib/test/test_support.py python/branches/p3yk-noslice/Lib/test/test_syntax.py python/branches/p3yk-noslice/Lib/test/test_tarfile.py python/branches/p3yk-noslice/Lib/test/test_tempfile.py python/branches/p3yk-noslice/Lib/test/test_time.py python/branches/p3yk-noslice/Lib/test/test_tokenize.py python/branches/p3yk-noslice/Lib/test/test_traceback.py python/branches/p3yk-noslice/Lib/test/test_transformer.py python/branches/p3yk-noslice/Lib/test/test_tuple.py python/branches/p3yk-noslice/Lib/test/test_types.py python/branches/p3yk-noslice/Lib/test/test_unicode.py python/branches/p3yk-noslice/Lib/test/test_unicode_file.py python/branches/p3yk-noslice/Lib/test/test_unpack.py python/branches/p3yk-noslice/Lib/test/test_urllib.py python/branches/p3yk-noslice/Lib/test/test_urllibnet.py python/branches/p3yk-noslice/Lib/test/test_userdict.py python/branches/p3yk-noslice/Lib/test/test_weakref.py python/branches/p3yk-noslice/Lib/test/test_wsgiref.py python/branches/p3yk-noslice/Lib/test/test_xdrlib.py python/branches/p3yk-noslice/Lib/test/test_xmlrpc.py python/branches/p3yk-noslice/Lib/test/time_hashlib.py python/branches/p3yk-noslice/Lib/test/tokenize_tests.txt python/branches/p3yk-noslice/Lib/timeit.py python/branches/p3yk-noslice/Lib/token.py python/branches/p3yk-noslice/Lib/tokenize.py python/branches/p3yk-noslice/Lib/trace.py python/branches/p3yk-noslice/Lib/traceback.py python/branches/p3yk-noslice/Lib/urllib.py python/branches/p3yk-noslice/Lib/urllib2.py python/branches/p3yk-noslice/Lib/uu.py python/branches/p3yk-noslice/Lib/uuid.py python/branches/p3yk-noslice/Lib/webbrowser.py python/branches/p3yk-noslice/Lib/wsgiref/headers.py python/branches/p3yk-noslice/Lib/wsgiref/simple_server.py python/branches/p3yk-noslice/Lib/wsgiref/util.py python/branches/p3yk-noslice/Lib/xdrlib.py python/branches/p3yk-noslice/Lib/xml/dom/minidom.py python/branches/p3yk-noslice/Lib/xmlrpclib.py python/branches/p3yk-noslice/Mac/BuildScript/build-installer.py python/branches/p3yk-noslice/Mac/BuildScript/scripts/postflight.documentation python/branches/p3yk-noslice/Mac/BuildScript/scripts/postflight.patch-profile python/branches/p3yk-noslice/Mac/Makefile.in python/branches/p3yk-noslice/Mac/PythonLauncher/FileSettings.m python/branches/p3yk-noslice/Mac/README python/branches/p3yk-noslice/Mac/Tools/fixapplepython23.py python/branches/p3yk-noslice/Makefile.pre.in python/branches/p3yk-noslice/Misc/ACKS python/branches/p3yk-noslice/Misc/HISTORY python/branches/p3yk-noslice/Misc/NEWS python/branches/p3yk-noslice/Misc/SpecialBuilds.txt python/branches/p3yk-noslice/Misc/Vim/python.vim python/branches/p3yk-noslice/Misc/Vim/vim_syntax.py python/branches/p3yk-noslice/Misc/Vim/vimrc python/branches/p3yk-noslice/Misc/cheatsheet python/branches/p3yk-noslice/Misc/python-mode.el python/branches/p3yk-noslice/Misc/vgrindefs python/branches/p3yk-noslice/Modules/_bsddb.c python/branches/p3yk-noslice/Modules/_ctypes/_ctypes.c python/branches/p3yk-noslice/Modules/_ctypes/_ctypes_test.c python/branches/p3yk-noslice/Modules/_ctypes/callbacks.c python/branches/p3yk-noslice/Modules/_ctypes/callproc.c python/branches/p3yk-noslice/Modules/_ctypes/cfield.c python/branches/p3yk-noslice/Modules/_ctypes/libffi/src/powerpc/ffi_darwin.c python/branches/p3yk-noslice/Modules/_ctypes/libffi/src/x86/sysv.S python/branches/p3yk-noslice/Modules/_ctypes/libffi_msvc/ffi.c python/branches/p3yk-noslice/Modules/_ctypes/libffi_msvc/ffi.h python/branches/p3yk-noslice/Modules/_ctypes/libffi_msvc/ffitarget.h python/branches/p3yk-noslice/Modules/_ctypes/stgdict.c python/branches/p3yk-noslice/Modules/_cursesmodule.c python/branches/p3yk-noslice/Modules/_functoolsmodule.c python/branches/p3yk-noslice/Modules/_sre.c python/branches/p3yk-noslice/Modules/_ssl.c python/branches/p3yk-noslice/Modules/_testcapimodule.c python/branches/p3yk-noslice/Modules/almodule.c python/branches/p3yk-noslice/Modules/arraymodule.c python/branches/p3yk-noslice/Modules/audioop.c python/branches/p3yk-noslice/Modules/binascii.c python/branches/p3yk-noslice/Modules/bz2module.c python/branches/p3yk-noslice/Modules/cPickle.c python/branches/p3yk-noslice/Modules/cStringIO.c python/branches/p3yk-noslice/Modules/cgen.py python/branches/p3yk-noslice/Modules/cjkcodecs/_codecs_cn.c python/branches/p3yk-noslice/Modules/cjkcodecs/_codecs_iso2022.c python/branches/p3yk-noslice/Modules/cjkcodecs/cjkcodecs.h python/branches/p3yk-noslice/Modules/datetimemodule.c python/branches/p3yk-noslice/Modules/dbmmodule.c python/branches/p3yk-noslice/Modules/gcmodule.c python/branches/p3yk-noslice/Modules/itertoolsmodule.c python/branches/p3yk-noslice/Modules/linuxaudiodev.c python/branches/p3yk-noslice/Modules/main.c python/branches/p3yk-noslice/Modules/mathmodule.c python/branches/p3yk-noslice/Modules/mmapmodule.c python/branches/p3yk-noslice/Modules/ossaudiodev.c python/branches/p3yk-noslice/Modules/parsermodule.c python/branches/p3yk-noslice/Modules/posixmodule.c python/branches/p3yk-noslice/Modules/pyexpat.c python/branches/p3yk-noslice/Modules/readline.c python/branches/p3yk-noslice/Modules/resource.c python/branches/p3yk-noslice/Modules/socketmodule.c python/branches/p3yk-noslice/Modules/socketmodule.h python/branches/p3yk-noslice/Modules/symtablemodule.c python/branches/p3yk-noslice/Modules/threadmodule.c python/branches/p3yk-noslice/Modules/unicodedata.c python/branches/p3yk-noslice/Objects/abstract.c python/branches/p3yk-noslice/Objects/boolobject.c python/branches/p3yk-noslice/Objects/bufferobject.c python/branches/p3yk-noslice/Objects/bytesobject.c python/branches/p3yk-noslice/Objects/cellobject.c python/branches/p3yk-noslice/Objects/classobject.c python/branches/p3yk-noslice/Objects/codeobject.c python/branches/p3yk-noslice/Objects/complexobject.c python/branches/p3yk-noslice/Objects/dictobject.c python/branches/p3yk-noslice/Objects/exceptions.c python/branches/p3yk-noslice/Objects/fileobject.c python/branches/p3yk-noslice/Objects/floatobject.c python/branches/p3yk-noslice/Objects/funcobject.c python/branches/p3yk-noslice/Objects/intobject.c python/branches/p3yk-noslice/Objects/iterobject.c python/branches/p3yk-noslice/Objects/listobject.c python/branches/p3yk-noslice/Objects/longobject.c python/branches/p3yk-noslice/Objects/methodobject.c python/branches/p3yk-noslice/Objects/object.c python/branches/p3yk-noslice/Objects/obmalloc.c python/branches/p3yk-noslice/Objects/setobject.c python/branches/p3yk-noslice/Objects/sliceobject.c python/branches/p3yk-noslice/Objects/stringlib/partition.h python/branches/p3yk-noslice/Objects/stringobject.c python/branches/p3yk-noslice/Objects/tupleobject.c python/branches/p3yk-noslice/Objects/typeobject.c python/branches/p3yk-noslice/Objects/unicodeobject.c python/branches/p3yk-noslice/Objects/weakrefobject.c python/branches/p3yk-noslice/PC/VC6/_bsddb.dsp (contents, props changed) python/branches/p3yk-noslice/PC/VC6/_socket.dsp (props changed) python/branches/p3yk-noslice/PC/VC6/_ssl.dsp (props changed) python/branches/p3yk-noslice/PC/VC6/_ssl.mak python/branches/p3yk-noslice/PC/VC6/_testcapi.dsp (props changed) python/branches/p3yk-noslice/PC/VC6/_tkinter.dsp (contents, props changed) python/branches/p3yk-noslice/PC/VC6/bz2.dsp (contents, props changed) python/branches/p3yk-noslice/PC/VC6/make_versioninfo.dsp (props changed) python/branches/p3yk-noslice/PC/VC6/pcbuild.dsw (contents, props changed) python/branches/p3yk-noslice/PC/VC6/pyexpat.dsp (props changed) python/branches/p3yk-noslice/PC/VC6/python.dsp (props changed) python/branches/p3yk-noslice/PC/VC6/pythoncore.dsp (contents, props changed) python/branches/p3yk-noslice/PC/VC6/pythonw.dsp (props changed) python/branches/p3yk-noslice/PC/VC6/readme.txt python/branches/p3yk-noslice/PC/VC6/select.dsp (props changed) python/branches/p3yk-noslice/PC/VC6/unicodedata.dsp (props changed) python/branches/p3yk-noslice/PC/VC6/w9xpopen.dsp (props changed) python/branches/p3yk-noslice/PC/VC6/winsound.dsp (props changed) python/branches/p3yk-noslice/PC/_msi.c python/branches/p3yk-noslice/PC/_winreg.c python/branches/p3yk-noslice/PC/example_nt/example.vcproj python/branches/p3yk-noslice/PC/pyconfig.h python/branches/p3yk-noslice/PCbuild/_ctypes.vcproj python/branches/p3yk-noslice/PCbuild/pythoncore.vcproj python/branches/p3yk-noslice/PCbuild8/_ctypes.vcproj python/branches/p3yk-noslice/PCbuild8/_ctypes_test.vcproj python/branches/p3yk-noslice/PCbuild8/_elementtree.vcproj python/branches/p3yk-noslice/PCbuild8/_msi.vcproj python/branches/p3yk-noslice/PCbuild8/_sqlite3.vcproj python/branches/p3yk-noslice/PCbuild8/make_buildinfo.c python/branches/p3yk-noslice/PCbuild8/make_buildinfo.vcproj python/branches/p3yk-noslice/PCbuild8/pcbuild.sln python/branches/p3yk-noslice/PCbuild8/python.vcproj python/branches/p3yk-noslice/PCbuild8/pythoncore.vcproj python/branches/p3yk-noslice/PCbuild8/pythonw.vcproj python/branches/p3yk-noslice/PCbuild8/readme.txt python/branches/p3yk-noslice/PCbuild8/select.vcproj python/branches/p3yk-noslice/PCbuild8/unicodedata.vcproj python/branches/p3yk-noslice/PCbuild8/w9xpopen.vcproj python/branches/p3yk-noslice/PCbuild8/winsound.vcproj python/branches/p3yk-noslice/Parser/Python.asdl python/branches/p3yk-noslice/Parser/asdl.py python/branches/p3yk-noslice/Parser/asdl_c.py python/branches/p3yk-noslice/Parser/parser.c python/branches/p3yk-noslice/Parser/parsetok.c python/branches/p3yk-noslice/Parser/tokenizer.c python/branches/p3yk-noslice/Python/Python-ast.c python/branches/p3yk-noslice/Python/ast.c python/branches/p3yk-noslice/Python/bltinmodule.c python/branches/p3yk-noslice/Python/ceval.c python/branches/p3yk-noslice/Python/compile.c python/branches/p3yk-noslice/Python/errors.c python/branches/p3yk-noslice/Python/frozen.c python/branches/p3yk-noslice/Python/getargs.c python/branches/p3yk-noslice/Python/graminit.c python/branches/p3yk-noslice/Python/import.c python/branches/p3yk-noslice/Python/marshal.c python/branches/p3yk-noslice/Python/modsupport.c python/branches/p3yk-noslice/Python/mystrtoul.c python/branches/p3yk-noslice/Python/peephole.c (contents, props changed) python/branches/p3yk-noslice/Python/pystate.c python/branches/p3yk-noslice/Python/pythonrun.c python/branches/p3yk-noslice/Python/structmember.c python/branches/p3yk-noslice/Python/symtable.c python/branches/p3yk-noslice/Python/sysmodule.c python/branches/p3yk-noslice/README python/branches/p3yk-noslice/Tools/compiler/ast.txt python/branches/p3yk-noslice/Tools/compiler/astgen.py python/branches/p3yk-noslice/Tools/modulator/modulator.py python/branches/p3yk-noslice/Tools/msi/msi.py python/branches/p3yk-noslice/Tools/msi/uuids.py python/branches/p3yk-noslice/Tools/pybench/pybench.py python/branches/p3yk-noslice/Tools/scripts/byext.py (props changed) python/branches/p3yk-noslice/Tools/scripts/findnocoding.py python/branches/p3yk-noslice/Tools/scripts/fixdiv.py python/branches/p3yk-noslice/Tools/scripts/h2py.py python/branches/p3yk-noslice/Tools/scripts/pysource.py python/branches/p3yk-noslice/configure python/branches/p3yk-noslice/configure.in python/branches/p3yk-noslice/pyconfig.h.in python/branches/p3yk-noslice/setup.py Log: Merge p3yk changes into branch. Deleted: /python/branches/p3yk-noslice/BROKEN ============================================================================== --- /python/branches/p3yk-noslice/BROKEN Fri Dec 15 05:21:50 2006 +++ (empty file) @@ -1 +0,0 @@ -(Nothing is broken at the moment AFAIK.) Modified: python/branches/p3yk-noslice/Demo/classes/Complex.py ============================================================================== --- python/branches/p3yk-noslice/Demo/classes/Complex.py (original) +++ python/branches/p3yk-noslice/Demo/classes/Complex.py Fri Dec 15 05:21:50 2006 @@ -165,7 +165,7 @@ other = ToComplex(other) return cmp(other, self) - def __nonzero__(self): + def __bool__(self): return not (self.re == self.im == 0) abs = radius = __abs__ Modified: python/branches/p3yk-noslice/Demo/classes/Rat.py ============================================================================== --- python/branches/p3yk-noslice/Demo/classes/Rat.py (original) +++ python/branches/p3yk-noslice/Demo/classes/Rat.py Fri Dec 15 05:21:50 2006 @@ -223,7 +223,7 @@ return cmp(Rat(a), b) # a != 0 - def __nonzero__(a): + def __bool__(a): return a.__num != 0 # coercion Modified: python/branches/p3yk-noslice/Demo/parser/unparse.py ============================================================================== --- python/branches/p3yk-noslice/Demo/parser/unparse.py (original) +++ python/branches/p3yk-noslice/Demo/parser/unparse.py Fri Dec 15 05:21:50 2006 @@ -123,16 +123,6 @@ self.write(", ") self.dispatch(t.msg) - def _Exec(self, t): - self.fill("exec ") - self.dispatch(t.body) - if t.globals: - self.write(" in ") - self.dispatch(t.globals) - if t.locals: - self.write(", ") - self.dispatch(t.locals) - def _Print(self, t): self.fill("print ") do_comma = False @@ -223,6 +213,9 @@ def _FunctionDef(self, t): self.write("\n") + for deco in t.decorators: + self.fill("@") + self.dispatch(deco) self.fill("def "+t.name + "(") self.dispatch(t.args) self.write(")") Modified: python/branches/p3yk-noslice/Demo/pysvr/pysvr.py ============================================================================== --- python/branches/p3yk-noslice/Demo/pysvr/pysvr.py (original) +++ python/branches/p3yk-noslice/Demo/pysvr/pysvr.py Fri Dec 15 05:21:50 2006 @@ -108,7 +108,7 @@ sys.stdout = sys.stderr = stdout sys.stdin = stdin try: - exec code in globals + exec(code, globals) except SystemExit, how: raise SystemExit, how, sys.exc_info()[2] except: Modified: python/branches/p3yk-noslice/Demo/rpc/nfsclient.py ============================================================================== --- python/branches/p3yk-noslice/Demo/rpc/nfsclient.py (original) +++ python/branches/p3yk-noslice/Demo/rpc/nfsclient.py Fri Dec 15 05:21:50 2006 @@ -163,7 +163,7 @@ ra = (dir, 0, 2000) while 1: (status, rest) = self.Readdir(ra) - if status <> NFS_OK: + if status != NFS_OK: break entries, eof = rest last_cookie = None Modified: python/branches/p3yk-noslice/Demo/rpc/xdr.py ============================================================================== --- python/branches/p3yk-noslice/Demo/rpc/xdr.py (original) +++ python/branches/p3yk-noslice/Demo/rpc/xdr.py Fri Dec 15 05:21:50 2006 @@ -78,7 +78,7 @@ self.pack_uint(0) def pack_farray(self, n, list, pack_item): - if len(list) <> n: + if len(list) != n: raise ValueError, 'wrong array size' for item in list: pack_item(item) @@ -183,7 +183,7 @@ while 1: x = self.unpack_uint() if x == 0: break - if x <> 1: + if x != 1: raise RuntimeError, '0 or 1 expected, got %r' % (x, ) item = unpack_item() list.append(item) Modified: python/branches/p3yk-noslice/Demo/scripts/lpwatch.py ============================================================================== --- python/branches/p3yk-noslice/Demo/scripts/lpwatch.py (original) +++ python/branches/p3yk-noslice/Demo/scripts/lpwatch.py Fri Dec 15 05:21:50 2006 @@ -74,7 +74,7 @@ ubytes = ubytes + bytes users[user] = ujobs, ubytes else: - if fields and fields[0] <> 'Rank': + if fields and fields[0] != 'Rank': line = string.strip(line) if line == 'no entries': line = name + ': idle' @@ -84,7 +84,7 @@ # if totaljobs: line = '%d K' % ((totalbytes+1023)/1024) - if totaljobs <> len(users): + if totaljobs != len(users): line = line + ' (%d jobs)' % totaljobs if len(users) == 1: line = line + ' for %s' % (users.keys()[0],) Modified: python/branches/p3yk-noslice/Demo/scripts/primes.py ============================================================================== --- python/branches/p3yk-noslice/Demo/scripts/primes.py (original) +++ python/branches/p3yk-noslice/Demo/scripts/primes.py Fri Dec 15 05:21:50 2006 @@ -18,7 +18,7 @@ while i <= max: for p in primes: if i%p == 0 or p*p > i: break - if i%p <> 0: + if i%p != 0: primes.append(i) if i >= min: print i i = i+2 Modified: python/branches/p3yk-noslice/Demo/scripts/update.py ============================================================================== --- python/branches/p3yk-noslice/Demo/scripts/update.py (original) +++ python/branches/p3yk-noslice/Demo/scripts/update.py Fri Dec 15 05:21:50 2006 @@ -83,7 +83,7 @@ print 'Funny line:', line, continue filename, lineno = prog.group(1, 2) - if not curfile or filename <> curfile.filename: + if not curfile or filename != curfile.filename: if curfile: curfile.finish() curfile = FileObj(filename) curfile.process(lineno, line[n:]) Modified: python/branches/p3yk-noslice/Demo/sockets/gopher.py ============================================================================== --- python/branches/p3yk-noslice/Demo/sockets/gopher.py (original) +++ python/branches/p3yk-noslice/Demo/sockets/gopher.py Fri Dec 15 05:21:50 2006 @@ -246,7 +246,7 @@ def browse_telnet(selector, host, port): if selector: print 'Log in as', repr(selector) - if type(port) <> type(''): + if type(port) != type(''): port = repr(port) sts = os.system('set -x; exec telnet ' + host + ' ' + port) if sts: Modified: python/branches/p3yk-noslice/Demo/sockets/rpythond.py ============================================================================== --- python/branches/p3yk-noslice/Demo/sockets/rpythond.py (original) +++ python/branches/p3yk-noslice/Demo/sockets/rpythond.py Fri Dec 15 05:21:50 2006 @@ -40,7 +40,7 @@ sys.stdout = sys.stderr = fakefile = StringIO.StringIO() try: try: - exec request in {}, {} + exec(request, {}, {}) except: print traceback.print_exc(100) Modified: python/branches/p3yk-noslice/Demo/tkinter/guido/ShellWindow.py ============================================================================== --- python/branches/p3yk-noslice/Demo/tkinter/guido/ShellWindow.py (original) +++ python/branches/p3yk-noslice/Demo/tkinter/guido/ShellWindow.py Fri Dec 15 05:21:50 2006 @@ -115,11 +115,11 @@ os.close(i) except os.error: pass - if os.dup(p2cread) <> 0: + if os.dup(p2cread) != 0: sys.stderr.write('popen2: bad read dup\n') - if os.dup(c2pwrite) <> 1: + if os.dup(c2pwrite) != 1: sys.stderr.write('popen2: bad write dup\n') - if os.dup(c2pwrite) <> 2: + if os.dup(c2pwrite) != 2: sys.stderr.write('popen2: bad write dup\n') for i in range(3, MAXFD): try: Modified: python/branches/p3yk-noslice/Doc/Makefile ============================================================================== --- python/branches/p3yk-noslice/Doc/Makefile (original) +++ python/branches/p3yk-noslice/Doc/Makefile Fri Dec 15 05:21:50 2006 @@ -122,7 +122,7 @@ # The end of this should reflect the major/minor version numbers of # the release: -WHATSNEW=whatsnew25 +WHATSNEW=whatsnew26 # what's what MANDVIFILES= paper-$(PAPER)/api.dvi paper-$(PAPER)/ext.dvi \ Modified: python/branches/p3yk-noslice/Doc/api/concrete.tex ============================================================================== --- python/branches/p3yk-noslice/Doc/api/concrete.tex (original) +++ python/branches/p3yk-noslice/Doc/api/concrete.tex Fri Dec 15 05:21:50 2006 @@ -602,15 +602,15 @@ \end{cfuncdesc} \begin{cfuncdesc}{PyObject*}{PyString_FromString}{const char *v} - Return a new string object with the value \var{v} on success, and - \NULL{} on failure. The parameter \var{v} must not be \NULL{}; it - will not be checked. + Return a new string object with a copy of the string \var{v} as value + on success, and \NULL{} on failure. The parameter \var{v} must not be + \NULL{}; it will not be checked. \end{cfuncdesc} \begin{cfuncdesc}{PyObject*}{PyString_FromStringAndSize}{const char *v, Py_ssize_t len} - Return a new string object with the value \var{v} and length - \var{len} on success, and \NULL{} on failure. If \var{v} is + Return a new string object with a copy of the string \var{v} as value + and length \var{len} on success, and \NULL{} on failure. If \var{v} is \NULL{}, the contents of the string are uninitialized. \end{cfuncdesc} @@ -2879,10 +2879,10 @@ Various date and time objects are supplied by the \module{datetime} module. Before using any of these functions, the header file \file{datetime.h} must be included in your source (note that this is -not include by \file{Python.h}), and macro \cfunction{PyDateTime_IMPORT()} -must be invoked. The macro arranges to put a pointer to a C structure -in a static variable \code{PyDateTimeAPI}, which is used by the following -macros. +not included by \file{Python.h}), and the macro +\cfunction{PyDateTime_IMPORT} must be invoked. The macro puts a +pointer to a C structure into a static variable, +\code{PyDateTimeAPI}, that is used by the following macros. Type-check macros: @@ -3080,9 +3080,9 @@ \cfunction{PyObject_IsTrue()}, \cfunction{PyObject_Print()}, and \cfunction{PyObject_GetIter()}) or the abstract number protocol (including -\cfunction{PyNumber_Add()}, \cfunction{PyNumber_Subtract()}, +\cfunction{PyNumber_And()}, \cfunction{PyNumber_Subtract()}, \cfunction{PyNumber_Or()}, \cfunction{PyNumber_Xor()}, -\cfunction{PyNumber_InPlaceAdd()}, \cfunction{PyNumber_InPlaceSubtract()}, +\cfunction{PyNumber_InPlaceAnd()}, \cfunction{PyNumber_InPlaceSubtract()}, \cfunction{PyNumber_InPlaceOr()}, and \cfunction{PyNumber_InPlaceXor()}). \begin{ctypedesc}{PySetObject} Modified: python/branches/p3yk-noslice/Doc/api/exceptions.tex ============================================================================== --- python/branches/p3yk-noslice/Doc/api/exceptions.tex (original) +++ python/branches/p3yk-noslice/Doc/api/exceptions.tex Fri Dec 15 05:21:50 2006 @@ -325,7 +325,7 @@ default effect for \constant{SIGINT}\ttindex{SIGINT} is to raise the \withsubitem{(built-in exception)}{\ttindex{KeyboardInterrupt}} \exception{KeyboardInterrupt} exception. If an exception is raised - the error indicator is set and the function returns \code{1}; + the error indicator is set and the function returns \code{-1}; otherwise the function returns \code{0}. The error indicator may or may not be cleared if it was previously set. \end{cfuncdesc} Modified: python/branches/p3yk-noslice/Doc/api/refcounts.dat ============================================================================== --- python/branches/p3yk-noslice/Doc/api/refcounts.dat (original) +++ python/branches/p3yk-noslice/Doc/api/refcounts.dat Fri Dec 15 05:21:50 2006 @@ -712,10 +712,6 @@ PyNumber_Check:PyObject*:o:0: PyNumber_Check:int::: -PyNumber_Coerce:int::: -PyNumber_Coerce:PyObject**:p1:+1: -PyNumber_Coerce:PyObject**:p2:+1: - PyNumber_Divide:PyObject*::+1: PyNumber_Divide:PyObject*:o1:0: PyNumber_Divide:PyObject*:o2:0: Modified: python/branches/p3yk-noslice/Doc/dist/dist.tex ============================================================================== --- python/branches/p3yk-noslice/Doc/dist/dist.tex (original) +++ python/branches/p3yk-noslice/Doc/dist/dist.tex Fri Dec 15 05:21:50 2006 @@ -3607,6 +3607,11 @@ % todo +\section{\module{distutils.command.bdist_msi} --- Build a Microsoft Installer binary package} +\declaremodule[distutils.command.bdistmsi]{standard}{distutils.command.bdist_msi} +\modulesynopsis{Build a binary distribution as a Windows MSI file} + +% todo \section{\module{distutils.command.bdist_rpm} --- Build a binary distribution as a Redhat RPM and SRPM} \declaremodule[distutils.command.bdistrpm]{standard}{distutils.command.bdist_rpm} Modified: python/branches/p3yk-noslice/Doc/ext/extending.tex ============================================================================== --- python/branches/p3yk-noslice/Doc/ext/extending.tex (original) +++ python/branches/p3yk-noslice/Doc/ext/extending.tex Fri Dec 15 05:21:50 2006 @@ -220,6 +220,8 @@ PyObject *m; m = Py_InitModule("spam", SpamMethods); + if (m == NULL) + return; SpamError = PyErr_NewException("spam.error", NULL, NULL); Py_INCREF(SpamError); @@ -364,9 +366,9 @@ created module based upon the table (an array of \ctype{PyMethodDef} structures) that was passed as its second argument. \cfunction{Py_InitModule()} returns a pointer to the module object -that it creates (which is unused here). It aborts with a fatal error -if the module could not be initialized satisfactorily, so the caller -doesn't need to check for errors. +that it creates (which is unused here). It may abort with a fatal error +for certain errors, or return \NULL{} if the module could not be +initialized satisfactorily. When embedding Python, the \cfunction{initspam()} function is not called automatically unless there's an entry in the @@ -1275,6 +1277,8 @@ PyObject *c_api_object; m = Py_InitModule("spam", SpamMethods); + if (m == NULL) + return; /* Initialize the C API pointer array */ PySpam_API[PySpam_System_NUM] = (void *)PySpam_System; @@ -1361,7 +1365,9 @@ { PyObject *m; - Py_InitModule("client", ClientMethods); + m = Py_InitModule("client", ClientMethods); + if (m == NULL) + return; if (import_spam() < 0) return; /* additional initialization can happen here */ Modified: python/branches/p3yk-noslice/Doc/howto/doanddont.tex ============================================================================== --- python/branches/p3yk-noslice/Doc/howto/doanddont.tex (original) +++ python/branches/p3yk-noslice/Doc/howto/doanddont.tex Fri Dec 15 05:21:50 2006 @@ -81,7 +81,7 @@ \end{itemize} -\subsection{Unadorned \keyword{exec}, \function{execfile} and friends} +\subsection{Unadorned \function{exec}, \function{execfile} and friends} The word ``unadorned'' refers to the use without an explicit dictionary, in which case those constructs evaluate code in the {\em current} environment. @@ -93,10 +93,10 @@ \begin{verbatim} >>> for name in sys.argv[1:]: ->>> exec "%s=1" % name +>>> exec("%s=1" % name) >>> def func(s, **kw): >>> for var, val in kw.items(): ->>> exec "s.%s=val" % var # invalid! +>>> exec("s.%s=val" % var) # invalid! >>> execfile("handler.py") >>> handle() \end{verbatim} @@ -289,19 +289,7 @@ aware of for some reason: \function{min()} and \function{max()} can find the minimum/maximum of any sequence with comparable semantics, for example, yet many people write their own -\function{max()}/\function{min()}. Another highly useful function is -\function{reduce()}. A classical use of \function{reduce()} -is something like - -\begin{verbatim} -import sys, operator -nums = map(float, sys.argv[1:]) -print reduce(operator.add, nums)/len(nums) -\end{verbatim} - -This cute little script prints the average of all numbers given on the -command line. The \function{reduce()} adds up all the numbers, and -the rest is just some pre- and postprocessing. +\function{max()}/\function{min()}. On the same note, note that \function{float()}, \function{int()} and \function{long()} all accept arguments of type string, and so are Modified: python/branches/p3yk-noslice/Doc/howto/regex.tex ============================================================================== --- python/branches/p3yk-noslice/Doc/howto/regex.tex (original) +++ python/branches/p3yk-noslice/Doc/howto/regex.tex Fri Dec 15 05:21:50 2006 @@ -367,7 +367,7 @@ strings, and displays whether the RE matches or fails. \file{redemo.py} can be quite useful when trying to debug a complicated RE. Phil Schwartz's -\ulink{Kodos}{http://kodos.sourceforge.net} is also an interactive +\ulink{Kodos}{http://www.phil-schwartz.com/kodos.spy} is also an interactive tool for developing and testing RE patterns. This HOWTO will use the standard Python interpreter for its examples. Modified: python/branches/p3yk-noslice/Doc/inst/inst.tex ============================================================================== --- python/branches/p3yk-noslice/Doc/inst/inst.tex (original) +++ python/branches/p3yk-noslice/Doc/inst/inst.tex Fri Dec 15 05:21:50 2006 @@ -632,7 +632,7 @@ installation base directory when you run the setup script. For example, \begin{verbatim} -python setup.py --install-base=/tmp +python setup.py install --install-base=/tmp \end{verbatim} would install pure modules to \filevar{/tmp/python/lib} in the first Modified: python/branches/p3yk-noslice/Doc/lib/asttable.tex ============================================================================== --- python/branches/p3yk-noslice/Doc/lib/asttable.tex (original) +++ python/branches/p3yk-noslice/Doc/lib/asttable.tex Fri Dec 15 05:21:50 2006 @@ -36,9 +36,6 @@ \lineiii{}{\member{expr}}{} \hline -\lineiii{Backquote}{\member{expr}}{} -\hline - \lineiii{Bitand}{\member{nodes}}{} \hline Modified: python/branches/p3yk-noslice/Doc/lib/email-unpack.py ============================================================================== --- python/branches/p3yk-noslice/Doc/lib/email-unpack.py (original) +++ python/branches/p3yk-noslice/Doc/lib/email-unpack.py Fri Dec 15 05:21:50 2006 @@ -37,7 +37,7 @@ os.mkdir(opts.directory) except OSError, e: # Ignore directory exists error - if e.errno <> errno.EEXIST: + if e.errno != errno.EEXIST: raise fp = open(msgfile) Modified: python/branches/p3yk-noslice/Doc/lib/libasyncore.tex ============================================================================== --- python/branches/p3yk-noslice/Doc/lib/libasyncore.tex (original) +++ python/branches/p3yk-noslice/Doc/lib/libasyncore.tex Fri Dec 15 05:21:50 2006 @@ -198,9 +198,11 @@ \end{methoddesc} \begin{methoddesc}{bind}{address} - Bind the socket to \var{address}. The socket must not already - be bound. (The format of \var{address} depends on the address - family --- see above.) + Bind the socket to \var{address}. The socket must not already be + bound. (The format of \var{address} depends on the address family + --- see above.) To mark the socket as re-usable (setting the + \constant{SO_REUSEADDR} option), call the \class{dispatcher} + object's \method{set_reuse_addr()} method. \end{methoddesc} \begin{methoddesc}{accept}{} Modified: python/branches/p3yk-noslice/Doc/lib/libatexit.tex ============================================================================== --- python/branches/p3yk-noslice/Doc/lib/libatexit.tex (original) +++ python/branches/p3yk-noslice/Doc/lib/libatexit.tex Fri Dec 15 05:21:50 2006 @@ -44,6 +44,10 @@ traceback is printed (unless \exception{SystemExit} is raised) and the exception information is saved. After all exit handlers have had a chance to run the last exception to be raised is re-raised. + +\versionchanged[This function now returns \var{func} which makes it + possible to use it as a decorator without binding the + original name to \code{None}]{2.6} \end{funcdesc} @@ -92,3 +96,15 @@ # or: atexit.register(goodbye, adjective='nice', name='Donny') \end{verbatim} + +Usage as a decorator: + +\begin{verbatim} +import atexit + + at atexit.register +def goodbye(): + print "You are now leaving the Python sector." +\end{verbatim} + +This obviously only works with functions that don't take arguments. Modified: python/branches/p3yk-noslice/Doc/lib/libbase64.tex ============================================================================== --- python/branches/p3yk-noslice/Doc/lib/libbase64.tex (original) +++ python/branches/p3yk-noslice/Doc/lib/libbase64.tex Fri Dec 15 05:21:50 2006 @@ -21,7 +21,7 @@ decoding to and from file-like objects as well as strings, but only using the Base64 standard alphabet. -The modern interface provides: +The modern interface, which was introduced in Python 2.4, provides: \begin{funcdesc}{b64encode}{s\optional{, altchars}} Encode a string use Base64. Modified: python/branches/p3yk-noslice/Doc/lib/libbsddb.tex ============================================================================== --- python/branches/p3yk-noslice/Doc/lib/libbsddb.tex (original) +++ python/branches/p3yk-noslice/Doc/lib/libbsddb.tex Fri Dec 15 05:21:50 2006 @@ -19,21 +19,23 @@ 3.3 thru 4.4. \begin{seealso} - \seeurl{http://pybsddb.sourceforge.net/}{The website with documentation - for the \module{bsddb.db} python Berkeley DB interface that closely mirrors - the Sleepycat object oriented interface provided in Berkeley DB 3 and 4.} - \seeurl{http://www.sleepycat.com/}{Sleepycat Software produces the - Berkeley DB library.} + \seeurl{http://pybsddb.sourceforge.net/} + {The website with documentation for the \module{bsddb.db} + Python Berkeley DB interface that closely mirrors the object + oriented interface provided in Berkeley DB 3 and 4.} + + \seeurl{http://www.oracle.com/database/berkeley-db/} + {The Berkeley DB library.} \end{seealso} A more modern DB, DBEnv and DBSequence object interface is available in the -\module{bsddb.db} module which closely matches the Sleepycat Berkeley DB C API +\module{bsddb.db} module which closely matches the Berkeley DB C API documented at the above URLs. Additional features provided by the \module{bsddb.db} API include fine tuning, transactions, logging, and multiprocess concurrent database access. The following is a description of the legacy \module{bsddb} interface -compatible with the old python bsddb module. Starting in Python 2.5 this +compatible with the old Python bsddb module. Starting in Python 2.5 this interface should be safe for multithreaded access. The \module{bsddb.db} API is recommended for threading users as it provides better control. Modified: python/branches/p3yk-noslice/Doc/lib/libcfgparser.tex ============================================================================== --- python/branches/p3yk-noslice/Doc/lib/libcfgparser.tex (original) +++ python/branches/p3yk-noslice/Doc/lib/libcfgparser.tex Fri Dec 15 05:21:50 2006 @@ -48,11 +48,20 @@ may be passed into the \method{get()} method which will override all others. -\begin{classdesc}{RawConfigParser}{\optional{defaults}} +Sections are normally stored in a builtin dictionary. An alternative +dictionary type can be passed to the \class{ConfigParser} constructor. +For example, if a dictionary type is passed that sorts its keys, +the sections will be sorted on write-back, as will be the keys within +each section. + +\begin{classdesc}{RawConfigParser}{\optional{defaults\optional{, dict_type}}} The basic configuration object. When \var{defaults} is given, it is -initialized into the dictionary of intrinsic defaults. This class -does not support the magical interpolation behavior. +initialized into the dictionary of intrinsic defaults. When \var{dict_type} +is given, it will be used to create the dictionary objects for the list +of sections, for the options within a section, and for the default values. +This class does not support the magical interpolation behavior. \versionadded{2.3} +\versionchanged[\var{dict_type} was added]{2.6} \end{classdesc} \begin{classdesc}{ConfigParser}{\optional{defaults}} Modified: python/branches/p3yk-noslice/Doc/lib/libcommands.tex ============================================================================== --- python/branches/p3yk-noslice/Doc/lib/libcommands.tex (original) +++ python/branches/p3yk-noslice/Doc/lib/libcommands.tex Fri Dec 15 05:21:50 2006 @@ -12,6 +12,11 @@ return any output generated by the command and, optionally, the exit status. +The \module{subprocess} module provides more powerful facilities for +spawning new processes and retrieving their results. Using the +\module{subprocess} module is preferable to using the \module{commands} +module. + The \module{commands} module defines the following functions: @@ -51,3 +56,7 @@ >>> commands.getstatus('/bin/ls') '-rwxr-xr-x 1 root 13352 Oct 14 1994 /bin/ls' \end{verbatim} + +\begin{seealso} + \seemodule{subprocess}{Module for spawning and managing subprocesses.} +\end{seealso} Modified: python/branches/p3yk-noslice/Doc/lib/libconsts.tex ============================================================================== --- python/branches/p3yk-noslice/Doc/lib/libconsts.tex (original) +++ python/branches/p3yk-noslice/Doc/lib/libconsts.tex Fri Dec 15 05:21:50 2006 @@ -26,6 +26,8 @@ \end{datadesc} \begin{datadesc}{Ellipsis} - Special value used in conjunction with extended slicing syntax. + The same as \code{...}. + Special value used mostly in conjunction with extended slicing syntax + for user-defined container data types. % XXX Someone who understands extended slicing should fill in here. \end{datadesc} Modified: python/branches/p3yk-noslice/Doc/lib/libcsv.tex ============================================================================== --- python/branches/p3yk-noslice/Doc/lib/libcsv.tex (original) +++ python/branches/p3yk-noslice/Doc/lib/libcsv.tex Fri Dec 15 05:21:50 2006 @@ -64,9 +64,9 @@ class or one of the strings returned by the \function{list_dialects} function. The other optional {}\var{fmtparam} keyword arguments can be given to override individual formatting parameters in the current -dialect. For more information about the dialect and formatting +dialect. For full details about the dialect and formatting parameters, see section~\ref{csv-fmt-params}, ``Dialects and Formatting -Parameters'' for details of these parameters. +Parameters''. All data read are returned as strings. No automatic data type conversion is performed. @@ -96,10 +96,10 @@ of a subclass of the \class{Dialect} class or one of the strings returned by the \function{list_dialects} function. The other optional {}\var{fmtparam} keyword arguments can be given to override individual -formatting parameters in the current dialect. For more information +formatting parameters in the current dialect. For full details about the dialect and formatting parameters, see -section~\ref{csv-fmt-params}, ``Dialects and Formatting Parameters'' for -details of these parameters. To make it as easy as possible to +section~\ref{csv-fmt-params}, ``Dialects and Formatting Parameters''. +To make it as easy as possible to interface with modules which implement the DB API, the value \constant{None} is written as the empty string. While this isn't a reversible transformation, it makes it easier to dump SQL NULL data values @@ -113,9 +113,8 @@ or Unicode object. The dialect can be specified either by passing a sub-class of \class{Dialect}, or by \var{fmtparam} keyword arguments, or both, with keyword arguments overriding parameters of the dialect. -For more information about the dialect and formatting parameters, see -section~\ref{csv-fmt-params}, ``Dialects and Formatting Parameters'' -for details of these parameters. +For full details about the dialect and formatting parameters, see +section~\ref{csv-fmt-params}, ``Dialects and Formatting Parameters''. \end{funcdesc} \begin{funcdesc}{unregister_dialect}{name} @@ -197,12 +196,13 @@ \begin{classdesc}{excel}{} The \class{excel} class defines the usual properties of an Excel-generated -CSV file. +CSV file. It is registered with the dialect name \code{'excel'}. \end{classdesc} \begin{classdesc}{excel_tab}{} The \class{excel_tab} class defines the usual properties of an -Excel-generated TAB-delimited file. +Excel-generated TAB-delimited file. It is registered with the dialect name +\code{'excel-tab'}. \end{classdesc} \begin{classdesc}{Sniffer}{} @@ -345,6 +345,7 @@ \begin{memberdesc}[csv reader]{line_num} The number of lines read from the source iterator. This is not the same as the number of records returned, as records can span multiple lines. + \versionadded{2.5} \end{memberdesc} Modified: python/branches/p3yk-noslice/Doc/lib/libctypes.tex ============================================================================== --- python/branches/p3yk-noslice/Doc/lib/libctypes.tex (original) +++ python/branches/p3yk-noslice/Doc/lib/libctypes.tex Fri Dec 15 05:21:50 2006 @@ -1821,7 +1821,7 @@ \begin{quote} \begin{verbatim}>>> from ctypes import c_int, WINFUNCTYPE, windll >>> from ctypes.wintypes import HWND, LPCSTR, UINT ->>> prototype = WINFUNCTYPE(c_int, HWND, LPCSTR, LPCSTR, c_uint) +>>> prototype = WINFUNCTYPE(c_int, HWND, LPCSTR, LPCSTR, UINT) >>> paramflags = (1, "hwnd", 0), (1, "text", "Hi"), (1, "caption", None), (1, "flags", 0) >>> MessageBox = prototype(("MessageBoxA", windll.user32), paramflags) >>>\end{verbatim} @@ -1848,7 +1848,7 @@ Here is the wrapping with \code{ctypes}: \begin{quote} -\begin{verbatim}>>> from ctypes import POINTER, WINFUNCTYPE, windll +\begin{verbatim}>>> from ctypes import POINTER, WINFUNCTYPE, windll, WinError >>> from ctypes.wintypes import BOOL, HWND, RECT >>> prototype = WINFUNCTYPE(BOOL, HWND, POINTER(RECT)) >>> paramflags = (1, "hwnd"), (2, "lprect") @@ -2299,12 +2299,10 @@ or error information for a function or method call. \end{classdesc*} -\code{py{\_}object} : classdesc* -\begin{quote} - -Represents the C \code{PyObject *} datatype. Calling this with an -without an argument creates a \code{NULL} \code{PyObject *} pointer. -\end{quote} +\begin{classdesc*}{py_object} +Represents the C \code{PyObject *} datatype. Calling this without an +argument creates a \code{NULL} \code{PyObject *} pointer. +\end{classdesc*} The \code{ctypes.wintypes} module provides quite some other Windows specific data types, for example \code{HWND}, \code{WPARAM}, or \code{DWORD}. @@ -2440,5 +2438,6 @@ \subsubsection{Arrays and pointers\label{ctypes-arrays-pointers}} -XXX +Not yet written - please see section~\ref{ctypes-pointers}, pointers and +section~\ref{ctypes-arrays}, arrays in the tutorial. Modified: python/branches/p3yk-noslice/Doc/lib/libdatetime.tex ============================================================================== --- python/branches/p3yk-noslice/Doc/lib/libdatetime.tex (original) +++ python/branches/p3yk-noslice/Doc/lib/libdatetime.tex Fri Dec 15 05:21:50 2006 @@ -1421,19 +1421,21 @@ varies across platforms. Regardless of platform, years before 1900 cannot be used. -\subsection{Examples} - -\subsubsection{Creating Datetime Objects from Formatted Strings} - -The \class{datetime} class does not directly support parsing formatted time -strings. You can use \function{time.strptime} to do the parsing and create -a \class{datetime} object from the tuple it returns: - -\begin{verbatim} ->>> s = "2005-12-06T12:13:14" ->>> from datetime import datetime ->>> from time import strptime ->>> datetime(*strptime(s, "%Y-%m-%dT%H:%M:%S")[0:6]) -datetime.datetime(2005, 12, 6, 12, 13, 14) -\end{verbatim} - +%%% This example is obsolete, since strptime is now supported by datetime. +% +% \subsection{Examples} +% +% \subsubsection{Creating Datetime Objects from Formatted Strings} +% +% The \class{datetime} class does not directly support parsing formatted time +% strings. You can use \function{time.strptime} to do the parsing and create +% a \class{datetime} object from the tuple it returns: +% +% \begin{verbatim} +% >>> s = "2005-12-06T12:13:14" +% >>> from datetime import datetime +% >>> from time import strptime +% >>> datetime(*strptime(s, "%Y-%m-%dT%H:%M:%S")[0:6]) +% datetime.datetime(2005, 12, 6, 12, 13, 14) +% \end{verbatim} +% Modified: python/branches/p3yk-noslice/Doc/lib/libdecimal.tex ============================================================================== --- python/branches/p3yk-noslice/Doc/lib/libdecimal.tex (original) +++ python/branches/p3yk-noslice/Doc/lib/libdecimal.tex Fri Dec 15 05:21:50 2006 @@ -435,36 +435,37 @@ the \function{getcontext()} and \function{setcontext()} functions: \begin{funcdesc}{getcontext}{} - Return the current context for the active thread. + Return the current context for the active thread. \end{funcdesc} \begin{funcdesc}{setcontext}{c} - Set the current context for the active thread to \var{c}. + Set the current context for the active thread to \var{c}. \end{funcdesc} Beginning with Python 2.5, you can also use the \keyword{with} statement -to temporarily change the active context. For example the following code -increases the current decimal precision by 2 places, performs a -calculation, and then automatically restores the previous context: +and the \function{localcontext()} function to temporarily change the +active context. -\begin{verbatim} -from __future__ import with_statement -import decimal - -with decimal.getcontext() as ctx: - ctx.prec += 2 # add 2 more digits of precision - calculate_something() +\begin{funcdesc}{localcontext}{\optional{c}} + Return a context manager that will set the current context for + the active thread to a copy of \var{c} on entry to the with-statement + and restore the previous context when exiting the with-statement. If + no context is specified, a copy of the current context is used. + \versionadded{2.5} + + For example, the following code sets the current decimal precision + to 42 places, performs a calculation, and then automatically restores + the previous context: +\begin{verbatim} + from __future__ import with_statement + from decimal import localcontext + + with localcontext() as ctx: + ctx.prec = 42 # Perform a high precision calculation + s = calculate_something() + s = +s # Round the final result back to the default precision \end{verbatim} - -The context that's active in the body of the \keyword{with} statement is -a \emph{copy} of the context you provided to the \keyword{with} -statement, so modifying its attributes doesn't affect anything except -that temporary copy. - -You can use any decimal context in a \keyword{with} statement, but if -you just want to make a temporary change to some aspect of the current -context, it's easiest to just use \function{getcontext()} as shown -above. +\end{funcdesc} New contexts can also be created using the \class{Context} constructor described below. In addition, the module provides three pre-made Modified: python/branches/p3yk-noslice/Doc/lib/libdis.tex ============================================================================== --- python/branches/p3yk-noslice/Doc/lib/libdis.tex (original) +++ python/branches/p3yk-noslice/Doc/lib/libdis.tex Fri Dec 15 05:21:50 2006 @@ -165,10 +165,6 @@ Implements \code{TOS = not TOS}. \end{opcodedesc} -\begin{opcodedesc}{UNARY_CONVERT}{} -Implements \code{TOS = `TOS`}. -\end{opcodedesc} - \begin{opcodedesc}{UNARY_INVERT}{} Implements \code{TOS = \~{}TOS}. \end{opcodedesc} @@ -359,11 +355,6 @@ This opcode implements \code{from module import *}. \end{opcodedesc} -\begin{opcodedesc}{EXEC_STMT}{} -Implements \code{exec TOS2,TOS1,TOS}. The compiler fills -missing optional parameters with \code{None}. -\end{opcodedesc} - \begin{opcodedesc}{POP_BLOCK}{} Removes one block from the block stack. Per frame, there is a stack of blocks, denoting nested loops, try statements, and such. @@ -452,6 +443,10 @@ Works as \code{BUILD_TUPLE}, but creates a list. \end{opcodedesc} +\begin{opcodedesc}{BUILD_SET}{count} +Works as \code{BUILD_TUPLE}, but creates a set. +\end{opcodedesc} + \begin{opcodedesc}{BUILD_MAP}{zero} Pushes a new empty dictionary object onto the stack. The argument is ignored and set to zero by the compiler. Modified: python/branches/p3yk-noslice/Doc/lib/libetree.tex ============================================================================== --- python/branches/p3yk-noslice/Doc/lib/libetree.tex (original) +++ python/branches/p3yk-noslice/Doc/lib/libetree.tex Fri Dec 15 05:21:50 2006 @@ -1,45 +1,34 @@ -\section{\module{elementtree} --- The xml.etree.ElementTree Module} -\declaremodule{standard}{elementtree} +\section{\module{xml.etree.ElementTree} --- The ElementTree XML API} +\declaremodule{standard}{xml.etree.ElementTree} \moduleauthor{Fredrik Lundh}{fredrik at pythonware.com} -\modulesynopsis{This module provides implementations -of the Element and ElementTree types, plus support classes. +\modulesynopsis{Implementation of the ElementTree API.} -A C version of this API is available as xml.etree.cElementTree.} \versionadded{2.5} - -\subsection{Overview\label{elementtree-overview}} - The Element type is a flexible container object, designed to store hierarchical data structures in memory. The type can be described as a cross between a list and a dictionary. Each element has a number of properties associated with it: -\begin{itemize} -\item {} -a tag which is a string identifying what kind of data -this element represents (the element type, in other words). - -\item {} -a number of attributes, stored in a Python dictionary. - -\item {} -a text string. - -\item {} -an optional tail string. - -\item {} -a number of child elements, stored in a Python sequence +\begin{itemize} + \item a tag which is a string identifying what kind of data + this element represents (the element type, in other words). + \item a number of attributes, stored in a Python dictionary. + \item a text string. + \item an optional tail string. + \item a number of child elements, stored in a Python sequence \end{itemize} To create an element instance, use the Element or SubElement factory functions. -The ElementTree class can be used to wrap an element +The \class{ElementTree} class can be used to wrap an element structure, and convert it from and to XML. +A C implementation of this API is available as +\module{xml.etree.cElementTree}. + \subsection{Functions\label{elementtree-functions}} Modified: python/branches/p3yk-noslice/Doc/lib/libexcs.tex ============================================================================== --- python/branches/p3yk-noslice/Doc/lib/libexcs.tex (original) +++ python/branches/p3yk-noslice/Doc/lib/libexcs.tex Fri Dec 15 05:21:50 2006 @@ -293,10 +293,10 @@ \begin{excdesc}{SyntaxError} % XXXJH xref to these functions? Raised when the parser encounters a syntax error. This may occur in - an \keyword{import} statement, in an \keyword{exec} statement, in a call - to the built-in function \function{eval()} or \function{input()}, or - when reading the initial script or standard input (also - interactively). + an \keyword{import} statement, in a call to the built-in functions + \function{exec()}, \function{execfile()}, \function{eval()} or + \function{input()}, or when reading the initial script or standard + input (also interactively). Instances of this class have attributes \member{filename}, \member{lineno}, \member{offset} and \member{text} for easier access Modified: python/branches/p3yk-noslice/Doc/lib/libfpectl.tex ============================================================================== --- python/branches/p3yk-noslice/Doc/lib/libfpectl.tex (original) +++ python/branches/p3yk-noslice/Doc/lib/libfpectl.tex Fri Dec 15 05:21:50 2006 @@ -7,6 +7,11 @@ \sectionauthor{Lee Busby}{busby1 at llnl.gov} \modulesynopsis{Provide control for floating point exception handling.} +\note{The \module{fpectl} module is not built by default, and its usage + is discouraged and may be dangerous except in the hands of + experts. See also the section \ref{fpectl-limitations} on + limitations for more details.} + Most computers carry out floating point operations\index{IEEE-754} in conformance with the so-called IEEE-754 standard. On any real computer, @@ -95,7 +100,7 @@ \end{verbatim} -\subsection{Limitations and other considerations} +\subsection{Limitations and other considerations \label{fpectl-limitations}} Setting up a given processor to trap IEEE-754 floating point errors currently requires custom code on a per-architecture basis. Modified: python/branches/p3yk-noslice/Doc/lib/libfuncs.tex ============================================================================== --- python/branches/p3yk-noslice/Doc/lib/libfuncs.tex (original) +++ python/branches/p3yk-noslice/Doc/lib/libfuncs.tex Fri Dec 15 05:21:50 2006 @@ -178,7 +178,7 @@ \begin{funcdesc}{compile}{string, filename, kind\optional{, flags\optional{, dont_inherit}}} Compile the \var{string} into a code object. Code objects can be - executed by an \keyword{exec} statement or evaluated by a call to + executed by a call to \function{exec()} or evaluated by a call to \function{eval()}. The \var{filename} argument should give the file from which the code was read; pass some recognizable value if it wasn't read from a file (\code{''} is commonly used). @@ -366,7 +366,7 @@ compiled passing \code{'eval'} as the \var{kind} argument. Hints: dynamic execution of statements is supported by the - \keyword{exec} statement. Execution of statements from a file is + \function{exec()} function. Execution of statements from a file is supported by the \function{execfile()} function. The \function{globals()} and \function{locals()} functions returns the current global and local dictionary, respectively, which may be @@ -374,13 +374,47 @@ \function{execfile()}. \end{funcdesc} + +\begin{funcdesc}{exec}{object\optional{, globals\optional{, locals}}} + This function supports dynamic execution of Python code. + \var{object} must be either a string, an open file object, or + a code object. If it is a string, the string is parsed as a suite of + Python statements which is then executed (unless a syntax error + occurs). If it is an open file, the file is parsed until \EOF{} and + executed. If it is a code object, it is simply executed. In all + cases, the code that's executed is expected to be valid as file + input (see the section ``File input'' in the Reference Manual). + Be aware that the \keyword{return} and \keyword{yield} statements may + not be used outside of function definitions even within the context of + code passed to the \function{exec()} function. + The return value is \code{None}. + + In all cases, if the optional parts are omitted, the code is executed + in the current scope. If only \var{globals} is provided, it must be + a dictionary, which will be used for both the global and the local + variables. If \var{globals} and \var{locals} are given, they are used + for the global and local variables, respectively. If provided, + \var{locals} can be any mapping object. + + If the \var{globals} dictionary does not contain a value for the + key \code{__builtins__}, a reference to the dictionary of the built-in + module \module{__builtin__} is inserted under that key. That way you + can control what builtins are available to the executed code by + inserting your own \code{__builtins__} dictionary into \var{globals} + before passing it to \function{exec()}. + + \note{The built-in functions \function{globals()} and \function{locals()} + return the current global and local dictionary, respectively, which + may be useful to pass around for use as the second and third + argument to \function{exec()}.} +\end{funcdesc} + \begin{funcdesc}{execfile}{filename\optional{, globals\optional{, locals}}} - This function is similar to the - \keyword{exec} statement, but parses a file instead of a string. It + This function is similar to the \function{exec()} function, but parses a + file given by the file name instead of a string. It is different from the \keyword{import} statement in that it does not use the module administration --- it reads the file unconditionally - and does not create a new module.\footnote{It is used relatively - rarely so does not warrant being made into a statement.} + and does not create a new module. The arguments are a file name and two optional dictionaries. The file is parsed and evaluated as a sequence of Python statements (similarly to a @@ -774,7 +808,7 @@ \begin{verbatim} class C(object): - def __init__(self): self.__x = None + def __init__(self): self._x = None def getx(self): return self._x def setx(self, value): self._x = value def delx(self): del self._x @@ -836,19 +870,6 @@ \end{verbatim} \end{funcdesc} -\begin{funcdesc}{reduce}{function, sequence\optional{, initializer}} - Apply \var{function} of two arguments cumulatively to the items of - \var{sequence}, from left to right, so as to reduce the sequence to - a single value. For example, \code{reduce(lambda x, y: x+y, [1, 2, - 3, 4, 5])} calculates \code{((((1+2)+3)+4)+5)}. The left argument, - \var{x}, is the accumulated value and the right argument, \var{y}, - is the update value from the \var{sequence}. If the optional - \var{initializer} is present, it is placed before the items of the - sequence in the calculation, and serves as a default when the - sequence is empty. If \var{initializer} is not given and - \var{sequence} contains only one item, the first item is returned. -\end{funcdesc} - \begin{funcdesc}{reload}{module} Reload a previously imported \var{module}. The argument must be a module object, so it must have been successfully @@ -1058,8 +1079,6 @@ The \var{sequence}'s items are normally numbers, and are not allowed to be strings. The fast, correct way to concatenate sequence of strings is by calling \code{''.join(\var{sequence})}. - Note that \code{sum(range(\var{n}), \var{m})} is equivalent to - \code{reduce(operator.add, range(\var{n}), \var{m})} \versionadded{2.3} \end{funcdesc} @@ -1243,12 +1262,6 @@ argument). \end{funcdesc} -\begin{funcdesc}{coerce}{x, y} - Return a tuple consisting of the two numeric arguments converted to - a common type, using the same rules as used by arithmetic - operations. If coercion is not possible, raise \exception{TypeError}. -\end{funcdesc} - \begin{funcdesc}{intern}{string} Enter \var{string} in the table of ``interned'' strings and return the interned string -- which is \var{string} itself or a copy. Modified: python/branches/p3yk-noslice/Doc/lib/libfunctools.tex ============================================================================== --- python/branches/p3yk-noslice/Doc/lib/libfunctools.tex (original) +++ python/branches/p3yk-noslice/Doc/lib/libfunctools.tex Fri Dec 15 05:21:50 2006 @@ -51,6 +51,19 @@ \end{verbatim} \end{funcdesc} +\begin{funcdesc}{reduce}{function, sequence\optional{, initializer}} + Apply \var{function} of two arguments cumulatively to the items of + \var{sequence}, from left to right, so as to reduce the sequence to + a single value. For example, \code{reduce(lambda x, y: x+y, [1, 2, + 3, 4, 5])} calculates \code{((((1+2)+3)+4)+5)}. The left argument, + \var{x}, is the accumulated value and the right argument, \var{y}, + is the update value from the \var{sequence}. If the optional + \var{initializer} is present, it is placed before the items of the + sequence in the calculation, and serves as a default when the + sequence is empty. If \var{initializer} is not given and + \var{sequence} contains only one item, the first item is returned. +\end{funcdesc} + \begin{funcdesc}{update_wrapper} {wrapper, wrapped\optional{, assigned}\optional{, updated}} Update a wrapper function to look like the wrapped function. The optional Modified: python/branches/p3yk-noslice/Doc/lib/libgetopt.tex ============================================================================== --- python/branches/p3yk-noslice/Doc/lib/libgetopt.tex (original) +++ python/branches/p3yk-noslice/Doc/lib/libgetopt.tex Fri Dec 15 05:21:50 2006 @@ -126,8 +126,9 @@ def main(): try: opts, args = getopt.getopt(sys.argv[1:], "ho:v", ["help", "output="]) - except getopt.GetoptError: + except getopt.GetoptError, err: # print help information and exit: + print str(err) # will print something like "option -a not recognized" usage() sys.exit(2) output = None @@ -135,11 +136,13 @@ for o, a in opts: if o == "-v": verbose = True - if o in ("-h", "--help"): + elif o in ("-h", "--help"): usage() sys.exit() - if o in ("-o", "--output"): + elif o in ("-o", "--output"): output = a + else: + assert False, "unhandled option" # ... if __name__ == "__main__": Modified: python/branches/p3yk-noslice/Doc/lib/libhashlib.tex ============================================================================== --- python/branches/p3yk-noslice/Doc/lib/libhashlib.tex (original) +++ python/branches/p3yk-noslice/Doc/lib/libhashlib.tex Fri Dec 15 05:21:50 2006 @@ -86,8 +86,8 @@ \begin{methoddesc}[hash]{digest}{} Return the digest of the strings passed to the \method{update()} -method so far. This is a 16-byte string which may contain -non-\ASCII{} characters, including null bytes. +method so far. This is a string of \member{digest_size} bytes which may +contain non-\ASCII{} characters, including null bytes. \end{methoddesc} \begin{methoddesc}[hash]{hexdigest}{} Modified: python/branches/p3yk-noslice/Doc/lib/libheapq.tex ============================================================================== --- python/branches/p3yk-noslice/Doc/lib/libheapq.tex (original) +++ python/branches/p3yk-noslice/Doc/lib/libheapq.tex Fri Dec 15 05:21:50 2006 @@ -76,14 +76,14 @@ >>> for item in data: ... heappush(heap, item) ... ->>> sorted = [] +>>> ordered = [] >>> while heap: -... sorted.append(heappop(heap)) +... ordered.append(heappop(heap)) ... ->>> print sorted +>>> print ordered [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] >>> data.sort() ->>> print data == sorted +>>> print data == ordered True >>> \end{verbatim} Modified: python/branches/p3yk-noslice/Doc/lib/libhotshot.tex ============================================================================== --- python/branches/p3yk-noslice/Doc/lib/libhotshot.tex (original) +++ python/branches/p3yk-noslice/Doc/lib/libhotshot.tex Fri Dec 15 05:21:50 2006 @@ -61,7 +61,7 @@ \end{methoddesc} \begin{methoddesc}{run}{cmd} -Profile an \keyword{exec}-compatible string in the script environment. +Profile an \function{exec()}-compatible string in the script environment. The globals from the \refmodule[main]{__main__} module are used as both the globals and locals for the script. \end{methoddesc} @@ -76,7 +76,7 @@ \begin{methoddesc}{runctx}{cmd, globals, locals} -Evaluate an \keyword{exec}-compatible string in a specific environment. +Profile an \function{exec()}-compatible string in a specific environment. The string is compiled before profiling begins. \end{methoddesc} Modified: python/branches/p3yk-noslice/Doc/lib/libhttplib.tex ============================================================================== --- python/branches/p3yk-noslice/Doc/lib/libhttplib.tex (original) +++ python/branches/p3yk-noslice/Doc/lib/libhttplib.tex Fri Dec 15 05:21:50 2006 @@ -304,9 +304,14 @@ This will send a request to the server using the HTTP request method \var{method} and the selector \var{url}. If the \var{body} argument is present, it should be a string of data to send after the headers are finished. +Alternatively, it may be an open file object, in which case the +contents of the file is sent; this file object should support +\code{fileno()} and \code{read()} methods. The header Content-Length is automatically set to the correct value. The \var{headers} argument should be a mapping of extra HTTP headers to send with the request. + +\versionchanged[\var{body} can be a file object]{2.6} \end{methoddesc} \begin{methoddesc}{getresponse}{} Modified: python/branches/p3yk-noslice/Doc/lib/libimp.tex ============================================================================== --- python/branches/p3yk-noslice/Doc/lib/libimp.tex (original) +++ python/branches/p3yk-noslice/Doc/lib/libimp.tex Fri Dec 15 05:21:50 2006 @@ -161,10 +161,10 @@ \begin{funcdesc}{init_builtin}{name} Initialize the built-in module called \var{name} and return its module -object. If the module was already initialized, it will be initialized -\emph{again}. A few modules cannot be initialized twice --- attempting -to initialize these again will raise an \exception{ImportError} -exception. If there is no +object along with storing it in \code{sys.modules}. If the module was already +initialized, it will be initialized \emph{again}. Re-initialization involves +the copying of the built-in module's \code{__dict__} from the cached +module over the module's entry in \code{sys.modules}. If there is no built-in module called \var{name}, \code{None} is returned. \end{funcdesc} @@ -208,14 +208,15 @@ \begin{funcdesc}{load_dynamic}{name, pathname\optional{, file}} Load and initialize a module implemented as a dynamically loadable shared library and return its module object. If the module was -already initialized, it will be initialized \emph{again}. Some modules -don't like that and may raise an exception. The \var{pathname} -argument must point to the shared library. The \var{name} argument is -used to construct the name of the initialization function: an external -C function called \samp{init\var{name}()} in the shared library is -called. The optional \var{file} argument is ignored. (Note: using -shared libraries is highly system dependent, and not all systems -support it.) +already initialized, it will be initialized \emph{again}. +Re-initialization involves copying the \code{__dict__} attribute of the cached +instance of the module over the value used in the module cached in +\code{sys.modules}. The \var{pathname} argument must point to the shared +library. The \var{name} argument is used to construct the name of the +initialization function: an external C function called +\samp{init\var{name}()} in the shared library is called. The optional +\var{file} argument is ignored. (Note: using shared libraries is highly +system dependent, and not all systems support it.) \end{funcdesc} \begin{funcdesc}{load_source}{name, pathname\optional{, file}} Modified: python/branches/p3yk-noslice/Doc/lib/libitertools.tex ============================================================================== --- python/branches/p3yk-noslice/Doc/lib/libitertools.tex (original) +++ python/branches/p3yk-noslice/Doc/lib/libitertools.tex Fri Dec 15 05:21:50 2006 @@ -474,8 +474,8 @@ return izip(mapping.iterkeys(), mapping.itervalues()) def nth(iterable, n): - "Returns the nth item" - return list(islice(iterable, n, n+1)) + "Returns the nth item or raise IndexError" + return list(islice(iterable, n, n+1))[0] def all(seq, pred=None): "Returns True if pred(x) is true for every element in the iterable" Modified: python/branches/p3yk-noslice/Doc/lib/liblogging.tex ============================================================================== --- python/branches/p3yk-noslice/Doc/lib/liblogging.tex (original) +++ python/branches/p3yk-noslice/Doc/lib/liblogging.tex Fri Dec 15 05:21:50 2006 @@ -528,8 +528,8 @@ \method{filter()}. \end{methoddesc} -\begin{methoddesc}{makeRecord}{name, lvl, fn, lno, msg, args, exc_info, - func, extra} +\begin{methoddesc}{makeRecord}{name, lvl, fn, lno, msg, args, exc_info + \optional{, func, extra}} This is a factory method which can be overridden in subclasses to create specialized \class{LogRecord} instances. \versionchanged[\var{func} and \var{extra} were added]{2.5} @@ -1397,6 +1397,9 @@ (if available).} \lineii{\%(created)f} {Time when the \class{LogRecord} was created (as returned by \function{time.time()}).} +\lineii{\%(relativeCreated)d} {Time in milliseconds when the LogRecord was + created, relative to the time the logging module was + loaded.} \lineii{\%(asctime)s} {Human-readable time when the \class{LogRecord} was created. By default this is of the form ``2003-07-08 16:49:45,896'' (the numbers after the @@ -1479,7 +1482,7 @@ information to be logged. \begin{classdesc}{LogRecord}{name, lvl, pathname, lineno, msg, args, - exc_info} + exc_info \optional{, func}} Returns an instance of \class{LogRecord} initialized with interesting information. The \var{name} is the logger name; \var{lvl} is the numeric level; \var{pathname} is the absolute pathname of the source @@ -1489,7 +1492,9 @@ which, together with \var{msg}, makes up the user message; and \var{exc_info} is the exception tuple obtained by calling \function{sys.exc_info() }(or \constant{None}, if no exception information -is available). +is available). The \var{func} is the name of the function from which the +logging call was made. If not specified, it defaults to \var{None}. +\versionchanged[\var{func} was added]{2.5} \end{classdesc} \begin{methoddesc}{getMessage}{} Modified: python/branches/p3yk-noslice/Doc/lib/libmsilib.tex ============================================================================== --- python/branches/p3yk-noslice/Doc/lib/libmsilib.tex (original) +++ python/branches/p3yk-noslice/Doc/lib/libmsilib.tex Fri Dec 15 05:21:50 2006 @@ -344,8 +344,8 @@ \subsection{Features\label{features}} \begin{classdesc}{Feature}{database, id, title, desc, display\optional{, - level=1\optional{, parent\optional\{, directory\optional{, - attributes=0}}}} + level=1\optional{, parent\optional{, directory\optional{, + attributes=0}}}}} Add a new record to the \code{Feature} table, using the values \var{id}, \var{parent.id}, \var{title}, \var{desc}, \var{display}, Modified: python/branches/p3yk-noslice/Doc/lib/liboperator.tex ============================================================================== --- python/branches/p3yk-noslice/Doc/lib/liboperator.tex (original) +++ python/branches/p3yk-noslice/Doc/lib/liboperator.tex Fri Dec 15 05:21:50 2006 @@ -55,7 +55,7 @@ Return the outcome of \keyword{not} \var{o}. (Note that there is no \method{__not__()} method for object instances; only the interpreter core defines this operation. The result is affected by the -\method{__nonzero__()} and \method{__len__()} methods.) +\method{__bool__()} and \method{__len__()} methods.) \end{funcdesc} \begin{funcdesc}{truth}{o} Modified: python/branches/p3yk-noslice/Doc/lib/libos.tex ============================================================================== --- python/branches/p3yk-noslice/Doc/lib/libos.tex (original) +++ python/branches/p3yk-noslice/Doc/lib/libos.tex Fri Dec 15 05:21:50 2006 @@ -361,6 +361,10 @@ errors), \code{None} is returned. Availability: Macintosh, \UNIX, Windows. +The \module{subprocess} module provides more powerful facilities for +spawning new processes and retrieving their results; using that module +is preferable to using this function. + \versionchanged[This function worked unreliably under Windows in earlier versions of Python. This was due to the use of the \cfunction{_popen()} function from the libraries provided with @@ -375,8 +379,13 @@ Availability: Macintosh, \UNIX, Windows. \end{funcdesc} +There are a number of different \function{popen*()} functions that +provide slightly different ways to create subprocesses. Note that the +\module{subprocess} module is easier to use and more powerful; +consider using that module before writing code using the +lower-level \function{popen*()} functions. -For each of the following \function{popen()} variants, if \var{bufsize} is +For each of the \function{popen*()} variants, if \var{bufsize} is specified, it specifies the buffer size for the I/O pipes. \var{mode}, if provided, should be the string \code{'b'} or \code{'t'}; on Windows this is needed to determine whether the file @@ -920,6 +929,8 @@ points. The result may be either an absolute or relative pathname; if it is relative, it may be converted to an absolute pathname using \code{os.path.join(os.path.dirname(\var{path}), \var{result})}. +\versionchanged [If the \var{path} is a Unicode object the result will also +be a Unicode object]{2.6} Availability: Macintosh, \UNIX. \end{funcdesc} @@ -1545,7 +1556,13 @@ \funcline{spawnve}{mode, path, args, env} \funcline{spawnvp}{mode, file, args} \funcline{spawnvpe}{mode, file, args, env} -Execute the program \var{path} in a new process. If \var{mode} is +Execute the program \var{path} in a new process. + +(Note that the \module{subprocess} module provides more powerful +facilities for spawning new processes and retrieving their results; +using that module is preferable to using these functions.) + +If \var{mode} is \constant{P_NOWAIT}, this function returns the process ID of the new process; if \var{mode} is \constant{P_WAIT}, returns the process's exit code if it exits normally, or \code{-\var{signal}}, where @@ -1682,6 +1699,10 @@ a non-native shell, consult your shell documentation. Availability: Macintosh, \UNIX, Windows. + +The \module{subprocess} module provides more powerful facilities for +spawning new processes and retrieving their results; using that module +is preferable to using this function. \end{funcdesc} \begin{funcdesc}{times}{} Modified: python/branches/p3yk-noslice/Doc/lib/libparser.tex ============================================================================== --- python/branches/p3yk-noslice/Doc/lib/libparser.tex (original) +++ python/branches/p3yk-noslice/Doc/lib/libparser.tex Fri Dec 15 05:21:50 2006 @@ -193,8 +193,9 @@ \begin{funcdesc}{compileast}{ast\optional{, filename\code{ = ''}}} The Python byte compiler can be invoked on an AST object to produce -code objects which can be used as part of an \keyword{exec} statement or -a call to the built-in \function{eval()}\bifuncindex{eval} function. +code objects which can be used as part of a call to the built-in +\function{exec()}\bifuncindex{exec} or \function{eval()} +\bifuncindex{eval} functions. This function provides the interface to the compiler, passing the internal parse tree from \var{ast} to the parser, using the source file name specified by the \var{filename} parameter. Modified: python/branches/p3yk-noslice/Doc/lib/libpdb.tex ============================================================================== --- python/branches/p3yk-noslice/Doc/lib/libpdb.tex (original) +++ python/branches/p3yk-noslice/Doc/lib/libpdb.tex Fri Dec 15 05:21:50 2006 @@ -79,8 +79,8 @@ explained below). The optional \var{globals} and \var{locals} arguments specify the environment in which the code is executed; by default the dictionary of the module \refmodule[main]{__main__} is -used. (See the explanation of the \keyword{exec} statement or the -\function{eval()} built-in function.) +used. (See the explanation of the built-in \function{exec()} or +\function{eval()} functions.) \end{funcdesc} \begin{funcdesc}{runeval}{expression\optional{, globals\optional{, locals}}} Modified: python/branches/p3yk-noslice/Doc/lib/libpickle.tex ============================================================================== --- python/branches/p3yk-noslice/Doc/lib/libpickle.tex (original) +++ python/branches/p3yk-noslice/Doc/lib/libpickle.tex Fri Dec 15 05:21:50 2006 @@ -519,7 +519,7 @@ version of the object. The next element of the tuple will provide arguments for this callable, and later elements provide additional state information that will subsequently be used to fully reconstruct -the pickled date. +the pickled data. In the unpickling environment this object must be either a class, a callable registered as a ``safe constructor'' (see below), or it must Modified: python/branches/p3yk-noslice/Doc/lib/libpopen2.tex ============================================================================== --- python/branches/p3yk-noslice/Doc/lib/libpopen2.tex (original) +++ python/branches/p3yk-noslice/Doc/lib/libpopen2.tex Fri Dec 15 05:21:50 2006 @@ -11,10 +11,10 @@ input/output/error pipes and obtain their return codes under \UNIX{} and Windows. -Note that starting with Python 2.0, this functionality is available -using functions from the \refmodule{os} module which have the same -names as the factory functions here, but the order of the return -values is more intuitive in the \refmodule{os} module variants. +The \module{subprocess} module provides more powerful facilities for +spawning new processes and retrieving their results. Using the +\module{subprocess} module is preferable to using the \module{popen2} +module. The primary interface offered by this module is a trio of factory functions. For each of these, if \var{bufsize} is specified, @@ -184,3 +184,7 @@ separate threads to read each of the individual files provided by whichever \function{popen*()} function or \class{Popen*} class was used. + +\begin{seealso} + \seemodule{subprocess}{Module for spawning and managing subprocesses.} +\end{seealso} Modified: python/branches/p3yk-noslice/Doc/lib/libprofile.tex ============================================================================== --- python/branches/p3yk-noslice/Doc/lib/libprofile.tex (original) +++ python/branches/p3yk-noslice/Doc/lib/libprofile.tex Fri Dec 15 05:21:50 2006 @@ -319,9 +319,9 @@ \begin{funcdesc}{run}{command\optional{, filename}} -This function takes a single argument that has can be passed to the -\keyword{exec} statement, and an optional file name. In all cases this -routine attempts to \keyword{exec} its first argument, and gather profiling +This function takes a single argument that can be passed to the +\function{exec()} function, and an optional file name. In all cases this +routine attempts to \function{exec()} its first argument, and gather profiling statistics from the execution. If no file name is present, then this function automatically prints a simple profiling report, sorted by the standard name string (file/line/function-name) that is presented in Modified: python/branches/p3yk-noslice/Doc/lib/libpyexpat.tex ============================================================================== --- python/branches/p3yk-noslice/Doc/lib/libpyexpat.tex (original) +++ python/branches/p3yk-noslice/Doc/lib/libpyexpat.tex Fri Dec 15 05:21:50 2006 @@ -216,9 +216,10 @@ \begin{memberdesc}[xmlparser]{returns_unicode} If this attribute is set to a non-zero integer, the handler functions -will be passed Unicode strings. If \member{returns_unicode} is 0, -8-bit strings containing UTF-8 encoded data will be passed to the -handlers. +will be passed Unicode strings. If \member{returns_unicode} is +\constant{False}, 8-bit strings containing UTF-8 encoded data will be +passed to the handlers. This is \constant{True} by default when +Python is built with Unicode support. \versionchanged[Can be changed at any time to affect the result type]{1.6} \end{memberdesc} Modified: python/branches/p3yk-noslice/Doc/lib/librexec.tex ============================================================================== --- python/branches/p3yk-noslice/Doc/lib/librexec.tex (original) +++ python/branches/p3yk-noslice/Doc/lib/librexec.tex Fri Dec 15 05:21:50 2006 @@ -11,10 +11,10 @@ \end{notice} This module contains the \class{RExec} class, which supports -\method{r_eval()}, \method{r_execfile()}, \method{r_exec()}, and +\method{r_exec()}, \method{r_eval()}, \method{r_execfile()}, and \method{r_import()} methods, which are restricted versions of the standard -Python functions \method{eval()}, \method{execfile()} and -the \keyword{exec} and \keyword{import} statements. +Python functions \method{exec()}, \method{eval()}, \method{execfile()} and +the \keyword{import} statement. Code executed in this restricted environment will only have access to modules and functions that are deemed safe; you can subclass \class{RExec} to add or remove capabilities as desired. Modified: python/branches/p3yk-noslice/Doc/lib/libsmtplib.tex ============================================================================== --- python/branches/p3yk-noslice/Doc/lib/libsmtplib.tex (original) +++ python/branches/p3yk-noslice/Doc/lib/libsmtplib.tex Fri Dec 15 05:21:50 2006 @@ -28,6 +28,18 @@ included below. \end{classdesc} +\begin{classdesc}{SMTP_SSL}{\optional{host\optional{, port\optional{, + local_hostname\optional{, + keyfile\optional{, + certfile}}}}}} +A \class{SMTP_SSL} instance behaves exactly the same as instances of \class{SMTP}. +\class{SMTP_SSL} should be used for situations where SSL is required from +the beginning of the connection and using \method{starttls()} is not appropriate. +If \var{host} is not specified, the local host is used. If \var{port} is +omitted, the standard SMTP-over-SSL port (465) is used. \var{keyfile} and \var{certfile} +are also optional, and can contain a PEM formatted private key and +certificate chain file for the SSL connection. +\end{classdesc} A nice selection of exceptions is defined as well: Modified: python/branches/p3yk-noslice/Doc/lib/libsocket.tex ============================================================================== --- python/branches/p3yk-noslice/Doc/lib/libsocket.tex (original) +++ python/branches/p3yk-noslice/Doc/lib/libsocket.tex Fri Dec 15 05:21:50 2006 @@ -241,8 +241,8 @@ This operation assumes that there is a valid address-to-host mapping for the host, and the assumption does not always hold. Note: \function{gethostname()} doesn't always return the fully qualified -domain name; use \code{gethostbyaddr(gethostname())} -(see below). +domain name; use \code{getfqdn()} +(see above). \end{funcdesc} \begin{funcdesc}{gethostbyaddr}{ip_address} @@ -712,14 +712,15 @@ \end{methoddesc} \begin{methoddesc}{server}{} -Returns a string containing the ASN.1 distinguished name identifying the -server's certificate. (See below for an example -showing what distinguished names look like.) +Returns a string describing the server's certificate. +Useful for debugging purposes; do not parse the content of this string +because its format can't be parsed unambiguously. \end{methoddesc} \begin{methoddesc}{issuer}{} -Returns a string containing the ASN.1 distinguished name identifying the -issuer of the server's certificate. +Returns a string describing the issuer of the server's certificate. +Useful for debugging purposes; do not parse the content of this string +because its format can't be parsed unambiguously. \end{methoddesc} \subsection{Example \label{socket-example}} Modified: python/branches/p3yk-noslice/Doc/lib/libsqlite3.tex ============================================================================== --- python/branches/p3yk-noslice/Doc/lib/libsqlite3.tex (original) +++ python/branches/p3yk-noslice/Doc/lib/libsqlite3.tex Fri Dec 15 05:21:50 2006 @@ -6,14 +6,16 @@ \sectionauthor{Gerhard H??ring}{gh at ghaering.de} \versionadded{2.5} -SQLite is a C library that provides a SQL-language database that -stores data in disk files without requiring a separate server process. +SQLite is a C library that provides a lightweight disk-based database +that doesn't require a separate server process and allows accessing +the database using a nonstandard variant of the SQL query language. +Some applications can use SQLite for internal data storage. It's also +possible to prototype an application using SQLite and then port the +code to a larger database such as PostgreSQL or Oracle. + pysqlite was written by Gerhard H\"aring and provides a SQL interface compliant with the DB-API 2.0 specification described by -\pep{249}. This means that it should be possible to write the first -version of your applications using SQLite for data storage. If -switching to a larger database such as PostgreSQL or Oracle is -later necessary, the switch should be relatively easy. +\pep{249}. To use the module, you must first create a \class{Connection} object that represents the database. Here the data will be stored in the @@ -34,8 +36,8 @@ # Create table c.execute('''create table stocks -(date timestamp, trans varchar, symbol varchar, - qty decimal, price decimal)''') +(date text, trans text, symbol text, + qty real, price real)''') # Insert a row of data c.execute("""insert into stocks @@ -144,11 +146,11 @@ wait for the lock to go away until raising an exception. The default for the timeout parameter is 5.0 (five seconds). -For the \var{isolation_level} parameter, please see \member{isolation_level} -\ref{sqlite3-Connection-IsolationLevel} property of \class{Connection} objects. +For the \var{isolation_level} parameter, please see the \member{isolation_level} +property of \class{Connection} objects in section~\ref{sqlite3-Connection-IsolationLevel}. SQLite natively supports only the types TEXT, INTEGER, FLOAT, BLOB and NULL. If -you want to use other types, like you have to add support for them yourself. +you want to use other types you must add support for them yourself. The \var{detect_types} parameter and the using custom \strong{converters} registered with the module-level \function{register_converter} function allow you to easily do that. @@ -195,7 +197,7 @@ \verbatiminput{sqlite3/complete_statement.py} \end{funcdesc} -\begin{funcdesc}{}enable_callback_tracebacks{flag} +\begin{funcdesc}{enable_callback_tracebacks}{flag} By default you will not get any tracebacks in user-defined functions, aggregates, converters, authorizer callbacks etc. If you want to debug them, you can call this function with \var{flag} as True. Afterwards, you will get @@ -210,13 +212,14 @@ \label{sqlite3-Connection-IsolationLevel} \begin{memberdesc}{isolation_level} Get or set the current isolation level. None for autocommit mode or one of - "DEFERRED", "IMMEDIATE" or "EXLUSIVE". See Controlling Transactions - \ref{sqlite3-Controlling-Transactions} for a more detailed explanation. + "DEFERRED", "IMMEDIATE" or "EXLUSIVE". See ``Controlling Transactions'', + section~\ref{sqlite3-Controlling-Transactions}, for a more detailed explanation. \end{memberdesc} \begin{methoddesc}{cursor}{\optional{cursorClass}} The cursor method accepts a single optional parameter \var{cursorClass}. - This is a custom cursor class which must extend \class{sqlite3.Cursor}. + If supplied, this must be a custom cursor class that extends + \class{sqlite3.Cursor}. \end{methoddesc} \begin{methoddesc}{execute}{sql, \optional{parameters}} @@ -242,7 +245,7 @@ Creates a user-defined function that you can later use from within SQL statements under the function name \var{name}. \var{num_params} is the number of parameters the function accepts, and \var{func} is a Python callable that is -called as SQL function. +called as the SQL function. The function can return any of the types supported by SQLite: unicode, str, int, long, float, buffer and None. @@ -272,7 +275,7 @@ Creates a collation with the specified \var{name} and \var{callable}. The callable will be passed two string arguments. It should return -1 if the first -is ordered lower than the second, 0 if they are ordered equal and 1 and if the +is ordered lower than the second, 0 if they are ordered equal and 1 if the first is ordered higher than the second. Note that this controls sorting (ORDER BY in SQL) so your comparisons don't affect other SQL operations. @@ -321,20 +324,21 @@ \begin{memberdesc}{row_factory} You can change this attribute to a callable that accepts the cursor and - the original row as tuple and will return the real result row. This - way, you can implement more advanced ways of returning results, like - ones that can also access columns by name. + the original row as a tuple and will return the real result row. This + way, you can implement more advanced ways of returning results, such + as returning an object that can also access columns by name. Example: \verbatiminput{sqlite3/row_factory.py} - If the standard tuple types don't suffice for you, and you want name-based + If returning a tuple doesn't suffice and you want name-based access to columns, you should consider setting \member{row_factory} to the - highly-optimized sqlite3.Row type. It provides both + highly-optimized \class{sqlite3.Row} type. \class{Row} provides both index-based and case-insensitive name-based access to columns with almost - no memory overhead. Much better than your own custom dictionary-based - approach or even a db_row based solution. + no memory overhead. It will probably be better than your own custom + dictionary-based approach or even a db_row based solution. + % XXX what's a db_row-based solution? \end{memberdesc} \begin{memberdesc}{text_factory} @@ -348,7 +352,7 @@ attribute to \constant{sqlite3.OptimizedUnicode}. You can also set it to any other callable that accepts a single bytestring - parameter and returns the result object. + parameter and returns the resulting object. See the following example code for illustration: @@ -356,7 +360,7 @@ \end{memberdesc} \begin{memberdesc}{total_changes} - Returns the total number of database rows that have be modified, inserted, + Returns the total number of database rows that have been modified, inserted, or deleted since the database connection was opened. \end{memberdesc} @@ -383,9 +387,9 @@ \verbatiminput{sqlite3/execute_2.py} - \method{execute} will only execute a single SQL statement. If you try to + \method{execute()} will only execute a single SQL statement. If you try to execute more than one statement with it, it will raise a Warning. Use - \method{executescript} if want to execute multiple SQL statements with one + \method{executescript()} if you want to execute multiple SQL statements with one call. \end{methoddesc} @@ -393,7 +397,7 @@ \begin{methoddesc}{executemany}{sql, seq_of_parameters} Executes a SQL command against all parameter sequences or mappings found in the sequence \var{sql}. The \module{sqlite3} module also allows -to use an iterator yielding parameters instead of a sequence. +using an iterator yielding parameters instead of a sequence. \verbatiminput{sqlite3/executemany_1.py} @@ -405,7 +409,7 @@ \begin{methoddesc}{executescript}{sql_script} This is a nonstandard convenience method for executing multiple SQL statements -at once. It issues a COMMIT statement before, then executes the SQL script it +at once. It issues a COMMIT statement first, then executes the SQL script it gets as a parameter. \var{sql_script} can be a bytestring or a Unicode string. @@ -462,20 +466,19 @@ \lineii{BLOB}{buffer} \end{tableii} -The type system of the \module{sqlite3} module is extensible in both ways: you can store +The type system of the \module{sqlite3} module is extensible in two ways: you can store additional Python types in a SQLite database via object adaptation, and you can let the \module{sqlite3} module convert SQLite types to different Python types via converters. \subsubsection{Using adapters to store additional Python types in SQLite databases} -Like described before, SQLite supports only a limited set of types natively. To +As described before, SQLite supports only a limited set of types natively. To use other Python types with SQLite, you must \strong{adapt} them to one of the sqlite3 -module's supported types for SQLite. So, one of NoneType, int, long, float, +module's supported types for SQLite: one of NoneType, int, long, float, str, unicode, buffer. -The \module{sqlite3} module uses the Python object adaptation, like described in PEP 246 -for this. The protocol to use is \class{PrepareProtocol}. +The \module{sqlite3} module uses Python object adaptation, as described in \pep{246} for this. The protocol to use is \class{PrepareProtocol}. There are two ways to enable the \module{sqlite3} module to adapt a custom Python type to one of the supported ones. @@ -491,8 +494,8 @@ self.x, self.y = x, y \end{verbatim} -Now you want to store the point in a single SQLite column. You'll have to -choose one of the supported types first that you use to represent the point in. +Now you want to store the point in a single SQLite column. First you'll have to +choose one of the supported types first to be used for representing the point. Let's just use str and separate the coordinates using a semicolon. Then you need to give your class a method \code{__conform__(self, protocol)} which must return the converted value. The parameter \var{protocol} will be @@ -505,13 +508,13 @@ The other possibility is to create a function that converts the type to the string representation and register the function with \method{register_adapter}. - \verbatiminput{sqlite3/adapter_point_2.py} - \begin{notice} The type/class to adapt must be a new-style class, i. e. it must have \class{object} as one of its bases. \end{notice} + \verbatiminput{sqlite3/adapter_point_2.py} + The \module{sqlite3} module has two default adapters for Python's built-in \class{datetime.date} and \class{datetime.datetime} types. Now let's suppose we want to store \class{datetime.datetime} objects not in ISO representation, @@ -521,16 +524,17 @@ \subsubsection{Converting SQLite values to custom Python types} -Now that's all nice and dandy that you can send custom Python types to SQLite. +Writing an adapter lets you send custom Python types to SQLite. But to make it really useful we need to make the Python to SQLite to Python -roundtrip work. +roundtrip work. Enter converters. -Let's go back to the Point class. We stored the x and y coordinates separated -via semicolons as strings in SQLite. +Let's go back to the \class{Point} class. We stored the x and y +coordinates separated via semicolons as strings in SQLite. -Let's first define a converter function that accepts the string as a parameter and constructs a Point object from it. +First, we'll define a converter function that accepts the string as a +parameter and constructs a \class{Point} object from it. \begin{notice} Converter functions \strong{always} get called with a string, no matter @@ -556,11 +560,12 @@ \item Explicitly via the column name \end{itemize} -Both ways are described at \ref{sqlite3-Module-Contents} in the text explaining -the constants \constant{PARSE_DECLTYPES} and \constant{PARSE_COlNAMES}. +Both ways are described in ``Module Constants'', section~\ref{sqlite3-Module-Contents}, in +the entries for the constants \constant{PARSE_DECLTYPES} and +\constant{PARSE_COLNAMES}. -The following example illustrates both ways. +The following example illustrates both approaches. \verbatiminput{sqlite3/converter_point.py} @@ -569,8 +574,8 @@ There are default adapters for the date and datetime types in the datetime module. They will be sent as ISO dates/ISO timestamps to SQLite. -The default converters are registered under the name "date" for datetime.date -and under the name "timestamp" for datetime.datetime. +The default converters are registered under the name "date" for \class{datetime.date} +and under the name "timestamp" for \class{datetime.datetime}. This way, you can use date/timestamps from Python without any additional fiddling in most cases. The format of the adapters is also compatible with the @@ -582,12 +587,12 @@ \subsection{Controlling Transactions \label{sqlite3-Controlling-Transactions}} -By default, the \module{sqlite3} module opens transactions implicitly before a DML -statement (INSERT/UPDATE/DELETE/REPLACE), and commits transactions implicitly -before a non-DML, non-DQL statement (i. e. anything other than +By default, the \module{sqlite3} module opens transactions implicitly before a Data Modification Language (DML) +statement (i.e. INSERT/UPDATE/DELETE/REPLACE), and commits transactions implicitly +before a non-DML, non-query statement (i. e. anything other than SELECT/INSERT/UPDATE/DELETE/REPLACE). -So if you are within a transaction, and issue a command like \code{CREATE TABLE +So if you are within a transaction and issue a command like \code{CREATE TABLE ...}, \code{VACUUM}, \code{PRAGMA}, the \module{sqlite3} module will commit implicitly before executing that command. There are two reasons for doing that. The first is that some of these commands don't work within transactions. The other reason @@ -616,17 +621,17 @@ Using the nonstandard \method{execute}, \method{executemany} and \method{executescript} methods of the \class{Connection} object, your code can -be written more concisely, because you don't have to create the - often -superfluous \class{Cursor} objects explicitly. Instead, the \class{Cursor} +be written more concisely because you don't have to create the (often +superfluous) \class{Cursor} objects explicitly. Instead, the \class{Cursor} objects are created implicitly and these shortcut methods return the cursor -objects. This way, you can for example execute a SELECT statement and iterate +objects. This way, you can execute a SELECT statement and iterate over it directly using only a single call on the \class{Connection} object. \verbatiminput{sqlite3/shortcut_methods.py} \subsubsection{Accessing columns by name instead of by index} -One cool feature of the \module{sqlite3} module is the builtin \class{sqlite3.Row} class +One useful feature of the \module{sqlite3} module is the builtin \class{sqlite3.Row} class designed to be used as a row factory. Rows wrapped with this class can be accessed both by index (like tuples) and Modified: python/branches/p3yk-noslice/Doc/lib/libstdtypes.tex ============================================================================== --- python/branches/p3yk-noslice/Doc/lib/libstdtypes.tex (original) +++ python/branches/p3yk-noslice/Doc/lib/libstdtypes.tex Fri Dec 15 05:21:50 2006 @@ -51,7 +51,7 @@ \item any empty mapping, for example, \code{\{\}}. \item instances of user-defined classes, if the class defines a - \method{__nonzero__()} or \method{__len__()} method, when that + \method{__bool__()} or \method{__len__()} method, when that method returns the integer zero or \class{bool} value \code{False}.\footnote{Additional information on these special methods may be found in the @@ -126,8 +126,7 @@ \lineiii{>}{strictly greater than}{} \lineiii{>=}{greater than or equal}{} \lineiii{==}{equal}{} - \lineiii{!=}{not equal}{(1)} - \lineiii{<>}{not equal}{(1)} + \lineiii{!=}{not equal}{} \lineiii{is}{object identity}{} \lineiii{is not}{negated object identity}{} \end{tableiii} @@ -136,17 +135,6 @@ \opindex{is} \opindex{is not} -\noindent -Notes: - -\begin{description} - -\item[(1)] -\code{<>} and \code{!=} are alternate spellings for the same operator. -\code{!=} is the preferred spelling; \code{<>} is obsolescent. - -\end{description} - Objects of different types, except different numeric types and different string types, never compare equal; such objects are ordered consistently but arbitrarily (so that sorting a heterogeneous array yields a consistent result). @@ -771,8 +759,8 @@ Split the string at the last occurrence of \var{sep}, and return a 3-tuple containing the part before the separator, the separator itself, and the part after the separator. If the separator is not -found, return a 3-tuple containing the string itself, followed by -two empty strings. +found, return a 3-tuple containing two empty strings, followed by +the string itself. \versionadded{2.5} \end{methoddesc} @@ -834,7 +822,7 @@ start\optional{, end}}} Return \code{True} if string starts with the \var{prefix}, otherwise return \code{False}. \var{prefix} can also be a tuple of -suffixes to look for. With optional \var{start}, test string beginning at +prefixes to look for. With optional \var{start}, test string beginning at that position. With optional \var{end}, stop comparing string at that position. @@ -876,6 +864,9 @@ characters have been mapped through the given translation table, which must be a string of length 256. +You can use the \function{maketrans()} helper function in the +\refmodule{string} module to create a translation table. + For Unicode objects, the \method{translate()} method does not accept the optional \var{deletechars} argument. Instead, it returns a copy of the \var{s} where all characters have been mapped @@ -1410,21 +1401,22 @@ {(1)} \lineiii{\var{a}.clear()}{remove all items from \code{a}}{} \lineiii{\var{a}.copy()}{a (shallow) copy of \code{a}}{} - \lineiii{\var{a}.has_key(\var{k})} + \lineiii{\var{k} in \var{a}} {\code{True} if \var{a} has a key \var{k}, else \code{False}} - {} - \lineiii{\var{k} \code{in} \var{a}} - {Equivalent to \var{a}.has_key(\var{k})} {(2)} \lineiii{\var{k} not in \var{a}} - {Equivalent to \code{not} \var{a}.has_key(\var{k})} + {Equivalent to \code{not} \var{k} in \var{a}} {(2)} + \lineiii{\var{a}.has_key(\var{k})} + {Equivalent to \var{k} \code{in} \var{a}, use that form in new code} + {} \lineiii{\var{a}.items()} {a copy of \var{a}'s list of (\var{key}, \var{value}) pairs} {(3)} \lineiii{\var{a}.keys()}{a copy of \var{a}'s list of keys}{(3)} \lineiii{\var{a}.update(\optional{\var{b}})} - {updates (and overwrites) key/value pairs from \var{b}} + {updates \var{a} with key/value pairs from \var{b}, overwriting + existing keys, returns \code{None}} {(9)} \lineiii{\var{a}.fromkeys(\var{seq}\optional{, \var{value}})} {Creates a new dictionary with keys from \var{seq} and values set to \var{value}} @@ -1682,6 +1674,7 @@ behavior. Note that not all file objects are seekable. + \versionchanged{Passing float values as offset has been deprecated}[2.6] \end{methoddesc} \begin{methoddesc}[file]{tell}{} @@ -1984,9 +1977,9 @@ \withsubitem{(function object attribute)}{\ttindex{func_code}} A code object can be executed or evaluated by passing it (instead of a -source string) to the \keyword{exec} statement or the built-in -\function{eval()} function. -\stindex{exec} +source string) to the \function{exec()} or \function{eval()} +built-in functions. +\bifuncindex{exec} \bifuncindex{eval} See the \citetitle[../ref/ref.html]{Python Reference Manual} for more @@ -2016,12 +2009,12 @@ \subsection{The Ellipsis Object \label{bltin-ellipsis-object}} -This object is used by extended slice notation (see the +This object is mostly used by extended slice notation (see the \citetitle[../ref/ref.html]{Python Reference Manual}). It supports no special operations. There is exactly one ellipsis object, named \constant{Ellipsis} (a built-in name). -It is written as \code{Ellipsis}. +It is written as \code{Ellipsis} or \code{...}. \subsection{Boolean Values} Modified: python/branches/p3yk-noslice/Doc/lib/libstdwin.tex ============================================================================== --- python/branches/p3yk-noslice/Doc/lib/libstdwin.tex (original) +++ python/branches/p3yk-noslice/Doc/lib/libstdwin.tex Fri Dec 15 05:21:50 2006 @@ -123,8 +123,8 @@ Hint: the following code tests whether you are on a machine that supports more than two colors: \begin{verbatim} -if stdwin.fetchcolor('black') <> \ - stdwin.fetchcolor('red') <> \ +if stdwin.fetchcolor('black') != \ + stdwin.fetchcolor('red') != \ stdwin.fetchcolor('white'): print 'color machine' else: Modified: python/branches/p3yk-noslice/Doc/lib/libstring.tex ============================================================================== --- python/branches/p3yk-noslice/Doc/lib/libstring.tex (original) +++ python/branches/p3yk-noslice/Doc/lib/libstring.tex Fri Dec 15 05:21:50 2006 @@ -220,7 +220,7 @@ \begin{funcdesc}{maketrans}{from, to} Return a translation table suitable for passing to - \function{translate()} or \function{regex.compile()}, that will map + \function{translate()}, that will map each character in \var{from} into the character at the same position in \var{to}; \var{from} and \var{to} must have the same length. Modified: python/branches/p3yk-noslice/Doc/lib/libsubprocess.tex ============================================================================== --- python/branches/p3yk-noslice/Doc/lib/libsubprocess.tex (original) +++ python/branches/p3yk-noslice/Doc/lib/libsubprocess.tex Fri Dec 15 05:21:50 2006 @@ -12,9 +12,6 @@ codes. This module intends to replace several other, older modules and functions, such as: -% XXX Should add pointers to this module to at least the popen2 -% and commands sections. - \begin{verbatim} os.system os.spawn* Modified: python/branches/p3yk-noslice/Doc/lib/libtempfile.tex ============================================================================== --- python/branches/p3yk-noslice/Doc/lib/libtempfile.tex (original) +++ python/branches/p3yk-noslice/Doc/lib/libtempfile.tex Fri Dec 15 05:21:50 2006 @@ -86,7 +86,12 @@ prefix; otherwise, a default prefix is used. If \var{dir} is specified, the file will be created in that directory; -otherwise, a default directory is used. +otherwise, a default directory is used. The default directory is chosen +from a platform-dependent list, but the user of the application can control +the directory location by setting the \var{TMPDIR}, \var{TEMP} or \var{TMP} +environment variables. There is thus no guarantee that the generated +filename will have any nice properties, such as not requiring quoting when +passed to external commands via \code{os.popen()}. If \var{text} is specified, it indicates whether to open the file in binary mode (the default) or text mode. On some platforms, this makes Modified: python/branches/p3yk-noslice/Doc/lib/libtimeit.tex ============================================================================== --- python/branches/p3yk-noslice/Doc/lib/libtimeit.tex (original) +++ python/branches/p3yk-noslice/Doc/lib/libtimeit.tex Fri Dec 15 05:21:50 2006 @@ -162,13 +162,13 @@ missing and present object attributes. \begin{verbatim} -% timeit.py 'try:' ' str.__nonzero__' 'except AttributeError:' ' pass' +% timeit.py 'try:' ' str.__bool__' 'except AttributeError:' ' pass' 100000 loops, best of 3: 15.7 usec per loop -% timeit.py 'if hasattr(str, "__nonzero__"): pass' +% timeit.py 'if hasattr(str, "__bool__"): pass' 100000 loops, best of 3: 4.26 usec per loop -% timeit.py 'try:' ' int.__nonzero__' 'except AttributeError:' ' pass' +% timeit.py 'try:' ' int.__bool__' 'except AttributeError:' ' pass' 1000000 loops, best of 3: 1.43 usec per loop -% timeit.py 'if hasattr(int, "__nonzero__"): pass' +% timeit.py 'if hasattr(int, "__bool__"): pass' 100000 loops, best of 3: 2.23 usec per loop \end{verbatim} @@ -176,7 +176,7 @@ >>> import timeit >>> s = """\ ... try: -... str.__nonzero__ +... str.__bool__ ... except AttributeError: ... pass ... """ @@ -184,14 +184,14 @@ >>> print "%.2f usec/pass" % (1000000 * t.timeit(number=100000)/100000) 17.09 usec/pass >>> s = """\ -... if hasattr(str, '__nonzero__'): pass +... if hasattr(str, '__bool__'): pass ... """ >>> t = timeit.Timer(stmt=s) >>> print "%.2f usec/pass" % (1000000 * t.timeit(number=100000)/100000) 4.85 usec/pass >>> s = """\ ... try: -... int.__nonzero__ +... int.__bool__ ... except AttributeError: ... pass ... """ @@ -199,7 +199,7 @@ >>> print "%.2f usec/pass" % (1000000 * t.timeit(number=100000)/100000) 1.97 usec/pass >>> s = """\ -... if hasattr(int, '__nonzero__'): pass +... if hasattr(int, '__bool__'): pass ... """ >>> t = timeit.Timer(stmt=s) >>> print "%.2f usec/pass" % (1000000 * t.timeit(number=100000)/100000) Modified: python/branches/p3yk-noslice/Doc/lib/libtraceback.tex ============================================================================== --- python/branches/p3yk-noslice/Doc/lib/libtraceback.tex (original) +++ python/branches/p3yk-noslice/Doc/lib/libtraceback.tex Fri Dec 15 05:21:50 2006 @@ -139,7 +139,7 @@ def run_user_code(envdir): source = raw_input(">>> ") try: - exec source in envdir + exec(source, envdir) except: print "Exception in user code:" print '-'*60 Modified: python/branches/p3yk-noslice/Doc/lib/libunittest.tex ============================================================================== --- python/branches/p3yk-noslice/Doc/lib/libunittest.tex (original) +++ python/branches/p3yk-noslice/Doc/lib/libunittest.tex Fri Dec 15 05:21:50 2006 @@ -212,8 +212,8 @@ class DefaultWidgetSizeTestCase(unittest.TestCase): def runTest(self): - widget = Widget("The widget") - self.failUnless(widget.size() == (50,50), 'incorrect default size') + widget = Widget('The widget') + self.assertEqual(widget.size(), (50, 50), 'incorrect default size') \end{verbatim} Note that in order to test something, we use the one of the @@ -247,7 +247,7 @@ class SimpleWidgetTestCase(unittest.TestCase): def setUp(self): - self.widget = Widget("The widget") + self.widget = Widget('The widget') class DefaultWidgetSizeTestCase(SimpleWidgetTestCase): def runTest(self): @@ -273,7 +273,7 @@ class SimpleWidgetTestCase(unittest.TestCase): def setUp(self): - self.widget = Widget("The widget") + self.widget = Widget('The widget') def tearDown(self): self.widget.dispose() @@ -298,7 +298,7 @@ class WidgetTestCase(unittest.TestCase): def setUp(self): - self.widget = Widget("The widget") + self.widget = Widget('The widget') def tearDown(self): self.widget.dispose() @@ -322,8 +322,8 @@ passing the method name in the constructor: \begin{verbatim} -defaultSizeTestCase = WidgetTestCase("testDefaultSize") -resizeTestCase = WidgetTestCase("testResize") +defaultSizeTestCase = WidgetTestCase('testDefaultSize') +resizeTestCase = WidgetTestCase('testResize') \end{verbatim} Test case instances are grouped together according to the features @@ -333,8 +333,8 @@ \begin{verbatim} widgetTestSuite = unittest.TestSuite() -widgetTestSuite.addTest(WidgetTestCase("testDefaultSize")) -widgetTestSuite.addTest(WidgetTestCase("testResize")) +widgetTestSuite.addTest(WidgetTestCase('testDefaultSize')) +widgetTestSuite.addTest(WidgetTestCase('testResize')) \end{verbatim} For the ease of running tests, as we will see later, it is a good @@ -344,8 +344,8 @@ \begin{verbatim} def suite(): suite = unittest.TestSuite() - suite.addTest(WidgetTestCase("testDefaultSize")) - suite.addTest(WidgetTestCase("testResize")) + suite.addTest(WidgetTestCase('testDefaultSize')) + suite.addTest(WidgetTestCase('testResize')) return suite \end{verbatim} @@ -353,7 +353,7 @@ \begin{verbatim} def suite(): - tests = ["testDefaultSize", "testResize"] + tests = ['testDefaultSize', 'testResize'] return unittest.TestSuite(map(WidgetTestCase, tests)) \end{verbatim} @@ -462,7 +462,7 @@ \subsection{Classes and functions \label{unittest-contents}} -\begin{classdesc}{TestCase}{} +\begin{classdesc}{TestCase}{\optional{methodName}} Instances of the \class{TestCase} class represent the smallest testable units in the \module{unittest} universe. This class is intended to be used as a base class, with specific tests being @@ -470,6 +470,23 @@ interface needed by the test runner to allow it to drive the test, and methods that the test code can use to check for and report various kinds of failure. + + Each instance of \class{TestCase} will run a single test method: + the method named \var{methodName}. If you remember, we had an + earlier example that went something like this: + + \begin{verbatim} + def suite(): + suite = unittest.TestSuite() + suite.addTest(WidgetTestCase('testDefaultSize')) + suite.addTest(WidgetTestCase('testResize')) + return suite + \end{verbatim} + + Here, we create two instances of \class{WidgetTestCase}, each of + which runs a single test. + + \var{methodName} defaults to \code{'runTest'}. \end{classdesc} \begin{classdesc}{FunctionTestCase}{testFunc\optional{, @@ -502,6 +519,11 @@ subclass. \end{classdesc} +\begin{classdesc}{TestResult}{} + This class is used to compile information about which tests have succeeded + and which have failed. +\end{classdesc} + \begin{datadesc}{defaultTestLoader} Instance of the \class{TestLoader} class intended to be shared. If no customization of the \class{TestLoader} is needed, this instance can @@ -574,8 +596,9 @@ \begin{methoddesc}[TestCase]{run}{\optional{result}} Run the test, collecting the result into the test result object passed as \var{result}. If \var{result} is omitted or \constant{None}, - a temporary result object is created and used, but is not made - available to the caller. + a temporary result object is created (by calling the + \method{defaultTestCase()} method) and used; this result object is not + returned to \method{run()}'s caller. The same effect may be had by simply calling the \class{TestCase} instance. @@ -684,8 +707,13 @@ \end{methoddesc} \begin{methoddesc}[TestCase]{defaultTestResult}{} - Return the default type of test result object to be used to run this - test. + Return an instance of the test result class that should be used + for this test case class (if no other result instance is provided + to the \method{run()} method). + + For \class{TestCase} instances, this will always be an instance of + \class{TestResult}; subclasses of \class{TestCase} should + override this as necessary. \end{methoddesc} \begin{methoddesc}[TestCase]{id}{} @@ -761,26 +789,20 @@ tests for reporting purposes; a \class{TestResult} instance is returned by the \method{TestRunner.run()} method for this purpose. -Each instance holds the total number of tests run, and collections of -failures and errors that occurred among those test runs. The -collections contain tuples of \code{(\var{testcase}, -\var{traceback})}, where \var{traceback} is a string containing a -formatted version of the traceback for the exception. - \class{TestResult} instances have the following attributes that will be of interest when inspecting the results of running a set of tests: \begin{memberdesc}[TestResult]{errors} A list containing 2-tuples of \class{TestCase} instances and - formatted tracebacks. Each tuple represents a test which raised an - unexpected exception. + strings holding formatted tracebacks. Each tuple represents a test which + raised an unexpected exception. \versionchanged[Contains formatted tracebacks instead of \function{sys.exc_info()} results]{2.2} \end{memberdesc} \begin{memberdesc}[TestResult]{failures} - A list containing 2-tuples of \class{TestCase} instances and - formatted tracebacks. Each tuple represents a test where a failure + A list containing 2-tuples of \class{TestCase} instances and strings + holding formatted tracebacks. Each tuple represents a test where a failure was explicitly signalled using the \method{TestCase.fail*()} or \method{TestCase.assert*()} methods. \versionchanged[Contains formatted tracebacks instead of @@ -817,17 +839,25 @@ \begin{methoddesc}[TestResult]{startTest}{test} Called when the test case \var{test} is about to be run. + + The default implementation simply increments the instance's + \code{testsRun} counter. \end{methoddesc} \begin{methoddesc}[TestResult]{stopTest}{test} - Called when the test case \var{test} has been executed, regardless + Called after the test case \var{test} has been executed, regardless of the outcome. + + The default implementation does nothing. \end{methoddesc} \begin{methoddesc}[TestResult]{addError}{test, err} Called when the test case \var{test} raises an unexpected exception \var{err} is a tuple of the form returned by \function{sys.exc_info()}: \code{(\var{type}, \var{value}, \var{traceback})}. + + The default implementation appends \code{(\var{test}, \var{err})} to + the instance's \code{errors} attribute. \end{methoddesc} \begin{methoddesc}[TestResult]{addFailure}{test, err} @@ -835,10 +865,15 @@ \var{err} is a tuple of the form returned by \function{sys.exc_info()}: \code{(\var{type}, \var{value}, \var{traceback})}. + + The default implementation appends \code{(\var{test}, \var{err})} to + the instance's \code{failures} attribute. \end{methoddesc} \begin{methoddesc}[TestResult]{addSuccess}{test} Called when the test case \var{test} succeeds. + + The default implementation does nothing. \end{methoddesc} @@ -878,9 +913,12 @@ Return a suite of all tests cases given a string specifier. The specifier \var{name} is a ``dotted name'' that may resolve - either to a module, a test case class, a \class{TestSuite} instance, - a test method within a test case class, or a callable object which - returns a \class{TestCase} or \class{TestSuite} instance. + either to a module, a test case class, a test method within a test + case class, a \class{TestSuite} instance, or a callable object which + returns a \class{TestCase} or \class{TestSuite} instance. These checks + are applied in the order listed here; that is, a method on a possible + test case class will be picked up as ``a test method within a test + case class'', rather than ``a callable object''. For example, if you have a module \module{SampleTests} containing a \class{TestCase}-derived class \class{SampleTestCase} with three test @@ -905,7 +943,7 @@ \begin{methoddesc}[TestLoader]{getTestCaseNames}{testCaseClass} Return a sorted sequence of method names found within - \var{testCaseClass}. + \var{testCaseClass}; this should be a subclass of \class{TestCase}. \end{methoddesc} Modified: python/branches/p3yk-noslice/Doc/lib/liburlparse.tex ============================================================================== --- python/branches/p3yk-noslice/Doc/lib/liburlparse.tex (original) +++ python/branches/p3yk-noslice/Doc/lib/liburlparse.tex Fri Dec 15 05:21:50 2006 @@ -142,7 +142,7 @@ \begin{funcdesc}{urljoin}{base, url\optional{, allow_fragments}} Construct a full (``absolute'') URL by combining a ``base URL'' -(\var{base}) with a ``relative URL'' (\var{url}). Informally, this +(\var{base}) with another URL (\var{url}). Informally, this uses components of the base URL, in particular the addressing scheme, the network location and (part of) the path, to provide missing components in the relative URL. For example: @@ -155,6 +155,20 @@ The \var{allow_fragments} argument has the same meaning and default as for \function{urlparse()}. + +\note{If \var{url} is an absolute URL (that is, starting with \code{//} + or \code{scheme://}, the \var{url}'s host name and/or scheme + will be present in the result. For example:} + +\begin{verbatim} +>>> urljoin('http://www.cwi.nl/%7Eguido/Python.html', +... '//www.python.org/%7Eguido') +'http://www.python.org/%7Eguido' +\end{verbatim} + +If you do not want that behavior, preprocess +the \var{url} with \function{urlsplit()} and \function{urlunsplit()}, +removing possible \em{scheme} and \em{netloc} parts. \end{funcdesc} \begin{funcdesc}{urldefrag}{url} Modified: python/branches/p3yk-noslice/Doc/lib/libuuid.tex ============================================================================== --- python/branches/p3yk-noslice/Doc/lib/libuuid.tex (original) +++ python/branches/p3yk-noslice/Doc/lib/libuuid.tex Fri Dec 15 05:21:50 2006 @@ -18,20 +18,11 @@ network address. \function{uuid4()} creates a random UUID. \begin{classdesc}{UUID}{\optional{hex\optional{, bytes\optional{, -fields\optional{, int\optional{, version}}}}}} - -%Instances of the UUID class represent UUIDs as specified in RFC 4122. -%UUID objects are immutable, hashable, and usable as dictionary keys. -%Converting a UUID to a string with str() yields something in the form -%'12345678-1234-1234-1234-123456789abc'. The UUID constructor accepts -%four possible forms: a similar string of hexadecimal digits, or a -%string of 16 raw bytes as an argument named 'bytes', or a tuple of -%six integer fields (with 32-bit, 16-bit, 16-bit, 8-bit, 8-bit, and -%48-bit values respectively) as an argument named 'fields', or a single -%128-bit integer as an argument named 'int'. +bytes_le\optional{, fields\optional{, int\optional{, version}}}}}}} Create a UUID from either a string of 32 hexadecimal digits, -a string of 16 bytes as the \var{bytes} argument, a tuple of six +a string of 16 bytes as the \var{bytes} argument, a string of 16 bytes +in little-endian order as the \var{bytes_le} argument, a tuple of six integers (32-bit \var{time_low}, 16-bit \var{time_mid}, 16-bit \var{time_hi_version}, 8-bit \var{clock_seq_hi_variant}, 8-bit \var{clock_seq_low}, 48-bit \var{node}) @@ -45,22 +36,31 @@ UUID('12345678123456781234567812345678') UUID('urn:uuid:12345678-1234-5678-1234-567812345678') UUID(bytes='\x12\x34\x56\x78'*4) +UUID(bytes_le='\x78\x56\x34\x12\x34\x12\x78\x56' + + '\x12\x34\x56\x78\x12\x34\x56\x78') UUID(fields=(0x12345678, 0x1234, 0x5678, 0x12, 0x34, 0x567812345678)) UUID(int=0x12345678123456781234567812345678) \end{verbatim} -Exactly one of \var{hex}, \var{bytes}, \var{fields}, or \var{int} must +Exactly one of \var{hex}, \var{bytes}, \var{bytes_le}, \var{fields}, +or \var{int} must be given. The \var{version} argument is optional; if given, the resulting UUID will have its variant and version number set according to RFC 4122, overriding bits in the given \var{hex}, \var{bytes}, -\var{fields}, or \var{int}. +\var{bytes_le}, \var{fields}, or \var{int}. \end{classdesc} \class{UUID} instances have these read-only attributes: \begin{memberdesc}{bytes} -The UUID as a 16-byte string. +The UUID as a 16-byte string (containing the six +integer fields in big-endian byte order). +\end{memberdesc} + +\begin{memberdesc}{bytes_le} +The UUID as a 16-byte string (with \var{time_low}, \var{time_mid}, +and \var{time_hi_version} in little-endian byte order). \end{memberdesc} \begin{memberdesc}{fields} @@ -95,10 +95,10 @@ \begin{memberdesc}{variant} The UUID variant, which determines the internal layout of the UUID. -This will be an integer equal to one of the constants +This will be one of the integer constants \constant{RESERVED_NCS}, \constant{RFC_4122}, \constant{RESERVED_MICROSOFT}, or -\constant{RESERVED_FUTURE}). +\constant{RESERVED_FUTURE}. \end{memberdesc} \begin{memberdesc}{version} @@ -106,7 +106,7 @@ when the variant is \constant{RFC_4122}). \end{memberdesc} -The \module{uuid} module defines the following functions +The \module{uuid} module defines the following functions: \begin{funcdesc}{getnode}{} Get the hardware address as a 48-bit positive integer. The first time this @@ -129,11 +129,8 @@ \index{uuid1} \begin{funcdesc}{uuid3}{namespace, name} -Generate a UUID based upon a MD5 hash of the \var{name} string value -drawn from a specified namespace. \var{namespace} -must be one of \constant{NAMESPACE_DNS}, -\constant{NAMESPACE_URL}, \constant{NAMESPACE_OID}, -or \constant{NAMESPACE_X500}. +Generate a UUID based on the MD5 hash +of a namespace identifier (which is a UUID) and a name (which is a string). \end{funcdesc} \index{uuid3} @@ -143,31 +140,32 @@ \index{uuid4} \begin{funcdesc}{uuid5}{namespace, name} -Generate a UUID based upon a SHA-1 hash of the \var{name} string value -drawn from a specified namespace. \var{namespace} -must be one of \constant{NAMESPACE_DNS}, -\constant{NAMESPACE_URL}, \constant{NAMESPACE_OID}, -or \constant{NAMESPACE_X500}. +Generate a UUID based on the SHA-1 hash +of a namespace identifier (which is a UUID) and a name (which is a string). \end{funcdesc} \index{uuid5} -The \module{uuid} module defines the following namespace constants +The \module{uuid} module defines the following namespace identifiers for use with \function{uuid3()} or \function{uuid5()}. \begin{datadesc}{NAMESPACE_DNS} -Fully-qualified domain name namespace UUID. +When this namespace is specified, +the \var{name} string is a fully-qualified domain name. \end{datadesc} \begin{datadesc}{NAMESPACE_URL} -URL namespace UUID. +When this namespace is specified, +the \var{name} string is a URL. \end{datadesc} \begin{datadesc}{NAMESPACE_OID} -ISO OID namespace UUID. +When this namespace is specified, +the \var{name} string is an ISO OID. \end{datadesc} \begin{datadesc}{NAMESPACE_X500} -X.500 DN namespace UUID. +When this namespace is specified, +the \var{name} string is an X.500 DN in DER or a text output format. \end{datadesc} The \module{uuid} module defines the following constants @@ -178,11 +176,11 @@ \end{datadesc} \begin{datadesc}{RFC_4122} -Uses UUID layout specified in \rfc{4122}. +Specifies the UUID layout given in \rfc{4122}. \end{datadesc} \begin{datadesc}{RESERVED_MICROSOFT} -Reserved for Microsoft backward compatibility. +Reserved for Microsoft compatibility. \end{datadesc} \begin{datadesc}{RESERVED_FUTURE} @@ -192,12 +190,13 @@ \begin{seealso} \seerfc{4122}{A Universally Unique IDentifier (UUID) URN Namespace}{ - This specifies a Uniform Resource Name namespace for UUIDs.} +This specification defines a Uniform Resource Name namespace for UUIDs, +the internal format of UUIDs, and methods of generating UUIDs.} \end{seealso} \subsection{Example \label{uuid-example}} -Here is a typical usage: +Here are some examples of typical usage of the \module{uuid} module: \begin{verbatim} >>> import uuid Modified: python/branches/p3yk-noslice/Doc/lib/libwinreg.tex ============================================================================== --- python/branches/p3yk-noslice/Doc/lib/libwinreg.tex (original) +++ python/branches/p3yk-noslice/Doc/lib/libwinreg.tex Fri Dec 15 05:21:50 2006 @@ -375,7 +375,7 @@ also accept an integer, however, use of the handle object is encouraged. - Handle objects provide semantics for \method{__nonzero__()} - thus + Handle objects provide semantics for \method{__bool__()} - thus \begin{verbatim} if handle: print "Yes" Modified: python/branches/p3yk-noslice/Doc/lib/libwsgiref.tex ============================================================================== --- python/branches/p3yk-noslice/Doc/lib/libwsgiref.tex (original) +++ python/branches/p3yk-noslice/Doc/lib/libwsgiref.tex Fri Dec 15 05:21:50 2006 @@ -26,8 +26,9 @@ WSGI specification (\pep{333}). % XXX If you're just trying to write a web application... -% XXX should create a URL on python.org to point people to. +See \url{http://www.wsgi.org} for more information about WSGI, +and links to tutorials and other resources. Modified: python/branches/p3yk-noslice/Doc/lib/libxmlrpclib.tex ============================================================================== --- python/branches/p3yk-noslice/Doc/lib/libxmlrpclib.tex (original) +++ python/branches/p3yk-noslice/Doc/lib/libxmlrpclib.tex Fri Dec 15 05:21:50 2006 @@ -68,7 +68,10 @@ \lineii{arrays}{Any Python sequence type containing conformable elements. Arrays are returned as lists} \lineii{structures}{A Python dictionary. Keys must be strings, - values may be any conformable type.} + values may be any conformable type. Objects + of user-defined classes can be passed in; + only their \var{__dict__} attribute is + transmitted.} \lineii{dates}{in seconds since the epoch (pass in an instance of the \class{DateTime} class) or a \class{\refmodule{datetime}.datetime}, @@ -100,6 +103,10 @@ compatibility. New code should use \class{ServerProxy}. \versionchanged[The \var{use_datetime} flag was added]{2.5} + +\versionchanged[Instances of new-style classes can be passed in +if they have an \var{__dict__} attribute and don't have a base class +that is marshalled in a special way]{2.6} \end{classdesc} @@ -171,7 +178,7 @@ This class may be initialized from any Python value; the instance returned depends only on its truth value. It supports various Python operators through \method{__cmp__()}, \method{__repr__()}, -\method{__int__()}, and \method{__nonzero__()} methods, all +\method{__int__()}, and \method{__bool__()} methods, all implemented in the obvious ways. It also has the following method, supported mainly for internal use by Modified: python/branches/p3yk-noslice/Doc/lib/sqlite3/executescript.py ============================================================================== --- python/branches/p3yk-noslice/Doc/lib/sqlite3/executescript.py (original) +++ python/branches/p3yk-noslice/Doc/lib/sqlite3/executescript.py Fri Dec 15 05:21:50 2006 @@ -17,7 +17,7 @@ insert into book(title, author, published) values ( - 'Dirk Gently''s Holistic Detective Agency + 'Dirk Gently''s Holistic Detective Agency', 'Douglas Adams', 1987 ); Modified: python/branches/p3yk-noslice/Doc/lib/tkinter.tex ============================================================================== --- python/branches/p3yk-noslice/Doc/lib/tkinter.tex (original) +++ python/branches/p3yk-noslice/Doc/lib/tkinter.tex Fri Dec 15 05:21:50 2006 @@ -318,7 +318,7 @@ \item[\var{options}] configure the widget's appearance and in some cases, its behavior. The options come in the form of a list of flags and values. -Flags are proceeded by a `-', like \UNIX{} shell command flags, and +Flags are preceded by a `-', like \UNIX{} shell command flags, and values are put in quotes if they are more than one word. \end{description} Modified: python/branches/p3yk-noslice/Doc/perl/python.perl ============================================================================== --- python/branches/p3yk-noslice/Doc/perl/python.perl (original) +++ python/branches/p3yk-noslice/Doc/perl/python.perl Fri Dec 15 05:21:50 2006 @@ -883,6 +883,12 @@ $filename = 'grammar.txt'; } open(GRAMMAR, ">$filename") || die "\n$!\n"; + print GRAMMAR "##################################################\n"; + print GRAMMAR "# This file is only meant to be a guide, #\n"; + print GRAMMAR "# and differs in small ways from the real #\n"; + print GRAMMAR "# grammar. The exact reference is the file #\n"; + print GRAMMAR "# Grammar/Grammar distributed with the source. #\n"; + print GRAMMAR "##################################################\n"; print GRAMMAR strip_grammar_markup($DefinedGrammars{$lang}); close(GRAMMAR); print "Wrote grammar file $filename\n"; Modified: python/branches/p3yk-noslice/Doc/ref/ref2.tex ============================================================================== --- python/branches/p3yk-noslice/Doc/ref/ref2.tex (original) +++ python/branches/p3yk-noslice/Doc/ref/ref2.tex Fri Dec 15 05:21:50 2006 @@ -308,13 +308,12 @@ \index{reserved word} \begin{verbatim} -and del from not while -as elif global or with -assert else if pass yield -break except import print -class exec in raise -continue finally is return -def for lambda try +and def for is raise +as del from lambda return +assert elif global not try +break else if or while +class except import pass with +continue finally in print yield \end{verbatim} % When adding keywords, use reswords.py for reformatting @@ -689,13 +688,9 @@ \begin{verbatim} + - * ** / // % << >> & | ^ ~ -< > <= >= == != <> +< > <= >= == != \end{verbatim} -The comparison operators \code{<>} and \code{!=} are alternate -spellings of the same operator. \code{!=} is the preferred spelling; -\code{<>} is obsolescent. - \section{Delimiters\label{delimiters}} Modified: python/branches/p3yk-noslice/Doc/ref/ref3.tex ============================================================================== --- python/branches/p3yk-noslice/Doc/ref/ref3.tex (original) +++ python/branches/p3yk-noslice/Doc/ref/ref3.tex Fri Dec 15 05:21:50 2006 @@ -148,9 +148,8 @@ \item[Ellipsis] This type has a single value. There is a single object with this value. -This object is accessed through the built-in name \code{Ellipsis}. -It is used to indicate the presence of the \samp{...} syntax in a -slice. Its truth value is true. +This object is accessed through the literal \code{...} or the +built-in name \code{Ellipsis}. Its truth value is true. \obindex{Ellipsis} \item[Numbers] @@ -379,6 +378,41 @@ \end{description} % Sequences + +\item[Set types] +These represent unordered, finite sets of unique, immutable objects. +As such, they cannot be indexed by any subscript. However, they can be +iterated over, and the built-in function \function{len()} returns the +number of items in a set. Common uses for sets are +fast membership testing, removing duplicates from a sequence, and +computing mathematical operations such as intersection, union, difference, +and symmetric difference. +\bifuncindex{len} +\obindex{set type} + +For set elements, the same immutability rules apply as for dictionary +keys. Note that numeric types obey the normal rules for numeric +comparison: if two numbers compare equal (e.g., \code{1} and +\code{1.0}), only one of them can be contained in a set. + +There are currently two intrinsic set types: + +\begin{description} + +\item[Sets] +These\obindex{set} represent a mutable set. They are created by the +built-in \function{set()} constructor and can be modified afterwards +by several methods, such as \method{add()}. + +\item[Frozen sets] +These\obindex{frozenset} represent an immutable set. They are created by +the built-in \function{frozenset()} constructor. As a frozenset is +immutable and hashable, it can be used again as an element of another set, +or as a dictionary key. + +\end{description} % Set types + + \item[Mappings] These represent finite sets of objects indexed by arbitrary index sets. The subscript notation \code{a[k]} selects the item indexed @@ -762,7 +796,7 @@ (call it~\class{C}) of the instance for which the attribute reference was initiated or one of its bases, it is transformed into a bound user-defined method object whose -\member{im_class} attribute is~\class{C} whose \member{im_self} attribute +\member{im_class} attribute is~\class{C} and whose \member{im_self} attribute is the instance. Static method and class method objects are also transformed, as if they had been retrieved from class~\class{C}; see above under ``Classes''. See section~\ref{descriptors} for @@ -1243,8 +1277,7 @@ \code{\var{x}<\var{y}} calls \code{\var{x}.__lt__(\var{y})}, \code{\var{x}<=\var{y}} calls \code{\var{x}.__le__(\var{y})}, \code{\var{x}==\var{y}} calls \code{\var{x}.__eq__(\var{y})}, -\code{\var{x}!=\var{y}} and \code{\var{x}<>\var{y}} call -\code{\var{x}.__ne__(\var{y})}, +\code{\var{x}!=\var{y}} calls \code{\var{x}.__ne__(\var{y})}, \code{\var{x}>\var{y}} calls \code{\var{x}.__gt__(\var{y})}, and \code{\var{x}>=\var{y}} calls \code{\var{x}.__ge__(\var{y})}. These methods can return any value, but if the comparison operator is @@ -1315,13 +1348,13 @@ \withsubitem{(object method)}{\ttindex{__cmp__()}} \end{methoddesc} -\begin{methoddesc}[object]{__nonzero__}{self} +\begin{methoddesc}[object]{__bool__}{self} Called to implement truth value testing, and the built-in operation -\code{bool()}; should return \code{False} or \code{True}, or their -integer equivalents \code{0} or \code{1}. +\code{bool()}; should return \code{False} or \code{True}. When this method is not defined, \method{__len__()} is -called, if it is defined (see below). If a class defines neither -\method{__len__()} nor \method{__nonzero__()}, all its instances are +called, if it is defined (see below) and \code{True} is returned when +the length is not zero. If a class defines neither +\method{__len__()} nor \method{__bool__()}, all its instances are considered true. \withsubitem{(mapping object method)}{\ttindex{__len__()}} \end{methoddesc} @@ -1695,9 +1728,9 @@ Called to implement the built-in function \function{len()}\bifuncindex{len}. Should return the length of the object, an integer \code{>=} 0. Also, an object that doesn't define a -\method{__nonzero__()} method and whose \method{__len__()} method +\method{__bool__()} method and whose \method{__len__()} method returns zero is considered to be false in a Boolean context. -\withsubitem{(object method)}{\ttindex{__nonzero__()}} +\withsubitem{(object method)}{\ttindex{__bool__()}} \end{methoddesc} \begin{methoddesc}[container object]{__getitem__}{self, key} Modified: python/branches/p3yk-noslice/Doc/ref/ref4.tex ============================================================================== --- python/branches/p3yk-noslice/Doc/ref/ref4.tex (original) +++ python/branches/p3yk-noslice/Doc/ref/ref4.tex Fri Dec 15 05:21:50 2006 @@ -20,8 +20,8 @@ argument) is a code block. A script command (a command specified on the interpreter command line with the `\strong{-c}' option) is a code block. The file read by the built-in function \function{execfile()} -is a code block. The string argument passed to the built-in function -\function{eval()} and to the \keyword{exec} statement is a code block. +is a code block. The string argument passed to the built-in functions +\function{eval()} and \function{exec()} is a code block. The expression read and evaluated by the built-in function \function{input()} is a code block. @@ -139,22 +139,16 @@ function and the function contains or is a nested block with free variables, the compiler will raise a \exception{SyntaxError}. -If \keyword{exec} is used in a function and the function contains or -is a nested block with free variables, the compiler will raise a -\exception{SyntaxError} unless the exec explicitly specifies the local -namespace for the \keyword{exec}. (In other words, \samp{exec obj} -would be illegal, but \samp{exec obj in ns} would be legal.) - -The \function{eval()}, \function{execfile()}, and \function{input()} -functions and the \keyword{exec} statement do not have access to the +The \function{eval()}, \function{exec()}, \function{execfile()}, +and \function{input()} functions do not have access to the full environment for resolving names. Names may be resolved in the local and global namespaces of the caller. Free variables are not resolved in the nearest enclosing namespace, but in the global namespace.\footnote{This limitation occurs because the code that is executed by these operations is not available at the time the module is compiled.} -The \keyword{exec} statement and the \function{eval()} and -\function{execfile()} functions have optional arguments to override +The \function{exec()}, \function{eval()} and \function{execfile()} +functions have optional arguments to override the global and local namespace. If only one namespace is specified, it is used for both. Modified: python/branches/p3yk-noslice/Doc/ref/ref5.tex ============================================================================== --- python/branches/p3yk-noslice/Doc/ref/ref5.tex (original) +++ python/branches/p3yk-noslice/Doc/ref/ref5.tex Fri Dec 15 05:21:50 2006 @@ -268,49 +268,6 @@ \indexii{immutable}{object} -\subsection{String conversions\label{string-conversions}} -\indexii{string}{conversion} -\indexii{reverse}{quotes} -\indexii{backward}{quotes} -\index{back-quotes} - -A string conversion is an expression list enclosed in reverse (a.k.a. -backward) quotes: - -\begin{productionlist} - \production{string_conversion} - {"`" \token{expression_list} "`"} -\end{productionlist} - -A string conversion evaluates the contained expression list and -converts the resulting object into a string according to rules -specific to its type. - -If the object is a string, a number, \code{None}, or a tuple, list or -dictionary containing only objects whose type is one of these, the -resulting string is a valid Python expression which can be passed to -the built-in function \function{eval()} to yield an expression with the -same value (or an approximation, if floating point numbers are -involved). - -(In particular, converting a string adds quotes around it and converts -``funny'' characters to escape sequences that are safe to print.) - -Recursive objects (for example, lists or dictionaries that contain a -reference to themselves, directly or indirectly) use \samp{...} to -indicate a recursive reference, and the result cannot be passed to -\function{eval()} to get an equal value (\exception{SyntaxError} will -be raised instead). -\obindex{recursive} - -The built-in function \function{repr()} performs exactly the same -conversion in its argument as enclosing it in parentheses and reverse -quotes does. The built-in function \function{str()} performs a -similar but more user-friendly conversion. -\bifuncindex{repr} -\bifuncindex{str} - - \section{Primaries\label{primaries}} \index{primary} @@ -454,8 +411,7 @@ contains at least one comma, the key is a tuple containing the conversion of the slice items; otherwise, the conversion of the lone slice item is the key. The conversion of a slice item that is an -expression is that expression. The conversion of an ellipsis slice -item is the built-in \code{Ellipsis} object. The conversion of a +expression is that expression. The conversion of a proper slice is a slice object (see section \ref{types}) whose \member{start}, \member{stop} and \member{step} attributes are the values of the expressions given as lower bound, upper bound and @@ -875,7 +831,7 @@ \production{comparison} {\token{or_expr} ( \token{comp_operator} \token{or_expr} )*} \production{comp_operator} - {"<" | ">" | "==" | ">=" | "<=" | "<>" | "!="} + {"<" | ">" | "==" | ">=" | "<=" | "!="} \productioncont{| "is" ["not"] | ["not"] "in"} \end{productionlist} @@ -897,11 +853,6 @@ between \var{a} and \var{c}, so that, e.g., \code{x < y > z} is perfectly legal (though perhaps not pretty). -The forms \code{<>} and \code{!=} are equivalent; for consistency with -C, \code{!=} is preferred; where \code{!=} is mentioned below -\code{<>} is also accepted. The \code{<>} spelling is considered -obsolescent. - The operators \code{<}, \code{>}, \code{==}, \code{>=}, \code{<=}, and \code{!=} compare the values of two objects. The objects need not have the same type. @@ -1154,7 +1105,7 @@ \lineii{\keyword{in}, \keyword{not} \keyword{in}}{Membership tests} \lineii{\keyword{is}, \keyword{is not}}{Identity tests} \lineii{\code{<}, \code{<=}, \code{>}, \code{>=}, - \code{<>}, \code{!=}, \code{==}} + \code{!=}, \code{==}} {Comparisons} \hline \lineii{\code{|}} {Bitwise OR} Modified: python/branches/p3yk-noslice/Doc/ref/ref6.tex ============================================================================== --- python/branches/p3yk-noslice/Doc/ref/ref6.tex (original) +++ python/branches/p3yk-noslice/Doc/ref/ref6.tex Fri Dec 15 05:21:50 2006 @@ -20,7 +20,6 @@ \productioncont{| \token{continue_stmt}} \productioncont{| \token{import_stmt}} \productioncont{| \token{global_stmt}} - \productioncont{| \token{exec_stmt}} \end{productionlist} @@ -809,7 +808,7 @@ That is not a future statement; it's an ordinary import statement with no special semantics or syntax restrictions. -Code compiled by an \keyword{exec} statement or calls to the builtin functions +Code compiled by calls to the builtin functions \function{exec()}, \function{compile()} and \function{execfile()} that occur in a module \module{M} containing a future statement will, by default, use the new syntax or semantics associated with the future statement. This can, @@ -855,64 +854,14 @@ \strong{Programmer's note:} the \keyword{global} is a directive to the parser. It applies only to code parsed at the same time as the \keyword{global} -statement. In particular, a \keyword{global} statement contained in an -\keyword{exec} statement does not affect the code block \emph{containing} -the \keyword{exec} statement, and code contained in an \keyword{exec} -statement is unaffected by \keyword{global} statements in the code -containing the \keyword{exec} statement. The same applies to the +statement. In particular, a \keyword{global} statement contained in a +string or code object supplied to the builtin \function{exec()} function +does not affect the code block \emph{containing} the function call, +and code contained in such a string is unaffected by \keyword{global} +statements in the code containing the function call. The same applies to the \function{eval()}, \function{execfile()} and \function{compile()} functions. -\stindex{exec} +\bifuncindex{exec} \bifuncindex{eval} \bifuncindex{execfile} \bifuncindex{compile} - -\section{The \keyword{exec} statement \label{exec}} -\stindex{exec} - -\begin{productionlist} - \production{exec_stmt} - {"exec" \token{expression} - ["in" \token{expression} ["," \token{expression}]]} -\end{productionlist} - -This statement supports dynamic execution of Python code. The first -expression should evaluate to either a string, an open file object, or -a code object. If it is a string, the string is parsed as a suite of -Python statements which is then executed (unless a syntax error -occurs). If it is an open file, the file is parsed until \EOF{} and -executed. If it is a code object, it is simply executed. In all -cases, the code that's executed is expected to be valid as file -input (see section~\ref{file-input}, ``File input''). Be aware that -the \keyword{return} and \keyword{yield} statements may not be used -outside of function definitions even within the context of code passed -to the \keyword{exec} statement. - -In all cases, if the optional parts are omitted, the code is executed -in the current scope. If only the first expression after \keyword{in} -is specified, it should be a dictionary, which will be used for both -the global and the local variables. If two expressions are given, -they are used for the global and local variables, respectively. -If provided, \var{locals} can be any mapping object. -\versionchanged[formerly \var{locals} was required to be a dictionary]{2.4} - -As a side effect, an implementation may insert additional keys into -the dictionaries given besides those corresponding to variable names -set by the executed code. For example, the current implementation -may add a reference to the dictionary of the built-in module -\module{__builtin__} under the key \code{__builtins__} (!). -\ttindex{__builtins__} -\refbimodindex{__builtin__} - -\strong{Programmer's hints:} -dynamic evaluation of expressions is supported by the built-in -function \function{eval()}. The built-in functions -\function{globals()} and \function{locals()} return the current global -and local dictionary, respectively, which may be useful to pass around -for use by \keyword{exec}. -\bifuncindex{eval} -\bifuncindex{globals} -\bifuncindex{locals} - - - Modified: python/branches/p3yk-noslice/Doc/ref/ref8.tex ============================================================================== --- python/branches/p3yk-noslice/Doc/ref/ref8.tex (original) +++ python/branches/p3yk-noslice/Doc/ref/ref8.tex Fri Dec 15 05:21:50 2006 @@ -62,7 +62,7 @@ \item when parsing a module; -\item when parsing a string passed to the \keyword{exec} statement; +\item when parsing a string passed to the \function{exec()} function; \end{itemize} Modified: python/branches/p3yk-noslice/Doc/ref/reswords.py ============================================================================== --- python/branches/p3yk-noslice/Doc/ref/reswords.py (original) +++ python/branches/p3yk-noslice/Doc/ref/reswords.py Fri Dec 15 05:21:50 2006 @@ -9,7 +9,7 @@ words.sort() colwidth = 1 + max(map(len, words)) nwords = len(words) - nrows = (nwords + ncols - 1) / ncols + nrows = (nwords + ncols - 1) // ncols for irow in range(nrows): for icol in range(ncols): i = irow + icol * nrows Modified: python/branches/p3yk-noslice/Doc/tools/py2texi.el ============================================================================== --- python/branches/p3yk-noslice/Doc/tools/py2texi.el (original) +++ python/branches/p3yk-noslice/Doc/tools/py2texi.el Fri Dec 15 05:21:50 2006 @@ -1,5 +1,6 @@ ;;; py2texi.el -- Conversion of Python LaTeX documentation to Texinfo +;; Copyright (C) 2006 Jeroen Dekkers ;; Copyright (C) 1998, 1999, 2001, 2002 Milan Zamazal ;; Author: Milan Zamazal @@ -168,6 +169,7 @@ "@end table\n") ("productionlist" 0 "\n at table @code\n" "@end table\n") ("quotation" 0 "@quotation" "@end quotation") + ("quote" 0 "@quotation" "@end quotation") ("seealso" 0 "See also:\n at table @emph\n" "@end table\n") ("seealso*" 0 "@table @emph\n" "@end table\n") ("sloppypar" 0 "" "") @@ -246,11 +248,12 @@ ("env" 1 "@code{\\1}") ("EOF" 0 "@code{EOF}") ("email" 1 "@email{\\1}") + ("em" 1 "@emph{\\1}") ("emph" 1 "@emph{\\1}") ("envvar" 1 "@env{\\1}") ("exception" 1 "@code{\\1}") ("exindex" 1 (progn (setq obindex t) "@obindex{\\1}")) - ("fi" 0 (concat "@end " last-if)) + ("fi" 0 (if (equal last-if "ifx") "" (concat "@end " last-if))) ("file" 1 "@file{\\1}") ("filenq" 1 "@file{\\1}") ("filevar" 1 "@file{@var{\\1}}") @@ -262,6 +265,7 @@ ("grammartoken" 1 "@code{\\1}") ("guilabel" 1 "@strong{\\1}") ("hline" 0 "") + ("ifx" 0 (progn (setq last-if "ifx") "")) ("ifhtml" 0 (concat "@" (setq last-if "ifinfo"))) ("iftexi" 0 (concat "@" (setq last-if "ifinfo"))) ("index" 1 (progn (setq cindex t) "@cindex{\\1}")) @@ -284,6 +288,7 @@ ("lineiii" 3 "@item \\1 @tab \\2 @tab \\3") ("lineiv" 4 "@item \\1 @tab \\2 @tab \\3 @tab \\4") ("linev" 5 "@item \\1 @tab \\2 @tab \\3 @tab \\4 @tab \\5") + ("locallinewidth" 0 "") ("localmoduletable" 0 "") ("longprogramopt" 1 "@option{--\\1}") ("macro" 1 "@code{@backslash{}\\1}") @@ -307,6 +312,7 @@ ("moreargs" 0 "@dots{}") ("n" 0 "@backslash{}n") ("newcommand" 2 "") + ("newlength" 1 "") ("newsgroup" 1 "@samp{\\1}") ("nodename" 1 (save-excursion @@ -322,6 +328,7 @@ ("opindex" 1 (progn (setq cindex t) "@cindex{\\1}")) ("option" 1 "@option{\\1}") ("optional" 1 "[\\1]") + ("paragraph" 1 "@subsubheading \\1") ("pep" 1 (progn (setq cindex t) "PEP@ \\1 at cindex PEP \\1\n")) ("pi" 0 "pi") ("platform" 1 "") @@ -363,6 +370,7 @@ ("seetitle" 1 "@cite{\\1}") ("seeurl" 2 "\n at table @url\n at item \\1\n\\2\n at end table\n") ("setindexsubitem" 1 (progn (setq cindex t) "@cindex \\1")) + ("setlength" 2 "") ("setreleaseinfo" 1 (progn (setq py2texi-releaseinfo ""))) ("setshortversion" 1 (progn (setq py2texi-python-short-version (match-string 1 string)) "")) @@ -382,8 +390,8 @@ ("textasciicircum" 0 "^") ("textbackslash" 0 "@backslash{}") ("textbar" 0 "|") - ; Some common versions of Texinfo don't support @euro yet: - ; ("texteuro" 0 "@euro{}") + ("textbf" 1 "@strong{\\1}") + ("texteuro" 0 "@euro{}") ; Unfortunately, this alternate spelling doesn't actually apply to ; the usage found in Python Tutorial, which actually requires a ; Euro symbol to make sense, so this is commented out as well. @@ -394,6 +402,7 @@ ("textrm" 1 "\\1") ("texttt" 1 "@code{\\1}") ("textunderscore" 0 "_") + ("tilde" 0 "~") ("title" 1 (progn (setq title (match-string 1 string)) "@settitle \\1")) ("today" 0 "@today{}") ("token" 1 "@code{\\1}") @@ -402,6 +411,7 @@ ("u" 0 "@backslash{}u") ("ulink" 2 "\\1") ("UNIX" 0 "UNIX") + ("undefined" 0 "") ("unspecified" 0 "@dots{}") ("url" 1 "@url{\\1}") ("usepackage" 1 "") @@ -534,15 +544,20 @@ beg end) (py2texi-search-safe "\\\\begin{\\(verbatim\\|displaymath\\)}" - (replace-match "@example") - (setq beg (copy-marker (point) nil)) - (re-search-forward "\\\\end{\\(verbatim\\|displaymath\\)}") - (setq end (copy-marker (match-beginning 0) nil)) - (replace-match "@end example") - (py2texi-texinfo-escape beg end) - (put-text-property (- beg (length "@example")) - (+ end (length "@end example")) - 'py2texi-protected t)) + (when (save-excursion + ; Make sure we aren't looking at a commented out version + ; of a verbatim environment + (beginning-of-line) + (not (looking-at "%"))) + (replace-match "@example ") + (setq beg (copy-marker (point) nil)) + (re-search-forward "\\\\end{\\(verbatim\\|displaymath\\)}") + (setq end (copy-marker (match-beginning 0) nil)) + (replace-match "@end example") + (py2texi-texinfo-escape beg end) + (put-text-property (- beg (length "@example ")) + (+ end (length "@end example")) + 'py2texi-protected t))) (py2texi-search-safe "\\\\verb\\([^a-z]\\)" (setq delimiter (match-string 1)) (replace-match "@code{") @@ -883,6 +898,10 @@ (defun py2texi-fix-braces () "Escape braces for Texinfo." + (py2texi-search "{@{}" + (replace-match "@{")) + (py2texi-search "{@}}" + (replace-match "@}")) (let (string) (py2texi-search "{" (unless (or (py2texi-protected) Modified: python/branches/p3yk-noslice/Doc/tut/tut.tex ============================================================================== --- python/branches/p3yk-noslice/Doc/tut/tut.tex (original) +++ python/branches/p3yk-noslice/Doc/tut/tut.tex Fri Dec 15 05:21:50 2006 @@ -1893,8 +1893,8 @@ \subsection{Functional Programming Tools \label{functional}} -There are three built-in functions that are very useful when used with -lists: \function{filter()}, \function{map()}, and \function{reduce()}. +There are two built-in functions that are very useful when used with +lists: \function{filter()} and \function{map()}. \samp{filter(\var{function}, \var{sequence})} returns a sequence consisting of those items from the @@ -1934,42 +1934,6 @@ >>> map(add, seq, seq) [0, 2, 4, 6, 8, 10, 12, 14] \end{verbatim} - -\samp{reduce(\var{function}, \var{sequence})} returns a single value -constructed by calling the binary function \var{function} on the first two -items of the sequence, then on the result and the next item, and so -on. For example, to compute the sum of the numbers 1 through 10: - -\begin{verbatim} ->>> def add(x,y): return x+y -... ->>> reduce(add, range(1, 11)) -55 -\end{verbatim} - -If there's only one item in the sequence, its value is returned; if -the sequence is empty, an exception is raised. - -A third argument can be passed to indicate the starting value. In this -case the starting value is returned for an empty sequence, and the -function is first applied to the starting value and the first sequence -item, then to the result and the next item, and so on. For example, - -\begin{verbatim} ->>> def sum(seq): -... def add(x,y): return x+y -... return reduce(add, seq, 0) -... ->>> sum(range(1, 11)) -55 ->>> sum([]) -0 -\end{verbatim} - -Don't use this example's definition of \function{sum()}: since summing -numbers is such a common need, a built-in function -\code{sum(\var{sequence})} is already provided, and works exactly like -this. \versionadded{2.3} \subsection{List Comprehensions} @@ -2732,14 +2696,14 @@ 'UserWarning', 'ValueError', 'Warning', 'WindowsError', 'ZeroDivisionError', '_', '__debug__', '__doc__', '__import__', '__name__', 'abs', 'basestring', 'bool', 'buffer', - 'callable', 'chr', 'classmethod', 'cmp', 'coerce', 'compile', + 'callable', 'chr', 'classmethod', 'cmp', 'compile', 'complex', 'copyright', 'credits', 'delattr', 'dict', 'dir', 'divmod', - 'enumerate', 'eval', 'execfile', 'exit', 'file', 'filter', 'float', + 'enumerate', 'eval', 'exec', 'execfile', 'exit', 'file', 'filter', 'float', 'frozenset', 'getattr', 'globals', 'hasattr', 'hash', 'help', 'hex', 'id', 'int', 'intern', 'isinstance', 'issubclass', 'iter', 'len', 'license', 'list', 'locals', 'long', 'map', 'max', 'min', 'object', 'oct', 'open', 'ord', 'pow', 'property', 'quit', 'range', - 'reduce', 'reload', 'repr', 'reversed', 'round', 'set', + 'reload', 'repr', 'reversed', 'round', 'set', 'setattr', 'slice', 'sorted', 'staticmethod', 'str', 'sum', 'super', 'tuple', 'type', 'unichr', 'unicode', 'vars', 'xrange', 'zip'] \end{verbatim} @@ -2867,7 +2831,7 @@ *}? Ideally, one would hope that this somehow goes out to the filesystem, finds which submodules are present in the package, and imports them all. Unfortunately, this operation does not work very -well on Mac and Windows platforms, where the filesystem does not +well on Windows platforms, where the filesystem does not always have accurate information about the case of a filename! On these platforms, there is no guaranteed way to know whether a file \file{ECHO.PY} should be imported as a module \module{echo}, @@ -3072,6 +3036,7 @@ 8 64 512 9 81 729 10 100 1000 + >>> for x in range(1,11): ... print '%2d %3d %4d' % (x, x*x, x*x*x) ... @@ -3087,8 +3052,9 @@ 10 100 1000 \end{verbatim} -(Note that one space between each column was added by the way -\keyword{print} works: it always adds spaces between its arguments.) +(Note that in the first example, one space between each column was +added by the way \keyword{print} works: it always adds spaces between +its arguments.) This example demonstrates the \method{rjust()} method of string objects, which right-justifies a string in a field of a given width by padding @@ -3557,7 +3523,7 @@ But use of \code{.args} is discouraged. Instead, the preferred use is to pass a single argument to an exception (which can be a tuple if multiple arguments -are needed) and have it bound to the \code{message} attribute. One my also +are needed) and have it bound to the \code{message} attribute. One may also instantiate an exception first before raising it and add any attributes to it as desired. @@ -4398,8 +4364,8 @@ (Buglet: derivation of a class with the same name as the base class makes use of private variables of the base class possible.) -Notice that code passed to \code{exec}, \code{eval()} or -\code{evalfile()} does not consider the classname of the invoking +Notice that code passed to \code{exec()}, \code{eval()} or +\code{execfile()} does not consider the classname of the invoking class to be the current class; this is similar to the effect of the \code{global} statement, the effect of which is likewise restricted to code that is byte-compiled together. The same restriction applies to Modified: python/branches/p3yk-noslice/Doc/whatsnew/whatsnew25.tex ============================================================================== --- python/branches/p3yk-noslice/Doc/whatsnew/whatsnew25.tex (original) +++ python/branches/p3yk-noslice/Doc/whatsnew/whatsnew25.tex Fri Dec 15 05:21:50 2006 @@ -409,7 +409,7 @@ specific exceptions. You couldn't combine both \keyword{except} blocks and a \keyword{finally} block, because generating the right bytecode for the combined version was complicated and it wasn't clear what the -semantics of the combined should be. +semantics of the combined statement should be. Guido van~Rossum spent some time working with Java, which does support the equivalent of combining \keyword{except} blocks and a @@ -540,10 +540,10 @@ StopIteration \end{verbatim} -Because \keyword{yield} will often be returning \constant{None}, you +\keyword{yield} will usually return \constant{None}, so you should always check for this case. Don't just use its value in expressions unless you're sure that the \method{send()} method -will be the only method used resume your generator function. +will be the only method used to resume your generator function. In addition to \method{send()}, there are two other new methods on generators: @@ -683,22 +683,22 @@ The lock is acquired before the block is executed and always released once the block is complete. -The \module{decimal} module's contexts, which encapsulate the desired -precision and rounding characteristics for computations, provide a -\method{context_manager()} method for getting a context manager: +The new \function{localcontext()} function in the \module{decimal} module +makes it easy to save and restore the current decimal context, which +encapsulates the desired precision and rounding characteristics for +computations: \begin{verbatim} -import decimal +from decimal import Decimal, Context, localcontext # Displays with default precision of 28 digits -v1 = decimal.Decimal('578') -print v1.sqrt() +v = Decimal('578') +print v.sqrt() -ctx = decimal.Context(prec=16) -with ctx.context_manager(): +with localcontext(Context(prec=16)): # All code in this block uses a precision of 16 digits. # The original context is restored on exiting the block. - print v1.sqrt() + print v.sqrt() \end{verbatim} \subsection{Writing Context Managers\label{context-managers}} @@ -1115,12 +1115,14 @@ \begin{verbatim} >>> ('http://www.python.org').partition('://') ('http', '://', 'www.python.org') ->>> (u'Subject: a quick question').partition(':') -(u'Subject', u':', u' a quick question') >>> ('file:/usr/share/doc/index.html').partition('://') ('file:/usr/share/doc/index.html', '', '') +>>> (u'Subject: a quick question').partition(':') +(u'Subject', u':', u' a quick question') >>> 'www.python.org'.rpartition('.') ('www.python', '.', 'org') +>>> 'www.python.org'.rpartition(':') +('', '', 'www.python.org') \end{verbatim} (Implemented by Fredrik Lundh following a suggestion by Raymond Hettinger.) @@ -2114,14 +2116,16 @@ SQLite embedded database, has been added to the standard library under the package name \module{sqlite3}. -SQLite is a C library that provides a SQL-language database that -stores data in disk files without requiring a separate server process. +SQLite is a C library that provides a lightweight disk-based database +that doesn't require a separate server process and allows accessing +the database using a nonstandard variant of the SQL query language. +Some applications can use SQLite for internal data storage. It's also +possible to prototype an application using SQLite and then port the +code to a larger database such as PostgreSQL or Oracle. + pysqlite was written by Gerhard H\"aring and provides a SQL interface compliant with the DB-API 2.0 specification described by -\pep{249}. This means that it should be possible to write the first -version of your applications using SQLite for data storage. If -switching to a larger database such as PostgreSQL or Oracle is -later necessary, the switch should be relatively easy. +\pep{249}. If you're compiling the Python source yourself, note that the source tree doesn't include the SQLite code, only the wrapper module. @@ -2148,8 +2152,8 @@ # Create table c.execute('''create table stocks -(date timestamp, trans varchar, symbol varchar, - qty decimal, price decimal)''') +(date text, trans text, symbol text, + qty real, price real)''') # Insert a row of data c.execute("""insert into stocks Modified: python/branches/p3yk-noslice/Grammar/Grammar ============================================================================== --- python/branches/p3yk-noslice/Grammar/Grammar (original) +++ python/branches/p3yk-noslice/Grammar/Grammar Fri Dec 15 05:21:50 2006 @@ -24,7 +24,7 @@ funcdef: [decorators] 'def' NAME parameters ':' suite parameters: '(' [varargslist] ')' varargslist: ((fpdef ['=' test] ',')* - ('*' NAME [',' '**' NAME] | '**' NAME) | + ('*' [NAME] (',' NAME ['=' test])* [',' '**' NAME] | '**' NAME) | fpdef ['=' test] (',' fpdef ['=' test])* [',']) fpdef: NAME | '(' fplist ')' fplist: fpdef (',' fpdef)* [','] @@ -32,7 +32,7 @@ stmt: simple_stmt | compound_stmt simple_stmt: small_stmt (';' small_stmt)* [';'] NEWLINE small_stmt: (expr_stmt | print_stmt | del_stmt | pass_stmt | flow_stmt | - import_stmt | global_stmt | exec_stmt | assert_stmt) + import_stmt | global_stmt | assert_stmt) expr_stmt: testlist (augassign (yield_expr|testlist) | ('=' (yield_expr|testlist))*) augassign: ('+=' | '-=' | '*=' | '/=' | '%=' | '&=' | '|=' | '^=' | @@ -58,7 +58,6 @@ dotted_as_names: dotted_as_name (',' dotted_as_name)* dotted_name: NAME ('.' NAME)* global_stmt: 'global' NAME (',' NAME)* -exec_stmt: 'exec' expr ['in' test [',' test]] assert_stmt: 'assert' test [',' test] compound_stmt: if_stmt | while_stmt | for_stmt | try_stmt | with_stmt | funcdef | classdef @@ -90,7 +89,7 @@ and_test: not_test ('and' not_test)* not_test: 'not' not_test | comparison comparison: expr (comp_op expr)* -comp_op: '<'|'>'|'=='|'>='|'<='|'<>'|'!='|'in'|'not' 'in'|'is'|'is' 'not' +comp_op: '<'|'>'|'=='|'>='|'<='|'!='|'in'|'not' 'in'|'is'|'is' 'not' expr: xor_expr ('|' xor_expr)* xor_expr: and_expr ('^' and_expr)* and_expr: shift_expr ('&' shift_expr)* @@ -101,19 +100,18 @@ power: atom trailer* ['**' factor] atom: ('(' [yield_expr|testlist_gexp] ')' | '[' [listmaker] ']' | - '{' [dictmaker] '}' | - '`' testlist1 '`' | - NAME | NUMBER | STRING+) + '{' [dictsetmaker] '}' | + NAME | NUMBER | STRING+ | '.' '.' '.') listmaker: test ( list_for | (',' test)* [','] ) testlist_gexp: test ( gen_for | (',' test)* [','] ) lambdef: 'lambda' [varargslist] ':' test trailer: '(' [arglist] ')' | '[' subscriptlist ']' | '.' NAME subscriptlist: subscript (',' subscript)* [','] -subscript: '.' '.' '.' | test | [test] ':' [test] [sliceop] +subscript: test | [test] ':' [test] [sliceop] sliceop: ':' [test] exprlist: expr (',' expr)* [','] testlist: test (',' test)* [','] -dictmaker: test ':' test (',' test ':' test)* [','] +dictsetmaker: (test ':' test (',' test ':' test)* [',']) | (test (',' test)* [',']) classdef: 'class' NAME ['(' [testlist] ')'] ':' suite Modified: python/branches/p3yk-noslice/Include/Python-ast.h ============================================================================== --- python/branches/p3yk-noslice/Include/Python-ast.h (original) +++ python/branches/p3yk-noslice/Include/Python-ast.h Fri Dec 15 05:21:50 2006 @@ -64,8 +64,8 @@ For_kind=8, While_kind=9, If_kind=10, With_kind=11, Raise_kind=12, TryExcept_kind=13, TryFinally_kind=14, Assert_kind=15, Import_kind=16, ImportFrom_kind=17, - Exec_kind=18, Global_kind=19, Expr_kind=20, Pass_kind=21, - Break_kind=22, Continue_kind=23}; + Global_kind=18, Expr_kind=19, Pass_kind=20, Break_kind=21, + Continue_kind=22}; struct _stmt { enum _stmt_kind kind; union { @@ -165,12 +165,6 @@ } ImportFrom; struct { - expr_ty body; - expr_ty globals; - expr_ty locals; - } Exec; - - struct { asdl_seq *names; } Global; @@ -184,11 +178,11 @@ }; enum _expr_kind {BoolOp_kind=1, BinOp_kind=2, UnaryOp_kind=3, Lambda_kind=4, - IfExp_kind=5, Dict_kind=6, ListComp_kind=7, - GeneratorExp_kind=8, Yield_kind=9, Compare_kind=10, - Call_kind=11, Repr_kind=12, Num_kind=13, Str_kind=14, - Attribute_kind=15, Subscript_kind=16, Name_kind=17, - List_kind=18, Tuple_kind=19}; + IfExp_kind=5, Dict_kind=6, Set_kind=7, ListComp_kind=8, + GeneratorExp_kind=9, Yield_kind=10, Compare_kind=11, + Call_kind=12, Num_kind=13, Str_kind=14, Ellipsis_kind=15, + Attribute_kind=16, Subscript_kind=17, Name_kind=18, + List_kind=19, Tuple_kind=20}; struct _expr { enum _expr_kind kind; union { @@ -225,6 +219,10 @@ } Dict; struct { + asdl_seq *elts; + } Set; + + struct { expr_ty elt; asdl_seq *generators; } ListComp; @@ -253,10 +251,6 @@ } Call; struct { - expr_ty value; - } Repr; - - struct { object n; } Num; @@ -296,7 +290,7 @@ int col_offset; }; -enum _slice_kind {Ellipsis_kind=1, Slice_kind=2, ExtSlice_kind=3, Index_kind=4}; +enum _slice_kind {Slice_kind=1, ExtSlice_kind=2, Index_kind=3}; struct _slice { enum _slice_kind kind; union { @@ -334,8 +328,10 @@ struct _arguments { asdl_seq *args; identifier vararg; + asdl_seq *kwonlyargs; identifier kwarg; asdl_seq *defaults; + asdl_seq *kw_defaults; }; struct _keyword { @@ -385,8 +381,6 @@ stmt_ty Import(asdl_seq * names, int lineno, int col_offset, PyArena *arena); stmt_ty ImportFrom(identifier module, asdl_seq * names, int level, int lineno, int col_offset, PyArena *arena); -stmt_ty Exec(expr_ty body, expr_ty globals, expr_ty locals, int lineno, int - col_offset, PyArena *arena); stmt_ty Global(asdl_seq * names, int lineno, int col_offset, PyArena *arena); stmt_ty Expr(expr_ty value, int lineno, int col_offset, PyArena *arena); stmt_ty Pass(int lineno, int col_offset, PyArena *arena); @@ -404,6 +398,7 @@ col_offset, PyArena *arena); expr_ty Dict(asdl_seq * keys, asdl_seq * values, int lineno, int col_offset, PyArena *arena); +expr_ty Set(asdl_seq * elts, int lineno, int col_offset, PyArena *arena); expr_ty ListComp(expr_ty elt, asdl_seq * generators, int lineno, int col_offset, PyArena *arena); expr_ty GeneratorExp(expr_ty elt, asdl_seq * generators, int lineno, int @@ -414,9 +409,9 @@ expr_ty Call(expr_ty func, asdl_seq * args, asdl_seq * keywords, expr_ty starargs, expr_ty kwargs, int lineno, int col_offset, PyArena *arena); -expr_ty Repr(expr_ty value, int lineno, int col_offset, PyArena *arena); expr_ty Num(object n, int lineno, int col_offset, PyArena *arena); expr_ty Str(string s, int lineno, int col_offset, PyArena *arena); +expr_ty Ellipsis(int lineno, int col_offset, PyArena *arena); expr_ty Attribute(expr_ty value, identifier attr, expr_context_ty ctx, int lineno, int col_offset, PyArena *arena); expr_ty Subscript(expr_ty value, slice_ty slice, expr_context_ty ctx, int @@ -427,7 +422,6 @@ PyArena *arena); expr_ty Tuple(asdl_seq * elts, expr_context_ty ctx, int lineno, int col_offset, PyArena *arena); -slice_ty Ellipsis(PyArena *arena); slice_ty Slice(expr_ty lower, expr_ty upper, expr_ty step, PyArena *arena); slice_ty ExtSlice(asdl_seq * dims, PyArena *arena); slice_ty Index(expr_ty value, PyArena *arena); @@ -435,8 +429,9 @@ PyArena *arena); excepthandler_ty excepthandler(expr_ty type, expr_ty name, asdl_seq * body, int lineno, int col_offset, PyArena *arena); -arguments_ty arguments(asdl_seq * args, identifier vararg, identifier kwarg, - asdl_seq * defaults, PyArena *arena); +arguments_ty arguments(asdl_seq * args, identifier vararg, asdl_seq * + kwonlyargs, identifier kwarg, asdl_seq * defaults, + asdl_seq * kw_defaults, PyArena *arena); keyword_ty keyword(identifier arg, expr_ty value, PyArena *arena); alias_ty alias(identifier name, identifier asname, PyArena *arena); Modified: python/branches/p3yk-noslice/Include/abstract.h ============================================================================== --- python/branches/p3yk-noslice/Include/abstract.h (original) +++ python/branches/p3yk-noslice/Include/abstract.h Fri Dec 15 05:21:50 2006 @@ -288,9 +288,10 @@ */ + /* Declared elsewhere + PyAPI_FUNC(int) PyCallable_Check(PyObject *o); - /* Determine if the object, o, is callable. Return 1 if the object is callable and 0 otherwise. Modified: python/branches/p3yk-noslice/Include/code.h ============================================================================== --- python/branches/p3yk-noslice/Include/code.h (original) +++ python/branches/p3yk-noslice/Include/code.h Fri Dec 15 05:21:50 2006 @@ -10,6 +10,7 @@ typedef struct { PyObject_HEAD int co_argcount; /* #arguments, except *args */ + int co_kwonlyargcount; /* #keyword only arguments */ int co_nlocals; /* #local variables */ int co_stacksize; /* #entries needed for evaluation stack */ int co_flags; /* CO_..., see below */ @@ -63,8 +64,9 @@ /* Public interface */ PyAPI_FUNC(PyCodeObject *) PyCode_New( - int, int, int, int, PyObject *, PyObject *, PyObject *, PyObject *, - PyObject *, PyObject *, PyObject *, PyObject *, int, PyObject *); + int, int, int, int, int, PyObject *, PyObject *, + PyObject *, PyObject *, PyObject *, PyObject *, + PyObject *, PyObject *, int, PyObject *); /* same as struct above */ PyAPI_FUNC(int) PyCode_Addr2Line(PyCodeObject *, int); Modified: python/branches/p3yk-noslice/Include/eval.h ============================================================================== --- python/branches/p3yk-noslice/Include/eval.h (original) +++ python/branches/p3yk-noslice/Include/eval.h Fri Dec 15 05:21:50 2006 @@ -15,7 +15,7 @@ PyObject **args, int argc, PyObject **kwds, int kwdc, PyObject **defs, int defc, - PyObject *closure); + PyObject *kwdefs, PyObject *closure); PyAPI_FUNC(PyObject *) _PyEval_CallTracing(PyObject *func, PyObject *args); Modified: python/branches/p3yk-noslice/Include/funcobject.h ============================================================================== --- python/branches/p3yk-noslice/Include/funcobject.h (original) +++ python/branches/p3yk-noslice/Include/funcobject.h Fri Dec 15 05:21:50 2006 @@ -23,6 +23,7 @@ PyObject *func_code; /* A code object */ PyObject *func_globals; /* A dictionary (other mappings won't do) */ PyObject *func_defaults; /* NULL or a tuple */ + PyObject *func_kwdefaults; /* NULL or a dict */ PyObject *func_closure; /* NULL or a tuple of cell objects */ PyObject *func_doc; /* The __doc__ attribute, can be anything */ PyObject *func_name; /* The __name__ attribute, a string object */ @@ -47,6 +48,8 @@ PyAPI_FUNC(PyObject *) PyFunction_GetModule(PyObject *); PyAPI_FUNC(PyObject *) PyFunction_GetDefaults(PyObject *); PyAPI_FUNC(int) PyFunction_SetDefaults(PyObject *, PyObject *); +PyAPI_FUNC(PyObject *) PyFunction_GetKwDefaults(PyObject *); +PyAPI_FUNC(int) PyFunction_SetKwDefaults(PyObject *, PyObject *); PyAPI_FUNC(PyObject *) PyFunction_GetClosure(PyObject *); PyAPI_FUNC(int) PyFunction_SetClosure(PyObject *, PyObject *); @@ -60,6 +63,8 @@ (((PyFunctionObject *)func) -> func_module) #define PyFunction_GET_DEFAULTS(func) \ (((PyFunctionObject *)func) -> func_defaults) +#define PyFunction_GET_KW_DEFAULTS(func) \ + (((PyFunctionObject *)func) -> func_kwdefaults) #define PyFunction_GET_CLOSURE(func) \ (((PyFunctionObject *)func) -> func_closure) Modified: python/branches/p3yk-noslice/Include/graminit.h ============================================================================== --- python/branches/p3yk-noslice/Include/graminit.h (original) +++ python/branches/p3yk-noslice/Include/graminit.h Fri Dec 15 05:21:50 2006 @@ -31,54 +31,53 @@ #define dotted_as_names 286 #define dotted_name 287 #define global_stmt 288 -#define exec_stmt 289 -#define assert_stmt 290 -#define compound_stmt 291 -#define if_stmt 292 -#define while_stmt 293 -#define for_stmt 294 -#define try_stmt 295 -#define with_stmt 296 -#define with_var 297 -#define except_clause 298 -#define suite 299 -#define testlist_safe 300 -#define old_test 301 -#define old_lambdef 302 -#define test 303 -#define or_test 304 -#define and_test 305 -#define not_test 306 -#define comparison 307 -#define comp_op 308 -#define expr 309 -#define xor_expr 310 -#define and_expr 311 -#define shift_expr 312 -#define arith_expr 313 -#define term 314 -#define factor 315 -#define power 316 -#define atom 317 -#define listmaker 318 -#define testlist_gexp 319 -#define lambdef 320 -#define trailer 321 -#define subscriptlist 322 -#define subscript 323 -#define sliceop 324 -#define exprlist 325 -#define testlist 326 -#define dictmaker 327 -#define classdef 328 -#define arglist 329 -#define argument 330 -#define list_iter 331 -#define list_for 332 -#define list_if 333 -#define gen_iter 334 -#define gen_for 335 -#define gen_if 336 -#define testlist1 337 -#define encoding_decl 338 -#define yield_expr 339 +#define assert_stmt 289 +#define compound_stmt 290 +#define if_stmt 291 +#define while_stmt 292 +#define for_stmt 293 +#define try_stmt 294 +#define with_stmt 295 +#define with_var 296 +#define except_clause 297 +#define suite 298 +#define testlist_safe 299 +#define old_test 300 +#define old_lambdef 301 +#define test 302 +#define or_test 303 +#define and_test 304 +#define not_test 305 +#define comparison 306 +#define comp_op 307 +#define expr 308 +#define xor_expr 309 +#define and_expr 310 +#define shift_expr 311 +#define arith_expr 312 +#define term 313 +#define factor 314 +#define power 315 +#define atom 316 +#define listmaker 317 +#define testlist_gexp 318 +#define lambdef 319 +#define trailer 320 +#define subscriptlist 321 +#define subscript 322 +#define sliceop 323 +#define exprlist 324 +#define testlist 325 +#define dictsetmaker 326 +#define classdef 327 +#define arglist 328 +#define argument 329 +#define list_iter 330 +#define list_for 331 +#define list_if 332 +#define gen_iter 333 +#define gen_for 334 +#define gen_if 335 +#define testlist1 336 +#define encoding_decl 337 +#define yield_expr 338 Modified: python/branches/p3yk-noslice/Include/iterobject.h ============================================================================== --- python/branches/p3yk-noslice/Include/iterobject.h (original) +++ python/branches/p3yk-noslice/Include/iterobject.h Fri Dec 15 05:21:50 2006 @@ -16,6 +16,9 @@ #define PyCallIter_Check(op) ((op)->ob_type == &PyCallIter_Type) PyAPI_FUNC(PyObject *) PyCallIter_New(PyObject *, PyObject *); + +PyObject* _PyZip_CreateIter(PyObject* args); + #ifdef __cplusplus } #endif Modified: python/branches/p3yk-noslice/Include/modsupport.h ============================================================================== --- python/branches/p3yk-noslice/Include/modsupport.h (original) +++ python/branches/p3yk-noslice/Include/modsupport.h Fri Dec 15 05:21:50 2006 @@ -24,7 +24,7 @@ #endif PyAPI_FUNC(int) PyArg_Parse(PyObject *, const char *, ...); -PyAPI_FUNC(int) PyArg_ParseTuple(PyObject *, const char *, ...); +PyAPI_FUNC(int) PyArg_ParseTuple(PyObject *, const char *, ...) Py_FORMAT_PARSETUPLE(PyArg_ParseTuple, 2, 3); PyAPI_FUNC(int) PyArg_ParseTupleAndKeywords(PyObject *, PyObject *, const char *, char **, ...); PyAPI_FUNC(int) PyArg_UnpackTuple(PyObject *, const char *, Py_ssize_t, Py_ssize_t, ...); Modified: python/branches/p3yk-noslice/Include/object.h ============================================================================== --- python/branches/p3yk-noslice/Include/object.h (original) +++ python/branches/p3yk-noslice/Include/object.h Fri Dec 15 05:21:50 2006 @@ -160,7 +160,7 @@ unaryfunc nb_negative; unaryfunc nb_positive; unaryfunc nb_absolute; - inquiry nb_nonzero; + inquiry nb_bool; unaryfunc nb_invert; binaryfunc nb_lshift; binaryfunc nb_rshift; @@ -379,6 +379,7 @@ PyAPI_FUNC(int) PyObject_Compare(PyObject *, PyObject *); PyAPI_FUNC(PyObject *) PyObject_RichCompare(PyObject *, PyObject *, int); PyAPI_FUNC(int) PyObject_RichCompareBool(PyObject *, PyObject *, int); +PyAPI_FUNC(PyObject *) Py_CmpToRich(int op, int cmp); PyAPI_FUNC(PyObject *) PyObject_GetAttrString(PyObject *, const char *); PyAPI_FUNC(int) PyObject_SetAttrString(PyObject *, const char *, PyObject *); PyAPI_FUNC(int) PyObject_HasAttrString(PyObject *, const char *); @@ -394,7 +395,6 @@ PyAPI_FUNC(int) PyObject_IsTrue(PyObject *); PyAPI_FUNC(int) PyObject_Not(PyObject *); PyAPI_FUNC(int) PyCallable_Check(PyObject *); -PyAPI_FUNC(int) PyNumber_CoerceEx(PyObject **, PyObject **); PyAPI_FUNC(void) PyObject_ClearWeakRefs(PyObject *); Modified: python/branches/p3yk-noslice/Include/opcode.h ============================================================================== --- python/branches/p3yk-noslice/Include/opcode.h (original) +++ python/branches/p3yk-noslice/Include/opcode.h Fri Dec 15 05:21:50 2006 @@ -18,7 +18,6 @@ #define UNARY_POSITIVE 10 #define UNARY_NEGATIVE 11 #define UNARY_NOT 12 -#define UNARY_CONVERT 13 #define UNARY_INVERT 15 @@ -67,7 +66,7 @@ #define LOAD_LOCALS 82 #define RETURN_VALUE 83 #define IMPORT_STAR 84 -#define EXEC_STMT 85 + #define YIELD_VALUE 86 #define POP_BLOCK 87 #define END_FINALLY 88 @@ -89,11 +88,12 @@ #define LOAD_NAME 101 /* Index in name list */ #define BUILD_TUPLE 102 /* Number of tuple items */ #define BUILD_LIST 103 /* Number of list items */ -#define BUILD_MAP 104 /* Always zero for now */ -#define LOAD_ATTR 105 /* Index in name list */ -#define COMPARE_OP 106 /* Comparison operator */ -#define IMPORT_NAME 107 /* Index in name list */ -#define IMPORT_FROM 108 /* Index in name list */ +#define BUILD_SET 104 /* Number of set items */ +#define BUILD_MAP 105 /* Always zero for now */ +#define LOAD_ATTR 106 /* Index in name list */ +#define COMPARE_OP 107 /* Comparison operator */ +#define IMPORT_NAME 108 /* Index in name list */ +#define IMPORT_FROM 109 /* Index in name list */ #define JUMP_FORWARD 110 /* Number of bytes to skip */ #define JUMP_IF_FALSE 111 /* "" */ Modified: python/branches/p3yk-noslice/Include/pyport.h ============================================================================== --- python/branches/p3yk-noslice/Include/pyport.h (original) +++ python/branches/p3yk-noslice/Include/pyport.h Fri Dec 15 05:21:50 2006 @@ -3,6 +3,10 @@ #include "pyconfig.h" /* include for defines */ +#ifdef HAVE_STDINT_H +#include +#endif + /************************************************************************** Symbols and macros to supply platform-independent interfaces to basic C language & library operations whose spellings vary across platforms. @@ -126,7 +130,7 @@ * Py_ssize_t on the platform. */ #ifndef PY_FORMAT_SIZE_T -# if SIZEOF_SIZE_T == SIZEOF_INT +# if SIZEOF_SIZE_T == SIZEOF_INT && !defined(__APPLE__) # define PY_FORMAT_SIZE_T "" # elif SIZEOF_SIZE_T == SIZEOF_LONG # define PY_FORMAT_SIZE_T "l" @@ -745,6 +749,15 @@ #define Py_GCC_ATTRIBUTE(x) __attribute__(x) #endif +/* + * Add PyArg_ParseTuple format where available. + */ +#ifdef HAVE_ATTRIBUTE_FORMAT_PARSETUPLE +#define Py_FORMAT_PARSETUPLE(func,p1,p2) __attribute__((format(func,p1,p2))) +#else +#define Py_FORMAT_PARSETUPLE(func,p1,p2) +#endif + /* Eliminate end-of-loop code not reached warnings from SunPro C * when using do{...}while(0) macros */ Modified: python/branches/p3yk-noslice/Include/symtable.h ============================================================================== --- python/branches/p3yk-noslice/Include/symtable.h (original) +++ python/branches/p3yk-noslice/Include/symtable.h Fri Dec 15 05:21:50 2006 @@ -88,11 +88,9 @@ #define FREE 4 #define CELL 5 -/* The following three names are used for the ste_unoptimized bit field */ +/* The following two names are used for the ste_unoptimized bit field */ #define OPT_IMPORT_STAR 1 -#define OPT_EXEC 2 -#define OPT_BARE_EXEC 4 -#define OPT_TOPLEVEL 8 /* top-level names, including eval and exec */ +#define OPT_TOPLEVEL 2 /* top-level names, including eval and exec */ #define GENERATOR 1 #define GENERATOR_EXPRESSION 2 Modified: python/branches/p3yk-noslice/Include/token.h ============================================================================== --- python/branches/p3yk-noslice/Include/token.h (original) +++ python/branches/p3yk-noslice/Include/token.h Fri Dec 15 05:21:50 2006 @@ -32,7 +32,7 @@ #define EQUAL 22 #define DOT 23 #define PERCENT 24 -#define BACKQUOTE 25 +/* #define BACKQUOTE 25 */ #define LBRACE 26 #define RBRACE 27 #define EQEQUAL 28 Modified: python/branches/p3yk-noslice/Lib/Bastion.py ============================================================================== --- python/branches/p3yk-noslice/Lib/Bastion.py (original) +++ python/branches/p3yk-noslice/Lib/Bastion.py Fri Dec 15 05:21:50 2006 @@ -164,7 +164,7 @@ else: print "accessible" \n""" - exec testcode + exec(testcode) print '='*20, "Using rexec:", '='*20 import rexec r = rexec.RExec() Modified: python/branches/p3yk-noslice/Lib/ConfigParser.py ============================================================================== --- python/branches/p3yk-noslice/Lib/ConfigParser.py (original) +++ python/branches/p3yk-noslice/Lib/ConfigParser.py Fri Dec 15 05:21:50 2006 @@ -199,11 +199,11 @@ self.line = line - class RawConfigParser: - def __init__(self, defaults=None): - self._sections = {} - self._defaults = {} + def __init__(self, defaults=None, dict_type=dict): + self._dict = dict_type + self._sections = self._dict() + self._defaults = self._dict() if defaults: for key, value in defaults.items(): self._defaults[self.optionxform(key)] = value @@ -224,7 +224,7 @@ """ if section in self._sections: raise DuplicateSectionError(section) - self._sections[section] = {} + self._sections[section] = self._dict() def has_section(self, section): """Indicate whether the named section is present in the configuration. @@ -307,7 +307,7 @@ except KeyError: if section != DEFAULTSECT: raise NoSectionError(section) - d2 = {} + d2 = self._dict() d = self._defaults.copy() d.update(d2) if "__name__" in d: @@ -453,7 +453,8 @@ elif sectname == DEFAULTSECT: cursect = self._defaults else: - cursect = {'__name__': sectname} + cursect = self._dict() + cursect['__name__'] = sectname self._sections[sectname] = cursect # So sections can't start with a continuation line optname = None Modified: python/branches/p3yk-noslice/Lib/Queue.py ============================================================================== --- python/branches/p3yk-noslice/Lib/Queue.py (original) +++ python/branches/p3yk-noslice/Lib/Queue.py Fri Dec 15 05:21:50 2006 @@ -26,7 +26,7 @@ self._init(maxsize) # mutex must be held whenever the queue is mutating. All methods # that acquire mutex must release it before returning. mutex - # is shared between the two conditions, so acquiring and + # is shared between the three conditions, so acquiring and # releasing the conditions also acquires and releases mutex. self.mutex = threading.Lock() # Notify not_empty whenever an item is added to the queue; a Modified: python/branches/p3yk-noslice/Lib/SimpleXMLRPCServer.py ============================================================================== --- python/branches/p3yk-noslice/Lib/SimpleXMLRPCServer.py (original) +++ python/branches/p3yk-noslice/Lib/SimpleXMLRPCServer.py Fri Dec 15 05:21:50 2006 @@ -264,8 +264,9 @@ encoding=self.encoding) except: # report exception back to server + exc_type, exc_value, exc_tb = sys.exc_info() response = xmlrpclib.dumps( - xmlrpclib.Fault(1, "%s:%s" % sys.exc_info()[:2]), + xmlrpclib.Fault(1, "%s:%s" % (exc_type, exc_value)), encoding=self.encoding, allow_none=self.allow_none, ) @@ -364,9 +365,10 @@ 'faultString' : fault.faultString} ) except: + exc_type, exc_value, exc_tb = sys.exc_info() results.append( {'faultCode' : 1, - 'faultString' : "%s:%s" % sys.exc_info()[:2]} + 'faultString' : "%s:%s" % (exc_type, exc_value)} ) return results Modified: python/branches/p3yk-noslice/Lib/StringIO.py ============================================================================== --- python/branches/p3yk-noslice/Lib/StringIO.py (original) +++ python/branches/p3yk-noslice/Lib/StringIO.py Fri Dec 15 05:21:50 2006 @@ -116,7 +116,7 @@ _complain_ifclosed(self.closed) return self.pos - def read(self, n = -1): + def read(self, n=None): """Read at most size bytes from the file (less if the read hits EOF before obtaining size bytes). @@ -128,6 +128,8 @@ if self.buflist: self.buf += ''.join(self.buflist) self.buflist = [] + if n is None: + n = -1 if n < 0: newpos = self.len else: Modified: python/branches/p3yk-noslice/Lib/UserDict.py ============================================================================== --- python/branches/p3yk-noslice/Lib/UserDict.py (original) +++ python/branches/p3yk-noslice/Lib/UserDict.py Fri Dec 15 05:21:50 2006 @@ -8,11 +8,16 @@ if len(kwargs): self.update(kwargs) def __repr__(self): return repr(self.data) - def __cmp__(self, dict): + def __eq__(self, dict): if isinstance(dict, UserDict): - return cmp(self.data, dict.data) + return self.data == dict.data else: - return cmp(self.data, dict) + return self.data == dict + def __ne__(self, dict): + if isinstance(dict, UserDict): + return self.data != dict.data + else: + return self.data != dict def __len__(self): return len(self.data) def __getitem__(self, key): if key in self.data: @@ -162,11 +167,13 @@ return default def __repr__(self): return repr(dict(self.iteritems())) - def __cmp__(self, other): - if other is None: - return 1 + def __eq__(self, other): + if isinstance(other, DictMixin): + other = dict(other.iteritems()) + return dict(self.iteritems()) == other + def __ne__(self, other): if isinstance(other, DictMixin): other = dict(other.iteritems()) - return cmp(dict(self.iteritems()), other) + return dict(self.iteritems()) != other def __len__(self): return len(self.keys()) Modified: python/branches/p3yk-noslice/Lib/UserString.py ============================================================================== --- python/branches/p3yk-noslice/Lib/UserString.py (original) +++ python/branches/p3yk-noslice/Lib/UserString.py Fri Dec 15 05:21:50 2006 @@ -25,11 +25,37 @@ def __complex__(self): return complex(self.data) def __hash__(self): return hash(self.data) - def __cmp__(self, string): + def __eq__(self, string): if isinstance(string, UserString): - return cmp(self.data, string.data) + return self.data == string.data else: - return cmp(self.data, string) + return self.data == string + def __ne__(self, string): + if isinstance(string, UserString): + return self.data != string.data + else: + return self.data != string + def __lt__(self, string): + if isinstance(string, UserString): + return self.data < string.data + else: + return self.data < string + def __le__(self, string): + if isinstance(string, UserString): + return self.data <= string.data + else: + return self.data <= string + def __gt__(self, string): + if isinstance(string, UserString): + return self.data > string.data + else: + return self.data > string + def __ge__(self, string): + if isinstance(string, UserString): + return self.data >= string.data + else: + return self.data >= string + def __contains__(self, char): return char in self.data Modified: python/branches/p3yk-noslice/Lib/_strptime.py ============================================================================== --- python/branches/p3yk-noslice/Lib/_strptime.py (original) +++ python/branches/p3yk-noslice/Lib/_strptime.py Fri Dec 15 05:21:50 2006 @@ -306,7 +306,7 @@ _cache_lock.release() found = format_regex.match(data_string) if not found: - raise ValueError("time data did not match format: data=%s fmt=%s" % + raise ValueError("time data %r does not match format %r" % (data_string, format)) if len(data_string) != found.end(): raise ValueError("unconverted data remains: %s" % Modified: python/branches/p3yk-noslice/Lib/atexit.py ============================================================================== --- python/branches/p3yk-noslice/Lib/atexit.py (original) +++ python/branches/p3yk-noslice/Lib/atexit.py Fri Dec 15 05:21:50 2006 @@ -40,8 +40,11 @@ func - function to be called at exit targs - optional arguments to pass to func kargs - optional keyword arguments to pass to func + + func is returned to facilitate usage as a decorator. """ _exithandlers.append((func, targs, kargs)) + return func if hasattr(sys, "exitfunc"): # Assume it's another registered exit function - append it to our list Modified: python/branches/p3yk-noslice/Lib/base64.py ============================================================================== --- python/branches/p3yk-noslice/Lib/base64.py (original) +++ python/branches/p3yk-noslice/Lib/base64.py Fri Dec 15 05:21:50 2006 @@ -308,7 +308,7 @@ def encodestring(s): - """Encode a string.""" + """Encode a string into multiple lines of base-64 data.""" pieces = [] for i in range(0, len(s), MAXBINSIZE): chunk = s[i : i + MAXBINSIZE] Modified: python/branches/p3yk-noslice/Lib/bdb.py ============================================================================== --- python/branches/p3yk-noslice/Lib/bdb.py (original) +++ python/branches/p3yk-noslice/Lib/bdb.py Fri Dec 15 05:21:50 2006 @@ -362,7 +362,7 @@ cmd = cmd+'\n' try: try: - exec cmd in globals, locals + exec(cmd, globals, locals) except BdbQuit: pass finally: Modified: python/branches/p3yk-noslice/Lib/bsddb/__init__.py ============================================================================== --- python/branches/p3yk-noslice/Lib/bsddb/__init__.py (original) +++ python/branches/p3yk-noslice/Lib/bsddb/__init__.py Fri Dec 15 05:21:50 2006 @@ -72,7 +72,7 @@ if sys.version >= '2.3': import UserDict from weakref import ref - exec """ + exec(""" class _iter_mixin(UserDict.DictMixin): def _make_iter_cursor(self): cur = _DeadlockWrap(self.db.cursor) @@ -145,7 +145,7 @@ except _bsddb.DBCursorClosedError: # the database was modified during iteration. abort. return -""" +""") else: class _iter_mixin: pass Modified: python/branches/p3yk-noslice/Lib/bsddb/dbtables.py ============================================================================== --- python/branches/p3yk-noslice/Lib/bsddb/dbtables.py (original) +++ python/branches/p3yk-noslice/Lib/bsddb/dbtables.py Fri Dec 15 05:21:50 2006 @@ -453,7 +453,7 @@ # error dataitem = None dataitem = mappings[column](dataitem) - if dataitem <> None: + if dataitem != None: self.db.put( _data_key(table, column, rowid), dataitem, txn=txn) Modified: python/branches/p3yk-noslice/Lib/bsddb/test/test_basics.py ============================================================================== --- python/branches/p3yk-noslice/Lib/bsddb/test/test_basics.py (original) +++ python/branches/p3yk-noslice/Lib/bsddb/test/test_basics.py Fri Dec 15 05:21:50 2006 @@ -697,7 +697,7 @@ for log in logs: if verbose: print 'log file: ' + log - if db.version >= (4,2): + if db.version() >= (4,2): logs = self.env.log_archive(db.DB_ARCH_REMOVE) assert not logs Modified: python/branches/p3yk-noslice/Lib/bsddb/test/test_compat.py ============================================================================== --- python/branches/p3yk-noslice/Lib/bsddb/test/test_compat.py (original) +++ python/branches/p3yk-noslice/Lib/bsddb/test/test_compat.py Fri Dec 15 05:21:50 2006 @@ -120,7 +120,7 @@ try: rec = f.next() except KeyError: - assert rec == f.last(), 'Error, last <> last!' + assert rec == f.last(), 'Error, last != last!' f.previous() break if verbose: Modified: python/branches/p3yk-noslice/Lib/bsddb/test/test_dbobj.py ============================================================================== --- python/branches/p3yk-noslice/Lib/bsddb/test/test_dbobj.py (original) +++ python/branches/p3yk-noslice/Lib/bsddb/test/test_dbobj.py Fri Dec 15 05:21:50 2006 @@ -69,6 +69,10 @@ self.db.close() self.env.close() + def test03_dbobj_type_before_open(self): + # Ensure this doesn't cause a segfault. + self.assertRaises(db.DBInvalidArgError, db.DB().type) + #---------------------------------------------------------------------- def test_suite(): Modified: python/branches/p3yk-noslice/Lib/bsddb/test/test_dbshelve.py ============================================================================== --- python/branches/p3yk-noslice/Lib/bsddb/test/test_dbshelve.py (original) +++ python/branches/p3yk-noslice/Lib/bsddb/test/test_dbshelve.py Fri Dec 15 05:21:50 2006 @@ -23,11 +23,24 @@ # We want the objects to be comparable so we can test dbshelve.values # later on. class DataClass: + def __init__(self): self.value = random.random() - def __cmp__(self, other): - return cmp(self.value, other) + def __repr__(self): + return "DataClass(%r)" % self.value + + def __eq__(self, other): + value = self.value + if isinstance(other, DataClass): + other = other.value + return value == other + + def __lt__(self, other): + value = self.value + if isinstance(other, DataClass): + other = other.value + return value < other class DBShelveTestCase(unittest.TestCase): def setUp(self): @@ -103,11 +116,10 @@ print "%s: %s" % (key, value) self.checkrec(key, value) - dbvalues = d.values() + dbvalues = sorted(d.values(), key=lambda x: (str(type(x)), x)) assert len(dbvalues) == len(d.keys()) - values.sort() - dbvalues.sort() - assert values == dbvalues + values.sort(key=lambda x: (str(type(x)), x)) + assert values == dbvalues, "%r != %r" % (values, dbvalues) items = d.items() assert len(items) == len(values) Modified: python/branches/p3yk-noslice/Lib/bsddb/test/test_recno.py ============================================================================== --- python/branches/p3yk-noslice/Lib/bsddb/test/test_recno.py (original) +++ python/branches/p3yk-noslice/Lib/bsddb/test/test_recno.py Fri Dec 15 05:21:50 2006 @@ -30,7 +30,7 @@ try: os.remove(self.filename) except OSError, e: - if e.errno <> errno.EEXIST: raise + if e.errno != errno.EEXIST: raise def test01_basic(self): d = db.DB() Modified: python/branches/p3yk-noslice/Lib/bsddb/test/test_thread.py ============================================================================== --- python/branches/p3yk-noslice/Lib/bsddb/test/test_thread.py (original) +++ python/branches/p3yk-noslice/Lib/bsddb/test/test_thread.py Fri Dec 15 05:21:50 2006 @@ -58,7 +58,7 @@ try: os.mkdir(homeDir) except OSError, e: - if e.errno <> errno.EEXIST: raise + if e.errno != errno.EEXIST: raise self.env = db.DBEnv() self.setEnvOpts() self.env.open(homeDir, self.envflags | db.DB_CREATE) Modified: python/branches/p3yk-noslice/Lib/cProfile.py ============================================================================== --- python/branches/p3yk-noslice/Lib/cProfile.py (original) +++ python/branches/p3yk-noslice/Lib/cProfile.py Fri Dec 15 05:21:50 2006 @@ -137,7 +137,7 @@ def runctx(self, cmd, globals, locals): self.enable() try: - exec cmd in globals, locals + exec(cmd, globals, locals) finally: self.disable() return self Modified: python/branches/p3yk-noslice/Lib/cgi.py ============================================================================== --- python/branches/p3yk-noslice/Lib/cgi.py (original) +++ python/branches/p3yk-noslice/Lib/cgi.py Fri Dec 15 05:21:50 2006 @@ -799,8 +799,10 @@ form.dict == {key: [val, val, ...], ...} """ - def __init__(self, environ=os.environ): - self.dict = self.data = parse(environ=environ) + def __init__(self, environ=os.environ, keep_blank_values=0, strict_parsing=0): + self.dict = self.data = parse(environ=environ, + keep_blank_values=keep_blank_values, + strict_parsing=strict_parsing) self.query_string = environ['QUERY_STRING'] @@ -910,7 +912,7 @@ print_environ(environ) print_environ_usage() def f(): - exec "testing print_exception() -- italics?" + exec("testing print_exception() -- italics?") def g(f=f): f() print "

    What follows is a test, not an actual exception:

    " Modified: python/branches/p3yk-noslice/Lib/code.py ============================================================================== --- python/branches/p3yk-noslice/Lib/code.py (original) +++ python/branches/p3yk-noslice/Lib/code.py Fri Dec 15 05:21:50 2006 @@ -100,7 +100,7 @@ """ try: - exec code in self.locals + exec(code, self.locals) except SystemExit: raise except: Modified: python/branches/p3yk-noslice/Lib/codecs.py ============================================================================== --- python/branches/p3yk-noslice/Lib/codecs.py (original) +++ python/branches/p3yk-noslice/Lib/codecs.py Fri Dec 15 05:21:50 2006 @@ -329,6 +329,12 @@ """ return getattr(self.stream, name) + def __enter__(self): + return self + + def __exit__(self, type, value, tb): + self.stream.close() + ### class StreamReader(Codec): @@ -568,6 +574,12 @@ """ return getattr(self.stream, name) + def __enter__(self): + return self + + def __exit__(self, type, value, tb): + self.stream.close() + ### class StreamReaderWriter: @@ -641,6 +653,14 @@ """ return getattr(self.stream, name) + # these are needed to make "with codecs.open(...)" work properly + + def __enter__(self): + return self + + def __exit__(self, type, value, tb): + self.stream.close() + ### class StreamRecoder: @@ -751,6 +771,12 @@ """ return getattr(self.stream, name) + def __enter__(self): + return self + + def __exit__(self, type, value, tb): + self.stream.close() + ### Shortcuts def open(filename, mode='rb', encoding=None, errors='strict', buffering=1): @@ -824,9 +850,10 @@ """ if file_encoding is None: file_encoding = data_encoding - info = lookup(data_encoding) - sr = StreamRecoder(file, info.encode, info.decode, - info.streamreader, info.streamwriter, errors) + data_info = lookup(data_encoding) + file_info = lookup(file_encoding) + sr = StreamRecoder(file, data_info.encode, data_info.decode, + file_info.streamreader, file_info.streamwriter, errors) # Add attributes to simplify introspection sr.data_encoding = data_encoding sr.file_encoding = file_encoding Modified: python/branches/p3yk-noslice/Lib/colorsys.py ============================================================================== --- python/branches/p3yk-noslice/Lib/colorsys.py (original) +++ python/branches/p3yk-noslice/Lib/colorsys.py Fri Dec 15 05:21:50 2006 @@ -117,7 +117,8 @@ p = v*(1.0 - s) q = v*(1.0 - s*f) t = v*(1.0 - s*(1.0-f)) - if i%6 == 0: return v, t, p + i = i%6 + if i == 0: return v, t, p if i == 1: return q, v, p if i == 2: return p, v, t if i == 3: return p, q, v Modified: python/branches/p3yk-noslice/Lib/compiler/ast.py ============================================================================== --- python/branches/p3yk-noslice/Lib/compiler/ast.py (original) +++ python/branches/p3yk-noslice/Lib/compiler/ast.py Fri Dec 15 05:21:50 2006 @@ -203,20 +203,6 @@ def __repr__(self): return "AugAssign(%s, %s, %s)" % (repr(self.node), repr(self.op), repr(self.expr)) -class Backquote(Node): - def __init__(self, expr, lineno=None): - self.expr = expr - self.lineno = lineno - - def getChildren(self): - return self.expr, - - def getChildNodes(self): - return self.expr, - - def __repr__(self): - return "Backquote(%s)" % (repr(self.expr),) - class Bitand(Node): def __init__(self, nodes, lineno=None): self.nodes = nodes @@ -441,45 +427,6 @@ def __repr__(self): return "Div((%s, %s))" % (repr(self.left), repr(self.right)) -class Ellipsis(Node): - def __init__(self, lineno=None): - self.lineno = lineno - - def getChildren(self): - return () - - def getChildNodes(self): - return () - - def __repr__(self): - return "Ellipsis()" - -class Exec(Node): - def __init__(self, expr, locals, globals, lineno=None): - self.expr = expr - self.locals = locals - self.globals = globals - self.lineno = lineno - - def getChildren(self): - children = [] - children.append(self.expr) - children.append(self.locals) - children.append(self.globals) - return tuple(children) - - def getChildNodes(self): - nodelist = [] - nodelist.append(self.expr) - if self.locals is not None: - nodelist.append(self.locals) - if self.globals is not None: - nodelist.append(self.globals) - return tuple(nodelist) - - def __repr__(self): - return "Exec(%s, %s, %s)" % (repr(self.expr), repr(self.locals), repr(self.globals)) - class FloorDiv(Node): def __init__(self, (left, right), lineno=None): self.left = left @@ -540,11 +487,12 @@ return "From(%s, %s, %s)" % (repr(self.modname), repr(self.names), repr(self.level)) class Function(Node): - def __init__(self, decorators, name, argnames, defaults, flags, doc, code, lineno=None): + def __init__(self, decorators, name, argnames, defaults, kwonlyargs, flags, doc, code, lineno=None): self.decorators = decorators self.name = name self.argnames = argnames self.defaults = defaults + self.kwonlyargs = kwonlyargs self.flags = flags self.doc = doc self.code = code @@ -556,13 +504,13 @@ self.kwargs = 1 - def getChildren(self): children = [] children.append(self.decorators) children.append(self.name) children.append(self.argnames) children.extend(flatten(self.defaults)) + children.append(self.kwonlyargs) children.append(self.flags) children.append(self.doc) children.append(self.code) @@ -577,7 +525,7 @@ return tuple(nodelist) def __repr__(self): - return "Function(%s, %s, %s, %s, %s, %s, %s)" % (repr(self.decorators), repr(self.name), repr(self.argnames), repr(self.defaults), repr(self.flags), repr(self.doc), repr(self.code)) + return "Function(%s, %s, %s, %s, %s, %s, %s, %s)" % (repr(self.decorators), repr(self.name), repr(self.argnames), repr(self.defaults), repr(self.kwonlyargs), repr(self.flags), repr(self.doc), repr(self.code)) class GenExpr(Node): def __init__(self, code, lineno=None): @@ -585,6 +533,8 @@ self.lineno = lineno self.argnames = ['.0'] self.varargs = self.kwargs = None + self.kwonlyargs = () + def getChildren(self): return self.code, @@ -603,7 +553,6 @@ self.lineno = lineno self.is_outmost = False - def getChildren(self): children = [] children.append(self.assign) @@ -767,9 +716,10 @@ return "Keyword(%s, %s)" % (repr(self.name), repr(self.expr)) class Lambda(Node): - def __init__(self, argnames, defaults, flags, code, lineno=None): + def __init__(self, argnames, defaults, kwonlyargs, flags, code, lineno=None): self.argnames = argnames self.defaults = defaults + self.kwonlyargs = kwonlyargs self.flags = flags self.code = code self.lineno = lineno @@ -780,11 +730,11 @@ self.kwargs = 1 - def getChildren(self): children = [] children.append(self.argnames) children.extend(flatten(self.defaults)) + children.append(self.kwonlyargs) children.append(self.flags) children.append(self.code) return tuple(children) @@ -796,7 +746,7 @@ return tuple(nodelist) def __repr__(self): - return "Lambda(%s, %s, %s, %s)" % (repr(self.argnames), repr(self.defaults), repr(self.flags), repr(self.code)) + return "Lambda(%s, %s, %s, %s, %s)" % (repr(self.argnames), repr(self.defaults), repr(self.kwonlyargs), repr(self.flags), repr(self.code)) class LeftShift(Node): def __init__(self, (left, right), lineno=None): @@ -1105,6 +1055,22 @@ def __repr__(self): return "RightShift((%s, %s))" % (repr(self.left), repr(self.right)) +class Set(Node): + def __init__(self, items, lineno=None): + self.items = items + self.lineno = lineno + + def getChildren(self): + return tuple(flatten(self.items)) + + def getChildNodes(self): + nodelist = [] + nodelist.extend(flatten_nodes(self.items)) + return tuple(nodelist) + + def __repr__(self): + return "Set(%s)" % (repr(self.items),) + class Slice(Node): def __init__(self, expr, flags, lower, upper, lineno=None): self.expr = expr Modified: python/branches/p3yk-noslice/Lib/compiler/pyassem.py ============================================================================== --- python/branches/p3yk-noslice/Lib/compiler/pyassem.py (original) +++ python/branches/p3yk-noslice/Lib/compiler/pyassem.py Fri Dec 15 05:21:50 2006 @@ -313,13 +313,15 @@ class PyFlowGraph(FlowGraph): super_init = FlowGraph.__init__ - def __init__(self, name, filename, args=(), optimized=0, klass=None): + def __init__(self, name, filename, + args=(), kwonlyargs={}, optimized=0, klass=None): self.super_init() self.name = name self.filename = filename self.docstring = None self.args = args # XXX self.argcount = getArgCount(args) + self.kwonlyargs = kwonlyargs self.klass = klass if optimized: self.flags = CO_OPTIMIZED | CO_NEWLOCALS @@ -595,7 +597,9 @@ argcount = self.argcount if self.flags & CO_VARKEYWORDS: argcount = argcount - 1 - return new.code(argcount, nlocals, self.stacksize, self.flags, + kwonlyargcount = len(self.kwonlyargs) + return new.code(argcount, kwonlyargcount, + nlocals, self.stacksize, self.flags, self.lnotab.getCode(), self.getConsts(), tuple(self.names), tuple(self.varnames), self.filename, self.name, self.lnotab.firstline, @@ -751,7 +755,6 @@ 'PRINT_ITEM': -1, 'RETURN_VALUE': -1, 'YIELD_VALUE': -1, - 'EXEC_STMT': -3, 'BUILD_CLASS': -2, 'STORE_NAME': -1, 'STORE_ATTR': -2, @@ -782,6 +785,8 @@ return -count+1 def BUILD_LIST(self, count): return -count+1 + def BUILD_SET(self, count): + return -count+1 def CALL_FUNCTION(self, argc): hi, lo = divmod(argc, 256) return -(lo + hi * 2) @@ -792,7 +797,8 @@ def CALL_FUNCTION_VAR_KW(self, argc): return self.CALL_FUNCTION(argc)-2 def MAKE_FUNCTION(self, argc): - return -argc + hi, lo = divmod(argc, 256) + return -(lo + hi * 2) def MAKE_CLOSURE(self, argc): # XXX need to account for free variables too! return -argc Modified: python/branches/p3yk-noslice/Lib/compiler/pycodegen.py ============================================================================== --- python/branches/p3yk-noslice/Lib/compiler/pycodegen.py (original) +++ python/branches/p3yk-noslice/Lib/compiler/pycodegen.py Fri Dec 15 05:21:50 2006 @@ -378,6 +378,12 @@ walk(node.code, gen) gen.finish() self.set_lineno(node) + for keyword in node.kwonlyargs: + default = keyword.expr + if isinstance(default, ast.EmptyNode): + continue + self.emit('LOAD_CONST', keyword.name) + self.visit(default) for default in node.defaults: self.visit(default) self._makeClosure(gen, len(node.defaults)) @@ -571,12 +577,11 @@ def visitListComp(self, node): self.set_lineno(node) # setup list - append = "$append%d" % self.__list_count + tmpname = "$list%d" % self.__list_count self.__list_count = self.__list_count + 1 self.emit('BUILD_LIST', 0) self.emit('DUP_TOP') - self.emit('LOAD_ATTR', 'append') - self._implicitNameOp('STORE', append) + self._implicitNameOp('STORE', tmpname) stack = [] for i, for_ in zip(range(len(node.quals)), node.quals): @@ -588,10 +593,9 @@ self.visit(if_, cont) stack.insert(0, (start, cont, anchor)) - self._implicitNameOp('LOAD', append) + self._implicitNameOp('LOAD', tmpname) self.visit(node.expr) - self.emit('CALL_FUNCTION', 1) - self.emit('POP_TOP') + self.emit('LIST_APPEND') for start, cont, anchor in stack: if cont: @@ -602,7 +606,7 @@ self.nextBlock(skip_one) self.emit('JUMP_ABSOLUTE', start) self.startBlock(anchor) - self._implicitNameOp('DELETE', append) + self._implicitNameOp('DELETE', tmpname) self.__list_count = self.__list_count - 1 @@ -1026,18 +1030,6 @@ self.emit('ROT_THREE') self.emit('STORE_SUBSCR') - def visitExec(self, node): - self.visit(node.expr) - if node.locals is None: - self.emit('LOAD_CONST', None) - else: - self.visit(node.locals) - if node.globals is None: - self.emit('DUP_TOP') - else: - self.visit(node.globals) - self.emit('EXEC_STMT') - def visitCallFunc(self, node): pos = 0 kw = 0 @@ -1163,9 +1155,6 @@ def visitNot(self, node): return self.unaryOp(node, 'UNARY_NOT') - def visitBackquote(self, node): - return self.unaryOp(node, 'UNARY_CONVERT') - # bit ops def bitOp(self, nodes, op): @@ -1185,9 +1174,6 @@ # object constructors - def visitEllipsis(self, node): - self.emit('LOAD_CONST', Ellipsis) - def visitTuple(self, node): self.set_lineno(node) for elt in node.nodes: @@ -1200,6 +1186,12 @@ self.visit(elt) self.emit('BUILD_LIST', len(node.nodes)) + def visitSet(self, node): + self.set_lineno(node) + for elt in node.items: + self.visit(elt) + self.emit('BUILD_SET', len(node.items)) + def visitSliceobj(self, node): for child in node.nodes: self.visit(child) @@ -1288,7 +1280,9 @@ name = func.name args, hasTupleArg = generateArgList(func.argnames) + kwonlyargs = generateKwonlyArgList(func.kwonlyargs) self.graph = pyassem.PyFlowGraph(name, func.filename, args, + kwonlyargs=kwonlyargs, optimized=1) self.isLambda = isLambda self.super_init() @@ -1424,6 +1418,13 @@ raise ValueError, "unexpect argument type:", elt return args + extra, count +def generateKwonlyArgList(keywordOnlyArgs): + kwonlyargs = {} + for elt in keywordOnlyArgs: + assert isinstance(elt, ast.Keyword) + kwonlyargs[elt.name] = elt.expr + return kwonlyargs + def findOp(node): """Find the op (DELETE, LOAD, STORE) in an AssTuple tree""" v = OpFinder() Modified: python/branches/p3yk-noslice/Lib/compiler/transformer.py ============================================================================== --- python/branches/p3yk-noslice/Lib/compiler/transformer.py (original) +++ python/branches/p3yk-noslice/Lib/compiler/transformer.py Fri Dec 15 05:21:50 2006 @@ -111,9 +111,9 @@ self._atom_dispatch = {token.LPAR: self.atom_lpar, token.LSQB: self.atom_lsqb, token.LBRACE: self.atom_lbrace, - token.BACKQUOTE: self.atom_backquote, token.NUMBER: self.atom_number, token.STRING: self.atom_string, + token.DOT: self.atom_ellipsis, token.NAME: self.atom_name, } self.encoding = None @@ -250,9 +250,9 @@ args = nodelist[-3][2] if args[0] == symbol.varargslist: - names, defaults, flags = self.com_arglist(args[1:]) + names, defaults, kwonlyargs, flags = self.com_arglist(args[1:]) else: - names = defaults = () + names = defaults = kwonlyargs = () flags = 0 doc = self.get_docstring(nodelist[-1]) @@ -263,21 +263,23 @@ assert isinstance(code, Stmt) assert isinstance(code.nodes[0], Discard) del code.nodes[0] - return Function(decorators, name, names, defaults, flags, doc, code, - lineno=lineno) + return Function(decorators, name, names, defaults, + kwonlyargs, flags, doc, code, lineno=lineno) def lambdef(self, nodelist): # lambdef: 'lambda' [varargslist] ':' test if nodelist[2][0] == symbol.varargslist: - names, defaults, flags = self.com_arglist(nodelist[2][1:]) + names, defaults, kwonlyargs, flags = \ + self.com_arglist(nodelist[2][1:]) else: - names = defaults = () + names = defaults = kwonlyargs = () flags = 0 # code for lambda code = self.com_node(nodelist[-1]) - return Lambda(names, defaults, flags, code, lineno=nodelist[1][2]) + return Lambda(names, defaults, kwonlyargs, + flags, code, lineno=nodelist[1][2]) old_lambdef = lambdef def classdef(self, nodelist): @@ -469,20 +471,6 @@ names.append(nodelist[i][1]) return Global(names, lineno=nodelist[0][2]) - def exec_stmt(self, nodelist): - # exec_stmt: 'exec' expr ['in' expr [',' expr]] - expr1 = self.com_node(nodelist[1]) - if len(nodelist) >= 4: - expr2 = self.com_node(nodelist[3]) - if len(nodelist) >= 6: - expr3 = self.com_node(nodelist[5]) - else: - expr3 = None - else: - expr2 = expr3 = None - - return Exec(expr1, expr2, expr3, lineno=nodelist[0][2]) - def assert_stmt(self, nodelist): # 'assert': test, [',' test] expr1 = self.com_node(nodelist[1]) @@ -618,7 +606,7 @@ for i in range(2, len(nodelist), 2): nl = nodelist[i-1] - # comp_op: '<' | '>' | '=' | '>=' | '<=' | '<>' | '!=' | '==' + # comp_op: '<' | '>' | '=' | '>=' | '<=' | '!=' | '==' # | 'in' | 'not' 'in' | 'is' | 'is' 'not' n = nl[1] if n[0] == token.NAME: @@ -738,10 +726,7 @@ def atom_lbrace(self, nodelist): if nodelist[1][0] == token.RBRACE: return Dict((), lineno=nodelist[0][2]) - return self.com_dictmaker(nodelist[1]) - - def atom_backquote(self, nodelist): - return Backquote(self.com_node(nodelist[1])) + return self.com_dictsetmaker(nodelist[1]) def atom_number(self, nodelist): ### need to verify this matches compile.c @@ -765,6 +750,9 @@ k += self.decode_literal(node[1]) return Const(k, lineno=nodelist[0][2]) + def atom_ellipsis(self, nodelist): + return Const(Ellipsis, lineno=nodelist[0][2]) + def atom_name(self, nodelist): return Name(nodelist[0][1], lineno=nodelist[0][2]) @@ -797,13 +785,37 @@ # ('const', xxxx)) Nodes) return Discard(Const(None)) + def keywordonlyargs(self, nodelist): + # (',' NAME ['=' test])* + # ^^^ + # ------+ + kwonlyargs = [] + i = 0 + while i < len(nodelist): + default = EmptyNode() + node = nodelist[i] + #assert node[0] == token.COMMA + #node = nodelist[i+1] + if i+1 < len(nodelist) and nodelist[i+1][0] == token.EQUAL: + assert i+2 < len(nodelist) + default = self.com_node(nodelist[i+2]) + i += 2 + if node[0] == token.DOUBLESTAR: + return kwonlyargs, i + elif node[0] == token.NAME: + kwonlyargs.append(Keyword(node[1], default, lineno=node[2])) + i += 2 + return kwonlyargs, i + def com_arglist(self, nodelist): # varargslist: - # (fpdef ['=' test] ',')* ('*' NAME [',' '**' NAME] | '**' NAME) - # | fpdef ['=' test] (',' fpdef ['=' test])* [','] + # (fpdef ['=' test] ',')* + # ('*' [NAME] (',' NAME '=' test)* [',' '**' NAME] | '**' NAME) + # | fpdef ['=' test] (',' fpdef ['=' test])* [','] # fpdef: NAME | '(' fplist ')' # fplist: fpdef (',' fpdef)* [','] names = [] + kwonlyargs = [] defaults = [] flags = 0 @@ -813,10 +825,16 @@ if node[0] == token.STAR or node[0] == token.DOUBLESTAR: if node[0] == token.STAR: node = nodelist[i+1] - if node[0] == token.NAME: + if node[0] == token.NAME: # vararg names.append(node[1]) flags = flags | CO_VARARGS i = i + 3 + else: # no vararg + assert node[0] == token.COMMA + i += 2 + if i < len(nodelist) and nodelist[i][0] == token.NAME: + kwonlyargs, skip = self.keywordonlyargs(nodelist[i:]) + i += skip if i < len(nodelist): # should be DOUBLESTAR @@ -845,7 +863,7 @@ # skip the comma i = i + 1 - return names, defaults, flags + return names, defaults, kwonlyargs, flags def com_fpdef(self, node): # fpdef: NAME | '(' fplist ')' @@ -1182,13 +1200,20 @@ assert node[0] == symbol.gen_iter return node[1] - def com_dictmaker(self, nodelist): - # dictmaker: test ':' test (',' test ':' value)* [','] + def com_dictsetmaker(self, nodelist): + # dictsetmaker: (test ':' test (',' test ':' value)* [',']) | (test (',' test)* [',']) items = [] - for i in range(1, len(nodelist), 4): - items.append((self.com_node(nodelist[i]), - self.com_node(nodelist[i+2]))) - return Dict(items, lineno=items[0][0].lineno) + if len(nodelist) == 1 or nodelist[1] != ':': + # it's a set + for i in range(1, len(nodelist), 2): + items.append(self.com_node(nodelist[i])) + return Set(items, lineno=items[0].lineno) + else: + # it's a dict + for i in range(1, len(nodelist), 4): + items.append((self.com_node(nodelist[i]), + self.com_node(nodelist[i+2]))) + return Dict(items, lineno=items[0][0].lineno) def com_apply_trailer(self, primaryNode, nodelist): t = nodelist[1][0] @@ -1279,11 +1304,9 @@ lineno=extractLineNo(nodelist)) def com_subscript(self, node): - # slice_item: expression | proper_slice | ellipsis + # slice_item: expression | proper_slice ch = node[1] t = ch[0] - if t == token.DOT and node[2][0] == token.DOT: - return Ellipsis() if t == token.COLON or len(node) > 2: return self.com_sliceobj(node) return self.com_node(ch) @@ -1374,7 +1397,7 @@ symbol.power, ] -# comp_op: '<' | '>' | '=' | '>=' | '<=' | '<>' | '!=' | '==' +# comp_op: '<' | '>' | '=' | '>=' | '<=' | '!=' | '==' # | 'in' | 'not' 'in' | 'is' | 'is' 'not' _cmp_types = { token.LESS : '<', @@ -1404,7 +1427,6 @@ symbol.raise_stmt, symbol.import_stmt, symbol.global_stmt, - symbol.exec_stmt, symbol.assert_stmt, symbol.if_stmt, symbol.while_stmt, Modified: python/branches/p3yk-noslice/Lib/ctypes/__init__.py ============================================================================== --- python/branches/p3yk-noslice/Lib/ctypes/__init__.py (original) +++ python/branches/p3yk-noslice/Lib/ctypes/__init__.py Fri Dec 15 05:21:50 2006 @@ -427,6 +427,8 @@ c_size_t = c_uint elif sizeof(c_ulong) == sizeof(c_void_p): c_size_t = c_ulong +elif sizeof(c_ulonglong) == sizeof(c_void_p): + c_size_t = c_ulonglong # functions Modified: python/branches/p3yk-noslice/Lib/ctypes/test/__init__.py ============================================================================== --- python/branches/p3yk-noslice/Lib/ctypes/test/__init__.py (original) +++ python/branches/p3yk-noslice/Lib/ctypes/test/__init__.py Fri Dec 15 05:21:50 2006 @@ -37,7 +37,8 @@ def find_package_modules(package, mask): import fnmatch - if hasattr(package, "__loader__"): + if (hasattr(package, "__loader__") and + hasattr(package.__loader__, '_files')): path = package.__name__.replace(".", os.path.sep) mask = os.path.join(path, mask) for fnm in package.__loader__._files.iterkeys(): Modified: python/branches/p3yk-noslice/Lib/ctypes/test/test_bitfields.py ============================================================================== --- python/branches/p3yk-noslice/Lib/ctypes/test/test_bitfields.py (original) +++ python/branches/p3yk-noslice/Lib/ctypes/test/test_bitfields.py Fri Dec 15 05:21:50 2006 @@ -215,5 +215,14 @@ ("b", c_ubyte, 4)] self.failUnlessEqual(sizeof(X), sizeof(c_byte)) + def test_anon_bitfields(self): + # anonymous bit-fields gave a strange error message + class X(Structure): + _fields_ = [("a", c_byte, 4), + ("b", c_ubyte, 4)] + class Y(Structure): + _anonymous_ = ["_"] + _fields_ = [("_", X)] + if __name__ == "__main__": unittest.main() Modified: python/branches/p3yk-noslice/Lib/ctypes/test/test_callbacks.py ============================================================================== --- python/branches/p3yk-noslice/Lib/ctypes/test/test_callbacks.py (original) +++ python/branches/p3yk-noslice/Lib/ctypes/test/test_callbacks.py Fri Dec 15 05:21:50 2006 @@ -101,6 +101,19 @@ after = grc(o) self.failUnlessEqual((after, o), (before, o)) + def test_unsupported_restype_1(self): + # Only "fundamental" result types are supported for callback + # functions, the type must have a non-NULL stgdict->setfunc. + # POINTER(c_double), for example, is not supported. + + prototype = self.functype.im_func(POINTER(c_double)) + # The type is checked when the prototype is called + self.assertRaises(TypeError, prototype, lambda: None) + + def test_unsupported_restype_2(self): + prototype = self.functype.im_func(object) + self.assertRaises(TypeError, prototype, lambda: None) + try: WINFUNCTYPE except NameError: Modified: python/branches/p3yk-noslice/Lib/ctypes/test/test_cast.py ============================================================================== --- python/branches/p3yk-noslice/Lib/ctypes/test/test_cast.py (original) +++ python/branches/p3yk-noslice/Lib/ctypes/test/test_cast.py Fri Dec 15 05:21:50 2006 @@ -57,5 +57,21 @@ c_int() self.failUnlessEqual(p[:4], [1, 2, 96, 4]) + def test_char_p(self): + # This didn't work: bad argument to internal function + s = c_char_p("hiho") + self.failUnlessEqual(cast(cast(s, c_void_p), c_char_p).value, + "hiho") + + try: + c_wchar_p + except NameError: + pass + else: + def test_wchar_p(self): + s = c_wchar_p("hiho") + self.failUnlessEqual(cast(cast(s, c_void_p), c_wchar_p).value, + "hiho") + if __name__ == "__main__": unittest.main() Modified: python/branches/p3yk-noslice/Lib/ctypes/test/test_simplesubclasses.py ============================================================================== --- python/branches/p3yk-noslice/Lib/ctypes/test/test_simplesubclasses.py (original) +++ python/branches/p3yk-noslice/Lib/ctypes/test/test_simplesubclasses.py Fri Dec 15 05:21:50 2006 @@ -2,10 +2,10 @@ from ctypes import * class MyInt(c_int): - def __cmp__(self, other): + def __eq__(self, other): if type(other) != MyInt: - return -1 - return cmp(self.value, other.value) + return NotImplementedError + return self.value == other.value class Test(unittest.TestCase): Modified: python/branches/p3yk-noslice/Lib/ctypes/test/test_structures.py ============================================================================== --- python/branches/p3yk-noslice/Lib/ctypes/test/test_structures.py (original) +++ python/branches/p3yk-noslice/Lib/ctypes/test/test_structures.py Fri Dec 15 05:21:50 2006 @@ -381,5 +381,35 @@ s.p = None self.failUnlessEqual(s.x, 12345678) +class TestRecursiveStructure(unittest.TestCase): + def test_contains_itself(self): + class Recursive(Structure): + pass + + try: + Recursive._fields_ = [("next", Recursive)] + except AttributeError, details: + self.failUnless("Structure or union cannot contain itself" in + str(details)) + else: + self.fail("Structure or union cannot contain itself") + + + def test_vice_versa(self): + class First(Structure): + pass + class Second(Structure): + pass + + First._fields_ = [("second", Second)] + + try: + Second._fields_ = [("first", First)] + except AttributeError, details: + self.failUnless("_fields_ is final" in + str(details)) + else: + self.fail("AttributeError not raised") + if __name__ == '__main__': unittest.main() Modified: python/branches/p3yk-noslice/Lib/ctypes/test/test_win32.py ============================================================================== --- python/branches/p3yk-noslice/Lib/ctypes/test/test_win32.py (original) +++ python/branches/p3yk-noslice/Lib/ctypes/test/test_win32.py Fri Dec 15 05:21:50 2006 @@ -6,7 +6,8 @@ import _ctypes_test -if sys.platform == "win32": +if sys.platform == "win32" and sizeof(c_void_p) == sizeof(c_int): + # Only windows 32-bit has different calling conventions. class WindowsTestCase(unittest.TestCase): def test_callconv_1(self): Modified: python/branches/p3yk-noslice/Lib/decimal.py ============================================================================== --- python/branches/p3yk-noslice/Lib/decimal.py (original) +++ python/branches/p3yk-noslice/Lib/decimal.py Fri Dec 15 05:21:50 2006 @@ -85,7 +85,7 @@ ... ... ... -DivisionByZero: x / 0 +decimal.DivisionByZero: x / 0 >>> c = Context() >>> c.traps[InvalidOperation] = 0 >>> print c.flags[InvalidOperation] @@ -103,7 +103,7 @@ ... ... ... -InvalidOperation: 0 / 0 +decimal.InvalidOperation: 0 / 0 >>> print c.flags[InvalidOperation] 1 >>> c.flags[InvalidOperation] = 0 @@ -131,7 +131,7 @@ 'ROUND_FLOOR', 'ROUND_UP', 'ROUND_HALF_DOWN', # Functions for manipulating contexts - 'setcontext', 'getcontext' + 'setcontext', 'getcontext', 'localcontext' ] import copy as _copy @@ -458,6 +458,49 @@ del threading, local # Don't contaminate the namespace +def localcontext(ctx=None): + """Return a context manager for a copy of the supplied context + + Uses a copy of the current context if no context is specified + The returned context manager creates a local decimal context + in a with statement: + def sin(x): + with localcontext() as ctx: + ctx.prec += 2 + # Rest of sin calculation algorithm + # uses a precision 2 greater than normal + return +s # Convert result to normal precision + + def sin(x): + with localcontext(ExtendedContext): + # Rest of sin calculation algorithm + # uses the Extended Context from the + # General Decimal Arithmetic Specification + return +s # Convert result to normal context + + """ + # The string below can't be included in the docstring until Python 2.6 + # as the doctest module doesn't understand __future__ statements + """ + >>> from __future__ import with_statement + >>> print getcontext().prec + 28 + >>> with localcontext(): + ... ctx = getcontext() + ... ctx.prec() += 2 + ... print ctx.prec + ... + 30 + >>> with localcontext(ExtendedContext): + ... print getcontext().prec + ... + 9 + >>> print getcontext().prec + 28 + """ + if ctx is None: ctx = getcontext() + return _ContextManager(ctx) + ##### Decimal class ########################################### @@ -633,14 +676,14 @@ return other return 0 - def __nonzero__(self): - """Is the number non-zero? + def __bool__(self): + """return True if the number is non-zero. - 0 if self == 0 - 1 if self != 0 + False if self == 0 + True if self != 0 """ if self._is_special: - return 1 + return True return sum(self._int) != 0 def __cmp__(self, other, context=None): @@ -706,6 +749,26 @@ return NotImplemented return self.__cmp__(other) != 0 + def __lt__(self, other): + if not isinstance(other, (Decimal, int, long)): + return NotImplemented + return self.__cmp__(other) < 0 + + def __le__(self, other): + if not isinstance(other, (Decimal, int, long)): + return NotImplemented + return self.__cmp__(other) <= 0 + + def __gt__(self, other): + if not isinstance(other, (Decimal, int, long)): + return NotImplemented + return self.__cmp__(other) > 0 + + def __ge__(self, other): + if not isinstance(other, (Decimal, int, long)): + return NotImplemented + return self.__cmp__(other) >= 0 + def compare(self, other, context=None): """Compares one to another. @@ -739,7 +802,7 @@ i = int(self) if self == Decimal(i): return hash(i) - assert self.__nonzero__() # '-0' handled by integer case + assert self.__bool__() # '-0' handled by integer case return hash(str(self.normalize())) def as_tuple(self): @@ -1894,6 +1957,7 @@ ans = self._check_nans(context=context) if ans: return ans + return self if self._exp >= 0: return self if context is None: @@ -2171,23 +2235,14 @@ del name, val, globalname, rounding_functions -class ContextManager(object): - """Helper class to simplify Context management. - - Sample usage: - - with decimal.ExtendedContext: - s = ... - return +s # Convert result to normal precision - - with decimal.getcontext() as ctx: - ctx.prec += 2 - s = ... - return +s +class _ContextManager(object): + """Context manager class to support localcontext(). + Sets a copy of the supplied context in __enter__() and restores + the previous decimal context in __exit__() """ def __init__(self, new_context): - self.new_context = new_context + self.new_context = new_context.copy() def __enter__(self): self.saved_context = getcontext() setcontext(self.new_context) @@ -2246,9 +2301,6 @@ s.append('traps=[' + ', '.join([t.__name__ for t, v in self.traps.items() if v]) + ']') return ', '.join(s) + ')' - def get_manager(self): - return ContextManager(self.copy()) - def clear_flags(self): """Reset all flags to zero""" for flag in self.flags: Modified: python/branches/p3yk-noslice/Lib/distutils/command/bdist_rpm.py ============================================================================== --- python/branches/p3yk-noslice/Lib/distutils/command/bdist_rpm.py (original) +++ python/branches/p3yk-noslice/Lib/distutils/command/bdist_rpm.py Fri Dec 15 05:21:50 2006 @@ -337,37 +337,47 @@ if not self.keep_temp: rpm_cmd.append('--clean') rpm_cmd.append(spec_path) + # Determine the binary rpm names that should be built out of this spec + # file + # Note that some of these may not be really built (if the file + # list is empty) + nvr_string = "%{name}-%{version}-%{release}" + src_rpm = nvr_string + ".src.rpm" + non_src_rpm = "%{arch}/" + nvr_string + ".%{arch}.rpm" + q_cmd = r"rpm -q --qf '%s %s\n' --specfile '%s'" % ( + src_rpm, non_src_rpm, spec_path) + + out = os.popen(q_cmd) + binary_rpms = [] + source_rpm = None + while 1: + line = out.readline() + if not line: + break + l = string.split(string.strip(line)) + assert(len(l) == 2) + binary_rpms.append(l[1]) + # The source rpm is named after the first entry in the spec file + if source_rpm is None: + source_rpm = l[0] + + status = out.close() + if status: + raise DistutilsExecError("Failed to execute: %s" % repr(q_cmd)) + self.spawn(rpm_cmd) - # XXX this is a nasty hack -- we really should have a proper way to - # find out the names of the RPM files created; also, this assumes - # that RPM creates exactly one source and one binary RPM. if not self.dry_run: if not self.binary_only: - srpms = glob.glob(os.path.join(rpm_dir['SRPMS'], "*.rpm")) - assert len(srpms) == 1, \ - "unexpected number of SRPM files found: %s" % srpms - dist_file = ('bdist_rpm', 'any', - self._dist_path(srpms[0])) - self.distribution.dist_files.append(dist_file) - self.move_file(srpms[0], self.dist_dir) + srpm = os.path.join(rpm_dir['SRPMS'], source_rpm) + assert(os.path.exists(srpm)) + self.move_file(srpm, self.dist_dir) if not self.source_only: - rpms = glob.glob(os.path.join(rpm_dir['RPMS'], "*/*.rpm")) - debuginfo = glob.glob(os.path.join(rpm_dir['RPMS'], - "*/*debuginfo*.rpm")) - if debuginfo: - rpms.remove(debuginfo[0]) - assert len(rpms) == 1, \ - "unexpected number of RPM files found: %s" % rpms - dist_file = ('bdist_rpm', get_python_version(), - self._dist_path(rpms[0])) - self.distribution.dist_files.append(dist_file) - self.move_file(rpms[0], self.dist_dir) - if debuginfo: - dist_file = ('bdist_rpm', get_python_version(), - self._dist_path(debuginfo[0])) - self.move_file(debuginfo[0], self.dist_dir) + for rpm in binary_rpms: + rpm = os.path.join(rpm_dir['RPMS'], rpm) + if os.path.exists(rpm): + self.move_file(rpm, self.dist_dir) # run() def _dist_path(self, path): @@ -381,6 +391,7 @@ spec_file = [ '%define name ' + self.distribution.get_name(), '%define version ' + self.distribution.get_version().replace('-','_'), + '%define unmangled_version ' + self.distribution.get_version(), '%define release ' + self.release.replace('-','_'), '', 'Summary: ' + self.distribution.get_description(), @@ -402,9 +413,9 @@ # but only after it has run: and we create the spec file before # running "sdist", in case of --spec-only. if self.use_bzip2: - spec_file.append('Source0: %{name}-%{version}.tar.bz2') + spec_file.append('Source0: %{name}-%{unmangled_version}.tar.bz2') else: - spec_file.append('Source0: %{name}-%{version}.tar.gz') + spec_file.append('Source0: %{name}-%{unmangled_version}.tar.gz') spec_file.extend([ 'License: ' + self.distribution.get_license(), @@ -479,7 +490,7 @@ # are just text that we drop in as-is. Hmmm. script_options = [ - ('prep', 'prep_script', "%setup"), + ('prep', 'prep_script', "%setup -n %{name}-%{unmangled_version}"), ('build', 'build_script', def_build), ('install', 'install_script', ("%s install " Modified: python/branches/p3yk-noslice/Lib/distutils/command/build_ext.py ============================================================================== --- python/branches/p3yk-noslice/Lib/distutils/command/build_ext.py (original) +++ python/branches/p3yk-noslice/Lib/distutils/command/build_ext.py Fri Dec 15 05:21:50 2006 @@ -186,7 +186,7 @@ # for extensions under Cygwin and AtheOS Python's library directory must be # appended to library_dirs if sys.platform[:6] == 'cygwin' or sys.platform[:6] == 'atheos' or \ - (sys.platform.startswith('linux') and + ((sys.platform.startswith('linux') or sys.platform.startswith('gnu')) and sysconfig.get_config_var('Py_ENABLE_SHARED')): if string.find(sys.executable, sys.exec_prefix) != -1: # building third party extensions Modified: python/branches/p3yk-noslice/Lib/distutils/command/install_egg_info.py ============================================================================== --- python/branches/p3yk-noslice/Lib/distutils/command/install_egg_info.py (original) +++ python/branches/p3yk-noslice/Lib/distutils/command/install_egg_info.py Fri Dec 15 05:21:50 2006 @@ -35,6 +35,9 @@ dir_util.remove_tree(target, dry_run=self.dry_run) elif os.path.exists(target): self.execute(os.unlink,(self.target,),"Removing "+target) + elif not os.path.isdir(self.install_dir): + self.execute(os.makedirs, (self.install_dir,), + "Creating "+self.install_dir) log.info("Writing %s", target) if not self.dry_run: f = open(target, 'w') Modified: python/branches/p3yk-noslice/Lib/distutils/command/register.py ============================================================================== --- python/branches/p3yk-noslice/Lib/distutils/command/register.py (original) +++ python/branches/p3yk-noslice/Lib/distutils/command/register.py Fri Dec 15 05:21:50 2006 @@ -256,7 +256,7 @@ body = StringIO.StringIO() for key, value in data.items(): # handle multiple entries for the same name - if type(value) != type([]): + if type(value) not in (type([]), type( () )): value = [value] for value in value: value = unicode(value).encode("utf-8") Modified: python/branches/p3yk-noslice/Lib/distutils/sysconfig.py ============================================================================== --- python/branches/p3yk-noslice/Lib/distutils/sysconfig.py (original) +++ python/branches/p3yk-noslice/Lib/distutils/sysconfig.py Fri Dec 15 05:21:50 2006 @@ -354,7 +354,7 @@ # load the installed pyconfig.h: try: filename = get_config_h_filename() - parse_config_h(file(filename), g) + parse_config_h(open(filename), g) except IOError, msg: my_msg = "invalid Python installation: unable to open %s" % filename if hasattr(msg, "strerror"): @@ -509,7 +509,10 @@ # are in CFLAGS or LDFLAGS and remove them if they are. # This is needed when building extensions on a 10.3 system # using a universal build of python. - for key in ('LDFLAGS', 'BASECFLAGS'): + for key in ('LDFLAGS', 'BASECFLAGS', + # a number of derived variables. These need to be + # patched up as well. + 'CFLAGS', 'PY_CFLAGS', 'BLDSHARED'): flags = _config_vars[key] flags = re.sub('-arch\s+\w+\s', ' ', flags) flags = re.sub('-isysroot [^ \t]*', ' ', flags) Modified: python/branches/p3yk-noslice/Lib/distutils/unixccompiler.py ============================================================================== --- python/branches/p3yk-noslice/Lib/distutils/unixccompiler.py (original) +++ python/branches/p3yk-noslice/Lib/distutils/unixccompiler.py Fri Dec 15 05:21:50 2006 @@ -82,6 +82,22 @@ except ValueError: pass + # Check if the SDK that is used during compilation actually exists, + # the universal build requires the usage of a universal SDK and not all + # users have that installed by default. + sysroot = None + if '-isysroot' in cc_args: + idx = cc_args.index('-isysroot') + sysroot = cc_args[idx+1] + elif '-isysroot' in compiler_so: + idx = compiler_so.index('-isysroot') + sysroot = compiler_so[idx+1] + + if sysroot and not os.path.isdir(sysroot): + log.warn("Compiling with an SDK that doesn't seem to exist: %s", + sysroot) + log.warn("Please check your Xcode installation") + return compiler_so class UnixCCompiler(CCompiler): Modified: python/branches/p3yk-noslice/Lib/distutils/version.py ============================================================================== --- python/branches/p3yk-noslice/Lib/distutils/version.py (original) +++ python/branches/p3yk-noslice/Lib/distutils/version.py Fri Dec 15 05:21:50 2006 @@ -32,7 +32,8 @@ class Version: """Abstract base class for version numbering classes. Just provides constructor (__init__) and reproducer (__repr__), because those - seem to be the same for all version numbering classes. + seem to be the same for all version numbering classes; and route + rich comparisons to __cmp__. """ def __init__ (self, vstring=None): @@ -42,6 +43,42 @@ def __repr__ (self): return "%s ('%s')" % (self.__class__.__name__, str(self)) + def __eq__(self, other): + c = self.__cmp__(other) + if c is NotImplemented: + return c + return c == 0 + + def __ne__(self, other): + c = self.__cmp__(other) + if c is NotImplemented: + return c + return c != 0 + + def __lt__(self, other): + c = self.__cmp__(other) + if c is NotImplemented: + return c + return c < 0 + + def __le__(self, other): + c = self.__cmp__(other) + if c is NotImplemented: + return c + return c <= 0 + + def __gt__(self, other): + c = self.__cmp__(other) + if c is NotImplemented: + return c + return c > 0 + + def __ge__(self, other): + c = self.__cmp__(other) + if c is NotImplemented: + return c + return c >= 0 + # Interface for version-number classes -- must be implemented # by the following classes (the concrete ones -- Version should Modified: python/branches/p3yk-noslice/Lib/doctest.py ============================================================================== --- python/branches/p3yk-noslice/Lib/doctest.py (original) +++ python/branches/p3yk-noslice/Lib/doctest.py Fri Dec 15 05:21:50 2006 @@ -469,11 +469,12 @@ # This lets us sort tests by name: - def __cmp__(self, other): + def __lt__(self, other): if not isinstance(other, DocTest): - return -1 - return cmp((self.name, self.filename, self.lineno, id(self)), - (other.name, other.filename, other.lineno, id(other))) + return NotImplemented + return ((self.name, self.filename, self.lineno, id(self)) + < + (other.name, other.filename, other.lineno, id(other))) ###################################################################### ## 3. DocTestParser @@ -1208,8 +1209,8 @@ # keyboard interrupts.) try: # Don't blink! This is where the user's code gets run. - exec compile(example.source, filename, "single", - compileflags, 1) in test.globs + exec(compile(example.source, filename, "single", + compileflags, 1), test.globs) self.debugger.set_continue() # ==== Example Finished ==== exception = None except KeyboardInterrupt: @@ -1561,7 +1562,7 @@ - test: the DocTest object being run - - excample: the Example object that failed + - example: the Example object that failed - got: the actual output """ @@ -1580,7 +1581,7 @@ - test: the DocTest object being run - - excample: the Example object that failed + - example: the Example object that failed - exc_info: the exception info """ @@ -1663,7 +1664,7 @@ >>> runner.run(test) Traceback (most recent call last): ... - UnexpectedException: + doctest.UnexpectedException: >>> del test.globs['__builtins__'] >>> test.globs Modified: python/branches/p3yk-noslice/Lib/email/base64mime.py ============================================================================== --- python/branches/p3yk-noslice/Lib/email/base64mime.py (original) +++ python/branches/p3yk-noslice/Lib/email/base64mime.py Fri Dec 15 05:21:50 2006 @@ -146,7 +146,7 @@ # BAW: should encode() inherit b2a_base64()'s dubious behavior in # adding a newline to the encoded string? enc = b2a_base64(s[i:i + max_unencoded]) - if enc.endswith(NL) and eol <> NL: + if enc.endswith(NL) and eol != NL: enc = enc[:-1] + eol encvec.append(enc) return EMPTYSTRING.join(encvec) Modified: python/branches/p3yk-noslice/Lib/email/charset.py ============================================================================== --- python/branches/p3yk-noslice/Lib/email/charset.py (original) +++ python/branches/p3yk-noslice/Lib/email/charset.py Fri Dec 15 05:21:50 2006 @@ -250,7 +250,7 @@ Returns "base64" if self.body_encoding is BASE64. Returns "7bit" otherwise. """ - assert self.body_encoding <> SHORTEST + assert self.body_encoding != SHORTEST if self.body_encoding == QP: return 'quoted-printable' elif self.body_encoding == BASE64: @@ -260,7 +260,7 @@ def convert(self, s): """Convert a string from the input_codec to the output_codec.""" - if self.input_codec <> self.output_codec: + if self.input_codec != self.output_codec: return unicode(s, self.input_codec).encode(self.output_codec) else: return s Modified: python/branches/p3yk-noslice/Lib/email/generator.py ============================================================================== --- python/branches/p3yk-noslice/Lib/email/generator.py (original) +++ python/branches/p3yk-noslice/Lib/email/generator.py Fri Dec 15 05:21:50 2006 @@ -211,7 +211,7 @@ # doesn't preserve newlines/continuations in headers. This is no big # deal in practice, but turns out to be inconvenient for the unittest # suite. - if msg.get_boundary() <> boundary: + if msg.get_boundary() != boundary: msg.set_boundary(boundary) # If there's a preamble, write it out, with a trailing CRLF if msg.preamble is not None: Modified: python/branches/p3yk-noslice/Lib/email/header.py ============================================================================== --- python/branches/p3yk-noslice/Lib/email/header.py (original) +++ python/branches/p3yk-noslice/Lib/email/header.py Fri Dec 15 05:21:50 2006 @@ -248,7 +248,7 @@ elif not isinstance(charset, Charset): charset = Charset(charset) # If the charset is our faux 8bit charset, leave the string unchanged - if charset <> '8bit': + if charset != '8bit': # We need to test that the string can be converted to unicode and # back to a byte string, given the input and output codecs of the # charset. @@ -454,7 +454,7 @@ # If this part is longer than maxlen and we aren't already # splitting on whitespace, try to recursively split this line # on whitespace. - if partlen > maxlen and ch <> ' ': + if partlen > maxlen and ch != ' ': subl = _split_ascii(part, maxlen, restlen, continuation_ws, ' ') lines.extend(subl[:-1]) Modified: python/branches/p3yk-noslice/Lib/email/message.py ============================================================================== --- python/branches/p3yk-noslice/Lib/email/message.py (original) +++ python/branches/p3yk-noslice/Lib/email/message.py Fri Dec 15 05:21:50 2006 @@ -252,7 +252,7 @@ charset=charset.get_output_charset()) else: self.set_param('charset', charset.get_output_charset()) - if str(charset) <> charset.get_output_charset(): + if str(charset) != charset.get_output_charset(): self._payload = charset.body_encode(self._payload) if 'Content-Transfer-Encoding' not in self: cte = charset.get_body_encoding() @@ -301,7 +301,7 @@ name = name.lower() newheaders = [] for k, v in self._headers: - if k.lower() <> name: + if k.lower() != name: newheaders.append((k, v)) self._headers = newheaders @@ -438,7 +438,7 @@ return self.get_default_type() ctype = paramre.split(value)[0].lower().strip() # RFC 2045, section 5.2 says if its invalid, use text/plain - if ctype.count('/') <> 1: + if ctype.count('/') != 1: return 'text/plain' return ctype @@ -601,7 +601,7 @@ ctype = append_param else: ctype = SEMISPACE.join([ctype, append_param]) - if ctype <> self.get(header): + if ctype != self.get(header): del self[header] self[header] = ctype @@ -617,13 +617,13 @@ return new_ctype = '' for p, v in self.get_params(header=header, unquote=requote): - if p.lower() <> param.lower(): + if p.lower() != param.lower(): if not new_ctype: new_ctype = _formatparam(p, v, requote) else: new_ctype = SEMISPACE.join([new_ctype, _formatparam(p, v, requote)]) - if new_ctype <> self.get(header): + if new_ctype != self.get(header): del self[header] self[header] = new_ctype Modified: python/branches/p3yk-noslice/Lib/email/quoprimime.py ============================================================================== --- python/branches/p3yk-noslice/Lib/email/quoprimime.py (original) +++ python/branches/p3yk-noslice/Lib/email/quoprimime.py Fri Dec 15 05:21:50 2006 @@ -287,7 +287,7 @@ n = len(line) while i < n: c = line[i] - if c <> '=': + if c != '=': decoded += c i += 1 # Otherwise, c == "=". Are we at the end of the line? If so, add Modified: python/branches/p3yk-noslice/Lib/email/test/test_email.py ============================================================================== --- python/branches/p3yk-noslice/Lib/email/test/test_email.py (original) +++ python/branches/p3yk-noslice/Lib/email/test/test_email.py Fri Dec 15 05:21:50 2006 @@ -51,7 +51,7 @@ class TestEmailBase(unittest.TestCase): def ndiffAssertEqual(self, first, second): """Like failUnlessEqual except use ndiff for readable output.""" - if first <> second: + if first != second: sfirst = str(first) ssecond = str(second) diff = difflib.ndiff(sfirst.splitlines(), ssecond.splitlines()) @@ -2726,7 +2726,7 @@ # Try a charset with None body encoding c = Charset('us-ascii') eq('hello world', c.body_encode('hello world')) - # Try the convert argument, where input codec <> output codec + # Try the convert argument, where input codec != output codec c = Charset('euc-jp') # With apologies to Tokio Kikuchi ;) try: Modified: python/branches/p3yk-noslice/Lib/email/test/test_email_renamed.py ============================================================================== --- python/branches/p3yk-noslice/Lib/email/test/test_email_renamed.py (original) +++ python/branches/p3yk-noslice/Lib/email/test/test_email_renamed.py Fri Dec 15 05:21:50 2006 @@ -52,7 +52,7 @@ class TestEmailBase(unittest.TestCase): def ndiffAssertEqual(self, first, second): """Like failUnlessEqual except use ndiff for readable output.""" - if first <> second: + if first != second: sfirst = str(first) ssecond = str(second) diff = difflib.ndiff(sfirst.splitlines(), ssecond.splitlines()) @@ -2732,7 +2732,7 @@ # Try a charset with None body encoding c = Charset('us-ascii') eq('hello world', c.body_encode('hello world')) - # Try the convert argument, where input codec <> output codec + # Try the convert argument, where input codec != output codec c = Charset('euc-jp') # With apologies to Tokio Kikuchi ;) try: Modified: python/branches/p3yk-noslice/Lib/email/utils.py ============================================================================== --- python/branches/p3yk-noslice/Lib/email/utils.py (original) +++ python/branches/p3yk-noslice/Lib/email/utils.py Fri Dec 15 05:21:50 2006 @@ -235,10 +235,6 @@ parts = s.split(TICK, 2) if len(parts) <= 2: return None, None, s - if len(parts) > 3: - charset, language = parts[:2] - s = TICK.join(parts[2:]) - return charset, language, s return parts Modified: python/branches/p3yk-noslice/Lib/encodings/__init__.py ============================================================================== --- python/branches/p3yk-noslice/Lib/encodings/__init__.py (original) +++ python/branches/p3yk-noslice/Lib/encodings/__init__.py Fri Dec 15 05:21:50 2006 @@ -28,7 +28,7 @@ """#" -import codecs, types +import codecs from . import aliases _cache = {} @@ -60,7 +60,7 @@ """ # Make sure we have an 8-bit string, because .translate() works # differently for Unicode strings. - if type(encoding) is types.UnicodeType: + if isinstance(encoding, unicode): # Note that .encode('latin-1') does *not* use the codec # registry, so this call doesn't recurse. (See unicodeobject.c # PyUnicode_AsEncodedString() for details) @@ -90,7 +90,7 @@ else: modnames = [norm_encoding] for modname in modnames: - if not modname: + if not modname or '.' in modname: continue try: mod = __import__('encodings.' + modname, Modified: python/branches/p3yk-noslice/Lib/encodings/bz2_codec.py ============================================================================== --- python/branches/p3yk-noslice/Lib/encodings/bz2_codec.py (original) +++ python/branches/p3yk-noslice/Lib/encodings/bz2_codec.py Fri Dec 15 05:21:50 2006 @@ -52,14 +52,35 @@ return bz2_decode(input, errors) class IncrementalEncoder(codecs.IncrementalEncoder): + def __init__(self, errors='strict'): + assert errors == 'strict' + self.errors = errors + self.compressobj = bz2.BZ2Compressor() + def encode(self, input, final=False): - assert self.errors == 'strict' - return bz2.compress(input) + if final: + c = self.compressobj.compress(input) + return c + self.compressobj.flush() + else: + return self.compressobj.compress(input) + + def reset(self): + self.compressobj = bz2.BZ2Compressor() class IncrementalDecoder(codecs.IncrementalDecoder): + def __init__(self, errors='strict'): + assert errors == 'strict' + self.errors = errors + self.decompressobj = bz2.BZ2Decompressor() + def decode(self, input, final=False): - assert self.errors == 'strict' - return bz2.decompress(input) + try: + return self.decompressobj.decompress(input) + except EOFError: + return '' + + def reset(self): + self.decompressobj = bz2.BZ2Decompressor() class StreamWriter(Codec,codecs.StreamWriter): pass Modified: python/branches/p3yk-noslice/Lib/encodings/utf_8_sig.py ============================================================================== --- python/branches/p3yk-noslice/Lib/encodings/utf_8_sig.py (original) +++ python/branches/p3yk-noslice/Lib/encodings/utf_8_sig.py Fri Dec 15 05:21:50 2006 @@ -16,7 +16,7 @@ def decode(input, errors='strict'): prefix = 0 - if input.startswith(codecs.BOM_UTF8): + if input[:3] == codecs.BOM_UTF8: input = input[3:] prefix = 3 (output, consumed) = codecs.utf_8_decode(input, errors, True) Modified: python/branches/p3yk-noslice/Lib/encodings/zlib_codec.py ============================================================================== --- python/branches/p3yk-noslice/Lib/encodings/zlib_codec.py (original) +++ python/branches/p3yk-noslice/Lib/encodings/zlib_codec.py Fri Dec 15 05:21:50 2006 @@ -51,14 +51,36 @@ return zlib_decode(input, errors) class IncrementalEncoder(codecs.IncrementalEncoder): + def __init__(self, errors='strict'): + assert errors == 'strict' + self.errors = errors + self.compressobj = zlib.compressobj() + def encode(self, input, final=False): - assert self.errors == 'strict' - return zlib.compress(input) + if final: + c = self.compressobj.compress(input) + return c + self.compressobj.flush() + else: + return self.compressobj.compress(input) + + def reset(self): + self.compressobj = zlib.compressobj() class IncrementalDecoder(codecs.IncrementalDecoder): + def __init__(self, errors='strict'): + assert errors == 'strict' + self.errors = errors + self.decompressobj = zlib.decompressobj() + def decode(self, input, final=False): - assert self.errors == 'strict' - return zlib.decompress(input) + if final: + c = self.decompressobj.decompress(input) + return c + self.decompressobj.flush() + else: + return self.decompressobj.decompress(input) + + def reset(self): + self.decompressobj = zlib.decompressobj() class StreamWriter(Codec,codecs.StreamWriter): pass Modified: python/branches/p3yk-noslice/Lib/ftplib.py ============================================================================== --- python/branches/p3yk-noslice/Lib/ftplib.py (original) +++ python/branches/p3yk-noslice/Lib/ftplib.py Fri Dec 15 05:21:50 2006 @@ -325,6 +325,14 @@ if rest is not None: self.sendcmd("REST %s" % rest) resp = self.sendcmd(cmd) + # Some servers apparently send a 200 reply to + # a LIST or STOR command, before the 150 reply + # (and way before the 226 reply). This seems to + # be in violation of the protocol (which only allows + # 1xx or error messages for LIST), so we just discard + # this response. + if resp[0] == '2': + resp = self.getresp() if resp[0] != '1': raise error_reply, resp else: @@ -332,6 +340,9 @@ if rest is not None: self.sendcmd("REST %s" % rest) resp = self.sendcmd(cmd) + # See above. + if resp[0] == '2': + resp = self.getresp() if resp[0] != '1': raise error_reply, resp conn, sockaddr = sock.accept() Modified: python/branches/p3yk-noslice/Lib/functools.py ============================================================================== --- python/branches/p3yk-noslice/Lib/functools.py (original) +++ python/branches/p3yk-noslice/Lib/functools.py Fri Dec 15 05:21:50 2006 @@ -7,7 +7,7 @@ # Copyright (C) 2006 Python Software Foundation. # See C source code for _functools credits/copyright -from _functools import partial +from _functools import partial, reduce # update_wrapper() and wraps() are tools to help write # wrapper functions that can handle naive introspection @@ -25,14 +25,14 @@ assigned is a tuple naming the attributes assigned directly from the wrapped function to the wrapper function (defaults to functools.WRAPPER_ASSIGNMENTS) - updated is a tuple naming the attributes off the wrapper that + updated is a tuple naming the attributes of the wrapper that are updated with the corresponding attribute from the wrapped function (defaults to functools.WRAPPER_UPDATES) """ for attr in assigned: setattr(wrapper, attr, getattr(wrapped, attr)) for attr in updated: - getattr(wrapper, attr).update(getattr(wrapped, attr)) + getattr(wrapper, attr).update(getattr(wrapped, attr, {})) # Return the wrapper so this can be used as a decorator via partial() return wrapper Modified: python/branches/p3yk-noslice/Lib/gzip.py ============================================================================== --- python/branches/p3yk-noslice/Lib/gzip.py (original) +++ python/branches/p3yk-noslice/Lib/gzip.py Fri Dec 15 05:21:50 2006 @@ -371,7 +371,12 @@ self.extrasize = 0 self.offset = 0 - def seek(self, offset): + def seek(self, offset, whence=0): + if whence: + if whence == 1: + offset = self.offset + offset + else: + raise ValueError('Seek from end not supported') if self.mode == WRITE: if offset < self.offset: raise IOError('Negative seek in write mode') Modified: python/branches/p3yk-noslice/Lib/hashlib.py ============================================================================== --- python/branches/p3yk-noslice/Lib/hashlib.py (original) +++ python/branches/p3yk-noslice/Lib/hashlib.py Fri Dec 15 05:21:50 2006 @@ -18,8 +18,37 @@ More algorithms may be available on your platform but the above are guaranteed to exist. -Choose your hash function wisely. Some have known weaknesses. +Choose your hash function wisely. Some have known collision weaknesses. sha384 and sha512 will be slow on 32 bit platforms. + +Hash objects have these methods: + - update(arg): Update the hash object with the string arg. Repeated calls + are equivalent to a single call with the concatenation of all + the arguments. + - digest(): Return the digest of the strings passed to the update() method + so far. This may contain non-ASCII characters, including + NUL bytes. + - hexdigest(): Like digest() except the digest is returned as a string of + double length, containing only hexadecimal digits. + - copy(): Return a copy (clone) of the hash object. This can be used to + efficiently compute the digests of strings that share a common + initial substring. + +For example, to obtain the digest of the string 'Nobody inspects the +spammish repetition': + + >>> import hashlib + >>> m = hashlib.md5() + >>> m.update("Nobody inspects") + >>> m.update(" the spammish repetition") + >>> m.digest() + '\xbbd\x9c\x83\xdd\x1e\xa5\xc9\xd9\xde\xc9\xa1\x8d\xf0\xff\xe9' + +More condensed: + + >>> hashlib.sha224("Nobody inspects the spammish repetition").hexdigest() + 'a4337bc45a8fc544c03f52dc550cd6e1e87021bc896588bd79e901e2' + """ @@ -82,11 +111,11 @@ f = getattr(_hashlib, opensslFuncName) f() # Use the C function directly (very fast) - exec funcName + ' = f' + exec(funcName + ' = f') except ValueError: try: # Use the builtin implementation directly (fast) - exec funcName + ' = __get_builtin_constructor(funcName)' + exec(funcName + ' = __get_builtin_constructor(funcName)') except ValueError: # this one has no builtin implementation, don't define it pass Modified: python/branches/p3yk-noslice/Lib/httplib.py ============================================================================== --- python/branches/p3yk-noslice/Lib/httplib.py (original) +++ python/branches/p3yk-noslice/Lib/httplib.py Fri Dec 15 05:21:50 2006 @@ -704,7 +704,15 @@ if self.debuglevel > 0: print "send:", repr(str) try: - self.sock.sendall(str) + blocksize=8192 + if hasattr(str,'read') : + if self.debuglevel > 0: print "sendIng a read()able" + data=str.read(blocksize) + while data: + self.sock.sendall(data) + data=str.read(blocksize) + else: + self.sock.sendall(str) except socket.error, v: if v[0] == 32: # Broken pipe self.close() @@ -879,7 +887,21 @@ self.putrequest(method, url, **skips) if body and ('content-length' not in header_names): - self.putheader('Content-Length', str(len(body))) + thelen=None + try: + thelen=str(len(body)) + except TypeError, te: + # If this is a file-like object, try to + # fstat its file descriptor + import os + try: + thelen = str(os.fstat(body.fileno()).st_size) + except (AttributeError, OSError): + # Don't send a length if this failed + if self.debuglevel > 0: print "Cannot stat!!" + + if thelen is not None: + self.putheader('Content-Length',thelen) for hdr, value in headers.iteritems(): self.putheader(hdr, value) self.endheaders() Modified: python/branches/p3yk-noslice/Lib/idlelib/CodeContext.py ============================================================================== --- python/branches/p3yk-noslice/Lib/idlelib/CodeContext.py (original) +++ python/branches/p3yk-noslice/Lib/idlelib/CodeContext.py Fri Dec 15 05:21:50 2006 @@ -54,25 +54,68 @@ def toggle_code_context_event(self, event=None): if not self.label: - self.pad_frame = Tkinter.Frame(self.editwin.top, - bg=self.bgcolor, border=2, - relief="sunken") - self.label = Tkinter.Label(self.pad_frame, - text="\n" * (self.context_depth - 1), - anchor="w", justify="left", - font=self.textfont, - bg=self.bgcolor, fg=self.fgcolor, - border=0, - width=1, # Don't request more than we get - ) - self.label.pack(side="top", fill="x", expand=True, - padx=4, pady=0) - self.pad_frame.pack(side="top", fill="x", expand=False, - padx=0, pady=0, - after=self.editwin.status_bar) + # The following code attempts to figure out the required border + # width and vertical padding required for the CodeContext widget + # to be perfectly aligned with the text in the main Text widget. + # This is done by retrieving the appropriate attributes from the + # editwin.text and editwin.text_frame widgets. + # + # All values are passed through int(str()), since some + # values may be pixel objects, which can't simply be added added + # to ints. + # + # This code is considered somewhat unstable since it relies on + # some of Tk's inner workings. However its effect is merely + # cosmetic; failure will only cause the CodeContext text to be + # somewhat misaligned with the text in the main Text widget. + # + # To avoid possible errors, all references to the inner workings + # of Tk are executed inside try/except blocks. + + widgets_for_width_calc = self.editwin.text, self.editwin.text_frame + + # calculate the required vertical padding + padx = 0 + for widget in widgets_for_width_calc: + try: + # retrieve the "padx" attribte from widget's pack info + padx += int(str( widget.pack_info()['padx'] )) + except: + pass + try: + # retrieve the widget's "padx" attribte + padx += int(str( widget.cget('padx') )) + except: + pass + + # calculate the required border width + border_width = 0 + for widget in widgets_for_width_calc: + try: + # retrieve the widget's "border" attribte + border_width += int(str( widget.cget('border') )) + except: + pass + + self.label = Tkinter.Label(self.editwin.top, + text="\n" * (self.context_depth - 1), + anchor="w", justify="left", + font=self.textfont, + bg=self.bgcolor, fg=self.fgcolor, + width=1, #don't request more than we get + padx=padx, #line up with text widget + border=border_width, #match border width + relief="sunken", + ) + + # CodeContext's label widget is packed before and above the + # text_frame widget, thus ensuring that it will appear directly + # above it. + self.label.pack(side="top", fill="x", expand=False, + before=self.editwin.text_frame) + else: self.label.destroy() - self.pad_frame.destroy() self.label = None idleConf.SetOption("extensions", "CodeContext", "visible", str(self.label is not None)) Modified: python/branches/p3yk-noslice/Lib/idlelib/ColorDelegator.py ============================================================================== --- python/branches/p3yk-noslice/Lib/idlelib/ColorDelegator.py (original) +++ python/branches/p3yk-noslice/Lib/idlelib/ColorDelegator.py Fri Dec 15 05:21:50 2006 @@ -16,7 +16,7 @@ kw = r"\b" + any("KEYWORD", keyword.kwlist) + r"\b" builtinlist = [str(name) for name in dir(__builtin__) if not name.startswith('_')] - # self.file = file("file") : + # self.file = open("file") : # 1st 'file' colorized normal, 2nd as builtin, 3rd as string builtin = r"([^.'\"\\#]\b|^)" + any("BUILTIN", builtinlist) + r"\b" comment = any("COMMENT", [r"#[^\n]*"]) Modified: python/branches/p3yk-noslice/Lib/idlelib/EditorWindow.py ============================================================================== --- python/branches/p3yk-noslice/Lib/idlelib/EditorWindow.py (original) +++ python/branches/p3yk-noslice/Lib/idlelib/EditorWindow.py Fri Dec 15 05:21:50 2006 @@ -102,8 +102,8 @@ self.top.instance_dict = {} self.recent_files_path = os.path.join(idleConf.GetUserCfgDir(), 'recent-files.lst') - self.vbar = vbar = Scrollbar(top, name='vbar') self.text_frame = text_frame = Frame(top) + self.vbar = vbar = Scrollbar(text_frame, name='vbar') self.width = idleConf.GetOption('main','EditorWindow','width') self.text = text = MultiCallCreator(Text)( text_frame, name='text', padx=5, wrap='none', @@ -1138,7 +1138,7 @@ if not self.context_use_ps1: for context in self.num_context_lines: startat = max(lno - context, 1) - startatindex = `startat` + ".0" + startatindex = repr(startat) + ".0" rawtext = text.get(startatindex, "insert") y.set_str(rawtext) bod = y.find_good_parse_start( Modified: python/branches/p3yk-noslice/Lib/idlelib/HyperParser.py ============================================================================== --- python/branches/p3yk-noslice/Lib/idlelib/HyperParser.py (original) +++ python/branches/p3yk-noslice/Lib/idlelib/HyperParser.py Fri Dec 15 05:21:50 2006 @@ -31,7 +31,7 @@ if not editwin.context_use_ps1: for context in editwin.num_context_lines: startat = max(lno - context, 1) - startatindex = `startat` + ".0" + startatindex = repr(startat) + ".0" stopatindex = "%d.end" % lno # We add the newline because PyParse requires a newline at end. # We add a space so that index won't be at end of line, so that Modified: python/branches/p3yk-noslice/Lib/idlelib/NEWS.txt ============================================================================== --- python/branches/p3yk-noslice/Lib/idlelib/NEWS.txt (original) +++ python/branches/p3yk-noslice/Lib/idlelib/NEWS.txt Fri Dec 15 05:21:50 2006 @@ -3,6 +3,13 @@ *Release date: XX-XXX-200X* +- Patch #1362975: Rework CodeContext indentation algorithm to + avoid hard-coding pixel widths. + +- Some syntax errors were being caught by tokenize during the tabnanny + check, resulting in obscure error messages. Do the syntax check + first. Bug 1562716, 1562719 + - IDLE's version number takes a big jump to match the version number of the Python release of which it's a part. Modified: python/branches/p3yk-noslice/Lib/idlelib/PyShell.py ============================================================================== --- python/branches/p3yk-noslice/Lib/idlelib/PyShell.py (original) +++ python/branches/p3yk-noslice/Lib/idlelib/PyShell.py Fri Dec 15 05:21:50 2006 @@ -351,6 +351,8 @@ def build_subprocess_arglist(self): w = ['-W' + s for s in sys.warnoptions] + if 1/2 > 0: # account for new division + w.append('-Qnew') # Maybe IDLE is installed and is being accessed via sys.path, # or maybe it's not installed and the idle.py script is being # run from the IDLE source directory. @@ -690,7 +692,7 @@ if self.rpcclt: self.rpcclt.remotequeue("exec", "runcode", (code,), {}) else: - exec code in self.locals + exec(code, self.locals) return 1 def runcode(self, code): @@ -711,7 +713,7 @@ elif debugger: debugger.run(code, self.locals) else: - exec code in self.locals + exec(code, self.locals) except SystemExit: if not self.tkconsole.closing: if tkMessageBox.askyesno( @@ -726,6 +728,8 @@ raise except: if use_subprocess: + # When run w/o subprocess, both user and IDLE errors + # are printed here; skip message in that case. print >> self.tkconsole.stderr, \ "IDLE internal error in runcode()" self.showtraceback() Modified: python/branches/p3yk-noslice/Lib/idlelib/ScriptBinding.py ============================================================================== --- python/branches/p3yk-noslice/Lib/idlelib/ScriptBinding.py (original) +++ python/branches/p3yk-noslice/Lib/idlelib/ScriptBinding.py Fri Dec 15 05:21:50 2006 @@ -57,9 +57,10 @@ filename = self.getfilename() if not filename: return + if not self.checksyntax(filename): + return if not self.tabnanny(filename): return - self.checksyntax(filename) def tabnanny(self, filename): f = open(filename, 'r') @@ -76,9 +77,6 @@ self.editwin.gotoline(nag.get_lineno()) self.errorbox("Tab/space error", indent_message) return False - except IndentationError: - # From tokenize(), let compile() in checksyntax find it again. - pass return True def checksyntax(self, filename): @@ -139,11 +137,11 @@ filename = self.getfilename() if not filename: return - if not self.tabnanny(filename): - return code = self.checksyntax(filename) if not code: return + if not self.tabnanny(filename): + return shell = self.shell interp = shell.interp if PyShell.use_subprocess: Modified: python/branches/p3yk-noslice/Lib/idlelib/run.py ============================================================================== --- python/branches/p3yk-noslice/Lib/idlelib/run.py (original) +++ python/branches/p3yk-noslice/Lib/idlelib/run.py Fri Dec 15 05:21:50 2006 @@ -282,7 +282,7 @@ def runcode(self, code): try: self.usr_exc_info = None - exec code in self.locals + exec(code, self.locals) except: self.usr_exc_info = sys.exc_info() if quitting: Modified: python/branches/p3yk-noslice/Lib/ihooks.py ============================================================================== --- python/branches/p3yk-noslice/Lib/ihooks.py (original) +++ python/branches/p3yk-noslice/Lib/ihooks.py Fri Dec 15 05:21:50 2006 @@ -323,7 +323,7 @@ m.__path__ = path m.__file__ = filename try: - exec code in m.__dict__ + exec(code, m.__dict__) except: d = self.hooks.modules_dict() if name in d: Modified: python/branches/p3yk-noslice/Lib/imputil.py ============================================================================== --- python/branches/p3yk-noslice/Lib/imputil.py (original) +++ python/branches/p3yk-noslice/Lib/imputil.py Fri Dec 15 05:21:50 2006 @@ -301,7 +301,7 @@ # execute the code within the module's namespace if not is_module: try: - exec code in module.__dict__ + exec(code, module.__dict__) except: if fqname in sys.modules: del sys.modules[fqname] Modified: python/branches/p3yk-noslice/Lib/inspect.py ============================================================================== --- python/branches/p3yk-noslice/Lib/inspect.py (original) +++ python/branches/p3yk-noslice/Lib/inspect.py Fri Dec 15 05:21:50 2006 @@ -403,6 +403,7 @@ return os.path.normcase(os.path.abspath(_filename)) modulesbyfile = {} +_filesbymodname = {} def getmodule(object, _filename=None): """Return the module an object was defined in, or None if not found.""" @@ -410,19 +411,32 @@ return object if hasattr(object, '__module__'): return sys.modules.get(object.__module__) + # Try the filename to modulename cache + if _filename is not None and _filename in modulesbyfile: + return sys.modules.get(modulesbyfile[_filename]) + # Try the cache again with the absolute file name try: file = getabsfile(object, _filename) except TypeError: return None if file in modulesbyfile: return sys.modules.get(modulesbyfile[file]) - for module in sys.modules.values(): + # Update the filename to module name cache and check yet again + # Copy sys.modules in order to cope with changes while iterating + for modname, module in sys.modules.items(): if ismodule(module) and hasattr(module, '__file__'): + f = module.__file__ + if f == _filesbymodname.get(modname, None): + # Have already mapped this module, so skip it + continue + _filesbymodname[modname] = f f = getabsfile(module) + # Always map to the name the module knows itself by modulesbyfile[f] = modulesbyfile[ os.path.realpath(f)] = module.__name__ if file in modulesbyfile: return sys.modules.get(modulesbyfile[file]) + # Check the main module main = sys.modules['__main__'] if not hasattr(object, '__name__'): return None @@ -430,6 +444,7 @@ mainobject = getattr(main, object.__name__) if mainobject is object: return main + # Check builtins builtin = sys.modules['__builtin__'] if hasattr(builtin, object.__name__): builtinobject = getattr(builtin, object.__name__) @@ -444,7 +459,7 @@ in the file and the line number indexes a line in that list. An IOError is raised if the source code cannot be retrieved.""" file = getsourcefile(object) or getfile(object) - module = getmodule(object) + module = getmodule(object, file) if module: lines = linecache.getlines(file, module.__dict__) else: @@ -457,9 +472,24 @@ if isclass(object): name = object.__name__ - pat = re.compile(r'^\s*class\s*' + name + r'\b') + pat = re.compile(r'^(\s*)class\s*' + name + r'\b') + # make some effort to find the best matching class definition: + # use the one with the least indentation, which is the one + # that's most probably not inside a function definition. + candidates = [] for i in range(len(lines)): - if pat.match(lines[i]): return lines, i + match = pat.match(lines[i]) + if match: + # if it's at toplevel, it's already the best one + if lines[i][0] == 'c': + return lines, i + # else add whitespace to candidate list + candidates.append((match.group(1), i)) + if candidates: + # this will sort by whitespace, and by line number, + # less whitespace first + candidates.sort() + return lines, candidates[0][1] else: raise IOError('could not find class definition') Modified: python/branches/p3yk-noslice/Lib/keyword.py ============================================================================== --- python/branches/p3yk-noslice/Lib/keyword.py (original) +++ python/branches/p3yk-noslice/Lib/keyword.py Fri Dec 15 05:21:50 2006 @@ -25,7 +25,6 @@ 'elif', 'else', 'except', - 'exec', 'finally', 'for', 'from', Modified: python/branches/p3yk-noslice/Lib/lib-tk/Tix.py ============================================================================== --- python/branches/p3yk-noslice/Lib/lib-tk/Tix.py (original) +++ python/branches/p3yk-noslice/Lib/lib-tk/Tix.py Fri Dec 15 05:21:50 2006 @@ -421,7 +421,7 @@ except: plist = [] - if (not check_intermediate) or len(plist) < 2: + if not check_intermediate: # immediate descendant TixWidget.__init__(self, master, None, None, {'name' : name}) else: @@ -437,6 +437,9 @@ parent = TixSubWidget(parent, plist[i], destroy_physically=0, check_intermediate=0) + # The Tk widget name is in plist, not in name + if plist: + name = plist[-1] TixWidget.__init__(self, parent, None, None, {'name' : name}) self.destroy_physically = destroy_physically Modified: python/branches/p3yk-noslice/Lib/lib-tk/Tkinter.py ============================================================================== --- python/branches/p3yk-noslice/Lib/lib-tk/Tkinter.py (original) +++ python/branches/p3yk-noslice/Lib/lib-tk/Tkinter.py Fri Dec 15 05:21:50 2006 @@ -1699,7 +1699,7 @@ base_tcl = os.path.join(home, '.%s.tcl' % baseName) base_py = os.path.join(home, '.%s.py' % baseName) dir = {'self': self} - exec 'from Tkinter import *' in dir + exec('from Tkinter import *', dir) if os.path.isfile(class_tcl): self.tk.call('source', class_tcl) if os.path.isfile(class_py): @@ -3017,7 +3017,7 @@ self.tk.call(self._w, 'scan', 'dragto', x, y) def search(self, pattern, index, stopindex=None, forwards=None, backwards=None, exact=None, - regexp=None, nocase=None, count=None): + regexp=None, nocase=None, count=None, elide=None): """Search PATTERN beginning from INDEX until STOPINDEX. Return the index of the first character of a match or an empty string.""" args = [self._w, 'search'] @@ -3026,6 +3026,7 @@ if exact: args.append('-exact') if regexp: args.append('-regexp') if nocase: args.append('-nocase') + if elide: args.append('-elide') if count: args.append('-count'); args.append(count) if pattern[0] == '-': args.append('--') args.append(pattern) Modified: python/branches/p3yk-noslice/Lib/lib-tk/tkMessageBox.py ============================================================================== --- python/branches/p3yk-noslice/Lib/lib-tk/tkMessageBox.py (original) +++ python/branches/p3yk-noslice/Lib/lib-tk/tkMessageBox.py Fri Dec 15 05:21:50 2006 @@ -102,6 +102,15 @@ s = _show(title, message, QUESTION, YESNO, **options) return s == YES +def askyesnocancel(title=None, message=None, **options): + "Ask a question; return true if the answer is yes, None if cancelled." + s = _show(title, message, QUESTION, YESNOCANCEL, **options) + # s might be a Tcl index object, so convert it to a string + s = str(s) + if s == CANCEL: + return None + return s == YES + def askretrycancel(title=None, message=None, **options): "Ask if operation should be retried; return true if the answer is yes" s = _show(title, message, WARNING, RETRYCANCEL, **options) @@ -119,4 +128,5 @@ print "question", askquestion("Spam", "Question?") print "proceed", askokcancel("Spam", "Proceed?") print "yes/no", askyesno("Spam", "Got it?") + print "yes/no/cancel", askyesnocancel("Spam", "Want it?") print "try again", askretrycancel("Spam", "Try again?") Modified: python/branches/p3yk-noslice/Lib/lib-tk/tkSimpleDialog.py ============================================================================== --- python/branches/p3yk-noslice/Lib/lib-tk/tkSimpleDialog.py (original) +++ python/branches/p3yk-noslice/Lib/lib-tk/tkSimpleDialog.py Fri Dec 15 05:21:50 2006 @@ -46,8 +46,13 @@ title -- the dialog title ''' Toplevel.__init__(self, parent) - self.transient(parent) + # If the master is not viewable, don't + # make the child transient, or else it + # would be opened withdrawn + if parent.winfo_viewable(): + self.transient(parent) + if title: self.title(title) @@ -124,9 +129,10 @@ self.withdraw() self.update_idletasks() - self.apply() - - self.cancel() + try: + self.apply() + finally: + self.cancel() def cancel(self, event=None): Modified: python/branches/p3yk-noslice/Lib/lib-tk/turtle.py ============================================================================== --- python/branches/p3yk-noslice/Lib/lib-tk/turtle.py (original) +++ python/branches/p3yk-noslice/Lib/lib-tk/turtle.py Fri Dec 15 05:21:50 2006 @@ -15,6 +15,7 @@ """ from math import * # Also for export +from time import sleep import Tkinter speeds = ['fastest', 'fast', 'normal', 'slow', 'slowest'] @@ -949,7 +950,6 @@ if __name__ == '__main__': - from time import sleep demo() sleep(3) demo2() Modified: python/branches/p3yk-noslice/Lib/logging/__init__.py ============================================================================== --- python/branches/p3yk-noslice/Lib/logging/__init__.py (original) +++ python/branches/p3yk-noslice/Lib/logging/__init__.py Fri Dec 15 05:21:50 2006 @@ -214,7 +214,7 @@ information to be logged. """ def __init__(self, name, level, pathname, lineno, - msg, args, exc_info, func): + msg, args, exc_info, func=None): """ Initialize a logging record with interesting information. """ @@ -910,9 +910,11 @@ Ensure that children of the placeholder ph are connected to the specified logger. """ - #for c in ph.loggers: + name = alogger.name + namelen = len(name) for c in ph.loggerMap.keys(): - if string.find(c.parent.name, alogger.name) <> 0: + #The if means ... if not c.parent.name.startswith(nm) + if c.parent.name[:namelen] != name: alogger.parent = c.parent c.parent = alogger Modified: python/branches/p3yk-noslice/Lib/logging/config.py ============================================================================== --- python/branches/p3yk-noslice/Lib/logging/config.py (original) +++ python/branches/p3yk-noslice/Lib/logging/config.py Fri Dec 15 05:21:50 2006 @@ -27,7 +27,7 @@ To use, simply 'import logging' and log away! """ -import sys, logging, logging.handlers, string, socket, struct, os, traceback +import sys, logging, logging.handlers, string, socket, struct, os, traceback, types try: import thread @@ -110,7 +110,7 @@ flist = string.split(flist, ",") formatters = {} for form in flist: - sectname = "formatter_%s" % form + sectname = "formatter_%s" % string.strip(form) opts = cp.options(sectname) if "format" in opts: fs = cp.get(sectname, "format", 1) @@ -139,7 +139,7 @@ handlers = {} fixups = [] #for inter-handler references for hand in hlist: - sectname = "handler_%s" % hand + sectname = "handler_%s" % string.strip(hand) klass = cp.get(sectname, "class") opts = cp.options(sectname) if "formatter" in opts: @@ -176,6 +176,7 @@ # configure the root first llist = cp.get("loggers", "keys") llist = string.split(llist, ",") + llist = map(lambda x: string.strip(x), llist) llist.remove("root") sectname = "logger_root" root = logging.root @@ -190,7 +191,7 @@ if len(hlist): hlist = string.split(hlist, ",") for hand in hlist: - log.addHandler(handlers[hand]) + log.addHandler(handlers[string.strip(hand)]) #and now the others... #we don't want to lose the existing loggers, @@ -225,7 +226,7 @@ if len(hlist): hlist = string.split(hlist, ",") for hand in hlist: - logger.addHandler(handlers[hand]) + logger.addHandler(handlers[string.strip(hand)]) #Disable any old loggers. There's no point deleting #them as other threads may continue to hold references Modified: python/branches/p3yk-noslice/Lib/logging/handlers.py ============================================================================== --- python/branches/p3yk-noslice/Lib/logging/handlers.py (original) +++ python/branches/p3yk-noslice/Lib/logging/handlers.py Fri Dec 15 05:21:50 2006 @@ -590,11 +590,11 @@ self.address = address self.facility = facility if type(address) == types.StringType: - self._connect_unixsocket(address) self.unixsocket = 1 + self._connect_unixsocket(address) else: - self.socket = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) self.unixsocket = 0 + self.socket = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) self.formatter = None Modified: python/branches/p3yk-noslice/Lib/macpath.py ============================================================================== --- python/branches/p3yk-noslice/Lib/macpath.py (original) +++ python/branches/p3yk-noslice/Lib/macpath.py Fri Dec 15 05:21:50 2006 @@ -2,6 +2,7 @@ import os from stat import * +from genericpath import * __all__ = ["normcase","isabs","join","splitdrive","split","splitext", "basename","dirname","commonprefix","getsize","getmtime", @@ -101,31 +102,6 @@ components = split(s) return len(components) == 2 and components[1] == '' -def isdir(s): - """Return true if the pathname refers to an existing directory.""" - - try: - st = os.stat(s) - except os.error: - return 0 - return S_ISDIR(st.st_mode) - - -# Get size, mtime, atime of files. - -def getsize(filename): - """Return the size of a file, reported by os.stat().""" - return os.stat(filename).st_size - -def getmtime(filename): - """Return the last modification time of a file, reported by os.stat().""" - return os.stat(filename).st_mtime - -def getatime(filename): - """Return the last access time of a file, reported by os.stat().""" - return os.stat(filename).st_atime - - def islink(s): """Return true if the pathname refers to a symbolic link.""" @@ -135,29 +111,6 @@ except: return False - -def isfile(s): - """Return true if the pathname refers to an existing regular file.""" - - try: - st = os.stat(s) - except os.error: - return False - return S_ISREG(st.st_mode) - -def getctime(filename): - """Return the creation time of a file, reported by os.stat().""" - return os.stat(filename).st_ctime - -def exists(s): - """Test whether a path exists. Returns False for broken symbolic links""" - - try: - st = os.stat(s) - except os.error: - return False - return True - # Is `stat`/`lstat` a meaningful difference on the Mac? This is safe in any # case. @@ -170,20 +123,6 @@ return False return True -# Return the longest prefix of all list elements. - -def commonprefix(m): - "Given a list of pathnames, returns the longest common leading component" - if not m: return '' - s1 = min(m) - s2 = max(m) - n = min(len(s1), len(s2)) - for i in xrange(n): - if s1[i] != s2[i]: - return s1[:i] - return s1[:n] - - def expandvars(path): """Dummy to retain interface-compatibility with other operating systems.""" return path Modified: python/branches/p3yk-noslice/Lib/mailbox.py ============================================================================== --- python/branches/p3yk-noslice/Lib/mailbox.py (original) +++ python/branches/p3yk-noslice/Lib/mailbox.py Fri Dec 15 05:21:50 2006 @@ -2,6 +2,12 @@ """Read/write support for Maildir, mbox, MH, Babyl, and MMDF mailboxes.""" +# Notes for authors of new mailbox subclasses: +# +# Remember to fsync() changes to disk before closing a modified file +# or returning from a flush() method. See functions _sync_flush() and +# _sync_close(). + import sys import os import time @@ -235,7 +241,7 @@ try: self._dump_message(message, tmp_file) finally: - tmp_file.close() + _sync_close(tmp_file) if isinstance(message, MaildirMessage): subdir = message.get_subdir() suffix = self.colon + message.get_info() @@ -246,7 +252,19 @@ suffix = '' uniq = os.path.basename(tmp_file.name).split(self.colon)[0] dest = os.path.join(self._path, subdir, uniq + suffix) - os.rename(tmp_file.name, dest) + try: + if hasattr(os, 'link'): + os.link(tmp_file.name, dest) + os.remove(tmp_file.name) + else: + os.rename(tmp_file.name, dest) + except OSError, e: + os.remove(tmp_file.name) + if e.errno == errno.EEXIST: + raise ExternalClashError('Name clash with existing message: %s' + % dest) + else: + raise if isinstance(message, MaildirMessage): os.utime(dest, (os.path.getatime(dest), message.get_date())) return uniq @@ -364,12 +382,14 @@ def get_folder(self, folder): """Return a Maildir instance for the named folder.""" - return Maildir(os.path.join(self._path, '.' + folder), create=False) + return Maildir(os.path.join(self._path, '.' + folder), + factory=self._factory, + create=False) def add_folder(self, folder): """Create a folder and return a Maildir instance representing it.""" path = os.path.join(self._path, '.' + folder) - result = Maildir(path) + result = Maildir(path, factory=self._factory) maildirfolder_path = os.path.join(path, 'maildirfolder') if not os.path.exists(maildirfolder_path): os.close(os.open(maildirfolder_path, os.O_CREAT | os.O_WRONLY)) @@ -420,12 +440,17 @@ except OSError, e: if e.errno == errno.ENOENT: Maildir._count += 1 - return open(path, 'wb+') + try: + return _create_carefully(path) + except OSError, e: + if e.errno != errno.EEXIST: + raise else: raise - else: - raise ExternalClashError('Name clash prevented file creation: %s' % - path) + + # Fall through to here if stat succeeded or open raised EEXIST. + raise ExternalClashError('Name clash prevented file creation: %s' % + path) def _refresh(self): """Update table of contents mapping.""" @@ -560,7 +585,8 @@ new_file.close() os.remove(new_file.name) raise - new_file.close() + _sync_close(new_file) + # self._file is about to get replaced, so no need to sync. self._file.close() try: os.rename(new_file.name, self._path) @@ -575,7 +601,7 @@ self._toc = new_toc self._pending = False if self._locked: - _lock_file(new_file, dotlock=False) + _lock_file(self._file, dotlock=False) def _pre_mailbox_hook(self, f): """Called before writing the mailbox to file f.""" @@ -594,7 +620,7 @@ self.flush() if self._locked: self.unlock() - self._file.close() + self._file.close() # Sync has been done by self.flush() above. def _lookup(self, key=None): """Return (start, stop) or raise KeyError.""" @@ -784,7 +810,7 @@ if self._locked: _unlock_file(f) finally: - f.close() + _sync_close(f) return new_key def remove(self, key): @@ -831,7 +857,7 @@ if self._locked: _unlock_file(f) finally: - f.close() + _sync_close(f) def get_message(self, key): """Return a Message representation or raise a KeyError.""" @@ -918,7 +944,7 @@ """Unlock the mailbox if it is locked.""" if self._locked: _unlock_file(self._file) - self._file.close() + _sync_close(self._file) del self._file self._locked = False @@ -941,11 +967,13 @@ def get_folder(self, folder): """Return an MH instance for the named folder.""" - return MH(os.path.join(self._path, folder), create=False) + return MH(os.path.join(self._path, folder), + factory=self._factory, create=False) def add_folder(self, folder): """Create a folder and return an MH instance representing it.""" - return MH(os.path.join(self._path, folder)) + return MH(os.path.join(self._path, folder), + factory=self._factory) def remove_folder(self, folder): """Delete the named folder, which must be empty.""" @@ -1013,7 +1041,7 @@ else: f.write('\n') finally: - f.close() + _sync_close(f) def pack(self): """Re-name messages to eliminate numbering gaps. Invalidates keys.""" @@ -1023,27 +1051,13 @@ for key in self.iterkeys(): if key - 1 != prev: changes.append((key, prev + 1)) - f = open(os.path.join(self._path, str(key)), 'r+') - try: - if self._locked: - _lock_file(f) - try: - if hasattr(os, 'link'): - os.link(os.path.join(self._path, str(key)), - os.path.join(self._path, str(prev + 1))) - if sys.platform == 'os2emx': - # cannot unlink an open file on OS/2 - f.close() - os.unlink(os.path.join(self._path, str(key))) - else: - f.close() - os.rename(os.path.join(self._path, str(key)), - os.path.join(self._path, str(prev + 1))) - finally: - if self._locked: - _unlock_file(f) - finally: - f.close() + if hasattr(os, 'link'): + os.link(os.path.join(self._path, str(key)), + os.path.join(self._path, str(prev + 1))) + os.unlink(os.path.join(self._path, str(key))) + else: + os.rename(os.path.join(self._path, str(key)), + os.path.join(self._path, str(prev + 1))) prev += 1 self._next_key = prev + 1 if len(changes) == 0: @@ -1867,6 +1881,15 @@ socket.gethostname(), os.getpid())) +def _sync_flush(f): + """Ensure changes to file f are physically on disk.""" + f.flush() + os.fsync(f.fileno()) + +def _sync_close(f): + """Close file f, ensuring all changes are physically on disk.""" + _sync_flush(f) + f.close() ## Start: classes from the original module (for backward compatibility). Modified: python/branches/p3yk-noslice/Lib/modulefinder.py ============================================================================== --- python/branches/p3yk-noslice/Lib/modulefinder.py (original) +++ python/branches/p3yk-noslice/Lib/modulefinder.py Fri Dec 15 05:21:50 2006 @@ -1,13 +1,14 @@ """Find modules used by a script, using introspection.""" - # This module should be kept compatible with Python 2.2, see PEP 291. +from __future__ import generators import dis import imp import marshal import os import sys import new +import struct if hasattr(sys.__stdout__, "newlines"): READ_MODE = "U" # universal line endings @@ -15,11 +16,12 @@ # remain compatible with Python < 2.3 READ_MODE = "r" -LOAD_CONST = dis.opname.index('LOAD_CONST') -IMPORT_NAME = dis.opname.index('IMPORT_NAME') -STORE_NAME = dis.opname.index('STORE_NAME') -STORE_GLOBAL = dis.opname.index('STORE_GLOBAL') +LOAD_CONST = chr(dis.opname.index('LOAD_CONST')) +IMPORT_NAME = chr(dis.opname.index('IMPORT_NAME')) +STORE_NAME = chr(dis.opname.index('STORE_NAME')) +STORE_GLOBAL = chr(dis.opname.index('STORE_GLOBAL')) STORE_OPS = [STORE_NAME, STORE_GLOBAL] +HAVE_ARGUMENT = chr(dis.HAVE_ARGUMENT) # Modulefinder does a good job at simulating Python's, but it can not # handle __path__ modifications packages make at runtime. Therefore there @@ -118,9 +120,9 @@ stuff = (ext, "r", imp.PY_SOURCE) self.load_module(name, fp, pathname, stuff) - def import_hook(self, name, caller=None, fromlist=None): - self.msg(3, "import_hook", name, caller, fromlist) - parent = self.determine_parent(caller) + def import_hook(self, name, caller=None, fromlist=None, level=-1): + self.msg(3, "import_hook", name, caller, fromlist, level) + parent = self.determine_parent(caller, level=level) q, tail = self.find_head_package(parent, name) m = self.load_tail(q, tail) if not fromlist: @@ -129,12 +131,26 @@ self.ensure_fromlist(m, fromlist) return None - def determine_parent(self, caller): - self.msgin(4, "determine_parent", caller) - if not caller: + def determine_parent(self, caller, level=-1): + self.msgin(4, "determine_parent", caller, level) + if not caller or level == 0: self.msgout(4, "determine_parent -> None") return None pname = caller.__name__ + if level >= 1: # relative import + if caller.__path__: + level -= 1 + if level == 0: + parent = self.modules[pname] + assert parent is caller + self.msgout(4, "determine_parent ->", parent) + return parent + if pname.count(".") < level: + raise ImportError, "relative importpath too deep" + pname = ".".join(pname.split(".")[:-level]) + parent = self.modules[pname] + self.msgout(4, "determine_parent ->", parent) + return parent if caller.__path__: parent = self.modules[pname] assert caller is parent @@ -294,13 +310,13 @@ self.badmodules[name] = {} self.badmodules[name][caller.__name__] = 1 - def _safe_import_hook(self, name, caller, fromlist): + def _safe_import_hook(self, name, caller, fromlist, level=-1): # wrapper for self.import_hook() that won't raise ImportError if name in self.badmodules: self._add_badmodule(name, caller) return try: - self.import_hook(name, caller) + self.import_hook(name, caller, level=level) except ImportError, msg: self.msg(2, "ImportError:", str(msg)) self._add_badmodule(name, caller) @@ -311,38 +327,83 @@ self._add_badmodule(sub, caller) continue try: - self.import_hook(name, caller, [sub]) + self.import_hook(name, caller, [sub], level=level) except ImportError, msg: self.msg(2, "ImportError:", str(msg)) fullname = name + "." + sub self._add_badmodule(fullname, caller) + def scan_opcodes(self, co, + unpack = struct.unpack): + # Scan the code, and yield 'interesting' opcode combinations + # Version for Python 2.4 and older + code = co.co_code + names = co.co_names + consts = co.co_consts + while code: + c = code[0] + if c in STORE_OPS: + oparg, = unpack('= HAVE_ARGUMENT: + code = code[3:] + else: + code = code[1:] + + def scan_opcodes_25(self, co, + unpack = struct.unpack): + # Scan the code, and yield 'interesting' opcode combinations + # Python 2.5 version (has absolute and relative imports) + code = co.co_code + names = co.co_names + consts = co.co_consts + LOAD_LOAD_AND_IMPORT = LOAD_CONST + LOAD_CONST + IMPORT_NAME + while code: + c = code[0] + if c in STORE_OPS: + oparg, = unpack('= HAVE_ARGUMENT: + code = code[3:] + else: + code = code[1:] + def scan_code(self, co, m): code = co.co_code - n = len(code) - i = 0 - fromlist = None - while i < n: - c = code[i] - i = i+1 - op = ord(c) - if op >= dis.HAVE_ARGUMENT: - oparg = ord(code[i]) + ord(code[i+1])*256 - i = i+2 - if op == LOAD_CONST: - # An IMPORT_NAME is always preceded by a LOAD_CONST, it's - # a tuple of "from" names, or None for a regular import. - # The tuple may contain "*" for "from import *" - fromlist = co.co_consts[oparg] - elif op == IMPORT_NAME: - assert fromlist is None or type(fromlist) is tuple - name = co.co_names[oparg] + if sys.version_info >= (2, 5): + scanner = self.scan_opcodes_25 + else: + scanner = self.scan_opcodes + for what, args in scanner(co): + if what == "store": + name, = args + m.globalnames[name] = 1 + elif what == "absolute_import": + fromlist, name = args have_star = 0 if fromlist is not None: if "*" in fromlist: have_star = 1 fromlist = [f for f in fromlist if f != "*"] - self._safe_import_hook(name, m, fromlist) + self._safe_import_hook(name, m, fromlist, level=0) if have_star: # We've encountered an "import *". If it is a Python module, # the code has already been parsed and we can suck out the @@ -362,10 +423,17 @@ m.starimports[name] = 1 else: m.starimports[name] = 1 - elif op in STORE_OPS: - # keep track of all global names that are assigned to - name = co.co_names[oparg] - m.globalnames[name] = 1 + elif what == "relative_import": + level, fromlist, name = args + if name: + self._safe_import_hook(name, m, fromlist, level=level) + else: + parent = self.determine_parent(m, level=level) + self._safe_import_hook(parent.__name__, None, fromlist, level=0) + else: + # We don't expect anything else from the generator. + raise RuntimeError(what) + for c in co.co_consts: if isinstance(c, type(co)): self.scan_code(c, m) Modified: python/branches/p3yk-noslice/Lib/ntpath.py ============================================================================== --- python/branches/p3yk-noslice/Lib/ntpath.py (original) +++ python/branches/p3yk-noslice/Lib/ntpath.py Fri Dec 15 05:21:50 2006 @@ -8,6 +8,7 @@ import os import stat import sys +from genericpath import * __all__ = ["normcase","isabs","join","splitdrive","split","splitext", "basename","dirname","commonprefix","getsize","getmtime", @@ -206,86 +207,18 @@ """Returns the directory component of a pathname""" return split(p)[0] - -# Return the longest prefix of all list elements. - -def commonprefix(m): - "Given a list of pathnames, returns the longest common leading component" - if not m: return '' - s1 = min(m) - s2 = max(m) - n = min(len(s1), len(s2)) - for i in xrange(n): - if s1[i] != s2[i]: - return s1[:i] - return s1[:n] - - -# Get size, mtime, atime of files. - -def getsize(filename): - """Return the size of a file, reported by os.stat()""" - return os.stat(filename).st_size - -def getmtime(filename): - """Return the last modification time of a file, reported by os.stat()""" - return os.stat(filename).st_mtime - -def getatime(filename): - """Return the last access time of a file, reported by os.stat()""" - return os.stat(filename).st_atime - -def getctime(filename): - """Return the creation time of a file, reported by os.stat().""" - return os.stat(filename).st_ctime - # Is a path a symbolic link? # This will always return false on systems where posix.lstat doesn't exist. def islink(path): - """Test for symbolic link. On WindowsNT/95 always returns false""" + """Test for symbolic link. + On WindowsNT/95 and OS/2 always returns false + """ return False - -# Does a path exist? - -def exists(path): - """Test whether a path exists""" - try: - st = os.stat(path) - except os.error: - return False - return True - +# alias exists to lexists lexists = exists - -# Is a path a dos directory? -# This follows symbolic links, so both islink() and isdir() can be true -# for the same path. - -def isdir(path): - """Test whether a path is a directory""" - try: - st = os.stat(path) - except os.error: - return False - return stat.S_ISDIR(st.st_mode) - - -# Is a path a regular file? -# This follows symbolic links, so both islink() and isdir() can be true -# for the same path. - -def isfile(path): - """Test whether a path is a regular file""" - try: - st = os.stat(path) - except os.error: - return False - return stat.S_ISREG(st.st_mode) - - # Is a path a mount point? Either a root (with or without drive letter) # or an UNC path with at most a / or \ after the mount point. Modified: python/branches/p3yk-noslice/Lib/opcode.py ============================================================================== --- python/branches/p3yk-noslice/Lib/opcode.py (original) +++ python/branches/p3yk-noslice/Lib/opcode.py Fri Dec 15 05:21:50 2006 @@ -54,7 +54,6 @@ def_op('UNARY_POSITIVE', 10) def_op('UNARY_NEGATIVE', 11) def_op('UNARY_NOT', 12) -def_op('UNARY_CONVERT', 13) def_op('UNARY_INVERT', 15) @@ -101,7 +100,6 @@ def_op('LOAD_LOCALS', 82) def_op('RETURN_VALUE', 83) def_op('IMPORT_STAR', 84) -def_op('EXEC_STMT', 85) def_op('YIELD_VALUE', 86) def_op('POP_BLOCK', 87) def_op('END_FINALLY', 88) @@ -124,12 +122,13 @@ name_op('LOAD_NAME', 101) # Index in name list def_op('BUILD_TUPLE', 102) # Number of tuple items def_op('BUILD_LIST', 103) # Number of list items -def_op('BUILD_MAP', 104) # Always zero for now -name_op('LOAD_ATTR', 105) # Index in name list -def_op('COMPARE_OP', 106) # Comparison operator -hascompare.append(106) -name_op('IMPORT_NAME', 107) # Index in name list -name_op('IMPORT_FROM', 108) # Index in name list +def_op('BUILD_SET', 104) # Number of set items +def_op('BUILD_MAP', 105) # Always zero for now +name_op('LOAD_ATTR', 106) # Index in name list +def_op('COMPARE_OP', 107) # Comparison operator +hascompare.append(107) +name_op('IMPORT_NAME', 108) # Index in name list +name_op('IMPORT_FROM', 109) # Index in name list jrel_op('JUMP_FORWARD', 110) # Number of bytes to skip jrel_op('JUMP_IF_FALSE', 111) # "" Modified: python/branches/p3yk-noslice/Lib/optparse.py ============================================================================== --- python/branches/p3yk-noslice/Lib/optparse.py (original) +++ python/branches/p3yk-noslice/Lib/optparse.py Fri Dec 15 05:21:50 2006 @@ -838,13 +838,13 @@ __repr__ = _repr - def __cmp__(self, other): + def __eq__(self, other): if isinstance(other, Values): - return cmp(self.__dict__, other.__dict__) + return self.__dict__ == other.__dict__ elif isinstance(other, types.DictType): - return cmp(self.__dict__, other) + return self.__dict__ == other else: - return -1 + return NotImplemented def _update_careful(self, dict): """ Modified: python/branches/p3yk-noslice/Lib/os.py ============================================================================== --- python/branches/p3yk-noslice/Lib/os.py (original) +++ python/branches/p3yk-noslice/Lib/os.py Fri Dec 15 05:21:50 2006 @@ -156,11 +156,17 @@ recursive. """ + from errno import EEXIST head, tail = path.split(name) if not tail: head, tail = path.split(head) if head and tail and not path.exists(head): - makedirs(head, mode) + try: + makedirs(head, mode) + except OSError, e: + # be happy if someone already created the path + if e.errno != EEXIST: + raise if tail == curdir: # xxx/newdir/. exists if xxx/newdir exists return mkdir(name, mode) Modified: python/branches/p3yk-noslice/Lib/os2emxpath.py ============================================================================== --- python/branches/p3yk-noslice/Lib/os2emxpath.py (original) +++ python/branches/p3yk-noslice/Lib/os2emxpath.py Fri Dec 15 05:21:50 2006 @@ -7,6 +7,9 @@ import os import stat +from genericpath import * +from ntpath import (expanduser, expandvars, isabs, islink, splitdrive, + splitext, split, walk) __all__ = ["normcase","isabs","join","splitdrive","split","splitext", "basename","dirname","commonprefix","getsize","getmtime", @@ -36,18 +39,6 @@ return s.replace('\\', '/').lower() -# Return whether a path is absolute. -# Trivial in Posix, harder on the Mac or MS-DOS. -# For DOS it is absolute if it starts with a slash or backslash (current -# volume), or if a pathname after the volume letter and colon / UNC resource -# starts with a slash or backslash. - -def isabs(s): - """Test whether a path is absolute""" - s = splitdrive(s)[1] - return s != '' and s[:1] in '/\\' - - # Join two (or more) paths. def join(a, *p): @@ -63,17 +54,6 @@ return path -# Split a path in a drive specification (a drive letter followed by a -# colon) and the path specification. -# It is always true that drivespec + pathspec == p -def splitdrive(p): - """Split a pathname into drive and path specifiers. Returns a 2-tuple -"(drive,path)"; either part may be empty""" - if p[1:2] == ':': - return p[0:2], p[2:] - return '', p - - # Parse UNC paths def splitunc(p): """Split a pathname into UNC mount point and relative path specifiers. @@ -103,57 +83,6 @@ return '', p -# Split a path in head (everything up to the last '/') and tail (the -# rest). After the trailing '/' is stripped, the invariant -# join(head, tail) == p holds. -# The resulting head won't end in '/' unless it is the root. - -def split(p): - """Split a pathname. - - Return tuple (head, tail) where tail is everything after the final slash. - Either part may be empty.""" - - d, p = splitdrive(p) - # set i to index beyond p's last slash - i = len(p) - while i and p[i-1] not in '/\\': - i = i - 1 - head, tail = p[:i], p[i:] # now tail has no slashes - # remove trailing slashes from head, unless it's all slashes - head2 = head - while head2 and head2[-1] in '/\\': - head2 = head2[:-1] - head = head2 or head - return d + head, tail - - -# Split a path in root and extension. -# The extension is everything starting at the last dot in the last -# pathname component; the root is everything before that. -# It is always true that root + ext == p. - -def splitext(p): - """Split the extension from a pathname. - - Extension is everything from the last dot to the end. - Return (root, ext), either part may be empty.""" - root, ext = '', '' - for c in p: - if c in ['/','\\']: - root, ext = root + ext + c, '' - elif c == '.': - if ext: - root, ext = root + ext, c - else: - ext = c - elif ext: - ext = ext + c - else: - root = root + c - return root, ext - - # Return the tail (basename) part of a path. def basename(p): @@ -168,84 +97,12 @@ return split(p)[0] -# Return the longest prefix of all list elements. - -def commonprefix(m): - "Given a list of pathnames, returns the longest common leading component" - if not m: return '' - s1 = min(m) - s2 = max(m) - n = min(len(s1), len(s2)) - for i in xrange(n): - if s1[i] != s2[i]: - return s1[:i] - return s1[:n] - - -# Get size, mtime, atime of files. - -def getsize(filename): - """Return the size of a file, reported by os.stat()""" - return os.stat(filename).st_size - -def getmtime(filename): - """Return the last modification time of a file, reported by os.stat()""" - return os.stat(filename).st_mtime - -def getatime(filename): - """Return the last access time of a file, reported by os.stat()""" - return os.stat(filename).st_atime - -def getctime(filename): - """Return the creation time of a file, reported by os.stat().""" - return os.stat(filename).st_ctime - -# Is a path a symbolic link? -# This will always return false on systems where posix.lstat doesn't exist. - -def islink(path): - """Test for symbolic link. On OS/2 always returns false""" - return False - - -# Does a path exist? -# This is false for dangling symbolic links. - -def exists(path): - """Test whether a path exists""" - try: - st = os.stat(path) - except os.error: - return False - return True - +# alias exists to lexists lexists = exists # Is a path a directory? -def isdir(path): - """Test whether a path is a directory""" - try: - st = os.stat(path) - except os.error: - return False - return stat.S_ISDIR(st.st_mode) - - -# Is a path a regular file? -# This follows symbolic links, so both islink() and isdir() can be true -# for the same path. - -def isfile(path): - """Test whether a path is a regular file""" - try: - st = os.stat(path) - except os.error: - return False - return stat.S_ISREG(st.st_mode) - - # Is a path a mount point? Either a root (with or without drive letter) # or an UNC path with at most a / or \ after the mount point. @@ -258,131 +115,6 @@ return len(p) == 1 and p[0] in '/\\' -# Directory tree walk. -# For each directory under top (including top itself, but excluding -# '.' and '..'), func(arg, dirname, filenames) is called, where -# dirname is the name of the directory and filenames is the list -# of files (and subdirectories etc.) in the directory. -# The func may modify the filenames list, to implement a filter, -# or to impose a different order of visiting. - -def walk(top, func, arg): - """Directory tree walk whth callback function. - - walk(top, func, arg) calls func(arg, d, files) for each directory d - in the tree rooted at top (including top itself); files is a list - of all the files and subdirs in directory d.""" - try: - names = os.listdir(top) - except os.error: - return - func(arg, top, names) - exceptions = ('.', '..') - for name in names: - if name not in exceptions: - name = join(top, name) - if isdir(name): - walk(name, func, arg) - - -# Expand paths beginning with '~' or '~user'. -# '~' means $HOME; '~user' means that user's home directory. -# If the path doesn't begin with '~', or if the user or $HOME is unknown, -# the path is returned unchanged (leaving error reporting to whatever -# function is called with the expanded path as argument). -# See also module 'glob' for expansion of *, ? and [...] in pathnames. -# (A function should also be defined to do full *sh-style environment -# variable expansion.) - -def expanduser(path): - """Expand ~ and ~user constructs. - - If user or $HOME is unknown, do nothing.""" - if path[:1] != '~': - return path - i, n = 1, len(path) - while i < n and path[i] not in '/\\': - i = i + 1 - if i == 1: - if 'HOME' in os.environ: - userhome = os.environ['HOME'] - elif not 'HOMEPATH' in os.environ: - return path - else: - try: - drive = os.environ['HOMEDRIVE'] - except KeyError: - drive = '' - userhome = join(drive, os.environ['HOMEPATH']) - else: - return path - return userhome + path[i:] - - -# Expand paths containing shell variable substitutions. -# The following rules apply: -# - no expansion within single quotes -# - no escape character, except for '$$' which is translated into '$' -# - ${varname} is accepted. -# - varnames can be made out of letters, digits and the character '_' -# XXX With COMMAND.COM you can use any characters in a variable name, -# XXX except '^|<>='. - -def expandvars(path): - """Expand shell variables of form $var and ${var}. - - Unknown variables are left unchanged.""" - if '$' not in path: - return path - import string - varchars = string.letters + string.digits + '_-' - res = '' - index = 0 - pathlen = len(path) - while index < pathlen: - c = path[index] - if c == '\'': # no expansion within single quotes - path = path[index + 1:] - pathlen = len(path) - try: - index = path.index('\'') - res = res + '\'' + path[:index + 1] - except ValueError: - res = res + path - index = pathlen - 1 - elif c == '$': # variable or '$$' - if path[index + 1:index + 2] == '$': - res = res + c - index = index + 1 - elif path[index + 1:index + 2] == '{': - path = path[index+2:] - pathlen = len(path) - try: - index = path.index('}') - var = path[:index] - if var in os.environ: - res = res + os.environ[var] - except ValueError: - res = res + path - index = pathlen - 1 - else: - var = '' - index = index + 1 - c = path[index:index + 1] - while c != '' and c in varchars: - var = var + c - index = index + 1 - c = path[index:index + 1] - if var in os.environ: - res = res + os.environ[var] - if c != '': - res = res + c - else: - res = res + c - index = index + 1 - return res - - # Normalize a path, e.g. A//B, A/./B and A/foo/../B all become A/B. def normpath(path): Modified: python/branches/p3yk-noslice/Lib/pdb.py ============================================================================== --- python/branches/p3yk-noslice/Lib/pdb.py (original) +++ python/branches/p3yk-noslice/Lib/pdb.py Fri Dec 15 05:21:50 2006 @@ -28,7 +28,7 @@ return sys.stdin.readline() def find_function(funcname, filename): - cre = re.compile(r'def\s+%s\s*[(]' % funcname) + cre = re.compile(r'def\s+%s\s*[(]' % re.escape(funcname)) try: fp = open(filename) except IOError: @@ -198,7 +198,7 @@ globals = self.curframe.f_globals try: code = compile(line + '\n', '', 'single') - exec code in globals, locals + exec(code, globals, locals) except: t, v = sys.exc_info()[:2] if type(t) == type(''): Modified: python/branches/p3yk-noslice/Lib/plat-irix5/flp.py ============================================================================== --- python/branches/p3yk-noslice/Lib/plat-irix5/flp.py (original) +++ python/branches/p3yk-noslice/Lib/plat-irix5/flp.py Fri Dec 15 05:21:50 2006 @@ -329,7 +329,7 @@ # def create_full_form(inst, (fdata, odatalist)): form = create_form(fdata) - exec 'inst.'+fdata.Name+' = form\n' + exec('inst.'+fdata.Name+' = form\n') for odata in odatalist: create_object_instance(inst, form, odata) @@ -338,7 +338,7 @@ # variable. # def merge_full_form(inst, form, (fdata, odatalist)): - exec 'inst.'+fdata.Name+' = form\n' + exec('inst.'+fdata.Name+' = form\n') if odatalist[0].Class != FL.BOX: raise error, 'merge_full_form() expects FL.BOX as first obj' for odata in odatalist[1:]: @@ -374,7 +374,7 @@ cbfunc = eval('inst.'+odata.Callback) obj.set_call_back(cbfunc, odata.Argument) if odata.Name: - exec 'inst.' + odata.Name + ' = obj\n' + exec('inst.' + odata.Name + ' = obj\n') # # Internal _create_object: Create the object and fill options # Modified: python/branches/p3yk-noslice/Lib/plat-irix5/panel.py ============================================================================== --- python/branches/p3yk-noslice/Lib/plat-irix5/panel.py (original) +++ python/branches/p3yk-noslice/Lib/plat-irix5/panel.py Fri Dec 15 05:21:50 2006 @@ -130,7 +130,7 @@ stmt = lhs + '=' + repr(value) if debug: print 'exec', stmt try: - exec stmt + '\n' + exec(stmt + '\n') except KeyboardInterrupt: # Don't catch this! raise KeyboardInterrupt except: @@ -186,7 +186,7 @@ if name: stmt = 'panel.' + name + ' = act' if debug: print 'exec', stmt - exec stmt + '\n' + exec(stmt + '\n') if is_endgroup(a): panel.endgroup() sub_al = getattrlist(a, 'al') @@ -236,7 +236,7 @@ act.addact(panel) if name: stmt = 'panel.' + name + ' = act' - exec stmt + '\n' + exec(stmt + '\n') if is_endgroup(a): panel.endgroup() sub_al = getattrlist(a, 'al') Modified: python/branches/p3yk-noslice/Lib/plat-irix6/flp.py ============================================================================== --- python/branches/p3yk-noslice/Lib/plat-irix6/flp.py (original) +++ python/branches/p3yk-noslice/Lib/plat-irix6/flp.py Fri Dec 15 05:21:50 2006 @@ -328,7 +328,7 @@ # def create_full_form(inst, (fdata, odatalist)): form = create_form(fdata) - exec 'inst.'+fdata.Name+' = form\n' + exec('inst.'+fdata.Name+' = form\n') for odata in odatalist: create_object_instance(inst, form, odata) @@ -337,7 +337,7 @@ # variable. # def merge_full_form(inst, form, (fdata, odatalist)): - exec 'inst.'+fdata.Name+' = form\n' + exec('inst.'+fdata.Name+' = form\n') if odatalist[0].Class != FL.BOX: raise error, 'merge_full_form() expects FL.BOX as first obj' for odata in odatalist[1:]: @@ -373,7 +373,7 @@ cbfunc = eval('inst.'+odata.Callback) obj.set_call_back(cbfunc, odata.Argument) if odata.Name: - exec 'inst.' + odata.Name + ' = obj\n' + exec('inst.' + odata.Name + ' = obj\n') # # Internal _create_object: Create the object and fill options # Modified: python/branches/p3yk-noslice/Lib/plat-irix6/panel.py ============================================================================== --- python/branches/p3yk-noslice/Lib/plat-irix6/panel.py (original) +++ python/branches/p3yk-noslice/Lib/plat-irix6/panel.py Fri Dec 15 05:21:50 2006 @@ -130,7 +130,7 @@ stmt = lhs + '=' + repr(value) if debug: print 'exec', stmt try: - exec stmt + '\n' + exec(stmt + '\n') except KeyboardInterrupt: # Don't catch this! raise KeyboardInterrupt except: @@ -186,7 +186,7 @@ if name: stmt = 'panel.' + name + ' = act' if debug: print 'exec', stmt - exec stmt + '\n' + exec(stmt + '\n') if is_endgroup(a): panel.endgroup() sub_al = getattrlist(a, 'al') @@ -236,7 +236,7 @@ act.addact(panel) if name: stmt = 'panel.' + name + ' = act' - exec stmt + '\n' + exec(stmt + '\n') if is_endgroup(a): panel.endgroup() sub_al = getattrlist(a, 'al') Modified: python/branches/p3yk-noslice/Lib/plat-mac/FrameWork.py ============================================================================== --- python/branches/p3yk-noslice/Lib/plat-mac/FrameWork.py (original) +++ python/branches/p3yk-noslice/Lib/plat-mac/FrameWork.py Fri Dec 15 05:21:50 2006 @@ -602,7 +602,7 @@ def dispatch(self, id, item, window, event): title, shortcut, callback, mtype = self.items[item-1] if callback: - if not self.bar.parent or type(callback) <> types.StringType: + if not self.bar.parent or not isinstance(callback, str): menuhandler = callback else: # callback is string @@ -748,7 +748,7 @@ self.parent = parent def open(self, bounds=(40, 40, 400, 400), resid=None): - if resid <> None: + if resid is not None: self.wid = GetNewWindow(resid, -1) else: self.wid = NewWindow(bounds, self.__class__.__name__, 1, @@ -826,7 +826,7 @@ # If we're not frontmost, select ourselves and wait for # the activate event. # - if MyFrontWindow() <> window: + if MyFrontWindow() != window: window.SelectWindow() return # We are. Handle the event. @@ -875,7 +875,7 @@ if DEBUG: print "control hit in", window, "on", control, "; pcode =", pcode def do_inContent(self, partcode, window, event): - if MyFrontWindow() <> window: + if MyFrontWindow() != window: window.SelectWindow() return (what, message, when, where, modifiers) = event Modified: python/branches/p3yk-noslice/Lib/plat-mac/aetypes.py ============================================================================== --- python/branches/p3yk-noslice/Lib/plat-mac/aetypes.py (original) +++ python/branches/p3yk-noslice/Lib/plat-mac/aetypes.py Fri Dec 15 05:21:50 2006 @@ -128,7 +128,7 @@ self.keyword = "%-4.4s" % str(keyword) def __repr__(self): - return "Keyword(%r)" % `self.keyword` + return "Keyword(%r)" % self.keyword def __str__(self): return string.strip(self.keyword) @@ -557,12 +557,12 @@ class %s(ComponentItem): want = '%s' """ -exec template % ("Text", 'text') -exec template % ("Character", 'cha ') -exec template % ("Word", 'cwor') -exec template % ("Line", 'clin') -exec template % ("paragraph", 'cpar') -exec template % ("Window", 'cwin') -exec template % ("Document", 'docu') -exec template % ("File", 'file') -exec template % ("InsertionPoint", 'cins') +exec(template % ("Text", 'text')) +exec(template % ("Character", 'cha ')) +exec(template % ("Word", 'cwor')) +exec(template % ("Line", 'clin')) +exec(template % ("paragraph", 'cpar')) +exec(template % ("Window", 'cwin')) +exec(template % ("Document", 'docu')) +exec(template % ("File", 'file')) +exec(template % ("InsertionPoint", 'cins')) Modified: python/branches/p3yk-noslice/Lib/plat-mac/appletrawmain.py ============================================================================== --- python/branches/p3yk-noslice/Lib/plat-mac/appletrawmain.py (original) +++ python/branches/p3yk-noslice/Lib/plat-mac/appletrawmain.py Fri Dec 15 05:21:50 2006 @@ -57,7 +57,7 @@ # funny) and go. # del argvemulator, os, sys, marshal, _dir, _fp - exec __code__ + exec(__code__) else: sys.stderr.write("%s: neither __main__.py nor __main__.pyc found\n"%sys.argv[0]) sys.exit(1) Modified: python/branches/p3yk-noslice/Lib/plat-mac/buildtools.py ============================================================================== --- python/branches/p3yk-noslice/Lib/plat-mac/buildtools.py (original) +++ python/branches/p3yk-noslice/Lib/plat-mac/buildtools.py Fri Dec 15 05:21:50 2006 @@ -192,7 +192,7 @@ 'icl8', 'ics4', 'ics8', 'ICN#', 'ics#'] if not copy_codefragment: skiptypes.append('cfrg') -## skipowner = (ownertype <> None) +## skipowner = (ownertype != None) # Copy the resources from the template Modified: python/branches/p3yk-noslice/Lib/plat-mac/cfmfile.py ============================================================================== --- python/branches/p3yk-noslice/Lib/plat-mac/cfmfile.py (original) +++ python/branches/p3yk-noslice/Lib/plat-mac/cfmfile.py Fri Dec 15 05:21:50 2006 @@ -73,7 +73,7 @@ Res.CloseResFile(resref) Res.UseResFile(currentresref) self.parse(data) - if self.version <> 1: + if self.version != 1: raise error, "unknown 'cfrg' resource format" def parse(self, data): @@ -143,7 +143,7 @@ return data def getfragment(self): - if self.where <> 1: + if self.where != 1: raise error, "can't read fragment, unsupported location" f = open(self.path, "rb") f.seek(self.offset) @@ -155,7 +155,7 @@ return frag def copydata(self, outfile): - if self.where <> 1: + if self.where != 1: raise error, "can't read fragment, unsupported location" infile = open(self.path, "rb") if self.length == 0: Modified: python/branches/p3yk-noslice/Lib/plat-mac/gensuitemodule.py ============================================================================== --- python/branches/p3yk-noslice/Lib/plat-mac/gensuitemodule.py (original) +++ python/branches/p3yk-noslice/Lib/plat-mac/gensuitemodule.py Fri Dec 15 05:21:50 2006 @@ -169,7 +169,7 @@ aete = decode(data, verbose) aetelist.append((aete, res.GetResInfo())) finally: - if rf <> cur: + if rf != cur: CloseResFile(rf) UseResFile(cur) # switch back (needed for dialogs in Python) @@ -332,7 +332,7 @@ def getalign(f): if f.tell() & 1: c = f.read(1) - ##if c <> '\0': + ##if c != '\0': ## print align:', repr(c) def getlist(f, description, getitem): @@ -779,7 +779,7 @@ if is_enum(a[2]): kname = a[1] ename = a[2][0] - if ename <> '****': + if ename != '****': fp.write(" aetools.enumsubst(_arguments, %r, _Enum_%s)\n" % (kname, identify(ename))) self.enumsneeded[ename] = 1 @@ -810,7 +810,7 @@ for a in arguments: if is_enum(a[2]): ename = a[2][0] - if ename <> '****': + if ename != '****': self.enumsneeded[ename] = 1 # Modified: python/branches/p3yk-noslice/Lib/plat-mac/lib-scriptpackages/StdSuites/AppleScript_Suite.py ============================================================================== --- python/branches/p3yk-noslice/Lib/plat-mac/lib-scriptpackages/StdSuites/AppleScript_Suite.py (original) +++ python/branches/p3yk-noslice/Lib/plat-mac/lib-scriptpackages/StdSuites/AppleScript_Suite.py Fri Dec 15 05:21:50 2006 @@ -301,7 +301,7 @@ return _arguments['----'] def as_(self, _object, _attributes={}, **_arguments): - """as_: Coercion + """as: Coercion Required argument: an AE object reference Keyword argument _attributes: AppleEvent attribute dictionary Returns: anything Modified: python/branches/p3yk-noslice/Lib/plat-mac/macerrors.py ============================================================================== --- python/branches/p3yk-noslice/Lib/plat-mac/macerrors.py (original) +++ python/branches/p3yk-noslice/Lib/plat-mac/macerrors.py Fri Dec 15 05:21:50 2006 @@ -1574,7 +1574,7 @@ smFHBlockRdErr = -310 #Error occurred during _sGetFHeader. smBLFieldBad = -309 #ByteLanes field was bad. smUnExBusErr = -308 #Unexpected BusError -smResrvErr = -307 #Fatal reserved error. Resreved field <> 0. +smResrvErr = -307 #Fatal reserved error. Resreved field != 0. smNosInfoArray = -306 #No sInfoArray. Memory Mgr error. smDisabledSlot = -305 #This slot is disabled (-305 use to be smLWTstBad) smNoDir = -304 #Directory offset is Nil Modified: python/branches/p3yk-noslice/Lib/plat-mac/pimp.py ============================================================================== --- python/branches/p3yk-noslice/Lib/plat-mac/pimp.py (original) +++ python/branches/p3yk-noslice/Lib/plat-mac/pimp.py Fri Dec 15 05:21:50 2006 @@ -588,7 +588,7 @@ } installTest = self._dict['Install-test'].strip() + '\n' try: - exec installTest in namespace + exec(installTest, namespace) except ImportError, arg: return "no", str(arg) except _scriptExc_NotInstalled, arg: @@ -757,7 +757,7 @@ if line[0] == '#': continue if line[:6] == 'import': - exec line + exec(line) continue if line[-1] == '\n': line = line[:-1] Modified: python/branches/p3yk-noslice/Lib/plat-mac/plistlib.py ============================================================================== --- python/branches/p3yk-noslice/Lib/plat-mac/plistlib.py (original) +++ python/branches/p3yk-noslice/Lib/plat-mac/plistlib.py Fri Dec 15 05:21:50 2006 @@ -374,13 +374,13 @@ def asBase64(self, maxlinelength=76): return _encodeBase64(self.data, maxlinelength) - def __cmp__(self, other): + def __eq__(self, other): if isinstance(other, self.__class__): - return cmp(self.data, other.data) + return self.data == other.data elif isinstance(other, str): - return cmp(self.data, other) + return self.data == other else: - return cmp(id(self), id(other)) + return id(self) == id(other) def __repr__(self): return "%s(%s)" % (self.__class__.__name__, repr(self.data)) Modified: python/branches/p3yk-noslice/Lib/plat-riscos/riscosenviron.py ============================================================================== --- python/branches/p3yk-noslice/Lib/plat-riscos/riscosenviron.py (original) +++ python/branches/p3yk-noslice/Lib/plat-riscos/riscosenviron.py Fri Dec 15 05:21:50 2006 @@ -13,7 +13,7 @@ return len(riscos.getenvdict()) def __getitem__(self, key): ret = riscos.getenv(key) - if ret<>None: + if ret != None: return ret else: raise KeyError @@ -31,7 +31,7 @@ def values(self): return riscos.getenvdict().values() def has_key(self, key): value = riscos.getenv(key) - return value<>None + return value != None def __contains__(self, key): return riscos.getenv(key) is not None def update(self, dict): @@ -39,7 +39,7 @@ riscos.putenv(k, v) def get(self, key, failobj=None): value = riscos.getenv(key) - if value<>None: + if value != None: return value else: return failobj Modified: python/branches/p3yk-noslice/Lib/plat-riscos/rourl2path.py ============================================================================== --- python/branches/p3yk-noslice/Lib/plat-riscos/rourl2path.py (original) +++ python/branches/p3yk-noslice/Lib/plat-riscos/rourl2path.py Fri Dec 15 05:21:50 2006 @@ -14,7 +14,7 @@ """OS-specific conversion from a relative URL of the 'file' scheme to a file system path; not recommended for general use.""" tp = urllib.splittype(url)[0] - if tp and tp <> 'file': + if tp and tp != 'file': raise RuntimeError, 'Cannot convert non-local URL to pathname' # Turn starting /// into /, an empty hostname means current host if url[:3] == '///': @@ -39,7 +39,7 @@ elif components[i] == '..': components[i] = '^' i += 1 - elif components[i] == '' and i > 0 and components[i-1] <> '': + elif components[i] == '' and i > 0 and components[i-1] != '': del components[i] else: i += 1 Modified: python/branches/p3yk-noslice/Lib/plat-sunos5/STROPTS.py ============================================================================== --- python/branches/p3yk-noslice/Lib/plat-sunos5/STROPTS.py (original) +++ python/branches/p3yk-noslice/Lib/plat-sunos5/STROPTS.py Fri Dec 15 05:21:50 2006 @@ -1550,7 +1550,7 @@ AS_PAGLCK = 0x80 AS_CLAIMGAP = 0x40 AS_UNMAPWAIT = 0x20 -def AS_TYPE_64BIT(as): return \ +def AS_TYPE_64BIT(as_): return \ AS_LREP_LINKEDLIST = 0 AS_LREP_SKIPLIST = 1 Modified: python/branches/p3yk-noslice/Lib/posixpath.py ============================================================================== --- python/branches/p3yk-noslice/Lib/posixpath.py (original) +++ python/branches/p3yk-noslice/Lib/posixpath.py Fri Dec 15 05:21:50 2006 @@ -12,6 +12,7 @@ import os import stat +from genericpath import * __all__ = ["normcase","isabs","join","splitdrive","split","splitext", "basename","dirname","commonprefix","getsize","getmtime", @@ -105,50 +106,24 @@ return '', p -# Return the tail (basename) part of a path. +# Return the tail (basename) part of a path, same as split(path)[1]. def basename(p): """Returns the final component of a pathname""" - return split(p)[1] + i = p.rfind('/') + 1 + return p[i:] -# Return the head (dirname) part of a path. +# Return the head (dirname) part of a path, same as split(path)[0]. def dirname(p): """Returns the directory component of a pathname""" - return split(p)[0] - - -# Return the longest prefix of all list elements. + i = p.rfind('/') + 1 + head = p[:i] + if head and head != '/'*len(head): + head = head.rstrip('/') + return head -def commonprefix(m): - "Given a list of pathnames, returns the longest common leading component" - if not m: return '' - s1 = min(m) - s2 = max(m) - n = min(len(s1), len(s2)) - for i in xrange(n): - if s1[i] != s2[i]: - return s1[:i] - return s1[:n] - -# Get size, mtime, atime of files. - -def getsize(filename): - """Return the size of a file, reported by os.stat().""" - return os.stat(filename).st_size - -def getmtime(filename): - """Return the last modification time of a file, reported by os.stat().""" - return os.stat(filename).st_mtime - -def getatime(filename): - """Return the last access time of a file, reported by os.stat().""" - return os.stat(filename).st_atime - -def getctime(filename): - """Return the metadata change time of a file, reported by os.stat().""" - return os.stat(filename).st_ctime # Is a path a symbolic link? # This will always return false on systems where os.lstat doesn't exist. @@ -161,19 +136,6 @@ return False return stat.S_ISLNK(st.st_mode) - -# Does a path exist? -# This is false for dangling symbolic links. - -def exists(path): - """Test whether a path exists. Returns False for broken symbolic links""" - try: - st = os.stat(path) - except os.error: - return False - return True - - # Being true for dangling symbolic links is also useful. def lexists(path): @@ -185,32 +147,6 @@ return True -# Is a path a directory? -# This follows symbolic links, so both islink() and isdir() can be true -# for the same path. - -def isdir(path): - """Test whether a path is a directory""" - try: - st = os.stat(path) - except os.error: - return False - return stat.S_ISDIR(st.st_mode) - - -# Is a path a regular file? -# This follows symbolic links, so both islink() and isfile() can be true -# for the same path. - -def isfile(path): - """Test whether a path is a regular file""" - try: - st = os.stat(path) - except os.error: - return False - return stat.S_ISREG(st.st_mode) - - # Are two filenames really pointing to the same file? def samefile(f1, f2): @@ -328,8 +264,7 @@ except KeyError: return path userhome = pwent.pw_dir - if userhome.endswith('/'): - i += 1 + userhome = userhome.rstrip('/') return userhome + path[i:] Modified: python/branches/p3yk-noslice/Lib/pprint.py ============================================================================== --- python/branches/p3yk-noslice/Lib/pprint.py (original) +++ python/branches/p3yk-noslice/Lib/pprint.py Fri Dec 15 05:21:50 2006 @@ -246,7 +246,12 @@ append = components.append level += 1 saferepr = _safe_repr - for k, v in sorted(object.items()): + items = object.items() + try: + items = sorted(items) + except TypeError: + items = sorted(items, key=lambda (k, v): (str(type(k)), k, v)) + for k, v in items: krepr, kreadable, krecur = saferepr(k, context, maxlevels, level) vrepr, vreadable, vrecur = saferepr(v, context, maxlevels, level) append("%s: %s" % (krepr, vrepr)) Modified: python/branches/p3yk-noslice/Lib/profile.py ============================================================================== --- python/branches/p3yk-noslice/Lib/profile.py (original) +++ python/branches/p3yk-noslice/Lib/profile.py Fri Dec 15 05:21:50 2006 @@ -459,7 +459,7 @@ self.set_cmd(cmd) sys.setprofile(self.dispatcher) try: - exec cmd in globals, locals + exec(cmd, globals, locals) finally: sys.setprofile(None) return self Modified: python/branches/p3yk-noslice/Lib/pstats.py ============================================================================== --- python/branches/p3yk-noslice/Lib/pstats.py (original) +++ python/branches/p3yk-noslice/Lib/pstats.py Fri Dec 15 05:21:50 2006 @@ -116,7 +116,7 @@ def load_stats(self, arg): if not arg: self.stats = {} - elif type(arg) == type(""): + elif isinstance(arg, basestring): f = open(arg, 'rb') self.stats = marshal.load(f) f.close() @@ -173,7 +173,7 @@ def dump_stats(self, filename): """Write the profile data to a file we know how to load back.""" - f = file(filename, 'wb') + f = open(filename, 'wb') try: marshal.dump(self.stats, f) finally: Modified: python/branches/p3yk-noslice/Lib/pty.py ============================================================================== --- python/branches/p3yk-noslice/Lib/pty.py (original) +++ python/branches/p3yk-noslice/Lib/pty.py Fri Dec 15 05:21:50 2006 @@ -118,6 +118,10 @@ if (slave_fd > STDERR_FILENO): os.close (slave_fd) + # Explicitly open the tty to make it become a controlling tty. + tmp_fd = os.open(os.ttyname(STDOUT_FILENO), os.O_RDWR) + os.close(tmp_fd) + # Parent and child process. return pid, master_fd Modified: python/branches/p3yk-noslice/Lib/pyclbr.py ============================================================================== --- python/branches/p3yk-noslice/Lib/pyclbr.py (original) +++ python/branches/p3yk-noslice/Lib/pyclbr.py Fri Dec 15 05:21:50 2006 @@ -172,7 +172,7 @@ # else it's a nested def else: # it's a function - dict[meth_name] = Function(module, meth_name, file, lineno) + dict[meth_name] = Function(fullmodule, meth_name, file, lineno) stack.append((None, thisindent)) # Marker for nested fns elif token == 'class': lineno, thisindent = start Modified: python/branches/p3yk-noslice/Lib/pydoc.py ============================================================================== --- python/branches/p3yk-noslice/Lib/pydoc.py (original) +++ python/branches/p3yk-noslice/Lib/pydoc.py Fri Dec 15 05:21:50 2006 @@ -1564,7 +1564,7 @@ 'CLASSES': ('ref/types', 'class SPECIALMETHODS PRIVATENAMES'), 'MODULES': ('lib/typesmodules', 'import'), 'PACKAGES': 'import', - 'EXPRESSIONS': ('ref/summary', 'lambda or and not in is BOOLEAN COMPARISON BITWISE SHIFTING BINARY FORMATTING POWER UNARY ATTRIBUTES SUBSCRIPTS SLICINGS CALLS TUPLES LISTS DICTIONARIES BACKQUOTES'), + 'EXPRESSIONS': ('ref/summary', 'lambda or and not in is BOOLEAN COMPARISON BITWISE SHIFTING BINARY FORMATTING POWER UNARY ATTRIBUTES SUBSCRIPTS SLICINGS CALLS TUPLES LISTS DICTIONARIES'), 'OPERATORS': 'EXPRESSIONS', 'PRECEDENCE': 'EXPRESSIONS', 'OBJECTS': ('ref/objects', 'TYPES'), @@ -1587,14 +1587,13 @@ 'IDENTIFIERS': ('ref/identifiers', 'keywords SPECIALIDENTIFIERS'), 'SPECIALIDENTIFIERS': ('ref/id-classes', ''), 'PRIVATENAMES': ('ref/atom-identifiers', ''), - 'LITERALS': ('ref/atom-literals', 'STRINGS BACKQUOTES NUMBERS TUPLELITERALS LISTLITERALS DICTIONARYLITERALS'), + 'LITERALS': ('ref/atom-literals', 'STRINGS NUMBERS TUPLELITERALS LISTLITERALS DICTIONARYLITERALS'), 'TUPLES': 'SEQUENCES', 'TUPLELITERALS': ('ref/exprlists', 'TUPLES LITERALS'), 'LISTS': ('lib/typesseq-mutable', 'LISTLITERALS'), 'LISTLITERALS': ('ref/lists', 'LISTS LITERALS'), 'DICTIONARIES': ('lib/typesmapping', 'DICTIONARYLITERALS'), 'DICTIONARYLITERALS': ('ref/dict', 'DICTIONARIES LITERALS'), - 'BACKQUOTES': ('ref/string-conversions', 'repr str STRINGS LITERALS'), 'ATTRIBUTES': ('ref/attribute-references', 'getattr hasattr setattr ATTRIBUTEMETHODS'), 'SUBSCRIPTS': ('ref/subscriptions', 'SEQUENCEMETHODS1'), 'SLICINGS': ('ref/slicings', 'SEQUENCEMETHODS2'), Modified: python/branches/p3yk-noslice/Lib/rexec.py ============================================================================== --- python/branches/p3yk-noslice/Lib/rexec.py (original) +++ python/branches/p3yk-noslice/Lib/rexec.py Fri Dec 15 05:21:50 2006 @@ -58,7 +58,7 @@ self.name = name for m in FileBase.ok_file_methods + ('close',): - exec TEMPLATE % (m, m) + exec(TEMPLATE % (m, m)) class RHooks(ihooks.Hooks): @@ -310,7 +310,7 @@ """ m = self.add_module('__main__') - exec code in m.__dict__ + exec(code, m.__dict__) def r_eval(self, code): """Evaluate code within a restricted environment. Modified: python/branches/p3yk-noslice/Lib/runpy.py ============================================================================== --- python/branches/p3yk-noslice/Lib/runpy.py (original) +++ python/branches/p3yk-noslice/Lib/runpy.py Fri Dec 15 05:21:50 2006 @@ -29,7 +29,7 @@ run_globals.update(__name__ = mod_name, __file__ = mod_fname, __loader__ = mod_loader) - exec code in run_globals + exec(code, run_globals) return run_globals def _run_module_code(code, init_globals=None, Modified: python/branches/p3yk-noslice/Lib/sgmllib.py ============================================================================== --- python/branches/p3yk-noslice/Lib/sgmllib.py (original) +++ python/branches/p3yk-noslice/Lib/sgmllib.py Fri Dec 15 05:21:50 2006 @@ -29,12 +29,7 @@ shorttagopen = re.compile('<[a-zA-Z][-.a-zA-Z0-9]*/') shorttag = re.compile('<([a-zA-Z][-.a-zA-Z0-9]*)/([^/]*)/') piclose = re.compile('>') -starttag = re.compile(r'<[a-zA-Z][-_.:a-zA-Z0-9]*\s*(' - r'\s*([a-zA-Z_][-:.a-zA-Z_0-9]*)(\s*=\s*' - r'(\'[^\']*\'|"[^"]*"|[-a-zA-Z0-9./,:;+*%?!&$\(\)_#=~@]' - r'[][\-a-zA-Z0-9./,:;+*%?!&$\(\)_#=~\'"@]*(?=[\s>/<])))?' - r')*\s*/?\s*(?=[<>])') -endtag = re.compile(r'])') +endbracket = re.compile('[<>]') tagfind = re.compile('[a-zA-Z][-_.a-zA-Z0-9]*') attrfind = re.compile( r'\s*([a-zA-Z_][-:.a-zA-Z_0-9]*)(\s*=\s*' @@ -254,10 +249,14 @@ self.finish_shorttag(tag, data) self.__starttag_text = rawdata[start_pos:match.end(1) + 1] return k - match = starttag.match(rawdata, i) + # XXX The following should skip matching quotes (' or ") + # As a shortcut way to exit, this isn't so bad, but shouldn't + # be used to locate the actual end of the start tag since the + # < or > characters may be embedded in an attribute value. + match = endbracket.search(rawdata, i+1) if not match: return -1 - j = match.end(0) + j = match.start(0) # Now parse the data between i+1 and j into a tag and attrs attrs = [] if rawdata[i:i+2] == '<>': @@ -306,10 +305,10 @@ # Internal -- parse endtag def parse_endtag(self, i): rawdata = self.rawdata - match = endtag.match(rawdata, i) + match = endbracket.search(rawdata, i+1) if not match: return -1 - j = match.end(0) + j = match.start(0) tag = rawdata[i+2:j].strip().lower() if rawdata[j] == '>': j = j+1 Modified: python/branches/p3yk-noslice/Lib/site.py ============================================================================== --- python/branches/p3yk-noslice/Lib/site.py (original) +++ python/branches/p3yk-noslice/Lib/site.py Fri Dec 15 05:21:50 2006 @@ -135,7 +135,7 @@ if line.startswith("#"): continue if line.startswith("import"): - exec line + exec(line) continue line = line.rstrip() dir, dircase = makepath(sitedir, line) @@ -274,7 +274,7 @@ for filename in self.__files: filename = os.path.join(dir, filename) try: - fp = file(filename, "rU") + fp = open(filename, "rU") data = fp.read() fp.close() break Modified: python/branches/p3yk-noslice/Lib/smtplib.py ============================================================================== --- python/branches/p3yk-noslice/Lib/smtplib.py (original) +++ python/branches/p3yk-noslice/Lib/smtplib.py Fri Dec 15 05:21:50 2006 @@ -52,9 +52,10 @@ __all__ = ["SMTPException","SMTPServerDisconnected","SMTPResponseException", "SMTPSenderRefused","SMTPRecipientsRefused","SMTPDataError", "SMTPConnectError","SMTPHeloError","SMTPAuthenticationError", - "quoteaddr","quotedata","SMTP"] + "quoteaddr","quotedata","SMTP","SMTP_SSL"] SMTP_PORT = 25 +SMTP_SSL_PORT = 465 CRLF="\r\n" OLDSTYLE_AUTH = re.compile(r"auth=(.*)", re.I) @@ -240,6 +241,7 @@ """ self.esmtp_features = {} + self.default_port = SMTP_PORT if host: (code, msg) = self.connect(host, port) if code != 220: @@ -271,6 +273,13 @@ """ self.debuglevel = debuglevel + def _get_socket(self,af, socktype, proto,sa): + # This makes it simpler for SMTP_SSL to use the SMTP connect code + # and just alter the socket connection bit. + self.sock = socket.socket(af, socktype, proto) + if self.debuglevel > 0: print>>stderr, 'connect:', (host, port) + self.sock.connect(sa) + def connect(self, host='localhost', port = 0): """Connect to a host on a given port. @@ -289,16 +298,14 @@ try: port = int(port) except ValueError: raise socket.error, "nonnumeric port" - if not port: port = SMTP_PORT + if not port: port = self.default_port if self.debuglevel > 0: print>>stderr, 'connect:', (host, port) msg = "getaddrinfo returns an empty list" self.sock = None for res in socket.getaddrinfo(host, port, 0, socket.SOCK_STREAM): af, socktype, proto, canonname, sa = res try: - self.sock = socket.socket(af, socktype, proto) - if self.debuglevel > 0: print>>stderr, 'connect:', sa - self.sock.connect(sa) + self._get_socket(af,socktype,proto,sa) except socket.error, msg: if self.debuglevel > 0: print>>stderr, 'connect fail:', msg if self.sock: @@ -716,6 +723,28 @@ self.docmd("quit") self.close() +class SMTP_SSL(SMTP): + """ This is a subclass derived from SMTP that connects over an SSL encrypted + socket (to use this class you need a socket module that was compiled with SSL + support). If host is not specified, '' (the local host) is used. If port is + omitted, the standard SMTP-over-SSL port (465) is used. keyfile and certfile + are also optional - they can contain a PEM formatted private key and + certificate chain file for the SSL connection. + """ + def __init__(self, host = '', port = 0, local_hostname = None, + keyfile = None, certfile = None): + self.keyfile = keyfile + self.certfile = certfile + SMTP.__init__(self,host,port,local_hostname) + self.default_port = SMTP_SSL_PORT + + def _get_socket(self,af, socktype, proto,sa): + self.sock = socket.socket(af, socktype, proto) + if self.debuglevel > 0: print>>stderr, 'connect:', (host, port) + self.sock.connect(sa) + sslobj = socket.ssl(self.sock, self.keyfile, self.certfile) + self.sock = SSLFakeSocket(self.sock, sslobj) + self.file = SSLFakeFile(sslobj) # Test the sendmail method, which tests most of the others. # Note: This always sends to localhost. Modified: python/branches/p3yk-noslice/Lib/socket.py ============================================================================== --- python/branches/p3yk-noslice/Lib/socket.py (original) +++ python/branches/p3yk-noslice/Lib/socket.py Fri Dec 15 05:21:50 2006 @@ -191,7 +191,7 @@ _s = ("def %s(self, *args): return self._sock.%s(*args)\n\n" "%s.__doc__ = _realsocket.%s.__doc__\n") for _m in _socketmethods: - exec _s % (_m, _m, _m, _m) + exec(_s % (_m, _m, _m, _m)) del _m, _s socket = SocketType = _socketobject Modified: python/branches/p3yk-noslice/Lib/sqlite3/test/types.py ============================================================================== --- python/branches/p3yk-noslice/Lib/sqlite3/test/types.py (original) +++ python/branches/p3yk-noslice/Lib/sqlite3/test/types.py Fri Dec 15 05:21:50 2006 @@ -86,6 +86,12 @@ else: return 1 + def __eq__(self, other): + c = self.__cmp__(other) + if c is NotImplemented: + return c + return c == 0 + def __conform__(self, protocol): if protocol is sqlite.PrepareProtocol: return self.val Modified: python/branches/p3yk-noslice/Lib/subprocess.py ============================================================================== --- python/branches/p3yk-noslice/Lib/subprocess.py (original) +++ python/branches/p3yk-noslice/Lib/subprocess.py Fri Dec 15 05:21:50 2006 @@ -420,7 +420,8 @@ def _cleanup(): for inst in _active[:]: - if inst.poll(_deadstate=sys.maxint) >= 0: + res = inst.poll(_deadstate=sys.maxint) + if res is not None and res >= 0: try: _active.remove(inst) except ValueError: @@ -965,6 +966,8 @@ if isinstance(args, types.StringTypes): args = [args] + else: + args = list(args) if shell: args = ["/bin/sh", "-c"] + args @@ -1000,14 +1003,10 @@ if errwrite: os.dup2(errwrite, 2) - # Close pipe fds. Make sure we doesn't close the same - # fd more than once. - if p2cread: - os.close(p2cread) - if c2pwrite and c2pwrite not in (p2cread,): - os.close(c2pwrite) - if errwrite and errwrite not in (p2cread, c2pwrite): - os.close(errwrite) + # Close pipe fds. Make sure we don't close the same + # fd more than once, or standard fds. + for fd in set((p2cread, c2pwrite, errwrite))-set((0,1,2)): + if fd: os.close(fd) # Close all other fds, if asked for if close_fds: Modified: python/branches/p3yk-noslice/Lib/symbol.py ============================================================================== --- python/branches/p3yk-noslice/Lib/symbol.py (original) +++ python/branches/p3yk-noslice/Lib/symbol.py Fri Dec 15 05:21:50 2006 @@ -43,57 +43,56 @@ dotted_as_names = 286 dotted_name = 287 global_stmt = 288 -exec_stmt = 289 -assert_stmt = 290 -compound_stmt = 291 -if_stmt = 292 -while_stmt = 293 -for_stmt = 294 -try_stmt = 295 -with_stmt = 296 -with_var = 297 -except_clause = 298 -suite = 299 -testlist_safe = 300 -old_test = 301 -old_lambdef = 302 -test = 303 -or_test = 304 -and_test = 305 -not_test = 306 -comparison = 307 -comp_op = 308 -expr = 309 -xor_expr = 310 -and_expr = 311 -shift_expr = 312 -arith_expr = 313 -term = 314 -factor = 315 -power = 316 -atom = 317 -listmaker = 318 -testlist_gexp = 319 -lambdef = 320 -trailer = 321 -subscriptlist = 322 -subscript = 323 -sliceop = 324 -exprlist = 325 -testlist = 326 -dictmaker = 327 -classdef = 328 -arglist = 329 -argument = 330 -list_iter = 331 -list_for = 332 -list_if = 333 -gen_iter = 334 -gen_for = 335 -gen_if = 336 -testlist1 = 337 -encoding_decl = 338 -yield_expr = 339 +assert_stmt = 289 +compound_stmt = 290 +if_stmt = 291 +while_stmt = 292 +for_stmt = 293 +try_stmt = 294 +with_stmt = 295 +with_var = 296 +except_clause = 297 +suite = 298 +testlist_safe = 299 +old_test = 300 +old_lambdef = 301 +test = 302 +or_test = 303 +and_test = 304 +not_test = 305 +comparison = 306 +comp_op = 307 +expr = 308 +xor_expr = 309 +and_expr = 310 +shift_expr = 311 +arith_expr = 312 +term = 313 +factor = 314 +power = 315 +atom = 316 +listmaker = 317 +testlist_gexp = 318 +lambdef = 319 +trailer = 320 +subscriptlist = 321 +subscript = 322 +sliceop = 323 +exprlist = 324 +testlist = 325 +dictsetmaker = 326 +classdef = 327 +arglist = 328 +argument = 329 +list_iter = 330 +list_for = 331 +list_if = 332 +gen_iter = 333 +gen_for = 334 +gen_if = 335 +testlist1 = 336 +encoding_decl = 337 +yield_expr = 338 #--end constants-- sym_name = {} Modified: python/branches/p3yk-noslice/Lib/symtable.py ============================================================================== --- python/branches/p3yk-noslice/Lib/symtable.py (original) +++ python/branches/p3yk-noslice/Lib/symtable.py Fri Dec 15 05:21:50 2006 @@ -4,7 +4,7 @@ from _symtable import USE, DEF_GLOBAL, DEF_LOCAL, DEF_PARAM, \ DEF_STAR, DEF_DOUBLESTAR, DEF_INTUPLE, DEF_FREE, \ DEF_FREE_GLOBAL, DEF_FREE_CLASS, DEF_IMPORT, DEF_BOUND, \ - OPT_IMPORT_STAR, OPT_EXEC, OPT_BARE_EXEC + OPT_IMPORT_STAR import weakref @@ -94,8 +94,8 @@ return bool(self._table.children) def has_exec(self): - """Return true if the scope uses exec""" - return bool(self._table.optimized & (OPT_EXEC | OPT_BARE_EXEC)) + """Return true if the scope uses exec. Deprecated method.""" + return False def has_import_star(self): """Return true if the scope uses import *""" Modified: python/branches/p3yk-noslice/Lib/tarfile.py ============================================================================== --- python/branches/p3yk-noslice/Lib/tarfile.py (original) +++ python/branches/p3yk-noslice/Lib/tarfile.py Fri Dec 15 05:21:50 2006 @@ -49,6 +49,7 @@ import errno import time import struct +import copy if sys.platform == 'mac': # This module needs work for MacOS9, especially in the area of pathname @@ -65,6 +66,8 @@ # from tarfile import * __all__ = ["TarFile", "TarInfo", "is_tarfile", "TarError"] +from __builtin__ import open as _open # Since 'open' is TarFile.open + #--------------------------------------------------------- # tar constants #--------------------------------------------------------- @@ -136,7 +139,7 @@ def stn(s, length): """Convert a python string to a null-terminated string buffer. """ - return s[:length-1] + (length - len(s) - 1) * NUL + NUL + return s[:length] + (length - len(s)) * NUL def nti(s): """Convert a number field to a python number. @@ -144,7 +147,7 @@ # There are two possible encodings for a number field, see # itn() below. if s[0] != chr(0200): - n = int(s.rstrip(NUL) or "0", 8) + n = int(s.rstrip(NUL + " ") or "0", 8) else: n = 0L for i in xrange(len(s) - 1): @@ -793,7 +796,6 @@ """Construct a TarInfo object. name is the optional name of the member. """ - self.name = name # member name (dirnames must end with '/') self.mode = 0666 # file permissions self.uid = 0 # user id @@ -807,8 +809,6 @@ self.gname = "group" # group name self.devmajor = 0 # device major number self.devminor = 0 # device minor number - self.prefix = "" # prefix to filename or information - # about sparse files self.offset = 0 # the tar header starts here self.offset_data = 0 # the file's data starts here @@ -840,24 +840,74 @@ tarinfo.gname = buf[297:329].rstrip(NUL) tarinfo.devmajor = nti(buf[329:337]) tarinfo.devminor = nti(buf[337:345]) - tarinfo.prefix = buf[345:500] + prefix = buf[345:500].rstrip(NUL) + + if prefix and not tarinfo.issparse(): + tarinfo.name = prefix + "/" + tarinfo.name if tarinfo.chksum not in calc_chksums(buf): raise ValueError("invalid header") return tarinfo def tobuf(self, posix=False): - """Return a tar header block as a 512 byte string. + """Return a tar header as a string of 512 byte blocks. """ + buf = "" + type = self.type + prefix = "" + + if self.name.endswith("/"): + type = DIRTYPE + + if type in (GNUTYPE_LONGNAME, GNUTYPE_LONGLINK): + # Prevent "././@LongLink" from being normalized. + name = self.name + else: + name = normpath(self.name) + + if type == DIRTYPE: + # directories should end with '/' + name += "/" + + linkname = self.linkname + if linkname: + # if linkname is empty we end up with a '.' + linkname = normpath(linkname) + + if posix: + if self.size > MAXSIZE_MEMBER: + raise ValueError("file is too large (>= 8 GB)") + + if len(self.linkname) > LENGTH_LINK: + raise ValueError("linkname is too long (>%d)" % (LENGTH_LINK)) + + if len(name) > LENGTH_NAME: + prefix = name[:LENGTH_PREFIX + 1] + while prefix and prefix[-1] != "/": + prefix = prefix[:-1] + + name = name[len(prefix):] + prefix = prefix[:-1] + + if not prefix or len(name) > LENGTH_NAME: + raise ValueError("name is too long") + + else: + if len(self.linkname) > LENGTH_LINK: + buf += self._create_gnulong(self.linkname, GNUTYPE_LONGLINK) + + if len(name) > LENGTH_NAME: + buf += self._create_gnulong(name, GNUTYPE_LONGNAME) + parts = [ - stn(self.name, 100), + stn(name, 100), itn(self.mode & 07777, 8, posix), itn(self.uid, 8, posix), itn(self.gid, 8, posix), itn(self.size, 12, posix), itn(self.mtime, 12, posix), " ", # checksum field - self.type, + type, stn(self.linkname, 100), stn(MAGIC, 6), stn(VERSION, 2), @@ -865,15 +915,38 @@ stn(self.gname, 32), itn(self.devmajor, 8, posix), itn(self.devminor, 8, posix), - stn(self.prefix, 155) + stn(prefix, 155) ] - buf = struct.pack("%ds" % BLOCKSIZE, "".join(parts)) - chksum = calc_chksums(buf)[0] - buf = buf[:148] + "%06o\0" % chksum + buf[155:] + buf += struct.pack("%ds" % BLOCKSIZE, "".join(parts)) + chksum = calc_chksums(buf[-BLOCKSIZE:])[0] + buf = buf[:-364] + "%06o\0" % chksum + buf[-357:] self.buf = buf return buf + def _create_gnulong(self, name, type): + """Create a GNU longname/longlink header from name. + It consists of an extended tar header, with the length + of the longname as size, followed by data blocks, + which contain the longname as a null terminated string. + """ + name += NUL + + tarinfo = self.__class__() + tarinfo.name = "././@LongLink" + tarinfo.type = type + tarinfo.mode = 0 + tarinfo.size = len(name) + + # create extended header + buf = tarinfo.tobuf() + # create name blocks + buf += name + blocks, remainder = divmod(len(name), BLOCKSIZE) + if remainder > 0: + buf += (BLOCKSIZE - remainder) * NUL + return buf + def isreg(self): return self.type in REGULAR_TYPES def isfile(self): @@ -934,7 +1007,7 @@ self.mode = {"r": "rb", "a": "r+b", "w": "wb"}[mode] if not fileobj: - fileobj = file(self.name, self.mode) + fileobj = _open(self.name, self.mode) self._extfileobj = False else: if self.name is None and hasattr(fileobj, "name"): @@ -1083,7 +1156,7 @@ tarname = pre + ext if fileobj is None: - fileobj = file(name, mode + "b") + fileobj = _open(name, mode + "b") if mode != "r": name = tarname @@ -1355,7 +1428,7 @@ # Append the tar header and data to the archive. if tarinfo.isreg(): - f = file(name, "rb") + f = _open(name, "rb") self.addfile(tarinfo, f) f.close() @@ -1377,50 +1450,11 @@ """ self._check("aw") - tarinfo.name = normpath(tarinfo.name) - if tarinfo.isdir(): - # directories should end with '/' - tarinfo.name += "/" - - if tarinfo.linkname: - tarinfo.linkname = normpath(tarinfo.linkname) - - if tarinfo.size > MAXSIZE_MEMBER: - if self.posix: - raise ValueError("file is too large (>= 8 GB)") - else: - self._dbg(2, "tarfile: Created GNU tar largefile header") - - - if len(tarinfo.linkname) > LENGTH_LINK: - if self.posix: - raise ValueError("linkname is too long (>%d)" % (LENGTH_LINK)) - else: - self._create_gnulong(tarinfo.linkname, GNUTYPE_LONGLINK) - tarinfo.linkname = tarinfo.linkname[:LENGTH_LINK -1] - self._dbg(2, "tarfile: Created GNU tar extension LONGLINK") - - if len(tarinfo.name) > LENGTH_NAME: - if self.posix: - prefix = tarinfo.name[:LENGTH_PREFIX + 1] - while prefix and prefix[-1] != "/": - prefix = prefix[:-1] - - name = tarinfo.name[len(prefix):] - prefix = prefix[:-1] - - if not prefix or len(name) > LENGTH_NAME: - raise ValueError("name is too long (>%d)" % (LENGTH_NAME)) - - tarinfo.name = name - tarinfo.prefix = prefix - else: - self._create_gnulong(tarinfo.name, GNUTYPE_LONGNAME) - tarinfo.name = tarinfo.name[:LENGTH_NAME - 1] - self._dbg(2, "tarfile: Created GNU tar extension LONGNAME") + tarinfo = copy.copy(tarinfo) - self.fileobj.write(tarinfo.tobuf(self.posix)) - self.offset += BLOCKSIZE + buf = tarinfo.tobuf(self.posix) + self.fileobj.write(buf) + self.offset += len(buf) # If there's data to follow, append it. if fileobj is not None: @@ -1617,7 +1651,7 @@ """Make a file called targetpath. """ source = self.extractfile(tarinfo) - target = file(targetpath, "wb") + target = _open(targetpath, "wb") copyfileobj(source, target) source.close() target.close() @@ -1779,12 +1813,6 @@ if tarinfo.isreg() and tarinfo.name.endswith("/"): tarinfo.type = DIRTYPE - # The prefix field is used for filenames > 100 in - # the POSIX standard. - # name = prefix + '/' + name - tarinfo.name = normpath(os.path.join(tarinfo.prefix.rstrip(NUL), - tarinfo.name)) - # Directory names should have a '/' at the end. if tarinfo.isdir(): tarinfo.name += "/" @@ -1909,10 +1937,6 @@ self.offset += self._block(tarinfo.size) tarinfo.size = origsize - # Clear the prefix field so that it is not used - # as a pathname in next(). - tarinfo.prefix = "" - return tarinfo #-------------------------------------------------------------------------- @@ -1970,31 +1994,6 @@ else: return TarIter(self) - def _create_gnulong(self, name, type): - """Write a GNU longname/longlink member to the TarFile. - It consists of an extended tar header, with the length - of the longname as size, followed by data blocks, - which contain the longname as a null terminated string. - """ - name += NUL - - tarinfo = TarInfo() - tarinfo.name = "././@LongLink" - tarinfo.type = type - tarinfo.mode = 0 - tarinfo.size = len(name) - - # write extended header - self.fileobj.write(tarinfo.tobuf()) - self.offset += BLOCKSIZE - # write name blocks - self.fileobj.write(name) - blocks, remainder = divmod(tarinfo.size, BLOCKSIZE) - if remainder > 0: - self.fileobj.write(NUL * (BLOCKSIZE - remainder)) - blocks += 1 - self.offset += blocks * BLOCKSIZE - def _dbg(self, level, msg): """Write debugging output to sys.stderr. """ Modified: python/branches/p3yk-noslice/Lib/test/README ============================================================================== --- python/branches/p3yk-noslice/Lib/test/README (original) +++ python/branches/p3yk-noslice/Lib/test/README Fri Dec 15 05:21:50 2006 @@ -379,8 +379,8 @@ point numbers when you expect them to only be approximately equal withing a fuzz factor (``test_support.FUZZ``, which defaults to 1e-6). - * ``check_syntax(statement)`` - make sure that the statement is *not* - correct Python syntax. + * ``check_syntax_error(testcase, statement)`` - make sure that the + statement is *not* correct Python syntax. Python and C statement coverage results are currently available at Modified: python/branches/p3yk-noslice/Lib/test/crashers/bogus_code_obj.py ============================================================================== --- python/branches/p3yk-noslice/Lib/test/crashers/bogus_code_obj.py (original) +++ python/branches/p3yk-noslice/Lib/test/crashers/bogus_code_obj.py Fri Dec 15 05:21:50 2006 @@ -16,4 +16,4 @@ co = types.CodeType(0, 0, 0, 0, '\x04\x71\x00\x00', (), (), (), '', '', 1, '') -exec co +exec(co) Modified: python/branches/p3yk-noslice/Lib/test/list_tests.py ============================================================================== --- python/branches/p3yk-noslice/Lib/test/list_tests.py (original) +++ python/branches/p3yk-noslice/Lib/test/list_tests.py Fri Dec 15 05:21:50 2006 @@ -37,7 +37,7 @@ self.assertEqual(str(a0), str(l0)) self.assertEqual(repr(a0), repr(l0)) - self.assertEqual(`a2`, `l2`) + self.assertEqual(repr(a2), repr(l2)) self.assertEqual(str(a2), "[0, 1, 2]") self.assertEqual(repr(a2), "[0, 1, 2]") @@ -269,7 +269,6 @@ self.assertRaises(TypeError, a.insert) def test_pop(self): - from decimal import Decimal a = self.type2test([-1, 0, 1]) a.pop() self.assertEqual(a, [-1, 0]) @@ -281,8 +280,6 @@ self.assertRaises(IndexError, a.pop) self.assertRaises(TypeError, a.pop, 42, 42) a = self.type2test([0, 10, 20, 30, 40]) - self.assertEqual(a.pop(Decimal(2)), 20) - self.assertRaises(IndexError, a.pop, Decimal(25)) def test_remove(self): a = self.type2test([0, 0, 1]) Modified: python/branches/p3yk-noslice/Lib/test/mapping_tests.py ============================================================================== --- python/branches/p3yk-noslice/Lib/test/mapping_tests.py (original) +++ python/branches/p3yk-noslice/Lib/test/mapping_tests.py Fri Dec 15 05:21:50 2006 @@ -60,10 +60,10 @@ for k in self.other: self.failIf(k in d) #cmp - self.assertEqual(cmp(p,p), 0) - self.assertEqual(cmp(d,d), 0) - self.assertEqual(cmp(p,d), -1) - self.assertEqual(cmp(d,p), 1) + self.assertEqual(p, p) + self.assertEqual(d, d) + self.assertNotEqual(p, d) + self.assertNotEqual(d, p) #__non__zero__ if p: self.fail("Empty mapping must compare to False") if not d: self.fail("Full mapping must compare to True") @@ -623,9 +623,10 @@ d = self._full_mapping({1: BadRepr()}) self.assertRaises(Exc, repr, d) - def test_le(self): - self.assert_(not (self._empty_mapping() < self._empty_mapping())) - self.assert_(not (self._full_mapping({1: 2}) < self._full_mapping({1L: 2L}))) + def test_eq(self): + self.assertEqual(self._empty_mapping(), self._empty_mapping()) + self.assertEqual(self._full_mapping({1: 2}), + self._full_mapping({1L: 2L})) class Exc(Exception): pass @@ -633,16 +634,12 @@ def __eq__(self, other): raise Exc() def __hash__(self): - return 42 + return 1 d1 = self._full_mapping({BadCmp(): 1}) d2 = self._full_mapping({1: 1}) - try: - d1 < d2 - except Exc: - pass - else: - self.fail("< didn't raise Exc") + self.assertRaises(Exc, lambda: BadCmp()==1) + self.assertRaises(Exc, lambda: d1==d2) def test_setdefault(self): TestMappingProtocol.test_setdefault(self) Deleted: /python/branches/p3yk-noslice/Lib/test/output/test_MimeWriter ============================================================================== --- /python/branches/p3yk-noslice/Lib/test/output/test_MimeWriter Fri Dec 15 05:21:50 2006 +++ (empty file) @@ -1,110 +0,0 @@ -test_MimeWriter -From: bwarsaw at cnri.reston.va.us -Date: Mon Feb 12 17:21:48 EST 1996 -To: kss-submit at cnri.reston.va.us -MIME-Version: 1.0 -Content-Type: multipart/knowbot; - boundary="801spam999"; - version="0.1" - -This is a multi-part message in MIME format. - ---801spam999 -Content-Type: multipart/knowbot-metadata; - boundary="802spam999" - - ---802spam999 -Content-Type: message/rfc822 -KP-Metadata-Type: simple -KP-Access: read-only - -KPMD-Interpreter: python -KPMD-Interpreter-Version: 1.3 -KPMD-Owner-Name: Barry Warsaw -KPMD-Owner-Rendezvous: bwarsaw at cnri.reston.va.us -KPMD-Home-KSS: kss.cnri.reston.va.us -KPMD-Identifier: hdl://cnri.kss/my_first_knowbot -KPMD-Launch-Date: Mon Feb 12 16:39:03 EST 1996 - ---802spam999 -Content-Type: text/isl -KP-Metadata-Type: complex -KP-Metadata-Key: connection -KP-Access: read-only -KP-Connection-Description: Barry's Big Bass Business -KP-Connection-Id: B4 -KP-Connection-Direction: client - -INTERFACE Seller-1; - -TYPE Seller = OBJECT - DOCUMENTATION "A simple Seller interface to test ILU" - METHODS - price():INTEGER, - END; - ---802spam999 -Content-Type: message/external-body; - access-type="URL"; - URL="hdl://cnri.kss/generic-knowbot" - -Content-Type: text/isl -KP-Metadata-Type: complex -KP-Metadata-Key: generic-interface -KP-Access: read-only -KP-Connection-Description: Generic Interface for All Knowbots -KP-Connection-Id: generic-kp -KP-Connection-Direction: client - - ---802spam999-- - ---801spam999 -Content-Type: multipart/knowbot-code; - boundary="803spam999" - - ---803spam999 -Content-Type: text/plain -KP-Module-Name: BuyerKP - -class Buyer: - def __setup__(self, maxprice): - self._maxprice = maxprice - - def __main__(self, kos): - """Entry point upon arrival at a new KOS.""" - broker = kos.broker() - # B4 == Barry's Big Bass Business :-) - seller = broker.lookup('Seller_1.Seller', 'B4') - if seller: - price = seller.price() - print 'Seller wants $', price, '... ' - if price > self._maxprice: - print 'too much!' - else: - print "I'll take it!" - else: - print 'no seller found here' - ---803spam999-- - ---801spam999 -Content-Type: multipart/knowbot-state; - boundary="804spam999" -KP-Main-Module: main - - ---804spam999 -Content-Type: text/plain -KP-Module-Name: main - -# instantiate a buyer instance and put it in a magic place for the KOS -# to find. -__kp__ = Buyer() -__kp__.__setup__(500) - ---804spam999-- - ---801spam999-- Modified: python/branches/p3yk-noslice/Lib/test/output/test_cProfile ============================================================================== --- python/branches/p3yk-noslice/Lib/test/output/test_cProfile (original) +++ python/branches/p3yk-noslice/Lib/test/output/test_cProfile Fri Dec 15 05:21:50 2006 @@ -1,5 +1,5 @@ test_cProfile - 126 function calls (106 primitive calls) in 1.000 CPU seconds + 127 function calls (107 primitive calls) in 1.000 CPU seconds Ordered by: standard name @@ -14,6 +14,7 @@ 4 0.116 0.029 0.120 0.030 test_cProfile.py:78(helper1) 2 0.000 0.000 0.140 0.070 test_cProfile.py:89(helper2_indirect) 8 0.312 0.039 0.400 0.050 test_cProfile.py:93(helper2) + 1 0.000 0.000 1.000 1.000 {exec} 12 0.000 0.000 0.012 0.001 {hasattr} 4 0.000 0.000 0.000 0.000 {method 'append' of 'list' objects} 1 0.000 0.000 0.000 0.000 {method 'disable' of '_lsprof.Profiler' objects} @@ -44,6 +45,7 @@ 2 0.078 0.100 test_cProfile.py:93(helper2) test_cProfile.py:93(helper2) -> 8 0.064 0.080 test_cProfile.py:103(subhelper) 8 0.000 0.008 {hasattr} +{exec} -> 1 0.000 1.000 :1() {hasattr} -> 12 0.012 0.012 test_cProfile.py:115(__getattr__) {method 'append' of 'list' objects} -> {method 'disable' of '_lsprof.Profiler' objects} -> @@ -55,7 +57,7 @@ Function was called by... ncalls tottime cumtime -:1() <- +:1() <- 1 0.000 1.000 {exec} test_cProfile.py:103(subhelper) <- 8 0.064 0.080 test_cProfile.py:93(helper2) test_cProfile.py:115(__getattr__) <- 16 0.016 0.016 test_cProfile.py:103(subhelper) 12 0.012 0.012 {hasattr} @@ -69,6 +71,7 @@ test_cProfile.py:89(helper2_indirect) <- 2 0.000 0.140 test_cProfile.py:60(helper) test_cProfile.py:93(helper2) <- 6 0.234 0.300 test_cProfile.py:60(helper) 2 0.078 0.100 test_cProfile.py:89(helper2_indirect) +{exec} <- {hasattr} <- 4 0.000 0.004 test_cProfile.py:78(helper1) 8 0.000 0.008 test_cProfile.py:93(helper2) {method 'append' of 'list' objects} <- 4 0.000 0.000 test_cProfile.py:78(helper1) Deleted: /python/branches/p3yk-noslice/Lib/test/output/test_cgi ============================================================================== --- /python/branches/p3yk-noslice/Lib/test/output/test_cgi Fri Dec 15 05:21:50 2006 +++ (empty file) @@ -1,42 +0,0 @@ -test_cgi -'' => [] -'&' => [] -'&&' => [] -'=' => [('', '')] -'=a' => [('', 'a')] -'a' => [('a', '')] -'a=' => [('a', '')] -'a=' => [('a', '')] -'&a=b' => [('a', 'b')] -'a=a+b&b=b+c' => [('a', 'a b'), ('b', 'b c')] -'a=1&a=2' => [('a', '1'), ('a', '2')] -'' -'&' -'&&' -';' -';&;' -'=' -'=&=' -'=;=' -'=a' -'&=a' -'=a&' -'=&a' -'b=a' -'b+=a' -'a=b=a' -'a=+b=a' -'&b=a' -'b&=a' -'a=a+b&b=b+c' -'a=a+b&a=b+a' -'x=1&y=2.0&z=2-3.%2b0' -'x=1;y=2.0&z=2-3.%2b0' -'x=1;y=2.0;z=2-3.%2b0' -'Hbc5161168c542333633315dee1182227:key_store_seqid=400006&cuyer=r&view=bustomer&order_id=0bb2e248638833d48cb7fed300000f1b&expire=964546263&lobale=en-US&kid=130003.300038&ss=env' -'group_id=5470&set=custom&_assigned_to=31392&_status=1&_category=100&SUBMIT=Browse' -Testing log -Testing initlog 1 -Testing log 2 -Test FieldStorage methods that use readline -Test basic FieldStorage multipart parsing Modified: python/branches/p3yk-noslice/Lib/test/output/test_class ============================================================================== --- python/branches/p3yk-noslice/Lib/test/output/test_class (original) +++ python/branches/p3yk-noslice/Lib/test/output/test_class Fri Dec 15 05:21:50 2006 @@ -51,16 +51,14 @@ __hash__: () __repr__: () __str__: () -__cmp__: (1,) -__cmp__: (1,) -__cmp__: (1,) -__cmp__: (1,) -__cmp__: (1,) -__cmp__: (1,) -__cmp__: (1,) -__cmp__: (1,) -__cmp__: (1,) -__cmp__: (1,) +__eq__: (1,) +__lt__: (1,) +__gt__: (1,) +__ne__: (1,) +__eq__: (1,) +__gt__: (1,) +__lt__: (1,) +__ne__: (1,) __del__: () __getattr__: ('spam',) __setattr__: ('eggs', 'spam, spam, spam and ham') Deleted: /python/branches/p3yk-noslice/Lib/test/output/test_cookie ============================================================================== --- /python/branches/p3yk-noslice/Lib/test/output/test_cookie Fri Dec 15 05:21:50 2006 +++ (empty file) @@ -1,32 +0,0 @@ -test_cookie - -Set-Cookie: chips=ahoy -Set-Cookie: vienna=finger - chips 'ahoy' 'ahoy' -Set-Cookie: chips=ahoy - vienna 'finger' 'finger' -Set-Cookie: vienna=finger - -Set-Cookie: keebler="E=mc2; L=\"Loves\"; fudge=\012;" - keebler 'E=mc2; L="Loves"; fudge=\n;' 'E=mc2; L="Loves"; fudge=\n;' -Set-Cookie: keebler="E=mc2; L=\"Loves\"; fudge=\012;" - -Set-Cookie: keebler=E=mc2 - keebler 'E=mc2' 'E=mc2' -Set-Cookie: keebler=E=mc2 -Set-Cookie: Customer="WILE_E_COYOTE"; Path=/acme - - - - - - -If anything blows up after this line, it's from Cookie's doctest. Modified: python/branches/p3yk-noslice/Lib/test/output/test_extcall ============================================================================== --- python/branches/p3yk-noslice/Lib/test/output/test_extcall (original) +++ python/branches/p3yk-noslice/Lib/test/output/test_extcall Fri Dec 15 05:21:50 2006 @@ -9,9 +9,9 @@ (1, 2, 3) {'a': 4, 'b': 5} (1, 2, 3, 4, 5) {'a': 6, 'b': 7} (1, 2, 3, 6, 7) {'a': 8, 'b': 9, 'x': 4, 'y': 5} -TypeError: g() takes at least 1 argument (0 given) -TypeError: g() takes at least 1 argument (0 given) -TypeError: g() takes at least 1 argument (0 given) +TypeError: g() takes at least 1 positional argument (0 given) +TypeError: g() takes at least 1 positional argument (0 given) +TypeError: g() takes at least 1 positional argument (0 given) 1 () {} 1 (2,) {} 1 (2, 3) {} @@ -35,24 +35,24 @@ 3 512 True 3 3 -za () {} -> za() takes exactly 1 argument (0 given) +za () {} -> za() takes exactly 1 positional argument (0 given) za () {'a': 'aa'} -> ok za aa B D E V a za () {'d': 'dd'} -> za() got an unexpected keyword argument 'd' za () {'a': 'aa', 'd': 'dd'} -> za() got an unexpected keyword argument 'd' za () {'a': 'aa', 'b': 'bb', 'd': 'dd', 'e': 'ee'} -> za() got an unexpected keyword argument 'b' -za (1, 2) {} -> za() takes exactly 1 argument (2 given) -za (1, 2) {'a': 'aa'} -> za() takes exactly 1 non-keyword argument (2 given) -za (1, 2) {'d': 'dd'} -> za() takes exactly 1 non-keyword argument (2 given) -za (1, 2) {'a': 'aa', 'd': 'dd'} -> za() takes exactly 1 non-keyword argument (2 given) -za (1, 2) {'a': 'aa', 'b': 'bb', 'd': 'dd', 'e': 'ee'} -> za() takes exactly 1 non-keyword argument (2 given) -za (1, 2, 3, 4, 5) {} -> za() takes exactly 1 argument (5 given) -za (1, 2, 3, 4, 5) {'a': 'aa'} -> za() takes exactly 1 non-keyword argument (5 given) -za (1, 2, 3, 4, 5) {'d': 'dd'} -> za() takes exactly 1 non-keyword argument (5 given) -za (1, 2, 3, 4, 5) {'a': 'aa', 'd': 'dd'} -> za() takes exactly 1 non-keyword argument (5 given) -za (1, 2, 3, 4, 5) {'a': 'aa', 'b': 'bb', 'd': 'dd', 'e': 'ee'} -> za() takes exactly 1 non-keyword argument (5 given) -zade () {} -> zade() takes at least 1 argument (0 given) +za (1, 2) {} -> za() takes exactly 1 positional argument (2 given) +za (1, 2) {'a': 'aa'} -> za() takes exactly 1 non-keyword positional argument (2 given) +za (1, 2) {'d': 'dd'} -> za() takes exactly 1 non-keyword positional argument (2 given) +za (1, 2) {'a': 'aa', 'd': 'dd'} -> za() takes exactly 1 non-keyword positional argument (2 given) +za (1, 2) {'a': 'aa', 'b': 'bb', 'd': 'dd', 'e': 'ee'} -> za() takes exactly 1 non-keyword positional argument (2 given) +za (1, 2, 3, 4, 5) {} -> za() takes exactly 1 positional argument (5 given) +za (1, 2, 3, 4, 5) {'a': 'aa'} -> za() takes exactly 1 non-keyword positional argument (5 given) +za (1, 2, 3, 4, 5) {'d': 'dd'} -> za() takes exactly 1 non-keyword positional argument (5 given) +za (1, 2, 3, 4, 5) {'a': 'aa', 'd': 'dd'} -> za() takes exactly 1 non-keyword positional argument (5 given) +za (1, 2, 3, 4, 5) {'a': 'aa', 'b': 'bb', 'd': 'dd', 'e': 'ee'} -> za() takes exactly 1 non-keyword positional argument (5 given) +zade () {} -> zade() takes at least 1 positional argument (0 given) zade () {'a': 'aa'} -> ok zade aa B d e V a -zade () {'d': 'dd'} -> zade() takes at least 1 non-keyword argument (0 given) +zade () {'d': 'dd'} -> zade() takes at least 1 non-keyword positional argument (0 given) zade () {'a': 'aa', 'd': 'dd'} -> ok zade aa B dd e V d zade () {'a': 'aa', 'b': 'bb', 'd': 'dd', 'e': 'ee'} -> zade() got an unexpected keyword argument 'b' zade (1, 2) {} -> ok zade 1 B 2 e V e @@ -60,30 +60,30 @@ zade (1, 2) {'d': 'dd'} -> zade() got multiple values for keyword argument 'd' zade (1, 2) {'a': 'aa', 'd': 'dd'} -> zade() got multiple values for keyword argument 'a' zade (1, 2) {'a': 'aa', 'b': 'bb', 'd': 'dd', 'e': 'ee'} -> zade() got multiple values for keyword argument 'a' -zade (1, 2, 3, 4, 5) {} -> zade() takes at most 3 arguments (5 given) -zade (1, 2, 3, 4, 5) {'a': 'aa'} -> zade() takes at most 3 non-keyword arguments (5 given) -zade (1, 2, 3, 4, 5) {'d': 'dd'} -> zade() takes at most 3 non-keyword arguments (5 given) -zade (1, 2, 3, 4, 5) {'a': 'aa', 'd': 'dd'} -> zade() takes at most 3 non-keyword arguments (5 given) -zade (1, 2, 3, 4, 5) {'a': 'aa', 'b': 'bb', 'd': 'dd', 'e': 'ee'} -> zade() takes at most 3 non-keyword arguments (5 given) -zabk () {} -> zabk() takes exactly 2 arguments (0 given) -zabk () {'a': 'aa'} -> zabk() takes exactly 2 non-keyword arguments (1 given) -zabk () {'d': 'dd'} -> zabk() takes exactly 2 non-keyword arguments (0 given) -zabk () {'a': 'aa', 'd': 'dd'} -> zabk() takes exactly 2 non-keyword arguments (1 given) +zade (1, 2, 3, 4, 5) {} -> zade() takes at most 3 positional arguments (5 given) +zade (1, 2, 3, 4, 5) {'a': 'aa'} -> zade() takes at most 3 non-keyword positional arguments (5 given) +zade (1, 2, 3, 4, 5) {'d': 'dd'} -> zade() takes at most 3 non-keyword positional arguments (5 given) +zade (1, 2, 3, 4, 5) {'a': 'aa', 'd': 'dd'} -> zade() takes at most 3 non-keyword positional arguments (5 given) +zade (1, 2, 3, 4, 5) {'a': 'aa', 'b': 'bb', 'd': 'dd', 'e': 'ee'} -> zade() takes at most 3 non-keyword positional arguments (5 given) +zabk () {} -> zabk() takes exactly 2 positional arguments (0 given) +zabk () {'a': 'aa'} -> zabk() takes exactly 2 non-keyword positional arguments (1 given) +zabk () {'d': 'dd'} -> zabk() takes exactly 2 non-keyword positional arguments (0 given) +zabk () {'a': 'aa', 'd': 'dd'} -> zabk() takes exactly 2 non-keyword positional arguments (1 given) zabk () {'a': 'aa', 'b': 'bb', 'd': 'dd', 'e': 'ee'} -> ok zabk aa bb D E V {'d': 'dd', 'e': 'ee'} zabk (1, 2) {} -> ok zabk 1 2 D E V {} zabk (1, 2) {'a': 'aa'} -> zabk() got multiple values for keyword argument 'a' zabk (1, 2) {'d': 'dd'} -> ok zabk 1 2 D E V {'d': 'dd'} zabk (1, 2) {'a': 'aa', 'd': 'dd'} -> zabk() got multiple values for keyword argument 'a' zabk (1, 2) {'a': 'aa', 'b': 'bb', 'd': 'dd', 'e': 'ee'} -> zabk() got multiple values for keyword argument 'a' -zabk (1, 2, 3, 4, 5) {} -> zabk() takes exactly 2 arguments (5 given) -zabk (1, 2, 3, 4, 5) {'a': 'aa'} -> zabk() takes exactly 2 non-keyword arguments (5 given) -zabk (1, 2, 3, 4, 5) {'d': 'dd'} -> zabk() takes exactly 2 non-keyword arguments (5 given) -zabk (1, 2, 3, 4, 5) {'a': 'aa', 'd': 'dd'} -> zabk() takes exactly 2 non-keyword arguments (5 given) -zabk (1, 2, 3, 4, 5) {'a': 'aa', 'b': 'bb', 'd': 'dd', 'e': 'ee'} -> zabk() takes exactly 2 non-keyword arguments (5 given) -zabdv () {} -> zabdv() takes at least 2 arguments (0 given) -zabdv () {'a': 'aa'} -> zabdv() takes at least 2 non-keyword arguments (1 given) -zabdv () {'d': 'dd'} -> zabdv() takes at least 2 non-keyword arguments (0 given) -zabdv () {'a': 'aa', 'd': 'dd'} -> zabdv() takes at least 2 non-keyword arguments (1 given) +zabk (1, 2, 3, 4, 5) {} -> zabk() takes exactly 2 positional arguments (5 given) +zabk (1, 2, 3, 4, 5) {'a': 'aa'} -> zabk() takes exactly 2 non-keyword positional arguments (5 given) +zabk (1, 2, 3, 4, 5) {'d': 'dd'} -> zabk() takes exactly 2 non-keyword positional arguments (5 given) +zabk (1, 2, 3, 4, 5) {'a': 'aa', 'd': 'dd'} -> zabk() takes exactly 2 non-keyword positional arguments (5 given) +zabk (1, 2, 3, 4, 5) {'a': 'aa', 'b': 'bb', 'd': 'dd', 'e': 'ee'} -> zabk() takes exactly 2 non-keyword positional arguments (5 given) +zabdv () {} -> zabdv() takes at least 2 positional arguments (0 given) +zabdv () {'a': 'aa'} -> zabdv() takes at least 2 non-keyword positional arguments (1 given) +zabdv () {'d': 'dd'} -> zabdv() takes at least 2 non-keyword positional arguments (0 given) +zabdv () {'a': 'aa', 'd': 'dd'} -> zabdv() takes at least 2 non-keyword positional arguments (1 given) zabdv () {'a': 'aa', 'b': 'bb', 'd': 'dd', 'e': 'ee'} -> zabdv() got an unexpected keyword argument 'e' zabdv (1, 2) {} -> ok zabdv 1 2 d E () e zabdv (1, 2) {'a': 'aa'} -> zabdv() got multiple values for keyword argument 'a' @@ -95,10 +95,10 @@ zabdv (1, 2, 3, 4, 5) {'d': 'dd'} -> zabdv() got multiple values for keyword argument 'd' zabdv (1, 2, 3, 4, 5) {'a': 'aa', 'd': 'dd'} -> zabdv() got multiple values for keyword argument 'a' zabdv (1, 2, 3, 4, 5) {'a': 'aa', 'b': 'bb', 'd': 'dd', 'e': 'ee'} -> zabdv() got multiple values for keyword argument 'a' -zabdevk () {} -> zabdevk() takes at least 2 arguments (0 given) -zabdevk () {'a': 'aa'} -> zabdevk() takes at least 2 non-keyword arguments (1 given) -zabdevk () {'d': 'dd'} -> zabdevk() takes at least 2 non-keyword arguments (0 given) -zabdevk () {'a': 'aa', 'd': 'dd'} -> zabdevk() takes at least 2 non-keyword arguments (1 given) +zabdevk () {} -> zabdevk() takes at least 2 positional arguments (0 given) +zabdevk () {'a': 'aa'} -> zabdevk() takes at least 2 non-keyword positional arguments (1 given) +zabdevk () {'d': 'dd'} -> zabdevk() takes at least 2 non-keyword positional arguments (0 given) +zabdevk () {'a': 'aa', 'd': 'dd'} -> zabdevk() takes at least 2 non-keyword positional arguments (1 given) zabdevk () {'a': 'aa', 'b': 'bb', 'd': 'dd', 'e': 'ee'} -> ok zabdevk aa bb dd ee () {} zabdevk (1, 2) {} -> ok zabdevk 1 2 d e () {} zabdevk (1, 2) {'a': 'aa'} -> zabdevk() got multiple values for keyword argument 'a' Deleted: /python/branches/p3yk-noslice/Lib/test/output/test_global ============================================================================== --- /python/branches/p3yk-noslice/Lib/test/output/test_global Fri Dec 15 05:21:50 2006 +++ (empty file) @@ -1,5 +0,0 @@ -test_global -got SyntaxError as expected -got SyntaxError as expected -got SyntaxError as expected -as expected, no SyntaxError Deleted: /python/branches/p3yk-noslice/Lib/test/output/test_grammar ============================================================================== --- /python/branches/p3yk-noslice/Lib/test/output/test_grammar Fri Dec 15 05:21:50 2006 +++ (empty file) @@ -1,69 +0,0 @@ -test_grammar -1. Parser -1.1 Tokens -1.1.1 Backslashes -1.1.2 Numeric literals -1.1.2.1 Plain integers -1.1.2.2 Long integers -1.1.2.3 Floating point -1.1.3 String literals -1.2 Grammar -single_input -file_input -expr_input -eval_input -funcdef -lambdef -simple_stmt -expr_stmt -print_stmt -1 2 3 -1 2 3 -1 1 1 -extended print_stmt -1 2 3 -1 2 3 -1 1 1 -hello world -del_stmt -pass_stmt -flow_stmt -break_stmt -continue_stmt -continue + try/except ok -continue + try/finally ok -testing continue and break in try/except in loop -return_stmt -yield_stmt -raise_stmt -import_name -import_from -global_stmt -exec_stmt -assert_stmt -if_stmt -while_stmt -for_stmt -try_stmt -suite -test -comparison -binary mask ops -shift ops -additive ops -multiplicative ops -unary ops -selectors - -[1, (1,), (1, 2), (1, 2, 3)] -atoms -classdef -['Apple', 'Banana', 'Coco nut'] -[3, 6, 9, 12, 15] -[3, 4, 5] -[(1, 'Apple'), (1, 'Banana'), (1, 'Coconut'), (2, 'Apple'), (2, 'Banana'), (2, 'Coconut'), (3, 'Apple'), (3, 'Banana'), (3, 'Coconut'), (4, 'Apple'), (4, 'Banana'), (4, 'Coconut'), (5, 'Apple'), (5, 'Banana'), (5, 'Coconut')] -[(1, 'Banana'), (1, 'Coconut'), (2, 'Banana'), (2, 'Coconut'), (3, 'Banana'), (3, 'Coconut'), (4, 'Banana'), (4, 'Coconut'), (5, 'Banana'), (5, 'Coconut')] -[[1], [1, 1], [1, 2, 4], [1, 3, 9, 27], [1, 4, 16, 64, 256]] -[False, False, False] -[[1, 2], [3, 4], [5, 6]] -[('Boeing', 'Airliner'), ('Boeing', 'Engine'), ('Ford', 'Engine'), ('Macdonalds', 'Cheeseburger')] Deleted: /python/branches/p3yk-noslice/Lib/test/output/test_httplib ============================================================================== --- /python/branches/p3yk-noslice/Lib/test/output/test_httplib Fri Dec 15 05:21:50 2006 +++ (empty file) @@ -1,13 +0,0 @@ -test_httplib -reply: 'HTTP/1.1 200 Ok\r\n' -Text -reply: 'HTTP/1.1 400.100 Not Ok\r\n' -BadStatusLine raised as expected -InvalidURL raised as expected -InvalidURL raised as expected -reply: 'HTTP/1.1 200 OK\r\n' -header: Set-Cookie: Customer="WILE_E_COYOTE"; Version="1"; Path="/acme" -header: Set-Cookie: Part_Number="Rocket_Launcher_0001"; Version="1"; Path="/acme" -reply: 'HTTP/1.1 200 OK\r\n' -header: Content-Length: 14432 - Deleted: /python/branches/p3yk-noslice/Lib/test/output/test_math ============================================================================== --- /python/branches/p3yk-noslice/Lib/test/output/test_math Fri Dec 15 05:21:50 2006 +++ (empty file) @@ -1,28 +0,0 @@ -test_math -math module, testing with eps 1e-05 -constants -acos -asin -atan -atan2 -ceil -cos -cosh -degrees -exp -fabs -floor -fmod -frexp -hypot -ldexp -log -log10 -modf -pow -radians -sin -sinh -sqrt -tan -tanh Deleted: /python/branches/p3yk-noslice/Lib/test/output/test_mmap ============================================================================== --- /python/branches/p3yk-noslice/Lib/test/output/test_mmap Fri Dec 15 05:21:50 2006 +++ (empty file) @@ -1,38 +0,0 @@ -test_mmap - - Position of foo: 1.0 pages - Length of file: 2.0 pages - Contents of byte 0: '\x00' - Contents of first 3 bytes: '\x00\x00\x00' - - Modifying file's content... - Contents of byte 0: '3' - Contents of first 3 bytes: '3\x00\x00' - Contents of second page: '\x00foobar\x00' - Regex match on mmap (page start, length of match): 1.0 6 - Seek to zeroth byte - Seek to 42nd byte - Seek to last byte - Try to seek to negative position... - Try to seek beyond end of mmap... - Try to seek to negative position... - Attempting resize() - Creating 10 byte test data file. - Opening mmap with access=ACCESS_READ - Ensuring that readonly mmap can't be slice assigned. - Ensuring that readonly mmap can't be item assigned. - Ensuring that readonly mmap can't be write() to. - Ensuring that readonly mmap can't be write_byte() to. - Ensuring that readonly mmap can't be resized. - Opening mmap with size too big - Opening mmap with access=ACCESS_WRITE - Modifying write-through memory map. - Opening mmap with access=ACCESS_COPY - Modifying copy-on-write memory map. - Ensuring copy-on-write maps cannot be resized. - Ensuring invalid access parameter raises exception. - Try opening a bad file descriptor... - Ensuring that passing 0 as map length sets map size to current file size. - Ensuring that passing 0 as map length sets map size to current file size. - anonymous mmap.mmap(-1, PAGESIZE)... - Test passed Deleted: /python/branches/p3yk-noslice/Lib/test/output/test_nis ============================================================================== --- /python/branches/p3yk-noslice/Lib/test/output/test_nis Fri Dec 15 05:21:50 2006 +++ (empty file) @@ -1,2 +0,0 @@ -test_nis -nis.maps() Deleted: /python/branches/p3yk-noslice/Lib/test/output/test_opcodes ============================================================================== --- /python/branches/p3yk-noslice/Lib/test/output/test_opcodes Fri Dec 15 05:21:50 2006 +++ (empty file) @@ -1,6 +0,0 @@ -test_opcodes -2. Opcodes -XXX Not yet fully implemented -2.1 try inside for loop -2.2 raise class exceptions -2.3 comparing function objects Deleted: /python/branches/p3yk-noslice/Lib/test/output/test_openpty ============================================================================== --- /python/branches/p3yk-noslice/Lib/test/output/test_openpty Fri Dec 15 05:21:50 2006 +++ (empty file) @@ -1,2 +0,0 @@ -test_openpty -Ping! Deleted: /python/branches/p3yk-noslice/Lib/test/output/test_poll ============================================================================== --- /python/branches/p3yk-noslice/Lib/test/output/test_poll Fri Dec 15 05:21:50 2006 +++ (empty file) @@ -1,19 +0,0 @@ -test_poll -Running poll test 1 - This is a test. - This is a test. - This is a test. - This is a test. - This is a test. - This is a test. - This is a test. - This is a test. - This is a test. - This is a test. - This is a test. - This is a test. -Poll test 1 complete -Running poll test 2 -Poll test 2 complete -Running poll test 3 -Poll test 3 complete Modified: python/branches/p3yk-noslice/Lib/test/output/test_profile ============================================================================== --- python/branches/p3yk-noslice/Lib/test/output/test_profile (original) +++ python/branches/p3yk-noslice/Lib/test/output/test_profile Fri Dec 15 05:21:50 2006 @@ -1,11 +1,12 @@ test_profile - 127 function calls (107 primitive calls) in 1.000 CPU seconds + 128 function calls (108 primitive calls) in 1.000 CPU seconds Ordered by: standard name ncalls tottime percall cumtime percall filename:lineno(function) 4 0.000 0.000 0.000 0.000 :0(append) 4 0.000 0.000 0.000 0.000 :0(exc_info) + 1 0.000 0.000 1.000 1.000 :0(exec) 12 0.000 0.000 0.012 0.001 :0(hasattr) 8 0.000 0.000 0.000 0.000 :0(range) 1 0.000 0.000 0.000 0.000 :0(setprofile) @@ -28,13 +29,14 @@ Function called... :0(append) -> :0(exc_info) -> +:0(exec) -> :1()(1) 1.000 :0(hasattr) -> test_profile.py:115(__getattr__)(12) 0.028 :0(range) -> :0(setprofile) -> :1() -> test_profile.py:30(testfunc)(1) 1.000 profile:0(profiler) -> profile:0(testfunc())(1) 1.000 -profile:0(testfunc()) -> :0(setprofile)(1) 0.000 - :1()(1) 1.000 +profile:0(testfunc()) -> :0(exec)(1) 1.000 + :0(setprofile)(1) 0.000 test_profile.py:103(subhelper) -> :0(range)(8) 0.000 test_profile.py:115(__getattr__)(16) 0.028 test_profile.py:115(__getattr__) -> @@ -60,11 +62,12 @@ Function was called by... :0(append) <- test_profile.py:78(helper1)(4) 0.120 :0(exc_info) <- test_profile.py:78(helper1)(4) 0.120 +:0(exec) <- profile:0(testfunc())(1) 1.000 :0(hasattr) <- test_profile.py:78(helper1)(4) 0.120 test_profile.py:93(helper2)(8) 0.400 :0(range) <- test_profile.py:103(subhelper)(8) 0.080 :0(setprofile) <- profile:0(testfunc())(1) 1.000 -:1() <- profile:0(testfunc())(1) 1.000 +:1() <- :0(exec)(1) 1.000 profile:0(profiler) <- profile:0(testfunc()) <- profile:0(profiler)(1) 0.000 test_profile.py:103(subhelper) <- test_profile.py:93(helper2)(8) 0.400 Deleted: /python/branches/p3yk-noslice/Lib/test/output/test_regex ============================================================================== --- /python/branches/p3yk-noslice/Lib/test/output/test_regex Fri Dec 15 05:21:50 2006 +++ (empty file) @@ -1,29 +0,0 @@ -test_regex -no match: -1 -successful search: 6 -caught expected exception -failed awk syntax: -1 -successful awk syntax: 2 -failed awk syntax: -1 -matching with group names and compile() --1 -caught expected exception -matching with group names and symcomp() -7 -801 999 -801 -('801', '999') -('801', '999') -realpat: \([0-9]+\) *\([0-9]+\) -groupindex: {'one': 1, 'two': 2} -not case folded search: -1 -case folded search: 6 -__members__: ['last', 'regs', 'translate', 'groupindex', 'realpat', 'givenpat'] -regs: ((6, 11), (-1, -1), (-1, -1), (-1, -1), (-1, -1), (-1, -1), (-1, -1), (-1, -1), (-1, -1), (-1, -1), (-1, -1), (-1, -1), (-1, -1), (-1, -1), (-1, -1), (-1, -1), (-1, -1), (-1, -1), (-1, -1), (-1, -1), (-1, -1), (-1, -1), (-1, -1), (-1, -1), (-1, -1), (-1, -1), (-1, -1), (-1, -1), (-1, -1), (-1, -1), (-1, -1), (-1, -1), (-1, -1), (-1, -1), (-1, -1), (-1, -1), (-1, -1), (-1, -1), (-1, -1), (-1, -1), (-1, -1), (-1, -1), (-1, -1), (-1, -1), (-1, -1), (-1, -1), (-1, -1), (-1, -1), (-1, -1), (-1, -1), (-1, -1), (-1, -1), (-1, -1), (-1, -1), (-1, -1), (-1, -1), (-1, -1), (-1, -1), (-1, -1), (-1, -1), (-1, -1), (-1, -1), (-1, -1), (-1, -1), (-1, -1), (-1, -1), (-1, -1), (-1, -1), (-1, -1), (-1, -1), (-1, -1), (-1, -1), (-1, -1), (-1, -1), (-1, -1), (-1, -1), (-1, -1), (-1, -1), (-1, -1), (-1, -1), (-1, -1), (-1, -1), (-1, -1), (-1, -1), (-1, -1), (-1, -1), (-1, -1), (-1, -1), (-1, -1), (-1, -1), (-1, -1), (-1, -1), (-1, -1), (-1, -1), (-1, -1), (-1, -1), (-1, -1), (-1, -1), (-1, -1), (-1, -1)) -last: HELLO WORLD -translate: 256 -givenpat: world -match with pos: -1 -search with pos: 18 -bogus group: ('world', None, None) -no name: caught expected exception Deleted: /python/branches/p3yk-noslice/Lib/test/output/test_scope ============================================================================== --- /python/branches/p3yk-noslice/Lib/test/output/test_scope Fri Dec 15 05:21:50 2006 +++ (empty file) @@ -1,24 +0,0 @@ -test_scope -1. simple nesting -2. extra nesting -3. simple nesting + rebinding -4. nesting with global but no free -5. nesting through class -6. nesting plus free ref to global -7. nearest enclosing scope -8. mixed freevars and cellvars -9. free variable in method -10. recursion -11. unoptimized namespaces -12. lambdas -13. UnboundLocal -14. complex definitions -15. scope of global statements -16. check leaks -17. class and global -18. verify that locals() works -19. var is bound and free in class -20. interaction with trace function -20. eval and exec with free variables -21. list comprehension with local variables -22. eval with free variables Modified: python/branches/p3yk-noslice/Lib/test/output/test_tokenize ============================================================================== --- python/branches/p3yk-noslice/Lib/test/output/test_tokenize (original) +++ python/branches/p3yk-noslice/Lib/test/output/test_tokenize Fri Dec 15 05:21:50 2006 @@ -1,15 +1,23 @@ test_tokenize -1,0-1,35: COMMENT "# Tests for the 'tokenize' module.\n" -2,0-2,43: COMMENT '# Large bits stolen from test_grammar.py. \n' +1,0-1,34: COMMENT "# Tests for the 'tokenize' module." +1,34-1,35: NL '\n' +2,0-2,42: COMMENT '# Large bits stolen from test_grammar.py. ' +2,42-2,43: NL '\n' 3,0-3,1: NL '\n' -4,0-4,11: COMMENT '# Comments\n' +4,0-4,10: COMMENT '# Comments' +4,10-4,11: NL '\n' 5,0-5,3: STRING '"#"' 5,3-5,4: NEWLINE '\n' -6,0-6,3: COMMENT "#'\n" -7,0-7,3: COMMENT '#"\n' -8,0-8,3: COMMENT '#\\\n' -9,7-9,9: COMMENT '#\n' -10,4-10,10: COMMENT '# abc\n' +6,0-6,2: COMMENT "#'" +6,2-6,3: NL '\n' +7,0-7,2: COMMENT '#"' +7,2-7,3: NL '\n' +8,0-8,2: COMMENT '#\\' +8,2-8,3: NL '\n' +9,7-9,8: COMMENT '#' +9,8-9,9: NL '\n' +10,4-10,9: COMMENT '# abc' +10,9-10,10: NL '\n' 11,0-12,4: STRING "'''#\n#'''" 12,4-12,5: NEWLINE '\n' 13,0-13,1: NL '\n' @@ -19,7 +27,8 @@ 14,7-14,8: COMMENT '#' 14,8-14,9: NEWLINE '\n' 15,0-15,1: NL '\n' -16,0-16,25: COMMENT '# Balancing continuation\n' +16,0-16,24: COMMENT '# Balancing continuation' +16,24-16,25: NL '\n' 17,0-17,1: NL '\n' 18,0-18,1: NAME 'a' 18,2-18,3: OP '=' @@ -63,18 +72,19 @@ 24,4-24,5: OP '(' 24,5-24,8: NAME 'len' 24,8-24,9: OP '(' -24,9-24,10: OP '`' -24,10-24,11: NAME 'y' -24,11-24,12: OP '`' -24,12-24,13: OP ')' -24,14-24,15: OP '+' -24,16-24,17: NUMBER '5' -24,17-24,18: OP '*' -24,18-24,19: NAME 'x' -24,20-24,21: OP '-' -24,22-24,23: NAME 'a' -24,23-24,24: OP '[' -24,24-24,25: NL '\n' +24,9-24,13: NAME 'repr' +24,13-24,14: OP '(' +24,14-24,15: NAME 'y' +24,15-24,16: OP ')' +24,16-24,17: OP ')' +24,18-24,19: OP '+' +24,20-24,21: NUMBER '5' +24,21-24,22: OP '*' +24,22-24,23: NAME 'x' +24,24-24,25: OP '-' +24,26-24,27: NAME 'a' +24,27-24,28: OP '[' +24,28-24,29: NL '\n' 25,3-25,4: NUMBER '3' 25,5-25,6: OP ']' 25,6-25,7: NL '\n' @@ -92,7 +102,8 @@ 29,2-29,3: OP ')' 29,3-29,4: NEWLINE '\n' 30,0-30,1: NL '\n' -31,0-31,37: COMMENT '# Backslash means line continuation:\n' +31,0-31,36: COMMENT '# Backslash means line continuation:' +31,36-31,37: NL '\n' 32,0-32,1: NAME 'x' 32,2-32,3: OP '=' 32,4-32,5: NUMBER '1' @@ -100,19 +111,21 @@ 33,2-33,3: NUMBER '1' 33,3-33,4: NEWLINE '\n' 34,0-34,1: NL '\n' -35,0-35,55: COMMENT '# Backslash does not means continuation in comments :\\\n' +35,0-35,54: COMMENT '# Backslash does not means continuation in comments :\\' +35,54-35,55: NL '\n' 36,0-36,1: NAME 'x' 36,2-36,3: OP '=' 36,4-36,5: NUMBER '0' 36,5-36,6: NEWLINE '\n' 37,0-37,1: NL '\n' -38,0-38,20: COMMENT '# Ordinary integers\n' +38,0-38,19: COMMENT '# Ordinary integers' +38,19-38,20: NL '\n' 39,0-39,4: NUMBER '0xff' -39,5-39,7: OP '<>' +39,5-39,7: OP '!=' 39,8-39,11: NUMBER '255' 39,11-39,12: NEWLINE '\n' 40,0-40,4: NUMBER '0377' -40,5-40,7: OP '<>' +40,5-40,7: OP '!=' 40,8-40,11: NUMBER '255' 40,11-40,12: NEWLINE '\n' 41,0-41,10: NUMBER '2147483647' @@ -137,7 +150,8 @@ 44,15-44,16: NUMBER '1' 44,16-44,17: NEWLINE '\n' 45,0-45,1: NL '\n' -46,0-46,16: COMMENT '# Long integers\n' +46,0-46,15: COMMENT '# Long integers' +46,15-46,16: NL '\n' 47,0-47,1: NAME 'x' 47,2-47,3: OP '=' 47,4-47,6: NUMBER '0L' @@ -171,7 +185,8 @@ 54,4-54,35: NUMBER '123456789012345678901234567890l' 54,35-54,36: NEWLINE '\n' 55,0-55,1: NL '\n' -56,0-56,25: COMMENT '# Floating-point numbers\n' +56,0-56,24: COMMENT '# Floating-point numbers' +56,24-56,25: NL '\n' 57,0-57,1: NAME 'x' 57,2-57,3: OP '=' 57,4-57,8: NUMBER '3.14' @@ -184,7 +199,8 @@ 59,2-59,3: OP '=' 59,4-59,9: NUMBER '0.314' 59,9-59,10: NEWLINE '\n' -60,0-60,18: COMMENT '# XXX x = 000.314\n' +60,0-60,17: COMMENT '# XXX x = 000.314' +60,17-60,18: NL '\n' 61,0-61,1: NAME 'x' 61,2-61,3: OP '=' 61,4-61,8: NUMBER '.314' @@ -218,7 +234,8 @@ 68,4-68,9: NUMBER '3.1e4' 68,9-68,10: NEWLINE '\n' 69,0-69,1: NL '\n' -70,0-70,18: COMMENT '# String literals\n' +70,0-70,17: COMMENT '# String literals' +70,17-70,18: NL '\n' 71,0-71,1: NAME 'x' 71,2-71,3: OP '=' 71,4-71,6: STRING "''" @@ -366,7 +383,8 @@ 125,6-126,3: STRING "uR'''spam\n'''" 126,3-126,4: NEWLINE '\n' 127,0-127,1: NL '\n' -128,0-128,14: COMMENT '# Indentation\n' +128,0-128,13: COMMENT '# Indentation' +128,13-128,14: NL '\n' 129,0-129,2: NAME 'if' 129,3-129,4: NUMBER '1' 129,4-129,5: OP ':' @@ -438,7 +456,8 @@ 142,14-142,15: NUMBER '2' 142,15-142,16: NEWLINE '\n' 143,0-143,1: NL '\n' -144,0-144,12: COMMENT '# Operators\n' +144,0-144,11: COMMENT '# Operators' +144,11-144,12: NL '\n' 145,0-145,1: NL '\n' 146,0-146,0: DEDENT '' 146,0-146,0: DEDENT '' @@ -484,7 +503,7 @@ 149,2-149,3: OP ',' 149,4-149,5: NAME 'y' 149,5-149,6: OP ')' -149,7-149,9: OP '<>' +149,7-149,9: OP '!=' 149,10-149,11: OP '(' 149,11-149,12: OP '{' 149,12-149,15: STRING "'a'" @@ -500,7 +519,8 @@ 149,27-149,28: OP ')' 149,28-149,29: NEWLINE '\n' 150,0-150,1: NL '\n' -151,0-151,13: COMMENT '# comparison\n' +151,0-151,12: COMMENT '# comparison' +151,12-151,13: NL '\n' 152,0-152,2: NAME 'if' 152,3-152,4: NUMBER '1' 152,5-152,6: OP '<' @@ -513,7 +533,7 @@ 152,21-152,22: NUMBER '1' 152,23-152,25: OP '<=' 152,26-152,27: NUMBER '1' -152,28-152,30: OP '<>' +152,28-152,30: OP '!=' 152,31-152,32: NUMBER '1' 152,33-152,35: OP '!=' 152,36-152,37: NUMBER '1' @@ -531,7 +551,8 @@ 152,67-152,71: NAME 'pass' 152,71-152,72: NEWLINE '\n' 153,0-153,1: NL '\n' -154,0-154,9: COMMENT '# binary\n' +154,0-154,8: COMMENT '# binary' +154,8-154,9: NL '\n' 155,0-155,1: NAME 'x' 155,2-155,3: OP '=' 155,4-155,5: NUMBER '1' @@ -551,7 +572,8 @@ 157,8-157,9: NUMBER '1' 157,9-157,10: NEWLINE '\n' 158,0-158,1: NL '\n' -159,0-159,8: COMMENT '# shift\n' +159,0-159,7: COMMENT '# shift' +159,7-159,8: NL '\n' 160,0-160,1: NAME 'x' 160,2-160,3: OP '=' 160,4-160,5: NUMBER '1' @@ -561,7 +583,8 @@ 160,14-160,15: NUMBER '1' 160,15-160,16: NEWLINE '\n' 161,0-161,1: NL '\n' -162,0-162,11: COMMENT '# additive\n' +162,0-162,10: COMMENT '# additive' +162,10-162,11: NL '\n' 163,0-163,1: NAME 'x' 163,2-163,3: OP '=' 163,4-163,5: NUMBER '1' @@ -575,7 +598,8 @@ 163,20-163,21: NUMBER '1' 163,21-163,22: NEWLINE '\n' 164,0-164,1: NL '\n' -165,0-165,17: COMMENT '# multiplicative\n' +165,0-165,16: COMMENT '# multiplicative' +165,16-165,17: NL '\n' 166,0-166,1: NAME 'x' 166,2-166,3: OP '=' 166,4-166,5: NUMBER '1' @@ -587,7 +611,8 @@ 166,16-166,17: NUMBER '1' 166,17-166,18: NEWLINE '\n' 167,0-167,1: NL '\n' -168,0-168,8: COMMENT '# unary\n' +168,0-168,7: COMMENT '# unary' +168,7-168,8: NL '\n' 169,0-169,1: NAME 'x' 169,2-169,3: OP '=' 169,4-169,5: OP '~' @@ -625,7 +650,8 @@ 170,24-170,25: NUMBER '1' 170,25-170,26: NEWLINE '\n' 171,0-171,1: NL '\n' -172,0-172,11: COMMENT '# selector\n' +172,0-172,10: COMMENT '# selector' +172,10-172,11: NL '\n' 173,0-173,6: NAME 'import' 173,7-173,10: NAME 'sys' 173,10-173,11: OP ',' Deleted: /python/branches/p3yk-noslice/Lib/test/output/test_types ============================================================================== --- /python/branches/p3yk-noslice/Lib/test/output/test_types Fri Dec 15 05:21:50 2006 +++ (empty file) @@ -1,15 +0,0 @@ -test_types -6. Built-in types -6.1 Truth value testing -6.2 Boolean operations -6.3 Comparisons -6.4 Numeric types (mostly conversions) -6.4.1 32-bit integers -6.4.2 Long integers -6.4.3 Floating point numbers -6.5 Sequence types -6.5.1 Strings -6.5.2 Tuples [see test_tuple.py] -6.5.3 Lists [see test_list.py] -6.6 Mappings == Dictionaries [see test_dict.py] -Buffers Deleted: /python/branches/p3yk-noslice/Lib/test/output/test_xdrlib ============================================================================== --- /python/branches/p3yk-noslice/Lib/test/output/test_xdrlib Fri Dec 15 05:21:50 2006 +++ (empty file) @@ -1,19 +0,0 @@ -test_xdrlib -pack test 0 succeeded -pack test 1 succeeded -pack test 2 succeeded -pack test 3 succeeded -pack test 4 succeeded -pack test 5 succeeded -pack test 6 succeeded -pack test 7 succeeded -pack test 8 succeeded -unpack test 0 succeeded : 9 -unpack test 1 succeeded : True -unpack test 2 succeeded : False -unpack test 3 succeeded : 45 -unpack test 4 succeeded : 1.89999997616 -unpack test 5 succeeded : 1.9 -unpack test 6 succeeded : hello world -unpack test 7 succeeded : [0, 1, 2, 3, 4] -unpack test 8 succeeded : ['what', 'is', 'hapnin', 'doctor'] Modified: python/branches/p3yk-noslice/Lib/test/outstanding_bugs.py ============================================================================== --- python/branches/p3yk-noslice/Lib/test/outstanding_bugs.py (original) +++ python/branches/p3yk-noslice/Lib/test/outstanding_bugs.py Fri Dec 15 05:21:50 2006 @@ -9,19 +9,14 @@ import unittest from test import test_support -class TestBug1385040(unittest.TestCase): - def testSyntaxError(self): - import compiler - - # The following snippet gives a SyntaxError in the interpreter - # - # If you compile and exec it, the call foo(7) returns (7, 1) - self.assertRaises(SyntaxError, compiler.compile, - "def foo(a=1, b): return a, b\n\n", "", "exec") +# +# No test cases for outstanding bugs at the moment. +# def test_main(): - test_support.run_unittest(TestBug1385040) + #test_support.run_unittest() + pass if __name__ == "__main__": test_main() Modified: python/branches/p3yk-noslice/Lib/test/pickletester.py ============================================================================== --- python/branches/p3yk-noslice/Lib/test/pickletester.py (original) +++ python/branches/p3yk-noslice/Lib/test/pickletester.py Fri Dec 15 05:21:50 2006 @@ -65,8 +65,8 @@ copy_reg.add_extension(pair[0], pair[1], code) class C: - def __cmp__(self, other): - return cmp(self.__dict__, other.__dict__) + def __eq__(self, other): + return self.__dict__ == other.__dict__ import __main__ __main__.C = C Modified: python/branches/p3yk-noslice/Lib/test/string_tests.py ============================================================================== --- python/branches/p3yk-noslice/Lib/test/string_tests.py (original) +++ python/branches/p3yk-noslice/Lib/test/string_tests.py Fri Dec 15 05:21:50 2006 @@ -1055,7 +1055,7 @@ # from raymond's original specification S = 'http://www.python.org' self.checkequal(('http', '://', 'www.python.org'), S, 'rpartition', '://') - self.checkequal(('http://www.python.org', '', ''), S, 'rpartition', '?') + self.checkequal(('', '', 'http://www.python.org'), S, 'rpartition', '?') self.checkequal(('', 'http://', 'www.python.org'), S, 'rpartition', 'http://') self.checkequal(('http://www.python.', 'org', ''), S, 'rpartition', 'org') Modified: python/branches/p3yk-noslice/Lib/test/test_MimeWriter.py ============================================================================== --- python/branches/p3yk-noslice/Lib/test/test_MimeWriter.py (original) +++ python/branches/p3yk-noslice/Lib/test/test_MimeWriter.py Fri Dec 15 05:21:50 2006 @@ -7,6 +7,8 @@ """ +import unittest, sys, StringIO +from test.test_support import run_unittest from MimeWriter import MimeWriter @@ -77,94 +79,213 @@ ] -def main(): - import sys +OUTPUT = '''\ +From: bwarsaw at cnri.reston.va.us +Date: Mon Feb 12 17:21:48 EST 1996 +To: kss-submit at cnri.reston.va.us +MIME-Version: 1.0 +Content-Type: multipart/knowbot; + boundary="801spam999"; + version="0.1" + +This is a multi-part message in MIME format. + +--801spam999 +Content-Type: multipart/knowbot-metadata; + boundary="802spam999" + + +--802spam999 +Content-Type: message/rfc822 +KP-Metadata-Type: simple +KP-Access: read-only + +KPMD-Interpreter: python +KPMD-Interpreter-Version: 1.3 +KPMD-Owner-Name: Barry Warsaw +KPMD-Owner-Rendezvous: bwarsaw at cnri.reston.va.us +KPMD-Home-KSS: kss.cnri.reston.va.us +KPMD-Identifier: hdl://cnri.kss/my_first_knowbot +KPMD-Launch-Date: Mon Feb 12 16:39:03 EST 1996 + +--802spam999 +Content-Type: text/isl +KP-Metadata-Type: complex +KP-Metadata-Key: connection +KP-Access: read-only +KP-Connection-Description: Barry's Big Bass Business +KP-Connection-Id: B4 +KP-Connection-Direction: client - # Toplevel headers +INTERFACE Seller-1; + +TYPE Seller = OBJECT + DOCUMENTATION "A simple Seller interface to test ILU" + METHODS + price():INTEGER, + END; + +--802spam999 +Content-Type: message/external-body; + access-type="URL"; + URL="hdl://cnri.kss/generic-knowbot" + +Content-Type: text/isl +KP-Metadata-Type: complex +KP-Metadata-Key: generic-interface +KP-Access: read-only +KP-Connection-Description: Generic Interface for All Knowbots +KP-Connection-Id: generic-kp +KP-Connection-Direction: client + + +--802spam999-- + +--801spam999 +Content-Type: multipart/knowbot-code; + boundary="803spam999" + + +--803spam999 +Content-Type: text/plain +KP-Module-Name: BuyerKP + +class Buyer: + def __setup__(self, maxprice): + self._maxprice = maxprice + + def __main__(self, kos): + """Entry point upon arrival at a new KOS.""" + broker = kos.broker() + # B4 == Barry's Big Bass Business :-) + seller = broker.lookup('Seller_1.Seller', 'B4') + if seller: + price = seller.price() + print 'Seller wants $', price, '... ' + if price > self._maxprice: + print 'too much!' + else: + print "I'll take it!" + else: + print 'no seller found here' + +--803spam999-- + +--801spam999 +Content-Type: multipart/knowbot-state; + boundary="804spam999" +KP-Main-Module: main + + +--804spam999 +Content-Type: text/plain +KP-Module-Name: main + +# instantiate a buyer instance and put it in a magic place for the KOS +# to find. +__kp__ = Buyer() +__kp__.__setup__(500) + +--804spam999-- + +--801spam999-- +''' + +class MimewriterTest(unittest.TestCase): + + def test(self): + buf = StringIO.StringIO() + + # Toplevel headers + + toplevel = MimeWriter(buf) + toplevel.addheader("From", "bwarsaw at cnri.reston.va.us") + toplevel.addheader("Date", "Mon Feb 12 17:21:48 EST 1996") + toplevel.addheader("To", "kss-submit at cnri.reston.va.us") + toplevel.addheader("MIME-Version", "1.0") - toplevel = MimeWriter(sys.stdout) - toplevel.addheader("From", "bwarsaw at cnri.reston.va.us") - toplevel.addheader("Date", "Mon Feb 12 17:21:48 EST 1996") - toplevel.addheader("To", "kss-submit at cnri.reston.va.us") - toplevel.addheader("MIME-Version", "1.0") + # Toplevel body parts - # Toplevel body parts + f = toplevel.startmultipartbody("knowbot", "801spam999", + [("version", "0.1")], prefix=0) + f.write("This is a multi-part message in MIME format.\n") - f = toplevel.startmultipartbody("knowbot", "801spam999", - [("version", "0.1")], prefix=0) - f.write("This is a multi-part message in MIME format.\n") + # First toplevel body part: metadata - # First toplevel body part: metadata + md = toplevel.nextpart() + md.startmultipartbody("knowbot-metadata", "802spam999") - md = toplevel.nextpart() - md.startmultipartbody("knowbot-metadata", "802spam999") + # Metadata part 1 - # Metadata part 1 + md1 = md.nextpart() + md1.addheader("KP-Metadata-Type", "simple") + md1.addheader("KP-Access", "read-only") + m = MimeWriter(md1.startbody("message/rfc822")) + for key, value in SIMPLE_METADATA: + m.addheader("KPMD-" + key, value) + m.flushheaders() + del md1 - md1 = md.nextpart() - md1.addheader("KP-Metadata-Type", "simple") - md1.addheader("KP-Access", "read-only") - m = MimeWriter(md1.startbody("message/rfc822")) - for key, value in SIMPLE_METADATA: - m.addheader("KPMD-" + key, value) - m.flushheaders() - del md1 + # Metadata part 2 - # Metadata part 2 + md2 = md.nextpart() + for key, value in COMPLEX_METADATA: + md2.addheader("KP-" + key, value) + f = md2.startbody("text/isl") + f.write(SELLER) + del md2 - md2 = md.nextpart() - for key, value in COMPLEX_METADATA: - md2.addheader("KP-" + key, value) - f = md2.startbody("text/isl") - f.write(SELLER) - del md2 + # Metadata part 3 - # Metadata part 3 + md3 = md.nextpart() + f = md3.startbody("message/external-body", + [("access-type", "URL"), + ("URL", "hdl://cnri.kss/generic-knowbot")]) + m = MimeWriter(f) + for key, value in EXTERNAL_METADATA: + md3.addheader("KP-" + key, value) + md3.startbody("text/isl") + # Phantom body doesn't need to be written - md3 = md.nextpart() - f = md3.startbody("message/external-body", - [("access-type", "URL"), - ("URL", "hdl://cnri.kss/generic-knowbot")]) - m = MimeWriter(f) - for key, value in EXTERNAL_METADATA: - md3.addheader("KP-" + key, value) - md3.startbody("text/isl") - # Phantom body doesn't need to be written + md.lastpart() - md.lastpart() + # Second toplevel body part: code - # Second toplevel body part: code + code = toplevel.nextpart() + code.startmultipartbody("knowbot-code", "803spam999") - code = toplevel.nextpart() - code.startmultipartbody("knowbot-code", "803spam999") + # Code: buyer program source - # Code: buyer program source + buyer = code.nextpart() + buyer.addheader("KP-Module-Name", "BuyerKP") + f = buyer.startbody("text/plain") + f.write(BUYER) - buyer = code.nextpart() - buyer.addheader("KP-Module-Name", "BuyerKP") - f = buyer.startbody("text/plain") - f.write(BUYER) + code.lastpart() - code.lastpart() + # Third toplevel body part: state - # Third toplevel body part: state + state = toplevel.nextpart() + state.addheader("KP-Main-Module", "main") + state.startmultipartbody("knowbot-state", "804spam999") - state = toplevel.nextpart() - state.addheader("KP-Main-Module", "main") - state.startmultipartbody("knowbot-state", "804spam999") + # State: a bunch of assignments - # State: a bunch of assignments + st = state.nextpart() + st.addheader("KP-Module-Name", "main") + f = st.startbody("text/plain") + f.write(STATE) - st = state.nextpart() - st.addheader("KP-Module-Name", "main") - f = st.startbody("text/plain") - f.write(STATE) + state.lastpart() - state.lastpart() + # End toplevel body parts - # End toplevel body parts + toplevel.lastpart() - toplevel.lastpart() + self.assertEqual(buf.getvalue(), OUTPUT) +def test_main(): + run_unittest(MimewriterTest) -main() +if __name__ == '__main__': + test_main() Modified: python/branches/p3yk-noslice/Lib/test/test_StringIO.py ============================================================================== --- python/branches/p3yk-noslice/Lib/test/test_StringIO.py (original) +++ python/branches/p3yk-noslice/Lib/test/test_StringIO.py Fri Dec 15 05:21:50 2006 @@ -62,6 +62,7 @@ eq(f.getvalue(), 'abcde') f.write('xyz') eq(f.getvalue(), 'abcdexyz') + self.assertRaises(IOError, f.truncate, -1) f.close() self.assertRaises(ValueError, f.write, 'frobnitz') @@ -120,6 +121,28 @@ class TestcStringIO(TestGenericStringIO): MODULE = cStringIO + def test_unicode(self): + + if not test_support.have_unicode: return + + # The cStringIO module converts Unicode strings to character + # strings when writing them to cStringIO objects. + # Check that this works. + + f = self.MODULE.StringIO() + f.write(unicode(self._line[:5])) + s = f.getvalue() + self.assertEqual(s, 'abcde') + self.assertEqual(type(s), types.StringType) + + f = self.MODULE.StringIO(unicode(self._line[:5])) + s = f.getvalue() + self.assertEqual(s, 'abcde') + self.assertEqual(type(s), types.StringType) + + self.assertRaises(UnicodeEncodeError, self.MODULE.StringIO, + unicode('\xf4', 'latin-1')) + import sys if sys.platform.startswith('java'): # Jython doesn't have a buffer object, so we just do a useless Modified: python/branches/p3yk-noslice/Lib/test/test___all__.py ============================================================================== --- python/branches/p3yk-noslice/Lib/test/test___all__.py (original) +++ python/branches/p3yk-noslice/Lib/test/test___all__.py Fri Dec 15 05:21:50 2006 @@ -15,7 +15,7 @@ def check_all(self, modname): names = {} try: - exec "import %s" % modname in names + exec("import %s" % modname, names) except ImportError: # Silent fail here seems the best route since some modules # may not be available in all environments. @@ -23,7 +23,7 @@ verify(hasattr(sys.modules[modname], "__all__"), "%s has no __all__ attribute" % modname) names = {} - exec "from %s import *" % modname in names + exec("from %s import *" % modname, names) if "__builtins__" in names: del names["__builtins__"] keys = set(names) Modified: python/branches/p3yk-noslice/Lib/test/test___future__.py ============================================================================== --- python/branches/p3yk-noslice/Lib/test/test___future__.py (original) +++ python/branches/p3yk-noslice/Lib/test/test___future__.py Fri Dec 15 05:21:50 2006 @@ -1,59 +1,63 @@ #! /usr/bin/env python -from test.test_support import verbose, verify -from types import TupleType, StringType, IntType +import unittest +from test import test_support import __future__ GOOD_SERIALS = ("alpha", "beta", "candidate", "final") features = __future__.all_feature_names -# Verify that all_feature_names appears correct. -given_feature_names = features[:] -for name in dir(__future__): - obj = getattr(__future__, name, None) - if obj is not None and isinstance(obj, __future__._Feature): - verify(name in given_feature_names, - "%r should have been in all_feature_names" % name) - given_feature_names.remove(name) -verify(len(given_feature_names) == 0, - "all_feature_names has too much: %r" % given_feature_names) -del given_feature_names - -for feature in features: - value = getattr(__future__, feature) - if verbose: - print "Checking __future__ ", feature, "value", value - - optional = value.getOptionalRelease() - mandatory = value.getMandatoryRelease() - - verify(type(optional) is TupleType, "optional isn't tuple") - verify(len(optional) == 5, "optional isn't 5-tuple") - major, minor, micro, level, serial = optional - verify(type(major) is IntType, "optional major isn't int") - verify(type(minor) is IntType, "optional minor isn't int") - verify(type(micro) is IntType, "optional micro isn't int") - verify(isinstance(level, basestring), "optional level isn't string") - verify(level in GOOD_SERIALS, - "optional level string has unknown value") - verify(type(serial) is IntType, "optional serial isn't int") - - verify(type(mandatory) is TupleType or - mandatory is None, "mandatory isn't tuple or None") - if mandatory is not None: - verify(len(mandatory) == 5, "mandatory isn't 5-tuple") - major, minor, micro, level, serial = mandatory - verify(type(major) is IntType, "mandatory major isn't int") - verify(type(minor) is IntType, "mandatory minor isn't int") - verify(type(micro) is IntType, "mandatory micro isn't int") - verify(isinstance(level, basestring), "mandatory level isn't string") - verify(level in GOOD_SERIALS, - "mandatory serial string has unknown value") - verify(type(serial) is IntType, "mandatory serial isn't int") - verify(optional < mandatory, - "optional not less than mandatory, and mandatory not None") - - verify(hasattr(value, "compiler_flag"), - "feature is missing a .compiler_flag attr") - verify(type(getattr(value, "compiler_flag")) is IntType, - ".compiler_flag isn't int") +class FutureTest(unittest.TestCase): + + def test_names(self): + # Verify that all_feature_names appears correct. + given_feature_names = features[:] + for name in dir(__future__): + obj = getattr(__future__, name, None) + if obj is not None and isinstance(obj, __future__._Feature): + self.assert_( + name in given_feature_names, + "%r should have been in all_feature_names" % name + ) + given_feature_names.remove(name) + self.assertEqual(len(given_feature_names), 0, + "all_feature_names has too much: %r" % given_feature_names) + + def test_attributes(self): + for feature in features: + value = getattr(__future__, feature) + + optional = value.getOptionalRelease() + mandatory = value.getMandatoryRelease() + + a = self.assert_ + e = self.assertEqual + def check(t, name): + a(isinstance(t, tuple), "%s isn't tuple" % name) + e(len(t), 5, "%s isn't 5-tuple" % name) + (major, minor, micro, level, serial) = t + a(isinstance(major, int), "%s major isn't int" % name) + a(isinstance(minor, int), "%s minor isn't int" % name) + a(isinstance(micro, int), "%s micro isn't int" % name) + a(isinstance(level, basestring), + "%s level isn't string" % name) + a(level in GOOD_SERIALS, + "%s level string has unknown value" % name) + a(isinstance(serial, int), "%s serial isn't int" % name) + + check(optional, "optional") + if mandatory is not None: + check(mandatory, "mandatory") + a(optional < mandatory, + "optional not less than mandatory, and mandatory not None") + + a(hasattr(value, "compiler_flag"), + "feature is missing a .compiler_flag attr") + a(isinstance(getattr(value, "compiler_flag"), int), + ".compiler_flag isn't int") + +def test_main(): + test_support.run_unittest(FutureTest) + +if __name__ == "__main__": + test_main() Modified: python/branches/p3yk-noslice/Lib/test/test_array.py ============================================================================== --- python/branches/p3yk-noslice/Lib/test/test_array.py (original) +++ python/branches/p3yk-noslice/Lib/test/test_array.py Fri Dec 15 05:21:50 2006 @@ -85,6 +85,13 @@ self.assertNotEqual(id(a), id(b)) self.assertEqual(a, b) + def test_deepcopy(self): + import copy + a = array.array(self.typecode, self.example) + b = copy.deepcopy(a) + self.assertNotEqual(id(a), id(b)) + self.assertEqual(a, b) + def test_pickle(self): for protocol in (0, 1, 2): a = array.array(self.typecode, self.example) Modified: python/branches/p3yk-noslice/Lib/test/test_ast.py ============================================================================== --- python/branches/p3yk-noslice/Lib/test/test_ast.py (original) +++ python/branches/p3yk-noslice/Lib/test/test_ast.py Fri Dec 15 05:21:50 2006 @@ -50,8 +50,6 @@ "import sys", # ImportFrom "from sys import v", - # Exec - "exec 'v'", # Global "global v", # Expr @@ -94,8 +92,6 @@ "1 < 2 < 3", # Call "f(1,2,c=3,*d,**e)", - # Repr - "`v`", # Num "10L", # Str @@ -155,9 +151,9 @@ #### EVERYTHING BELOW IS GENERATED ##### exec_results = [ -('Module', [('FunctionDef', (1, 0), 'f', ('arguments', [], None, None, []), [('Pass', (1, 9))], [])]), +('Module', [('FunctionDef', (1, 0), 'f', ('arguments', [], None, [], None, [], []), [('Pass', (1, 9))], [])]), ('Module', [('ClassDef', (1, 0), 'C', [], [('Pass', (1, 8))])]), -('Module', [('FunctionDef', (1, 0), 'f', ('arguments', [], None, None, []), [('Return', (1, 8), ('Num', (1, 15), 1))], [])]), +('Module', [('FunctionDef', (1, 0), 'f', ('arguments', [], None, [], None, [], []), [('Return', (1, 8), ('Num', (1, 15), 1))], [])]), ('Module', [('Delete', (1, 0), [('Name', (1, 4), 'v', ('Del',))])]), ('Module', [('Assign', (1, 0), [('Name', (1, 0), 'v', ('Store',))], ('Num', (1, 4), 1))]), ('Module', [('AugAssign', (1, 0), ('Name', (1, 0), 'v', ('Store',)), ('Add',), ('Num', (1, 5), 1))]), @@ -171,7 +167,6 @@ ('Module', [('Assert', (1, 0), ('Name', (1, 7), 'v', ('Load',)), None)]), ('Module', [('Import', (1, 0), [('alias', 'sys', None)])]), ('Module', [('ImportFrom', (1, 0), 'sys', [('alias', 'v', None)], 0)]), -('Module', [('Exec', (1, 0), ('Str', (1, 5), 'v'), None, None)]), ('Module', [('Global', (1, 0), ['v'])]), ('Module', [('Expr', (1, 0), ('Num', (1, 0), 1))]), ('Module', [('Pass', (1, 0))]), @@ -185,13 +180,12 @@ ('Expression', ('BoolOp', (1, 0), ('And',), [('Name', (1, 0), 'a', ('Load',)), ('Name', (1, 6), 'b', ('Load',))])), ('Expression', ('BinOp', (1, 0), ('Name', (1, 0), 'a', ('Load',)), ('Add',), ('Name', (1, 4), 'b', ('Load',)))), ('Expression', ('UnaryOp', (1, 0), ('Not',), ('Name', (1, 4), 'v', ('Load',)))), -('Expression', ('Lambda', (1, 0), ('arguments', [], None, None, []), ('Name', (1, 7), 'None', ('Load',)))), +('Expression', ('Lambda', (1, 0), ('arguments', [], None, [], None, [], []), ('Name', (1, 7), 'None', ('Load',)))), ('Expression', ('Dict', (1, 0), [('Num', (1, 2), 1)], [('Num', (1, 4), 2)])), ('Expression', ('ListComp', (1, 1), ('Name', (1, 1), 'a', ('Load',)), [('comprehension', ('Name', (1, 7), 'b', ('Store',)), ('Name', (1, 12), 'c', ('Load',)), [('Name', (1, 17), 'd', ('Load',))])])), ('Expression', ('GeneratorExp', (1, 1), ('Name', (1, 1), 'a', ('Load',)), [('comprehension', ('Name', (1, 7), 'b', ('Store',)), ('Name', (1, 12), 'c', ('Load',)), [('Name', (1, 17), 'd', ('Load',))])])), ('Expression', ('Compare', (1, 0), ('Num', (1, 0), 1), [('Lt',), ('Lt',)], [('Num', (1, 4), 2), ('Num', (1, 8), 3)])), ('Expression', ('Call', (1, 0), ('Name', (1, 0), 'f', ('Load',)), [('Num', (1, 2), 1), ('Num', (1, 4), 2)], [('keyword', 'c', ('Num', (1, 8), 3))], ('Name', (1, 11), 'd', ('Load',)), ('Name', (1, 15), 'e', ('Load',)))), -('Expression', ('Repr', (1, 0), ('Name', (1, 1), 'v', ('Load',)))), ('Expression', ('Num', (1, 0), 10L)), ('Expression', ('Str', (1, 0), 'string')), ('Expression', ('Attribute', (1, 0), ('Name', (1, 0), 'a', ('Load',)), 'b', ('Load',))), Modified: python/branches/p3yk-noslice/Lib/test/test_binascii.py ============================================================================== --- python/branches/p3yk-noslice/Lib/test/test_binascii.py (original) +++ python/branches/p3yk-noslice/Lib/test/test_binascii.py Fri Dec 15 05:21:50 2006 @@ -134,7 +134,7 @@ pass else: self.fail("binascii.a2b_qp(**{1:1}) didn't raise TypeError") - self.assertEqual(binascii.a2b_qp("= "), "") + self.assertEqual(binascii.a2b_qp("= "), "= ") self.assertEqual(binascii.a2b_qp("=="), "=") self.assertEqual(binascii.a2b_qp("=AX"), "=AX") self.assertRaises(TypeError, binascii.b2a_qp, foo="bar") Modified: python/branches/p3yk-noslice/Lib/test/test_binop.py ============================================================================== --- python/branches/p3yk-noslice/Lib/test/test_binop.py (original) +++ python/branches/p3yk-noslice/Lib/test/test_binop.py Fri Dec 15 05:21:50 2006 @@ -302,7 +302,7 @@ self.assertEqual(10.0, Rat(10)) def test_future_div(self): - exec future_test + exec(future_test) # XXX Ran out of steam; TO DO: divmod, div, future division Modified: python/branches/p3yk-noslice/Lib/test/test_bisect.py ============================================================================== --- python/branches/p3yk-noslice/Lib/test/test_bisect.py (original) +++ python/branches/p3yk-noslice/Lib/test/test_bisect.py Fri Dec 15 05:21:50 2006 @@ -174,8 +174,13 @@ class CmpErr: "Dummy element that always raises an error during comparison" - def __cmp__(self, other): + def __lt__(self, other): raise ZeroDivisionError + __gt__ = __lt__ + __le__ = __lt__ + __ge__ = __lt__ + __eq__ = __lt__ + __ne__ = __lt__ class TestErrorHandling(unittest.TestCase): Modified: python/branches/p3yk-noslice/Lib/test/test_bool.py ============================================================================== --- python/branches/p3yk-noslice/Lib/test/test_bool.py (original) +++ python/branches/p3yk-noslice/Lib/test/test_bool.py Fri Dec 15 05:21:50 2006 @@ -246,7 +246,7 @@ def test_fileclosed(self): try: - f = file(test_support.TESTFN, "w") + f = open(test_support.TESTFN, "w") self.assertIs(f.closed, False) f.close() self.assertIs(f.closed, True) @@ -335,24 +335,51 @@ def test_convert_to_bool(self): # Verify that TypeError occurs when bad things are returned - # from __nonzero__(). This isn't really a bool test, but + # from __bool__(). This isn't really a bool test, but # it's related. check = lambda o: self.assertRaises(TypeError, bool, o) class Foo(object): - def __nonzero__(self): + def __bool__(self): return self check(Foo()) class Bar(object): - def __nonzero__(self): + def __bool__(self): return "Yes" check(Bar()) class Baz(int): - def __nonzero__(self): + def __bool__(self): return self check(Baz()) + # __bool__() must return a bool not an int + class Spam(int): + def __bool__(self): + return 1 + check(Spam()) + + class Eggs: + def __len__(self): + return -1 + self.assertRaises(ValueError, bool, Eggs()) + + def test_sane_len(self): + # this test just tests our assumptions about __len__ + # this will start failing if __len__ changes assertions + for badval in ['illegal', -1, 1 << 32]: + class A: + def __len__(self): + return badval + try: + bool(A()) + except (Exception), e_bool: + pass + try: + len(A()) + except (Exception), e_len: + pass + self.assertEqual(str(e_bool), str(e_len)) def test_main(): test_support.run_unittest(BoolTest) Modified: python/branches/p3yk-noslice/Lib/test/test_bsddb3.py ============================================================================== --- python/branches/p3yk-noslice/Lib/test/test_bsddb3.py (original) +++ python/branches/p3yk-noslice/Lib/test/test_bsddb3.py Fri Dec 15 05:21:50 2006 @@ -8,7 +8,7 @@ # When running as a script instead of within the regrtest framework, skip the # requires test, since it's obvious we want to run them. -if __name__ <> '__main__': +if __name__ != '__main__': requires('bsddb') verbose = False Modified: python/branches/p3yk-noslice/Lib/test/test_bufio.py ============================================================================== --- python/branches/p3yk-noslice/Lib/test/test_bufio.py (original) +++ python/branches/p3yk-noslice/Lib/test/test_bufio.py Fri Dec 15 05:21:50 2006 @@ -1,60 +1,66 @@ -from test.test_support import verify, TestFailed, TESTFN +import unittest +from test import test_support # Simple test to ensure that optimizations in fileobject.c deliver # the expected results. For best testing, run this under a debug-build # Python too (to exercise asserts in the C code). -# Repeat string 'pattern' as often as needed to reach total length -# 'length'. Then call try_one with that string, a string one larger -# than that, and a string one smaller than that. The main driver -# feeds this all small sizes and various powers of 2, so we exercise -# all likely stdio buffer sizes, and "off by one" errors on both -# sides. -def drive_one(pattern, length): - q, r = divmod(length, len(pattern)) - teststring = pattern * q + pattern[:r] - verify(len(teststring) == length) - try_one(teststring) - try_one(teststring + "x") - try_one(teststring[:-1]) - -# Write s + "\n" + s to file, then open it and ensure that successive -# .readline()s deliver what we wrote. -def try_one(s): - # Since C doesn't guarantee we can write/read arbitrary bytes in text - # files, use binary mode. - f = open(TESTFN, "wb") - # write once with \n and once without - f.write(s) - f.write("\n") - f.write(s) - f.close() - f = open(TESTFN, "rb") - line = f.readline() - if line != s + "\n": - raise TestFailed("Expected %r got %r" % (s + "\n", line)) - line = f.readline() - if line != s: - raise TestFailed("Expected %r got %r" % (s, line)) - line = f.readline() - if line: - raise TestFailed("Expected EOF but got %r" % line) - f.close() - -# A pattern with prime length, to avoid simple relationships with -# stdio buffer sizes. -primepat = "1234567890\00\01\02\03\04\05\06" - -nullpat = "\0" * 1000 - -try: - for size in range(1, 257) + [512, 1000, 1024, 2048, 4096, 8192, 10000, - 16384, 32768, 65536, 1000000]: - drive_one(primepat, size) - drive_one(nullpat, size) -finally: - try: - import os - os.unlink(TESTFN) - except: - pass +lengths = range(1, 257) + [512, 1000, 1024, 2048, 4096, 8192, 10000, + 16384, 32768, 65536, 1000000] + +class BufferSizeTest(unittest.TestCase): + def try_one(self, s): + # Write s + "\n" + s to file, then open it and ensure that successive + # .readline()s deliver what we wrote. + + # Since C doesn't guarantee we can write/read arbitrary bytes in text + # files, use binary mode. + f = open(test_support.TESTFN, "wb") + try: + # write once with \n and once without + f.write(s) + f.write("\n") + f.write(s) + f.close() + f = open(test_support.TESTFN, "rb") + line = f.readline() + self.assertEqual(line, s + "\n") + line = f.readline() + self.assertEqual(line, s) + line = f.readline() + self.assert_(not line) # Must be at EOF + f.close() + finally: + try: + import os + os.unlink(test_support.TESTFN) + except: + pass + + def drive_one(self, pattern): + for length in lengths: + # Repeat string 'pattern' as often as needed to reach total length + # 'length'. Then call try_one with that string, a string one larger + # than that, and a string one smaller than that. Try this with all + # small sizes and various powers of 2, so we exercise all likely + # stdio buffer sizes, and "off by one" errors on both sides. + q, r = divmod(length, len(pattern)) + teststring = pattern * q + pattern[:r] + self.assertEqual(len(teststring), length) + self.try_one(teststring) + self.try_one(teststring + "x") + self.try_one(teststring[:-1]) + + def test_primepat(self): + # A pattern with prime length, to avoid simple relationships with + # stdio buffer sizes. + self.drive_one("1234567890\00\01\02\03\04\05\06") + + def test_nullpat(self): + self.drive_one("\0" * 1000) + +def test_main(): + test_support.run_unittest(BufferSizeTest) + +if __name__ == "__main__": + test_main() Modified: python/branches/p3yk-noslice/Lib/test/test_builtin.py ============================================================================== --- python/branches/p3yk-noslice/Lib/test/test_builtin.py (original) +++ python/branches/p3yk-noslice/Lib/test/test_builtin.py Fri Dec 15 05:21:50 2006 @@ -94,7 +94,7 @@ ] class TestFailingBool: - def __nonzero__(self): + def __bool__(self): raise RuntimeError class TestFailingIter: @@ -116,6 +116,7 @@ self.assertEqual(abs(0), 0) self.assertEqual(abs(1234), 1234) self.assertEqual(abs(-1234), 1234) + self.assertTrue(abs(-sys.maxint-1) > 0) # float self.assertEqual(abs(0.0), 0.0) self.assertEqual(abs(3.14), 3.14) @@ -155,6 +156,11 @@ S = [10, 20, 30] self.assertEqual(any(x > 42 for x in S), False) + def test_neg(self): + x = -sys.maxint-1 + self.assert_(isinstance(x, int)) + self.assertEqual(-x, sys.maxint+1) + def test_callable(self): self.assert_(callable(len)) def f(): pass @@ -179,7 +185,8 @@ self.assertRaises(ValueError, chr, 256) self.assertRaises(TypeError, chr) - def test_cmp(self): + def XXX_test_cmp(self): + # cmp() is no longer supported self.assertEqual(cmp(-1, 1), -1) self.assertEqual(cmp(1, -1), 1) self.assertEqual(cmp(1, 1), 0) @@ -397,6 +404,29 @@ self.assertRaises(IOError, execfile, os.curdir) self.assertRaises(IOError, execfile, "I_dont_exist") + def test_exec(self): + g = {} + exec('z = 1', g) + if '__builtins__' in g: + del g['__builtins__'] + self.assertEqual(g, {'z': 1}) + + exec(u'z = 1+1', g) + if '__builtins__' in g: + del g['__builtins__'] + self.assertEqual(g, {'z': 2}) + g = {} + l = {} + + import warnings + warnings.filterwarnings("ignore", "global statement", module="") + exec('global a; a = 1; b = 2', g, l) + if '__builtins__' in g: + del g['__builtins__'] + if '__builtins__' in l: + del l['__builtins__'] + self.assertEqual((g, l), ({'a': 1}, {'b': 2})) + def test_filter(self): self.assertEqual(filter(lambda c: 'a' <= c <= 'z', 'Hello World'), 'elloorld') self.assertEqual(filter(None, [1, 'hello', [], [3], '', None, 9, 0]), [1, 'hello', [3], 9]) @@ -665,9 +695,11 @@ pass s = repr(-1-sys.maxint) - self.assertEqual(int(s)+1, -sys.maxint) + x = int(s) + self.assertEqual(x+1, -sys.maxint) + self.assert_(isinstance(x, int)) # should return long - int(s[1:]) + self.assertEqual(int(s[1:]), sys.maxint+1) # should return long x = int(1e100) @@ -685,6 +717,11 @@ self.assertRaises(ValueError, int, '123\0') self.assertRaises(ValueError, int, '53', 40) + # SF bug 1545497: embedded NULs were not detected with + # explicit base + self.assertRaises(ValueError, int, '123\0', 10) + self.assertRaises(ValueError, int, '123\x00 245', 20) + x = int('1' * 600) self.assert_(isinstance(x, long)) @@ -1135,8 +1172,14 @@ map(None, Squares(3), Squares(2)), [(0,0), (1,1), (4,None)] ) + def Max(a, b): + if a is None: + return b + if b is None: + return a + return max(a, b) self.assertEqual( - map(max, Squares(3), Squares(2)), + map(Max, Squares(3), Squares(2)), [0, 1, 4] ) self.assertRaises(TypeError, map) @@ -1168,7 +1211,7 @@ "max(1, 2, key=1)", # keyfunc is not callable ): try: - exec(stmt) in globals() + exec(stmt, globals()) except TypeError: pass else: @@ -1204,7 +1247,7 @@ class BadNumber: def __cmp__(self, other): raise ValueError - self.assertRaises(ValueError, min, (42, BadNumber())) + self.assertRaises(TypeError, min, (42, BadNumber())) for stmt in ( "min(key=int)", # no args @@ -1214,7 +1257,7 @@ "min(1, 2, key=1)", # keyfunc is not callable ): try: - exec(stmt) in globals() + exec(stmt, globals()) except TypeError: pass else: @@ -1382,8 +1425,11 @@ self.assertRaises(ValueError, range, a, a + 1, long(0)) class badzero(int): - def __cmp__(self, other): + def __eq__(self, other): raise RuntimeError + __ne__ = __lt__ = __gt__ = __le__ = __ge__ = __eq__ + + # XXX This won't (but should!) raise RuntimeError if a is an int... self.assertRaises(RuntimeError, range, a, a + 1, badzero(1)) # Reject floats when it would require PyLongs to represent. @@ -1547,18 +1593,18 @@ a = (1, 2, 3) b = (4, 5, 6) t = [(1, 4), (2, 5), (3, 6)] - self.assertEqual(zip(a, b), t) + self.assertEqual(list(zip(a, b)), t) b = [4, 5, 6] - self.assertEqual(zip(a, b), t) + self.assertEqual(list(zip(a, b)), t) b = (4, 5, 6, 7) - self.assertEqual(zip(a, b), t) + self.assertEqual(list(zip(a, b)), t) class I: def __getitem__(self, i): if i < 0 or i > 2: raise IndexError return i + 4 - self.assertEqual(zip(a, I()), t) - self.assertEqual(zip(), []) - self.assertEqual(zip(*[]), []) + self.assertEqual(list(zip(a, I())), t) + self.assertEqual(list(zip()), []) + self.assertEqual(list(zip(*[])), []) self.assertRaises(TypeError, zip, None) class G: pass @@ -1574,7 +1620,7 @@ else: return i self.assertEqual( - zip(SequenceWithoutALength(), xrange(2**30)), + list(zip(SequenceWithoutALength(), xrange(2**30))), list(enumerate(range(5))) ) @@ -1584,7 +1630,7 @@ raise ValueError else: return i - self.assertRaises(ValueError, zip, BadSeq(), BadSeq()) + self.assertRaises(ValueError, list, zip(BadSeq(), BadSeq())) class TestSorted(unittest.TestCase): @@ -1597,7 +1643,7 @@ data.reverse() random.shuffle(copy) - self.assertEqual(data, sorted(copy, cmp=lambda x, y: cmp(y,x))) + self.assertEqual(data, sorted(copy, cmp=lambda x, y: (x < y) - (x > y))) self.assertNotEqual(data, copy) random.shuffle(copy) self.assertEqual(data, sorted(copy, key=lambda x: -x)) Modified: python/branches/p3yk-noslice/Lib/test/test_bytes.py ============================================================================== --- python/branches/p3yk-noslice/Lib/test/test_bytes.py (original) +++ python/branches/p3yk-noslice/Lib/test/test_bytes.py Fri Dec 15 05:21:50 2006 @@ -245,6 +245,9 @@ b[3:5] = [3, 4, 5, 6] self.assertEqual(b, bytes(range(10))) + + b[3:0] = [42, 42, 42] + self.assertEqual(b, bytes([0, 1, 2, 42, 42, 42, 3, 4, 5, 6, 7, 8, 9])) def test_extended_set_del_slice(self): indices = (None, 1, 5, 11, 19, 100, -1, -2, -5, -11, -19, -100) Modified: python/branches/p3yk-noslice/Lib/test/test_bz2.py ============================================================================== --- python/branches/p3yk-noslice/Lib/test/test_bz2.py (original) +++ python/branches/p3yk-noslice/Lib/test/test_bz2.py Fri Dec 15 05:21:50 2006 @@ -243,7 +243,7 @@ self.createTempFile() bz2f = BZ2File(self.filename, "U") bz2f.close() - f = file(self.filename) + f = open(self.filename) f.seek(0, 2) self.assertEqual(f.tell(), len(self.DATA)) f.close() Modified: python/branches/p3yk-noslice/Lib/test/test_calendar.py ============================================================================== --- python/branches/p3yk-noslice/Lib/test/test_calendar.py (original) +++ python/branches/p3yk-noslice/Lib/test/test_calendar.py Fri Dec 15 05:21:50 2006 @@ -212,7 +212,7 @@ self.assertEqual(calendar.isleap(2003), 0) def test_setfirstweekday(self): - self.assertRaises(ValueError, calendar.setfirstweekday, 'flabber') + self.assertRaises(TypeError, calendar.setfirstweekday, 'flabber') self.assertRaises(ValueError, calendar.setfirstweekday, -1) self.assertRaises(ValueError, calendar.setfirstweekday, 200) orig = calendar.firstweekday() Modified: python/branches/p3yk-noslice/Lib/test/test_cfgparser.py ============================================================================== --- python/branches/p3yk-noslice/Lib/test/test_cfgparser.py (original) +++ python/branches/p3yk-noslice/Lib/test/test_cfgparser.py Fri Dec 15 05:21:50 2006 @@ -1,9 +1,29 @@ import ConfigParser import StringIO import unittest +import UserDict from test import test_support +class SortedDict(UserDict.UserDict): + def items(self): + result = self.data.items() + result.sort() + return result + + def keys(self): + result = self.data.keys() + result.sort() + return result + + def values(self): + result = self.items() + return [i[1] for i in values] + + def iteritems(self): return iter(self.items()) + def iterkeys(self): return iter(self.keys()) + __iter__ = iterkeys + def itervalues(self): return iter(self.values()) class TestCaseBase(unittest.TestCase): def newconfig(self, defaults=None): @@ -414,12 +434,36 @@ self.assertRaises(TypeError, cf.set, "sect", "option2", 1.0) self.assertRaises(TypeError, cf.set, "sect", "option2", object()) +class SortedTestCase(RawConfigParserTestCase): + def newconfig(self, defaults=None): + self.cf = self.config_class(defaults=defaults, dict_type=SortedDict) + return self.cf + + def test_sorted(self): + self.fromstring("[b]\n" + "o4=1\n" + "o3=2\n" + "o2=3\n" + "o1=4\n" + "[a]\n" + "k=v\n") + output = StringIO.StringIO() + self.cf.write(output) + self.assertEquals(output.getvalue(), + "[a]\n" + "k = v\n\n" + "[b]\n" + "o1 = 4\n" + "o2 = 3\n" + "o3 = 2\n" + "o4 = 1\n\n") def test_main(): test_support.run_unittest( ConfigParserTestCase, RawConfigParserTestCase, - SafeConfigParserTestCase + SafeConfigParserTestCase, + SortedTestCase ) if __name__ == "__main__": Modified: python/branches/p3yk-noslice/Lib/test/test_cgi.py ============================================================================== --- python/branches/p3yk-noslice/Lib/test/test_cgi.py (original) +++ python/branches/p3yk-noslice/Lib/test/test_cgi.py Fri Dec 15 05:21:50 2006 @@ -1,8 +1,9 @@ -from test.test_support import verify, verbose +from test.test_support import run_unittest import cgi import os import sys import tempfile +import unittest from StringIO import StringIO class HackedSysModule: @@ -25,13 +26,11 @@ def __str__(self): return str(self.err) - def __cmp__(self, anExc): + def __eq__(self, anExc): if not isinstance(anExc, Exception): - return -1 - x = cmp(self.err.__class__, anExc.__class__) - if x != 0: - return x - return cmp(self.err.args, anExc.args) + return NotImplemented + return (self.err.__class__ == anExc.__class__ and + self.err.args == anExc.args) def __getattr__(self, attr): return getattr(self.err, attr) @@ -118,10 +117,10 @@ }) ] -def norm(list): - if type(list) == type([]): - list.sort() - return list +def norm(seq): + if isinstance(seq, list): + seq.sort(key=repr) + return seq def first_elts(list): return map(lambda x:x[0], list) @@ -129,119 +128,124 @@ def first_second_elts(list): return map(lambda p:(p[0], p[1][0]), list) -def main(): - for orig, expect in parse_qsl_test_cases: - result = cgi.parse_qsl(orig, keep_blank_values=True) - print repr(orig), '=>', result - verify(result == expect, "Error parsing %s" % repr(orig)) - - for orig, expect in parse_strict_test_cases: - # Test basic parsing - print repr(orig) - d = do_test(orig, "GET") - verify(d == expect, "Error parsing %s" % repr(orig)) - d = do_test(orig, "POST") - verify(d == expect, "Error parsing %s" % repr(orig)) - - env = {'QUERY_STRING': orig} - fcd = cgi.FormContentDict(env) - sd = cgi.SvFormContentDict(env) - fs = cgi.FieldStorage(environ=env) - if type(expect) == type({}): - # test dict interface - verify(len(expect) == len(fcd)) - verify(norm(expect.keys()) == norm(fcd.keys())) - verify(norm(expect.values()) == norm(fcd.values())) - verify(norm(expect.items()) == norm(fcd.items())) - verify(fcd.get("nonexistent field", "default") == "default") - verify(len(sd) == len(fs)) - verify(norm(sd.keys()) == norm(fs.keys())) - verify(fs.getvalue("nonexistent field", "default") == "default") - # test individual fields - for key in expect.keys(): - expect_val = expect[key] - verify(key in fcd) - verify(norm(fcd[key]) == norm(expect[key])) - verify(fcd.get(key, "default") == fcd[key]) - verify(key in fs) - if len(expect_val) > 1: - single_value = 0 - else: - single_value = 1 - try: - val = sd[key] - except IndexError: - verify(not single_value) - verify(fs.getvalue(key) == expect_val) +class CgiTests(unittest.TestCase): + + def test_qsl(self): + for orig, expect in parse_qsl_test_cases: + result = cgi.parse_qsl(orig, keep_blank_values=True) + self.assertEqual(result, expect, "Error parsing %s" % repr(orig)) + + def test_strict(self): + for orig, expect in parse_strict_test_cases: + # Test basic parsing + d = do_test(orig, "GET") + self.assertEqual(d, expect, "Error parsing %s" % repr(orig)) + d = do_test(orig, "POST") + self.assertEqual(d, expect, "Error parsing %s" % repr(orig)) + + env = {'QUERY_STRING': orig} + fcd = cgi.FormContentDict(env) + sd = cgi.SvFormContentDict(env) + fs = cgi.FieldStorage(environ=env) + if type(expect) == type({}): + # test dict interface + self.assertEqual(len(expect), len(fcd)) + self.assertEqual(norm(expect.keys()), norm(fcd.keys())) + self.assertEqual(norm(expect.values()), norm(fcd.values())) + self.assertEqual(norm(expect.items()), norm(fcd.items())) + self.assertEqual(fcd.get("nonexistent field", "default"), "default") + self.assertEqual(len(sd), len(fs)) + self.assertEqual(norm(sd.keys()), norm(fs.keys())) + self.assertEqual(fs.getvalue("nonexistent field", "default"), "default") + # test individual fields + for key in expect.keys(): + expect_val = expect[key] + self.assert_(key in fcd) + self.assertEqual(norm(fcd[key]), norm(expect[key])) + self.assertEqual(fcd.get(key, "default"), fcd[key]) + self.assert_(key in fs) + if len(expect_val) > 1: + single_value = 0 + else: + single_value = 1 + try: + val = sd[key] + except IndexError: + self.failIf(single_value) + self.assertEqual(fs.getvalue(key), expect_val) + else: + self.assert_(single_value) + self.assertEqual(val, expect_val[0]) + self.assertEqual(fs.getvalue(key), expect_val[0]) + self.assertEqual(norm(sd.getlist(key)), norm(expect_val)) + if single_value: + self.assertEqual(norm(sd.values()), + first_elts(norm(expect.values()))) + self.assertEqual(norm(sd.items()), + first_second_elts(norm(expect.items()))) + + def test_weird_formcontentdict(self): + # Test the weird FormContentDict classes + env = {'QUERY_STRING': "x=1&y=2.0&z=2-3.%2b0&1=1abc"} + expect = {'x': 1, 'y': 2.0, 'z': '2-3.+0', '1': '1abc'} + d = cgi.InterpFormContentDict(env) + for k, v in expect.items(): + self.assertEqual(d[k], v) + for k, v in d.items(): + self.assertEqual(expect[k], v) + self.assertEqual(norm(expect.values()), norm(d.values())) + + def test_log(self): + cgi.log("Testing") + + cgi.logfp = StringIO() + cgi.initlog("%s", "Testing initlog 1") + cgi.log("%s", "Testing log 2") + self.assertEqual(cgi.logfp.getvalue(), "Testing initlog 1\nTesting log 2\n") + if os.path.exists("/dev/null"): + cgi.logfp = None + cgi.logfile = "/dev/null" + cgi.initlog("%s", "Testing log 3") + cgi.log("Testing log 4") + + def test_fieldstorage_readline(self): + # FieldStorage uses readline, which has the capacity to read all + # contents of the input file into memory; we use readline's size argument + # to prevent that for files that do not contain any newlines in + # non-GET/HEAD requests + class TestReadlineFile: + def __init__(self, file): + self.file = file + self.numcalls = 0 + + def readline(self, size=None): + self.numcalls += 1 + if size: + return self.file.readline(size) else: - verify(single_value) - verify(val == expect_val[0]) - verify(fs.getvalue(key) == expect_val[0]) - verify(norm(sd.getlist(key)) == norm(expect_val)) - if single_value: - verify(norm(sd.values()) == \ - first_elts(norm(expect.values()))) - verify(norm(sd.items()) == \ - first_second_elts(norm(expect.items()))) - - # Test the weird FormContentDict classes - env = {'QUERY_STRING': "x=1&y=2.0&z=2-3.%2b0&1=1abc"} - expect = {'x': 1, 'y': 2.0, 'z': '2-3.+0', '1': '1abc'} - d = cgi.InterpFormContentDict(env) - for k, v in expect.items(): - verify(d[k] == v) - for k, v in d.items(): - verify(expect[k] == v) - verify(norm(expect.values()) == norm(d.values())) - - print "Testing log" - cgi.log("Testing") - cgi.logfp = sys.stdout - cgi.initlog("%s", "Testing initlog 1") - cgi.log("%s", "Testing log 2") - if os.path.exists("/dev/null"): - cgi.logfp = None - cgi.logfile = "/dev/null" - cgi.initlog("%s", "Testing log 3") - cgi.log("Testing log 4") - - print "Test FieldStorage methods that use readline" - # FieldStorage uses readline, which has the capacity to read all - # contents of the input file into memory; we use readline's size argument - # to prevent that for files that do not contain any newlines in - # non-GET/HEAD requests - class TestReadlineFile: - def __init__(self, file): - self.file = file - self.numcalls = 0 - - def readline(self, size=None): - self.numcalls += 1 - if size: - return self.file.readline(size) - else: - return self.file.readline() - - def __getattr__(self, name): - file = self.__dict__['file'] - a = getattr(file, name) - if not isinstance(a, int): - setattr(self, name, a) - return a - - f = TestReadlineFile(tempfile.TemporaryFile()) - f.write('x' * 256 * 1024) - f.seek(0) - env = {'REQUEST_METHOD':'PUT'} - fs = cgi.FieldStorage(fp=f, environ=env) - # if we're not chunking properly, readline is only called twice - # (by read_binary); if we are chunking properly, it will be called 5 times - # as long as the chunksize is 1 << 16. - verify(f.numcalls > 2) - - print "Test basic FieldStorage multipart parsing" - env = {'REQUEST_METHOD':'POST', 'CONTENT_TYPE':'multipart/form-data; boundary=---------------------------721837373350705526688164684', 'CONTENT_LENGTH':'558'} - postdata = """-----------------------------721837373350705526688164684 + return self.file.readline() + + def __getattr__(self, name): + file = self.__dict__['file'] + a = getattr(file, name) + if not isinstance(a, int): + setattr(self, name, a) + return a + + f = TestReadlineFile(tempfile.TemporaryFile()) + f.write('x' * 256 * 1024) + f.seek(0) + env = {'REQUEST_METHOD':'PUT'} + fs = cgi.FieldStorage(fp=f, environ=env) + # if we're not chunking properly, readline is only called twice + # (by read_binary); if we are chunking properly, it will be called 5 times + # as long as the chunksize is 1 << 16. + self.assert_(f.numcalls > 2) + + def test_fieldstorage_multipart(self): + #Test basic FieldStorage multipart parsing + env = {'REQUEST_METHOD':'POST', 'CONTENT_TYPE':'multipart/form-data; boundary=---------------------------721837373350705526688164684', 'CONTENT_LENGTH':'558'} + postdata = """-----------------------------721837373350705526688164684 Content-Disposition: form-data; name="id" 1234 @@ -261,15 +265,19 @@ Add\x20 -----------------------------721837373350705526688164684-- """ - fs = cgi.FieldStorage(fp=StringIO(postdata), environ=env) - verify(len(fs.list) == 4) - expect = [{'name':'id', 'filename':None, 'value':'1234'}, - {'name':'title', 'filename':None, 'value':''}, - {'name':'file', 'filename':'test.txt','value':'Testing 123.\n'}, - {'name':'submit', 'filename':None, 'value':' Add '}] - for x in range(len(fs.list)): - for k, exp in expect[x].items(): - got = getattr(fs.list[x], k) - verify(got == exp) + fs = cgi.FieldStorage(fp=StringIO(postdata), environ=env) + self.assertEquals(len(fs.list), 4) + expect = [{'name':'id', 'filename':None, 'value':'1234'}, + {'name':'title', 'filename':None, 'value':''}, + {'name':'file', 'filename':'test.txt','value':'Testing 123.\n'}, + {'name':'submit', 'filename':None, 'value':' Add '}] + for x in range(len(fs.list)): + for k, exp in expect[x].items(): + got = getattr(fs.list[x], k) + self.assertEquals(got, exp) + +def test_main(): + run_unittest(CgiTests) -main() +if __name__ == '__main__': + test_main() Modified: python/branches/p3yk-noslice/Lib/test/test_class.py ============================================================================== --- python/branches/p3yk-noslice/Lib/test/test_class.py (original) +++ python/branches/p3yk-noslice/Lib/test/test_class.py Fri Dec 15 05:21:50 2006 @@ -100,6 +100,30 @@ print "__cmp__:", args return 0 + def __eq__(self, *args): + print "__eq__:", args + return True + + def __ne__(self, *args): + print "__ne__:", args + return False + + def __lt__(self, *args): + print "__lt__:", args + return False + + def __le__(self, *args): + print "__le__:", args + return True + + def __gt__(self, *args): + print "__gt__:", args + return False + + def __ge__(self, *args): + print "__ge__:", args + return True + def __del__(self, *args): print "__del__:", args @@ -112,7 +136,7 @@ d = {} for method in testmeths: - exec method_template % locals() in d + exec(method_template % locals(), d) for k in d: setattr(AllTests, k, d[k]) del d, k @@ -162,6 +186,14 @@ # List/dict operations +class Empty: pass + +try: + 1 in Empty() + print 'failed, should have raised TypeError' +except TypeError: + pass + 1 in testme testme[1] @@ -220,12 +252,10 @@ testme == 1 testme < 1 testme > 1 -testme <> 1 testme != 1 1 == testme 1 < testme 1 > testme -1 <> testme 1 != testme # This test has to be last (duh.) @@ -269,7 +299,7 @@ """Raise TestFailed if executing 'stmt' does not raise 'exception' """ try: - exec stmt + exec(stmt) except exception: pass else: Modified: python/branches/p3yk-noslice/Lib/test/test_code.py ============================================================================== --- python/branches/p3yk-noslice/Lib/test/test_code.py (original) +++ python/branches/p3yk-noslice/Lib/test/test_code.py Fri Dec 15 05:21:50 2006 @@ -9,6 +9,7 @@ >>> dump(f.func_code) name: f argcount: 1 +kwonlyargcount: 0 names: () varnames: ('x', 'g') cellvars: ('x',) @@ -20,6 +21,7 @@ >>> dump(f(4).func_code) name: g argcount: 1 +kwonlyargcount: 0 names: () varnames: ('y',) cellvars: () @@ -34,9 +36,11 @@ ... c = a * b ... return c ... + >>> dump(h.func_code) name: h argcount: 2 +kwonlyargcount: 0 names: () varnames: ('x', 'y', 'a', 'b', 'c') cellvars: () @@ -53,6 +57,7 @@ >>> dump(attrs.func_code) name: attrs argcount: 1 +kwonlyargcount: 0 names: ('attr1', 'attr2', 'attr3') varnames: ('obj',) cellvars: () @@ -70,6 +75,7 @@ >>> dump(optimize_away.func_code) name: optimize_away argcount: 0 +kwonlyargcount: 0 names: () varnames: () cellvars: () @@ -78,6 +84,22 @@ flags: 67 consts: ("'doc string'", 'None') +>>> def keywordonly_args(a,b,*,k1): +... return a,b,k1 +... + +>>> dump(keywordonly_args.func_code) +name: keywordonly_args +argcount: 2 +kwonlyargcount: 1 +names: () +varnames: ('a', 'b', 'k1') +cellvars: () +freevars: () +nlocals: 3 +flags: 67 +consts: ('None',) + """ def consts(t): @@ -91,8 +113,8 @@ def dump(co): """Print out a text representation of a code object.""" - for attr in ["name", "argcount", "names", "varnames", "cellvars", - "freevars", "nlocals", "flags"]: + for attr in ["name", "argcount", "kwonlyargcount", "names", "varnames", + "cellvars", "freevars", "nlocals", "flags"]: print "%s: %s" % (attr, getattr(co, "co_" + attr)) print "consts:", tuple(consts(co.co_consts)) Modified: python/branches/p3yk-noslice/Lib/test/test_codecencodings_cn.py ============================================================================== --- python/branches/p3yk-noslice/Lib/test/test_codecencodings_cn.py (original) +++ python/branches/p3yk-noslice/Lib/test/test_codecencodings_cn.py Fri Dec 15 05:21:50 2006 @@ -32,6 +32,7 @@ ("abc\x80\x80\xc1\xc4\xc8", "replace", u"abc\ufffd\u804a\ufffd"), ("abc\x80\x80\xc1\xc4", "ignore", u"abc\u804a"), ("\x83\x34\x83\x31", "strict", None), + (u"\u30fb", "strict", None), ) class Test_GB18030(test_multibytecodec_support.TestBase, unittest.TestCase): @@ -45,6 +46,7 @@ ("abc\x80\x80\xc1\xc4\xc8", "replace", u"abc\ufffd\u804a\ufffd"), ("abc\x80\x80\xc1\xc4", "ignore", u"abc\u804a"), ("abc\x84\x39\x84\x39\xc1\xc4", "replace", u"abc\ufffd\u804a"), + (u"\u30fb", "strict", "\x819\xa79"), ) has_iso10646 = True Modified: python/branches/p3yk-noslice/Lib/test/test_codecs.py ============================================================================== --- python/branches/p3yk-noslice/Lib/test/test_codecs.py (original) +++ python/branches/p3yk-noslice/Lib/test/test_codecs.py Fri Dec 15 05:21:50 2006 @@ -425,6 +425,10 @@ ] ) + def test_bug1601501(self): + # SF bug #1601501: check that the codec works with a buffer + unicode("\xef\xbb\xbf", "utf-8-sig") + class EscapeDecodeTest(unittest.TestCase): def test_empty(self): self.assertEquals(codecs.escape_decode(""), ("", 0)) @@ -910,6 +914,18 @@ f = self.reader(self.stream) self.assertEquals(f.readlines(), [u'\ud55c\n', u'\uae00']) +class EncodedFileTest(unittest.TestCase): + + def test_basic(self): + f = StringIO.StringIO('\xed\x95\x9c\n\xea\xb8\x80') + ef = codecs.EncodedFile(f, 'utf-16-le', 'utf-8') + self.assertEquals(ef.read(), '\\\xd5\n\x00\x00\xae') + + f = StringIO.StringIO() + ef = codecs.EncodedFile(f, 'utf-8', 'latin1') + ef.write('\xc3\xbc') + self.assertEquals(f.getvalue(), '\xfc') + class Str2StrTest(unittest.TestCase): def test_read(self): @@ -1050,6 +1066,14 @@ "punycode", "unicode_internal" ] +broken_incremental_coders = broken_unicode_with_streams[:] + +# The following encodings only support "strict" mode +only_strict_mode = [ + "idna", + "zlib_codec", + "bz2_codec", +] try: import bz2 @@ -1099,6 +1123,7 @@ decodedresult += reader.read() self.assertEqual(decodedresult, s, "%r != %r (encoding=%r)" % (decodedresult, s, encoding)) + if encoding not in broken_incremental_coders: # check incremental decoder/encoder (fetched via the Python # and C API) and iterencode()/iterdecode() try: @@ -1139,6 +1164,24 @@ result = u"".join(codecs.iterdecode(codecs.iterencode(u"", encoding), encoding)) self.assertEqual(result, u"") + if encoding not in only_strict_mode: + # check incremental decoder/encoder with errors argument + try: + encoder = codecs.getincrementalencoder(encoding)("ignore") + cencoder = _testcapi.codec_incrementalencoder(encoding, "ignore") + except LookupError: # no IncrementalEncoder + pass + else: + encodedresult = "".join(encoder.encode(c) for c in s) + decoder = codecs.getincrementaldecoder(encoding)("ignore") + decodedresult = u"".join(decoder.decode(c) for c in encodedresult) + self.assertEqual(decodedresult, s, "%r != %r (encoding=%r)" % (decodedresult, s, encoding)) + + encodedresult = "".join(cencoder.encode(c) for c in s) + cdecoder = _testcapi.codec_incrementaldecoder(encoding, "ignore") + decodedresult = u"".join(cdecoder.decode(c) for c in encodedresult) + self.assertEqual(decodedresult, s, "%r != %r (encoding=%r)" % (decodedresult, s, encoding)) + def test_seek(self): # all codecs should be able to encode these s = u"%s\n%s\n" % (100*u"abc123", 100*u"def456") @@ -1214,6 +1257,19 @@ (u"", len(allbytes)) ) +class WithStmtTest(unittest.TestCase): + def test_encodedfile(self): + f = StringIO.StringIO("\xc3\xbc") + with codecs.EncodedFile(f, "latin-1", "utf-8") as ef: + self.assertEquals(ef.read(), "\xfc") + + def test_streamreaderwriter(self): + f = StringIO.StringIO("\xc3\xbc") + info = codecs.lookup("utf-8") + with codecs.StreamReaderWriter(f, info.streamreader, + info.streamwriter, 'strict') as srw: + self.assertEquals(srw.read(), u"\xfc") + def test_main(): test_support.run_unittest( @@ -1234,10 +1290,12 @@ IDNACodecTest, CodecsModuleTest, StreamReaderTest, + EncodedFileTest, Str2StrTest, BasicUnicodeTest, BasicStrTest, - CharmapTest + CharmapTest, + WithStmtTest, ) Modified: python/branches/p3yk-noslice/Lib/test/test_codeop.py ============================================================================== --- python/branches/p3yk-noslice/Lib/test/test_codeop.py (original) +++ python/branches/p3yk-noslice/Lib/test/test_codeop.py Fri Dec 15 05:21:50 2006 @@ -29,8 +29,8 @@ saved_stdout = sys.stdout sys.stdout = cStringIO.StringIO() try: - exec code in d - exec compile(str,"","single") in r + exec(code, d) + exec(compile(str,"","single"), r) finally: sys.stdout = saved_stdout elif symbol == 'eval': Modified: python/branches/p3yk-noslice/Lib/test/test_compare.py ============================================================================== --- python/branches/p3yk-noslice/Lib/test/test_compare.py (original) +++ python/branches/p3yk-noslice/Lib/test/test_compare.py Fri Dec 15 05:21:50 2006 @@ -13,8 +13,8 @@ def __repr__(self): return '' % self.arg - def __cmp__(self, other): - return cmp(self.arg, other) + def __eq__(self, other): + return self.arg == other class ComparisonTest(unittest.TestCase): set1 = [2, 2.0, 2L, 2+0j, Cmp(2.0)] @@ -36,7 +36,7 @@ L.insert(len(L)//2, Empty()) for a in L: for b in L: - self.assertEqual(cmp(a, b), cmp(id(a), id(b)), + self.assertEqual(a == b, id(a) == id(b), 'a=%r, b=%r' % (a, b)) def test_main(): Modified: python/branches/p3yk-noslice/Lib/test/test_compile.py ============================================================================== --- python/branches/p3yk-noslice/Lib/test/test_compile.py (original) +++ python/branches/p3yk-noslice/Lib/test/test_compile.py Fri Dec 15 05:21:50 2006 @@ -19,17 +19,17 @@ self.assertRaises(SyntaxError, eval, 'lambda a,a=1:0') self.assertRaises(SyntaxError, eval, 'lambda a=1,a=1:0') try: - exec 'def f(a, a): pass' + exec('def f(a, a): pass') self.fail("duplicate arguments") except SyntaxError: pass try: - exec 'def f(a = 0, a = 1): pass' + exec('def f(a = 0, a = 1): pass') self.fail("duplicate keyword arguments") except SyntaxError: pass try: - exec 'def f(a): global a; a = 1' + exec('def f(a): global a; a = 1') self.fail("variable is global and local") except SyntaxError: pass @@ -39,7 +39,7 @@ def test_duplicate_global_local(self): try: - exec 'def f(a): global a; a = 1' + exec('def f(a): global a; a = 1') self.fail("variable is global and local") except SyntaxError: pass @@ -59,22 +59,22 @@ m = M() g = globals() - exec 'z = a' in g, m + exec('z = a', g, m) self.assertEqual(m.results, ('z', 12)) try: - exec 'z = b' in g, m + exec('z = b', g, m) except NameError: pass else: self.fail('Did not detect a KeyError') - exec 'z = dir()' in g, m + exec('z = dir()', g, m) self.assertEqual(m.results, ('z', list('xyz'))) - exec 'z = globals()' in g, m + exec('z = globals()', g, m) self.assertEqual(m.results, ('z', g)) - exec 'z = locals()' in g, m + exec('z = locals()', g, m) self.assertEqual(m.results, ('z', m)) try: - exec 'z = b' in m + exec('z = b', m) except TypeError: pass else: @@ -85,7 +85,7 @@ pass m = A() try: - exec 'z = a' in g, m + exec('z = a', g, m) except TypeError: pass else: @@ -98,11 +98,12 @@ return 12 return dict.__getitem__(self, key) d = D() - exec 'z = a' in g, d + exec('z = a', g, d) self.assertEqual(d['z'], 12) def test_extended_arg(self): longexpr = 'x = x or ' + '-x' * 2500 + g = {} code = ''' def f(x): %s @@ -121,8 +122,8 @@ # EXTENDED_ARG/JUMP_ABSOLUTE here return x ''' % ((longexpr,)*10) - exec code - self.assertEqual(f(5), 0) + exec(code, g) + self.assertEqual(g['f'](5), 0) def test_complex_args(self): @@ -146,7 +147,7 @@ def test_argument_order(self): try: - exec 'def f(a=1, (b, c)): pass' + exec('def f(a=1, (b, c)): pass') self.fail("non-default args after default") except SyntaxError: pass Modified: python/branches/p3yk-noslice/Lib/test/test_compiler.py ============================================================================== --- python/branches/p3yk-noslice/Lib/test/test_compiler.py (original) +++ python/branches/p3yk-noslice/Lib/test/test_compiler.py Fri Dec 15 05:21:50 2006 @@ -61,7 +61,7 @@ c = compiler.compile("try:\n 1/0\nexcept:\n e = 1\nfinally:\n f = 1", "", "exec") dct = {} - exec c in dct + exec(c, dct) self.assertEquals(dct.get('e'), 1) self.assertEquals(dct.get('f'), 1) @@ -73,7 +73,7 @@ self.assert_('__doc__' in c.co_names) c = compiler.compile('def f():\n "doc"', '', 'exec') g = {} - exec c in g + exec(c, g) self.assertEquals(g['f'].__doc__, "doc") def testLineNo(self): @@ -113,7 +113,7 @@ '', 'exec') dct = {} - exec c in dct + exec(c, dct) self.assertEquals(dct.get('result'), 3) def testGenExp(self): Modified: python/branches/p3yk-noslice/Lib/test/test_contextlib.py ============================================================================== --- python/branches/p3yk-noslice/Lib/test/test_contextlib.py (original) +++ python/branches/p3yk-noslice/Lib/test/test_contextlib.py Fri Dec 15 05:21:50 2006 @@ -330,32 +330,6 @@ return True self.boilerPlate(lock, locked) -class DecimalContextTestCase(unittest.TestCase): - - # XXX Somebody should write more thorough tests for this - - def testBasic(self): - ctx = decimal.getcontext() - orig_context = ctx.copy() - try: - ctx.prec = save_prec = decimal.ExtendedContext.prec + 5 - with decimal.ExtendedContext.get_manager(): - self.assertEqual(decimal.getcontext().prec, - decimal.ExtendedContext.prec) - self.assertEqual(decimal.getcontext().prec, save_prec) - try: - with decimal.ExtendedContext.get_manager(): - self.assertEqual(decimal.getcontext().prec, - decimal.ExtendedContext.prec) - 1/0 - except ZeroDivisionError: - self.assertEqual(decimal.getcontext().prec, save_prec) - else: - self.fail("Didn't raise ZeroDivisionError") - finally: - decimal.setcontext(orig_context) - - # This is needed to make the test actually run under regrtest.py! def test_main(): run_suite( Modified: python/branches/p3yk-noslice/Lib/test/test_cookie.py ============================================================================== --- python/branches/p3yk-noslice/Lib/test/test_cookie.py (original) +++ python/branches/p3yk-noslice/Lib/test/test_cookie.py Fri Dec 15 05:21:50 2006 @@ -1,6 +1,7 @@ # Simple test suite for Cookie.py -from test.test_support import verify, verbose, run_doctest +from test.test_support import run_unittest, run_doctest +import unittest import Cookie import warnings @@ -8,43 +9,74 @@ ".* class is insecure.*", DeprecationWarning) -# Currently this only tests SimpleCookie +class CookieTests(unittest.TestCase): + # Currently this only tests SimpleCookie + def test_basic(self): + cases = [ + { 'data': 'chips=ahoy; vienna=finger', + 'dict': {'chips':'ahoy', 'vienna':'finger'}, + 'repr': "", + 'output': 'Set-Cookie: chips=ahoy\nSet-Cookie: vienna=finger', + }, + + { 'data': 'keebler="E=mc2; L=\\"Loves\\"; fudge=\\012;"', + 'dict': {'keebler' : 'E=mc2; L="Loves"; fudge=\012;'}, + 'repr': '''''', + 'output': 'Set-Cookie: keebler="E=mc2; L=\\"Loves\\"; fudge=\\012;"', + }, + + # Check illegal cookies that have an '=' char in an unquoted value + { 'data': 'keebler=E=mc2', + 'dict': {'keebler' : 'E=mc2'}, + 'repr': "", + 'output': 'Set-Cookie: keebler=E=mc2', + } + ] + + for case in cases: + C = Cookie.SimpleCookie() + C.load(case['data']) + self.assertEqual(repr(C), case['repr']) + self.assertEqual(C.output(sep='\n'), case['output']) + for k, v in sorted(case['dict'].iteritems()): + self.assertEqual(C[k].value, v) + + def test_load(self): + C = Cookie.SimpleCookie() + C.load('Customer="WILE_E_COYOTE"; Version=1; Path=/acme') + + self.assertEqual(C['Customer'].value, 'WILE_E_COYOTE') + self.assertEqual(C['Customer']['version'], '1') + self.assertEqual(C['Customer']['path'], '/acme') + + self.assertEqual(C.output(['path']), + 'Set-Cookie: Customer="WILE_E_COYOTE"; Path=/acme') + self.assertEqual(C.js_output(), """ + + """) + self.assertEqual(C.js_output(['path']), """ + + """) + + def test_quoted_meta(self): + # Try cookie with quoted meta-data + C = Cookie.SimpleCookie() + C.load('Customer="WILE_E_COYOTE"; Version="1"; Path="/acme"') + self.assertEqual(C['Customer'].value, 'WILE_E_COYOTE') + self.assertEqual(C['Customer']['version'], '1') + self.assertEqual(C['Customer']['path'], '/acme') + +def test_main(): + run_unittest(CookieTests) + run_doctest(Cookie) -cases = [ - ('chips=ahoy; vienna=finger', {'chips':'ahoy', 'vienna':'finger'}), - ('keebler="E=mc2; L=\\"Loves\\"; fudge=\\012;"', - {'keebler' : 'E=mc2; L="Loves"; fudge=\012;'}), - - # Check illegal cookies that have an '=' char in an unquoted value - ('keebler=E=mc2', {'keebler' : 'E=mc2'}) - ] - -for data, dict in cases: - C = Cookie.SimpleCookie() ; C.load(data) - print repr(C) - print C.output(sep='\n') - for k, v in sorted(dict.iteritems()): - print ' ', k, repr( C[k].value ), repr(v) - verify(C[k].value == v) - print C[k] - -C = Cookie.SimpleCookie() -C.load('Customer="WILE_E_COYOTE"; Version=1; Path=/acme') - -verify(C['Customer'].value == 'WILE_E_COYOTE') -verify(C['Customer']['version'] == '1') -verify(C['Customer']['path'] == '/acme') - -print C.output(['path']) -print C.js_output() -print C.js_output(['path']) - -# Try cookie with quoted meta-data -C = Cookie.SimpleCookie() -C.load('Customer="WILE_E_COYOTE"; Version="1"; Path="/acme"') -verify(C['Customer'].value == 'WILE_E_COYOTE') -verify(C['Customer']['version'] == '1') -verify(C['Customer']['path'] == '/acme') - -print "If anything blows up after this line, it's from Cookie's doctest." -run_doctest(Cookie) +if __name__ == '__main__': + test_main() Modified: python/branches/p3yk-noslice/Lib/test/test_copy.py ============================================================================== --- python/branches/p3yk-noslice/Lib/test/test_copy.py (original) +++ python/branches/p3yk-noslice/Lib/test/test_copy.py Fri Dec 15 05:21:50 2006 @@ -104,8 +104,8 @@ class C: def __init__(self, foo): self.foo = foo - def __cmp__(self, other): - return cmp(self.foo, other.foo) + def __eq__(self, other): + return self.foo == other.foo x = C(42) self.assertEqual(copy.copy(x), x) @@ -115,8 +115,8 @@ self.foo = foo def __copy__(self): return C(self.foo) - def __cmp__(self, other): - return cmp(self.foo, other.foo) + def __eq__(self, other): + return self.foo == other.foo x = C(42) self.assertEqual(copy.copy(x), x) @@ -126,8 +126,8 @@ self.foo = foo def __getinitargs__(self): return (self.foo,) - def __cmp__(self, other): - return cmp(self.foo, other.foo) + def __eq__(self, other): + return self.foo == other.foo x = C(42) self.assertEqual(copy.copy(x), x) @@ -137,8 +137,8 @@ self.foo = foo def __getstate__(self): return {"foo": self.foo} - def __cmp__(self, other): - return cmp(self.foo, other.foo) + def __eq__(self, other): + return self.foo == other.foo x = C(42) self.assertEqual(copy.copy(x), x) @@ -148,8 +148,8 @@ self.foo = foo def __setstate__(self, state): self.foo = state["foo"] - def __cmp__(self, other): - return cmp(self.foo, other.foo) + def __eq__(self, other): + return self.foo == other.foo x = C(42) self.assertEqual(copy.copy(x), x) @@ -161,8 +161,8 @@ return self.foo def __setstate__(self, state): self.foo = state - def __cmp__(self, other): - return cmp(self.foo, other.foo) + def __eq__(self, other): + return self.foo == other.foo x = C(42) self.assertEqual(copy.copy(x), x) @@ -304,7 +304,7 @@ x = {} x['foo'] = x y = copy.deepcopy(x) - self.assertRaises(RuntimeError, cmp, y, x) + self.assertRaises(TypeError, cmp, y, x) self.assert_(y is not x) self.assert_(y['foo'] is y) self.assertEqual(len(y), 1) @@ -319,8 +319,8 @@ class C: def __init__(self, foo): self.foo = foo - def __cmp__(self, other): - return cmp(self.foo, other.foo) + def __eq__(self, other): + return self.foo == other.foo x = C([42]) y = copy.deepcopy(x) self.assertEqual(y, x) @@ -332,8 +332,8 @@ self.foo = foo def __deepcopy__(self, memo): return C(copy.deepcopy(self.foo, memo)) - def __cmp__(self, other): - return cmp(self.foo, other.foo) + def __eq__(self, other): + return self.foo == other.foo x = C([42]) y = copy.deepcopy(x) self.assertEqual(y, x) @@ -346,8 +346,8 @@ self.foo = foo def __getinitargs__(self): return (self.foo,) - def __cmp__(self, other): - return cmp(self.foo, other.foo) + def __eq__(self, other): + return self.foo == other.foo x = C([42]) y = copy.deepcopy(x) self.assertEqual(y, x) @@ -360,8 +360,8 @@ self.foo = foo def __getstate__(self): return {"foo": self.foo} - def __cmp__(self, other): - return cmp(self.foo, other.foo) + def __eq__(self, other): + return self.foo == other.foo x = C([42]) y = copy.deepcopy(x) self.assertEqual(y, x) @@ -374,8 +374,8 @@ self.foo = foo def __setstate__(self, state): self.foo = state["foo"] - def __cmp__(self, other): - return cmp(self.foo, other.foo) + def __eq__(self, other): + return self.foo == other.foo x = C([42]) y = copy.deepcopy(x) self.assertEqual(y, x) @@ -390,8 +390,8 @@ return self.foo def __setstate__(self, state): self.foo = state - def __cmp__(self, other): - return cmp(self.foo, other.foo) + def __eq__(self, other): + return self.foo == other.foo x = C([42]) y = copy.deepcopy(x) self.assertEqual(y, x) @@ -434,8 +434,8 @@ class C(object): def __reduce__(self): return (C, (), self.__dict__) - def __cmp__(self, other): - return cmp(self.__dict__, other.__dict__) + def __eq__(self, other): + return self.__dict__ == other.__dict__ x = C() x.foo = [42] y = copy.copy(x) @@ -450,8 +450,8 @@ return (C, (), self.__dict__) def __setstate__(self, state): self.__dict__.update(state) - def __cmp__(self, other): - return cmp(self.__dict__, other.__dict__) + def __eq__(self, other): + return self.__dict__ == other.__dict__ x = C() x.foo = [42] y = copy.copy(x) @@ -475,9 +475,9 @@ class C(list): def __reduce__(self): return (C, (), self.__dict__, iter(self)) - def __cmp__(self, other): - return (cmp(list(self), list(other)) or - cmp(self.__dict__, other.__dict__)) + def __eq__(self, other): + return (list(self) == list(other) and + self.__dict__ == other.__dict__) x = C([[1, 2], 3]) y = copy.copy(x) self.assertEqual(x, y) @@ -492,9 +492,9 @@ class C(dict): def __reduce__(self): return (C, (), self.__dict__, None, self.iteritems()) - def __cmp__(self, other): - return (cmp(dict(self), list(dict)) or - cmp(self.__dict__, other.__dict__)) + def __eq__(self, other): + return (dict(self) == dict(other) and + self.__dict__ == other.__dict__) x = C([("foo", [1, 2]), ("bar", 3)]) y = copy.copy(x) self.assertEqual(x, y) Modified: python/branches/p3yk-noslice/Lib/test/test_datetime.py ============================================================================== --- python/branches/p3yk-noslice/Lib/test/test_datetime.py (original) +++ python/branches/p3yk-noslice/Lib/test/test_datetime.py Fri Dec 15 05:21:50 2006 @@ -852,6 +852,7 @@ t = self.theclass(2005, 3, 2) self.assertEqual(t.strftime("m:%m d:%d y:%y"), "m:03 d:02 y:05") self.assertEqual(t.strftime(""), "") # SF bug #761337 + self.assertEqual(t.strftime('x'*1000), 'x'*1000) # SF bug #1556784 self.assertRaises(TypeError, t.strftime) # needs an arg self.assertRaises(TypeError, t.strftime, "one", "two") # too many args @@ -954,41 +955,60 @@ def test_mixed_compare(self): our = self.theclass(2000, 4, 5) + + # Our class can be compared for equality to other classes + self.assertEqual(our == 1, False) + self.assertEqual(1 == our, False) + self.assertEqual(our != 1, True) + self.assertEqual(1 != our, True) + + # But the ordering is undefined + self.assertRaises(TypeError, lambda: our < 1) + self.assertRaises(TypeError, lambda: 1 < our) self.assertRaises(TypeError, cmp, our, 1) self.assertRaises(TypeError, cmp, 1, our) - class AnotherDateTimeClass(object): - def __cmp__(self, other): - # Return "equal" so calling this can't be confused with - # compare-by-address (which never says "equal" for distinct - # objects). - return 0 - - # This still errors, because date and datetime comparison raise - # TypeError instead of NotImplemented when they don't know what to - # do, in order to stop comparison from falling back to the default - # compare-by-address. - their = AnotherDateTimeClass() + # Repeat those tests with a different class + + class SomeClass: + pass + + their = SomeClass() + self.assertEqual(our == their, False) + self.assertEqual(their == our, False) + self.assertEqual(our != their, True) + self.assertEqual(their != our, True) + self.assertRaises(TypeError, lambda: our < their) + self.assertRaises(TypeError, lambda: their < our) self.assertRaises(TypeError, cmp, our, their) - # Oops: The next stab raises TypeError in the C implementation, - # but not in the Python implementation of datetime. The difference - # is due to that the Python implementation defines __cmp__ but - # the C implementation defines tp_richcompare. This is more pain - # to fix than it's worth, so commenting out the test. - # self.assertEqual(cmp(their, our), 0) - - # But date and datetime comparison return NotImplemented instead if the - # other object has a timetuple attr. This gives the other object a - # chance to do the comparison. - class Comparable(AnotherDateTimeClass): - def timetuple(self): - return () - - their = Comparable() - self.assertEqual(cmp(our, their), 0) - self.assertEqual(cmp(their, our), 0) - self.failUnless(our == their) - self.failUnless(their == our) + self.assertRaises(TypeError, cmp, their, our) + + # However, if the other class explicitly defines ordering + # relative to our class, it is allowed to do so + + class LargerThanAnything: + def __lt__(self, other): + return False + def __le__(self, other): + return isinstance(other, LargerThanAnything) + def __eq__(self, other): + return isinstance(other, LargerThanAnything) + def __ne__(self, other): + return not isinstance(other, LargerThanAnything) + def __gt__(self, other): + return not isinstance(other, LargerThanAnything) + def __ge__(self, other): + return True + + their = LargerThanAnything() + self.assertEqual(our == their, False) + self.assertEqual(their == our, False) + self.assertEqual(our != their, True) + self.assertEqual(their != our, True) + self.assertEqual(our < their, True) + self.assertEqual(their < our, False) + self.assertEqual(cmp(our, their), -1) + self.assertEqual(cmp(their, our), 1) def test_bool(self): # All dates are considered true. @@ -3217,10 +3237,10 @@ # Neverthelss, comparison should work with the base-class (date) # projection if use of a date method is forced. - self.assert_(as_date.__eq__(as_datetime)) + self.assertEqual(as_date.__eq__(as_datetime), True) different_day = (as_date.day + 1) % 20 + 1 - self.assert_(not as_date.__eq__(as_datetime.replace(day= - different_day))) + as_different = as_datetime.replace(day= different_day) + self.assertEqual(as_date.__eq__(as_different), False) # And date should compare with other subclasses of date. If a # subclass wants to stop this, it's up to the subclass to do so. Modified: python/branches/p3yk-noslice/Lib/test/test_dbm.py ============================================================================== --- python/branches/p3yk-noslice/Lib/test/test_dbm.py (original) +++ python/branches/p3yk-noslice/Lib/test/test_dbm.py Fri Dec 15 05:21:50 2006 @@ -6,11 +6,11 @@ import random import dbm from dbm import error -from test.test_support import verbose, verify, TestSkipped +from test.test_support import verbose, verify, TestSkipped, TESTFN # make filename unique to allow multiple concurrent tests # and to minimize the likelihood of a problem from an old file -filename = '/tmp/delete_me_' + str(random.random())[-6:] +filename = TESTFN def cleanup(): for suffix in ['', '.pag', '.dir', '.db']: Modified: python/branches/p3yk-noslice/Lib/test/test_decimal.py ============================================================================== --- python/branches/p3yk-noslice/Lib/test/test_decimal.py (original) +++ python/branches/p3yk-noslice/Lib/test/test_decimal.py Fri Dec 15 05:21:50 2006 @@ -23,6 +23,7 @@ you're working through IDLE, you can import this test module and call test_main() with the corresponding argument. """ +from __future__ import with_statement import unittest import glob @@ -276,8 +277,8 @@ myexceptions = self.getexceptions() self.context.clear_flags() - myexceptions.sort() - theirexceptions.sort() + myexceptions.sort(key=repr) + theirexceptions.sort(key=repr) self.assertEqual(result, ans, 'Incorrect answer for ' + s + ' -- got ' + result) @@ -990,7 +991,7 @@ checkSameDec("__mod__", True) checkSameDec("__mul__", True) checkSameDec("__neg__") - checkSameDec("__nonzero__") + checkSameDec("__bool__") checkSameDec("__pos__") checkSameDec("__pow__", True) checkSameDec("__radd__", True) @@ -1057,6 +1058,32 @@ self.assertNotEqual(id(c.flags), id(d.flags)) self.assertNotEqual(id(c.traps), id(d.traps)) +class WithStatementTest(unittest.TestCase): + # Can't do these as docstrings until Python 2.6 + # as doctest can't handle __future__ statements + + def test_localcontext(self): + # Use a copy of the current context in the block + orig_ctx = getcontext() + with localcontext() as enter_ctx: + set_ctx = getcontext() + final_ctx = getcontext() + self.assert_(orig_ctx is final_ctx, 'did not restore context correctly') + self.assert_(orig_ctx is not set_ctx, 'did not copy the context') + self.assert_(set_ctx is enter_ctx, '__enter__ returned wrong context') + + def test_localcontextarg(self): + # Use a copy of the supplied context in the block + orig_ctx = getcontext() + new_ctx = Context(prec=42) + with localcontext(new_ctx) as enter_ctx: + set_ctx = getcontext() + final_ctx = getcontext() + self.assert_(orig_ctx is final_ctx, 'did not restore context correctly') + self.assert_(set_ctx.prec == new_ctx.prec, 'did not set correct context') + self.assert_(new_ctx is not set_ctx, 'did not copy the context') + self.assert_(set_ctx is enter_ctx, '__enter__ returned wrong context') + def test_main(arith=False, verbose=None): """ Execute the tests. @@ -1077,6 +1104,7 @@ DecimalPythonAPItests, ContextAPItests, DecimalTest, + WithStatementTest, ] try: Modified: python/branches/p3yk-noslice/Lib/test/test_descr.py ============================================================================== --- python/branches/p3yk-noslice/Lib/test/test_descr.py (original) +++ python/branches/p3yk-noslice/Lib/test/test_descr.py Fri Dec 15 05:21:50 2006 @@ -55,7 +55,7 @@ def testsetop(a, b, res, stmt="a+=b", meth="__iadd__"): if verbose: print "checking", stmt dict = {'a': deepcopy(a), 'b': b} - exec stmt in dict + exec(stmt, dict) vereq(dict['a'], res) t = type(a) m = getattr(t, meth) @@ -73,7 +73,7 @@ def testset2op(a, b, c, res, stmt="a[b]=c", meth="__setitem__"): if verbose: print "checking", stmt dict = {'a': deepcopy(a), 'b': b, 'c': c} - exec stmt in dict + exec(stmt, dict) vereq(dict['a'], res) t = type(a) m = getattr(t, meth) @@ -91,7 +91,7 @@ def testset3op(a, b, c, d, res, stmt="a[b:c]=d", meth="__setitem__"): if verbose: print "checking", stmt dict = {'a': deepcopy(a), 'b': b, 'c': c, 'd': d} - exec stmt in dict + exec(stmt, dict) vereq(dict['a'], res) t = type(a) while meth not in t.__dict__: @@ -151,7 +151,7 @@ def dicts(): if verbose: print "Testing dict operations..." - testbinop({1:2}, {2:1}, -1, "cmp(a,b)", "__cmp__") + ##testbinop({1:2}, {2:1}, -1, "cmp(a,b)", "__cmp__") testbinop({1:2,3:4}, 1, 1, "b in a", "__contains__") testbinop({1:2,3:4}, 2, 0, "b in a", "__contains__") testbinop({1:2,3:4}, 1, 2, "a[b]", "__getitem__") @@ -417,8 +417,8 @@ if verbose: print "Testing int operations..." numops(100, 3) # The following crashes in Python 2.2 - vereq((1).__nonzero__(), 1) - vereq((0).__nonzero__(), 0) + vereq((1).__bool__(), True) + vereq((0).__bool__(), False) # This returns 'NotImplemented' in Python 2.2 class C(int): def __add__(self, other): @@ -523,7 +523,7 @@ # This is an ugly hack: copy._deepcopy_dispatch[spam.spamdict] = spamdict - testbinop(spamdict({1:2}), spamdict({2:1}), -1, "cmp(a,b)", "__cmp__") + ##testbinop(spamdict({1:2}), spamdict({2:1}), -1, "cmp(a,b)", "__cmp__") testbinop(spamdict({1:2,3:4}), 1, 1, "b in a", "__contains__") testbinop(spamdict({1:2,3:4}), 2, 0, "b in a", "__contains__") testbinop(spamdict({1:2,3:4}), 1, 2, "a[b]", "__getitem__") @@ -1634,7 +1634,7 @@ verify(id(c1) != id(c2)) hash(c1) hash(c2) - vereq(cmp(c1, c2), cmp(id(c1), id(c2))) + ##vereq(cmp(c1, c2), cmp(id(c1), id(c2))) vereq(c1, c1) verify(c1 != c2) verify(not c1 != c1) @@ -1658,7 +1658,7 @@ verify(id(d1) != id(d2)) hash(d1) hash(d2) - vereq(cmp(d1, d2), cmp(id(d1), id(d2))) + ##vereq(cmp(d1, d2), cmp(id(d1), id(d2))) vereq(d1, d1) verify(d1 != d2) verify(not d1 != d1) @@ -1675,7 +1675,7 @@ class Proxy(object): def __init__(self, x): self.x = x - def __nonzero__(self): + def __bool__(self): return not not self.x def __hash__(self): return hash(self.x) @@ -1715,7 +1715,7 @@ class DProxy(object): def __init__(self, x): self.x = x - def __nonzero__(self): + def __bool__(self): return not not self.x def __hash__(self): return hash(self.x) @@ -1751,21 +1751,21 @@ for i in range(10): verify(i in p10) verify(10 not in p10) - # Safety test for __cmp__ - def unsafecmp(a, b): - try: - a.__class__.__cmp__(a, b) - except TypeError: - pass - else: - raise TestFailed, "shouldn't allow %s.__cmp__(%r, %r)" % ( - a.__class__, a, b) - unsafecmp(u"123", "123") - unsafecmp("123", u"123") - unsafecmp(1, 1.0) - unsafecmp(1.0, 1) - unsafecmp(1, 1L) - unsafecmp(1L, 1) +## # Safety test for __cmp__ +## def unsafecmp(a, b): +## try: +## a.__class__.__cmp__(a, b) +## except TypeError: +## pass +## else: +## raise TestFailed, "shouldn't allow %s.__cmp__(%r, %r)" % ( +## a.__class__, a, b) +## unsafecmp(u"123", "123") +## unsafecmp("123", u"123") +## unsafecmp(1, 1.0) +## unsafecmp(1.0, 1) +## unsafecmp(1, 1L) +## unsafecmp(1L, 1) class Letter(str): def __new__(cls, letter): @@ -2010,6 +2010,13 @@ veris(Sub.test(), Base.aProp) + # Verify that super() doesn't allow keyword args + try: + super(Base, kw=1) + except TypeError: + pass + else: + raise TestFailed, "super shouldn't accept keyword args" def inherits(): if verbose: print "Testing inheritance from basic types..." @@ -2331,7 +2338,7 @@ self.ateof = 1 return s - f = file(name=TESTFN, mode='w') + f = open(name=TESTFN, mode='w') lines = ['a\n', 'b\n', 'c\n'] try: f.writelines(lines) @@ -2387,7 +2394,7 @@ sandbox = rexec.RExec() code1 = """f = open(%r, 'w')""" % TESTFN - code2 = """f = file(%r, 'w')""" % TESTFN + code2 = """f = open(%r, 'w')""" % TESTFN code3 = """\ f = open(%r) t = type(f) # a sneaky way to get the file() constructor @@ -2462,12 +2469,43 @@ class C(base): def __init__(self, value): self.value = int(value) - def __cmp__(self, other): + def __eq__(self, other): if isinstance(other, C): - return cmp(self.value, other.value) + return self.value == other.value if isinstance(other, int) or isinstance(other, long): - return cmp(self.value, other) + return self.value == other return NotImplemented + def __ne__(self, other): + if isinstance(other, C): + return self.value != other.value + if isinstance(other, int) or isinstance(other, long): + return self.value != other + return NotImplemented + def __lt__(self, other): + if isinstance(other, C): + return self.value < other.value + if isinstance(other, int) or isinstance(other, long): + return self.value < other + return NotImplemented + def __le__(self, other): + if isinstance(other, C): + return self.value <= other.value + if isinstance(other, int) or isinstance(other, long): + return self.value <= other + return NotImplemented + def __gt__(self, other): + if isinstance(other, C): + return self.value > other.value + if isinstance(other, int) or isinstance(other, long): + return self.value > other + return NotImplemented + def __ge__(self, other): + if isinstance(other, C): + return self.value >= other.value + if isinstance(other, int) or isinstance(other, long): + return self.value >= other + return NotImplemented + c1 = C(1) c2 = C(2) c3 = C(3) @@ -2475,12 +2513,12 @@ c = {1: c1, 2: c2, 3: c3} for x in 1, 2, 3: for y in 1, 2, 3: - verify(cmp(c[x], c[y]) == cmp(x, y), "x=%d, y=%d" % (x, y)) + ##verify(cmp(c[x], c[y]) == cmp(x, y), "x=%d, y=%d" % (x, y)) for op in "<", "<=", "==", "!=", ">", ">=": verify(eval("c[x] %s c[y]" % op) == eval("x %s y" % op), "x=%d, y=%d" % (x, y)) - verify(cmp(c[x], y) == cmp(x, y), "x=%d, y=%d" % (x, y)) - verify(cmp(x, c[y]) == cmp(x, y), "x=%d, y=%d" % (x, y)) + ##verify(cmp(c[x], y) == cmp(x, y), "x=%d, y=%d" % (x, y)) + ##verify(cmp(x, c[y]) == cmp(x, y), "x=%d, y=%d" % (x, y)) def rich_comparisons(): if verbose: @@ -3463,6 +3501,13 @@ raise TestFailed, "shouldn't be able to assign to list.__bases__" try: + D.__bases__ = (C2, list) + except TypeError: + pass + else: + assert 0, "best_base calculation found wanting" + + try: del D.__bases__ except TypeError: pass @@ -3868,6 +3913,8 @@ if verbose: print "Testing method-wrapper objects..." + return # XXX should methods really support __eq__? + l = [] vereq(l.__add__, l.__add__) vereq(l.__add__, [].__add__) @@ -3903,7 +3950,7 @@ def check(expr, x, y): try: - exec expr in {'x': x, 'y': y, 'operator': operator} + exec(expr, {'x': x, 'y': y, 'operator': operator}) except TypeError: pass else: Modified: python/branches/p3yk-noslice/Lib/test/test_descrtut.py ============================================================================== --- python/branches/p3yk-noslice/Lib/test/test_descrtut.py (original) +++ python/branches/p3yk-noslice/Lib/test/test_descrtut.py Fri Dec 15 05:21:50 2006 @@ -65,14 +65,11 @@ dictionaries, such as the locals/globals dictionaries for the exec statement or the built-in function eval(): - >>> def sorted(seq): - ... seq.sort() - ... return seq >>> print sorted(a.keys()) [1, 2] - >>> exec "x = 3; print x" in a + >>> exec("x = 3; print x", a) 3 - >>> print sorted(a.keys()) + >>> print sorted(a.keys(), key=lambda x: (str(type(x)), x)) [1, 2, '__builtins__', 'x'] >>> print a['x'] 3 Modified: python/branches/p3yk-noslice/Lib/test/test_dict.py ============================================================================== --- python/branches/p3yk-noslice/Lib/test/test_dict.py (original) +++ python/branches/p3yk-noslice/Lib/test/test_dict.py Fri Dec 15 05:21:50 2006 @@ -5,6 +5,7 @@ class DictTest(unittest.TestCase): + def test_constructor(self): # calling built-in types without argument must return empty self.assertEqual(dict(), {}) @@ -368,9 +369,9 @@ d = {1: BadRepr()} self.assertRaises(Exc, repr, d) - def test_le(self): - self.assert_(not ({} < {})) - self.assert_(not ({1: 2} < {1L: 2L})) + def test_eq(self): + self.assertEqual({}, {}) + self.assertEqual({1: 2}, {1L: 2L}) class Exc(Exception): pass @@ -378,12 +379,12 @@ def __eq__(self, other): raise Exc() def __hash__(self): - return 42 + return 1 d1 = {BadCmp(): 1} d2 = {1: 1} try: - d1 < d2 + d1 == d2 except Exc: pass else: @@ -438,6 +439,16 @@ else: self.fail_("g[42] didn't raise KeyError") + def test_tuple_keyerror(self): + # SF #1576657 + d = {} + try: + d[(1,)] + except KeyError, e: + self.assertEqual(e.args, ((1,),)) + else: + self.fail("missing KeyError") + from test import mapping_tests Modified: python/branches/p3yk-noslice/Lib/test/test_dis.py ============================================================================== --- python/branches/p3yk-noslice/Lib/test/test_dis.py (original) +++ python/branches/p3yk-noslice/Lib/test/test_dis.py Fri Dec 15 05:21:50 2006 @@ -135,7 +135,7 @@ def func(count): namespace = {} func = "def foo():\n " + "".join(["\n "] * count + ["spam\n"]) - exec func in namespace + exec(func, namespace) return namespace['foo'] # Test all small ranges Modified: python/branches/p3yk-noslice/Lib/test/test_doctest.py ============================================================================== --- python/branches/p3yk-noslice/Lib/test/test_doctest.py (original) +++ python/branches/p3yk-noslice/Lib/test/test_doctest.py Fri Dec 15 05:21:50 2006 @@ -605,7 +605,7 @@ ... if isinstance(piece, doctest.Example): ... print 'Example:', (piece.source, piece.want, piece.lineno) ... else: - ... print ' Text:', `piece` + ... print ' Text:', repr(piece) Text: '\n' Example: ('x, y = 2, 3 # no output expected\n', '', 1) Text: '' @@ -2234,7 +2234,7 @@ >>> doctest.testfile('test_doctest.txt', raise_on_error=True) ... # doctest: +ELLIPSIS Traceback (most recent call last): - UnexpectedException: ... + doctest.UnexpectedException: ... >>> doctest.master = None # Reset master. If the tests contain non-ASCII characters, the tests might fail, since @@ -2366,8 +2366,8 @@ ... '''>>> assert 1 < 2 ... ''' ... \""" - >>> exec test_data in m1.__dict__ - >>> exec test_data in m2.__dict__ + >>> exec(test_data, m1.__dict__) + >>> exec(test_data, m2.__dict__) >>> m1.__dict__.update({"f2": m2._f, "g2": m2.g, "h2": m2.H}) Tests that objects outside m1 are excluded: Modified: python/branches/p3yk-noslice/Lib/test/test_enumerate.py ============================================================================== --- python/branches/p3yk-noslice/Lib/test/test_enumerate.py (original) +++ python/branches/p3yk-noslice/Lib/test/test_enumerate.py Fri Dec 15 05:21:50 2006 @@ -122,7 +122,7 @@ class TestBig(EnumerateTestCase): seq = range(10,20000,2) - res = zip(range(20000), seq) + res = list(zip(range(20000), seq)) class TestReversed(unittest.TestCase): Modified: python/branches/p3yk-noslice/Lib/test/test_exceptions.py ============================================================================== --- python/branches/p3yk-noslice/Lib/test/test_exceptions.py (original) +++ python/branches/p3yk-noslice/Lib/test/test_exceptions.py Fri Dec 15 05:21:50 2006 @@ -87,7 +87,7 @@ self.raise_catch(RuntimeError, "RuntimeError") self.raise_catch(SyntaxError, "SyntaxError") - try: exec '/\n' + try: exec('/\n') except SyntaxError: pass self.raise_catch(IndentationError, "IndentationError") @@ -196,17 +196,21 @@ test_capi2() test_capi3() - def testAttributes(self): - # test that exception attributes are happy + def test_WindowsError(self): try: - str(u'Hello \u00E1') - except Exception, e: - sampleUnicodeEncodeError = e + WindowsError + except NameError: + pass + else: + self.failUnlessEqual(str(WindowsError(1001)), + "1001") + self.failUnlessEqual(str(WindowsError(1001, "message")), + "[Error 1001] message") + self.failUnlessEqual(WindowsError(1001, "message").errno, 22) + self.failUnlessEqual(WindowsError(1001, "message").winerror, 1001) - try: - unicode('\xff') - except Exception, e: - sampleUnicodeDecodeError = e + def testAttributes(self): + # test that exception attributes are happy exceptionList = [ (BaseException, (), {'message' : '', 'args' : ()}), @@ -218,11 +222,16 @@ (SystemExit, ('foo',), {'message' : 'foo', 'args' : ('foo',), 'code' : 'foo'}), (IOError, ('foo',), - {'message' : 'foo', 'args' : ('foo',)}), + {'message' : 'foo', 'args' : ('foo',), 'filename' : None, + 'errno' : None, 'strerror' : None}), (IOError, ('foo', 'bar'), - {'message' : '', 'args' : ('foo', 'bar')}), + {'message' : '', 'args' : ('foo', 'bar'), 'filename' : None, + 'errno' : 'foo', 'strerror' : 'bar'}), (IOError, ('foo', 'bar', 'baz'), - {'message' : '', 'args' : ('foo', 'bar')}), + {'message' : '', 'args' : ('foo', 'bar'), 'filename' : 'baz', + 'errno' : 'foo', 'strerror' : 'bar'}), + (IOError, ('foo', 'bar', 'baz', 'quux'), + {'message' : '', 'args' : ('foo', 'bar', 'baz', 'quux')}), (EnvironmentError, ('errnoStr', 'strErrorStr', 'filenameStr'), {'message' : '', 'args' : ('errnoStr', 'strErrorStr'), 'strerror' : 'strErrorStr', 'errno' : 'errnoStr', @@ -249,16 +258,16 @@ 'print_file_and_line' : None, 'msg' : 'msgStr', 'filename' : None, 'lineno' : None, 'offset' : None}), (UnicodeError, (), {'message' : '', 'args' : (),}), - (sampleUnicodeEncodeError, - {'message' : '', 'args' : ('ascii', u'Hello \xe1', 6, 7, - 'ordinal not in range(128)'), - 'encoding' : 'ascii', 'object' : u'Hello \xe1', - 'start' : 6, 'reason' : 'ordinal not in range(128)'}), - (sampleUnicodeDecodeError, + (UnicodeEncodeError, ('ascii', u'a', 0, 1, 'ordinal not in range'), + {'message' : '', 'args' : ('ascii', u'a', 0, 1, + 'ordinal not in range'), + 'encoding' : 'ascii', 'object' : u'a', + 'start' : 0, 'reason' : 'ordinal not in range'}), + (UnicodeDecodeError, ('ascii', '\xff', 0, 1, 'ordinal not in range'), {'message' : '', 'args' : ('ascii', '\xff', 0, 1, - 'ordinal not in range(128)'), + 'ordinal not in range'), 'encoding' : 'ascii', 'object' : '\xff', - 'start' : 0, 'reason' : 'ordinal not in range(128)'}), + 'start' : 0, 'reason' : 'ordinal not in range'}), (UnicodeTranslateError, (u"\u3042", 0, 1, "ouch"), {'message' : '', 'args' : (u'\u3042', 0, 1, 'ouch'), 'object' : u'\u3042', 'reason' : 'ouch', @@ -274,18 +283,14 @@ except NameError: pass - for args in exceptionList: - expected = args[-1] + for exc, args, expected in exceptionList: try: - exc = args[0] - if len(args) == 2: - raise exc - else: - raise exc(*args[1]) + raise exc(*args) except BaseException, e: - if (e is not exc and # needed for sampleUnicode errors - type(e) is not exc): + if type(e) is not exc: raise + # Verify module name + self.assertEquals(type(e).__module__, 'exceptions') # Verify no ref leaks in Exc_str() s = str(e) for checkArgName in expected: @@ -332,6 +337,15 @@ return -1 self.assertRaises(RuntimeError, g) + def testUnicodeStrUsage(self): + # Make sure both instances and classes have a str and unicode + # representation. + self.failUnless(str(Exception)) + self.failUnless(unicode(Exception)) + self.failUnless(str(Exception('a'))) + self.failUnless(unicode(Exception(u'a'))) + + def test_main(): run_unittest(ExceptionTests) Modified: python/branches/p3yk-noslice/Lib/test/test_fcntl.py ============================================================================== --- python/branches/p3yk-noslice/Lib/test/test_fcntl.py (original) +++ python/branches/p3yk-noslice/Lib/test/test_fcntl.py Fri Dec 15 05:21:50 2006 @@ -25,7 +25,7 @@ 'freebsd2', 'freebsd3', 'freebsd4', 'freebsd5', 'freebsd6', 'freebsd7', 'bsdos2', 'bsdos3', 'bsdos4', - 'openbsd', 'openbsd2', 'openbsd3'): + 'openbsd', 'openbsd2', 'openbsd3', 'openbsd4'): if struct.calcsize('l') == 8: off_t = 'l' pid_t = 'i' Modified: python/branches/p3yk-noslice/Lib/test/test_format.py ============================================================================== --- python/branches/p3yk-noslice/Lib/test/test_format.py (original) +++ python/branches/p3yk-noslice/Lib/test/test_format.py Fri Dec 15 05:21:50 2006 @@ -219,8 +219,8 @@ test_exc(unicode('abc %\u3000','raw-unicode-escape'), 1, ValueError, "unsupported format character '?' (0x3000) at index 5") -test_exc('%d', '1', TypeError, "int argument required") -test_exc('%g', '1', TypeError, "float argument required") +test_exc('%d', '1', TypeError, "int argument required, not str") +test_exc('%g', '1', TypeError, "float argument required, not str") test_exc('no format', '1', TypeError, "not all arguments converted during string formatting") test_exc('no format', u'1', TypeError, Modified: python/branches/p3yk-noslice/Lib/test/test_frozen.py ============================================================================== --- python/branches/p3yk-noslice/Lib/test/test_frozen.py (original) +++ python/branches/p3yk-noslice/Lib/test/test_frozen.py Fri Dec 15 05:21:50 2006 @@ -1,4 +1,11 @@ # Test the frozen module defined in frozen.c. +# Currently test_frozen fails: +# Implementing pep3102(keyword only argument) needs changes in +# code object, which needs modification to marshal. +# However, to regenerate hard-coded marshal data in frozen.c, +# we need to run Tools/freeze/freeze.py, which currently doesn't work +# because Lib/modulefinder.py cannot handle relative module import +# This test will keep failing until Lib/modulefinder.py is fixed from test.test_support import TestFailed import sys, os Modified: python/branches/p3yk-noslice/Lib/test/test_funcattrs.py ============================================================================== --- python/branches/p3yk-noslice/Lib/test/test_funcattrs.py (original) +++ python/branches/p3yk-noslice/Lib/test/test_funcattrs.py Fri Dec 15 05:21:50 2006 @@ -19,16 +19,16 @@ except AttributeError: pass else: raise TestFailed, 'expected AttributeError' -if b.__dict__ <> {}: +if b.__dict__ != {}: raise TestFailed, 'expected unassigned func.__dict__ to be {}' b.publish = 1 -if b.publish <> 1: +if b.publish != 1: raise TestFailed, 'function attribute not set to expected value' docstring = 'its docstring' b.__doc__ = docstring -if b.__doc__ <> docstring: +if b.__doc__ != docstring: raise TestFailed, 'problem with setting __doc__ attribute' if 'publish' not in dir(b): @@ -49,7 +49,7 @@ b.__dict__ = d if b.func_dict is not d: raise TestFailed, 'func.__dict__ assignment to dictionary failed' -if b.hello <> 'world': +if b.hello != 'world': raise TestFailed, 'attribute after func.__dict__ assignment failed' f1 = F() @@ -75,13 +75,13 @@ # But setting it explicitly on the underlying function object is okay. F.a.im_func.publish = 1 -if F.a.publish <> 1: +if F.a.publish != 1: raise TestFailed, 'unbound method attribute not set to expected value' -if f1.a.publish <> 1: +if f1.a.publish != 1: raise TestFailed, 'bound method attribute access did not work' -if f2.a.publish <> 1: +if f2.a.publish != 1: raise TestFailed, 'bound method attribute access did not work' if 'publish' not in dir(F.a): @@ -117,7 +117,7 @@ F.a.im_func.__dict__ = {'one': 11, 'two': 22, 'three': 33} -if f1.a.two <> 22: +if f1.a.two != 22: raise TestFailed, 'setting __dict__' from UserDict import UserDict @@ -128,7 +128,7 @@ except (AttributeError, TypeError): pass else: raise TestFailed -if f2.a.one <> f1.a.one <> F.a.one <> 11: +if f2.a.one != f1.a.one != F.a.one != 11: raise TestFailed # im_func may not be a Python method! @@ -136,7 +136,7 @@ F.id = new.instancemethod(id, None, F) eff = F() -if eff.id() <> id(eff): +if eff.id() != id(eff): raise TestFailed try: @@ -278,7 +278,7 @@ cantset(f, "__name__", 1) # test that you can access func.__name__ in restricted mode s = """def f(): pass\nf.__name__""" - exec s in {'__builtins__':{}} + exec(s, {'__builtins__':{}}) def test_func_code(): Modified: python/branches/p3yk-noslice/Lib/test/test_functools.py ============================================================================== --- python/branches/p3yk-noslice/Lib/test/test_functools.py (original) +++ python/branches/p3yk-noslice/Lib/test/test_functools.py Fri Dec 15 05:21:50 2006 @@ -210,6 +210,13 @@ self.assertEqual(wrapper.attr, 'This is a different test') self.assertEqual(wrapper.dict_attr, f.dict_attr) + def test_builtin_update(self): + # Test for bug #1576241 + def wrapper(): + pass + functools.update_wrapper(wrapper, max) + self.assertEqual(wrapper.__name__, 'max') + self.assert_(wrapper.__doc__.startswith('max(')) class TestWraps(TestUpdateWrapper): @@ -259,6 +266,74 @@ self.assertEqual(wrapper.attr, 'This is a different test') self.assertEqual(wrapper.dict_attr, f.dict_attr) +class TestReduce(unittest.TestCase): + func = functools.reduce + + def test_reduce(self): + class Squares: + def __init__(self, max): + self.max = max + self.sofar = [] + + def __len__(self): + return len(self.sofar) + + def __getitem__(self, i): + if not 0 <= i < self.max: raise IndexError + n = len(self.sofar) + while n <= i: + self.sofar.append(n*n) + n += 1 + return self.sofar[i] + + self.assertEqual(self.func(lambda x, y: x+y, ['a', 'b', 'c'], ''), 'abc') + self.assertEqual( + self.func(lambda x, y: x+y, [['a', 'c'], [], ['d', 'w']], []), + ['a','c','d','w'] + ) + self.assertEqual(self.func(lambda x, y: x*y, range(2,8), 1), 5040) + self.assertEqual( + self.func(lambda x, y: x*y, range(2,21), 1L), + 2432902008176640000L + ) + self.assertEqual(self.func(lambda x, y: x+y, Squares(10)), 285) + self.assertEqual(self.func(lambda x, y: x+y, Squares(10), 0), 285) + self.assertEqual(self.func(lambda x, y: x+y, Squares(0), 0), 0) + self.assertRaises(TypeError, self.func) + self.assertRaises(TypeError, self.func, 42, 42) + self.assertRaises(TypeError, self.func, 42, 42, 42) + self.assertEqual(self.func(42, "1"), "1") # func is never called with one item + self.assertEqual(self.func(42, "", "1"), "1") # func is never called with one item + self.assertRaises(TypeError, self.func, 42, (42, 42)) + + class BadSeq: + def __getitem__(self, index): + raise ValueError + self.assertRaises(ValueError, self.func, 42, BadSeq()) + + # Test reduce()'s use of iterators. + def test_iterator_usage(self): + class SequenceClass: + def __init__(self, n): + self.n = n + def __getitem__(self, i): + if 0 <= i < self.n: + return i + else: + raise IndexError + + from operator import add + self.assertEqual(self.func(add, SequenceClass(5)), 10) + self.assertEqual(self.func(add, SequenceClass(5), 42), 52) + self.assertRaises(TypeError, self.func, add, SequenceClass(0)) + self.assertEqual(self.func(add, SequenceClass(0), 42), 42) + self.assertEqual(self.func(add, SequenceClass(1)), 0) + self.assertEqual(self.func(add, SequenceClass(1), 42), 42) + + d = {"one": 1, "two": 2, "three": 3} + self.assertEqual(self.func(add, d), "".join(d.keys())) + + def test_main(verbose=None): @@ -268,7 +343,8 @@ TestPartialSubclass, TestPythonPartial, TestUpdateWrapper, - TestWraps + TestWraps, + TestReduce ) test_support.run_unittest(*test_classes) Modified: python/branches/p3yk-noslice/Lib/test/test_future.py ============================================================================== --- python/branches/p3yk-noslice/Lib/test/test_future.py (original) +++ python/branches/p3yk-noslice/Lib/test/test_future.py Fri Dec 15 05:21:50 2006 @@ -82,6 +82,27 @@ else: self.fail("expected exception didn't occur") + def test_parserhack(self): + # test that the parser.c::future_hack function works as expected + # Note: although this test must pass, it's not testing the original + # bug as of 2.6 since the with statement is not optional and + # the parser hack disabled. If a new keyword is introduced in + # 2.6, change this to refer to the new future import. + try: + exec("from __future__ import division, with_statement; with = 0") + except SyntaxError: + pass + else: + self.fail("syntax error didn't occur") + + try: + exec("from __future__ import (with_statement, division); with = 0") + except SyntaxError: + pass + else: + self.fail("syntax error didn't occur") + + def test_main(): test_support.run_unittest(FutureTest) Modified: python/branches/p3yk-noslice/Lib/test/test_gc.py ============================================================================== --- python/branches/p3yk-noslice/Lib/test/test_gc.py (original) +++ python/branches/p3yk-noslice/Lib/test/test_gc.py Fri Dec 15 05:21:50 2006 @@ -153,7 +153,7 @@ # Tricky: f -> d -> f, code should call d.clear() after the exec to # break the cycle. d = {} - exec("def f(): pass\n") in d + exec("def f(): pass\n", d) gc.collect() del d expect(gc.collect(), 2, "function") Modified: python/branches/p3yk-noslice/Lib/test/test_gdbm.py ============================================================================== --- python/branches/p3yk-noslice/Lib/test/test_gdbm.py (original) +++ python/branches/p3yk-noslice/Lib/test/test_gdbm.py Fri Dec 15 05:21:50 2006 @@ -5,9 +5,9 @@ import gdbm from gdbm import error -from test.test_support import verbose, verify, TestFailed +from test.test_support import verbose, verify, TestFailed, TESTFN -filename= '/tmp/delete_me' +filename = TESTFN g = gdbm.open(filename, 'c') verify(g.keys() == []) Modified: python/branches/p3yk-noslice/Lib/test/test_getopt.py ============================================================================== --- python/branches/p3yk-noslice/Lib/test/test_getopt.py (original) +++ python/branches/p3yk-noslice/Lib/test/test_getopt.py Fri Dec 15 05:21:50 2006 @@ -10,7 +10,7 @@ """Executes a statement passed in teststr, and raises an exception (failure) if the expected exception is *not* raised.""" try: - exec teststr + exec(teststr) except expected: pass else: Modified: python/branches/p3yk-noslice/Lib/test/test_global.py ============================================================================== --- python/branches/p3yk-noslice/Lib/test/test_global.py (original) +++ python/branches/p3yk-noslice/Lib/test/test_global.py Fri Dec 15 05:21:50 2006 @@ -1,51 +1,51 @@ """Verify that warnings are issued for global statements following use.""" -from test.test_support import check_syntax +from test.test_support import run_unittest, check_syntax_error +import unittest import warnings +warnings.filterwarnings("error", module="") -warnings.filterwarnings("error", module="") +class GlobalTests(unittest.TestCase): -def compile_and_check(text, should_fail=1): - try: - compile(text, "", "exec") - except SyntaxError, msg: - if should_fail: - print "got SyntaxError as expected" - else: - print "raised unexpected SyntaxError:", text - else: - if should_fail: - print "should have raised SyntaxError:", text - else: - print "as expected, no SyntaxError" - -prog_text_1 = """ + def test1(self): + prog_text_1 = """\ def wrong1(): a = 1 b = 2 global a global b """ -compile_and_check(prog_text_1) + check_syntax_error(self, prog_text_1) -prog_text_2 = """ + def test2(self): + prog_text_2 = """\ def wrong2(): print x global x """ -compile_and_check(prog_text_2) + check_syntax_error(self, prog_text_2) -prog_text_3 = """ + def test3(self): + prog_text_3 = """\ def wrong3(): print x x = 2 global x """ -compile_and_check(prog_text_3) + check_syntax_error(self, prog_text_3) -prog_text_4 = """ + def test4(self): + prog_text_4 = """\ global x x = 2 """ -compile_and_check(prog_text_4, 0) + # this should work + compile(prog_text_4, "", "exec") + + +def test_main(): + run_unittest(GlobalTests) + +if __name__ == "__main__": + test_main() Modified: python/branches/p3yk-noslice/Lib/test/test_grammar.py ============================================================================== --- python/branches/p3yk-noslice/Lib/test/test_grammar.py (original) +++ python/branches/p3yk-noslice/Lib/test/test_grammar.py Fri Dec 15 05:21:50 2006 @@ -8,844 +8,897 @@ # regression test, the filterwarnings() call has been added to # regrtest.py. -from test.test_support import TestFailed, verify, vereq, check_syntax +from test.test_support import run_unittest, check_syntax_error +import unittest import sys +# testing import * +from sys import * -print '1. Parser' - -print '1.1 Tokens' - -print '1.1.1 Backslashes' +class TokenTests(unittest.TestCase): -# Backslash means line continuation: -x = 1 \ -+ 1 -if x != 2: raise TestFailed, 'backslash for line continuation' - -# Backslash does not means continuation in comments :\ -x = 0 -if x != 0: raise TestFailed, 'backslash ending comment' - -print '1.1.2 Numeric literals' - -print '1.1.2.1 Plain integers' -if 0xff != 255: raise TestFailed, 'hex int' -if 0377 != 255: raise TestFailed, 'octal int' -if 2147483647 != 017777777777: raise TestFailed, 'large positive int' -try: - from sys import maxint -except ImportError: - maxint = 2147483647 -if maxint == 2147483647: - # The following test will start to fail in Python 2.4; - # change the 020000000000 to -020000000000 - if -2147483647-1 != -020000000000: raise TestFailed, 'max negative int' - # XXX -2147483648 - if 037777777777 < 0: raise TestFailed, 'large oct' - if 0xffffffff < 0: raise TestFailed, 'large hex' - for s in '2147483648', '040000000000', '0x100000000': - try: - x = eval(s) - except OverflowError: - print "OverflowError on huge integer literal " + repr(s) -elif eval('maxint == 9223372036854775807'): - if eval('-9223372036854775807-1 != -01000000000000000000000'): - raise TestFailed, 'max negative int' - if eval('01777777777777777777777') < 0: raise TestFailed, 'large oct' - if eval('0xffffffffffffffff') < 0: raise TestFailed, 'large hex' - for s in '9223372036854775808', '02000000000000000000000', \ - '0x10000000000000000': - try: - x = eval(s) - except OverflowError: - print "OverflowError on huge integer literal " + repr(s) -else: - print 'Weird maxint value', maxint - -print '1.1.2.2 Long integers' -x = 0L -x = 0l -x = 0xffffffffffffffffL -x = 0xffffffffffffffffl -x = 077777777777777777L -x = 077777777777777777l -x = 123456789012345678901234567890L -x = 123456789012345678901234567890l - -print '1.1.2.3 Floating point' -x = 3.14 -x = 314. -x = 0.314 -# XXX x = 000.314 -x = .314 -x = 3e14 -x = 3E14 -x = 3e-14 -x = 3e+14 -x = 3.e14 -x = .3e14 -x = 3.1e4 - -print '1.1.3 String literals' - -x = ''; y = ""; verify(len(x) == 0 and x == y) -x = '\''; y = "'"; verify(len(x) == 1 and x == y and ord(x) == 39) -x = '"'; y = "\""; verify(len(x) == 1 and x == y and ord(x) == 34) -x = "doesn't \"shrink\" does it" -y = 'doesn\'t "shrink" does it' -verify(len(x) == 24 and x == y) -x = "does \"shrink\" doesn't it" -y = 'does "shrink" doesn\'t it' -verify(len(x) == 24 and x == y) -x = """ + def testBackslash(self): + # Backslash means line continuation: + x = 1 \ + + 1 + self.assertEquals(x, 2, 'backslash for line continuation') + + # Backslash does not means continuation in comments :\ + x = 0 + self.assertEquals(x, 0, 'backslash ending comment') + + def testPlainIntegers(self): + self.assertEquals(0xff, 255) + self.assertEquals(0377, 255) + self.assertEquals(2147483647, 017777777777) + from sys import maxint + if maxint == 2147483647: + self.assertEquals(-2147483647-1, -020000000000) + # XXX -2147483648 + self.assert_(037777777777 > 0) + self.assert_(0xffffffff > 0) + for s in '2147483648', '040000000000', '0x100000000': + try: + x = eval(s) + except OverflowError: + self.fail("OverflowError on huge integer literal %r" % s) + elif maxint == 9223372036854775807: + self.assertEquals(-9223372036854775807-1, -01000000000000000000000) + self.assert_(01777777777777777777777 > 0) + self.assert_(0xffffffffffffffff > 0) + for s in '9223372036854775808', '02000000000000000000000', \ + '0x10000000000000000': + try: + x = eval(s) + except OverflowError: + self.fail("OverflowError on huge integer literal %r" % s) + else: + self.fail('Weird maxint value %r' % maxint) + + def testLongIntegers(self): + x = 0L + x = 0l + x = 0xffffffffffffffffL + x = 0xffffffffffffffffl + x = 077777777777777777L + x = 077777777777777777l + x = 123456789012345678901234567890L + x = 123456789012345678901234567890l + + def testFloats(self): + x = 3.14 + x = 314. + x = 0.314 + # XXX x = 000.314 + x = .314 + x = 3e14 + x = 3E14 + x = 3e-14 + x = 3e+14 + x = 3.e14 + x = .3e14 + x = 3.1e4 + + def testStringLiterals(self): + x = ''; y = ""; self.assert_(len(x) == 0 and x == y) + x = '\''; y = "'"; self.assert_(len(x) == 1 and x == y and ord(x) == 39) + x = '"'; y = "\""; self.assert_(len(x) == 1 and x == y and ord(x) == 34) + x = "doesn't \"shrink\" does it" + y = 'doesn\'t "shrink" does it' + self.assert_(len(x) == 24 and x == y) + x = "does \"shrink\" doesn't it" + y = 'does "shrink" doesn\'t it' + self.assert_(len(x) == 24 and x == y) + x = """ The "quick" brown fox jumps over the 'lazy' dog. """ -y = '\nThe "quick"\nbrown fox\njumps over\nthe \'lazy\' dog.\n' -verify(x == y) -y = ''' + y = '\nThe "quick"\nbrown fox\njumps over\nthe \'lazy\' dog.\n' + self.assertEquals(x, y) + y = ''' The "quick" brown fox jumps over the 'lazy' dog. -'''; verify(x == y) -y = "\n\ +''' + self.assertEquals(x, y) + y = "\n\ The \"quick\"\n\ brown fox\n\ jumps over\n\ the 'lazy' dog.\n\ -"; verify(x == y) -y = '\n\ +" + self.assertEquals(x, y) + y = '\n\ The \"quick\"\n\ brown fox\n\ jumps over\n\ the \'lazy\' dog.\n\ -'; verify(x == y) - +' + self.assertEquals(x, y) -print '1.2 Grammar' + def testEllipsis(self): + x = ... + self.assert_(x is Ellipsis) + +class GrammarTests(unittest.TestCase): + + # single_input: NEWLINE | simple_stmt | compound_stmt NEWLINE + # XXX can't test in a script -- this rule is only used when interactive + + # file_input: (NEWLINE | stmt)* ENDMARKER + # Being tested as this very moment this very module + + # expr_input: testlist NEWLINE + # XXX Hard to test -- used only in calls to input() + + def testEvalInput(self): + # testlist ENDMARKER + x = eval('1, 0 or 1') + + def testFuncdef(self): + ### 'def' NAME parameters ':' suite + ### parameters: '(' [varargslist] ')' + ### varargslist: (fpdef ['=' test] ',')* + ### ('*' (NAME|',' fpdef ['=' test]) [',' ('**'|'*' '*') NAME] + ### | ('**'|'*' '*') NAME) + ### | fpdef ['=' test] (',' fpdef ['=' test])* [','] + ### fpdef: NAME | '(' fplist ')' + ### fplist: fpdef (',' fpdef)* [','] + ### arglist: (argument ',')* (argument | *' test [',' '**' test] | '**' test) + ### argument: [test '='] test # Really [keyword '='] test + def f1(): pass + f1() + f1(*()) + f1(*(), **{}) + def f2(one_argument): pass + def f3(two, arguments): pass + def f4(two, (compound, (argument, list))): pass + def f5((compound, first), two): pass + self.assertEquals(f2.func_code.co_varnames, ('one_argument',)) + self.assertEquals(f3.func_code.co_varnames, ('two', 'arguments')) + if sys.platform.startswith('java'): + self.assertEquals(f4.func_code.co_varnames, + ('two', '(compound, (argument, list))', 'compound', 'argument', + 'list',)) + self.assertEquals(f5.func_code.co_varnames, + ('(compound, first)', 'two', 'compound', 'first')) + else: + self.assertEquals(f4.func_code.co_varnames, + ('two', '.1', 'compound', 'argument', 'list')) + self.assertEquals(f5.func_code.co_varnames, + ('.0', 'two', 'compound', 'first')) + def a1(one_arg,): pass + def a2(two, args,): pass + def v0(*rest): pass + def v1(a, *rest): pass + def v2(a, b, *rest): pass + def v3(a, (b, c), *rest): return a, b, c, rest + + f1() + f2(1) + f2(1,) + f3(1, 2) + f3(1, 2,) + f4(1, (2, (3, 4))) + v0() + v0(1) + v0(1,) + v0(1,2) + v0(1,2,3,4,5,6,7,8,9,0) + v1(1) + v1(1,) + v1(1,2) + v1(1,2,3) + v1(1,2,3,4,5,6,7,8,9,0) + v2(1,2) + v2(1,2,3) + v2(1,2,3,4) + v2(1,2,3,4,5,6,7,8,9,0) + v3(1,(2,3)) + v3(1,(2,3),4) + v3(1,(2,3),4,5,6,7,8,9,0) + + # ceval unpacks the formal arguments into the first argcount names; + # thus, the names nested inside tuples must appear after these names. + if sys.platform.startswith('java'): + self.assertEquals(v3.func_code.co_varnames, ('a', '(b, c)', 'rest', 'b', 'c')) + else: + self.assertEquals(v3.func_code.co_varnames, ('a', '.1', 'rest', 'b', 'c')) + self.assertEquals(v3(1, (2, 3), 4), (1, 2, 3, (4,))) + def d01(a=1): pass + d01() + d01(1) + d01(*(1,)) + d01(**{'a':2}) + def d11(a, b=1): pass + d11(1) + d11(1, 2) + d11(1, **{'b':2}) + def d21(a, b, c=1): pass + d21(1, 2) + d21(1, 2, 3) + d21(*(1, 2, 3)) + d21(1, *(2, 3)) + d21(1, 2, *(3,)) + d21(1, 2, **{'c':3}) + def d02(a=1, b=2): pass + d02() + d02(1) + d02(1, 2) + d02(*(1, 2)) + d02(1, *(2,)) + d02(1, **{'b':2}) + d02(**{'a': 1, 'b': 2}) + def d12(a, b=1, c=2): pass + d12(1) + d12(1, 2) + d12(1, 2, 3) + def d22(a, b, c=1, d=2): pass + d22(1, 2) + d22(1, 2, 3) + d22(1, 2, 3, 4) + def d01v(a=1, *rest): pass + d01v() + d01v(1) + d01v(1, 2) + d01v(*(1, 2, 3, 4)) + d01v(*(1,)) + d01v(**{'a':2}) + def d11v(a, b=1, *rest): pass + d11v(1) + d11v(1, 2) + d11v(1, 2, 3) + def d21v(a, b, c=1, *rest): pass + d21v(1, 2) + d21v(1, 2, 3) + d21v(1, 2, 3, 4) + d21v(*(1, 2, 3, 4)) + d21v(1, 2, **{'c': 3}) + def d02v(a=1, b=2, *rest): pass + d02v() + d02v(1) + d02v(1, 2) + d02v(1, 2, 3) + d02v(1, *(2, 3, 4)) + d02v(**{'a': 1, 'b': 2}) + def d12v(a, b=1, c=2, *rest): pass + d12v(1) + d12v(1, 2) + d12v(1, 2, 3) + d12v(1, 2, 3, 4) + d12v(*(1, 2, 3, 4)) + d12v(1, 2, *(3, 4, 5)) + d12v(1, *(2,), **{'c': 3}) + def d22v(a, b, c=1, d=2, *rest): pass + d22v(1, 2) + d22v(1, 2, 3) + d22v(1, 2, 3, 4) + d22v(1, 2, 3, 4, 5) + d22v(*(1, 2, 3, 4)) + d22v(1, 2, *(3, 4, 5)) + d22v(1, *(2, 3), **{'d': 4}) + def d31v((x)): pass + d31v(1) + def d32v((x,)): pass + d32v((1,)) + # keyword only argument tests + def pos0key1(*, key): return key + pos0key1(key=100) + def pos2key2(p1, p2, *, k1, k2=100): return p1,p2,k1,k2 + pos2key2(1, 2, k1=100) + pos2key2(1, 2, k1=100, k2=200) + pos2key2(1, 2, k2=100, k1=200) + def pos2key2dict(p1, p2, *, k1=100, k2, **kwarg): return p1,p2,k1,k2,kwarg + pos2key2dict(1,2,k2=100,tokwarg1=100,tokwarg2=200) + pos2key2dict(1,2,tokwarg1=100,tokwarg2=200, k2=100) + + def testLambdef(self): + ### lambdef: 'lambda' [varargslist] ':' test + l1 = lambda : 0 + self.assertEquals(l1(), 0) + l2 = lambda : a[d] # XXX just testing the expression + l3 = lambda : [2 < x for x in [-1, 3, 0L]] + self.assertEquals(l3(), [0, 1, 0]) + l4 = lambda x = lambda y = lambda z=1 : z : y() : x() + self.assertEquals(l4(), 1) + l5 = lambda x, y, z=2: x + y + z + self.assertEquals(l5(1, 2), 5) + self.assertEquals(l5(1, 2, 3), 6) + check_syntax_error(self, "lambda x: x = 2") + l6 = lambda x, y, *, k=20: x+y+k + self.assertEquals(l6(1,2), 1+2+20) + self.assertEquals(l6(1,2,k=10), 1+2+10) + + + ### stmt: simple_stmt | compound_stmt + # Tested below + + def testSimpleStmt(self): + ### simple_stmt: small_stmt (';' small_stmt)* [';'] + x = 1; pass; del x + def foo(): + # verify statments that end with semi-colons + x = 1; pass; del x; + foo() + + ### small_stmt: expr_stmt | print_stmt | pass_stmt | del_stmt | flow_stmt | import_stmt | global_stmt | access_stmt + # Tested below + + def testExprStmt(self): + # (exprlist '=')* exprlist + 1 + 1, 2, 3 + x = 1 + x = 1, 2, 3 + x = y = z = 1, 2, 3 + x, y, z = 1, 2, 3 + abc = a, b, c = x, y, z = xyz = 1, 2, (3, 4) + + check_syntax_error(self, "x + 1 = 1") + check_syntax_error(self, "a + 1 = b + 2") + + def testPrintStmt(self): + # 'print' (test ',')* [test] + import StringIO + + # Can't test printing to real stdout without comparing output + # which is not available in unittest. + save_stdout = sys.stdout + sys.stdout = StringIO.StringIO() + + print 1, 2, 3 + print 1, 2, 3, + print + print 0 or 1, 0 or 1, + print 0 or 1 + + # 'print' '>>' test ',' + print >> sys.stdout, 1, 2, 3 + print >> sys.stdout, 1, 2, 3, + print >> sys.stdout + print >> sys.stdout, 0 or 1, 0 or 1, + print >> sys.stdout, 0 or 1 + + # test printing to an instance + class Gulp: + def write(self, msg): pass + + gulp = Gulp() + print >> gulp, 1, 2, 3 + print >> gulp, 1, 2, 3, + print >> gulp + print >> gulp, 0 or 1, 0 or 1, + print >> gulp, 0 or 1 + + # test print >> None + def driver(): + oldstdout = sys.stdout + sys.stdout = Gulp() + try: + tellme(Gulp()) + tellme() + finally: + sys.stdout = oldstdout + + # we should see this once + def tellme(file=sys.stdout): + print >> file, 'hello world' + + driver() + + # we should not see this at all + def tellme(file=None): + print >> file, 'goodbye universe' + + driver() + + self.assertEqual(sys.stdout.getvalue(), '''\ +1 2 3 +1 2 3 +1 1 1 +1 2 3 +1 2 3 +1 1 1 +hello world +''') + sys.stdout = save_stdout + + # syntax errors + check_syntax_error(self, 'print ,') + check_syntax_error(self, 'print >> x,') + + def testDelStmt(self): + # 'del' exprlist + abc = [1,2,3] + x, y, z = abc + xyz = x, y, z + + del abc + del x, y, (z, xyz) + + def testPassStmt(self): + # 'pass' + pass + + # flow_stmt: break_stmt | continue_stmt | return_stmt | raise_stmt + # Tested below + + def testBreakStmt(self): + # 'break' + while 1: break + + def testContinueStmt(self): + # 'continue' + i = 1 + while i: i = 0; continue + + msg = "" + while not msg: + msg = "ok" + try: + continue + msg = "continue failed to continue inside try" + except: + msg = "continue inside try called except block" + if msg != "ok": + self.fail(msg) + + msg = "" + while not msg: + msg = "finally block not called" + try: + continue + finally: + msg = "ok" + if msg != "ok": + self.fail(msg) + + def test_break_continue_loop(self): + # This test warrants an explanation. It is a test specifically for SF bugs + # #463359 and #462937. The bug is that a 'break' statement executed or + # exception raised inside a try/except inside a loop, *after* a continue + # statement has been executed in that loop, will cause the wrong number of + # arguments to be popped off the stack and the instruction pointer reset to + # a very small number (usually 0.) Because of this, the following test + # *must* written as a function, and the tracking vars *must* be function + # arguments with default values. Otherwise, the test will loop and loop. + + def test_inner(extra_burning_oil = 1, count=0): + big_hippo = 2 + while big_hippo: + count += 1 + try: + if extra_burning_oil and big_hippo == 1: + extra_burning_oil -= 1 + break + big_hippo -= 1 + continue + except: + raise + if count > 2 or big_hippo != 1: + self.fail("continue then break in try/except in loop broken!") + test_inner() + + def testReturn(self): + # 'return' [testlist] + def g1(): return + def g2(): return 1 + g1() + x = g2() + check_syntax_error(self, "class foo:return 1") + + def testYield(self): + check_syntax_error(self, "class foo:yield 1") + + def testRaise(self): + # 'raise' test [',' test] + try: raise RuntimeError, 'just testing' + except RuntimeError: pass + try: raise KeyboardInterrupt + except KeyboardInterrupt: pass + + def testImport(self): + # 'import' dotted_as_names + import sys + import time, sys + # 'from' dotted_name 'import' ('*' | '(' import_as_names ')' | import_as_names) + from time import time + from time import (time) + # not testable inside a function, but already done at top of the module + # from sys import * + from sys import path, argv + from sys import (path, argv) + from sys import (path, argv,) + + def testGlobal(self): + # 'global' NAME (',' NAME)* + global a + global a, b + global one, two, three, four, five, six, seven, eight, nine, ten + + def testAssert(self): + # assert_stmt: 'assert' test [',' test] + assert 1 + assert 1, 1 + assert lambda x:x + assert 1, lambda x:x+1 + try: + assert 0, "msg" + except AssertionError, e: + self.assertEquals(e.args[0], "msg") + else: + if __debug__: + self.fail("AssertionError not raised by assert 0") + + ### compound_stmt: if_stmt | while_stmt | for_stmt | try_stmt | funcdef | classdef + # Tested below + + def testIf(self): + # 'if' test ':' suite ('elif' test ':' suite)* ['else' ':' suite] + if 1: pass + if 1: pass + else: pass + if 0: pass + elif 0: pass + if 0: pass + elif 0: pass + elif 0: pass + elif 0: pass + else: pass + + def testWhile(self): + # 'while' test ':' suite ['else' ':' suite] + while 0: pass + while 0: pass + else: pass + + def testFor(self): + # 'for' exprlist 'in' exprlist ':' suite ['else' ':' suite] + for i in 1, 2, 3: pass + for i, j, k in (): pass + else: pass + class Squares: + def __init__(self, max): + self.max = max + self.sofar = [] + def __len__(self): return len(self.sofar) + def __getitem__(self, i): + if not 0 <= i < self.max: raise IndexError + n = len(self.sofar) + while n <= i: + self.sofar.append(n*n) + n = n+1 + return self.sofar[i] + n = 0 + for x in Squares(10): n = n+x + if n != 285: + self.fail('for over growing sequence') + + result = [] + for x, in [(1,), (2,), (3,)]: + result.append(x) + self.assertEqual(result, [1, 2, 3]) + + def testTry(self): + ### try_stmt: 'try' ':' suite (except_clause ':' suite)+ ['else' ':' suite] + ### | 'try' ':' suite 'finally' ':' suite + ### except_clause: 'except' [expr [',' expr]] + try: + 1/0 + except ZeroDivisionError: + pass + else: + pass + try: 1/0 + except EOFError: pass + except TypeError, msg: pass + except RuntimeError, msg: pass + except: pass + else: pass + try: 1/0 + except (EOFError, TypeError, ZeroDivisionError): pass + try: 1/0 + except (EOFError, TypeError, ZeroDivisionError), msg: pass + try: pass + finally: pass + + def testSuite(self): + # simple_stmt | NEWLINE INDENT NEWLINE* (stmt NEWLINE*)+ DEDENT + if 1: pass + if 1: + pass + if 1: + # + # + # + pass + pass + # + pass + # + + def testTest(self): + ### and_test ('or' and_test)* + ### and_test: not_test ('and' not_test)* + ### not_test: 'not' not_test | comparison + if not 1: pass + if 1 and 1: pass + if 1 or 1: pass + if not not not 1: pass + if not 1 and 1 and 1: pass + if 1 and 1 or 1 and 1 and 1 or not 1 and 1: pass + + def testComparison(self): + ### comparison: expr (comp_op expr)* + ### comp_op: '<'|'>'|'=='|'>='|'<='|'!='|'in'|'not' 'in'|'is'|'is' 'not' + if 1: pass + x = (1 == 1) + if 1 == 1: pass + if 1 != 1: pass + if 1 < 1: pass + if 1 > 1: pass + if 1 <= 1: pass + if 1 >= 1: pass + if 1 is 1: pass + if 1 is not 1: pass + if 1 in (): pass + if 1 not in (): pass + if 1 < 1 > 1 == 1 >= 1 <= 1 != 1 in 1 not in 1 is 1 is not 1: pass + + def testBinaryMaskOps(self): + x = 1 & 1 + x = 1 ^ 1 + x = 1 | 1 + + def testShiftOps(self): + x = 1 << 1 + x = 1 >> 1 + x = 1 << 1 >> 1 + + def testAdditiveOps(self): + x = 1 + x = 1 + 1 + x = 1 - 1 - 1 + x = 1 - 1 + 1 - 1 + 1 + + def testMultiplicativeOps(self): + x = 1 * 1 + x = 1 / 1 + x = 1 % 1 + x = 1 / 1 * 1 % 1 + + def testUnaryOps(self): + x = +1 + x = -1 + x = ~1 + x = ~1 ^ 1 & 1 | 1 & 1 ^ -1 + x = -1*1/1 + 1*1 - ---1*1 + + def testSelectors(self): + ### trailer: '(' [testlist] ')' | '[' subscript ']' | '.' NAME + ### subscript: expr | [expr] ':' [expr] + + import sys, time + c = sys.path[0] + x = time.time() + x = sys.modules['time'].time() + a = '01234' + c = a[0] + c = a[-1] + s = a[0:5] + s = a[:5] + s = a[0:] + s = a[:] + s = a[-5:] + s = a[:-1] + s = a[-4:-3] + # A rough test of SF bug 1333982. http://python.org/sf/1333982 + # The testing here is fairly incomplete. + # Test cases should include: commas with 1 and 2 colons + d = {} + d[1] = 1 + d[1,] = 2 + d[1,2] = 3 + d[1,2,3] = 4 + L = list(d) + L.sort(key=lambda x: x if isinstance(x, tuple) else ()) + self.assertEquals(str(L), '[1, (1,), (1, 2), (1, 2, 3)]') + + def testAtoms(self): + ### atom: '(' [testlist] ')' | '[' [testlist] ']' | '{' [dictsetmaker] '}' | NAME | NUMBER | STRING + ### dictsetmaker: (test ':' test (',' test ':' test)* [',']) | (test (',' test)* [',']) + + x = (1) + x = (1 or 2 or 3) + x = (1 or 2 or 3, 2, 3) + + x = [] + x = [1] + x = [1 or 2 or 3] + x = [1 or 2 or 3, 2, 3] + x = [] + + x = {} + x = {'one': 1} + x = {'one': 1,} + x = {'one' or 'two': 1 or 2} + x = {'one': 1, 'two': 2} + x = {'one': 1, 'two': 2,} + x = {'one': 1, 'two': 2, 'three': 3, 'four': 4, 'five': 5, 'six': 6} + + x = {'one'} + x = {'one', 1,} + x = {'one', 'two', 'three'} + x = {2, 3, 4,} + + x = x + x = 'x' + x = 123 + + ### exprlist: expr (',' expr)* [','] + ### testlist: test (',' test)* [','] + # These have been exercised enough above + + def testClassdef(self): + # 'class' NAME ['(' [testlist] ')'] ':' suite + class B: pass + class B2(): pass + class C1(B): pass + class C2(B): pass + class D(C1, C2, B): pass + class C: + def meth1(self): pass + def meth2(self, arg): pass + def meth3(self, a1, a2): pass + + def testListcomps(self): + # list comprehension tests + nums = [1, 2, 3, 4, 5] + strs = ["Apple", "Banana", "Coconut"] + spcs = [" Apple", " Banana ", "Coco nut "] + + self.assertEqual([s.strip() for s in spcs], ['Apple', 'Banana', 'Coco nut']) + self.assertEqual([3 * x for x in nums], [3, 6, 9, 12, 15]) + self.assertEqual([x for x in nums if x > 2], [3, 4, 5]) + self.assertEqual([(i, s) for i in nums for s in strs], + [(1, 'Apple'), (1, 'Banana'), (1, 'Coconut'), + (2, 'Apple'), (2, 'Banana'), (2, 'Coconut'), + (3, 'Apple'), (3, 'Banana'), (3, 'Coconut'), + (4, 'Apple'), (4, 'Banana'), (4, 'Coconut'), + (5, 'Apple'), (5, 'Banana'), (5, 'Coconut')]) + self.assertEqual([(i, s) for i in nums for s in [f for f in strs if "n" in f]], + [(1, 'Banana'), (1, 'Coconut'), (2, 'Banana'), (2, 'Coconut'), + (3, 'Banana'), (3, 'Coconut'), (4, 'Banana'), (4, 'Coconut'), + (5, 'Banana'), (5, 'Coconut')]) + self.assertEqual([(lambda a:[a**i for i in range(a+1)])(j) for j in range(5)], + [[1], [1, 1], [1, 2, 4], [1, 3, 9, 27], [1, 4, 16, 64, 256]]) + + def test_in_func(l): + return [0 < x < 3 for x in l if x > 2] + + self.assertEqual(test_in_func(nums), [False, False, False]) + + def test_nested_front(): + self.assertEqual([[y for y in [x, x + 1]] for x in [1,3,5]], + [[1, 2], [3, 4], [5, 6]]) + + test_nested_front() + + check_syntax_error(self, "[i, s for i in nums for s in strs]") + check_syntax_error(self, "[x if y]") + + suppliers = [ + (1, "Boeing"), + (2, "Ford"), + (3, "Macdonalds") + ] + + parts = [ + (10, "Airliner"), + (20, "Engine"), + (30, "Cheeseburger") + ] + + suppart = [ + (1, 10), (1, 20), (2, 20), (3, 30) + ] + + x = [ + (sname, pname) + for (sno, sname) in suppliers + for (pno, pname) in parts + for (sp_sno, sp_pno) in suppart + if sno == sp_sno and pno == sp_pno + ] + + self.assertEqual(x, [('Boeing', 'Airliner'), ('Boeing', 'Engine'), ('Ford', 'Engine'), + ('Macdonalds', 'Cheeseburger')]) + + def testGenexps(self): + # generator expression tests + g = ([x for x in range(10)] for x in range(1)) + self.assertEqual(g.next(), [x for x in range(10)]) + try: + g.next() + self.fail('should produce StopIteration exception') + except StopIteration: + pass -print 'single_input' # NEWLINE | simple_stmt | compound_stmt NEWLINE -# XXX can't test in a script -- this rule is only used when interactive + a = 1 + try: + g = (a for d in a) + g.next() + self.fail('should produce TypeError') + except TypeError: + pass + + self.assertEqual(list((x, y) for x in 'abcd' for y in 'abcd'), [(x, y) for x in 'abcd' for y in 'abcd']) + self.assertEqual(list((x, y) for x in 'ab' for y in 'xy'), [(x, y) for x in 'ab' for y in 'xy']) + + a = [x for x in range(10)] + b = (x for x in (y for y in a)) + self.assertEqual(sum(b), sum([x for x in range(10)])) + + self.assertEqual(sum(x**2 for x in range(10)), sum([x**2 for x in range(10)])) + self.assertEqual(sum(x*x for x in range(10) if x%2), sum([x*x for x in range(10) if x%2])) + self.assertEqual(sum(x for x in (y for y in range(10))), sum([x for x in range(10)])) + self.assertEqual(sum(x for x in (y for y in (z for z in range(10)))), sum([x for x in range(10)])) + self.assertEqual(sum(x for x in [y for y in (z for z in range(10))]), sum([x for x in range(10)])) + self.assertEqual(sum(x for x in (y for y in (z for z in range(10) if True)) if True), sum([x for x in range(10)])) + self.assertEqual(sum(x for x in (y for y in (z for z in range(10) if True) if False) if True), 0) + check_syntax_error(self, "foo(x for x in range(10), 100)") + check_syntax_error(self, "foo(100, x for x in range(10))") + + def testComprehensionSpecials(self): + # test for outmost iterable precomputation + x = 10; g = (i for i in range(x)); x = 5 + self.assertEqual(len(list(g)), 10) + + # This should hold, since we're only precomputing outmost iterable. + x = 10; t = False; g = ((i,j) for i in range(x) if t for j in range(x)) + x = 5; t = True; + self.assertEqual([(i,j) for i in range(10) for j in range(5)], list(g)) + + # Grammar allows multiple adjacent 'if's in listcomps and genexps, + # even though it's silly. Make sure it works (ifelse broke this.) + self.assertEqual([ x for x in range(10) if x % 2 if x % 3 ], [1, 5, 7]) + self.assertEqual(list(x for x in range(10) if x % 2 if x % 3), [1, 5, 7]) + + # verify unpacking single element tuples in listcomp/genexp. + self.assertEqual([x for x, in [(4,), (5,), (6,)]], [4, 5, 6]) + self.assertEqual(list(x for x, in [(7,), (8,), (9,)]), [7, 8, 9]) + + def testIfElseExpr(self): + # Test ifelse expressions in various cases + def _checkeval(msg, ret): + "helper to check that evaluation of expressions is done correctly" + print x + return ret + + self.assertEqual([ x() for x in lambda: True, lambda: False if x() ], [True]) + self.assertEqual([ x() for x in (lambda: True, lambda: False) if x() ], [True]) + self.assertEqual([ x(False) for x in (lambda x: False if x else True, lambda x: True if x else False) if x(False) ], [True]) + self.assertEqual((5 if 1 else _checkeval("check 1", 0)), 5) + self.assertEqual((_checkeval("check 2", 0) if 0 else 5), 5) + self.assertEqual((5 and 6 if 0 else 1), 1) + self.assertEqual(((5 and 6) if 0 else 1), 1) + self.assertEqual((5 and (6 if 1 else 1)), 6) + self.assertEqual((0 or _checkeval("check 3", 2) if 0 else 3), 3) + self.assertEqual((1 or _checkeval("check 4", 2) if 1 else _checkeval("check 5", 3)), 1) + self.assertEqual((0 or 5 if 1 else _checkeval("check 6", 3)), 5) + self.assertEqual((not 5 if 1 else 1), False) + self.assertEqual((not 5 if 0 else 1), 1) + self.assertEqual((6 + 1 if 1 else 2), 7) + self.assertEqual((6 - 1 if 1 else 2), 5) + self.assertEqual((6 * 2 if 1 else 4), 12) + self.assertEqual((6 / 2 if 1 else 3), 3) + self.assertEqual((6 < 4 if 0 else 2), 2) -print 'file_input' # (NEWLINE | stmt)* ENDMARKER -# Being tested as this very moment this very module - -print 'expr_input' # testlist NEWLINE -# XXX Hard to test -- used only in calls to input() - -print 'eval_input' # testlist ENDMARKER -x = eval('1, 0 or 1') - -print 'funcdef' -### 'def' NAME parameters ':' suite -### parameters: '(' [varargslist] ')' -### varargslist: (fpdef ['=' test] ',')* ('*' NAME [',' ('**'|'*' '*') NAME] -### | ('**'|'*' '*') NAME) -### | fpdef ['=' test] (',' fpdef ['=' test])* [','] -### fpdef: NAME | '(' fplist ')' -### fplist: fpdef (',' fpdef)* [','] -### arglist: (argument ',')* (argument | *' test [',' '**' test] | '**' test) -### argument: [test '='] test # Really [keyword '='] test -def f1(): pass -f1() -f1(*()) -f1(*(), **{}) -def f2(one_argument): pass -def f3(two, arguments): pass -def f4(two, (compound, (argument, list))): pass -def f5((compound, first), two): pass -vereq(f2.func_code.co_varnames, ('one_argument',)) -vereq(f3.func_code.co_varnames, ('two', 'arguments')) -if sys.platform.startswith('java'): - vereq(f4.func_code.co_varnames, - ('two', '(compound, (argument, list))', 'compound', 'argument', - 'list',)) - vereq(f5.func_code.co_varnames, - ('(compound, first)', 'two', 'compound', 'first')) -else: - vereq(f4.func_code.co_varnames, - ('two', '.1', 'compound', 'argument', 'list')) - vereq(f5.func_code.co_varnames, - ('.0', 'two', 'compound', 'first')) -def a1(one_arg,): pass -def a2(two, args,): pass -def v0(*rest): pass -def v1(a, *rest): pass -def v2(a, b, *rest): pass -def v3(a, (b, c), *rest): return a, b, c, rest -# ceval unpacks the formal arguments into the first argcount names; -# thus, the names nested inside tuples must appear after these names. -if sys.platform.startswith('java'): - verify(v3.func_code.co_varnames == ('a', '(b, c)', 'rest', 'b', 'c')) -else: - vereq(v3.func_code.co_varnames, ('a', '.1', 'rest', 'b', 'c')) -verify(v3(1, (2, 3), 4) == (1, 2, 3, (4,))) -def d01(a=1): pass -d01() -d01(1) -d01(*(1,)) -d01(**{'a':2}) -def d11(a, b=1): pass -d11(1) -d11(1, 2) -d11(1, **{'b':2}) -def d21(a, b, c=1): pass -d21(1, 2) -d21(1, 2, 3) -d21(*(1, 2, 3)) -d21(1, *(2, 3)) -d21(1, 2, *(3,)) -d21(1, 2, **{'c':3}) -def d02(a=1, b=2): pass -d02() -d02(1) -d02(1, 2) -d02(*(1, 2)) -d02(1, *(2,)) -d02(1, **{'b':2}) -d02(**{'a': 1, 'b': 2}) -def d12(a, b=1, c=2): pass -d12(1) -d12(1, 2) -d12(1, 2, 3) -def d22(a, b, c=1, d=2): pass -d22(1, 2) -d22(1, 2, 3) -d22(1, 2, 3, 4) -def d01v(a=1, *rest): pass -d01v() -d01v(1) -d01v(1, 2) -d01v(*(1, 2, 3, 4)) -d01v(*(1,)) -d01v(**{'a':2}) -def d11v(a, b=1, *rest): pass -d11v(1) -d11v(1, 2) -d11v(1, 2, 3) -def d21v(a, b, c=1, *rest): pass -d21v(1, 2) -d21v(1, 2, 3) -d21v(1, 2, 3, 4) -d21v(*(1, 2, 3, 4)) -d21v(1, 2, **{'c': 3}) -def d02v(a=1, b=2, *rest): pass -d02v() -d02v(1) -d02v(1, 2) -d02v(1, 2, 3) -d02v(1, *(2, 3, 4)) -d02v(**{'a': 1, 'b': 2}) -def d12v(a, b=1, c=2, *rest): pass -d12v(1) -d12v(1, 2) -d12v(1, 2, 3) -d12v(1, 2, 3, 4) -d12v(*(1, 2, 3, 4)) -d12v(1, 2, *(3, 4, 5)) -d12v(1, *(2,), **{'c': 3}) -def d22v(a, b, c=1, d=2, *rest): pass -d22v(1, 2) -d22v(1, 2, 3) -d22v(1, 2, 3, 4) -d22v(1, 2, 3, 4, 5) -d22v(*(1, 2, 3, 4)) -d22v(1, 2, *(3, 4, 5)) -d22v(1, *(2, 3), **{'d': 4}) -def d31v((x)): pass -d31v(1) -def d32v((x,)): pass -d32v((1,)) - -### lambdef: 'lambda' [varargslist] ':' test -print 'lambdef' -l1 = lambda : 0 -verify(l1() == 0) -l2 = lambda : a[d] # XXX just testing the expression -l3 = lambda : [2 < x for x in [-1, 3, 0L]] -verify(l3() == [0, 1, 0]) -l4 = lambda x = lambda y = lambda z=1 : z : y() : x() -verify(l4() == 1) -l5 = lambda x, y, z=2: x + y + z -verify(l5(1, 2) == 5) -verify(l5(1, 2, 3) == 6) -check_syntax("lambda x: x = 2") - -### stmt: simple_stmt | compound_stmt -# Tested below - -### simple_stmt: small_stmt (';' small_stmt)* [';'] -print 'simple_stmt' -x = 1; pass; del x -def foo(): - # verify statments that end with semi-colons - x = 1; pass; del x; -foo() - -### small_stmt: expr_stmt | print_stmt | pass_stmt | del_stmt | flow_stmt | import_stmt | global_stmt | access_stmt | exec_stmt -# Tested below - -print 'expr_stmt' # (exprlist '=')* exprlist -1 -1, 2, 3 -x = 1 -x = 1, 2, 3 -x = y = z = 1, 2, 3 -x, y, z = 1, 2, 3 -abc = a, b, c = x, y, z = xyz = 1, 2, (3, 4) -# NB these variables are deleted below - -check_syntax("x + 1 = 1") -check_syntax("a + 1 = b + 2") - -print 'print_stmt' # 'print' (test ',')* [test] -print 1, 2, 3 -print 1, 2, 3, -print -print 0 or 1, 0 or 1, -print 0 or 1 -print 'extended print_stmt' # 'print' '>>' test ',' -import sys -print >> sys.stdout, 1, 2, 3 -print >> sys.stdout, 1, 2, 3, -print >> sys.stdout -print >> sys.stdout, 0 or 1, 0 or 1, -print >> sys.stdout, 0 or 1 - -# test printing to an instance -class Gulp: - def write(self, msg): pass - -gulp = Gulp() -print >> gulp, 1, 2, 3 -print >> gulp, 1, 2, 3, -print >> gulp -print >> gulp, 0 or 1, 0 or 1, -print >> gulp, 0 or 1 - -# test print >> None -def driver(): - oldstdout = sys.stdout - sys.stdout = Gulp() - try: - tellme(Gulp()) - tellme() - finally: - sys.stdout = oldstdout - -# we should see this once -def tellme(file=sys.stdout): - print >> file, 'hello world' - -driver() - -# we should not see this at all -def tellme(file=None): - print >> file, 'goodbye universe' - -driver() - -# syntax errors -check_syntax('print ,') -check_syntax('print >> x,') - -print 'del_stmt' # 'del' exprlist -del abc -del x, y, (z, xyz) - -print 'pass_stmt' # 'pass' -pass - -print 'flow_stmt' # break_stmt | continue_stmt | return_stmt | raise_stmt -# Tested below - -print 'break_stmt' # 'break' -while 1: break - -print 'continue_stmt' # 'continue' -i = 1 -while i: i = 0; continue - -msg = "" -while not msg: - msg = "continue + try/except ok" - try: - continue - msg = "continue failed to continue inside try" - except: - msg = "continue inside try called except block" -print msg - -msg = "" -while not msg: - msg = "finally block not called" - try: - continue - finally: - msg = "continue + try/finally ok" -print msg - - -# This test warrants an explanation. It is a test specifically for SF bugs -# #463359 and #462937. The bug is that a 'break' statement executed or -# exception raised inside a try/except inside a loop, *after* a continue -# statement has been executed in that loop, will cause the wrong number of -# arguments to be popped off the stack and the instruction pointer reset to -# a very small number (usually 0.) Because of this, the following test -# *must* written as a function, and the tracking vars *must* be function -# arguments with default values. Otherwise, the test will loop and loop. - -print "testing continue and break in try/except in loop" -def test_break_continue_loop(extra_burning_oil = 1, count=0): - big_hippo = 2 - while big_hippo: - count += 1 - try: - if extra_burning_oil and big_hippo == 1: - extra_burning_oil -= 1 - break - big_hippo -= 1 - continue - except: - raise - if count > 2 or big_hippo <> 1: - print "continue then break in try/except in loop broken!" -test_break_continue_loop() - -print 'return_stmt' # 'return' [testlist] -def g1(): return -def g2(): return 1 -g1() -x = g2() -check_syntax("class foo:return 1") - -print 'yield_stmt' -check_syntax("class foo:yield 1") - -print 'raise_stmt' # 'raise' test [',' test] -try: raise RuntimeError, 'just testing' -except RuntimeError: pass -try: raise KeyboardInterrupt -except KeyboardInterrupt: pass +def test_main(): + run_unittest(TokenTests, GrammarTests) -print 'import_name' # 'import' dotted_as_names -import sys -import time, sys -print 'import_from' # 'from' dotted_name 'import' ('*' | '(' import_as_names ')' | import_as_names) -from time import time -from time import (time) -from sys import * -from sys import path, argv -from sys import (path, argv) -from sys import (path, argv,) - -print 'global_stmt' # 'global' NAME (',' NAME)* -def f(): - global a - global a, b - global one, two, three, four, five, six, seven, eight, nine, ten - -print 'exec_stmt' # 'exec' expr ['in' expr [',' expr]] -def f(): - z = None - del z - exec 'z=1+1\n' - if z != 2: raise TestFailed, 'exec \'z=1+1\'\\n' - del z - exec 'z=1+1' - if z != 2: raise TestFailed, 'exec \'z=1+1\'' - z = None - del z - import types - if hasattr(types, "UnicodeType"): - exec r"""if 1: - exec u'z=1+1\n' - if z != 2: raise TestFailed, 'exec u\'z=1+1\'\\n' - del z - exec u'z=1+1' - if z != 2: raise TestFailed, 'exec u\'z=1+1\'' -""" -f() -g = {} -exec 'z = 1' in g -if '__builtins__' in g: del g['__builtins__'] -if g != {'z': 1}: raise TestFailed, 'exec \'z = 1\' in g' -g = {} -l = {} - -import warnings -warnings.filterwarnings("ignore", "global statement", module="") -exec 'global a; a = 1; b = 2' in g, l -if '__builtins__' in g: del g['__builtins__'] -if '__builtins__' in l: del l['__builtins__'] -if (g, l) != ({'a':1}, {'b':2}): raise TestFailed, 'exec ... in g (%s), l (%s)' %(g,l) - - -print "assert_stmt" # assert_stmt: 'assert' test [',' test] -assert 1 -assert 1, 1 -assert lambda x:x -assert 1, lambda x:x+1 - -### compound_stmt: if_stmt | while_stmt | for_stmt | try_stmt | funcdef | classdef -# Tested below - -print 'if_stmt' # 'if' test ':' suite ('elif' test ':' suite)* ['else' ':' suite] -if 1: pass -if 1: pass -else: pass -if 0: pass -elif 0: pass -if 0: pass -elif 0: pass -elif 0: pass -elif 0: pass -else: pass - -print 'while_stmt' # 'while' test ':' suite ['else' ':' suite] -while 0: pass -while 0: pass -else: pass - -print 'for_stmt' # 'for' exprlist 'in' exprlist ':' suite ['else' ':' suite] -for i in 1, 2, 3: pass -for i, j, k in (): pass -else: pass -class Squares: - def __init__(self, max): - self.max = max - self.sofar = [] - def __len__(self): return len(self.sofar) - def __getitem__(self, i): - if not 0 <= i < self.max: raise IndexError - n = len(self.sofar) - while n <= i: - self.sofar.append(n*n) - n = n+1 - return self.sofar[i] -n = 0 -for x in Squares(10): n = n+x -if n != 285: raise TestFailed, 'for over growing sequence' - -result = [] -for x, in [(1,), (2,), (3,)]: - result.append(x) -vereq(result, [1, 2, 3]) - -print 'try_stmt' -### try_stmt: 'try' ':' suite (except_clause ':' suite)+ ['else' ':' suite] -### | 'try' ':' suite 'finally' ':' suite -### except_clause: 'except' [expr [',' expr]] -try: - 1/0 -except ZeroDivisionError: - pass -else: - pass -try: 1/0 -except EOFError: pass -except TypeError, msg: pass -except RuntimeError, msg: pass -except: pass -else: pass -try: 1/0 -except (EOFError, TypeError, ZeroDivisionError): pass -try: 1/0 -except (EOFError, TypeError, ZeroDivisionError), msg: pass -try: pass -finally: pass - -print 'suite' # simple_stmt | NEWLINE INDENT NEWLINE* (stmt NEWLINE*)+ DEDENT -if 1: pass -if 1: - pass -if 1: - # - # - # - pass - pass - # - pass - # - -print 'test' -### and_test ('or' and_test)* -### and_test: not_test ('and' not_test)* -### not_test: 'not' not_test | comparison -if not 1: pass -if 1 and 1: pass -if 1 or 1: pass -if not not not 1: pass -if not 1 and 1 and 1: pass -if 1 and 1 or 1 and 1 and 1 or not 1 and 1: pass - -print 'comparison' -### comparison: expr (comp_op expr)* -### comp_op: '<'|'>'|'=='|'>='|'<='|'<>'|'!='|'in'|'not' 'in'|'is'|'is' 'not' -if 1: pass -x = (1 == 1) -if 1 == 1: pass -if 1 != 1: pass -if 1 <> 1: pass -if 1 < 1: pass -if 1 > 1: pass -if 1 <= 1: pass -if 1 >= 1: pass -if 1 is 1: pass -if 1 is not 1: pass -if 1 in (): pass -if 1 not in (): pass -if 1 < 1 > 1 == 1 >= 1 <= 1 <> 1 != 1 in 1 not in 1 is 1 is not 1: pass - -print 'binary mask ops' -x = 1 & 1 -x = 1 ^ 1 -x = 1 | 1 - -print 'shift ops' -x = 1 << 1 -x = 1 >> 1 -x = 1 << 1 >> 1 - -print 'additive ops' -x = 1 -x = 1 + 1 -x = 1 - 1 - 1 -x = 1 - 1 + 1 - 1 + 1 - -print 'multiplicative ops' -x = 1 * 1 -x = 1 / 1 -x = 1 % 1 -x = 1 / 1 * 1 % 1 - -print 'unary ops' -x = +1 -x = -1 -x = ~1 -x = ~1 ^ 1 & 1 | 1 & 1 ^ -1 -x = -1*1/1 + 1*1 - ---1*1 - -print 'selectors' -### trailer: '(' [testlist] ')' | '[' subscript ']' | '.' NAME -### subscript: expr | [expr] ':' [expr] -f1() -f2(1) -f2(1,) -f3(1, 2) -f3(1, 2,) -f4(1, (2, (3, 4))) -v0() -v0(1) -v0(1,) -v0(1,2) -v0(1,2,3,4,5,6,7,8,9,0) -v1(1) -v1(1,) -v1(1,2) -v1(1,2,3) -v1(1,2,3,4,5,6,7,8,9,0) -v2(1,2) -v2(1,2,3) -v2(1,2,3,4) -v2(1,2,3,4,5,6,7,8,9,0) -v3(1,(2,3)) -v3(1,(2,3),4) -v3(1,(2,3),4,5,6,7,8,9,0) -print -import sys, time -c = sys.path[0] -x = time.time() -x = sys.modules['time'].time() -a = '01234' -c = a[0] -c = a[-1] -s = a[0:5] -s = a[:5] -s = a[0:] -s = a[:] -s = a[-5:] -s = a[:-1] -s = a[-4:-3] -# A rough test of SF bug 1333982. http://python.org/sf/1333982 -# The testing here is fairly incomplete. -# Test cases should include: commas with 1 and 2 colons -d = {} -d[1] = 1 -d[1,] = 2 -d[1,2] = 3 -d[1,2,3] = 4 -L = list(d) -L.sort() -print L - - -print 'atoms' -### atom: '(' [testlist] ')' | '[' [testlist] ']' | '{' [dictmaker] '}' | '`' testlist '`' | NAME | NUMBER | STRING -### dictmaker: test ':' test (',' test ':' test)* [','] - -x = (1) -x = (1 or 2 or 3) -x = (1 or 2 or 3, 2, 3) - -x = [] -x = [1] -x = [1 or 2 or 3] -x = [1 or 2 or 3, 2, 3] -x = [] - -x = {} -x = {'one': 1} -x = {'one': 1,} -x = {'one' or 'two': 1 or 2} -x = {'one': 1, 'two': 2} -x = {'one': 1, 'two': 2,} -x = {'one': 1, 'two': 2, 'three': 3, 'four': 4, 'five': 5, 'six': 6} - -x = `x` -x = `1 or 2 or 3` -x = x -x = 'x' -x = 123 - -### exprlist: expr (',' expr)* [','] -### testlist: test (',' test)* [','] -# These have been exercised enough above - -print 'classdef' # 'class' NAME ['(' [testlist] ')'] ':' suite -class B: pass -class B2(): pass -class C1(B): pass -class C2(B): pass -class D(C1, C2, B): pass -class C: - def meth1(self): pass - def meth2(self, arg): pass - def meth3(self, a1, a2): pass - -# list comprehension tests -nums = [1, 2, 3, 4, 5] -strs = ["Apple", "Banana", "Coconut"] -spcs = [" Apple", " Banana ", "Coco nut "] - -print [s.strip() for s in spcs] -print [3 * x for x in nums] -print [x for x in nums if x > 2] -print [(i, s) for i in nums for s in strs] -print [(i, s) for i in nums for s in [f for f in strs if "n" in f]] -print [(lambda a:[a**i for i in range(a+1)])(j) for j in range(5)] - -def test_in_func(l): - return [None < x < 3 for x in l if x > 2] - -print test_in_func(nums) - -def test_nested_front(): - print [[y for y in [x, x + 1]] for x in [1,3,5]] - -test_nested_front() - -check_syntax("[i, s for i in nums for s in strs]") -check_syntax("[x if y]") - -suppliers = [ - (1, "Boeing"), - (2, "Ford"), - (3, "Macdonalds") -] - -parts = [ - (10, "Airliner"), - (20, "Engine"), - (30, "Cheeseburger") -] - -suppart = [ - (1, 10), (1, 20), (2, 20), (3, 30) -] - -print [ - (sname, pname) - for (sno, sname) in suppliers - for (pno, pname) in parts - for (sp_sno, sp_pno) in suppart - if sno == sp_sno and pno == sp_pno -] - -# generator expression tests -g = ([x for x in range(10)] for x in range(1)) -verify(g.next() == [x for x in range(10)]) -try: - g.next() - raise TestFailed, 'should produce StopIteration exception' -except StopIteration: - pass - -a = 1 -try: - g = (a for d in a) - g.next() - raise TestFailed, 'should produce TypeError' -except TypeError: - pass - -verify(list((x, y) for x in 'abcd' for y in 'abcd') == [(x, y) for x in 'abcd' for y in 'abcd']) -verify(list((x, y) for x in 'ab' for y in 'xy') == [(x, y) for x in 'ab' for y in 'xy']) - -a = [x for x in range(10)] -b = (x for x in (y for y in a)) -verify(sum(b) == sum([x for x in range(10)])) - -verify(sum(x**2 for x in range(10)) == sum([x**2 for x in range(10)])) -verify(sum(x*x for x in range(10) if x%2) == sum([x*x for x in range(10) if x%2])) -verify(sum(x for x in (y for y in range(10))) == sum([x for x in range(10)])) -verify(sum(x for x in (y for y in (z for z in range(10)))) == sum([x for x in range(10)])) -verify(sum(x for x in [y for y in (z for z in range(10))]) == sum([x for x in range(10)])) -verify(sum(x for x in (y for y in (z for z in range(10) if True)) if True) == sum([x for x in range(10)])) -verify(sum(x for x in (y for y in (z for z in range(10) if True) if False) if True) == 0) -check_syntax("foo(x for x in range(10), 100)") -check_syntax("foo(100, x for x in range(10))") - -# test for outmost iterable precomputation -x = 10; g = (i for i in range(x)); x = 5 -verify(len(list(g)) == 10) - -# This should hold, since we're only precomputing outmost iterable. -x = 10; t = False; g = ((i,j) for i in range(x) if t for j in range(x)) -x = 5; t = True; -verify([(i,j) for i in range(10) for j in range(5)] == list(g)) - -# Grammar allows multiple adjacent 'if's in listcomps and genexps, -# even though it's silly. Make sure it works (ifelse broke this.) -verify([ x for x in range(10) if x % 2 if x % 3 ], [1, 5, 7]) -verify((x for x in range(10) if x % 2 if x % 3), [1, 5, 7]) - -# Test ifelse expressions in various cases -def _checkeval(msg, ret): - "helper to check that evaluation of expressions is done correctly" - print x - return ret - -verify([ x() for x in lambda: True, lambda: False if x() ] == [True]) -verify([ x() for x in (lambda: True, lambda: False) if x() ] == [True]) -verify([ x(False) for x in (lambda x: False if x else True, lambda x: True if x else False) if x(False) ] == [True]) -verify((5 if 1 else _checkeval("check 1", 0)) == 5) -verify((_checkeval("check 2", 0) if 0 else 5) == 5) -verify((5 and 6 if 0 else 1) == 1) -verify(((5 and 6) if 0 else 1) == 1) -verify((5 and (6 if 1 else 1)) == 6) -verify((0 or _checkeval("check 3", 2) if 0 else 3) == 3) -verify((1 or _checkeval("check 4", 2) if 1 else _checkeval("check 5", 3)) == 1) -verify((0 or 5 if 1 else _checkeval("check 6", 3)) == 5) -verify((not 5 if 1 else 1) == False) -verify((not 5 if 0 else 1) == 1) -verify((6 + 1 if 1 else 2) == 7) -verify((6 - 1 if 1 else 2) == 5) -verify((6 * 2 if 1 else 4) == 12) -verify((6 / 2 if 1 else 3) == 3) -verify((6 < 4 if 0 else 2) == 2) +if __name__ == '__main__': + test_main() Modified: python/branches/p3yk-noslice/Lib/test/test_gzip.py ============================================================================== --- python/branches/p3yk-noslice/Lib/test/test_gzip.py (original) +++ python/branches/p3yk-noslice/Lib/test/test_gzip.py Fri Dec 15 05:21:50 2006 @@ -128,6 +128,17 @@ f.seek(newpos) # positive seek f.close() + def test_seek_whence(self): + self.test_write() + # Try seek(whence=1), read test + + f = gzip.GzipFile(self.filename) + f.read(10) + f.seek(10, whence=1) + y = f.read(10) + f.close() + self.assertEquals(y, data1[20:30]) + def test_seek_write(self): # Try seek, write test f = gzip.GzipFile(self.filename, 'w') Modified: python/branches/p3yk-noslice/Lib/test/test_heapq.py ============================================================================== --- python/branches/p3yk-noslice/Lib/test/test_heapq.py (original) +++ python/branches/p3yk-noslice/Lib/test/test_heapq.py Fri Dec 15 05:21:50 2006 @@ -136,6 +136,7 @@ "Dummy element that always raises an error during comparison" def __cmp__(self, other): raise ZeroDivisionError + __eq__ = __ne__ = __lt__ = __le__ = __gt__ = __ge__ = __cmp__ def R(seqn): 'Regular generator' @@ -253,7 +254,7 @@ def test_iterable_args(self): for f in (nlargest, nsmallest): - for s in ("123", "", range(1000), ('do', 1.2), xrange(2000,2200,5)): + for s in ("123", "", range(1000), (1, 1.2), xrange(2000,2200,5)): for g in (G, I, Ig, L, R): self.assertEqual(f(2, g(s)), f(2,s)) self.assertEqual(f(2, S(s)), []) Modified: python/branches/p3yk-noslice/Lib/test/test_httplib.py ============================================================================== --- python/branches/p3yk-noslice/Lib/test/test_httplib.py (original) +++ python/branches/p3yk-noslice/Lib/test/test_httplib.py Fri Dec 15 05:21:50 2006 @@ -10,9 +10,10 @@ def __init__(self, text, fileclass=StringIO.StringIO): self.text = text self.fileclass = fileclass + self.data = '' def sendall(self, data): - self.data = data + self.data += data def makefile(self, mode, bufsize=None): if mode != 'r' and mode != 'rb': @@ -70,103 +71,86 @@ conn.request('POST', '/', body, headers) self.assertEqual(conn._buffer.count[header.lower()], 1) -# Collect output to a buffer so that we don't have to cope with line-ending -# issues across platforms. Specifically, the headers will have \r\n pairs -# and some platforms will strip them from the output file. - -def test(): - buf = StringIO.StringIO() - _stdout = sys.stdout - try: - sys.stdout = buf - _test() - finally: - sys.stdout = _stdout - - # print individual lines with endings stripped - s = buf.getvalue() - for line in s.split("\n"): - print line.strip() - -def _test(): - # Test HTTP status lines - - body = "HTTP/1.1 200 Ok\r\n\r\nText" - sock = FakeSocket(body) - resp = httplib.HTTPResponse(sock, 1) - resp.begin() - print resp.read() - resp.close() - - body = "HTTP/1.1 400.100 Not Ok\r\n\r\nText" - sock = FakeSocket(body) - resp = httplib.HTTPResponse(sock, 1) - try: +class BasicTest(TestCase): + def test_status_lines(self): + # Test HTTP status lines + + body = "HTTP/1.1 200 Ok\r\n\r\nText" + sock = FakeSocket(body) + resp = httplib.HTTPResponse(sock) resp.begin() - except httplib.BadStatusLine: - print "BadStatusLine raised as expected" - else: - print "Expect BadStatusLine" - - # Check invalid host_port - - for hp in ("www.python.org:abc", "www.python.org:"): - try: - h = httplib.HTTP(hp) - except httplib.InvalidURL: - print "InvalidURL raised as expected" - else: - print "Expect InvalidURL" - - for hp,h,p in (("[fe80::207:e9ff:fe9b]:8000", "fe80::207:e9ff:fe9b", 8000), - ("www.python.org:80", "www.python.org", 80), - ("www.python.org", "www.python.org", 80), - ("[fe80::207:e9ff:fe9b]", "fe80::207:e9ff:fe9b", 80)): - try: - http = httplib.HTTP(hp) - except httplib.InvalidURL: - print "InvalidURL raised erroneously" - c = http._conn - if h != c.host: raise AssertionError, ("Host incorrectly parsed", h, c.host) - if p != c.port: raise AssertionError, ("Port incorrectly parsed", p, c.host) - - # test response with multiple message headers with the same field name. - text = ('HTTP/1.1 200 OK\r\n' - 'Set-Cookie: Customer="WILE_E_COYOTE"; Version="1"; Path="/acme"\r\n' - 'Set-Cookie: Part_Number="Rocket_Launcher_0001"; Version="1";' - ' Path="/acme"\r\n' - '\r\n' - 'No body\r\n') - hdr = ('Customer="WILE_E_COYOTE"; Version="1"; Path="/acme"' - ', ' - 'Part_Number="Rocket_Launcher_0001"; Version="1"; Path="/acme"') - s = FakeSocket(text) - r = httplib.HTTPResponse(s, 1) - r.begin() - cookies = r.getheader("Set-Cookie") - if cookies != hdr: - raise AssertionError, "multiple headers not combined properly" - - # Test that the library doesn't attempt to read any data - # from a HEAD request. (Tickles SF bug #622042.) - sock = FakeSocket( - 'HTTP/1.1 200 OK\r\n' - 'Content-Length: 14432\r\n' - '\r\n', - NoEOFStringIO) - resp = httplib.HTTPResponse(sock, 1, method="HEAD") - resp.begin() - if resp.read() != "": - raise AssertionError, "Did not expect response from HEAD request" - resp.close() + self.assertEqual(resp.read(), 'Text') + resp.close() + body = "HTTP/1.1 400.100 Not Ok\r\n\r\nText" + sock = FakeSocket(body) + resp = httplib.HTTPResponse(sock) + self.assertRaises(httplib.BadStatusLine, resp.begin) + + def test_host_port(self): + # Check invalid host_port + + for hp in ("www.python.org:abc", "www.python.org:"): + self.assertRaises(httplib.InvalidURL, httplib.HTTP, hp) + + for hp, h, p in (("[fe80::207:e9ff:fe9b]:8000", "fe80::207:e9ff:fe9b", 8000), + ("www.python.org:80", "www.python.org", 80), + ("www.python.org", "www.python.org", 80), + ("[fe80::207:e9ff:fe9b]", "fe80::207:e9ff:fe9b", 80)): + http = httplib.HTTP(hp) + c = http._conn + if h != c.host: self.fail("Host incorrectly parsed: %s != %s" % (h, c.host)) + if p != c.port: self.fail("Port incorrectly parsed: %s != %s" % (p, c.host)) + + def test_response_headers(self): + # test response with multiple message headers with the same field name. + text = ('HTTP/1.1 200 OK\r\n' + 'Set-Cookie: Customer="WILE_E_COYOTE"; Version="1"; Path="/acme"\r\n' + 'Set-Cookie: Part_Number="Rocket_Launcher_0001"; Version="1";' + ' Path="/acme"\r\n' + '\r\n' + 'No body\r\n') + hdr = ('Customer="WILE_E_COYOTE"; Version="1"; Path="/acme"' + ', ' + 'Part_Number="Rocket_Launcher_0001"; Version="1"; Path="/acme"') + s = FakeSocket(text) + r = httplib.HTTPResponse(s) + r.begin() + cookies = r.getheader("Set-Cookie") + if cookies != hdr: + self.fail("multiple headers not combined properly") + + def test_read_head(self): + # Test that the library doesn't attempt to read any data + # from a HEAD request. (Tickles SF bug #622042.) + sock = FakeSocket( + 'HTTP/1.1 200 OK\r\n' + 'Content-Length: 14432\r\n' + '\r\n', + NoEOFStringIO) + resp = httplib.HTTPResponse(sock, method="HEAD") + resp.begin() + if resp.read() != "": + self.fail("Did not expect response from HEAD request") + resp.close() + + def test_send_file(self): + expected = 'GET /foo HTTP/1.1\r\nHost: example.com\r\n' \ + 'Accept-Encoding: identity\r\nContent-Length:' + + body = open(__file__, 'rb') + conn = httplib.HTTPConnection('example.com') + sock = FakeSocket(body) + conn.sock = sock + conn.request('GET', '/foo', body) + self.assertTrue(sock.data.startswith(expected)) class OfflineTest(TestCase): def test_responses(self): self.assertEquals(httplib.responses[httplib.NOT_FOUND], "Not Found") def test_main(verbose=None): - tests = [HeaderTests,OfflineTest] - test_support.run_unittest(*tests) + test_support.run_unittest(HeaderTests, OfflineTest, BasicTest) -test() +if __name__ == '__main__': + test_main() Modified: python/branches/p3yk-noslice/Lib/test/test_imp.py ============================================================================== --- python/branches/p3yk-noslice/Lib/test/test_imp.py (original) +++ python/branches/p3yk-noslice/Lib/test/test_imp.py Fri Dec 15 05:21:50 2006 @@ -1,43 +1,47 @@ import imp -from test.test_support import TestFailed, TestSkipped -try: - import thread -except ImportError: - raise TestSkipped("test only valid when thread support is available") - -def verify_lock_state(expected): - if imp.lock_held() != expected: - raise TestFailed("expected imp.lock_held() to be %r" % expected) - -def testLock(): - LOOPS = 50 - - # The import lock may already be held, e.g. if the test suite is run - # via "import test.autotest". - lock_held_at_start = imp.lock_held() - verify_lock_state(lock_held_at_start) - - for i in range(LOOPS): - imp.acquire_lock() - verify_lock_state(True) +import thread +import unittest +from test import test_support - for i in range(LOOPS): - imp.release_lock() - # The original state should be restored now. - verify_lock_state(lock_held_at_start) +class LockTests(unittest.TestCase): - if not lock_held_at_start: - try: + """Very basic test of import lock functions.""" + + def verify_lock_state(self, expected): + self.failUnlessEqual(imp.lock_held(), expected, + "expected imp.lock_held() to be %r" % expected) + def testLock(self): + LOOPS = 50 + + # The import lock may already be held, e.g. if the test suite is run + # via "import test.autotest". + lock_held_at_start = imp.lock_held() + self.verify_lock_state(lock_held_at_start) + + for i in range(LOOPS): + imp.acquire_lock() + self.verify_lock_state(True) + + for i in range(LOOPS): imp.release_lock() - except RuntimeError: - pass - else: - raise TestFailed("release_lock() without lock should raise " - "RuntimeError") + + # The original state should be restored now. + self.verify_lock_state(lock_held_at_start) + + if not lock_held_at_start: + try: + imp.release_lock() + except RuntimeError: + pass + else: + self.fail("release_lock() without lock should raise " + "RuntimeError") def test_main(): - testLock() + test_support.run_unittest( + LockTests, + ) if __name__ == "__main__": test_main() Modified: python/branches/p3yk-noslice/Lib/test/test_import.py ============================================================================== --- python/branches/p3yk-noslice/Lib/test/test_import.py (original) +++ python/branches/p3yk-noslice/Lib/test/test_import.py Fri Dec 15 05:21:50 2006 @@ -1,21 +1,11 @@ -from test.test_support import TESTFN, TestFailed +from test.test_support import TESTFN, run_unittest +import unittest import os import random import sys import py_compile -# Brief digression to test that import is case-sensitive: if we got this -# far, we know for sure that "random" exists. -try: - import RAnDoM -except ImportError: - pass -else: - raise TestFailed("import of RAnDoM should have failed (case mismatch)") - -# Another brief digression to test the accuracy of manifest float constants. -from test import double_const # don't blink -- that *was* the test def remove_files(name): for f in (name + os.extsep + "py", @@ -26,199 +16,206 @@ if os.path.exists(f): os.remove(f) -def test_with_extension(ext): # ext normally ".py"; perhaps ".pyw" - source = TESTFN + ext - pyo = TESTFN + os.extsep + "pyo" - if sys.platform.startswith('java'): - pyc = TESTFN + "$py.class" - else: - pyc = TESTFN + os.extsep + "pyc" - - f = open(source, "w") - print >> f, "# This tests Python's ability to import a", ext, "file." - a = random.randrange(1000) - b = random.randrange(1000) - print >> f, "a =", a - print >> f, "b =", b - f.close() - - try: - try: - mod = __import__(TESTFN) - except ImportError, err: - raise ValueError("import from %s failed: %s" % (ext, err)) - if mod.a != a or mod.b != b: - print a, "!=", mod.a - print b, "!=", mod.b - raise ValueError("module loaded (%s) but contents invalid" % mod) - finally: - os.unlink(source) +class ImportTest(unittest.TestCase): - try: + def testCaseSensitivity(self): + # Brief digression to test that import is case-sensitive: if we got this + # far, we know for sure that "random" exists. try: - reload(mod) - except ImportError, err: - raise ValueError("import from .pyc/.pyo failed: %s" % err) - finally: - try: - os.unlink(pyc) - except os.error: - pass - try: - os.unlink(pyo) - except os.error: + import RAnDoM + except ImportError: pass - del sys.modules[TESTFN] + else: + self.fail("import of RAnDoM should have failed (case mismatch)") -sys.path.insert(0, os.curdir) -try: - test_with_extension(os.extsep + "py") - if sys.platform.startswith("win"): - for ext in ".PY", ".Py", ".pY", ".pyw", ".PYW", ".pYw": - test_with_extension(ext) -finally: - del sys.path[0] - -# Verify that the imp module can correctly load and find .py files -import imp -x = imp.find_module("os") -os = imp.load_module("os", *x) - -def test_module_with_large_stack(module): - # create module w/list of 65000 elements to test bug #561858 - filename = module + os.extsep + 'py' - - # create a file with a list of 65000 elements - f = open(filename, 'w+') - f.write('d = [\n') - for i in range(65000): - f.write('"",\n') - f.write(']') - f.close() - - # compile & remove .py file, we only need .pyc (or .pyo) - f = open(filename, 'r') - py_compile.compile(filename) - f.close() - os.unlink(filename) - - # need to be able to load from current dir - sys.path.append('') - - # this used to crash - exec 'import ' + module - - # cleanup - del sys.path[-1] - for ext in 'pyc', 'pyo': - fname = module + os.extsep + ext - if os.path.exists(fname): - os.unlink(fname) - -test_module_with_large_stack('longlist') - -def test_failing_import_sticks(): - source = TESTFN + os.extsep + "py" - f = open(source, "w") - print >> f, "a = 1/0" - f.close() - - # New in 2.4, we shouldn't be able to import that no matter how often - # we try. - sys.path.insert(0, os.curdir) - try: - for i in 1, 2, 3: - try: - mod = __import__(TESTFN) - except ZeroDivisionError: - if TESTFN in sys.modules: - raise TestFailed("damaged module in sys.modules", i) + def testDoubleConst(self): + # Another brief digression to test the accuracy of manifest float constants. + from test import double_const # don't blink -- that *was* the test + + def testImport(self): + def test_with_extension(ext): + # ext normally ".py"; perhaps ".pyw" + source = TESTFN + ext + pyo = TESTFN + os.extsep + "pyo" + if sys.platform.startswith('java'): + pyc = TESTFN + "$py.class" else: - raise TestFailed("was able to import a damaged module", i) - finally: - sys.path.pop(0) - remove_files(TESTFN) - -test_failing_import_sticks() - -def test_failing_reload(): - # A failing reload should leave the module object in sys.modules. - source = TESTFN + os.extsep + "py" - f = open(source, "w") - print >> f, "a = 1" - print >> f, "b = 2" - f.close() - - sys.path.insert(0, os.curdir) - try: - mod = __import__(TESTFN) - if TESTFN not in sys.modules: - raise TestFailed("expected module in sys.modules") - if mod.a != 1 or mod.b != 2: - raise TestFailed("module has wrong attribute values") - - # On WinXP, just replacing the .py file wasn't enough to - # convince reload() to reparse it. Maybe the timestamp didn't - # move enough. We force it to get reparsed by removing the - # compiled file too. - remove_files(TESTFN) + pyc = TESTFN + os.extsep + "pyc" + + f = open(source, "w") + print >> f, "# This tests Python's ability to import a", ext, "file." + a = random.randrange(1000) + b = random.randrange(1000) + print >> f, "a =", a + print >> f, "b =", b + f.close() + + try: + try: + mod = __import__(TESTFN) + except ImportError, err: + self.fail("import from %s failed: %s" % (ext, err)) + + self.assertEquals(mod.a, a, + "module loaded (%s) but contents invalid" % mod) + self.assertEquals(mod.b, b, + "module loaded (%s) but contents invalid" % mod) + finally: + os.unlink(source) - # Now damage the module. + try: + try: + reload(mod) + except ImportError, err: + self.fail("import from .pyc/.pyo failed: %s" % err) + finally: + try: + os.unlink(pyc) + except OSError: + pass + try: + os.unlink(pyo) + except OSError: + pass + del sys.modules[TESTFN] + + sys.path.insert(0, os.curdir) + try: + test_with_extension(os.extsep + "py") + if sys.platform.startswith("win"): + for ext in ".PY", ".Py", ".pY", ".pyw", ".PYW", ".pYw": + test_with_extension(ext) + finally: + del sys.path[0] + + def testImpModule(self): + # Verify that the imp module can correctly load and find .py files + import imp + x = imp.find_module("os") + os = imp.load_module("os", *x) + + def test_module_with_large_stack(self, module='longlist'): + # create module w/list of 65000 elements to test bug #561858 + filename = module + os.extsep + 'py' + + # create a file with a list of 65000 elements + f = open(filename, 'w+') + f.write('d = [\n') + for i in range(65000): + f.write('"",\n') + f.write(']') + f.close() + + # compile & remove .py file, we only need .pyc (or .pyo) + f = open(filename, 'r') + py_compile.compile(filename) + f.close() + os.unlink(filename) + + # need to be able to load from current dir + sys.path.append('') + + # this used to crash + exec('import ' + module) + + # cleanup + del sys.path[-1] + for ext in 'pyc', 'pyo': + fname = module + os.extsep + ext + if os.path.exists(fname): + os.unlink(fname) + + def test_failing_import_sticks(self): + source = TESTFN + os.extsep + "py" f = open(source, "w") - print >> f, "a = 10" - print >> f, "b = 20//0" + print >> f, "a = 1/0" f.close() + + # New in 2.4, we shouldn't be able to import that no matter how often + # we try. + sys.path.insert(0, os.curdir) try: - reload(mod) - except ZeroDivisionError: - pass - else: - raise TestFailed("was able to reload a damaged module") + for i in 1, 2, 3: + try: + mod = __import__(TESTFN) + except ZeroDivisionError: + if TESTFN in sys.modules: + self.fail("damaged module in sys.modules on %i. try" % i) + else: + self.fail("was able to import a damaged module on %i. try" % i) + finally: + sys.path.pop(0) + remove_files(TESTFN) + + def test_failing_reload(self): + # A failing reload should leave the module object in sys.modules. + source = TESTFN + os.extsep + "py" + f = open(source, "w") + print >> f, "a = 1" + print >> f, "b = 2" + f.close() + + sys.path.insert(0, os.curdir) + try: + mod = __import__(TESTFN) + self.assert_(TESTFN in sys.modules, "expected module in sys.modules") + self.assertEquals(mod.a, 1, "module has wrong attribute values") + self.assertEquals(mod.b, 2, "module has wrong attribute values") + + # On WinXP, just replacing the .py file wasn't enough to + # convince reload() to reparse it. Maybe the timestamp didn't + # move enough. We force it to get reparsed by removing the + # compiled file too. + remove_files(TESTFN) + + # Now damage the module. + f = open(source, "w") + print >> f, "a = 10" + print >> f, "b = 20//0" + f.close() + + self.assertRaises(ZeroDivisionError, reload, mod) + + # But we still expect the module to be in sys.modules. + mod = sys.modules.get(TESTFN) + self.failIf(mod is None, "expected module to still be in sys.modules") + + # We should have replaced a w/ 10, but the old b value should + # stick. + self.assertEquals(mod.a, 10, "module has wrong attribute values") + self.assertEquals(mod.b, 2, "module has wrong attribute values") + + finally: + sys.path.pop(0) + remove_files(TESTFN) + if TESTFN in sys.modules: + del sys.modules[TESTFN] + + def test_import_name_binding(self): + # import x.y.z binds x in the current namespace + import test as x + import test.test_support + self.assert_(x is test, x.__name__) + self.assert_(hasattr(test.test_support, "__file__")) + + # import x.y.z as w binds z as w + import test.test_support as y + self.assert_(y is test.test_support, y.__name__) + + def test_import_initless_directory_warning(self): + import warnings + oldfilters = warnings.filters[:] + warnings.simplefilter('error', ImportWarning); + try: + # Just a random non-package directory we always expect to be + # somewhere in sys.path... + self.assertRaises(ImportWarning, __import__, "site-packages") + finally: + warnings.filters = oldfilters - # But we still expect the module to be in sys.modules. - mod = sys.modules.get(TESTFN) - if mod is None: - raise TestFailed("expected module to still be in sys.modules") - # We should have replaced a w/ 10, but the old b value should - # stick. - if mod.a != 10 or mod.b != 2: - raise TestFailed("module has wrong attribute values") - - finally: - sys.path.pop(0) - remove_files(TESTFN) - if TESTFN in sys.modules: - del sys.modules[TESTFN] - -test_failing_reload() - -def test_import_name_binding(): - # import x.y.z binds x in the current namespace - import test as x - import test.test_support - assert x is test, x.__name__ - assert hasattr(test.test_support, "__file__") - - # import x.y.z as w binds z as w - import test.test_support as y - assert y is test.test_support, y.__name__ - -test_import_name_binding() - -def test_import_initless_directory_warning(): - import warnings - oldfilters = warnings.filters[:] - warnings.simplefilter('error', ImportWarning); - try: - # Just a random non-package directory we always expect to be - # somewhere in sys.path... - __import__("site-packages") - except ImportWarning: - pass - else: - raise AssertionError - finally: - warnings.filters = oldfilters +def test_main(verbose=None): + run_unittest(ImportTest) -test_import_initless_directory_warning() +if __name__ == '__main__': + test_main() Modified: python/branches/p3yk-noslice/Lib/test/test_importhooks.py ============================================================================== --- python/branches/p3yk-noslice/Lib/test/test_importhooks.py (original) +++ python/branches/p3yk-noslice/Lib/test/test_importhooks.py Fri Dec 15 05:21:50 2006 @@ -81,7 +81,7 @@ mod.__loader__ = self if ispkg: mod.__path__ = self._get__path__() - exec code in mod.__dict__ + exec(code, mod.__dict__) return mod Modified: python/branches/p3yk-noslice/Lib/test/test_inspect.py ============================================================================== --- python/branches/p3yk-noslice/Lib/test/test_inspect.py (original) +++ python/branches/p3yk-noslice/Lib/test/test_inspect.py Fri Dec 15 05:21:50 2006 @@ -130,7 +130,7 @@ def __init__(self, *args, **kwargs): unittest.TestCase.__init__(self, *args, **kwargs) - self.source = file(inspect.getsourcefile(self.fodderFile)).read() + self.source = open(inspect.getsourcefile(self.fodderFile)).read() def sourcerange(self, top, bottom): lines = self.source.split("\n") @@ -180,7 +180,18 @@ self.assertEqual(inspect.getcomments(mod.StupidGit), '# line 20\n') def test_getmodule(self): + # Check actual module + self.assertEqual(inspect.getmodule(mod), mod) + # Check class (uses __module__ attribute) self.assertEqual(inspect.getmodule(mod.StupidGit), mod) + # Check a method (no __module__ attribute, falls back to filename) + self.assertEqual(inspect.getmodule(mod.StupidGit.abuse), mod) + # Do it again (check the caching isn't broken) + self.assertEqual(inspect.getmodule(mod.StupidGit.abuse), mod) + # Check a builtin + self.assertEqual(inspect.getmodule(str), sys.modules["__builtin__"]) + # Check filename override + self.assertEqual(inspect.getmodule(None, modfile), mod) def test_getsource(self): self.assertSourceEqual(git.abuse, 29, 39) @@ -199,7 +210,7 @@ m = sys.modules[name] = module(name) m.__file__ = "" # hopefully not a real filename... m.__loader__ = "dummy" # pretend the filename is understood by a loader - exec "def x(): pass" in m.__dict__ + exec("def x(): pass", m.__dict__) self.assertEqual(inspect.getsourcefile(m.x.func_code), '') del sys.modules[name] inspect.getmodule(compile('a=10','','single')) Modified: python/branches/p3yk-noslice/Lib/test/test_iter.py ============================================================================== --- python/branches/p3yk-noslice/Lib/test/test_iter.py (original) +++ python/branches/p3yk-noslice/Lib/test/test_iter.py Fri Dec 15 05:21:50 2006 @@ -327,10 +327,10 @@ class Boolean: def __init__(self, truth): self.truth = truth - def __nonzero__(self): + def __bool__(self): return self.truth - bTrue = Boolean(1) - bFalse = Boolean(0) + bTrue = Boolean(True) + bFalse = Boolean(False) class Seq: def __init__(self, *args): @@ -423,21 +423,21 @@ # Test zip()'s use of iterators. def test_builtin_zip(self): - self.assertEqual(zip(), []) - self.assertEqual(zip(*[]), []) - self.assertEqual(zip(*[(1, 2), 'ab']), [(1, 'a'), (2, 'b')]) + self.assertEqual(list(zip()), []) + self.assertEqual(list(zip(*[])), []) + self.assertEqual(list(zip(*[(1, 2), 'ab'])), [(1, 'a'), (2, 'b')]) self.assertRaises(TypeError, zip, None) self.assertRaises(TypeError, zip, range(10), 42) self.assertRaises(TypeError, zip, range(10), zip) - self.assertEqual(zip(IteratingSequenceClass(3)), + self.assertEqual(list(zip(IteratingSequenceClass(3))), [(0,), (1,), (2,)]) - self.assertEqual(zip(SequenceClass(3)), + self.assertEqual(list(zip(SequenceClass(3))), [(0,), (1,), (2,)]) d = {"one": 1, "two": 2, "three": 3} - self.assertEqual(d.items(), zip(d, d.itervalues())) + self.assertEqual(d.items(), list(zip(d, d.itervalues()))) # Generate all ints starting at constructor arg. class IntsFrom: @@ -459,7 +459,7 @@ f.close() f = open(TESTFN, "r") try: - self.assertEqual(zip(IntsFrom(0), f, IntsFrom(-100)), + self.assertEqual(list(zip(IntsFrom(0), f, IntsFrom(-100))), [(0, "a\n", -100), (1, "bbb\n", -99), (2, "cc\n", -98)]) @@ -470,7 +470,7 @@ except OSError: pass - self.assertEqual(zip(xrange(5)), [(i,) for i in range(5)]) + self.assertEqual(list(zip(xrange(5))), [(i,) for i in range(5)]) # Classes that lie about their lengths. class NoGuessLen5: @@ -487,16 +487,19 @@ def __len__(self): return 30 + def lzip(*args): + return list(zip(*args)) + self.assertEqual(len(Guess3Len5()), 3) self.assertEqual(len(Guess30Len5()), 30) - self.assertEqual(zip(NoGuessLen5()), zip(range(5))) - self.assertEqual(zip(Guess3Len5()), zip(range(5))) - self.assertEqual(zip(Guess30Len5()), zip(range(5))) + self.assertEqual(lzip(NoGuessLen5()), lzip(range(5))) + self.assertEqual(lzip(Guess3Len5()), lzip(range(5))) + self.assertEqual(lzip(Guess30Len5()), lzip(range(5))) expected = [(i, i) for i in range(5)] for x in NoGuessLen5(), Guess3Len5(), Guess30Len5(): for y in NoGuessLen5(), Guess3Len5(), Guess30Len5(): - self.assertEqual(zip(x, y), expected) + self.assertEqual(lzip(x, y), expected) # This test case will be removed if we don't have Unicode def test_unicode_join_endcase(self): @@ -661,7 +664,7 @@ # Test iterators with file.writelines(). def test_writelines(self): - f = file(TESTFN, "w") + f = open(TESTFN, "w") try: self.assertRaises(TypeError, f.writelines, None) @@ -700,7 +703,7 @@ f.writelines(Whatever(6, 6+2000)) f.close() - f = file(TESTFN) + f = open(TESTFN) expected = [str(i) + "\n" for i in range(1, 2006)] self.assertEqual(list(f), expected) @@ -861,7 +864,7 @@ a = range(5) e = enumerate(a) b = iter(e) - self.assertEqual(list(b), zip(range(5), range(5))) + self.assertEqual(list(b), list(zip(range(5), range(5)))) self.assertEqual(list(b), []) Modified: python/branches/p3yk-noslice/Lib/test/test_itertools.py ============================================================================== --- python/branches/p3yk-noslice/Lib/test/test_itertools.py (original) +++ python/branches/p3yk-noslice/Lib/test/test_itertools.py Fri Dec 15 05:21:50 2006 @@ -6,6 +6,9 @@ import operator import random +def lzip(*args): + return list(zip(*args)) + def onearg(x): 'Test function of one argument' return 2*x @@ -47,9 +50,9 @@ self.assertRaises(TypeError, chain, 2, 3) def test_count(self): - self.assertEqual(zip('abc',count()), [('a', 0), ('b', 1), ('c', 2)]) - self.assertEqual(zip('abc',count(3)), [('a', 3), ('b', 4), ('c', 5)]) - self.assertEqual(take(2, zip('abc',count(3))), [('a', 3), ('b', 4)]) + self.assertEqual(lzip('abc',count()), [('a', 0), ('b', 1), ('c', 2)]) + self.assertEqual(lzip('abc',count(3)), [('a', 3), ('b', 4), ('c', 5)]) + self.assertEqual(take(2, lzip('abc',count(3))), [('a', 3), ('b', 4)]) self.assertRaises(TypeError, count, 2, 3) self.assertRaises(TypeError, count, 'a') c = count(sys.maxint-2) # verify that rollover doesn't crash @@ -58,6 +61,10 @@ self.assertEqual(repr(c), 'count(3)') c.next() self.assertEqual(repr(c), 'count(4)') + c = count(-9) + self.assertEqual(repr(c), 'count(-9)') + c.next() + self.assertEqual(c.next(), -8) def test_cycle(self): self.assertEqual(take(10, cycle('abc')), list('abcabcabca')) @@ -132,13 +139,13 @@ # __cmp__ failure class DummyCmp: - def __cmp__(self, dst): + def __eq__(self, dst): raise ExpectedError s = [DummyCmp(), DummyCmp(), None] - # __cmp__ failure on outer object + # __eq__ failure on outer object self.assertRaises(ExpectedError, gulp, s, func=id) - # __cmp__ failure on inner object + # __eq__ failure on inner object self.assertRaises(ExpectedError, gulp, s) # keyfunc failure @@ -176,27 +183,28 @@ self.assertRaises(TypeError, ifilterfalse(range(6), range(6)).next) def test_izip(self): + # XXX This is rather silly now that builtin zip() calls izip()... ans = [(x,y) for x, y in izip('abc',count())] self.assertEqual(ans, [('a', 0), ('b', 1), ('c', 2)]) - self.assertEqual(list(izip('abc', range(6))), zip('abc', range(6))) - self.assertEqual(list(izip('abcdef', range(3))), zip('abcdef', range(3))) - self.assertEqual(take(3,izip('abcdef', count())), zip('abcdef', range(3))) - self.assertEqual(list(izip('abcdef')), zip('abcdef')) - self.assertEqual(list(izip()), zip()) + self.assertEqual(list(izip('abc', range(6))), lzip('abc', range(6))) + self.assertEqual(list(izip('abcdef', range(3))), lzip('abcdef', range(3))) + self.assertEqual(take(3,izip('abcdef', count())), lzip('abcdef', range(3))) + self.assertEqual(list(izip('abcdef')), lzip('abcdef')) + self.assertEqual(list(izip()), lzip()) self.assertRaises(TypeError, izip, 3) self.assertRaises(TypeError, izip, range(3), 3) # Check tuple re-use (implementation detail) self.assertEqual([tuple(list(pair)) for pair in izip('abc', 'def')], - zip('abc', 'def')) + lzip('abc', 'def')) self.assertEqual([pair for pair in izip('abc', 'def')], - zip('abc', 'def')) + lzip('abc', 'def')) ids = map(id, izip('abc', 'def')) self.assertEqual(min(ids), max(ids)) ids = map(id, list(izip('abc', 'def'))) self.assertEqual(len(dict.fromkeys(ids)), len(ids)) def test_repeat(self): - self.assertEqual(zip(xrange(3),repeat('a')), + self.assertEqual(lzip(xrange(3),repeat('a')), [(0, 'a'), (1, 'a'), (2, 'a')]) self.assertEqual(list(repeat('a', 3)), ['a', 'a', 'a']) self.assertEqual(take(3, repeat('a')), ['a', 'a', 'a']) @@ -320,7 +328,7 @@ self.assertEqual(list(b), []) a, b = tee(irange(n)) # test 100% interleaved - self.assertEqual(zip(a,b), zip(range(n),range(n))) + self.assertEqual(lzip(a,b), lzip(range(n), range(n))) a, b = tee(irange(n)) # test 0% interleaved self.assertEqual(list(a), range(n)) @@ -371,6 +379,7 @@ # test values of n self.assertRaises(TypeError, tee, 'abc', 'invalid') + self.assertRaises(ValueError, tee, [], -1) for n in xrange(5): result = tee('abc', n) self.assertEqual(type(result), tuple) @@ -601,8 +610,8 @@ def test_izip(self): for s in ("123", "", range(1000), ('do', 1.2), xrange(2000,2200,5)): for g in (G, I, Ig, S, L, R): - self.assertEqual(list(izip(g(s))), zip(g(s))) - self.assertEqual(list(izip(g(s), g(s))), zip(g(s), g(s))) + self.assertEqual(list(izip(g(s))), lzip(g(s))) + self.assertEqual(list(izip(g(s), g(s))), lzip(g(s), g(s))) self.assertRaises(TypeError, izip, X(s)) self.assertRaises(TypeError, izip, N(s)) self.assertRaises(ZeroDivisionError, list, izip(E(s))) @@ -627,7 +636,7 @@ def test_starmap(self): for s in (range(10), range(0), range(100), (7,11), xrange(20,50,5)): for g in (G, I, Ig, S, L, R): - ss = zip(s, s) + ss = lzip(s, s) self.assertEqual(list(starmap(operator.pow, g(ss))), map(operator.pow, g(s), g(s))) self.assertRaises(TypeError, starmap, operator.pow, X(ss)) self.assertRaises(TypeError, starmap, operator.pow, N(ss)) Modified: python/branches/p3yk-noslice/Lib/test/test_long.py ============================================================================== --- python/branches/p3yk-noslice/Lib/test/test_long.py (original) +++ python/branches/p3yk-noslice/Lib/test/test_long.py Fri Dec 15 05:21:50 2006 @@ -247,17 +247,23 @@ "long(-sys.maxint-1) != -sys.maxint-1") # long -> int should not fail for hugepos_aslong or hugeneg_aslong + x = int(hugepos_aslong) try: - self.assertEqual(int(hugepos_aslong), hugepos, + self.assertEqual(x, hugepos, "converting sys.maxint to long and back to int fails") except OverflowError: self.fail("int(long(sys.maxint)) overflowed!") + if not isinstance(x, int): + raise TestFailed("int(long(sys.maxint)) should have returned int") + x = int(hugeneg_aslong) try: - self.assertEqual(int(hugeneg_aslong), hugeneg, + self.assertEqual(x, hugeneg, "converting -sys.maxint-1 to long and back to int fails") except OverflowError: self.fail("int(long(-sys.maxint-1)) overflowed!") - + if not isinstance(x, int): + raise TestFailed("int(long(-sys.maxint-1)) should have " + "returned int") # but long -> int should overflow for hugepos+1 and hugeneg-1 x = hugepos_aslong + 1 try: @@ -282,6 +288,7 @@ self.assert_(type(y) is long, "overflowing int conversion must return long not long subtype") + # ----------------------------------- tests of auto int->long conversion def test_auto_overflow(self): Modified: python/branches/p3yk-noslice/Lib/test/test_mailbox.py ============================================================================== --- python/branches/p3yk-noslice/Lib/test/test_mailbox.py (original) +++ python/branches/p3yk-noslice/Lib/test/test_mailbox.py Fri Dec 15 05:21:50 2006 @@ -666,6 +666,19 @@ self._box.lock() self._box.unlock() + def test_folder (self): + # Test for bug #1569790: verify that folders returned by .get_folder() + # use the same factory function. + def dummy_factory (s): + return None + box = self._factory(self._path, factory=dummy_factory) + folder = box.add_folder('folder1') + self.assert_(folder._factory is dummy_factory) + + folder1_alias = box.get_folder('folder1') + self.assert_(folder1_alias._factory is dummy_factory) + + class _TestMboxMMDF(TestMailbox): @@ -740,6 +753,22 @@ self._box.lock() self._box.unlock() + def test_relock(self): + # Test case for bug #1575506: the mailbox class was locking the + # wrong file object in its flush() method. + msg = "Subject: sub\n\nbody\n" + key1 = self._box.add(msg) + self._box.flush() + self._box.close() + + self._box = self._factory(self._path) + self._box.lock() + key2 = self._box.add(msg) + self._box.flush() + self.assert_(self._box._locked) + self._box.close() + + class TestMbox(_TestMboxMMDF): @@ -766,7 +795,11 @@ def test_get_folder(self): # Open folders - self._box.add_folder('foo.bar') + def dummy_factory (s): + return None + self._box = self._factory(self._path, dummy_factory) + + new_folder = self._box.add_folder('foo.bar') folder0 = self._box.get_folder('foo.bar') folder0.add(self._template % 'bar') self.assert_(os.path.isdir(os.path.join(self._path, 'foo.bar'))) @@ -774,6 +807,11 @@ self.assert_(folder1.get_string(folder1.keys()[0]) == \ self._template % 'bar') + # Test for bug #1569790: verify that folders returned by .get_folder() + # use the same factory function. + self.assert_(new_folder._factory is self._box._factory) + self.assert_(folder0._factory is self._box._factory) + def test_add_and_remove_folders(self): # Delete folders self._box.add_folder('one') @@ -842,6 +880,21 @@ self.assert_(self._box.get_sequences() == {'foo':[1, 2, 3], 'unseen':[1], 'bar':[3], 'replied':[3]}) + # Test case for packing while holding the mailbox locked. + key0 = self._box.add(msg1) + key1 = self._box.add(msg1) + key2 = self._box.add(msg1) + key3 = self._box.add(msg1) + + self._box.remove(key0) + self._box.remove(key2) + self._box.lock() + self._box.pack() + self._box.unlock() + self.assert_(self._box.get_sequences() == + {'foo':[1, 2, 3, 4, 5], + 'unseen':[1], 'bar':[3], 'replied':[3]}) + def _get_lock_path(self): return os.path.join(self._path, '.mh_sequences.lock') Modified: python/branches/p3yk-noslice/Lib/test/test_marshal.py ============================================================================== --- python/branches/p3yk-noslice/Lib/test/test_marshal.py (original) +++ python/branches/p3yk-noslice/Lib/test/test_marshal.py Fri Dec 15 05:21:50 2006 @@ -16,8 +16,8 @@ s = marshal.dumps(expected) got = marshal.loads(s) self.assertEqual(expected, got) - marshal.dump(expected, file(test_support.TESTFN, "wb")) - got = marshal.load(file(test_support.TESTFN, "rb")) + marshal.dump(expected, open(test_support.TESTFN, "wb")) + got = marshal.load( open(test_support.TESTFN, "rb")) self.assertEqual(expected, got) n = n >> 1 os.unlink(test_support.TESTFN) @@ -51,8 +51,8 @@ new = marshal.loads(marshal.dumps(b)) self.assertEqual(b, new) self.assertEqual(type(b), type(new)) - marshal.dump(b, file(test_support.TESTFN, "wb")) - new = marshal.load(file(test_support.TESTFN, "rb")) + marshal.dump(b, open(test_support.TESTFN, "wb")) + new = marshal.load(open(test_support.TESTFN, "rb")) self.assertEqual(b, new) self.assertEqual(type(b), type(new)) @@ -67,8 +67,8 @@ s = marshal.dumps(f) got = marshal.loads(s) self.assertEqual(f, got) - marshal.dump(f, file(test_support.TESTFN, "wb")) - got = marshal.load(file(test_support.TESTFN, "rb")) + marshal.dump(f, open(test_support.TESTFN, "wb")) + got = marshal.load(open(test_support.TESTFN, "rb")) self.assertEqual(f, got) n /= 123.4567 @@ -94,12 +94,12 @@ got = marshal.loads(s) self.assertEqual(f, got) - marshal.dump(f, file(test_support.TESTFN, "wb")) - got = marshal.load(file(test_support.TESTFN, "rb")) + marshal.dump(f, open(test_support.TESTFN, "wb")) + got = marshal.load(open(test_support.TESTFN, "rb")) self.assertEqual(f, got) - marshal.dump(f, file(test_support.TESTFN, "wb"), 1) - got = marshal.load(file(test_support.TESTFN, "rb")) + marshal.dump(f, open(test_support.TESTFN, "wb"), 1) + got = marshal.load(open(test_support.TESTFN, "rb")) self.assertEqual(f, got) n *= 123.4567 os.unlink(test_support.TESTFN) @@ -110,8 +110,8 @@ new = marshal.loads(marshal.dumps(s)) self.assertEqual(s, new) self.assertEqual(type(s), type(new)) - marshal.dump(s, file(test_support.TESTFN, "wb")) - new = marshal.load(file(test_support.TESTFN, "rb")) + marshal.dump(s, open(test_support.TESTFN, "wb")) + new = marshal.load(open(test_support.TESTFN, "rb")) self.assertEqual(s, new) self.assertEqual(type(s), type(new)) os.unlink(test_support.TESTFN) @@ -121,8 +121,8 @@ new = marshal.loads(marshal.dumps(s)) self.assertEqual(s, new) self.assertEqual(type(s), type(new)) - marshal.dump(s, file(test_support.TESTFN, "wb")) - new = marshal.load(file(test_support.TESTFN, "rb")) + marshal.dump(s, open(test_support.TESTFN, "wb")) + new = marshal.load(open(test_support.TESTFN, "rb")) self.assertEqual(s, new) self.assertEqual(type(s), type(new)) os.unlink(test_support.TESTFN) @@ -132,8 +132,8 @@ b = buffer(s) new = marshal.loads(marshal.dumps(b)) self.assertEqual(s, new) - marshal.dump(b, file(test_support.TESTFN, "wb")) - new = marshal.load(file(test_support.TESTFN, "rb")) + marshal.dump(b, open(test_support.TESTFN, "wb")) + new = marshal.load(open(test_support.TESTFN, "rb")) self.assertEqual(s, new) os.unlink(test_support.TESTFN) @@ -161,8 +161,8 @@ def test_dict(self): new = marshal.loads(marshal.dumps(self.d)) self.assertEqual(self.d, new) - marshal.dump(self.d, file(test_support.TESTFN, "wb")) - new = marshal.load(file(test_support.TESTFN, "rb")) + marshal.dump(self.d, open(test_support.TESTFN, "wb")) + new = marshal.load(open(test_support.TESTFN, "rb")) self.assertEqual(self.d, new) os.unlink(test_support.TESTFN) @@ -170,8 +170,8 @@ lst = self.d.items() new = marshal.loads(marshal.dumps(lst)) self.assertEqual(lst, new) - marshal.dump(lst, file(test_support.TESTFN, "wb")) - new = marshal.load(file(test_support.TESTFN, "rb")) + marshal.dump(lst, open(test_support.TESTFN, "wb")) + new = marshal.load(open(test_support.TESTFN, "rb")) self.assertEqual(lst, new) os.unlink(test_support.TESTFN) @@ -179,8 +179,8 @@ t = tuple(self.d.keys()) new = marshal.loads(marshal.dumps(t)) self.assertEqual(t, new) - marshal.dump(t, file(test_support.TESTFN, "wb")) - new = marshal.load(file(test_support.TESTFN, "rb")) + marshal.dump(t, open(test_support.TESTFN, "wb")) + new = marshal.load(open(test_support.TESTFN, "rb")) self.assertEqual(t, new) os.unlink(test_support.TESTFN) @@ -191,8 +191,8 @@ self.assertEqual(t, new) self.assert_(isinstance(new, constructor)) self.assertNotEqual(id(t), id(new)) - marshal.dump(t, file(test_support.TESTFN, "wb")) - new = marshal.load(file(test_support.TESTFN, "rb")) + marshal.dump(t, open(test_support.TESTFN, "wb")) + new = marshal.load(open(test_support.TESTFN, "rb")) self.assertEqual(t, new) os.unlink(test_support.TESTFN) Modified: python/branches/p3yk-noslice/Lib/test/test_math.py ============================================================================== --- python/branches/p3yk-noslice/Lib/test/test_math.py (original) +++ python/branches/p3yk-noslice/Lib/test/test_math.py Fri Dec 15 05:21:50 2006 @@ -1,208 +1,241 @@ # Python test set -- math module # XXXX Should not do tests around zero only -from test.test_support import TestFailed, verbose +from test.test_support import run_unittest, verbose +import unittest +import math seps='1e-05' eps = eval(seps) -print 'math module, testing with eps', seps -import math -def testit(name, value, expected): - if abs(value-expected) > eps: - raise TestFailed, '%s returned %f, expected %f'%\ - (name, value, expected) - -print 'constants' -testit('pi', math.pi, 3.1415926) -testit('e', math.e, 2.7182818) - -print 'acos' -testit('acos(-1)', math.acos(-1), math.pi) -testit('acos(0)', math.acos(0), math.pi/2) -testit('acos(1)', math.acos(1), 0) - -print 'asin' -testit('asin(-1)', math.asin(-1), -math.pi/2) -testit('asin(0)', math.asin(0), 0) -testit('asin(1)', math.asin(1), math.pi/2) - -print 'atan' -testit('atan(-1)', math.atan(-1), -math.pi/4) -testit('atan(0)', math.atan(0), 0) -testit('atan(1)', math.atan(1), math.pi/4) - -print 'atan2' -testit('atan2(-1, 0)', math.atan2(-1, 0), -math.pi/2) -testit('atan2(-1, 1)', math.atan2(-1, 1), -math.pi/4) -testit('atan2(0, 1)', math.atan2(0, 1), 0) -testit('atan2(1, 1)', math.atan2(1, 1), math.pi/4) -testit('atan2(1, 0)', math.atan2(1, 0), math.pi/2) - -print 'ceil' -testit('ceil(0.5)', math.ceil(0.5), 1) -testit('ceil(1.0)', math.ceil(1.0), 1) -testit('ceil(1.5)', math.ceil(1.5), 2) -testit('ceil(-0.5)', math.ceil(-0.5), 0) -testit('ceil(-1.0)', math.ceil(-1.0), -1) -testit('ceil(-1.5)', math.ceil(-1.5), -1) - -print 'cos' -testit('cos(-pi/2)', math.cos(-math.pi/2), 0) -testit('cos(0)', math.cos(0), 1) -testit('cos(pi/2)', math.cos(math.pi/2), 0) -testit('cos(pi)', math.cos(math.pi), -1) - -print 'cosh' -testit('cosh(0)', math.cosh(0), 1) -testit('cosh(2)-2*cosh(1)**2', math.cosh(2)-2*math.cosh(1)**2, -1) # Thanks to Lambert - -print 'degrees' -testit('degrees(pi)', math.degrees(math.pi), 180.0) -testit('degrees(pi/2)', math.degrees(math.pi/2), 90.0) -testit('degrees(-pi/4)', math.degrees(-math.pi/4), -45.0) - -print 'exp' -testit('exp(-1)', math.exp(-1), 1/math.e) -testit('exp(0)', math.exp(0), 1) -testit('exp(1)', math.exp(1), math.e) - -print 'fabs' -testit('fabs(-1)', math.fabs(-1), 1) -testit('fabs(0)', math.fabs(0), 0) -testit('fabs(1)', math.fabs(1), 1) - -print 'floor' -testit('floor(0.5)', math.floor(0.5), 0) -testit('floor(1.0)', math.floor(1.0), 1) -testit('floor(1.5)', math.floor(1.5), 1) -testit('floor(-0.5)', math.floor(-0.5), -1) -testit('floor(-1.0)', math.floor(-1.0), -1) -testit('floor(-1.5)', math.floor(-1.5), -2) - -print 'fmod' -testit('fmod(10,1)', math.fmod(10,1), 0) -testit('fmod(10,0.5)', math.fmod(10,0.5), 0) -testit('fmod(10,1.5)', math.fmod(10,1.5), 1) -testit('fmod(-10,1)', math.fmod(-10,1), 0) -testit('fmod(-10,0.5)', math.fmod(-10,0.5), 0) -testit('fmod(-10,1.5)', math.fmod(-10,1.5), -1) - -print 'frexp' -def testfrexp(name, (mant, exp), (emant, eexp)): - if abs(mant-emant) > eps or exp != eexp: - raise TestFailed, '%s returned %r, expected %r'%\ - (name, (mant, exp), (emant,eexp)) - -testfrexp('frexp(-1)', math.frexp(-1), (-0.5, 1)) -testfrexp('frexp(0)', math.frexp(0), (0, 0)) -testfrexp('frexp(1)', math.frexp(1), (0.5, 1)) -testfrexp('frexp(2)', math.frexp(2), (0.5, 2)) - -print 'hypot' -testit('hypot(0,0)', math.hypot(0,0), 0) -testit('hypot(3,4)', math.hypot(3,4), 5) - -print 'ldexp' -testit('ldexp(0,1)', math.ldexp(0,1), 0) -testit('ldexp(1,1)', math.ldexp(1,1), 2) -testit('ldexp(1,-1)', math.ldexp(1,-1), 0.5) -testit('ldexp(-1,1)', math.ldexp(-1,1), -2) - -print 'log' -testit('log(1/e)', math.log(1/math.e), -1) -testit('log(1)', math.log(1), 0) -testit('log(e)', math.log(math.e), 1) -testit('log(32,2)', math.log(32,2), 5) -testit('log(10**40, 10)', math.log(10**40, 10), 40) -testit('log(10**40, 10**20)', math.log(10**40, 10**20), 2) - -print 'log10' -testit('log10(0.1)', math.log10(0.1), -1) -testit('log10(1)', math.log10(1), 0) -testit('log10(10)', math.log10(10), 1) - -print 'modf' -def testmodf(name, (v1, v2), (e1, e2)): - if abs(v1-e1) > eps or abs(v2-e2): - raise TestFailed, '%s returned %r, expected %r'%\ - (name, (v1,v2), (e1,e2)) - -testmodf('modf(1.5)', math.modf(1.5), (0.5, 1.0)) -testmodf('modf(-1.5)', math.modf(-1.5), (-0.5, -1.0)) - -print 'pow' -testit('pow(0,1)', math.pow(0,1), 0) -testit('pow(1,0)', math.pow(1,0), 1) -testit('pow(2,1)', math.pow(2,1), 2) -testit('pow(2,-1)', math.pow(2,-1), 0.5) - -print 'radians' -testit('radians(180)', math.radians(180), math.pi) -testit('radians(90)', math.radians(90), math.pi/2) -testit('radians(-45)', math.radians(-45), -math.pi/4) - -print 'sin' -testit('sin(0)', math.sin(0), 0) -testit('sin(pi/2)', math.sin(math.pi/2), 1) -testit('sin(-pi/2)', math.sin(-math.pi/2), -1) - -print 'sinh' -testit('sinh(0)', math.sinh(0), 0) -testit('sinh(1)**2-cosh(1)**2', math.sinh(1)**2-math.cosh(1)**2, -1) -testit('sinh(1)+sinh(-1)', math.sinh(1)+math.sinh(-1), 0) - -print 'sqrt' -testit('sqrt(0)', math.sqrt(0), 0) -testit('sqrt(1)', math.sqrt(1), 1) -testit('sqrt(4)', math.sqrt(4), 2) - -print 'tan' -testit('tan(0)', math.tan(0), 0) -testit('tan(pi/4)', math.tan(math.pi/4), 1) -testit('tan(-pi/4)', math.tan(-math.pi/4), -1) - -print 'tanh' -testit('tanh(0)', math.tanh(0), 0) -testit('tanh(1)+tanh(-1)', math.tanh(1)+math.tanh(-1), 0) - -# RED_FLAG 16-Oct-2000 Tim -# While 2.0 is more consistent about exceptions than previous releases, it -# still fails this part of the test on some platforms. For now, we only -# *run* test_exceptions() in verbose mode, so that this isn't normally -# tested. - -def test_exceptions(): - print 'exceptions' - try: - x = math.exp(-1000000000) - except: - # mathmodule.c is failing to weed out underflows from libm, or - # we've got an fp format with huge dynamic range - raise TestFailed("underflowing exp() should not have raised " - "an exception") - if x != 0: - raise TestFailed("underflowing exp() should have returned 0") - - # If this fails, probably using a strict IEEE-754 conforming libm, and x - # is +Inf afterwards. But Python wants overflows detected by default. - try: - x = math.exp(1000000000) - except OverflowError: - pass - else: - raise TestFailed("overflowing exp() didn't trigger OverflowError") - - # If this fails, it could be a puzzle. One odd possibility is that - # mathmodule.c's macros are getting confused while comparing - # Inf (HUGE_VAL) to a NaN, and artificially setting errno to ERANGE - # as a result (and so raising OverflowError instead). - try: - x = math.sqrt(-1.0) - except ValueError: - pass - else: - raise TestFailed("sqrt(-1) didn't raise ValueError") +class MathTests(unittest.TestCase): + + def ftest(self, name, value, expected): + if abs(value-expected) > eps: + self.fail('%s returned %f, expected %f'%\ + (name, value, expected)) + + def testConstants(self): + self.ftest('pi', math.pi, 3.1415926) + self.ftest('e', math.e, 2.7182818) + + def testAcos(self): + self.assertRaises(TypeError, math.acos) + self.ftest('acos(-1)', math.acos(-1), math.pi) + self.ftest('acos(0)', math.acos(0), math.pi/2) + self.ftest('acos(1)', math.acos(1), 0) + + def testAsin(self): + self.assertRaises(TypeError, math.asin) + self.ftest('asin(-1)', math.asin(-1), -math.pi/2) + self.ftest('asin(0)', math.asin(0), 0) + self.ftest('asin(1)', math.asin(1), math.pi/2) + + def testAtan(self): + self.assertRaises(TypeError, math.atan) + self.ftest('atan(-1)', math.atan(-1), -math.pi/4) + self.ftest('atan(0)', math.atan(0), 0) + self.ftest('atan(1)', math.atan(1), math.pi/4) + + def testAtan2(self): + self.assertRaises(TypeError, math.atan2) + self.ftest('atan2(-1, 0)', math.atan2(-1, 0), -math.pi/2) + self.ftest('atan2(-1, 1)', math.atan2(-1, 1), -math.pi/4) + self.ftest('atan2(0, 1)', math.atan2(0, 1), 0) + self.ftest('atan2(1, 1)', math.atan2(1, 1), math.pi/4) + self.ftest('atan2(1, 0)', math.atan2(1, 0), math.pi/2) + + def testCeil(self): + self.assertRaises(TypeError, math.ceil) + self.ftest('ceil(0.5)', math.ceil(0.5), 1) + self.ftest('ceil(1.0)', math.ceil(1.0), 1) + self.ftest('ceil(1.5)', math.ceil(1.5), 2) + self.ftest('ceil(-0.5)', math.ceil(-0.5), 0) + self.ftest('ceil(-1.0)', math.ceil(-1.0), -1) + self.ftest('ceil(-1.5)', math.ceil(-1.5), -1) + + def testCos(self): + self.assertRaises(TypeError, math.cos) + self.ftest('cos(-pi/2)', math.cos(-math.pi/2), 0) + self.ftest('cos(0)', math.cos(0), 1) + self.ftest('cos(pi/2)', math.cos(math.pi/2), 0) + self.ftest('cos(pi)', math.cos(math.pi), -1) + + def testCosh(self): + self.assertRaises(TypeError, math.cosh) + self.ftest('cosh(0)', math.cosh(0), 1) + self.ftest('cosh(2)-2*cosh(1)**2', math.cosh(2)-2*math.cosh(1)**2, -1) # Thanks to Lambert + + def testDegrees(self): + self.assertRaises(TypeError, math.degrees) + self.ftest('degrees(pi)', math.degrees(math.pi), 180.0) + self.ftest('degrees(pi/2)', math.degrees(math.pi/2), 90.0) + self.ftest('degrees(-pi/4)', math.degrees(-math.pi/4), -45.0) + + def testExp(self): + self.assertRaises(TypeError, math.exp) + self.ftest('exp(-1)', math.exp(-1), 1/math.e) + self.ftest('exp(0)', math.exp(0), 1) + self.ftest('exp(1)', math.exp(1), math.e) + + def testFabs(self): + self.assertRaises(TypeError, math.fabs) + self.ftest('fabs(-1)', math.fabs(-1), 1) + self.ftest('fabs(0)', math.fabs(0), 0) + self.ftest('fabs(1)', math.fabs(1), 1) + + def testFloor(self): + self.assertRaises(TypeError, math.floor) + self.ftest('floor(0.5)', math.floor(0.5), 0) + self.ftest('floor(1.0)', math.floor(1.0), 1) + self.ftest('floor(1.5)', math.floor(1.5), 1) + self.ftest('floor(-0.5)', math.floor(-0.5), -1) + self.ftest('floor(-1.0)', math.floor(-1.0), -1) + self.ftest('floor(-1.5)', math.floor(-1.5), -2) + + def testFmod(self): + self.assertRaises(TypeError, math.fmod) + self.ftest('fmod(10,1)', math.fmod(10,1), 0) + self.ftest('fmod(10,0.5)', math.fmod(10,0.5), 0) + self.ftest('fmod(10,1.5)', math.fmod(10,1.5), 1) + self.ftest('fmod(-10,1)', math.fmod(-10,1), 0) + self.ftest('fmod(-10,0.5)', math.fmod(-10,0.5), 0) + self.ftest('fmod(-10,1.5)', math.fmod(-10,1.5), -1) + + def testFrexp(self): + self.assertRaises(TypeError, math.frexp) + + def testfrexp(name, (mant, exp), (emant, eexp)): + if abs(mant-emant) > eps or exp != eexp: + self.fail('%s returned %r, expected %r'%\ + (name, (mant, exp), (emant,eexp))) + + testfrexp('frexp(-1)', math.frexp(-1), (-0.5, 1)) + testfrexp('frexp(0)', math.frexp(0), (0, 0)) + testfrexp('frexp(1)', math.frexp(1), (0.5, 1)) + testfrexp('frexp(2)', math.frexp(2), (0.5, 2)) + + def testHypot(self): + self.assertRaises(TypeError, math.hypot) + self.ftest('hypot(0,0)', math.hypot(0,0), 0) + self.ftest('hypot(3,4)', math.hypot(3,4), 5) + + def testLdexp(self): + self.assertRaises(TypeError, math.ldexp) + self.ftest('ldexp(0,1)', math.ldexp(0,1), 0) + self.ftest('ldexp(1,1)', math.ldexp(1,1), 2) + self.ftest('ldexp(1,-1)', math.ldexp(1,-1), 0.5) + self.ftest('ldexp(-1,1)', math.ldexp(-1,1), -2) + + def testLog(self): + self.assertRaises(TypeError, math.log) + self.ftest('log(1/e)', math.log(1/math.e), -1) + self.ftest('log(1)', math.log(1), 0) + self.ftest('log(e)', math.log(math.e), 1) + self.ftest('log(32,2)', math.log(32,2), 5) + self.ftest('log(10**40, 10)', math.log(10**40, 10), 40) + self.ftest('log(10**40, 10**20)', math.log(10**40, 10**20), 2) + + def testLog10(self): + self.assertRaises(TypeError, math.log10) + self.ftest('log10(0.1)', math.log10(0.1), -1) + self.ftest('log10(1)', math.log10(1), 0) + self.ftest('log10(10)', math.log10(10), 1) + + def testModf(self): + self.assertRaises(TypeError, math.modf) + + def testmodf(name, (v1, v2), (e1, e2)): + if abs(v1-e1) > eps or abs(v2-e2): + self.fail('%s returned %r, expected %r'%\ + (name, (v1,v2), (e1,e2))) + + testmodf('modf(1.5)', math.modf(1.5), (0.5, 1.0)) + testmodf('modf(-1.5)', math.modf(-1.5), (-0.5, -1.0)) + + def testPow(self): + self.assertRaises(TypeError, math.pow) + self.ftest('pow(0,1)', math.pow(0,1), 0) + self.ftest('pow(1,0)', math.pow(1,0), 1) + self.ftest('pow(2,1)', math.pow(2,1), 2) + self.ftest('pow(2,-1)', math.pow(2,-1), 0.5) + + def testRadians(self): + self.assertRaises(TypeError, math.radians) + self.ftest('radians(180)', math.radians(180), math.pi) + self.ftest('radians(90)', math.radians(90), math.pi/2) + self.ftest('radians(-45)', math.radians(-45), -math.pi/4) + + def testSin(self): + self.assertRaises(TypeError, math.sin) + self.ftest('sin(0)', math.sin(0), 0) + self.ftest('sin(pi/2)', math.sin(math.pi/2), 1) + self.ftest('sin(-pi/2)', math.sin(-math.pi/2), -1) + + def testSinh(self): + self.assertRaises(TypeError, math.sinh) + self.ftest('sinh(0)', math.sinh(0), 0) + self.ftest('sinh(1)**2-cosh(1)**2', math.sinh(1)**2-math.cosh(1)**2, -1) + self.ftest('sinh(1)+sinh(-1)', math.sinh(1)+math.sinh(-1), 0) + + def testSqrt(self): + self.assertRaises(TypeError, math.sqrt) + self.ftest('sqrt(0)', math.sqrt(0), 0) + self.ftest('sqrt(1)', math.sqrt(1), 1) + self.ftest('sqrt(4)', math.sqrt(4), 2) + + def testTan(self): + self.assertRaises(TypeError, math.tan) + self.ftest('tan(0)', math.tan(0), 0) + self.ftest('tan(pi/4)', math.tan(math.pi/4), 1) + self.ftest('tan(-pi/4)', math.tan(-math.pi/4), -1) + + def testTanh(self): + self.assertRaises(TypeError, math.tanh) + self.ftest('tanh(0)', math.tanh(0), 0) + self.ftest('tanh(1)+tanh(-1)', math.tanh(1)+math.tanh(-1), 0) + + # RED_FLAG 16-Oct-2000 Tim + # While 2.0 is more consistent about exceptions than previous releases, it + # still fails this part of the test on some platforms. For now, we only + # *run* test_exceptions() in verbose mode, so that this isn't normally + # tested. + + if verbose: + def test_exceptions(self): + try: + x = math.exp(-1000000000) + except: + # mathmodule.c is failing to weed out underflows from libm, or + # we've got an fp format with huge dynamic range + self.fail("underflowing exp() should not have raised " + "an exception") + if x != 0: + self.fail("underflowing exp() should have returned 0") + + # If this fails, probably using a strict IEEE-754 conforming libm, and x + # is +Inf afterwards. But Python wants overflows detected by default. + try: + x = math.exp(1000000000) + except OverflowError: + pass + else: + self.fail("overflowing exp() didn't trigger OverflowError") + + # If this fails, it could be a puzzle. One odd possibility is that + # mathmodule.c's macros are getting confused while comparing + # Inf (HUGE_VAL) to a NaN, and artificially setting errno to ERANGE + # as a result (and so raising OverflowError instead). + try: + x = math.sqrt(-1.0) + except ValueError: + pass + else: + self.fail("sqrt(-1) didn't raise ValueError") + + +def test_main(): + run_unittest(MathTests) -if verbose: - test_exceptions() +if __name__ == '__main__': + test_main() Modified: python/branches/p3yk-noslice/Lib/test/test_mmap.py ============================================================================== --- python/branches/p3yk-noslice/Lib/test/test_mmap.py (original) +++ python/branches/p3yk-noslice/Lib/test/test_mmap.py Fri Dec 15 05:21:50 2006 @@ -1,190 +1,158 @@ -from test.test_support import verify, vereq, TESTFN +from test.test_support import TESTFN, run_unittest import mmap +import unittest import os, re PAGESIZE = mmap.PAGESIZE -def test_both(): - "Test mmap module on Unix systems and Windows" +class MmapTests(unittest.TestCase): - # Create a file to be mmap'ed. - if os.path.exists(TESTFN): - os.unlink(TESTFN) - f = open(TESTFN, 'w+') - - try: # unlink TESTFN no matter what - # Write 2 pages worth of data to the file - f.write('\0'* PAGESIZE) - f.write('foo') - f.write('\0'* (PAGESIZE-3) ) - f.flush() - m = mmap.mmap(f.fileno(), 2 * PAGESIZE) - f.close() + def setUp(self): + if os.path.exists(TESTFN): + os.unlink(TESTFN) - # Simple sanity checks + def tearDown(self): + try: + os.unlink(TESTFN) + except OSError: + pass - print type(m) # SF bug 128713: segfaulted on Linux - print ' Position of foo:', m.find('foo') / float(PAGESIZE), 'pages' - vereq(m.find('foo'), PAGESIZE) - - print ' Length of file:', len(m) / float(PAGESIZE), 'pages' - vereq(len(m), 2*PAGESIZE) - - print ' Contents of byte 0:', repr(m[0]) - vereq(m[0], '\0') - print ' Contents of first 3 bytes:', repr(m[0:3]) - vereq(m[0:3], '\0\0\0') - - # Modify the file's content - print "\n Modifying file's content..." - m[0] = '3' - m[PAGESIZE +3: PAGESIZE +3+3] = 'bar' - - # Check that the modification worked - print ' Contents of byte 0:', repr(m[0]) - vereq(m[0], '3') - print ' Contents of first 3 bytes:', repr(m[0:3]) - vereq(m[0:3], '3\0\0') - print ' Contents of second page:', repr(m[PAGESIZE-1 : PAGESIZE + 7]) - vereq(m[PAGESIZE-1 : PAGESIZE + 7], '\0foobar\0') + def test_basic(self): + # Test mmap module on Unix systems and Windows - m.flush() + # Create a file to be mmap'ed. + f = open(TESTFN, 'w+') + try: + # Write 2 pages worth of data to the file + f.write('\0'* PAGESIZE) + f.write('foo') + f.write('\0'* (PAGESIZE-3) ) + f.flush() + m = mmap.mmap(f.fileno(), 2 * PAGESIZE) + f.close() - # Test doing a regular expression match in an mmap'ed file - match = re.search('[A-Za-z]+', m) - if match is None: - print ' ERROR: regex match on mmap failed!' - else: - start, end = match.span(0) - length = end - start + # Simple sanity checks - print ' Regex match on mmap (page start, length of match):', - print start / float(PAGESIZE), length + tp = str(type(m)) # SF bug 128713: segfaulted on Linux + self.assertEqual(m.find('foo'), PAGESIZE) - vereq(start, PAGESIZE) - vereq(end, PAGESIZE + 6) + self.assertEqual(len(m), 2*PAGESIZE) - # test seeking around (try to overflow the seek implementation) - m.seek(0,0) - print ' Seek to zeroth byte' - vereq(m.tell(), 0) - m.seek(42,1) - print ' Seek to 42nd byte' - vereq(m.tell(), 42) - m.seek(0,2) - print ' Seek to last byte' - vereq(m.tell(), len(m)) + self.assertEqual(m[0], '\0') + self.assertEqual(m[0:3], '\0\0\0') - print ' Try to seek to negative position...' - try: - m.seek(-1) - except ValueError: - pass - else: - verify(0, 'expected a ValueError but did not get it') + # Modify the file's content + m[0] = '3' + m[PAGESIZE +3: PAGESIZE +3+3] = 'bar' - print ' Try to seek beyond end of mmap...' - try: - m.seek(1,2) - except ValueError: - pass - else: - verify(0, 'expected a ValueError but did not get it') + # Check that the modification worked + self.assertEqual(m[0], '3') + self.assertEqual(m[0:3], '3\0\0') + self.assertEqual(m[PAGESIZE-1 : PAGESIZE + 7], '\0foobar\0') - print ' Try to seek to negative position...' - try: - m.seek(-len(m)-1,2) - except ValueError: - pass - else: - verify(0, 'expected a ValueError but did not get it') + m.flush() - # Try resizing map - print ' Attempting resize()' - try: - m.resize(512) - except SystemError: - # resize() not supported - # No messages are printed, since the output of this test suite - # would then be different across platforms. - pass - else: - # resize() is supported - verify(len(m) == 512, - "len(m) is %d, but expecting 512" % (len(m),) ) - # Check that we can no longer seek beyond the new size. + # Test doing a regular expression match in an mmap'ed file + match = re.search('[A-Za-z]+', m) + if match is None: + self.fail('regex match on mmap failed!') + else: + start, end = match.span(0) + length = end - start + + self.assertEqual(start, PAGESIZE) + self.assertEqual(end, PAGESIZE + 6) + + # test seeking around (try to overflow the seek implementation) + m.seek(0,0) + self.assertEqual(m.tell(), 0) + m.seek(42,1) + self.assertEqual(m.tell(), 42) + m.seek(0,2) + self.assertEqual(m.tell(), len(m)) + + # Try to seek to negative position... + self.assertRaises(ValueError, m.seek, -1) + + # Try to seek beyond end of mmap... + self.assertRaises(ValueError, m.seek, 1, 2) + + # Try to seek to negative position... + self.assertRaises(ValueError, m.seek, -len(m)-1, 2) + + # Try resizing map try: - m.seek(513,0) - except ValueError: + m.resize(512) + except SystemError: + # resize() not supported + # No messages are printed, since the output of this test suite + # would then be different across platforms. pass else: - verify(0, 'Could seek beyond the new size') + # resize() is supported + self.assertEqual(len(m), 512) + # Check that we can no longer seek beyond the new size. + self.assertRaises(ValueError, m.seek, 513, 0) + + # Check that the underlying file is truncated too + # (bug #728515) + f = open(TESTFN) + f.seek(0, 2) + self.assertEqual(f.tell(), 512) + f.close() + self.assertEqual(m.size(), 512) - # Check that the underlying file is truncated too - # (bug #728515) - f = open(TESTFN) - f.seek(0, 2) - verify(f.tell() == 512, 'Underlying file not truncated') - f.close() - verify(m.size() == 512, 'New size not reflected in file') - - m.close() + m.close() - finally: - try: - f.close() - except OSError: - pass - try: - os.unlink(TESTFN) - except OSError: - pass + finally: + try: + f.close() + except OSError: + pass - # Test for "access" keyword parameter - try: + def test_access_parameter(self): + # Test for "access" keyword parameter mapsize = 10 - print " Creating", mapsize, "byte test data file." open(TESTFN, "wb").write("a"*mapsize) - print " Opening mmap with access=ACCESS_READ" f = open(TESTFN, "rb") m = mmap.mmap(f.fileno(), mapsize, access=mmap.ACCESS_READ) - verify(m[:] == 'a'*mapsize, "Readonly memory map data incorrect.") + self.assertEqual(m[:], 'a'*mapsize, "Readonly memory map data incorrect.") - print " Ensuring that readonly mmap can't be slice assigned." + # Ensuring that readonly mmap can't be slice assigned try: m[:] = 'b'*mapsize except TypeError: pass else: - verify(0, "Able to write to readonly memory map") + self.fail("Able to write to readonly memory map") - print " Ensuring that readonly mmap can't be item assigned." + # Ensuring that readonly mmap can't be item assigned try: m[0] = 'b' except TypeError: pass else: - verify(0, "Able to write to readonly memory map") + self.fail("Able to write to readonly memory map") - print " Ensuring that readonly mmap can't be write() to." + # Ensuring that readonly mmap can't be write() to try: m.seek(0,0) m.write('abc') except TypeError: pass else: - verify(0, "Able to write to readonly memory map") + self.fail("Able to write to readonly memory map") - print " Ensuring that readonly mmap can't be write_byte() to." + # Ensuring that readonly mmap can't be write_byte() to try: m.seek(0,0) m.write_byte('d') except TypeError: pass else: - verify(0, "Able to write to readonly memory map") + self.fail("Able to write to readonly memory map") - print " Ensuring that readonly mmap can't be resized." + # Ensuring that readonly mmap can't be resized try: m.resize(2*mapsize) except SystemError: # resize is not universally supported @@ -192,12 +160,12 @@ except TypeError: pass else: - verify(0, "Able to resize readonly memory map") + self.fail("Able to resize readonly memory map") del m, f - verify(open(TESTFN, "rb").read() == 'a'*mapsize, + self.assertEqual(open(TESTFN, "rb").read(), 'a'*mapsize, "Readonly memory map data file was modified") - print " Opening mmap with size too big" + # Opening mmap with size too big import sys f = open(TESTFN, "r+b") try: @@ -208,11 +176,11 @@ # later tests assume that the length hasn't changed. We need to # repair that. if sys.platform.startswith('win'): - verify(0, "Opening mmap with size+1 should work on Windows.") + self.fail("Opening mmap with size+1 should work on Windows.") else: # we expect a ValueError on Unix, but not on Windows if not sys.platform.startswith('win'): - verify(0, "Opening mmap with size+1 should raise ValueError.") + self.fail("Opening mmap with size+1 should raise ValueError.") m.close() f.close() if sys.platform.startswith('win'): @@ -221,12 +189,12 @@ f.truncate(mapsize) f.close() - print " Opening mmap with access=ACCESS_WRITE" + # Opening mmap with access=ACCESS_WRITE f = open(TESTFN, "r+b") m = mmap.mmap(f.fileno(), mapsize, access=mmap.ACCESS_WRITE) - print " Modifying write-through memory map." + # Modifying write-through memory map m[:] = 'c'*mapsize - verify(m[:] == 'c'*mapsize, + self.assertEqual(m[:], 'c'*mapsize, "Write-through memory map memory not updated properly.") m.flush() m.close() @@ -234,66 +202,45 @@ f = open(TESTFN, 'rb') stuff = f.read() f.close() - verify(stuff == 'c'*mapsize, + self.assertEqual(stuff, 'c'*mapsize, "Write-through memory map data file not updated properly.") - print " Opening mmap with access=ACCESS_COPY" + # Opening mmap with access=ACCESS_COPY f = open(TESTFN, "r+b") m = mmap.mmap(f.fileno(), mapsize, access=mmap.ACCESS_COPY) - print " Modifying copy-on-write memory map." + # Modifying copy-on-write memory map m[:] = 'd'*mapsize - verify(m[:] == 'd' * mapsize, + self.assertEqual(m[:], 'd' * mapsize, "Copy-on-write memory map data not written correctly.") m.flush() - verify(open(TESTFN, "rb").read() == 'c'*mapsize, + self.assertEqual(open(TESTFN, "rb").read(), 'c'*mapsize, "Copy-on-write test data file should not be modified.") - try: - print " Ensuring copy-on-write maps cannot be resized." - m.resize(2*mapsize) - except TypeError: - pass - else: - verify(0, "Copy-on-write mmap resize did not raise exception.") + # Ensuring copy-on-write maps cannot be resized + self.assertRaises(TypeError, m.resize, 2*mapsize) del m, f - try: - print " Ensuring invalid access parameter raises exception." - f = open(TESTFN, "r+b") - m = mmap.mmap(f.fileno(), mapsize, access=4) - except ValueError: - pass - else: - verify(0, "Invalid access code should have raised exception.") + + # Ensuring invalid access parameter raises exception + f = open(TESTFN, "r+b") + self.assertRaises(ValueError, mmap.mmap, f.fileno(), mapsize, access=4) + f.close() if os.name == "posix": # Try incompatible flags, prot and access parameters. f = open(TESTFN, "r+b") - try: - m = mmap.mmap(f.fileno(), mapsize, flags=mmap.MAP_PRIVATE, + self.assertRaises(ValueError, mmap.mmap, f.fileno(), mapsize, + flags=mmap.MAP_PRIVATE, prot=mmap.PROT_READ, access=mmap.ACCESS_WRITE) - except ValueError: - pass - else: - verify(0, "Incompatible parameters should raise ValueError.") f.close() - finally: - try: - os.unlink(TESTFN) - except OSError: - pass - print ' Try opening a bad file descriptor...' - try: - mmap.mmap(-2, 4096) - except mmap.error: - pass - else: - verify(0, 'expected a mmap.error but did not get it') - - # Do a tougher .find() test. SF bug 515943 pointed out that, in 2.2, - # searching for data with embedded \0 bytes didn't work. - f = open(TESTFN, 'w+') + def test_bad_file_desc(self): + # Try opening a bad file descriptor... + self.assertRaises(mmap.error, mmap.mmap, -2, 4096) + + def test_tougher_find(self): + # Do a tougher .find() test. SF bug 515943 pointed out that, in 2.2, + # searching for data with embedded \0 bytes didn't work. + f = open(TESTFN, 'w+') - try: # unlink TESTFN no matter what data = 'aabaac\x00deef\x00\x00aa\x00' n = len(data) f.write(data) @@ -304,17 +251,14 @@ for start in range(n+1): for finish in range(start, n+1): slice = data[start : finish] - vereq(m.find(slice), data.find(slice)) - vereq(m.find(slice + 'x'), -1) + self.assertEqual(m.find(slice), data.find(slice)) + self.assertEqual(m.find(slice + 'x'), -1) m.close() - finally: - os.unlink(TESTFN) - - # make sure a double close doesn't crash on Solaris (Bug# 665913) - f = open(TESTFN, 'w+') + def test_double_close(self): + # make sure a double close doesn't crash on Solaris (Bug# 665913) + f = open(TESTFN, 'w+') - try: # unlink TESTFN no matter what f.write(2**16 * 'a') # Arbitrary character f.close() @@ -324,72 +268,46 @@ mf.close() f.close() - finally: - os.unlink(TESTFN) + def test_entire_file(self): + # test mapping of entire file by passing 0 for map length + if hasattr(os, "stat"): + f = open(TESTFN, "w+") - # test mapping of entire file by passing 0 for map length - if hasattr(os, "stat"): - print " Ensuring that passing 0 as map length sets map size to current file size." - f = open(TESTFN, "w+") - - try: f.write(2**16 * 'm') # Arbitrary character f.close() f = open(TESTFN, "rb+") mf = mmap.mmap(f.fileno(), 0) - verify(len(mf) == 2**16, "Map size should equal file size.") - vereq(mf.read(2**16), 2**16 * "m") + self.assertEqual(len(mf), 2**16, "Map size should equal file size.") + self.assertEqual(mf.read(2**16), 2**16 * "m") mf.close() f.close() - finally: - os.unlink(TESTFN) - - # test mapping of entire file by passing 0 for map length - if hasattr(os, "stat"): - print " Ensuring that passing 0 as map length sets map size to current file size." - f = open(TESTFN, "w+") - try: - f.write(2**16 * 'm') # Arbitrary character - f.close() + def test_move(self): + # make move works everywhere (64-bit format problem earlier) + f = open(TESTFN, 'w+') - f = open(TESTFN, "rb+") - mf = mmap.mmap(f.fileno(), 0) - verify(len(mf) == 2**16, "Map size should equal file size.") - vereq(mf.read(2**16), 2**16 * "m") - mf.close() - f.close() - - finally: - os.unlink(TESTFN) - - # make move works everywhere (64-bit format problem earlier) - f = open(TESTFN, 'w+') - - try: # unlink TESTFN no matter what f.write("ABCDEabcde") # Arbitrary character f.flush() mf = mmap.mmap(f.fileno(), 10) mf.move(5, 0, 5) - verify(mf[:] == "ABCDEABCDE", "Map move should have duplicated front 5") + self.assertEqual(mf[:], "ABCDEABCDE", "Map move should have duplicated front 5") mf.close() f.close() - finally: - os.unlink(TESTFN) + def test_anonymous(self): + # anonymous mmap.mmap(-1, PAGE) + m = mmap.mmap(-1, PAGESIZE) + for x in xrange(PAGESIZE): + self.assertEqual(m[x], '\0', "anonymously mmap'ed contents should be zero") + + for x in xrange(PAGESIZE): + m[x] = ch = chr(x & 255) + self.assertEqual(m[x], ch) + +def test_main(): + run_unittest(MmapTests) -def test_anon(): - print " anonymous mmap.mmap(-1, PAGESIZE)..." - m = mmap.mmap(-1, PAGESIZE) - for x in xrange(PAGESIZE): - verify(m[x] == '\0', "anonymously mmap'ed contents should be zero") - - for x in xrange(PAGESIZE): - m[x] = ch = chr(x & 255) - vereq(m[x], ch) - -test_both() -test_anon() -print ' Test passed' +if __name__ == '__main__': + test_main() Modified: python/branches/p3yk-noslice/Lib/test/test_multibytecodec.py ============================================================================== --- python/branches/p3yk-noslice/Lib/test/test_multibytecodec.py (original) +++ python/branches/p3yk-noslice/Lib/test/test_multibytecodec.py Fri Dec 15 05:21:50 2006 @@ -49,7 +49,7 @@ try: for enc in ALL_CJKENCODINGS: print >> open(TESTFN, 'w'), '# coding:', enc - exec open(TESTFN) + execfile(TESTFN) finally: os.unlink(TESTFN) @@ -202,6 +202,22 @@ uni = u':hu4:unit\xe9 de famille' self.assertEqual(iso2022jp2.decode('iso2022-jp-2'), uni) + def test_iso2022_jp_g0(self): + self.failIf('\x0e' in u'\N{SOFT HYPHEN}'.encode('iso-2022-jp-2')) + for encoding in ('iso-2022-jp-2004', 'iso-2022-jp-3'): + e = u'\u3406'.encode(encoding) + self.failIf(filter(lambda x: x >= '\x80', e)) + + def test_bug1572832(self): + if sys.maxunicode >= 0x10000: + myunichr = unichr + else: + myunichr = lambda x: unichr(0xD7C0+(x>>10)) + unichr(0xDC00+(x&0x3FF)) + + for x in xrange(0x10000, 0x110000): + # Any ISO 2022 codec will cause the segfault + myunichr(x).encode('iso_2022_jp', 'ignore') + def test_main(): suite = unittest.TestSuite() suite.addTest(unittest.makeSuite(Test_MultibyteCodec)) Modified: python/branches/p3yk-noslice/Lib/test/test_mutants.py ============================================================================== --- python/branches/p3yk-noslice/Lib/test/test_mutants.py (original) +++ python/branches/p3yk-noslice/Lib/test/test_mutants.py Fri Dec 15 05:21:50 2006 @@ -88,14 +88,21 @@ # have any systematic relationship between comparison outcomes # (based on self.i and other.i) and relative position within the # hash vector (based on hashcode). - self.hashcode = random.randrange(1000000000) + # XXX This is no longer effective. + ##self.hashcode = random.randrange(1000000000) def __hash__(self): + return 42 return self.hashcode - def __cmp__(self, other): + def __eq__(self, other): maybe_mutate() # The point of the test. - return cmp(self.i, other.i) + return self.i == other.i + + def __ne__(self, other): + raise RuntimeError("I didn't expect some kind of Spanish inquisition!") + + __lt__ = __le__ = __gt__ = __ge__ = __ne__ def __repr__(self): return "Horrid(%d)" % self.i @@ -132,7 +139,7 @@ while dict1 and len(dict1) == len(dict2): if verbose: print ".", - c = cmp(dict1, dict2) + c = dict1 == dict2 if verbose: print @@ -202,7 +209,7 @@ # Tim sez: "luck of the draw; crashes with or without for me." print >> f - return `"machiavelli"` + return repr("machiavelli") def __hash__(self): return 0 Modified: python/branches/p3yk-noslice/Lib/test/test_new.py ============================================================================== --- python/branches/p3yk-noslice/Lib/test/test_new.py (original) +++ python/branches/p3yk-noslice/Lib/test/test_new.py Fri Dec 15 05:21:50 2006 @@ -47,6 +47,14 @@ else: raise TestFailed, "dangerous instance method creation allowed" +# Verify that instancemethod() doesn't allow keyword args +try: + new.instancemethod(break_yolks, c, kw=1) +except TypeError: + pass +else: + raise TestFailed, "instancemethod shouldn't accept keyword args" + # It's unclear what the semantics should be for a code object compiled at # module scope, but bound and run in a function. In CPython, `c' is global # (by accident?) while in Jython, `c' is local. The intent of the test @@ -103,6 +111,7 @@ c = f.func_code argcount = c.co_argcount + kwonlyargcount = c.co_kwonlyargcount nlocals = c.co_nlocals stacksize = c.co_stacksize flags = c.co_flags @@ -117,17 +126,20 @@ freevars = c.co_freevars cellvars = c.co_cellvars - d = new.code(argcount, nlocals, stacksize, flags, codestring, + d = new.code(argcount, kwonlyargcount, + nlocals, stacksize, flags, codestring, constants, names, varnames, filename, name, firstlineno, lnotab, freevars, cellvars) # test backwards-compatibility version with no freevars or cellvars - d = new.code(argcount, nlocals, stacksize, flags, codestring, + d = new.code(argcount, kwonlyargcount, + nlocals, stacksize, flags, codestring, constants, names, varnames, filename, name, firstlineno, lnotab) try: # this used to trigger a SystemError - d = new.code(-argcount, nlocals, stacksize, flags, codestring, + d = new.code(-argcount, kwonlyargcount, + nlocals, stacksize, flags, codestring, constants, names, varnames, filename, name, firstlineno, lnotab) except ValueError: @@ -136,7 +148,8 @@ raise TestFailed, "negative co_argcount didn't trigger an exception" try: # this used to trigger a SystemError - d = new.code(argcount, -nlocals, stacksize, flags, codestring, + d = new.code(argcount, kwonlyargcount, + -nlocals, stacksize, flags, codestring, constants, names, varnames, filename, name, firstlineno, lnotab) except ValueError: @@ -145,7 +158,8 @@ raise TestFailed, "negative co_nlocals didn't trigger an exception" try: # this used to trigger a Py_FatalError! - d = new.code(argcount, nlocals, stacksize, flags, codestring, + d = new.code(argcount, kwonlyargcount, + nlocals, stacksize, flags, codestring, constants, (5,), varnames, filename, name, firstlineno, lnotab) except TypeError: @@ -156,7 +170,8 @@ # new.code used to be a way to mutate a tuple... class S(str): pass t = (S("ab"),) - d = new.code(argcount, nlocals, stacksize, flags, codestring, + d = new.code(argcount, kwonlyargcount, + nlocals, stacksize, flags, codestring, constants, t, varnames, filename, name, firstlineno, lnotab) verify(type(t[0]) is S, "eek, tuple changed under us!") Modified: python/branches/p3yk-noslice/Lib/test/test_nis.py ============================================================================== --- python/branches/p3yk-noslice/Lib/test/test_nis.py (original) +++ python/branches/p3yk-noslice/Lib/test/test_nis.py Fri Dec 15 05:21:50 2006 @@ -1,32 +1,41 @@ -from test.test_support import verbose, TestFailed, TestSkipped +from test.test_support import verbose, run_unittest +import unittest import nis -print 'nis.maps()' -try: - maps = nis.maps() -except nis.error, msg: - # NIS is probably not active, so this test isn't useful - if verbose: - raise TestFailed, msg - # only do this if running under the regression suite - raise TestSkipped, msg +class NisTests(unittest.TestCase): + def test_maps(self): + try: + maps = nis.maps() + except nis.error, msg: + # NIS is probably not active, so this test isn't useful + if verbose: + self.fail("(failing because of verbose mode) %s" % msg) + return + try: + # On some systems, this map is only accessible to the + # super user + maps.remove("passwd.adjunct.byname") + except ValueError: + pass -done = 0 -for nismap in maps: - if verbose: - print nismap - mapping = nis.cat(nismap) - for k, v in mapping.items(): - if verbose: - print ' ', k, v - if not k: - continue - if nis.match(k, nismap) != v: - print "NIS match failed for key `%s' in map `%s'" % (k, nismap) - else: - # just test the one key, otherwise this test could take a - # very long time - done = 1 - break - if done: - break + done = 0 + for nismap in maps: + mapping = nis.cat(nismap) + for k, v in mapping.items(): + if not k: + continue + if nis.match(k, nismap) != v: + self.fail("NIS match failed for key `%s' in map `%s'" % (k, nismap)) + else: + # just test the one key, otherwise this test could take a + # very long time + done = 1 + break + if done: + break + +def test_main(): + run_unittest(NisTests) + +if __name__ == '__main__': + test_main() Modified: python/branches/p3yk-noslice/Lib/test/test_opcodes.py ============================================================================== --- python/branches/p3yk-noslice/Lib/test/test_opcodes.py (original) +++ python/branches/p3yk-noslice/Lib/test/test_opcodes.py Fri Dec 15 05:21:50 2006 @@ -1,101 +1,110 @@ # Python test set -- part 2, opcodes -from test.test_support import TestFailed +from test.test_support import run_unittest +import unittest +class OpcodeTest(unittest.TestCase): -print '2. Opcodes' -print 'XXX Not yet fully implemented' + def test_try_inside_for_loop(self): + n = 0 + for i in range(10): + n = n+i + try: 1/0 + except NameError: pass + except ZeroDivisionError: pass + except TypeError: pass + try: pass + except: pass + try: pass + finally: pass + n = n+i + if n != 90: + self.fail('try inside for') + + def test_raise_class_exceptions(self): + + class AClass(Exception): pass + class BClass(AClass): pass + class CClass(Exception): pass + class DClass(AClass): + def __init__(self, ignore): + pass + + try: raise AClass() + except: pass + + try: raise AClass() + except AClass: pass + + try: raise BClass() + except AClass: pass + + try: raise BClass() + except CClass: self.fail() + except: pass + + a = AClass() + b = BClass() + + try: raise AClass, b + except BClass, v: + if v != b: self.fail("v!=b") + else: self.fail("no exception") + + try: raise b + except AClass, v: + if v != b: self.fail("v!=b AClass") + else: + self.fail("no exception") + + # not enough arguments + ##try: raise BClass, a + ##except TypeError: pass + ##else: self.fail("no exception") + + try: raise DClass, a + except DClass, v: + self.assert_(isinstance(v, DClass)) + else: + self.fail("no exception") + + def test_compare_function_objects(self): + + f = eval('lambda: None') + g = eval('lambda: None') + self.failIf(f == g) + + f = eval('lambda a: a') + g = eval('lambda a: a') + self.failIf(f == g) + + f = eval('lambda a=1: a') + g = eval('lambda a=1: a') + self.failIf(f == g) + + f = eval('lambda: 0') + g = eval('lambda: 1') + self.failIf(f == g) + + f = eval('lambda: None') + g = eval('lambda a: None') + self.failIf(f == g) + + f = eval('lambda a: None') + g = eval('lambda b: None') + self.failIf(f == g) + + f = eval('lambda a: None') + g = eval('lambda a=None: None') + self.failIf(f == g) + + f = eval('lambda a=0: None') + g = eval('lambda a=1: None') + self.failIf(f == g) -print '2.1 try inside for loop' -n = 0 -for i in range(10): - n = n+i - try: 1/0 - except NameError: pass - except ZeroDivisionError: pass - except TypeError: pass - try: pass - except: pass - try: pass - finally: pass - n = n+i -if n != 90: - raise TestFailed, 'try inside for' - - -print '2.2 raise class exceptions' - -class AClass(Exception): pass -class BClass(AClass): pass -class CClass(Exception): pass -class DClass(AClass): - def __init__(self, ignore): - pass - -try: raise AClass() -except: pass - -try: raise AClass() -except AClass: pass - -try: raise BClass() -except AClass: pass - -try: raise BClass() -except CClass: raise TestFailed -except: pass - -a = AClass() -b = BClass() - -try: raise AClass, b -except BClass, v: - if v != b: raise TestFailed, "v!=b" -else: raise TestFailed, "no exception" - -try: raise b -except AClass, v: - if v != b: raise TestFailed, "v!=b AClass" - -# not enough arguments -##try: raise BClass, a -##except TypeError: pass - -try: raise DClass, a -except DClass, v: - if not isinstance(v, DClass): - raise TestFailed, "v not DClass" - -print '2.3 comparing function objects' - -f = eval('lambda: None') -g = eval('lambda: None') -if f == g: raise TestFailed, "functions should not be same" - -f = eval('lambda a: a') -g = eval('lambda a: a') -if f == g: raise TestFailed, "functions should not be same" - -f = eval('lambda a=1: a') -g = eval('lambda a=1: a') -if f == g: raise TestFailed, "functions should not be same" - -f = eval('lambda: 0') -g = eval('lambda: 1') -if f == g: raise TestFailed - -f = eval('lambda: None') -g = eval('lambda a: None') -if f == g: raise TestFailed - -f = eval('lambda a: None') -g = eval('lambda b: None') -if f == g: raise TestFailed - -f = eval('lambda a: None') -g = eval('lambda a=None: None') -if f == g: raise TestFailed - -f = eval('lambda a=0: None') -g = eval('lambda a=1: None') -if f == g: raise TestFailed + +def test_main(): + run_unittest(OpcodeTest) + +if __name__ == '__main__': + test_main() Modified: python/branches/p3yk-noslice/Lib/test/test_openpty.py ============================================================================== --- python/branches/p3yk-noslice/Lib/test/test_openpty.py (original) +++ python/branches/p3yk-noslice/Lib/test/test_openpty.py Fri Dec 15 05:21:50 2006 @@ -1,19 +1,23 @@ # Test to see if openpty works. (But don't worry if it isn't available.) -import os -from test.test_support import verbose, TestFailed, TestSkipped +import os, unittest +from test.test_support import run_unittest, TestSkipped -try: - if verbose: - print "Calling os.openpty()" - master, slave = os.openpty() - if verbose: - print "(master, slave) = (%d, %d)"%(master, slave) -except AttributeError: +if not hasattr(os, "openpty"): raise TestSkipped, "No openpty() available." -if not os.isatty(slave): - raise TestFailed, "Slave-end of pty is not a terminal." -os.write(slave, 'Ping!') -print os.read(master, 1024) +class OpenptyTest(unittest.TestCase): + def test(self): + master, slave = os.openpty() + if not os.isatty(slave): + self.fail("Slave-end of pty is not a terminal.") + + os.write(slave, 'Ping!') + self.assertEqual(os.read(master, 1024), 'Ping!') + +def test_main(): + run_unittest(OpenptyTest) + +if __name__ == '__main__': + test_main() Modified: python/branches/p3yk-noslice/Lib/test/test_operations.py ============================================================================== --- python/branches/p3yk-noslice/Lib/test/test_operations.py (original) +++ python/branches/p3yk-noslice/Lib/test/test_operations.py Fri Dec 15 05:21:50 2006 @@ -12,7 +12,7 @@ def __hash__(self): return hash(self.__class__) - def __cmp__(self, other): + def __eq__(self, other): if isinstance(other, self.__class__): print "raising error" raise RuntimeError, "gotcha" @@ -30,11 +30,11 @@ 'd.pop(x2)', 'd.update({x2: 2})']: try: - exec stmt + exec(stmt) except RuntimeError: print "%s: caught the RuntimeError outside" % (stmt,) else: - print "%s: No exception passed through!" # old CPython behavior + print "%s: No exception passed through!" % (stmt,) # old CPython behavior # Dict resizing bug, found by Jack Jansen in 2.2 CVS development. Modified: python/branches/p3yk-noslice/Lib/test/test_operator.py ============================================================================== --- python/branches/p3yk-noslice/Lib/test/test_operator.py (original) +++ python/branches/p3yk-noslice/Lib/test/test_operator.py Fri Dec 15 05:21:50 2006 @@ -319,7 +319,7 @@ def test_truth(self): class C(object): - def __nonzero__(self): + def __bool__(self): raise SyntaxError self.failUnlessRaises(TypeError, operator.truth) self.failUnlessRaises(SyntaxError, operator.truth, C()) Modified: python/branches/p3yk-noslice/Lib/test/test_os.py ============================================================================== --- python/branches/p3yk-noslice/Lib/test/test_os.py (original) +++ python/branches/p3yk-noslice/Lib/test/test_os.py Fri Dec 15 05:21:50 2006 @@ -223,6 +223,23 @@ except TypeError: pass + def test_utime_dir(self): + delta = 1000000 + st = os.stat(test_support.TESTFN) + # round to int, because some systems may support sub-second + # time stamps in stat, but not in utime. + os.utime(test_support.TESTFN, (st.st_atime, int(st.st_mtime-delta))) + st2 = os.stat(test_support.TESTFN) + self.assertEquals(st2.st_mtime, int(st.st_mtime-delta)) + + # Restrict test to Win32, since there is no guarantee other + # systems support centiseconds + if sys.platform == 'win32': + def test_1565150(self): + t1 = 1159195039.25 + os.utime(self.fname, (t1, t1)) + self.assertEquals(os.stat(self.fname).st_mtime, t1) + from test import mapping_tests class EnvironTests(mapping_tests.BasicTestMappingProtocol): @@ -273,7 +290,7 @@ os.makedirs(sub11_path) os.makedirs(sub2_path) for path in tmp1_path, tmp2_path, tmp3_path: - f = file(path, "w") + f = open(path, "w") f.write("I'm " + path + " and proud of it. Blame test_os.\n") f.close() @@ -361,10 +378,10 @@ class DevNullTests (unittest.TestCase): def test_devnull(self): - f = file(os.devnull, 'w') + f = open(os.devnull, 'w') f.write('hello') f.close() - f = file(os.devnull, 'r') + f = open(os.devnull, 'r') self.assertEqual(f.read(), '') f.close() Modified: python/branches/p3yk-noslice/Lib/test/test_parser.py ============================================================================== --- python/branches/p3yk-noslice/Lib/test/test_parser.py (original) +++ python/branches/p3yk-noslice/Lib/test/test_parser.py Fri Dec 15 05:21:50 2006 @@ -183,6 +183,44 @@ def test_assert(self): self.check_suite("assert alo < ahi and blo < bhi\n") + def test_position(self): + # An absolutely minimal test of position information. Better + # tests would be a big project. + code = "def f(x):\n return x + 1\n" + st1 = parser.suite(code) + st2 = st1.totuple(line_info=1, col_info=1) + + def walk(tree): + node_type = tree[0] + next = tree[1] + if isinstance(next, tuple): + for elt in tree[1:]: + for x in walk(elt): + yield x + else: + yield tree + + terminals = list(walk(st2)) + self.assertEqual([ + (1, 'def', 1, 0), + (1, 'f', 1, 4), + (7, '(', 1, 5), + (1, 'x', 1, 6), + (8, ')', 1, 7), + (11, ':', 1, 8), + (4, '', 1, 9), + (5, '', 2, -1), + (1, 'return', 2, 4), + (1, 'x', 2, 11), + (14, '+', 2, 13), + (2, '1', 2, 15), + (4, '', 2, 16), + (6, '', 2, -1), + (4, '', 2, -1), + (0, '', 2, -1)], + terminals) + + # # Second, we take *invalid* trees and make sure we get ParserError # rejections for them. @@ -429,7 +467,7 @@ st = parser.suite('x = 2; y = x + 3') code = parser.compilest(st) globs = {} - exec code in globs + exec(code, globs) self.assertEquals(globs['y'], 5) def test_compile_error(self): Modified: python/branches/p3yk-noslice/Lib/test/test_peepholer.py ============================================================================== --- python/branches/p3yk-noslice/Lib/test/test_peepholer.py (original) +++ python/branches/p3yk-noslice/Lib/test/test_peepholer.py Fri Dec 15 05:21:50 2006 @@ -135,7 +135,6 @@ def test_folding_of_unaryops_on_constants(self): for line, elem in ( - ('`1`', "('1')"), # unary convert ('-0.5', '(-0.5)'), # unary negative ('~-2', '(1)'), # unary invert ): @@ -161,6 +160,41 @@ self.assert_('(None)' not in asm) self.assertEqual(asm.split().count('RETURN_VALUE'), 1) + def test_elim_jump_to_return(self): + # JUMP_FORWARD to RETURN --> RETURN + def f(cond, true_value, false_value): + return true_value if cond else false_value + asm = disassemble(f) + self.assert_('JUMP_FORWARD' not in asm) + self.assert_('JUMP_ABSOLUTE' not in asm) + self.assertEqual(asm.split().count('RETURN_VALUE'), 2) + + def test_elim_jump_after_return1(self): + # Eliminate dead code: jumps immediately after returns can't be reached + def f(cond1, cond2): + if cond1: return 1 + if cond2: return 2 + while 1: + return 3 + while 1: + if cond1: return 4 + return 5 + return 6 + asm = disassemble(f) + self.assert_('JUMP_FORWARD' not in asm) + self.assert_('JUMP_ABSOLUTE' not in asm) + self.assertEqual(asm.split().count('RETURN_VALUE'), 6) + + def test_elim_jump_after_return2(self): + # Eliminate dead code: jumps immediately after returns can't be reached + def f(cond1, cond2): + while 1: + if cond1: return 4 + asm = disassemble(f) + self.assert_('JUMP_FORWARD' not in asm) + # There should be one jump for the while loop. + self.assertEqual(asm.split().count('JUMP_ABSOLUTE'), 1) + self.assertEqual(asm.split().count('RETURN_VALUE'), 2) def test_main(verbose=None): Modified: python/branches/p3yk-noslice/Lib/test/test_pep352.py ============================================================================== --- python/branches/p3yk-noslice/Lib/test/test_pep352.py (original) +++ python/branches/p3yk-noslice/Lib/test/test_pep352.py Fri Dec 15 05:21:50 2006 @@ -15,8 +15,7 @@ self.failUnless(issubclass(Exception, object)) def verify_instance_interface(self, ins): - for attr in ("args", "message", "__str__", "__unicode__", "__repr__", - "__getitem__"): + for attr in ("args", "message", "__str__", "__repr__", "__getitem__"): self.failUnless(hasattr(ins, attr), "%s missing %s attribute" % (ins.__class__.__name__, attr)) Modified: python/branches/p3yk-noslice/Lib/test/test_poll.py ============================================================================== --- python/branches/p3yk-noslice/Lib/test/test_poll.py (original) +++ python/branches/p3yk-noslice/Lib/test/test_poll.py Fri Dec 15 05:21:50 2006 @@ -1,7 +1,7 @@ # Test case for the os.poll() function -import sys, os, select, random -from test.test_support import verify, verbose, TestSkipped, TESTFN +import sys, os, select, random, unittest +from test.test_support import TestSkipped, TESTFN, run_unittest try: select.poll @@ -16,177 +16,141 @@ match.append(fd) return match -def test_poll1(): - """Basic functional test of poll object +class PollTests(unittest.TestCase): - Create a bunch of pipe and test that poll works with them. - """ - print 'Running poll test 1' - p = select.poll() - - NUM_PIPES = 12 - MSG = " This is a test." - MSG_LEN = len(MSG) - readers = [] - writers = [] - r2w = {} - w2r = {} - - for i in range(NUM_PIPES): - rd, wr = os.pipe() - p.register(rd, select.POLLIN) - p.register(wr, select.POLLOUT) - readers.append(rd) - writers.append(wr) - r2w[rd] = wr - w2r[wr] = rd - - while writers: - ready = p.poll() - ready_writers = find_ready_matching(ready, select.POLLOUT) - if not ready_writers: - raise RuntimeError, "no pipes ready for writing" - wr = random.choice(ready_writers) - os.write(wr, MSG) - - ready = p.poll() - ready_readers = find_ready_matching(ready, select.POLLIN) - if not ready_readers: - raise RuntimeError, "no pipes ready for reading" - rd = random.choice(ready_readers) - buf = os.read(rd, MSG_LEN) - verify(len(buf) == MSG_LEN) - print buf - os.close(r2w[rd]) ; os.close( rd ) - p.unregister( r2w[rd] ) - p.unregister( rd ) - writers.remove(r2w[rd]) - - poll_unit_tests() - print 'Poll test 1 complete' - -def poll_unit_tests(): - # returns NVAL for invalid file descriptor - FD = 42 - try: - os.close(FD) - except OSError: - pass - p = select.poll() - p.register(FD) - r = p.poll() - verify(r[0] == (FD, select.POLLNVAL)) - - f = open(TESTFN, 'w') - fd = f.fileno() - p = select.poll() - p.register(f) - r = p.poll() - verify(r[0][0] == fd) - f.close() - r = p.poll() - verify(r[0] == (fd, select.POLLNVAL)) - os.unlink(TESTFN) - - # type error for invalid arguments - p = select.poll() - try: - p.register(p) - except TypeError: - pass - else: - print "Bogus register call did not raise TypeError" - try: - p.unregister(p) - except TypeError: - pass - else: - print "Bogus unregister call did not raise TypeError" - - # can't unregister non-existent object - p = select.poll() - try: - p.unregister(3) - except KeyError: - pass - else: - print "Bogus unregister call did not raise KeyError" - - # Test error cases - pollster = select.poll() - class Nope: - pass - - class Almost: - def fileno(self): - return 'fileno' - - try: - pollster.register( Nope(), 0 ) - except TypeError: pass - else: print 'expected TypeError exception, not raised' - - try: - pollster.register( Almost(), 0 ) - except TypeError: pass - else: print 'expected TypeError exception, not raised' - - -# Another test case for poll(). This is copied from the test case for -# select(), modified to use poll() instead. - -def test_poll2(): - print 'Running poll test 2' - cmd = 'for i in 0 1 2 3 4 5 6 7 8 9; do echo testing...; sleep 1; done' - p = os.popen(cmd, 'r') - pollster = select.poll() - pollster.register( p, select.POLLIN ) - for tout in (0, 1000, 2000, 4000, 8000, 16000) + (-1,)*10: - if verbose: - print 'timeout =', tout - fdlist = pollster.poll(tout) - if (fdlist == []): - continue - fd, flags = fdlist[0] - if flags & select.POLLHUP: - line = p.readline() - if line != "": - print 'error: pipe seems to be closed, but still returns data' - continue - - elif flags & select.POLLIN: - line = p.readline() - if verbose: - print repr(line) - if not line: - if verbose: - print 'EOF' - break - continue - else: - print 'Unexpected return value from select.poll:', fdlist - p.close() - print 'Poll test 2 complete' - -def test_poll3(): - # test int overflow - print 'Running poll test 3' - pollster = select.poll() - pollster.register(1) - - try: - pollster.poll(1L << 64) - except OverflowError: - pass - else: - print 'Expected OverflowError with excessive timeout' - - x = 2 + 3 - if x != 5: - print 'Overflow must have occurred' - print 'Poll test 3 complete' - - -test_poll1() -test_poll2() -test_poll3() + def test_poll1(self): + # Basic functional test of poll object + # Create a bunch of pipe and test that poll works with them. + + p = select.poll() + + NUM_PIPES = 12 + MSG = " This is a test." + MSG_LEN = len(MSG) + readers = [] + writers = [] + r2w = {} + w2r = {} + + for i in range(NUM_PIPES): + rd, wr = os.pipe() + p.register(rd, select.POLLIN) + p.register(wr, select.POLLOUT) + readers.append(rd) + writers.append(wr) + r2w[rd] = wr + w2r[wr] = rd + + bufs = [] + + while writers: + ready = p.poll() + ready_writers = find_ready_matching(ready, select.POLLOUT) + if not ready_writers: + raise RuntimeError, "no pipes ready for writing" + wr = random.choice(ready_writers) + os.write(wr, MSG) + + ready = p.poll() + ready_readers = find_ready_matching(ready, select.POLLIN) + if not ready_readers: + raise RuntimeError, "no pipes ready for reading" + rd = random.choice(ready_readers) + buf = os.read(rd, MSG_LEN) + self.assertEqual(len(buf), MSG_LEN) + bufs.append(buf) + os.close(r2w[rd]) ; os.close( rd ) + p.unregister( r2w[rd] ) + p.unregister( rd ) + writers.remove(r2w[rd]) + + self.assertEqual(bufs, [MSG] * NUM_PIPES) + + def poll_unit_tests(self): + # returns NVAL for invalid file descriptor + FD = 42 + try: + os.close(FD) + except OSError: + pass + p = select.poll() + p.register(FD) + r = p.poll() + self.assertEqual(r[0], (FD, select.POLLNVAL)) + + f = open(TESTFN, 'w') + fd = f.fileno() + p = select.poll() + p.register(f) + r = p.poll() + self.assertEqual(r[0][0], fd) + f.close() + r = p.poll() + self.assertEqual(r[0], (fd, select.POLLNVAL)) + os.unlink(TESTFN) + + # type error for invalid arguments + p = select.poll() + self.assertRaises(TypeError, p.register, p) + self.assertRaises(TypeError, p.unregister, p) + + # can't unregister non-existent object + p = select.poll() + self.assertRaises(KeyError, p.unregister, 3) + + # Test error cases + pollster = select.poll() + class Nope: + pass + + class Almost: + def fileno(self): + return 'fileno' + + self.assertRaises(TypeError, pollster.register, Nope(), 0) + self.assertRaises(TypeError, pollster.register, Almost(), 0) + + # Another test case for poll(). This is copied from the test case for + # select(), modified to use poll() instead. + + def test_poll2(self): + cmd = 'for i in 0 1 2 3 4 5 6 7 8 9; do echo testing...; sleep 1; done' + p = os.popen(cmd, 'r') + pollster = select.poll() + pollster.register( p, select.POLLIN ) + for tout in (0, 1000, 2000, 4000, 8000, 16000) + (-1,)*10: + fdlist = pollster.poll(tout) + if (fdlist == []): + continue + fd, flags = fdlist[0] + if flags & select.POLLHUP: + line = p.readline() + if line != "": + self.fail('error: pipe seems to be closed, but still returns data') + continue + + elif flags & select.POLLIN: + line = p.readline() + if not line: + break + continue + else: + self.fail('Unexpected return value from select.poll: %s' % fdlist) + p.close() + + def test_poll3(self): + # test int overflow + pollster = select.poll() + pollster.register(1) + + self.assertRaises(OverflowError, pollster.poll, 1L << 64) + + x = 2 + 3 + if x != 5: + self.fail('Overflow must have occurred') + +def test_main(): + run_unittest(PollTests) + +if __name__ == '__main__': + test_main() Modified: python/branches/p3yk-noslice/Lib/test/test_pyclbr.py ============================================================================== --- python/branches/p3yk-noslice/Lib/test/test_pyclbr.py (original) +++ python/branches/p3yk-noslice/Lib/test/test_pyclbr.py Fri Dec 15 05:21:50 2006 @@ -95,6 +95,9 @@ py_item = getattr(module, name) if isinstance(value, pyclbr.Function): self.assert_(isinstance(py_item, (FunctionType, BuiltinFunctionType))) + if py_item.__module__ != moduleName: + continue # skip functions that came from somewhere else + self.assertEquals(py_item.__module__, value.module) else: self.failUnless(isinstance(py_item, (ClassType, type))) if py_item.__module__ != moduleName: Modified: python/branches/p3yk-noslice/Lib/test/test_rfc822.py ============================================================================== --- python/branches/p3yk-noslice/Lib/test/test_rfc822.py (original) +++ python/branches/p3yk-noslice/Lib/test/test_rfc822.py Fri Dec 15 05:21:50 2006 @@ -46,9 +46,9 @@ continue i = i + 1 self.assertEqual(mn, n, - "Un-expected name: %s != %s" % (`mn`, `n`)) + "Un-expected name: %r != %r" % (mn, n)) self.assertEqual(ma, a, - "Un-expected address: %s != %s" % (`ma`, `a`)) + "Un-expected address: %r != %r" % (ma, a)) if mn == n and ma == a: pass else: Modified: python/branches/p3yk-noslice/Lib/test/test_richcmp.py ============================================================================== --- python/branches/p3yk-noslice/Lib/test/test_richcmp.py (original) +++ python/branches/p3yk-noslice/Lib/test/test_richcmp.py Fri Dec 15 05:21:50 2006 @@ -51,7 +51,7 @@ def __hash__(self): raise TypeError, "Vectors cannot be hashed" - def __nonzero__(self): + def __bool__(self): raise TypeError, "Vectors cannot be used in Boolean contexts" def __cmp__(self, other): @@ -133,7 +133,7 @@ for ops in opmap.itervalues(): for op in ops: - # calls __nonzero__, which should fail + # calls __bool__, which should fail self.assertRaises(TypeError, bool, op(a, b)) class NumberTest(unittest.TestCase): @@ -208,13 +208,13 @@ self.assertRaises(RuntimeError, cmp, a, b) def test_not(self): - # Check that exceptions in __nonzero__ are properly + # Check that exceptions in __bool__ are properly # propagated by the not operator import operator class Exc(Exception): pass class Bad: - def __nonzero__(self): + def __bool__(self): raise Exc def do(bad): Modified: python/branches/p3yk-noslice/Lib/test/test_scope.py ============================================================================== --- python/branches/p3yk-noslice/Lib/test/test_scope.py (original) +++ python/branches/p3yk-noslice/Lib/test/test_scope.py Fri Dec 15 05:21:50 2006 @@ -1,186 +1,190 @@ -from test.test_support import verify, TestFailed, check_syntax, vereq +import unittest +from test.test_support import check_syntax_error, run_unittest import warnings +warnings.filterwarnings("ignore", r"import \*", SyntaxWarning, "") warnings.filterwarnings("ignore", r"import \*", SyntaxWarning, "") -print "1. simple nesting" +class ScopeTests(unittest.TestCase): -def make_adder(x): - def adder(y): - return x + y - return adder + def testSimpleNesting(self): -inc = make_adder(1) -plus10 = make_adder(10) + def make_adder(x): + def adder(y): + return x + y + return adder -vereq(inc(1), 2) -vereq(plus10(-2), 8) + inc = make_adder(1) + plus10 = make_adder(10) -print "2. extra nesting" + self.assertEqual(inc(1), 2) + self.assertEqual(plus10(-2), 8) -def make_adder2(x): - def extra(): # check freevars passing through non-use scopes - def adder(y): - return x + y - return adder - return extra() + def testExtraNesting(self): -inc = make_adder2(1) -plus10 = make_adder2(10) + def make_adder2(x): + def extra(): # check freevars passing through non-use scopes + def adder(y): + return x + y + return adder + return extra() -vereq(inc(1), 2) -vereq(plus10(-2), 8) + inc = make_adder2(1) + plus10 = make_adder2(10) -print "3. simple nesting + rebinding" + self.assertEqual(inc(1), 2) + self.assertEqual(plus10(-2), 8) -def make_adder3(x): - def adder(y): - return x + y - x = x + 1 # check tracking of assignment to x in defining scope - return adder + def testSimpleAndRebinding(self): -inc = make_adder3(0) -plus10 = make_adder3(9) + def make_adder3(x): + def adder(y): + return x + y + x = x + 1 # check tracking of assignment to x in defining scope + return adder -vereq(inc(1), 2) -vereq(plus10(-2), 8) + inc = make_adder3(0) + plus10 = make_adder3(9) -print "4. nesting with global but no free" + self.assertEqual(inc(1), 2) + self.assertEqual(plus10(-2), 8) -def make_adder4(): # XXX add exta level of indirection - def nest(): - def nest(): - def adder(y): - return global_x + y # check that plain old globals work - return adder - return nest() - return nest() + def testNestingGlobalNoFree(self): -global_x = 1 -adder = make_adder4() -vereq(adder(1), 2) + def make_adder4(): # XXX add exta level of indirection + def nest(): + def nest(): + def adder(y): + return global_x + y # check that plain old globals work + return adder + return nest() + return nest() -global_x = 10 -vereq(adder(-2), 8) + global_x = 1 + adder = make_adder4() + self.assertEqual(adder(1), 2) -print "5. nesting through class" + global_x = 10 + self.assertEqual(adder(-2), 8) -def make_adder5(x): - class Adder: - def __call__(self, y): - return x + y - return Adder() + def testNestingThroughClass(self): -inc = make_adder5(1) -plus10 = make_adder5(10) + def make_adder5(x): + class Adder: + def __call__(self, y): + return x + y + return Adder() -vereq(inc(1), 2) -vereq(plus10(-2), 8) + inc = make_adder5(1) + plus10 = make_adder5(10) -print "6. nesting plus free ref to global" + self.assertEqual(inc(1), 2) + self.assertEqual(plus10(-2), 8) -def make_adder6(x): - global global_nest_x - def adder(y): - return global_nest_x + y - global_nest_x = x - return adder + def testNestingPlusFreeRefToGlobal(self): -inc = make_adder6(1) -plus10 = make_adder6(10) + def make_adder6(x): + global global_nest_x + def adder(y): + return global_nest_x + y + global_nest_x = x + return adder -vereq(inc(1), 11) # there's only one global -vereq(plus10(-2), 8) + inc = make_adder6(1) + plus10 = make_adder6(10) -print "7. nearest enclosing scope" + self.assertEqual(inc(1), 11) # there's only one global + self.assertEqual(plus10(-2), 8) -def f(x): - def g(y): - x = 42 # check that this masks binding in f() - def h(z): - return x + z - return h - return g(2) - -test_func = f(10) -vereq(test_func(5), 47) - -print "8. mixed freevars and cellvars" - -def identity(x): - return x - -def f(x, y, z): - def g(a, b, c): - a = a + x # 3 - def h(): - # z * (4 + 9) - # 3 * 13 - return identity(z * (b + y)) - y = c + z # 9 - return h - return g - -g = f(1, 2, 3) -h = g(2, 4, 6) -vereq(h(), 39) - -print "9. free variable in method" - -def test(): - method_and_var = "var" - class Test: - def method_and_var(self): - return "method" - def test(self): - return method_and_var - def actual_global(self): - return str("global") - def str(self): - return str(self) - return Test() - -t = test() -vereq(t.test(), "var") -vereq(t.method_and_var(), "method") -vereq(t.actual_global(), "global") - -method_and_var = "var" -class Test: - # this class is not nested, so the rules are different - def method_and_var(self): - return "method" - def test(self): - return method_and_var - def actual_global(self): - return str("global") - def str(self): - return str(self) - -t = Test() -vereq(t.test(), "var") -vereq(t.method_and_var(), "method") -vereq(t.actual_global(), "global") + def testNearestEnclosingScope(self): -print "10. recursion" + def f(x): + def g(y): + x = 42 # check that this masks binding in f() + def h(z): + return x + z + return h + return g(2) -def f(x): - def fact(n): - if n == 0: - return 1 - else: - return n * fact(n - 1) - if x >= 0: - return fact(x) - else: - raise ValueError, "x must be >= 0" + test_func = f(10) + self.assertEqual(test_func(5), 47) + + def testMixedFreevarsAndCellvars(self): + + def identity(x): + return x -vereq(f(6), 720) + def f(x, y, z): + def g(a, b, c): + a = a + x # 3 + def h(): + # z * (4 + 9) + # 3 * 13 + return identity(z * (b + y)) + y = c + z # 9 + return h + return g + + g = f(1, 2, 3) + h = g(2, 4, 6) + self.assertEqual(h(), 39) + + def testFreeVarInMethod(self): + + def test(): + method_and_var = "var" + class Test: + def method_and_var(self): + return "method" + def test(self): + return method_and_var + def actual_global(self): + return str("global") + def str(self): + return str(self) + return Test() + + t = test() + self.assertEqual(t.test(), "var") + self.assertEqual(t.method_and_var(), "method") + self.assertEqual(t.actual_global(), "global") + + method_and_var = "var" + class Test: + # this class is not nested, so the rules are different + def method_and_var(self): + return "method" + def test(self): + return method_and_var + def actual_global(self): + return str("global") + def str(self): + return str(self) + + t = Test() + self.assertEqual(t.test(), "var") + self.assertEqual(t.method_and_var(), "method") + self.assertEqual(t.actual_global(), "global") + + def testRecursion(self): + + def f(x): + def fact(n): + if n == 0: + return 1 + else: + return n * fact(n - 1) + if x >= 0: + return fact(x) + else: + raise ValueError, "x must be >= 0" + self.assertEqual(f(6), 720) -print "11. unoptimized namespaces" -check_syntax("""\ + def testUnoptimizedNamespaces(self): + + check_syntax_error(self, """\ def unoptimized_clash1(strip): def f(s): from string import * @@ -188,7 +192,7 @@ return f """) -check_syntax("""\ + check_syntax_error(self, """\ def unoptimized_clash2(): from string import * def f(s): @@ -196,7 +200,7 @@ return f """) -check_syntax("""\ + check_syntax_error(self, """\ def unoptimized_clash2(): from string import * def g(): @@ -205,32 +209,23 @@ return f """) -# XXX could allow this for exec with const argument, but what's the point -check_syntax("""\ -def error(y): - exec "a = 1" - def f(x): - return x + y - return f -""") - -check_syntax("""\ + check_syntax_error(self, """\ def f(x): def g(): return x del x # can't del name """) -check_syntax("""\ + check_syntax_error(self, """\ def f(): def g(): - from string import * - return strip # global or local? + from string import * + return strip # global or local? """) -# and verify a few cases that should work + # and verify a few cases that should work -exec """ + exec(""" def noproblem1(): from string import * f = lambda x:x @@ -245,61 +240,62 @@ def f(x): global y y = x -""" - -print "12. lambdas" - -f1 = lambda x: lambda y: x + y -inc = f1(1) -plus10 = f1(10) -vereq(inc(1), 2) -vereq(plus10(5), 15) - -f2 = lambda x: (lambda : lambda y: x + y)() -inc = f2(1) -plus10 = f2(10) -vereq(inc(1), 2) -vereq(plus10(5), 15) - -f3 = lambda x: lambda y: global_x + y -global_x = 1 -inc = f3(None) -vereq(inc(2), 3) +""") -f8 = lambda x, y, z: lambda a, b, c: lambda : z * (b + y) -g = f8(1, 2, 3) -h = g(2, 4, 6) -vereq(h(), 18) - -print "13. UnboundLocal" - -def errorInOuter(): - print y - def inner(): - return y - y = 1 - -def errorInInner(): - def inner(): - return y - inner() - y = 1 + def testLambdas(self): -try: - errorInOuter() -except UnboundLocalError: - pass -else: - raise TestFailed + f1 = lambda x: lambda y: x + y + inc = f1(1) + plus10 = f1(10) + self.assertEqual(inc(1), 2) + self.assertEqual(plus10(5), 15) + + f2 = lambda x: (lambda : lambda y: x + y)() + inc = f2(1) + plus10 = f2(10) + self.assertEqual(inc(1), 2) + self.assertEqual(plus10(5), 15) + + f3 = lambda x: lambda y: global_x + y + global_x = 1 + inc = f3(None) + self.assertEqual(inc(2), 3) + + f8 = lambda x, y, z: lambda a, b, c: lambda : z * (b + y) + g = f8(1, 2, 3) + h = g(2, 4, 6) + self.assertEqual(h(), 18) + + def testUnboundLocal(self): + + def errorInOuter(): + print y + def inner(): + return y + y = 1 + + def errorInInner(): + def inner(): + return y + inner() + y = 1 + + try: + errorInOuter() + except UnboundLocalError: + pass + else: + self.fail() -try: - errorInInner() -except NameError: - pass -else: - raise TestFailed + try: + errorInInner() + except NameError: + pass + else: + self.fail() -# test for bug #1501934: incorrect LOAD/STORE_GLOBAL generation + # test for bug #1501934: incorrect LOAD/STORE_GLOBAL generation + exec(""" global_x = 1 def f(): global_x += 1 @@ -308,34 +304,36 @@ except UnboundLocalError: pass else: - raise TestFailed, 'scope of global_x not correctly determined' + fail('scope of global_x not correctly determined') +""", {'fail': self.fail}) -print "14. complex definitions" + def testComplexDefinitions(self): -def makeReturner(*lst): - def returner(): - return lst - return returner + def makeReturner(*lst): + def returner(): + return lst + return returner -vereq(makeReturner(1,2,3)(), (1,2,3)) + self.assertEqual(makeReturner(1,2,3)(), (1,2,3)) -def makeReturner2(**kwargs): - def returner(): - return kwargs - return returner + def makeReturner2(**kwargs): + def returner(): + return kwargs + return returner -vereq(makeReturner2(a=11)()['a'], 11) + self.assertEqual(makeReturner2(a=11)()['a'], 11) -def makeAddPair((a, b)): - def addPair((c, d)): - return (a + c, b + d) - return addPair + def makeAddPair((a, b)): + def addPair((c, d)): + return (a + c, b + d) + return addPair -vereq(makeAddPair((1, 2))((100, 200)), (101,202)) + self.assertEqual(makeAddPair((1, 2))((100, 200)), (101,202)) -print "15. scope of global statements" + def testScopeOfGlobalStmt(self): # Examples posted by Samuele Pedroni to python-dev on 3/1/2001 + exec("""\ # I x = 7 def f(): @@ -348,8 +346,8 @@ return h() return i() return g() -vereq(f(), 7) -vereq(x, 7) +self.assertEqual(f(), 7) +self.assertEqual(x, 7) # II x = 7 @@ -363,8 +361,8 @@ return h() return i() return g() -vereq(f(), 2) -vereq(x, 7) +self.assertEqual(f(), 2) +self.assertEqual(x, 7) # III x = 7 @@ -379,8 +377,8 @@ return h() return i() return g() -vereq(f(), 2) -vereq(x, 2) +self.assertEqual(f(), 2) +self.assertEqual(x, 2) # IV x = 7 @@ -395,8 +393,8 @@ return h() return i() return g() -vereq(f(), 2) -vereq(x, 2) +self.assertEqual(f(), 2) +self.assertEqual(x, 2) # XXX what about global statements in class blocks? # do they affect methods? @@ -411,34 +409,36 @@ return x g = Global() -vereq(g.get(), 13) +self.assertEqual(g.get(), 13) g.set(15) -vereq(g.get(), 13) +self.assertEqual(g.get(), 13) +""") -print "16. check leaks" + def testLeaks(self): -class Foo: - count = 0 + class Foo: + count = 0 - def __init__(self): - Foo.count += 1 + def __init__(self): + Foo.count += 1 - def __del__(self): - Foo.count -= 1 + def __del__(self): + Foo.count -= 1 -def f1(): - x = Foo() - def f2(): - return x - f2() + def f1(): + x = Foo() + def f2(): + return x + f2() -for i in range(100): - f1() + for i in range(100): + f1() -vereq(Foo.count, 0) + self.assertEqual(Foo.count, 0) -print "17. class and global" + def testClassAndGlobal(self): + exec("""\ def test(x): class Foo: global x @@ -447,9 +447,9 @@ return Foo() x = 0 -vereq(test(6)(2), 8) +self.assertEqual(test(6)(2), 8) x = -1 -vereq(test(3)(2), 5) +self.assertEqual(test(3)(2), 5) looked_up_by_load_name = False class X: @@ -458,104 +458,106 @@ locals()['looked_up_by_load_name'] = True passed = looked_up_by_load_name -verify(X.passed) - -print "18. verify that locals() works" - -def f(x): - def g(y): - def h(z): - return y + z - w = x + y - y += 3 - return locals() - return g - -d = f(2)(4) -verify('h' in d) -del d['h'] -vereq(d, {'x': 2, 'y': 7, 'w': 6}) - -print "19. var is bound and free in class" - -def f(x): - class C: - def m(self): - return x - a = x - return C - -inst = f(3)() -vereq(inst.a, inst.m()) - -print "20. interaction with trace function" - -import sys -def tracer(a,b,c): - return tracer - -def adaptgetter(name, klass, getter): - kind, des = getter - if kind == 1: # AV happens when stepping from this line to next - if des == "": - des = "_%s__%s" % (klass.__name__, name) - return lambda obj: getattr(obj, des) - -class TestClass: - pass +self.assert_(X.passed) +""") -sys.settrace(tracer) -adaptgetter("foo", TestClass, (1, "")) -sys.settrace(None) - -try: sys.settrace() -except TypeError: pass -else: raise TestFailed, 'sys.settrace() did not raise TypeError' + def testLocalsFunction(self): -print "20. eval and exec with free variables" + def f(x): + def g(y): + def h(z): + return y + z + w = x + y + y += 3 + return locals() + return g + + d = f(2)(4) + self.assert_('h' in d) + del d['h'] + self.assertEqual(d, {'x': 2, 'y': 7, 'w': 6}) + + def testBoundAndFree(self): + # var is bound and free in class + + def f(x): + class C: + def m(self): + return x + a = x + return C + + inst = f(3)() + self.assertEqual(inst.a, inst.m()) + + def testInteractionWithTraceFunc(self): + + import sys + def tracer(a,b,c): + return tracer + + def adaptgetter(name, klass, getter): + kind, des = getter + if kind == 1: # AV happens when stepping from this line to next + if des == "": + des = "_%s__%s" % (klass.__name__, name) + return lambda obj: getattr(obj, des) + + class TestClass: + pass + + sys.settrace(tracer) + adaptgetter("foo", TestClass, (1, "")) + sys.settrace(None) + + self.assertRaises(TypeError, sys.settrace) + + def testEvalExecFreeVars(self): + + def f(x): + return lambda: x + 1 + + g = f(3) + self.assertRaises(TypeError, eval, g.func_code) + + try: + exec(g.func_code, {}) + except TypeError: + pass + else: + self.fail("exec should have failed, because code contained free vars") -def f(x): - return lambda: x + 1 + def testListCompLocalVars(self): -g = f(3) -try: - eval(g.func_code) -except TypeError: - pass -else: - print "eval() should have failed, because code contained free vars" + try: + print bad + except NameError: + pass + else: + print "bad should not be defined" -try: - exec g.func_code -except TypeError: - pass -else: - print "exec should have failed, because code contained free vars" + def x(): + [bad for s in 'a b' for bad in s.split()] -print "21. list comprehension with local variables" + x() + try: + print bad + except NameError: + pass -try: - print bad -except NameError: - pass -else: - print "bad should not be defined" + def testEvalFreeVars(self): -def x(): - [bad for s in 'a b' for bad in s.split()] + def f(x): + def g(): + x + eval("x + 1") + return g -x() -try: - print bad -except NameError: - pass + f(4)() -print "22. eval with free variables" -def f(x): - def g(): - x - eval("x + 1") - return g +def test_main(): + run_unittest(ScopeTests) -f(4)() +if __name__ == '__main__': + test_main() Modified: python/branches/p3yk-noslice/Lib/test/test_set.py ============================================================================== --- python/branches/p3yk-noslice/Lib/test/test_set.py (original) +++ python/branches/p3yk-noslice/Lib/test/test_set.py Fri Dec 15 05:21:50 2006 @@ -18,7 +18,7 @@ class BadCmp: def __hash__(self): return 1 - def __cmp__(self, other): + def __eq__(self, other): raise RuntimeError class TestJointOps(unittest.TestCase): @@ -261,6 +261,11 @@ t = self.thetype(s) self.assertNotEqual(id(s), id(t)) + def test_set_literal(self): + s = set([1,2,3]) + t = {1,2,3} + self.assertEqual(s, t) + def test_hash(self): self.assertRaises(TypeError, hash, self.s) @@ -293,6 +298,17 @@ self.assert_(self.thetype(self.word) not in s) self.assertRaises(KeyError, self.s.remove, self.thetype(self.word)) + def test_remove_keyerror_unpacking(self): + # bug: www.python.org/sf/1576657 + for v1 in ['Q', (1,)]: + try: + self.s.remove(v1) + except KeyError, e: + v2 = e.args[0] + self.assertEqual(v1, v2) + else: + self.fail() + def test_discard(self): self.s.discard('a') self.assert_('a' not in self.s) @@ -626,7 +642,7 @@ self.set = set(self.values) self.dup = set(self.values) self.length = 0 - self.repr = "set([])" + self.repr = "set()" #------------------------------------------------------------------------------ @@ -637,7 +653,7 @@ self.set = set(self.values) self.dup = set(self.values) self.length = 1 - self.repr = "set([3])" + self.repr = "{3}" def test_in(self): self.failUnless(3 in self.set) @@ -654,7 +670,7 @@ self.set = set(self.values) self.dup = set(self.values) self.length = 1 - self.repr = "set([(0, 'zero')])" + self.repr = "{(0, 'zero')}" def test_in(self): self.failUnless((0, "zero") in self.set) @@ -781,11 +797,8 @@ a, b = set('a'), set('b') self.assertRaises(TypeError, cmp, a, b) - # You can view this as a buglet: cmp(a, a) does not raise TypeError, - # because __eq__ is tried before __cmp__, and a.__eq__(a) returns True, - # which Python thinks is good enough to synthesize a cmp() result - # without calling __cmp__. - self.assertEqual(cmp(a, a), 0) + # In py3k, this works! + self.assertRaises(TypeError, cmp, a, a) self.assertRaises(TypeError, cmp, a, 12) self.assertRaises(TypeError, cmp, "abc", a) @@ -1201,8 +1214,8 @@ def test_copy(self): dup = self.set.copy() - dup_list = list(dup); dup_list.sort() - set_list = list(self.set); set_list.sort() + dup_list = sorted(dup, key=repr) + set_list = sorted(self.set, key=repr) self.assertEqual(len(dup_list), len(set_list)) for i in range(len(dup_list)): self.failUnless(dup_list[i] is set_list[i]) @@ -1210,8 +1223,8 @@ def test_deep_copy(self): dup = copy.deepcopy(self.set) ##print type(dup), repr(dup) - dup_list = list(dup); dup_list.sort() - set_list = list(self.set); set_list.sort() + dup_list = sorted(dup, key=repr) + set_list = sorted(self.set, key=repr) self.assertEqual(len(dup_list), len(set_list)) for i in range(len(dup_list)): self.assertEqual(dup_list[i], set_list[i]) @@ -1374,7 +1387,7 @@ for cons in (set, frozenset): for s in ("123", "", range(1000), ('do', 1.2), xrange(2000,2200,5)): for g in (G, I, Ig, S, L, R): - self.assertEqual(sorted(cons(g(s))), sorted(g(s))) + self.assertEqual(sorted(cons(g(s)), key=repr), sorted(g(s), key=repr)) self.assertRaises(TypeError, cons , X(s)) self.assertRaises(TypeError, cons , N(s)) self.assertRaises(ZeroDivisionError, cons , E(s)) @@ -1386,7 +1399,7 @@ for g in (G, I, Ig, L, R): expected = meth(data) actual = meth(G(data)) - self.assertEqual(sorted(actual), sorted(expected)) + self.assertEqual(sorted(actual, key=repr), sorted(expected, key=repr)) self.assertRaises(TypeError, meth, X(s)) self.assertRaises(TypeError, meth, N(s)) self.assertRaises(ZeroDivisionError, meth, E(s)) @@ -1400,7 +1413,7 @@ t = s.copy() getattr(s, methname)(list(g(data))) getattr(t, methname)(g(data)) - self.assertEqual(sorted(s), sorted(t)) + self.assertEqual(sorted(s, key=repr), sorted(t, key=repr)) self.assertRaises(TypeError, getattr(set('january'), methname), X(data)) self.assertRaises(TypeError, getattr(set('january'), methname), N(data)) Modified: python/branches/p3yk-noslice/Lib/test/test_sets.py ============================================================================== --- python/branches/p3yk-noslice/Lib/test/test_sets.py (original) +++ python/branches/p3yk-noslice/Lib/test/test_sets.py Fri Dec 15 05:21:50 2006 @@ -234,11 +234,8 @@ a, b = Set('a'), Set('b') self.assertRaises(TypeError, cmp, a, b) - # You can view this as a buglet: cmp(a, a) does not raise TypeError, - # because __eq__ is tried before __cmp__, and a.__eq__(a) returns True, - # which Python thinks is good enough to synthesize a cmp() result - # without calling __cmp__. - self.assertEqual(cmp(a, a), 0) + # In py3k, this works! + self.assertRaises(TypeError, cmp, a, a) self.assertRaises(TypeError, cmp, a, 12) self.assertRaises(TypeError, cmp, "abc", a) @@ -675,8 +672,8 @@ def test_copy(self): dup = self.set.copy() - dup_list = list(dup); dup_list.sort() - set_list = list(self.set); set_list.sort() + dup_list = sorted(dup, key=repr) + set_list = sorted(self.set, key=repr) self.assertEqual(len(dup_list), len(set_list)) for i in range(len(dup_list)): self.failUnless(dup_list[i] is set_list[i]) @@ -684,8 +681,8 @@ def test_deep_copy(self): dup = copy.deepcopy(self.set) ##print type(dup), repr(dup) - dup_list = list(dup); dup_list.sort() - set_list = list(self.set); set_list.sort() + dup_list = sorted(dup, key=repr) + set_list = sorted(self.set, key=repr) self.assertEqual(len(dup_list), len(set_list)) for i in range(len(dup_list)): self.assertEqual(dup_list[i], set_list[i]) Modified: python/branches/p3yk-noslice/Lib/test/test_sgmllib.py ============================================================================== --- python/branches/p3yk-noslice/Lib/test/test_sgmllib.py (original) +++ python/branches/p3yk-noslice/Lib/test/test_sgmllib.py Fri Dec 15 05:21:50 2006 @@ -286,21 +286,6 @@ ('codepoint', 'convert', 42), ]) - def test_attr_values_quoted_markup(self): - """Multi-line and markup in attribute values""" - self.check_events("""text""", - [("starttag", "a", [("title", "foo\n
    bar")]), - ("data", "text"), - ("endtag", "a")]) - self.check_events("""text""", - [("starttag", "a", [("title", "less < than")]), - ("data", "text"), - ("endtag", "a")]) - self.check_events("""text""", - [("starttag", "a", [("title", "greater > than")]), - ("data", "text"), - ("endtag", "a")]) - def test_attr_funky_names(self): self.check_events("""""", [ ("starttag", "a", [("a.b", "v"), ("c:d", "v"), ("e-f", "v")]), @@ -376,6 +361,19 @@ ('decl', 'DOCTYPE doc []'), ]) + def test_read_chunks(self): + # SF bug #1541697, this caused sgml parser to hang + # Just verify this code doesn't cause a hang. + CHUNK = 1024 # increasing this to 8212 makes the problem go away + + f = open(test_support.findfile('sgml_input.html')) + fp = sgmllib.SGMLParser() + while 1: + data = f.read(CHUNK) + fp.feed(data) + if len(data) != CHUNK: + break + # XXX These tests have been disabled by prefixing their names with # an underscore. The first two exercise outstanding bugs in the # sgmllib module, and the third exhibits questionable behavior Modified: python/branches/p3yk-noslice/Lib/test/test_sha.py ============================================================================== --- python/branches/p3yk-noslice/Lib/test/test_sha.py (original) +++ python/branches/p3yk-noslice/Lib/test/test_sha.py Fri Dec 15 05:21:50 2006 @@ -11,9 +11,23 @@ class SHATestCase(unittest.TestCase): def check(self, data, digest): - computed = sha.new(data).hexdigest() + # Check digest matches the expected value + obj = sha.new(data) + computed = obj.hexdigest() self.assert_(computed == digest) + # Verify that the value doesn't change between two consecutive + # digest operations. + computed_again = obj.hexdigest() + self.assert_(computed == computed_again) + + # Check hexdigest() output matches digest()'s output + digest = obj.digest() + hexd = "" + for c in digest: + hexd += '%02x' % ord(c) + self.assert_(computed == hexd) + def test_case_1(self): self.check("abc", "a9993e364706816aba3e25717850c26c9cd0d89d") @@ -26,6 +40,9 @@ self.check("a" * 1000000, "34aa973cd4c4daa4f61eeb2bdbad27316534016f") + def test_case_4(self): + self.check(chr(0xAA) * 80, + '4ca0ef38f1794b28a8f8ee110ee79d48ce13be25') def test_main(): test_support.run_unittest(SHATestCase) Modified: python/branches/p3yk-noslice/Lib/test/test_site.py ============================================================================== --- python/branches/p3yk-noslice/Lib/test/test_site.py (original) +++ python/branches/p3yk-noslice/Lib/test/test_site.py Fri Dec 15 05:21:50 2006 @@ -164,7 +164,7 @@ site.abs__file__() for module in (sys, os, __builtin__): try: - self.failUnless(os.path.isabs(module.__file__), `module`) + self.failUnless(os.path.isabs(module.__file__), repr(module)) except AttributeError: continue # We could try everything in sys.modules; however, when regrtest.py Modified: python/branches/p3yk-noslice/Lib/test/test_slice.py ============================================================================== --- python/branches/p3yk-noslice/Lib/test/test_slice.py (original) +++ python/branches/p3yk-noslice/Lib/test/test_slice.py Fri Dec 15 05:21:50 2006 @@ -35,18 +35,18 @@ s1 = slice(BadCmp()) s2 = slice(BadCmp()) - self.assertRaises(Exc, cmp, s1, s2) self.assertEqual(s1, s1) + self.assertRaises(Exc, lambda: s1 == s2) s1 = slice(1, BadCmp()) s2 = slice(1, BadCmp()) self.assertEqual(s1, s1) - self.assertRaises(Exc, cmp, s1, s2) + self.assertRaises(Exc, lambda: s1 == s2) s1 = slice(1, 2, BadCmp()) s2 = slice(1, 2, BadCmp()) self.assertEqual(s1, s1) - self.assertRaises(Exc, cmp, s1, s2) + self.assertRaises(Exc, lambda: s1 == s2) def test_members(self): s = slice(1) Modified: python/branches/p3yk-noslice/Lib/test/test_socket.py ============================================================================== --- python/branches/p3yk-noslice/Lib/test/test_socket.py (original) +++ python/branches/p3yk-noslice/Lib/test/test_socket.py Fri Dec 15 05:21:50 2006 @@ -285,7 +285,7 @@ orig = sys.getrefcount(__name__) socket.getnameinfo(__name__,0) except SystemError: - if sys.getrefcount(__name__) <> orig: + if sys.getrefcount(__name__) != orig: self.fail("socket.getnameinfo loses a reference") def testInterpreterCrash(self): Modified: python/branches/p3yk-noslice/Lib/test/test_sort.py ============================================================================== --- python/branches/p3yk-noslice/Lib/test/test_sort.py (original) +++ python/branches/p3yk-noslice/Lib/test/test_sort.py Fri Dec 15 05:21:50 2006 @@ -68,8 +68,8 @@ self.key = key self.index = i - def __cmp__(self, other): - return cmp(self.key, other.key) + def __lt__(self, other): + return self.key < other.key def __repr__(self): return "Stable(%d, %d)" % (self.key, self.index) @@ -225,6 +225,8 @@ def __del__(self): del data[:] data[:] = range(20) + def __lt__(self, other): + return id(self) < id(other) self.assertRaises(ValueError, data.sort, key=SortKiller) def test_key_with_mutating_del_and_exception(self): Modified: python/branches/p3yk-noslice/Lib/test/test_subprocess.py ============================================================================== --- python/branches/p3yk-noslice/Lib/test/test_subprocess.py (original) +++ python/branches/p3yk-noslice/Lib/test/test_subprocess.py Fri Dec 15 05:21:50 2006 @@ -234,6 +234,12 @@ stripped = remove_stderr_debug_decorations(output) self.assertEqual(stripped, "appleorange") + def test_stdout_filedes_of_stdout(self): + # stdout is set to 1 (#1531862). + cmd = r"import sys, os; sys.exit(os.write(sys.stdout.fileno(), '.\n'))" + rc = subprocess.call([sys.executable, "-c", cmd], stdout=1) + self.assertEquals(rc, 2) + def test_cwd(self): tmpdir = os.getenv("TEMP", "/tmp") # We cannot use os.path.realpath to canonicalize the path, Modified: python/branches/p3yk-noslice/Lib/test/test_support.py ============================================================================== --- python/branches/p3yk-noslice/Lib/test/test_support.py (original) +++ python/branches/p3yk-noslice/Lib/test/test_support.py Fri Dec 15 05:21:50 2006 @@ -122,8 +122,8 @@ outcome = fcmp(x[i], y[i]) if outcome != 0: return outcome - return cmp(len(x), len(y)) - return cmp(x, y) + return (len(x) > len(y)) - (len(x) < len(y)) + return (x > y) - (x < y) try: unicode @@ -244,13 +244,13 @@ withcommas = ", ".join(reprpairs) return "{%s}" % withcommas -def check_syntax(statement): +def check_syntax_error(testcase, statement): try: - compile(statement, '', 'exec') + compile(statement, '', 'exec') except SyntaxError: pass else: - print 'Missing SyntaxError: "%s"' % statement + testcase.fail('Missing SyntaxError: "%s"' % statement) def open_urlresource(url): import urllib, urlparse Modified: python/branches/p3yk-noslice/Lib/test/test_syntax.py ============================================================================== --- python/branches/p3yk-noslice/Lib/test/test_syntax.py (original) +++ python/branches/p3yk-noslice/Lib/test/test_syntax.py Fri Dec 15 05:21:50 2006 @@ -71,7 +71,7 @@ >>> `1` = 1 Traceback (most recent call last): -SyntaxError: can't assign to repr (, line 1) +SyntaxError: invalid syntax If the left-hand side of an assignment is a list or tuple, an illegal expression inside that contain should still cause a syntax error. @@ -235,6 +235,138 @@ >>> f() += 1 Traceback (most recent call last): SyntaxError: illegal expression for augmented assignment (, line 1) + + +Test continue in finally in weird combinations. + +continue in for loop under finally shouuld be ok. + + >>> def test(): + ... try: + ... pass + ... finally: + ... for abc in range(10): + ... continue + ... print abc + >>> test() + 9 + +Start simple, a continue in a finally should not be allowed. + + >>> def test(): + ... for abc in range(10): + ... try: + ... pass + ... finally: + ... continue + Traceback (most recent call last): + ... + SyntaxError: 'continue' not supported inside 'finally' clause (, line 6) + +This is essentially a continue in a finally which should not be allowed. + + >>> def test(): + ... for abc in range(10): + ... try: + ... pass + ... finally: + ... try: + ... continue + ... except: + ... pass + Traceback (most recent call last): + ... + SyntaxError: 'continue' not supported inside 'finally' clause (, line 7) + + >>> def foo(): + ... try: + ... pass + ... finally: + ... continue + Traceback (most recent call last): + ... + SyntaxError: 'continue' not supported inside 'finally' clause (, line 5) + + >>> def foo(): + ... for a in (): + ... try: + ... pass + ... finally: + ... continue + Traceback (most recent call last): + ... + SyntaxError: 'continue' not supported inside 'finally' clause (, line 6) + + >>> def foo(): + ... for a in (): + ... try: + ... pass + ... finally: + ... try: + ... continue + ... finally: + ... pass + Traceback (most recent call last): + ... + SyntaxError: 'continue' not supported inside 'finally' clause (, line 7) + + >>> def foo(): + ... for a in (): + ... try: pass + ... finally: + ... try: + ... pass + ... except: + ... continue + Traceback (most recent call last): + ... + SyntaxError: 'continue' not supported inside 'finally' clause (, line 8) + +There is one test for a break that is not in a loop. The compiler +uses a single data structure to keep track of try-finally and loops, +so we need to be sure that a break is actually inside a loop. If it +isn't, there should be a syntax error. + + >>> try: + ... print 1 + ... break + ... print 2 + ... finally: + ... print 3 + Traceback (most recent call last): + ... + SyntaxError: 'break' outside loop (, line 3) + +This should probably raise a better error than a SystemError (or none at all). +In 2.5 there was a missing exception and an assert was triggered in a debug +build. The number of blocks must be greater than CO_MAXBLOCKS. SF #1565514 + + >>> while 1: + ... while 2: + ... while 3: + ... while 4: + ... while 5: + ... while 6: + ... while 8: + ... while 9: + ... while 10: + ... while 11: + ... while 12: + ... while 13: + ... while 14: + ... while 15: + ... while 16: + ... while 17: + ... while 18: + ... while 19: + ... while 20: + ... while 21: + ... while 22: + ... break + Traceback (most recent call last): + ... + SystemError: too many statically nested blocks + """ import re Modified: python/branches/p3yk-noslice/Lib/test/test_tarfile.py ============================================================================== --- python/branches/p3yk-noslice/Lib/test/test_tarfile.py (original) +++ python/branches/p3yk-noslice/Lib/test/test_tarfile.py Fri Dec 15 05:21:50 2006 @@ -280,6 +280,32 @@ else: self.dst.addfile(tarinfo, f) + +class Write100Test(BaseTest): + # The name field in a tar header stores strings of at most 100 chars. + # If a string is shorter than 100 chars it has to be padded with '\0', + # which implies that a string of exactly 100 chars is stored without + # a trailing '\0'. + + def setUp(self): + self.name = "01234567890123456789012345678901234567890123456789" + self.name += "01234567890123456789012345678901234567890123456789" + + self.tar = tarfile.open(tmpname(), "w") + t = tarfile.TarInfo(self.name) + self.tar.addfile(t) + self.tar.close() + + self.tar = tarfile.open(tmpname()) + + def tearDown(self): + self.tar.close() + + def test(self): + self.assertEqual(self.tar.getnames()[0], self.name, + "failed to store 100 char filename") + + class WriteSize0Test(BaseTest): mode = 'w' @@ -333,11 +359,11 @@ f.close() elif self.comp == "bz2": f = bz2.BZ2Decompressor() - s = file(self.dstname).read() + s = open(self.dstname).read() s = f.decompress(s) self.assertEqual(len(f.unused_data), 0, "trailing data") else: - f = file(self.dstname) + f = open(self.dstname) s = f.read() f.close() @@ -362,13 +388,6 @@ is tested as well. """ - def setUp(self): - self.tar = tarfile.open(tmpname(), "w") - self.tar.posix = False - - def tearDown(self): - self.tar.close() - def _length(self, s): blocks, remainder = divmod(len(s) + 1, 512) if remainder: @@ -397,12 +416,23 @@ tarinfo.linkname = link tarinfo.type = tarfile.LNKTYPE - self.tar.addfile(tarinfo) + tar = tarfile.open(tmpname(), "w") + tar.posix = False + tar.addfile(tarinfo) v1 = self._calc_size(name, link) - v2 = self.tar.offset + v2 = tar.offset self.assertEqual(v1, v2, "GNU longname/longlink creation failed") + tar.close() + + tar = tarfile.open(tmpname()) + member = tar.next() + self.failIf(member is None, "unable to read longname member") + self.assert_(tarinfo.name == member.name and \ + tarinfo.linkname == member.linkname, \ + "unable to read longname member") + def test_longname_1023(self): self._test(("longnam/" * 127) + "longnam") @@ -623,6 +653,7 @@ ReadAsteriskTest, ReadStreamAsteriskTest, WriteTest, + Write100Test, WriteSize0Test, WriteStreamTest, WriteGNULongTest, Modified: python/branches/p3yk-noslice/Lib/test/test_tempfile.py ============================================================================== --- python/branches/p3yk-noslice/Lib/test/test_tempfile.py (original) +++ python/branches/p3yk-noslice/Lib/test/test_tempfile.py Fri Dec 15 05:21:50 2006 @@ -27,7 +27,7 @@ # number of files that can be opened at one time (see ulimit -n) if sys.platform == 'mac': TEST_FILES = 32 -elif sys.platform == 'openbsd3': +elif sys.platform in ('openbsd3', 'openbsd4'): TEST_FILES = 48 else: TEST_FILES = 100 Modified: python/branches/p3yk-noslice/Lib/test/test_time.py ============================================================================== --- python/branches/p3yk-noslice/Lib/test/test_time.py (original) +++ python/branches/p3yk-noslice/Lib/test/test_time.py Fri Dec 15 05:21:50 2006 @@ -102,15 +102,19 @@ self.assertEquals(expected, result) def test_strptime(self): + # Should be able to go round-trip from strftime to strptime without + # throwing an exception. tt = time.gmtime(self.t) for directive in ('a', 'A', 'b', 'B', 'c', 'd', 'H', 'I', 'j', 'm', 'M', 'p', 'S', 'U', 'w', 'W', 'x', 'X', 'y', 'Y', 'Z', '%'): - format = ' %' + directive + format = '%' + directive + strf_output = time.strftime(format, tt) try: - time.strptime(time.strftime(format, tt), format) + time.strptime(strf_output, format) except ValueError: - self.fail('conversion specifier: %r failed.' % format) + self.fail("conversion specifier %r failed with '%s' input." % + (format, strf_output)) def test_asctime(self): time.asctime(time.gmtime(self.t)) Modified: python/branches/p3yk-noslice/Lib/test/test_tokenize.py ============================================================================== --- python/branches/p3yk-noslice/Lib/test/test_tokenize.py (original) +++ python/branches/p3yk-noslice/Lib/test/test_tokenize.py Fri Dec 15 05:21:50 2006 @@ -1,9 +1,93 @@ -import os, glob, random +"""Tests for the tokenize module. + +The tests were originally written in the old Python style, where the +test output was compared to a golden file. This docstring represents +the first steps towards rewriting the entire test as a doctest. + +The tests can be really simple. Given a small fragment of source +code, print out a table with the tokens. The ENDMARK is omitted for +brevity. + +>>> dump_tokens("1 + 1") +NUMBER '1' (1, 0) (1, 1) +OP '+' (1, 2) (1, 3) +NUMBER '1' (1, 4) (1, 5) + +A comment generates a token here, unlike in the parser module. The +comment token is followed by an NL or a NEWLINE token, depending on +whether the line contains the completion of a statement. + +>>> dump_tokens("if False:\\n" +... " # NL\\n" +... " True = False # NEWLINE\\n") +NAME 'if' (1, 0) (1, 2) +NAME 'False' (1, 3) (1, 8) +OP ':' (1, 8) (1, 9) +NEWLINE '\\n' (1, 9) (1, 10) +COMMENT '# NL' (2, 4) (2, 8) +NL '\\n' (2, 8) (2, 9) +INDENT ' ' (3, 0) (3, 4) +NAME 'True' (3, 4) (3, 8) +OP '=' (3, 9) (3, 10) +NAME 'False' (3, 11) (3, 16) +COMMENT '# NEWLINE' (3, 17) (3, 26) +NEWLINE '\\n' (3, 26) (3, 27) +DEDENT '' (4, 0) (4, 0) + + +There will be a bunch more tests of specific source patterns. + +The tokenize module also defines an untokenize function that should +regenerate the original program text from the tokens. + +There are some standard formatting practices that are easy to get right. + +>>> roundtrip("if x == 1:\\n" +... " print x\\n") +if x == 1: + print x + +Some people use different formatting conventions, which makes +untokenize a little trickier. Note that this test involves trailing +whitespace after the colon. Note that we use hex escapes to make the +two trailing blanks apparent in the expected output. + +>>> roundtrip("if x == 1 : \\n" +... " print x\\n") +if x == 1 :\x20\x20 + print x + +Comments need to go in the right place. + +>>> roundtrip("if x == 1:\\n" +... " # A comment by itself.\\n" +... " print x # Comment here, too.\\n" +... " # Another comment.\\n" +... "after_if = True\\n") +if x == 1: + # A comment by itself. + print x # Comment here, too. + # Another comment. +after_if = True + +>>> roundtrip("if (x # The comments need to go in the right place\\n" +... " == 1):\\n" +... " print 'x == 1'\\n") +if (x # The comments need to go in the right place + == 1): + print 'x == 1' + +""" + +import os, glob, random, time, sys from cStringIO import StringIO from test.test_support import (verbose, findfile, is_resource_enabled, TestFailed) -from tokenize import (tokenize, generate_tokens, untokenize, - NUMBER, NAME, OP, STRING) +from tokenize import (tokenize, generate_tokens, untokenize, tok_name, + ENDMARKER, NUMBER, NAME, OP, STRING, COMMENT) + +# How much time in seconds can pass before we print a 'Still working' message. +_PRINT_WORKING_MSG_INTERVAL = 5 * 60 # Test roundtrip for `untokenize`. `f` is a file path. The source code in f # is tokenized, converted back to source code via tokenize.untokenize(), @@ -24,6 +108,23 @@ if t1 != t2: raise TestFailed("untokenize() roundtrip failed for %r" % f) +def dump_tokens(s): + """Print out the tokens in s in a table format. + + The ENDMARKER is omitted. + """ + f = StringIO(s) + for type, token, start, end, line in generate_tokens(f.readline): + if type == ENDMARKER: + break + type = tok_name[type] + print "%(type)-10.10s %(token)-13.13r %(start)s %(end)s" % locals() + +def roundtrip(s): + f = StringIO(s) + source = untokenize(generate_tokens(f.readline)) + print source, + # This is an example from the docs, set up as a doctest. def decistmt(s): """Substitute Decimals for floats in a string of statements. @@ -66,6 +167,8 @@ if verbose: print 'starting...' + next_time = time.time() + _PRINT_WORKING_MSG_INTERVAL + # This displays the tokenization of tokenize_tests.py to stdout, and # regrtest.py checks that this equals the expected output (in the # test/output/ directory). @@ -85,6 +188,12 @@ testfiles = random.sample(testfiles, 10) for f in testfiles: + # Print still working message since this test can be really slow + if next_time <= time.time(): + next_time = time.time() + _PRINT_WORKING_MSG_INTERVAL + print >>sys.__stdout__, ' test_main still working, be patient...' + sys.__stdout__.flush() + test_roundtrip(f) # Test detecton of IndentationError. @@ -105,7 +214,7 @@ # Run the doctests in this module. from test import test_tokenize # i.e., this module from test.test_support import run_doctest - run_doctest(test_tokenize) + run_doctest(test_tokenize, verbose) if verbose: print 'finished' Modified: python/branches/p3yk-noslice/Lib/test/test_traceback.py ============================================================================== --- python/branches/p3yk-noslice/Lib/test/test_traceback.py (original) +++ python/branches/p3yk-noslice/Lib/test/test_traceback.py Fri Dec 15 05:21:50 2006 @@ -118,7 +118,13 @@ err = traceback.format_exception_only(X, X()) self.assertEqual(len(err), 1) str_value = '' % X.__name__ - self.assertEqual(err[0], X.__name__ + ': ' + str_value + '\n') + self.assertEqual(err[0], "%s.%s: %s\n" % (X.__module__, + X.__name__, + str_value)) + + def test_without_exception(self): + err = traceback.format_exception_only(None, None) + self.assertEqual(err, ['None\n']) def test_main(): Modified: python/branches/p3yk-noslice/Lib/test/test_transformer.py ============================================================================== --- python/branches/p3yk-noslice/Lib/test/test_transformer.py (original) +++ python/branches/p3yk-noslice/Lib/test/test_transformer.py Fri Dec 15 05:21:50 2006 @@ -24,7 +24,7 @@ # is correct c = compile(s, '', 'single') vals = {} - exec c in vals + exec(c, vals) assert vals['a'] == 1 assert vals['b'] == 2 Modified: python/branches/p3yk-noslice/Lib/test/test_tuple.py ============================================================================== --- python/branches/p3yk-noslice/Lib/test/test_tuple.py (original) +++ python/branches/p3yk-noslice/Lib/test/test_tuple.py Fri Dec 15 05:21:50 2006 @@ -61,7 +61,7 @@ base = range(N) xp = [(i, j) for i in base for j in base] inps = base + [(i, j) for i in base for j in xp] + \ - [(i, j) for i in xp for j in base] + xp + zip(base) + [(i, j) for i in xp for j in base] + xp + list(zip(base)) collisions = len(inps) - len(set(map(hash, inps))) self.assert_(collisions <= 15) Modified: python/branches/p3yk-noslice/Lib/test/test_types.py ============================================================================== --- python/branches/p3yk-noslice/Lib/test/test_types.py (original) +++ python/branches/p3yk-noslice/Lib/test/test_types.py Fri Dec 15 05:21:50 2006 @@ -1,286 +1,271 @@ # Python test set -- part 6, built-in types -from test.test_support import * +from test.test_support import run_unittest, have_unicode +import unittest +import sys -print '6. Built-in types' +class TypesTests(unittest.TestCase): -print '6.1 Truth value testing' -if None: raise TestFailed, 'None is true instead of false' -if 0: raise TestFailed, '0 is true instead of false' -if 0L: raise TestFailed, '0L is true instead of false' -if 0.0: raise TestFailed, '0.0 is true instead of false' -if '': raise TestFailed, '\'\' is true instead of false' -if not 1: raise TestFailed, '1 is false instead of true' -if not 1L: raise TestFailed, '1L is false instead of true' -if not 1.0: raise TestFailed, '1.0 is false instead of true' -if not 'x': raise TestFailed, '\'x\' is false instead of true' -if not {'x': 1}: raise TestFailed, '{\'x\': 1} is false instead of true' -def f(): pass -class C: pass -import sys -x = C() -if not f: raise TestFailed, 'f is false instead of true' -if not C: raise TestFailed, 'C is false instead of true' -if not sys: raise TestFailed, 'sys is false instead of true' -if not x: raise TestFailed, 'x is false instead of true' - -print '6.2 Boolean operations' -if 0 or 0: raise TestFailed, '0 or 0 is true instead of false' -if 1 and 1: pass -else: raise TestFailed, '1 and 1 is false instead of true' -if not 1: raise TestFailed, 'not 1 is true instead of false' - -print '6.3 Comparisons' -if 0 < 1 <= 1 == 1 >= 1 > 0 != 1: pass -else: raise TestFailed, 'int comparisons failed' -if 0L < 1L <= 1L == 1L >= 1L > 0L != 1L: pass -else: raise TestFailed, 'long int comparisons failed' -if 0.0 < 1.0 <= 1.0 == 1.0 >= 1.0 > 0.0 != 1.0: pass -else: raise TestFailed, 'float comparisons failed' -if '' < 'a' <= 'a' == 'a' < 'abc' < 'abd' < 'b': pass -else: raise TestFailed, 'string comparisons failed' -if None is None: pass -else: raise TestFailed, 'identity test failed' - -try: float('') -except ValueError: pass -else: raise TestFailed, "float('') didn't raise ValueError" - -try: float('5\0') -except ValueError: pass -else: raise TestFailed, "float('5\0') didn't raise ValueError" - -try: 5.0 / 0.0 -except ZeroDivisionError: pass -else: raise TestFailed, "5.0 / 0.0 didn't raise ZeroDivisionError" - -try: 5.0 // 0.0 -except ZeroDivisionError: pass -else: raise TestFailed, "5.0 // 0.0 didn't raise ZeroDivisionError" - -try: 5.0 % 0.0 -except ZeroDivisionError: pass -else: raise TestFailed, "5.0 % 0.0 didn't raise ZeroDivisionError" - -try: 5 / 0L -except ZeroDivisionError: pass -else: raise TestFailed, "5 / 0L didn't raise ZeroDivisionError" - -try: 5 // 0L -except ZeroDivisionError: pass -else: raise TestFailed, "5 // 0L didn't raise ZeroDivisionError" - -try: 5 % 0L -except ZeroDivisionError: pass -else: raise TestFailed, "5 % 0L didn't raise ZeroDivisionError" - -print '6.4 Numeric types (mostly conversions)' -if 0 != 0L or 0 != 0.0 or 0L != 0.0: raise TestFailed, 'mixed comparisons' -if 1 != 1L or 1 != 1.0 or 1L != 1.0: raise TestFailed, 'mixed comparisons' -if -1 != -1L or -1 != -1.0 or -1L != -1.0: - raise TestFailed, 'int/long/float value not equal' -# calling built-in types without argument must return 0 -if int() != 0: raise TestFailed, 'int() does not return 0' -if long() != 0L: raise TestFailed, 'long() does not return 0L' -if float() != 0.0: raise TestFailed, 'float() does not return 0.0' -if int(1.9) == 1 == int(1.1) and int(-1.1) == -1 == int(-1.9): pass -else: raise TestFailed, 'int() does not round properly' -if long(1.9) == 1L == long(1.1) and long(-1.1) == -1L == long(-1.9): pass -else: raise TestFailed, 'long() does not round properly' -if float(1) == 1.0 and float(-1) == -1.0 and float(0) == 0.0: pass -else: raise TestFailed, 'float() does not work properly' -print '6.4.1 32-bit integers' -# Ensure the first 256 integers are shared -a = 256 -b = 128*2 -if a is not b: raise TestFailed, '256 is not shared' -if 12 + 24 != 36: raise TestFailed, 'int op' -if 12 + (-24) != -12: raise TestFailed, 'int op' -if (-12) + 24 != 12: raise TestFailed, 'int op' -if (-12) + (-24) != -36: raise TestFailed, 'int op' -if not 12 < 24: raise TestFailed, 'int op' -if not -24 < -12: raise TestFailed, 'int op' -# Test for a particular bug in integer multiply -xsize, ysize, zsize = 238, 356, 4 -if not (xsize*ysize*zsize == zsize*xsize*ysize == 338912): - raise TestFailed, 'int mul commutativity' -# And another. -m = -sys.maxint - 1 -for divisor in 1, 2, 4, 8, 16, 32: - j = m // divisor - prod = divisor * j - if prod != m: - raise TestFailed, "%r * %r == %r != %r" % (divisor, j, prod, m) - if type(prod) is not int: - raise TestFailed, ("expected type(prod) to be int, not %r" % - type(prod)) -# Check for expected * overflow to long. -for divisor in 1, 2, 4, 8, 16, 32: - j = m // divisor - 1 - prod = divisor * j - if type(prod) is not long: - raise TestFailed, ("expected type(%r) to be long, not %r" % - (prod, type(prod))) -# Check for expected * overflow to long. -m = sys.maxint -for divisor in 1, 2, 4, 8, 16, 32: - j = m // divisor + 1 - prod = divisor * j - if type(prod) is not long: - raise TestFailed, ("expected type(%r) to be long, not %r" % - (prod, type(prod))) - -print '6.4.2 Long integers' -if 12L + 24L != 36L: raise TestFailed, 'long op' -if 12L + (-24L) != -12L: raise TestFailed, 'long op' -if (-12L) + 24L != 12L: raise TestFailed, 'long op' -if (-12L) + (-24L) != -36L: raise TestFailed, 'long op' -if not 12L < 24L: raise TestFailed, 'long op' -if not -24L < -12L: raise TestFailed, 'long op' -x = sys.maxint -if int(long(x)) != x: raise TestFailed, 'long op' -try: y = int(long(x)+1L) -except OverflowError: raise TestFailed, 'long op' -if not isinstance(y, long): raise TestFailed, 'long op' -x = -x -if int(long(x)) != x: raise TestFailed, 'long op' -x = x-1 -if int(long(x)) != x: raise TestFailed, 'long op' -try: y = int(long(x)-1L) -except OverflowError: raise TestFailed, 'long op' -if not isinstance(y, long): raise TestFailed, 'long op' - -try: 5 << -5 -except ValueError: pass -else: raise TestFailed, 'int negative shift <<' - -try: 5L << -5L -except ValueError: pass -else: raise TestFailed, 'long negative shift <<' - -try: 5 >> -5 -except ValueError: pass -else: raise TestFailed, 'int negative shift >>' - -try: 5L >> -5L -except ValueError: pass -else: raise TestFailed, 'long negative shift >>' - -print '6.4.3 Floating point numbers' -if 12.0 + 24.0 != 36.0: raise TestFailed, 'float op' -if 12.0 + (-24.0) != -12.0: raise TestFailed, 'float op' -if (-12.0) + 24.0 != 12.0: raise TestFailed, 'float op' -if (-12.0) + (-24.0) != -36.0: raise TestFailed, 'float op' -if not 12.0 < 24.0: raise TestFailed, 'float op' -if not -24.0 < -12.0: raise TestFailed, 'float op' - -print '6.5 Sequence types' - -print '6.5.1 Strings' -if len('') != 0: raise TestFailed, 'len(\'\')' -if len('a') != 1: raise TestFailed, 'len(\'a\')' -if len('abcdef') != 6: raise TestFailed, 'len(\'abcdef\')' -if 'xyz' + 'abcde' != 'xyzabcde': raise TestFailed, 'string concatenation' -if 'xyz'*3 != 'xyzxyzxyz': raise TestFailed, 'string repetition *3' -if 0*'abcde' != '': raise TestFailed, 'string repetition 0*' -if min('abc') != 'a' or max('abc') != 'c': raise TestFailed, 'min/max string' -if 'a' in 'abc' and 'b' in 'abc' and 'c' in 'abc' and 'd' not in 'abc': pass -else: raise TestFailed, 'in/not in string' -x = 'x'*103 -if '%s!'%x != x+'!': raise TestFailed, 'nasty string formatting bug' - -#extended slices for strings -a = '0123456789' -vereq(a[::], a) -vereq(a[::2], '02468') -vereq(a[1::2], '13579') -vereq(a[::-1],'9876543210') -vereq(a[::-2], '97531') -vereq(a[3::-2], '31') -vereq(a[-100:100:], a) -vereq(a[100:-100:-1], a[::-1]) -vereq(a[-100L:100L:2L], '02468') - -if have_unicode: - a = unicode('0123456789', 'ascii') - vereq(a[::], a) - vereq(a[::2], unicode('02468', 'ascii')) - vereq(a[1::2], unicode('13579', 'ascii')) - vereq(a[::-1], unicode('9876543210', 'ascii')) - vereq(a[::-2], unicode('97531', 'ascii')) - vereq(a[3::-2], unicode('31', 'ascii')) - vereq(a[-100:100:], a) - vereq(a[100:-100:-1], a[::-1]) - vereq(a[-100L:100L:2L], unicode('02468', 'ascii')) - - -print '6.5.2 Tuples [see test_tuple.py]' - -print '6.5.3 Lists [see test_list.py]' - -print '6.6 Mappings == Dictionaries [see test_dict.py]' - - -try: type(1, 2) -except TypeError: pass -else: raise TestFailed, 'type(), w/2 args expected TypeError' - -try: type(1, 2, 3, 4) -except TypeError: pass -else: raise TestFailed, 'type(), w/4 args expected TypeError' - -print 'Buffers' -try: buffer('asdf', -1) -except ValueError: pass -else: raise TestFailed, "buffer('asdf', -1) should raise ValueError" -cmp(buffer("abc"), buffer("def")) # used to raise a warning: tp_compare didn't return -1, 0, or 1 - -try: buffer(None) -except TypeError: pass -else: raise TestFailed, "buffer(None) should raise TypeError" - -a = buffer('asdf') -hash(a) -b = a * 5 -if a == b: - raise TestFailed, 'buffers should not be equal' -if str(b) != ('asdf' * 5): - raise TestFailed, 'repeated buffer has wrong content' -if str(a * 0) != '': - raise TestFailed, 'repeated buffer zero times has wrong content' -if str(a + buffer('def')) != 'asdfdef': - raise TestFailed, 'concatenation of buffers yields wrong content' -if str(buffer(a)) != 'asdf': - raise TestFailed, 'composing buffers failed' -if str(buffer(a, 2)) != 'df': - raise TestFailed, 'specifying buffer offset failed' -if str(buffer(a, 0, 2)) != 'as': - raise TestFailed, 'specifying buffer size failed' -if str(buffer(a, 1, 2)) != 'sd': - raise TestFailed, 'specifying buffer offset and size failed' -try: buffer(buffer('asdf', 1), -1) -except ValueError: pass -else: raise TestFailed, "buffer(buffer('asdf', 1), -1) should raise ValueError" -if str(buffer(buffer('asdf', 0, 2), 0)) != 'as': - raise TestFailed, 'composing length-specified buffer failed' -if str(buffer(buffer('asdf', 0, 2), 0, 5000)) != 'as': - raise TestFailed, 'composing length-specified buffer failed' -if str(buffer(buffer('asdf', 0, 2), 0, -1)) != 'as': - raise TestFailed, 'composing length-specified buffer failed' -if str(buffer(buffer('asdf', 0, 2), 1, 2)) != 's': - raise TestFailed, 'composing length-specified buffer failed' - -try: a[1] = 'g' -except TypeError: pass -else: raise TestFailed, "buffer assignment should raise TypeError" - -try: a[0:1] = 'g' -except TypeError: pass -else: raise TestFailed, "buffer slice assignment should raise TypeError" - -# array.array() returns an object that does not implement a char buffer, -# something which int() uses for conversion. -import array -try: int(buffer(array.array('c'))) -except TypeError :pass -else: raise TestFailed, "char buffer (at C level) not working" + def test_truth_values(self): + if None: self.fail('None is true instead of false') + if 0: self.fail('0 is true instead of false') + if 0L: self.fail('0L is true instead of false') + if 0.0: self.fail('0.0 is true instead of false') + if '': self.fail('\'\' is true instead of false') + if not 1: self.fail('1 is false instead of true') + if not 1L: self.fail('1L is false instead of true') + if not 1.0: self.fail('1.0 is false instead of true') + if not 'x': self.fail('\'x\' is false instead of true') + if not {'x': 1}: self.fail('{\'x\': 1} is false instead of true') + def f(): pass + class C: pass + import sys + x = C() + if not f: self.fail('f is false instead of true') + if not C: self.fail('C is false instead of true') + if not sys: self.fail('sys is false instead of true') + if not x: self.fail('x is false instead of true') + + def test_boolean_ops(self): + if 0 or 0: self.fail('0 or 0 is true instead of false') + if 1 and 1: pass + else: self.fail('1 and 1 is false instead of true') + if not 1: self.fail('not 1 is true instead of false') + + def test_comparisons(self): + if 0 < 1 <= 1 == 1 >= 1 > 0 != 1: pass + else: self.fail('int comparisons failed') + if 0L < 1L <= 1L == 1L >= 1L > 0L != 1L: pass + else: self.fail('long int comparisons failed') + if 0.0 < 1.0 <= 1.0 == 1.0 >= 1.0 > 0.0 != 1.0: pass + else: self.fail('float comparisons failed') + if '' < 'a' <= 'a' == 'a' < 'abc' < 'abd' < 'b': pass + else: self.fail('string comparisons failed') + if None is None: pass + else: self.fail('identity test failed') + + def test_float_constructor(self): + self.assertRaises(ValueError, float, '') + self.assertRaises(ValueError, float, '5\0') + + def test_zero_division(self): + try: 5.0 / 0.0 + except ZeroDivisionError: pass + else: self.fail("5.0 / 0.0 didn't raise ZeroDivisionError") + + try: 5.0 // 0.0 + except ZeroDivisionError: pass + else: self.fail("5.0 // 0.0 didn't raise ZeroDivisionError") + + try: 5.0 % 0.0 + except ZeroDivisionError: pass + else: self.fail("5.0 % 0.0 didn't raise ZeroDivisionError") + + try: 5 / 0L + except ZeroDivisionError: pass + else: self.fail("5 / 0L didn't raise ZeroDivisionError") + + try: 5 // 0L + except ZeroDivisionError: pass + else: self.fail("5 // 0L didn't raise ZeroDivisionError") + + try: 5 % 0L + except ZeroDivisionError: pass + else: self.fail("5 % 0L didn't raise ZeroDivisionError") + + def test_numeric_types(self): + if 0 != 0L or 0 != 0.0 or 0L != 0.0: self.fail('mixed comparisons') + if 1 != 1L or 1 != 1.0 or 1L != 1.0: self.fail('mixed comparisons') + if -1 != -1L or -1 != -1.0 or -1L != -1.0: + self.fail('int/long/float value not equal') + # calling built-in types without argument must return 0 + if int() != 0: self.fail('int() does not return 0') + if long() != 0L: self.fail('long() does not return 0L') + if float() != 0.0: self.fail('float() does not return 0.0') + if int(1.9) == 1 == int(1.1) and int(-1.1) == -1 == int(-1.9): pass + else: self.fail('int() does not round properly') + if long(1.9) == 1L == long(1.1) and long(-1.1) == -1L == long(-1.9): pass + else: self.fail('long() does not round properly') + if float(1) == 1.0 and float(-1) == -1.0 and float(0) == 0.0: pass + else: self.fail('float() does not work properly') + + def test_normal_integers(self): + # Ensure the first 256 integers are shared + a = 256 + b = 128*2 + if a is not b: self.fail('256 is not shared') + if 12 + 24 != 36: self.fail('int op') + if 12 + (-24) != -12: self.fail('int op') + if (-12) + 24 != 12: self.fail('int op') + if (-12) + (-24) != -36: self.fail('int op') + if not 12 < 24: self.fail('int op') + if not -24 < -12: self.fail('int op') + # Test for a particular bug in integer multiply + xsize, ysize, zsize = 238, 356, 4 + if not (xsize*ysize*zsize == zsize*xsize*ysize == 338912): + self.fail('int mul commutativity') + # And another. + m = -sys.maxint - 1 + for divisor in 1, 2, 4, 8, 16, 32: + j = m // divisor + prod = divisor * j + if prod != m: + self.fail("%r * %r == %r != %r" % (divisor, j, prod, m)) + if type(prod) is not int: + self.fail("expected type(prod) to be int, not %r" % + type(prod)) + # Check for expected * overflow to long. + for divisor in 1, 2, 4, 8, 16, 32: + j = m // divisor - 1 + prod = divisor * j + if type(prod) is not long: + self.fail("expected type(%r) to be long, not %r" % + (prod, type(prod))) + # Check for expected * overflow to long. + m = sys.maxint + for divisor in 1, 2, 4, 8, 16, 32: + j = m // divisor + 1 + prod = divisor * j + if type(prod) is not long: + self.fail("expected type(%r) to be long, not %r" % + (prod, type(prod))) + + def test_long_integers(self): + if 12L + 24L != 36L: self.fail('long op') + if 12L + (-24L) != -12L: self.fail('long op') + if (-12L) + 24L != 12L: self.fail('long op') + if (-12L) + (-24L) != -36L: self.fail('long op') + if not 12L < 24L: self.fail('long op') + if not -24L < -12L: self.fail('long op') + x = sys.maxint + if int(long(x)) != x: self.fail('long op') + try: y = int(long(x)+1L) + except OverflowError: self.fail('long op') + if not isinstance(y, long): self.fail('long op') + x = -x + if int(long(x)) != x: self.fail('long op') + x = x-1 + if int(long(x)) != x: self.fail('long op') + try: y = int(long(x)-1L) + except OverflowError: self.fail('long op') + if not isinstance(y, long): self.fail('long op') + + try: 5 << -5 + except ValueError: pass + else: self.fail('int negative shift <<') + + try: 5L << -5L + except ValueError: pass + else: self.fail('long negative shift <<') + + try: 5 >> -5 + except ValueError: pass + else: self.fail('int negative shift >>') + + try: 5L >> -5L + except ValueError: pass + else: self.fail('long negative shift >>') + + def test_floats(self): + if 12.0 + 24.0 != 36.0: self.fail('float op') + if 12.0 + (-24.0) != -12.0: self.fail('float op') + if (-12.0) + 24.0 != 12.0: self.fail('float op') + if (-12.0) + (-24.0) != -36.0: self.fail('float op') + if not 12.0 < 24.0: self.fail('float op') + if not -24.0 < -12.0: self.fail('float op') + + def test_strings(self): + if len('') != 0: self.fail('len(\'\')') + if len('a') != 1: self.fail('len(\'a\')') + if len('abcdef') != 6: self.fail('len(\'abcdef\')') + if 'xyz' + 'abcde' != 'xyzabcde': self.fail('string concatenation') + if 'xyz'*3 != 'xyzxyzxyz': self.fail('string repetition *3') + if 0*'abcde' != '': self.fail('string repetition 0*') + if min('abc') != 'a' or max('abc') != 'c': self.fail('min/max string') + if 'a' in 'abc' and 'b' in 'abc' and 'c' in 'abc' and 'd' not in 'abc': pass + else: self.fail('in/not in string') + x = 'x'*103 + if '%s!'%x != x+'!': self.fail('nasty string formatting bug') + + #extended slices for strings + a = '0123456789' + self.assertEqual(a[::], a) + self.assertEqual(a[::2], '02468') + self.assertEqual(a[1::2], '13579') + self.assertEqual(a[::-1],'9876543210') + self.assertEqual(a[::-2], '97531') + self.assertEqual(a[3::-2], '31') + self.assertEqual(a[-100:100:], a) + self.assertEqual(a[100:-100:-1], a[::-1]) + self.assertEqual(a[-100L:100L:2L], '02468') + + if have_unicode: + a = unicode('0123456789', 'ascii') + self.assertEqual(a[::], a) + self.assertEqual(a[::2], unicode('02468', 'ascii')) + self.assertEqual(a[1::2], unicode('13579', 'ascii')) + self.assertEqual(a[::-1], unicode('9876543210', 'ascii')) + self.assertEqual(a[::-2], unicode('97531', 'ascii')) + self.assertEqual(a[3::-2], unicode('31', 'ascii')) + self.assertEqual(a[-100:100:], a) + self.assertEqual(a[100:-100:-1], a[::-1]) + self.assertEqual(a[-100L:100L:2L], unicode('02468', 'ascii')) + + + def test_type_function(self): + self.assertRaises(TypeError, type, 1, 2) + self.assertRaises(TypeError, type, 1, 2, 3, 4) + + def test_buffers(self): + self.assertRaises(ValueError, buffer, 'asdf', -1) + self.assertRaises(TypeError, buffer, None) + + a = buffer('asdf') + hash(a) + b = a * 5 + if a == b: + self.fail('buffers should not be equal') + if str(b) != ('asdf' * 5): + self.fail('repeated buffer has wrong content') + if str(a * 0) != '': + self.fail('repeated buffer zero times has wrong content') + if str(a + buffer('def')) != 'asdfdef': + self.fail('concatenation of buffers yields wrong content') + if str(buffer(a)) != 'asdf': + self.fail('composing buffers failed') + if str(buffer(a, 2)) != 'df': + self.fail('specifying buffer offset failed') + if str(buffer(a, 0, 2)) != 'as': + self.fail('specifying buffer size failed') + if str(buffer(a, 1, 2)) != 'sd': + self.fail('specifying buffer offset and size failed') + self.assertRaises(ValueError, buffer, buffer('asdf', 1), -1) + if str(buffer(buffer('asdf', 0, 2), 0)) != 'as': + self.fail('composing length-specified buffer failed') + if str(buffer(buffer('asdf', 0, 2), 0, 5000)) != 'as': + self.fail('composing length-specified buffer failed') + if str(buffer(buffer('asdf', 0, 2), 0, -1)) != 'as': + self.fail('composing length-specified buffer failed') + if str(buffer(buffer('asdf', 0, 2), 1, 2)) != 's': + self.fail('composing length-specified buffer failed') + + try: a[1] = 'g' + except TypeError: pass + else: self.fail("buffer assignment should raise TypeError") + + try: a[0:1] = 'g' + except TypeError: pass + else: self.fail("buffer slice assignment should raise TypeError") + + # array.array() returns an object that does not implement a char buffer, + # something which int() uses for conversion. + import array + try: int(buffer(array.array('c'))) + except TypeError: pass + else: self.fail("char buffer (at C level) not working") + +def test_main(): + run_unittest(TypesTests) + +if __name__ == '__main__': + test_main() Modified: python/branches/p3yk-noslice/Lib/test/test_unicode.py ============================================================================== --- python/branches/p3yk-noslice/Lib/test/test_unicode.py (original) +++ python/branches/p3yk-noslice/Lib/test/test_unicode.py Fri Dec 15 05:21:50 2006 @@ -92,6 +92,9 @@ "\\xfe\\xff'") testrepr = repr(u''.join(map(unichr, xrange(256)))) self.assertEqual(testrepr, latin1repr) + # Test repr works on wide unicode escapes without overflow. + self.assertEqual(repr(u"\U00010000" * 39 + u"\uffff" * 4096), + repr(u"\U00010000" * 39 + u"\uffff" * 4096)) def test_iterators(self): # Make sure unicode objects have an __iter__ method Modified: python/branches/p3yk-noslice/Lib/test/test_unicode_file.py ============================================================================== --- python/branches/p3yk-noslice/Lib/test/test_unicode_file.py (original) +++ python/branches/p3yk-noslice/Lib/test/test_unicode_file.py Fri Dec 15 05:21:50 2006 @@ -152,7 +152,7 @@ # top-level 'test' functions would be if they could take params def _test_single(self, filename): remove_if_exists(filename) - f = file(filename, "w") + f = open(filename, "w") f.close() try: self._do_single(filename) @@ -170,7 +170,7 @@ def _test_equivalent(self, filename1, filename2): remove_if_exists(filename1) self.failUnless(not os.path.exists(filename2)) - f = file(filename1, "w") + f = open(filename1, "w") f.close() try: self._do_equivilent(filename1, filename2) Modified: python/branches/p3yk-noslice/Lib/test/test_unpack.py ============================================================================== --- python/branches/p3yk-noslice/Lib/test/test_unpack.py (original) +++ python/branches/p3yk-noslice/Lib/test/test_unpack.py Fri Dec 15 05:21:50 2006 @@ -107,7 +107,7 @@ >>> a, b, c, d, e = BadSeq() Traceback (most recent call last): ... - BozoError + test.test_unpack.BozoError Trigger code while expecting an IndexError (unpack sequence too short, wrong error) @@ -115,7 +115,7 @@ >>> a, b, c = BadSeq() Traceback (most recent call last): ... - BozoError + test.test_unpack.BozoError """ Modified: python/branches/p3yk-noslice/Lib/test/test_urllib.py ============================================================================== --- python/branches/p3yk-noslice/Lib/test/test_urllib.py (original) +++ python/branches/p3yk-noslice/Lib/test/test_urllib.py Fri Dec 15 05:21:50 2006 @@ -27,7 +27,7 @@ def setUp(self): """Setup of a temp file to use for testing""" self.text = "test_urllib: %s\n" % self.__class__.__name__ - FILE = file(test_support.TESTFN, 'wb') + FILE = open(test_support.TESTFN, 'wb') try: FILE.write(self.text) finally: @@ -139,7 +139,7 @@ self.registerFileForCleanUp(test_support.TESTFN) self.text = 'testing urllib.urlretrieve' try: - FILE = file(test_support.TESTFN, 'wb') + FILE = open(test_support.TESTFN, 'wb') FILE.write(self.text) FILE.close() finally: @@ -192,7 +192,7 @@ self.assertEqual(second_temp, result[0]) self.assert_(os.path.exists(second_temp), "copy of the file was not " "made") - FILE = file(second_temp, 'rb') + FILE = open(second_temp, 'rb') try: text = FILE.read() FILE.close() Modified: python/branches/p3yk-noslice/Lib/test/test_urllibnet.py ============================================================================== --- python/branches/p3yk-noslice/Lib/test/test_urllibnet.py (original) +++ python/branches/p3yk-noslice/Lib/test/test_urllibnet.py Fri Dec 15 05:21:50 2006 @@ -120,7 +120,7 @@ file_location,info = urllib.urlretrieve("http://www.python.org/") self.assert_(os.path.exists(file_location), "file location returned by" " urlretrieve is not a valid path") - FILE = file(file_location) + FILE = open(file_location) try: self.assert_(FILE.read(), "reading from the file location returned" " by urlretrieve failed") @@ -134,7 +134,7 @@ test_support.TESTFN) self.assertEqual(file_location, test_support.TESTFN) self.assert_(os.path.exists(file_location)) - FILE = file(file_location) + FILE = open(file_location) try: self.assert_(FILE.read(), "reading from temporary file failed") finally: Modified: python/branches/p3yk-noslice/Lib/test/test_userdict.py ============================================================================== --- python/branches/p3yk-noslice/Lib/test/test_userdict.py (original) +++ python/branches/p3yk-noslice/Lib/test/test_userdict.py Fri Dec 15 05:21:50 2006 @@ -46,13 +46,13 @@ # Test __repr__ self.assertEqual(str(u0), str(d0)) self.assertEqual(repr(u1), repr(d1)) - self.assertEqual(`u2`, `d2`) + self.assertEqual(repr(u2), repr(d2)) # Test __cmp__ and __len__ all = [d0, d1, d2, u, u0, u1, u2, uu, uu0, uu1, uu2] for a in all: for b in all: - self.assertEqual(cmp(a, b), cmp(len(a), len(b))) + self.assertEqual(a == b, len(a) == len(b)) # Test __getitem__ self.assertEqual(u2["one"], 1) Modified: python/branches/p3yk-noslice/Lib/test/test_weakref.py ============================================================================== --- python/branches/p3yk-noslice/Lib/test/test_weakref.py (original) +++ python/branches/p3yk-noslice/Lib/test/test_weakref.py Fri Dec 15 05:21:50 2006 @@ -51,10 +51,10 @@ # Live reference: o = C() wr = weakref.ref(o) - `wr` + repr(wr) # Dead reference: del o - `wr` + repr(wr) def test_basic_callback(self): self.check_basic_callback(C) @@ -701,6 +701,12 @@ self.arg = arg def __repr__(self): return "" % self.arg + def __lt__(self, other): + if isinstance(other, Object): + return self.arg < other.arg + return NotImplemented + def __hash__(self): + return hash(self.arg) class MappingTestCase(TestBase): Modified: python/branches/p3yk-noslice/Lib/test/test_wsgiref.py ============================================================================== --- python/branches/p3yk-noslice/Lib/test/test_wsgiref.py (original) +++ python/branches/p3yk-noslice/Lib/test/test_wsgiref.py Fri Dec 15 05:21:50 2006 @@ -515,7 +515,7 @@ "Content-Length: %d\r\n" "\r\n%s" % (h.error_status,len(h.error_body),h.error_body)) - self.failUnless(h.stderr.getvalue().find("AssertionError")<>-1) + self.failUnless("AssertionError" in h.stderr.getvalue()) def testErrorAfterOutput(self): MSG = "Some output has been sent" @@ -528,7 +528,7 @@ self.assertEqual(h.stdout.getvalue(), "Status: 200 OK\r\n" "\r\n"+MSG) - self.failUnless(h.stderr.getvalue().find("AssertionError")<>-1) + self.failUnless("AssertionError" in h.stderr.getvalue()) def testHeaderFormats(self): Modified: python/branches/p3yk-noslice/Lib/test/test_xdrlib.py ============================================================================== --- python/branches/p3yk-noslice/Lib/test/test_xdrlib.py (original) +++ python/branches/p3yk-noslice/Lib/test/test_xdrlib.py Fri Dec 15 05:21:50 2006 @@ -1,3 +1,56 @@ +from test import test_support +import unittest + import xdrlib -xdrlib._test() +class XDRTest(unittest.TestCase): + + def test_xdr(self): + p = xdrlib.Packer() + + s = 'hello world' + a = ['what', 'is', 'hapnin', 'doctor'] + + p.pack_int(42) + p.pack_uint(9) + p.pack_bool(True) + p.pack_bool(False) + p.pack_uhyper(45L) + p.pack_float(1.9) + p.pack_double(1.9) + p.pack_string(s) + p.pack_list(range(5), p.pack_uint) + p.pack_array(a, p.pack_string) + + # now verify + data = p.get_buffer() + up = xdrlib.Unpacker(data) + + self.assertEqual(up.get_position(), 0) + + self.assertEqual(up.unpack_int(), 42) + self.assertEqual(up.unpack_uint(), 9) + self.assert_(up.unpack_bool() is True) + + # remember position + pos = up.get_position() + self.assert_(up.unpack_bool() is False) + + # rewind and unpack again + up.set_position(pos) + self.assert_(up.unpack_bool() is False) + + self.assertEqual(up.unpack_uhyper(), 45L) + self.assertAlmostEqual(up.unpack_float(), 1.9) + self.assertAlmostEqual(up.unpack_double(), 1.9) + self.assertEqual(up.unpack_string(), s) + self.assertEqual(up.unpack_list(up.unpack_uint), range(5)) + self.assertEqual(up.unpack_array(up.unpack_string), a) + up.done() + self.assertRaises(EOFError, up.unpack_uint) + +def test_main(): + test_support.run_unittest(XDRTest) + +if __name__ == "__main__": + test_main() Modified: python/branches/p3yk-noslice/Lib/test/test_xmlrpc.py ============================================================================== --- python/branches/p3yk-noslice/Lib/test/test_xmlrpc.py (original) +++ python/branches/p3yk-noslice/Lib/test/test_xmlrpc.py Fri Dec 15 05:21:50 2006 @@ -86,6 +86,15 @@ s = xmlrpclib.dumps((new_d,), methodresponse=True) self.assert_(isinstance(s, str)) + def test_newstyle_class(self): + class T(object): + pass + t = T() + t.x = 100 + t.y = "Hello" + ((t2,), dummy) = xmlrpclib.loads(xmlrpclib.dumps((t,))) + self.assertEquals(t2, t.__dict__) + def test_dump_big_long(self): self.assertRaises(OverflowError, xmlrpclib.dumps, (2L**99,)) Modified: python/branches/p3yk-noslice/Lib/test/time_hashlib.py ============================================================================== --- python/branches/p3yk-noslice/Lib/test/time_hashlib.py (original) +++ python/branches/p3yk-noslice/Lib/test/time_hashlib.py Fri Dec 15 05:21:50 2006 @@ -44,22 +44,22 @@ # setup our creatorFunc to test the requested hash # if hName in ('_md5', '_sha'): - exec 'import '+hName - exec 'creatorFunc = '+hName+'.new' + exec('import '+hName) + exec('creatorFunc = '+hName+'.new') print "testing speed of old", hName, "legacy interface" elif hName == '_hashlib' and len(sys.argv) > 3: import _hashlib - exec 'creatorFunc = _hashlib.%s' % sys.argv[2] + exec('creatorFunc = _hashlib.%s' % sys.argv[2]) print "testing speed of _hashlib.%s" % sys.argv[2], getattr(_hashlib, sys.argv[2]) elif hName == '_hashlib' and len(sys.argv) == 3: import _hashlib - exec 'creatorFunc = lambda x=_hashlib.new : x(%r)' % sys.argv[2] + exec('creatorFunc = lambda x=_hashlib.new : x(%r)' % sys.argv[2]) print "testing speed of _hashlib.new(%r)" % sys.argv[2] elif hasattr(hashlib, hName) and callable(getattr(hashlib, hName)): creatorFunc = getattr(hashlib, hName) print "testing speed of hashlib."+hName, getattr(hashlib, hName) else: - exec "creatorFunc = lambda x=hashlib.new : x(%r)" % hName + exec("creatorFunc = lambda x=hashlib.new : x(%r)" % hName) print "testing speed of hashlib.new(%r)" % hName try: Modified: python/branches/p3yk-noslice/Lib/test/tokenize_tests.txt ============================================================================== --- python/branches/p3yk-noslice/Lib/test/tokenize_tests.txt (original) +++ python/branches/p3yk-noslice/Lib/test/tokenize_tests.txt Fri Dec 15 05:21:50 2006 @@ -21,7 +21,7 @@ 5] z = {'a':5, 'b':6} -x = (len(`y`) + 5*x - a[ +x = (len(repr(y)) + 5*x - a[ 3 ] - x + len({ } @@ -36,8 +36,8 @@ x = 0 # Ordinary integers -0xff <> 255 -0377 <> 255 +0xff != 255 +0377 != 255 2147483647 != 017777777777 -2147483647-1 != 020000000000 037777777777 != -1 @@ -146,10 +146,10 @@ def d22(a, b, c=1, d=2): pass def d01v(a=1, *restt, **restd): pass -(x, y) <> ({'a':1}, {'b':2}) +(x, y) != ({'a':1}, {'b':2}) # comparison -if 1 < 1 > 1 == 1 >= 1 <= 1 <> 1 != 1 in 1 not in 1 is 1 is not 1: pass +if 1 < 1 > 1 == 1 >= 1 <= 1 != 1 != 1 in 1 not in 1 is 1 is not 1: pass # binary x = 1 & 1 Modified: python/branches/p3yk-noslice/Lib/timeit.py ============================================================================== --- python/branches/p3yk-noslice/Lib/timeit.py (original) +++ python/branches/p3yk-noslice/Lib/timeit.py Fri Dec 15 05:21:50 2006 @@ -115,7 +115,7 @@ self.src = src # Save for traceback display code = compile(src, dummy_src_name, "exec") ns = {} - exec code in globals(), ns + exec(code, globals(), ns) self.inner = ns["inner"] def print_exc(self, file=None): Modified: python/branches/p3yk-noslice/Lib/token.py ============================================================================== --- python/branches/p3yk-noslice/Lib/token.py (original) +++ python/branches/p3yk-noslice/Lib/token.py Fri Dec 15 05:21:50 2006 @@ -35,7 +35,6 @@ EQUAL = 22 DOT = 23 PERCENT = 24 -BACKQUOTE = 25 LBRACE = 26 RBRACE = 27 EQEQUAL = 28 Modified: python/branches/p3yk-noslice/Lib/tokenize.py ============================================================================== --- python/branches/p3yk-noslice/Lib/tokenize.py (original) +++ python/branches/p3yk-noslice/Lib/tokenize.py Fri Dec 15 05:21:50 2006 @@ -24,7 +24,7 @@ __author__ = 'Ka-Ping Yee ' __credits__ = \ - 'GvR, ESR, Tim Peters, Thomas Wouters, Fred Drake, Skip Montanaro' + 'GvR, ESR, Tim Peters, Thomas Wouters, Fred Drake, Skip Montanaro, Raymond Hettinger' import string, re from token import * @@ -77,13 +77,13 @@ # Because of leftmost-then-longest match semantics, be sure to put the # longest operators first (e.g., if = came before ==, == would get # recognized as two instances of =). -Operator = group(r"\*\*=?", r">>=?", r"<<=?", r"<>", r"!=", +Operator = group(r"\*\*=?", r">>=?", r"<<=?", r"!=", r"//=?", r"[+\-*/%&|^=<>]=?", r"~") Bracket = '[][(){}]' -Special = group(r'\r?\n', r'[:;.,`@]') +Special = group(r'\r?\n', r'[:;.,@]') Funny = group(Operator, Bracket, Special) PlainToken = group(Number, Funny, String, Name) @@ -159,14 +159,73 @@ for token_info in generate_tokens(readline): tokeneater(*token_info) +class Untokenizer: + + def __init__(self): + self.tokens = [] + self.prev_row = 1 + self.prev_col = 0 + + def add_whitespace(self, start): + row, col = start + assert row <= self.prev_row + col_offset = col - self.prev_col + if col_offset: + self.tokens.append(" " * col_offset) + + def untokenize(self, iterable): + for t in iterable: + if len(t) == 2: + self.compat(t, iterable) + break + tok_type, token, start, end, line = t + self.add_whitespace(start) + self.tokens.append(token) + self.prev_row, self.prev_col = end + if tok_type in (NEWLINE, NL): + self.prev_row += 1 + self.prev_col = 0 + return "".join(self.tokens) + + def compat(self, token, iterable): + startline = False + indents = [] + toks_append = self.tokens.append + toknum, tokval = token + if toknum in (NAME, NUMBER): + tokval += ' ' + if toknum in (NEWLINE, NL): + startline = True + for tok in iterable: + toknum, tokval = tok[:2] + + if toknum in (NAME, NUMBER): + tokval += ' ' + + if toknum == INDENT: + indents.append(tokval) + continue + elif toknum == DEDENT: + indents.pop() + continue + elif toknum in (NEWLINE, NL): + startline = True + elif startline and indents: + toks_append(indents[-1]) + startline = False + toks_append(tokval) def untokenize(iterable): """Transform tokens back into Python source code. Each element returned by the iterable must be a token sequence - with at least two elements, a token number and token value. + with at least two elements, a token number and token value. If + only two tokens are passed, the resulting output is poor. + + Round-trip invariant for full input: + Untokenized source will match input source exactly - Round-trip invariant: + Round-trip invariant for limited intput: # Output text will tokenize the back to the input t1 = [tok[:2] for tok in generate_tokens(f.readline)] newcode = untokenize(t1) @@ -174,31 +233,8 @@ t2 = [tok[:2] for tokin generate_tokens(readline)] assert t1 == t2 """ - - startline = False - indents = [] - toks = [] - toks_append = toks.append - for tok in iterable: - toknum, tokval = tok[:2] - - if toknum in (NAME, NUMBER): - tokval += ' ' - - if toknum == INDENT: - indents.append(tokval) - continue - elif toknum == DEDENT: - indents.pop() - continue - elif toknum in (NEWLINE, COMMENT, NL): - startline = True - elif startline and indents: - toks_append(indents[-1]) - startline = False - toks_append(tokval) - return ''.join(toks) - + ut = Untokenizer() + return ut.untokenize(iterable) def generate_tokens(readline): """ @@ -237,7 +273,7 @@ if endmatch: pos = end = endmatch.end(0) yield (STRING, contstr + line[:end], - strstart, (lnum, end), contline + line) + strstart, (lnum, end), contline + line) contstr, needcont = '', 0 contline = None elif needcont and line[-2:] != '\\\n' and line[-3:] != '\\\r\n': @@ -263,7 +299,15 @@ if pos == max: break if line[pos] in '#\r\n': # skip comments or blank lines - yield ((NL, COMMENT)[line[pos] == '#'], line[pos:], + if line[pos] == '#': + comment_token = line[pos:].rstrip('\r\n') + nl_pos = pos + len(comment_token) + yield (COMMENT, comment_token, + (lnum, pos), (lnum, pos + len(comment_token)), line) + yield (NL, line[nl_pos:], + (lnum, nl_pos), (lnum, len(line)), line) + else: + yield ((NL, COMMENT)[line[pos] == '#'], line[pos:], (lnum, pos), (lnum, len(line)), line) continue @@ -294,9 +338,10 @@ (initial == '.' and token != '.'): # ordinary number yield (NUMBER, token, spos, epos, line) elif initial in '\r\n': - yield (parenlev > 0 and NL or NEWLINE, - token, spos, epos, line) + yield (NL if parenlev > 0 else NEWLINE, + token, spos, epos, line) elif initial == '#': + assert not token.endswith("\n") yield (COMMENT, token, spos, epos, line) elif token in triple_quoted: endprog = endprogs[token] Modified: python/branches/p3yk-noslice/Lib/trace.py ============================================================================== --- python/branches/p3yk-noslice/Lib/trace.py (original) +++ python/branches/p3yk-noslice/Lib/trace.py Fri Dec 15 05:21:50 2006 @@ -484,7 +484,7 @@ sys.settrace(self.globaltrace) threading.settrace(self.globaltrace) try: - exec cmd in dict, dict + exec(cmd, dict, dict) finally: if not self.donothing: sys.settrace(None) @@ -497,7 +497,7 @@ sys.settrace(self.globaltrace) threading.settrace(self.globaltrace) try: - exec cmd in globals, locals + exec(cmd, globals, locals) finally: if not self.donothing: sys.settrace(None) Modified: python/branches/p3yk-noslice/Lib/traceback.py ============================================================================== --- python/branches/p3yk-noslice/Lib/traceback.py (original) +++ python/branches/p3yk-noslice/Lib/traceback.py Fri Dec 15 05:21:50 2006 @@ -162,7 +162,15 @@ """ + # Gracefully handle (the way Python 2.4 and earlier did) the case of + # being called with (None, None). + if etype is None: + return [_format_final_exc_line(etype, value)] + stype = etype.__name__ + smod = etype.__module__ + if smod not in ("exceptions", "__main__", "__builtin__"): + stype = smod + '.' + stype if not issubclass(etype, SyntaxError): return [_format_final_exc_line(stype, value)] Modified: python/branches/p3yk-noslice/Lib/urllib.py ============================================================================== --- python/branches/p3yk-noslice/Lib/urllib.py (original) +++ python/branches/p3yk-noslice/Lib/urllib.py Fri Dec 15 05:21:50 2006 @@ -302,13 +302,13 @@ if proxy_passwd: import base64 - proxy_auth = base64.encodestring(proxy_passwd).strip() + proxy_auth = base64.b64encode(proxy_passwd).strip() else: proxy_auth = None if user_passwd: import base64 - auth = base64.encodestring(user_passwd).strip() + auth = base64.b64encode(user_passwd).strip() else: auth = None h = httplib.HTTP(host) @@ -387,12 +387,12 @@ if not host: raise IOError, ('https error', 'no host given') if proxy_passwd: import base64 - proxy_auth = base64.encodestring(proxy_passwd).strip() + proxy_auth = base64.b64encode(proxy_passwd).strip() else: proxy_auth = None if user_passwd: import base64 - auth = base64.encodestring(user_passwd).strip() + auth = base64.b64encode(user_passwd).strip() else: auth = None h = httplib.HTTPS(host, 0, Modified: python/branches/p3yk-noslice/Lib/urllib2.py ============================================================================== --- python/branches/p3yk-noslice/Lib/urllib2.py (original) +++ python/branches/p3yk-noslice/Lib/urllib2.py Fri Dec 15 05:21:50 2006 @@ -674,7 +674,7 @@ proxy_type = orig_type if user and password: user_pass = '%s:%s' % (unquote(user), unquote(password)) - creds = base64.encodestring(user_pass).strip() + creds = base64.b64encode(user_pass).strip() req.add_header('Proxy-authorization', 'Basic ' + creds) hostport = unquote(hostport) req.set_proxy(hostport, proxy_type) @@ -798,7 +798,7 @@ user, pw = self.passwd.find_user_password(realm, host) if pw is not None: raw = "%s:%s" % (user, pw) - auth = 'Basic %s' % base64.encodestring(raw).strip() + auth = 'Basic %s' % base64.b64encode(raw).strip() if req.headers.get(self.auth_header, None) == auth: return None req.add_header(self.auth_header, auth) Modified: python/branches/p3yk-noslice/Lib/uu.py ============================================================================== --- python/branches/p3yk-noslice/Lib/uu.py (original) +++ python/branches/p3yk-noslice/Lib/uu.py Fri Dec 15 05:21:50 2006 @@ -114,6 +114,7 @@ # # Open the output file # + opened = False if out_file == '-': out_file = sys.stdout elif isinstance(out_file, basestring): @@ -123,6 +124,7 @@ except AttributeError: pass out_file = fp + opened = True # # Main decoding loop # @@ -140,6 +142,8 @@ s = in_file.readline() if not s: raise Error('Truncated input file') + if opened: + out_file.close() def test(): """uuencode/uudecode main program""" Modified: python/branches/p3yk-noslice/Lib/uuid.py ============================================================================== --- python/branches/p3yk-noslice/Lib/uuid.py (original) +++ python/branches/p3yk-noslice/Lib/uuid.py Fri Dec 15 05:21:50 2006 @@ -177,9 +177,36 @@ int |= version << 76L self.__dict__['int'] = int - def __cmp__(self, other): + def __eq__(self, other): if isinstance(other, UUID): - return cmp(self.int, other.int) + return self.int == other.int + return NotImplemented + + def __ne__(self, other): + if isinstance(other, UUID): + return self.int != other.int + return NotImplemented + + # XXX What's the value of being able to sort UUIDs? + + def __lt__(self, other): + if isinstance(other, UUID): + return self.int < other.int + return NotImplemented + + def __gt__(self, other): + if isinstance(other, UUID): + return self.int > other.int + return NotImplemented + + def __le__(self, other): + if isinstance(other, UUID): + return self.int <= other.int + return NotImplemented + + def __ge__(self, other): + if isinstance(other, UUID): + return self.int >= other.int return NotImplemented def __hash__(self): @@ -488,7 +515,7 @@ # 0x01b21dd213814000 is the number of 100-ns intervals between the # UUID epoch 1582-10-15 00:00:00 and the Unix epoch 1970-01-01 00:00:00. timestamp = int(nanoseconds/100) + 0x01b21dd213814000L - if timestamp <= _last_timestamp: + if _last_timestamp is not None and timestamp <= _last_timestamp: timestamp = _last_timestamp + 1 _last_timestamp = timestamp if clock_seq is None: Modified: python/branches/p3yk-noslice/Lib/webbrowser.py ============================================================================== --- python/branches/p3yk-noslice/Lib/webbrowser.py (original) +++ python/branches/p3yk-noslice/Lib/webbrowser.py Fri Dec 15 05:21:50 2006 @@ -165,7 +165,10 @@ cmdline = [self.name] + [arg.replace("%s", url) for arg in self.args] try: - p = subprocess.Popen(cmdline, close_fds=True) + if sys.platform[:3] == 'win': + p = subprocess.Popen(cmdline) + else: + p = subprocess.Popen(cmdline, close_fds=True) return not p.wait() except OSError: return False @@ -178,11 +181,14 @@ def open(self, url, new=0, autoraise=1): cmdline = [self.name] + [arg.replace("%s", url) for arg in self.args] - setsid = getattr(os, 'setsid', None) - if not setsid: - setsid = getattr(os, 'setpgrp', None) try: - p = subprocess.Popen(cmdline, close_fds=True, preexec_fn=setsid) + if sys.platform[:3] == 'win': + p = subprocess.Popen(cmdline) + else: + setsid = getattr(os, 'setsid', None) + if not setsid: + setsid = getattr(os, 'setpgrp', None) + p = subprocess.Popen(cmdline, close_fds=True, preexec_fn=setsid) return (p.poll() is None) except OSError: return False @@ -210,7 +216,7 @@ cmdline = [self.name] + raise_opt + args if remote or self.background: - inout = file(os.devnull, "r+") + inout = open(os.devnull, "r+") else: # for TTY browsers, we need stdin/out inout = None @@ -334,7 +340,7 @@ else: action = "openURL" - devnull = file(os.devnull, "r+") + devnull = open(os.devnull, "r+") # if possible, put browser in separate process group, so # keyboard interrupts don't affect browser as well as Python setsid = getattr(os, 'setsid', None) @@ -441,7 +447,7 @@ # if successful, register it if retncode is None and commd: - register("gnome", None, BackgroundBrowser(commd)) + register("gnome", None, BackgroundBrowser(commd.split())) # First, the Mozilla/Netscape browsers for browser in ("mozilla-firefox", "firefox", @@ -627,7 +633,7 @@ for o, a in opts: if o == '-n': new_win = 1 elif o == '-t': new_win = 2 - if len(args) <> 1: + if len(args) != 1: print >>sys.stderr, usage sys.exit(1) Modified: python/branches/p3yk-noslice/Lib/wsgiref/headers.py ============================================================================== --- python/branches/p3yk-noslice/Lib/wsgiref/headers.py (original) +++ python/branches/p3yk-noslice/Lib/wsgiref/headers.py Fri Dec 15 05:21:50 2006 @@ -63,7 +63,7 @@ Does *not* raise an exception if the header is missing. """ name = name.lower() - self._headers[:] = [kv for kv in self._headers if kv[0].lower()<>name] + self._headers[:] = [kv for kv in self._headers if kv[0].lower() != name] def __getitem__(self,name): """Get the first header value for 'name' @@ -140,7 +140,7 @@ return self._headers[:] def __repr__(self): - return "Headers(%s)" % `self._headers` + return "Headers(%r)" % self._headers def __str__(self): """str() returns the formatted headers, complete with end line, Modified: python/branches/p3yk-noslice/Lib/wsgiref/simple_server.py ============================================================================== --- python/branches/p3yk-noslice/Lib/wsgiref/simple_server.py (original) +++ python/branches/p3yk-noslice/Lib/wsgiref/simple_server.py Fri Dec 15 05:21:50 2006 @@ -169,7 +169,7 @@ print >>stdout h = environ.items(); h.sort() for k,v in h: - print >>stdout, k,'=',`v` + print >>stdout, k,'=',repr(v) start_response("200 OK", [('Content-Type','text/plain')]) return [stdout.getvalue()] Modified: python/branches/p3yk-noslice/Lib/wsgiref/util.py ============================================================================== --- python/branches/p3yk-noslice/Lib/wsgiref/util.py (original) +++ python/branches/p3yk-noslice/Lib/wsgiref/util.py Fri Dec 15 05:21:50 2006 @@ -98,7 +98,7 @@ return None path_parts = path_info.split('/') - path_parts[1:-1] = [p for p in path_parts[1:-1] if p and p<>'.'] + path_parts[1:-1] = [p for p in path_parts[1:-1] if p and p != '.'] name = path_parts[1] del path_parts[1] Modified: python/branches/p3yk-noslice/Lib/xdrlib.py ============================================================================== --- python/branches/p3yk-noslice/Lib/xdrlib.py (original) +++ python/branches/p3yk-noslice/Lib/xdrlib.py Fri Dec 15 05:21:50 2006 @@ -227,61 +227,3 @@ def unpack_array(self, unpack_item): n = self.unpack_uint() return self.unpack_farray(n, unpack_item) - - -# test suite -def _test(): - p = Packer() - packtest = [ - (p.pack_uint, (9,)), - (p.pack_bool, (True,)), - (p.pack_bool, (False,)), - (p.pack_uhyper, (45L,)), - (p.pack_float, (1.9,)), - (p.pack_double, (1.9,)), - (p.pack_string, ('hello world',)), - (p.pack_list, (range(5), p.pack_uint)), - (p.pack_array, (['what', 'is', 'hapnin', 'doctor'], p.pack_string)), - ] - succeedlist = [1] * len(packtest) - count = 0 - for method, args in packtest: - print 'pack test', count, - try: - method(*args) - print 'succeeded' - except ConversionError, var: - print 'ConversionError:', var.msg - succeedlist[count] = 0 - count = count + 1 - data = p.get_buffer() - # now verify - up = Unpacker(data) - unpacktest = [ - (up.unpack_uint, (), lambda x: x == 9), - (up.unpack_bool, (), lambda x: x is True), - (up.unpack_bool, (), lambda x: x is False), - (up.unpack_uhyper, (), lambda x: x == 45L), - (up.unpack_float, (), lambda x: 1.89 < x < 1.91), - (up.unpack_double, (), lambda x: 1.89 < x < 1.91), - (up.unpack_string, (), lambda x: x == 'hello world'), - (up.unpack_list, (up.unpack_uint,), lambda x: x == range(5)), - (up.unpack_array, (up.unpack_string,), - lambda x: x == ['what', 'is', 'hapnin', 'doctor']), - ] - count = 0 - for method, args, pred in unpacktest: - print 'unpack test', count, - try: - if succeedlist[count]: - x = method(*args) - print pred(x) and 'succeeded' or 'failed', ':', x - else: - print 'skipping' - except ConversionError, var: - print 'ConversionError:', var.msg - count = count + 1 - - -if __name__ == '__main__': - _test() Modified: python/branches/p3yk-noslice/Lib/xml/dom/minidom.py ============================================================================== --- python/branches/p3yk-noslice/Lib/xml/dom/minidom.py (original) +++ python/branches/p3yk-noslice/Lib/xml/dom/minidom.py Fri Dec 15 05:21:50 2006 @@ -38,7 +38,7 @@ prefix = EMPTY_PREFIX # non-null only for NS elements and attributes - def __nonzero__(self): + def __bool__(self): return True def toxml(self, encoding = None): Modified: python/branches/p3yk-noslice/Lib/xmlrpclib.py ============================================================================== --- python/branches/p3yk-noslice/Lib/xmlrpclib.py (original) +++ python/branches/p3yk-noslice/Lib/xmlrpclib.py Fri Dec 15 05:21:50 2006 @@ -282,56 +282,9 @@ # @param value A boolean value. Any true value is interpreted as True, # all other values are interpreted as False. -if _bool_is_builtin: - boolean = Boolean = bool - # to avoid breaking code which references xmlrpclib.{True,False} - True, False = True, False -else: - class Boolean: - """Boolean-value wrapper. - - Use True or False to generate a "boolean" XML-RPC value. - """ - - def __init__(self, value = 0): - self.value = operator.truth(value) - - def encode(self, out): - out.write("%d\n" % self.value) - - def __cmp__(self, other): - if isinstance(other, Boolean): - other = other.value - return cmp(self.value, other) - - def __repr__(self): - if self.value: - return "" % id(self) - else: - return "" % id(self) - - def __int__(self): - return self.value - - def __nonzero__(self): - return self.value - - True, False = Boolean(1), Boolean(0) - - ## - # Map true or false value to XML-RPC boolean values. - # - # @def boolean(value) - # @param value A boolean value. Any true value is mapped to True, - # all other values are mapped to False. - # @return xmlrpclib.True or xmlrpclib.False. - # @see Boolean - # @see True - # @see False - - def boolean(value, _truefalse=(False, True)): - """Convert any Python value to XML-RPC 'boolean'.""" - return _truefalse[operator.truth(value)] +boolean = Boolean = bool +# to avoid breaking code which references xmlrpclib.{True,False} +True, False = True, False ## # Wrapper for XML-RPC DateTime values. This converts a time value to @@ -371,10 +324,15 @@ value = time.strftime("%Y%m%dT%H:%M:%S", value) self.value = value - def __cmp__(self, other): + def __eq__(self, other): if isinstance(other, DateTime): other = other.value - return cmp(self.value, other) + return self.value == other + + def __ne__(self, other): + if isinstance(other, DateTime): + other = other.value + return self.value != other ## # Get date/time value. @@ -432,10 +390,15 @@ def __str__(self): return self.data or "" - def __cmp__(self, other): + def __eq__(self, other): if isinstance(other, Binary): other = other.data - return cmp(self.data, other) + return self.data == other + + def __ne__(self, other): + if isinstance(other, Binary): + other = other.data + return self.data != other def decode(self, data): self.data = base64.decodestring(data) @@ -630,9 +593,21 @@ try: f = self.dispatch[type(value)] except KeyError: - raise TypeError, "cannot marshal %s objects" % type(value) - else: - f(self, value, write) + # check if this object can be marshalled as a structure + try: + value.__dict__ + except: + raise TypeError, "cannot marshal %s objects" % type(value) + # check if this class is a sub-class of a basic type, + # because we don't know how to marshal these types + # (e.g. a string sub-class) + for type_ in type(value).__mro__: + if type_ in self.dispatch.keys(): + raise TypeError, "cannot marshal %s objects" % type(value) + # XXX(twouters): using "_arbitrary_instance" as key as a quick-fix + # for the p3yk merge, this should probably be fixed more neatly. + f = self.dispatch["_arbitrary_instance"] + f(self, value, write) def dump_nil (self, value, write): if not self.allow_none: @@ -750,6 +725,9 @@ self.dump_struct(value.__dict__, write) dispatch[DateTime] = dump_instance dispatch[Binary] = dump_instance + # XXX(twouters): using "_arbitrary_instance" as key as a quick-fix + # for the p3yk merge, this should probably be fixed more neatly. + dispatch["_arbitrary_instance"] = dump_instance ## # XML-RPC unmarshaller. Modified: python/branches/p3yk-noslice/Mac/BuildScript/build-installer.py ============================================================================== --- python/branches/p3yk-noslice/Mac/BuildScript/build-installer.py (original) +++ python/branches/p3yk-noslice/Mac/BuildScript/build-installer.py Fri Dec 15 05:21:50 2006 @@ -10,9 +10,10 @@ Usage: see USAGE variable in the script. """ import platform, os, sys, getopt, textwrap, shutil, urllib2, stat, time, pwd +import grp -INCLUDE_TIMESTAMP=1 -VERBOSE=1 +INCLUDE_TIMESTAMP = 1 +VERBOSE = 1 from plistlib import Plist @@ -32,7 +33,7 @@ def shellQuote(value): """ - Return the string value in a form that can savely be inserted into + Return the string value in a form that can safely be inserted into a shell command. """ return "'%s'"%(value.replace("'", "'\"'\"'")) @@ -55,28 +56,28 @@ raise RuntimeError, "Cannot find full version??" -# The directory we'll use to create the build, will be erased and recreated -WORKDIR="/tmp/_py" +# The directory we'll use to create the build (will be erased and recreated) +WORKDIR = "/tmp/_py" -# The directory we'll use to store third-party sources, set this to something +# The directory we'll use to store third-party sources. Set this to something # else if you don't want to re-fetch required libraries every time. -DEPSRC=os.path.join(WORKDIR, 'third-party') -DEPSRC=os.path.expanduser('~/Universal/other-sources') +DEPSRC = os.path.join(WORKDIR, 'third-party') +DEPSRC = os.path.expanduser('~/Universal/other-sources') # Location of the preferred SDK -SDKPATH="/Developer/SDKs/MacOSX10.4u.sdk" -#SDKPATH="/" +SDKPATH = "/Developer/SDKs/MacOSX10.4u.sdk" +#SDKPATH = "/" -ARCHLIST=('i386', 'ppc',) +ARCHLIST = ('i386', 'ppc',) # Source directory (asume we're in Mac/BuildScript) -SRCDIR=os.path.dirname( +SRCDIR = os.path.dirname( os.path.dirname( os.path.dirname( os.path.abspath(__file__ )))) -USAGE=textwrap.dedent("""\ +USAGE = textwrap.dedent("""\ Usage: build_python [options] Options: @@ -91,7 +92,7 @@ # Instructions for building libraries that are necessary for building a # batteries included python. -LIBRARY_RECIPES=[ +LIBRARY_RECIPES = [ dict( name="Bzip2 1.0.3", url="http://www.bzip.org/1.0.3/bzip2-1.0.3.tar.gz", @@ -183,7 +184,7 @@ # Instructions for building packages inside the .mpkg. -PKG_RECIPES=[ +PKG_RECIPES = [ dict( name="PythonFramework", long_name="Python Framework", @@ -200,7 +201,7 @@ long_name="GUI Applications", source="/Applications/MacPython %(VER)s", readme="""\ - This package installs IDLE (an interactive Python IDLE), + This package installs IDLE (an interactive Python IDE), Python Launcher and Build Applet (create application bundles from python scripts). @@ -256,8 +257,7 @@ readme="""\ This package updates the system python installation on Mac OS X 10.3 to ensure that you can build new python extensions - using that copy of python after installing this version of - python. + using that copy of python after installing this version. """, postflight="../Tools/fixapplepython23.py", topdir="/Library/Frameworks/Python.framework", @@ -323,7 +323,7 @@ -def parseOptions(args = None): +def parseOptions(args=None): """ Parse arguments and update global settings. """ @@ -636,15 +636,15 @@ print "Running make" runCommand("make") - print "Runing make frameworkinstall" + print "Running make frameworkinstall" runCommand("make frameworkinstall DESTDIR=%s"%( shellQuote(rootDir))) - print "Runing make frameworkinstallextras" + print "Running make frameworkinstallextras" runCommand("make frameworkinstallextras DESTDIR=%s"%( shellQuote(rootDir))) - print "Copy required shared libraries" + print "Copying required shared libraries" if os.path.exists(os.path.join(WORKDIR, 'libraries', 'Library')): runCommand("mv %s/* %s"%( shellQuote(os.path.join( @@ -657,9 +657,13 @@ print "Fix file modes" frmDir = os.path.join(rootDir, 'Library', 'Frameworks', 'Python.framework') + gid = grp.getgrnam('admin').gr_gid + for dirpath, dirnames, filenames in os.walk(frmDir): for dn in dirnames: os.chmod(os.path.join(dirpath, dn), 0775) + os.chown(os.path.join(dirpath, dn), -1, gid) + for fn in filenames: if os.path.islink(fn): @@ -668,7 +672,8 @@ # "chmod g+w $fn" p = os.path.join(dirpath, fn) st = os.stat(p) - os.chmod(p, stat.S_IMODE(st.st_mode) | stat.S_IXGRP) + os.chmod(p, stat.S_IMODE(st.st_mode) | stat.S_IWGRP) + os.chown(p, -1, gid) # We added some directories to the search path during the configure # phase. Remove those because those directories won't be there on @@ -729,8 +734,8 @@ def packageFromRecipe(targetDir, recipe): curdir = os.getcwd() try: - # The major version (such as 2.5) is included in the pacakge name - # because haveing two version of python installed at the same time is + # The major version (such as 2.5) is included in the package name + # because having two version of python installed at the same time is # common. pkgname = '%s-%s'%(recipe['name'], getVersion()) srcdir = recipe.get('source') @@ -904,7 +909,7 @@ def buildDMG(): """ - Create DMG containing the rootDir + Create DMG containing the rootDir. """ outdir = os.path.join(WORKDIR, 'diskimage') if os.path.exists(outdir): @@ -917,7 +922,7 @@ imagepath = imagepath + '.dmg' os.mkdir(outdir) - runCommand("hdiutil create -volname 'Univeral MacPython %s' -srcfolder %s %s"%( + runCommand("hdiutil create -volname 'Universal MacPython %s' -srcfolder %s %s"%( getFullVersion(), shellQuote(os.path.join(WORKDIR, 'installer')), shellQuote(imagepath))) @@ -945,6 +950,10 @@ ref, isDirectory = Carbon.File.FSPathMakeRef(filePath) if isDirectory: + # There is a problem with getting this into the pax(1) archive, + # just ignore directory icons for now. + return + tmpPath = os.path.join(filePath, "Icon\r") if not os.path.exists(tmpPath): fp = open(tmpPath, 'w') Modified: python/branches/p3yk-noslice/Mac/BuildScript/scripts/postflight.documentation ============================================================================== --- python/branches/p3yk-noslice/Mac/BuildScript/scripts/postflight.documentation (original) +++ python/branches/p3yk-noslice/Mac/BuildScript/scripts/postflight.documentation Fri Dec 15 05:21:50 2006 @@ -1,6 +1,5 @@ #!/bin/sh -# FIXME PYVER="@PYVER@" if [ -d /Developer/Documentation ]; then @@ -8,5 +7,5 @@ mkdir -p /Developer/Documentation/Python fi - ln -fhs /Library/Frameworks/Python.framework/Versions/${PYVER}/Resources/English.lproj/Documentation "/Developer/Documentation/Python/Reference Documentation" + ln -fhs /Library/Frameworks/Python.framework/Versions/${PYVER}/Resources/English.lproj/Documentation "/Developer/Documentation/Python/Reference Documentation @PYVER@" fi Modified: python/branches/p3yk-noslice/Mac/BuildScript/scripts/postflight.patch-profile ============================================================================== --- python/branches/p3yk-noslice/Mac/BuildScript/scripts/postflight.patch-profile (original) +++ python/branches/p3yk-noslice/Mac/BuildScript/scripts/postflight.patch-profile Fri Dec 15 05:21:50 2006 @@ -47,22 +47,29 @@ echo "${PYTHON_ROOT}/bin is not on your PATH or at least not early enough" case "${BSH}" in *csh) + if [ -f "${HOME}/.tcshrc" ]; then + RC="${HOME}/.tcshrc" + else + RC="${HOME}/.cshrc" + fi # Create backup copy before patching - if [ -f "${HOME}/.cshrc" ]; then - cp -fp "${HOME}/.cshrc" "${HOME}/.cshrc.pysave" + if [ -f "${RC}" ]; then + cp -fp "${RC}" "${RC}.pysave" fi - echo "" >> "${HOME}/.cshrc" - echo "# Setting PATH for MacPython ${PYVER}" >> "${HOME}/.cshrc" - echo "# The orginal version is saved in .cshrc.pysave" >> "${HOME}/.cshrc" - echo "set path=(${PYTHON_ROOT}/bin "'$path'")" >> "${HOME}/.cshrc" + echo "" >> "${RC}" + echo "# Setting PATH for MacPython ${PYVER}" >> "${RC}" + echo "# The orginal version is saved in .cshrc.pysave" >> "${RC}" + echo "set path=(${PYTHON_ROOT}/bin "'$path'")" >> "${RC}" if [ `id -ur` = 0 ]; then - chown "${USER}" "${HOME}/.cshrc" + chown "${USER}" "${RC}" fi exit 0 ;; bash) if [ -e "${HOME}/.bash_profile" ]; then PR="${HOME}/.bash_profile" + elif [ -e "${HOME}/.bash_login" ]; then + PR="${HOME}/.bash_login" elif [ -e "${HOME}/.profile" ]; then PR="${HOME}/.profile" else Modified: python/branches/p3yk-noslice/Mac/Makefile.in ============================================================================== --- python/branches/p3yk-noslice/Mac/Makefile.in (original) +++ python/branches/p3yk-noslice/Mac/Makefile.in Fri Dec 15 05:21:50 2006 @@ -101,7 +101,7 @@ fi -pythonw: $(srcdir)/Tools/pythonw.c +pythonw: $(srcdir)/Tools/pythonw.c Makefile $(CC) $(LDFLAGS) -o $@ $(srcdir)/Tools/pythonw.c \ -DPYTHONWEXECUTABLE='"$(APPINSTALLDIR)/Contents/MacOS/Python"' @@ -249,3 +249,6 @@ rm pythonw cd PythonLauncher && make clean cd IDLE && make clean + +Makefile: $(srcdir)/Makefile.in ../config.status + cd .. && CONFIG_FILES=Mac/Makefile CONFIG_HEADERS= $(SHELL) ./config.status Modified: python/branches/p3yk-noslice/Mac/PythonLauncher/FileSettings.m ============================================================================== --- python/branches/p3yk-noslice/Mac/PythonLauncher/FileSettings.m (original) +++ python/branches/p3yk-noslice/Mac/PythonLauncher/FileSettings.m Fri Dec 15 05:21:50 2006 @@ -207,7 +207,7 @@ [NSNumber numberWithBool: inspect], @"inspect", [NSNumber numberWithBool: optimize], @"optimize", [NSNumber numberWithBool: nosite], @"nosite", - [NSNumber numberWithBool: nosite], @"nosite", + [NSNumber numberWithBool: tabs], @"tabs", others, @"others", scriptargs, @"scriptargs", [NSNumber numberWithBool: with_terminal], @"with_terminal", @@ -235,7 +235,7 @@ if (value) optimize = [value boolValue]; value = [dict objectForKey: @"nosite"]; if (value) nosite = [value boolValue]; - value = [dict objectForKey: @"nosite"]; + value = [dict objectForKey: @"tabs"]; if (value) tabs = [value boolValue]; value = [dict objectForKey: @"others"]; if (value) others = [value retain]; @@ -291,7 +291,7 @@ tabs?" -t":"", others, [self _replaceSingleQuotes:script], - scriptargs, + scriptargs ? scriptargs : @"", with_terminal? "&& echo Exit status: $? && exit 1" : " &"]; } Modified: python/branches/p3yk-noslice/Mac/README ============================================================================== --- python/branches/p3yk-noslice/Mac/README (original) +++ python/branches/p3yk-noslice/Mac/README Fri Dec 15 05:21:50 2006 @@ -48,7 +48,7 @@ A second reason for using frameworks is that they put Python-related items in only two places: "/Library/Framework/Python.framework" and -"/Applications/MacPython 2.5". This simplifies matters for users installing +"/Applications/MacPython 2.6". This simplifies matters for users installing Python from a binary distribution if they want to get rid of it again. Moreover, due to the way frameworks work a user without admin privileges can install a binary distribution in his or her home directory without recompilation. @@ -75,7 +75,7 @@ This directory contains a Makefile that will create a couple of python-related applications (fullblown OSX .app applications, that is) in -"/Applications/MacPython 2.3", and a hidden helper application Python.app +"/Applications/MacPython 2.6", and a hidden helper application Python.app inside the Python.framework, and unix tools "python" and "pythonw" into /usr/local/bin. In addition it has a target "installmacsubtree" that installs the relevant portions of the Mac subtree into the Python.framework. @@ -90,20 +90,16 @@ 3. make install This sequence will put the framework in /Library/Framework/Python.framework, -the applications in /Applications/MacPython 2.5 and the unix tools in +the applications in "/Applications/MacPython 2.6" and the unix tools in /usr/local/bin. Installing in another place, for instance $HOME/Library/Frameworks if you have no admin privileges on your machine, has only been tested very lightly. This can be done by configuring with --enable-framework=$HOME/Library/Frameworks. -The other two directories, /Applications/MacPython-2.3 and /usr/local/bin, will -then also be deposited in $HOME. This is sub-optimal for the unix tools, which -you would want in $HOME/bin, but there is no easy way to fix this right now. - -Note that there are no references to the actual locations in the code or -resource files, so you are free to move things around afterwards. For example, -you could use --enable-framework=/tmp/newversion/Library/Frameworks and use -/tmp/newversion as the basis for an installer or something. +The other two directories, "/Applications/MacPython-2.6" and /usr/local/bin, +will then also be deposited in $HOME. This is sub-optimal for the unix tools, +which you would want in $HOME/bin, but there is no easy way to fix this right +now. If you want to install some part, but not all, read the main Makefile. The frameworkinstall is composed of a couple of sub-targets that install the @@ -111,7 +107,7 @@ There is an extra target frameworkinstallextras that is not part of the normal frameworkinstall which installs the Demo and Tools directories -into /Applications/MacPython-2.3, this is useful for binary distributions. +into "/Applications/MacPython 2.6", this is useful for binary distributions. What do all these programs do? =============================== Modified: python/branches/p3yk-noslice/Mac/Tools/fixapplepython23.py ============================================================================== --- python/branches/p3yk-noslice/Mac/Tools/fixapplepython23.py (original) +++ python/branches/p3yk-noslice/Mac/Tools/fixapplepython23.py Fri Dec 15 05:21:50 2006 @@ -123,7 +123,8 @@ makescript(GXX_SCRIPT, "g++") # Finally fix the makefile rv = fix(MAKEFILE, do_apply) - sys.exit(rv) + #sys.exit(rv) + sys.exit(0) if __name__ == '__main__': main() Modified: python/branches/p3yk-noslice/Makefile.pre.in ============================================================================== --- python/branches/p3yk-noslice/Makefile.pre.in (original) +++ python/branches/p3yk-noslice/Makefile.pre.in Fri Dec 15 05:21:50 2006 @@ -346,7 +346,7 @@ # Build the shared modules sharedmods: $(BUILDPYTHON) - case $$MAKEFLAGS in \ + @case $$MAKEFLAGS in \ *-s*) $(RUNSHARED) CC='$(CC)' LDSHARED='$(BLDSHARED)' OPT='$(OPT)' ./$(BUILDPYTHON) -E $(srcdir)/setup.py -q build;; \ *) $(RUNSHARED) CC='$(CC)' LDSHARED='$(BLDSHARED)' OPT='$(OPT)' ./$(BUILDPYTHON) -E $(srcdir)/setup.py build;; \ esac @@ -457,7 +457,7 @@ $(SIGNAL_OBJS) \ $(MODOBJS) \ $(srcdir)/Modules/getbuildinfo.c - $(CC) -c $(PY_CFLAGS) -DSVNVERSION=\"`LANG=C $(SVNVERSION)`\" -o $@ $(srcdir)/Modules/getbuildinfo.c + $(CC) -c $(PY_CFLAGS) -DSVNVERSION=\"`LC_ALL=C $(SVNVERSION)`\" -o $@ $(srcdir)/Modules/getbuildinfo.c Modules/getpath.o: $(srcdir)/Modules/getpath.c Makefile $(CC) -c $(PY_CFLAGS) -DPYTHONPATH='"$(PYTHONPATH)"' \ Modified: python/branches/p3yk-noslice/Misc/ACKS ============================================================================== --- python/branches/p3yk-noslice/Misc/ACKS (original) +++ python/branches/p3yk-noslice/Misc/ACKS Fri Dec 15 05:21:50 2006 @@ -242,6 +242,7 @@ Michael Guravage Lars Gust?bel Barry Haddow +V?clav Haisman Paul ten Hagen Rasmus Hahn Peter Haight @@ -365,6 +366,7 @@ Soren Larsen Piers Lauder Ben Laurie +Simon Law Chris Lawrence Christopher Lee Inyeol Lee @@ -611,6 +613,7 @@ Christian Tanzer Steven Taschuk Amy Taylor +Monty Taylor Tobias Thelen Robin Thomas Eric Tiedemann @@ -631,6 +634,7 @@ Bill Tutt Doobee R. Tzeck Lionel Ulmer +Roger Upole Michael Urman Hector Urtubia Dmitry Vasiliev Modified: python/branches/p3yk-noslice/Misc/HISTORY ============================================================================== --- python/branches/p3yk-noslice/Misc/HISTORY (original) +++ python/branches/p3yk-noslice/Misc/HISTORY Fri Dec 15 05:21:50 2006 @@ -11679,7 +11679,7 @@ - The way GNU readline is configured is totally different. The --with-readline configure option is gone. It is now an extension module, which may be loaded dynamically. You must enable it (and -specify the correct linraries to link with) in the Modules/Setup file. +specify the correct libraries to link with) in the Modules/Setup file. Importing the module installs some hooks which enable command line editing. When the interpreter shell is invoked interactively, it attempts to import the readline module; when this fails, the default Modified: python/branches/p3yk-noslice/Misc/NEWS ============================================================================== --- python/branches/p3yk-noslice/Misc/NEWS (original) +++ python/branches/p3yk-noslice/Misc/NEWS Fri Dec 15 05:21:50 2006 @@ -32,10 +32,11 @@ - Get rid of various compatibility-related flags (e.g. division flags). + Core and Builtins ----------------- -- __coerce__ has been removed. +- Renamed nb_nonzero to nb_bool and __nonzero__ to __bool__ - Classic classes are a thing of the past. All classes are new style. @@ -55,19 +56,23 @@ - Absolute import is the default behavior for 'import foo' etc. +- Removed support for syntax: + backticks (`x`), <> + - Removed these Python builtins: apply(), coerce(), input(), raw_input() +- Removed these Python methods: + {}.has_key + - Removed these Python slots: __coerce__, __div__, __idiv__, __rdiv__ - Removed these attributes from Python modules: * operator module: div, idiv, __div__, __idiv__ -*** PyNumber_CoerceEx() and nb_coerce still need to be removed. - - Removed these C APIs: - PyNumber_Coerce(), + PyNumber_Coerce(), PyNumber_CoerceEx() - Removed these C slots/fields: nb_divide, nb_inplace_divide @@ -80,7 +85,13 @@ getreadbufferproc, getwritebufferproc, getsegcountproc, getcharbufferproc - Removed these opcodes: - BINARY_DIVIDE, INPLACE_DIVIDE + BINARY_DIVIDE, INPLACE_DIVIDE, UNARY_CONVERT + +- zip returns an iterator + +- Additions: + set literals + Extension Modules ----------------- Modified: python/branches/p3yk-noslice/Misc/SpecialBuilds.txt ============================================================================== --- python/branches/p3yk-noslice/Misc/SpecialBuilds.txt (original) +++ python/branches/p3yk-noslice/Misc/SpecialBuilds.txt Fri Dec 15 05:21:50 2006 @@ -91,7 +91,7 @@ #define CLEANBYTE 0xCB /* clean (newly allocated) memory */ #define DEADBYTE 0xDB /* dead (newly freed) memory */ -#define FORBIDDENBYTE 0xFB /* fordidden -- untouchable bytes */ +#define FORBIDDENBYTE 0xFB /* forbidden -- untouchable bytes */ Strings of these bytes are unlikely to be valid addresses, floats, or 7-bit ASCII strings. Modified: python/branches/p3yk-noslice/Misc/Vim/python.vim ============================================================================== --- python/branches/p3yk-noslice/Misc/Vim/python.vim (original) +++ python/branches/p3yk-noslice/Misc/Vim/python.vim Fri Dec 15 05:21:50 2006 @@ -62,39 +62,39 @@ if exists("python_highlight_builtins") - syn keyword pythonBuiltin unichr all set abs vars int __import__ unicode - syn keyword pythonBuiltin enumerate reduce exit issubclass - syn keyword pythonBuiltin divmod file Ellipsis isinstance open any - syn keyword pythonBuiltin locals help filter basestring slice copyright min - syn keyword pythonBuiltin super sum tuple hex execfile long id chr - syn keyword pythonBuiltin complex bool zip pow dict True oct NotImplemented - syn keyword pythonBuiltin map None float hash getattr buffer max reversed - syn keyword pythonBuiltin object quit len repr callable credits setattr - syn keyword pythonBuiltin eval frozenset sorted ord __debug__ hasattr - syn keyword pythonBuiltin delattr False license classmethod type - syn keyword pythonBuiltin list iter reload range globals - syn keyword pythonBuiltin staticmethod str property round dir cmp + syn keyword pythonBuiltin Ellipsis False None NotImplemented True __debug__ + syn keyword pythonBuiltin __import__ abs all any basestring bool + syn keyword pythonBuiltin buffer callable chr classmethod cmp + syn keyword pythonBuiltin complex copyright credits delattr dict + syn keyword pythonBuiltin dir divmod enumerate eval execfile exit file + syn keyword pythonBuiltin filter float frozenset getattr globals hasattr + syn keyword pythonBuiltin hash help hex id int isinstance + syn keyword pythonBuiltin issubclass iter len license list locals long map + syn keyword pythonBuiltin max min object oct open ord pow property quit + syn keyword pythonBuiltin range reload repr reversed round + syn keyword pythonBuiltin set setattr slice sorted staticmethod str sum + syn keyword pythonBuiltin super tuple type unichr unicode vars zip endif if exists("python_highlight_exceptions") - syn keyword pythonException GeneratorExit ImportError RuntimeError - syn keyword pythonException UnicodeTranslateError MemoryError StopIteration - syn keyword pythonException PendingDeprecationWarning EnvironmentError - syn keyword pythonException LookupError OSError DeprecationWarning - syn keyword pythonException UnicodeError UnicodeEncodeError - syn keyword pythonException FloatingPointError ReferenceError NameError - syn keyword pythonException IOError SyntaxError - syn keyword pythonException FutureWarning ImportWarning SystemExit - syn keyword pythonException Exception EOFError StandardError ValueError - syn keyword pythonException TabError KeyError ZeroDivisionError SystemError - syn keyword pythonException UnicodeDecodeError IndentationError - syn keyword pythonException AssertionError TypeError IndexError - syn keyword pythonException RuntimeWarning KeyboardInterrupt UserWarning - syn keyword pythonException SyntaxWarning UnboundLocalError ArithmeticError - syn keyword pythonException Warning NotImplementedError AttributeError - syn keyword pythonException OverflowError BaseException + syn keyword pythonException ArithmeticError AssertionError AttributeError + syn keyword pythonException BaseException DeprecationWarning EOFError + syn keyword pythonException EnvironmentError Exception FloatingPointError + syn keyword pythonException FutureWarning GeneratorExit IOError ImportError + syn keyword pythonException ImportWarning IndentationError IndexError + syn keyword pythonException KeyError KeyboardInterrupt LookupError + syn keyword pythonException MemoryError NameError NotImplementedError + syn keyword pythonException OSError OverflowError PendingDeprecationWarning + syn keyword pythonException ReferenceError RuntimeError RuntimeWarning + syn keyword pythonException StandardError StopIteration SyntaxError + syn keyword pythonException SyntaxWarning SystemError SystemExit TabError + syn keyword pythonException TypeError UnboundLocalError UnicodeDecodeError + syn keyword pythonException UnicodeEncodeError UnicodeError + syn keyword pythonException UnicodeTranslateError UnicodeWarning + syn keyword pythonException UserWarning ValueError Warning + syn keyword pythonException ZeroDivisionError endif Modified: python/branches/p3yk-noslice/Misc/Vim/vim_syntax.py ============================================================================== --- python/branches/p3yk-noslice/Misc/Vim/vim_syntax.py (original) +++ python/branches/p3yk-noslice/Misc/Vim/vim_syntax.py Fri Dec 15 05:21:50 2006 @@ -5,9 +5,9 @@ import __builtin__ from string import Template -comment_header = """" Auto-generated Vim syntax file for Python +comment_header = '''" Auto-generated Vim syntax file for Python. " -" To use: copy or symlink to ~/.vim/syntax/python.vim""" +" To use: copy or symlink to ~/.vim/syntax/python.vim''' statement_header = """ if exists("b:current_syntax") @@ -30,14 +30,14 @@ import_stmts = ('import', 'from') object_defs = ('def', 'class') -exception_names = frozenset(exc for exc in dir(exceptions) +exception_names = sorted(exc for exc in dir(exceptions) if not exc.startswith('__')) # Need to include functions that start with '__' (e.g., __import__), but # nothing that comes with modules (e.g., __name__), so just exclude anything in # the 'exceptions' module since we want to ignore exceptions *and* what any # module would have -builtin_names = frozenset(builtin for builtin in dir(__builtin__) +builtin_names = sorted(builtin for builtin in dir(__builtin__) if builtin not in dir(exceptions)) escapes = (r'+\\[abfnrtv\'"\\]+', r'"\\\o\{1,3}"', r'"\\x\x\{2}"', Modified: python/branches/p3yk-noslice/Misc/Vim/vimrc ============================================================================== --- python/branches/p3yk-noslice/Misc/Vim/vimrc (original) +++ python/branches/p3yk-noslice/Misc/Vim/vimrc Fri Dec 15 05:21:50 2006 @@ -19,9 +19,10 @@ " Number of spaces to use for an indent. " This will affect Ctrl-T and 'autoindent'. " Python: 4 spaces -" C: tab (8 spaces) +" C: 4 spaces au BufRead,BufNewFile *.py,*pyw set shiftwidth=4 -au BufRead,BufNewFile *.c,*.h set shiftwidth=4 +au BufRead *.c,*.h set shiftwidth=8 +au BufNewFile *.c,*.h set shiftwidth=4 " Number of spaces that a pre-existing tab is equal to. " For the amount of space used for a new tab use shiftwidth. Modified: python/branches/p3yk-noslice/Misc/cheatsheet ============================================================================== --- python/branches/p3yk-noslice/Misc/cheatsheet (original) +++ python/branches/p3yk-noslice/Misc/cheatsheet Fri Dec 15 05:21:50 2006 @@ -215,7 +215,6 @@ x^y Bitwise exclusive or x|y Bitwise or xy x>=y x==y x!=y Comparison, - x<>y identity, x is y x is not y membership x in s x not in s not x boolean negation @@ -241,7 +240,7 @@ > strictly greater than >= greater than or equal to == equal to -!= or <> not equal to +!= not equal to is object identity (2) is not negated object identity (2) @@ -270,7 +269,7 @@ Notes : Truth testing behavior can be overridden for a given class by defining -special method __nonzero__. +special method __bool__. (1) Evaluate second arg only if necessary to determine outcome. None @@ -901,7 +900,7 @@ -- Creates an anonymous function. returnedExpr must be an expression, not a statement (e.g., not "if xx:...", "print xxx", etc.) and thus can't contain newlines. - Used mostly for filter(), map(), reduce() functions, and GUI callbacks.. + Used mostly for filter(), map() functions, and GUI callbacks.. List comprehensions result = [expression for item1 in sequence1 [if condition1] [for item2 in sequence2 ... for itemN in sequenceN] @@ -1005,18 +1004,12 @@ range(start [,end Returns list of ints from >= start and < end.With 1 arg, [, step]]) list from 0..arg-1With 2 args, list from start..end-1With 3 args, list from start up to end by step -reduce(f, list [, Applies the binary function f to the items oflist so as to -init]) reduce the list to a single value.If init given, it is - "prepended" to list. - Re-parses and re-initializes an already imported module. - Useful in interactive mode, if you want to reload amodule reload(module) after fixing it. If module was syntacticallycorrect but had an error in initialization, mustimport it one more time before calling reload(). Returns a string containing a printable and if possible -repr(object) evaluable representation of an object. <=> `object` - (usingbackquotes). Class redefinissable (__repr__). See - also str() +repr(object) evaluable representation of an object. + Class redefinable (__repr__). See also str(). round(x, n=0) Returns the floating point value x rounded to n digitsafter the decimal point. setattr(object, This is the counterpart of getattr().setattr(o, 'foobar', @@ -1150,7 +1143,7 @@ __cmp__(s, o) Compares s to o and returns <0, 0, or >0. Implements >, <, == etc... __hash__(s) Compute a 32 bit hash code; hash() and dictionary ops - __nonzero__(s) Returns False or True for truth value testing + __bool__(s) Returns False or True for truth value testing __getattr__(s, name) called when attr lookup doesn't find __setattr__(s, name, val) called when setting an attr (inside, don't use "self.name = value" @@ -1174,7 +1167,7 @@ s&o = __and__(s,o) s^o = __xor__(s,o) s|o = __or__(s,o) s<>o = __rshift__(s,o) - nonzero(s) = __nonzero__(s) (used in boolean testing) + bool(s) = __bool__(s) (used in boolean testing) -s = __neg__(s) +s = __pos__(s) abs(s) = __abs__(s) ~s = __invert__(s) (bitwise) s+=o = __iadd__(s,o) s-=o = __isub__(s,o) Modified: python/branches/p3yk-noslice/Misc/python-mode.el ============================================================================== --- python/branches/p3yk-noslice/Misc/python-mode.el (original) +++ python/branches/p3yk-noslice/Misc/python-mode.el Fri Dec 15 05:21:50 2006 @@ -386,7 +386,7 @@ "isinstance" "issubclass" "iter" "len" "license" "list" "locals" "long" "map" "max" "min" "object" "oct" "open" "ord" "pow" "property" "range" - "reduce" "reload" "repr" "round" + "reload" "repr" "round" "setattr" "slice" "staticmethod" "str" "sum" "super" "tuple" "type" "unichr" "unicode" "vars" "zip") @@ -690,8 +690,6 @@ ;; Both single quote and double quote are string delimiters (modify-syntax-entry ?\' "\"" py-mode-syntax-table) (modify-syntax-entry ?\" "\"" py-mode-syntax-table) - ;; backquote is open and close paren - (modify-syntax-entry ?\` "$" py-mode-syntax-table) ;; comment delimiters (modify-syntax-entry ?\# "<" py-mode-syntax-table) (modify-syntax-entry ?\n ">" py-mode-syntax-table) Modified: python/branches/p3yk-noslice/Misc/vgrindefs ============================================================================== --- python/branches/p3yk-noslice/Misc/vgrindefs (original) +++ python/branches/p3yk-noslice/Misc/vgrindefs Fri Dec 15 05:21:50 2006 @@ -6,5 +6,5 @@ :pb=^\d?(def|class)\d\p(\d|\\|\(|\:):\ :cb=#:ce=$:sb=":se=\e":lb=':le=\e':\ :kw=assert and break class continue def del elif else except\ - exec finally for from global if import in is lambda not or\ + finally for from global if import in is lambda not or\ pass print raise return try while yield: Modified: python/branches/p3yk-noslice/Modules/_bsddb.c ============================================================================== --- python/branches/p3yk-noslice/Modules/_bsddb.c (original) +++ python/branches/p3yk-noslice/Modules/_bsddb.c Fri Dec 15 05:21:50 2006 @@ -98,7 +98,7 @@ #error "eek! DBVER can't handle minor versions > 9" #endif -#define PY_BSDDB_VERSION "4.4.5" +#define PY_BSDDB_VERSION "4.4.6" static char *rcs_id = "$Id$"; @@ -1779,9 +1779,7 @@ return NULL; CHECK_DB_NOT_CLOSED(self); - MYDB_BEGIN_ALLOW_THREADS; type = _DB_get_type(self); - MYDB_END_ALLOW_THREADS; if (type == -1) return NULL; return PyInt_FromLong(type); @@ -2430,7 +2428,7 @@ #if (DBVER >= 43) PyObject* txnobj = NULL; DB_TXN *txn = NULL; - static char* kwnames[] = { "txn", "flags", NULL }; + static char* kwnames[] = { "flags", "txn", NULL }; #else static char* kwnames[] = { "flags", NULL }; #endif Modified: python/branches/p3yk-noslice/Modules/_ctypes/_ctypes.c ============================================================================== --- python/branches/p3yk-noslice/Modules/_ctypes/_ctypes.c (original) +++ python/branches/p3yk-noslice/Modules/_ctypes/_ctypes.c Fri Dec 15 05:21:50 2006 @@ -2589,16 +2589,22 @@ PPROC address; char *mangled_name; int i; - StgDictObject *dict = PyType_stgdict((PyObject *)type); + StgDictObject *dict; address = (PPROC)GetProcAddress(handle, name); +#ifdef _WIN64 + /* win64 has no stdcall calling conv, so it should + also not have the name mangling of it. + */ + return address; +#else if (address) return address; - if (((size_t)name & ~0xFFFF) == 0) { return NULL; } + dict = PyType_stgdict((PyObject *)type); /* It should not happen that dict is NULL, but better be safe */ if (dict==NULL || dict->flags & FUNCFLAG_CDECL) return address; @@ -2617,6 +2623,7 @@ return address; } return NULL; +#endif } #endif @@ -4154,7 +4161,7 @@ { NULL, NULL }, }; -static int Simple_nonzero(CDataObject *self) +static int Simple_bool(CDataObject *self) { return memcmp(self->b_ptr, "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0", self->b_size); } @@ -4169,7 +4176,7 @@ 0, /* nb_negative */ 0, /* nb_positive */ 0, /* nb_absolute */ - (inquiry)Simple_nonzero, /* nb_nonzero */ + (inquiry)Simple_bool, /* nb_bool */ }; #if (PY_VERSION_HEX < 0x02040000) @@ -4594,7 +4601,7 @@ }; static int -Pointer_nonzero(CDataObject *self) +Pointer_bool(CDataObject *self) { return *(void **)self->b_ptr != NULL; } @@ -4609,7 +4616,7 @@ 0, /* nb_negative */ 0, /* nb_positive */ 0, /* nb_absolute */ - (inquiry)Pointer_nonzero, /* nb_nonzero */ + (inquiry)Pointer_bool, /* nb_bool */ }; PyTypeObject Pointer_Type = { @@ -4818,11 +4825,11 @@ if (obj->b_objects == NULL) goto failed; } + Py_XINCREF(obj->b_objects); result->b_objects = obj->b_objects; - if (result->b_objects) { + if (result->b_objects && PyDict_Check(result->b_objects)) { PyObject *index; int rc; - Py_INCREF(obj->b_objects); index = PyLong_FromVoidPtr((void *)src); if (index == NULL) goto failed; Modified: python/branches/p3yk-noslice/Modules/_ctypes/_ctypes_test.c ============================================================================== --- python/branches/p3yk-noslice/Modules/_ctypes/_ctypes_test.c (original) +++ python/branches/p3yk-noslice/Modules/_ctypes/_ctypes_test.c Fri Dec 15 05:21:50 2006 @@ -25,6 +25,16 @@ /* some functions handy for testing */ +EXPORT(int)myprintf(char *fmt, ...) +{ + int result; + va_list argptr; + va_start(argptr, fmt); + result = vprintf(fmt, argptr); + va_end(argptr); + return result; +} + EXPORT(char *)my_strtok(char *token, const char *delim) { return strtok(token, delim); Modified: python/branches/p3yk-noslice/Modules/_ctypes/callbacks.c ============================================================================== --- python/branches/p3yk-noslice/Modules/_ctypes/callbacks.c (original) +++ python/branches/p3yk-noslice/Modules/_ctypes/callbacks.c Fri Dec 15 05:21:50 2006 @@ -51,6 +51,7 @@ if (!empty_string) goto bad; py_code = PyCode_New( 0, /*int argcount,*/ + 0, /*int kwonlyargcount,*/ 0, /*int nlocals,*/ 0, /*int stacksize,*/ 0, /*int flags,*/ @@ -293,14 +294,17 @@ p->restype = &ffi_type_void; } else { StgDictObject *dict = PyType_stgdict(restype); - if (dict == NULL) - goto error; + if (dict == NULL || dict->setfunc == NULL) { + PyErr_SetString(PyExc_TypeError, + "invalid result type for callback function"); + goto error; + } p->setfunc = dict->setfunc; p->restype = &dict->ffi_type_pointer; } cc = FFI_DEFAULT_ABI; -#if defined(MS_WIN32) && !defined(_WIN32_WCE) +#if defined(MS_WIN32) && !defined(_WIN32_WCE) && !defined(MS_WIN64) if (is_cdecl == 0) cc = FFI_STDCALL; #endif Modified: python/branches/p3yk-noslice/Modules/_ctypes/callproc.c ============================================================================== --- python/branches/p3yk-noslice/Modules/_ctypes/callproc.c (original) +++ python/branches/p3yk-noslice/Modules/_ctypes/callproc.c Fri Dec 15 05:21:50 2006 @@ -638,7 +638,7 @@ } cc = FFI_DEFAULT_ABI; -#if defined(MS_WIN32) && !defined(_WIN32_WCE) +#if defined(MS_WIN32) && !defined(MS_WIN64) && !defined(_WIN32_WCE) if ((flags & FUNCFLAG_CDECL) == 0) cc = FFI_STDCALL; #endif @@ -683,6 +683,14 @@ return -1; } #endif +#ifdef MS_WIN64 + if (delta != 0) { + PyErr_Format(PyExc_RuntimeError, + "ffi_call failed with code %d", + delta); + return -1; + } +#else if (delta < 0) { if (flags & FUNCFLAG_CDECL) PyErr_Format(PyExc_ValueError, @@ -704,6 +712,7 @@ return -1; } #endif +#endif if ((flags & FUNCFLAG_PYTHONAPI) && PyErr_Occurred()) return -1; return 0; @@ -979,7 +988,11 @@ } for (i = 0; i < argcount; ++i) { atypes[i] = args[i].ffi_type; - if (atypes[i]->type == FFI_TYPE_STRUCT) + if (atypes[i]->type == FFI_TYPE_STRUCT +#ifdef _WIN64 + && atypes[i]->size <= sizeof(void *) +#endif + ) avalues[i] = (void *)args[i].value.p; else avalues[i] = (void *)&args[i].value; @@ -1099,7 +1112,11 @@ hMod = LoadLibrary(name); if (!hMod) return PyErr_SetFromWindowsErr(GetLastError()); +#ifdef _WIN64 + return PyLong_FromVoidPtr(hMod); +#else return Py_BuildValue("i", hMod); +#endif } static char free_library_doc[] = @@ -1230,11 +1247,11 @@ static PyObject *py_dl_close(PyObject *self, PyObject *args) { - void * handle; + int handle; if (!PyArg_ParseTuple(args, "i:dlclose", &handle)) return NULL; - if (dlclose(handle)) { + if (dlclose((void*)handle)) { PyErr_SetString(PyExc_OSError, ctypes_dlerror()); return NULL; @@ -1246,12 +1263,12 @@ static PyObject *py_dl_sym(PyObject *self, PyObject *args) { char *name; - void *handle; + int handle; void *ptr; if (!PyArg_ParseTuple(args, "is:dlsym", &handle, &name)) return NULL; - ptr = ctypes_dlsym(handle, name); + ptr = ctypes_dlsym((void*)handle, name); if (!ptr) { PyErr_SetString(PyExc_OSError, ctypes_dlerror()); @@ -1269,7 +1286,7 @@ static PyObject * call_function(PyObject *self, PyObject *args) { - PPROC func; + int func; PyObject *arguments; PyObject *result; @@ -1279,7 +1296,7 @@ &PyTuple_Type, &arguments)) return NULL; - result = _CallProc(func, + result = _CallProc((PPROC)func, arguments, #ifdef MS_WIN32 NULL, @@ -1300,7 +1317,7 @@ static PyObject * call_cdeclfunction(PyObject *self, PyObject *args) { - PPROC func; + int func; PyObject *arguments; PyObject *result; @@ -1310,7 +1327,7 @@ &PyTuple_Type, &arguments)) return NULL; - result = _CallProc(func, + result = _CallProc((PPROC)func, arguments, #ifdef MS_WIN32 NULL, @@ -1493,7 +1510,7 @@ #else "On:resize", #endif - (PyObject *)&obj, &size)) + &obj, &size)) return NULL; dict = PyObject_stgdict((PyObject *)obj); Modified: python/branches/p3yk-noslice/Modules/_ctypes/cfield.c ============================================================================== --- python/branches/p3yk-noslice/Modules/_ctypes/cfield.c (original) +++ python/branches/p3yk-noslice/Modules/_ctypes/cfield.c Fri Dec 15 05:21:50 2006 @@ -1315,7 +1315,11 @@ *(char **)ptr = PyString_AS_STRING(str); return str; } else if (PyInt_Check(value) || PyLong_Check(value)) { +#if SIZEOF_VOID_P == SIZEOF_LONG_LONG + *(char **)ptr = (char *)PyInt_AsUnsignedLongLongMask(value); +#else *(char **)ptr = (char *)PyInt_AsUnsignedLongMask(value); +#endif _RET(value); } PyErr_Format(PyExc_TypeError, @@ -1360,7 +1364,11 @@ if (!value) return NULL; } else if (PyInt_Check(value) || PyLong_Check(value)) { +#if SIZEOF_VOID_P == SIZEOF_LONG_LONG + *(wchar_t **)ptr = (wchar_t *)PyInt_AsUnsignedLongLongMask(value); +#else *(wchar_t **)ptr = (wchar_t *)PyInt_AsUnsignedLongMask(value); +#endif Py_INCREF(Py_None); return Py_None; } else if (!PyUnicode_Check(value)) { Modified: python/branches/p3yk-noslice/Modules/_ctypes/libffi/src/powerpc/ffi_darwin.c ============================================================================== --- python/branches/p3yk-noslice/Modules/_ctypes/libffi/src/powerpc/ffi_darwin.c (original) +++ python/branches/p3yk-noslice/Modules/_ctypes/libffi/src/powerpc/ffi_darwin.c Fri Dec 15 05:21:50 2006 @@ -1,4 +1,4 @@ -#ifdef __ppc__ +#if !(defined(__APPLE__) && !defined(__ppc__)) /* ----------------------------------------------------------------------- ffi.c - Copyright (c) 1998 Geoffrey Keating Modified: python/branches/p3yk-noslice/Modules/_ctypes/libffi/src/x86/sysv.S ============================================================================== --- python/branches/p3yk-noslice/Modules/_ctypes/libffi/src/x86/sysv.S (original) +++ python/branches/p3yk-noslice/Modules/_ctypes/libffi/src/x86/sysv.S Fri Dec 15 05:21:50 2006 @@ -376,3 +376,7 @@ #endif #endif /* ifndef __x86_64__ */ + +#ifdef __ELF__ +.section .note.GNU-stack,"",%progbits +#endif Modified: python/branches/p3yk-noslice/Modules/_ctypes/libffi_msvc/ffi.c ============================================================================== --- python/branches/p3yk-noslice/Modules/_ctypes/libffi_msvc/ffi.c (original) +++ python/branches/p3yk-noslice/Modules/_ctypes/libffi_msvc/ffi.c Fri Dec 15 05:21:50 2006 @@ -34,6 +34,8 @@ /* ffi_prep_args is called by the assembly routine once stack space has been allocated for the function's arguments */ +extern void Py_FatalError(char *msg); + /*@-exportheader@*/ void ffi_prep_args(char *stack, extended_cif *ecif) /*@=exportheader@*/ @@ -44,11 +46,10 @@ register ffi_type **p_arg; argp = stack; - if (ecif->cif->rtype->type == FFI_TYPE_STRUCT) { *(void **) argp = ecif->rvalue; - argp += 4; + argp += sizeof(void *); } p_argv = ecif->avalue; @@ -60,8 +61,8 @@ size_t z; /* Align if necessary */ - if ((sizeof(int) - 1) & (unsigned) argp) - argp = (char *) ALIGN(argp, sizeof(int)); + if ((sizeof(void *) - 1) & (size_t) argp) + argp = (char *) ALIGN(argp, sizeof(void *)); z = (*p_arg)->size; if (z < sizeof(int)) @@ -108,7 +109,11 @@ p_argv++; argp += z; } - + + if (argp - stack > ecif->cif->bytes) + { + Py_FatalError("FFI BUG: not enough stack space for arguments"); + } return; } @@ -128,6 +133,9 @@ break; case FFI_TYPE_UINT64: +#ifdef _WIN64 + case FFI_TYPE_POINTER: +#endif cif->flags = FFI_TYPE_SINT64; break; @@ -139,6 +147,7 @@ return FFI_OK; } +#ifdef _WIN32 /*@-declundef@*/ /*@-exportheader@*/ extern int @@ -160,6 +169,16 @@ void (*fn)()); /*@=declundef@*/ /*@=exportheader@*/ +#endif + +#ifdef _WIN64 +extern int +ffi_call_AMD64(void (*)(char *, extended_cif *), + /*@out@*/ extended_cif *, + unsigned, unsigned, + /*@out@*/ unsigned *, + void (*fn)()); +#endif int ffi_call(/*@dependent@*/ ffi_cif *cif, @@ -188,6 +207,7 @@ switch (cif->abi) { +#if !defined(_WIN64) case FFI_SYSV: /*@-usedef@*/ return ffi_call_SYSV(ffi_prep_args, &ecif, cif->bytes, @@ -201,6 +221,14 @@ cif->flags, ecif.rvalue, fn); /*@=usedef@*/ break; +#else + case FFI_SYSV: + /*@-usedef@*/ + return ffi_call_AMD64(ffi_prep_args, &ecif, cif->bytes, + cif->flags, ecif.rvalue, fn); + /*@=usedef@*/ + break; +#endif default: FFI_ASSERT(0); @@ -213,10 +241,14 @@ /** private members **/ static void ffi_prep_incoming_args_SYSV (char *stack, void **ret, - void** args, ffi_cif* cif); + void** args, ffi_cif* cif); /* This function is jumped to by the trampoline */ +#ifdef _WIN64 +void * +#else static void __fastcall +#endif ffi_closure_SYSV (ffi_closure *closure, int *argp) { // this is our return value storage @@ -244,6 +276,7 @@ rtype = cif->flags; +#if defined(_WIN32) && !defined(_WIN64) #ifdef _MSC_VER /* now, do a generic return based on the value of rtype */ if (rtype == FFI_TYPE_INT) @@ -303,6 +336,15 @@ : "eax", "edx"); } #endif +#endif + +#ifdef _WIN64 + /* The result is returned in rax. This does the right thing for + result types except for floats; we have to 'mov xmm0, rax' in the + caller to correct this. + */ + return *(void **)resp; +#endif } /*@-exportheader@*/ @@ -330,8 +372,8 @@ size_t z; /* Align if necessary */ - if ((sizeof(int) - 1) & (unsigned) argp) { - argp = (char *) ALIGN(argp, sizeof(int)); + if ((sizeof(char *) - 1) & (size_t) argp) { + argp = (char *) ALIGN(argp, sizeof(char*)); } z = (*p_arg)->size; @@ -347,24 +389,8 @@ return; } -/* How to make a trampoline. Derived from gcc/config/i386/i386.c. */ - -#define FFI_INIT_TRAMPOLINE(TRAMP,FUN,CTX,BYTES) \ -{ unsigned char *__tramp = (unsigned char*)(TRAMP); \ - unsigned int __fun = (unsigned int)(FUN); \ - unsigned int __ctx = (unsigned int)(CTX); \ - unsigned int __dis = __fun - ((unsigned int) __tramp + 8 + 4); \ - *(unsigned char*) &__tramp[0] = 0xb9; \ - *(unsigned int*) &__tramp[1] = __ctx; /* mov ecx, __ctx */ \ - *(unsigned char*) &__tramp[5] = 0x8b; \ - *(unsigned char*) &__tramp[6] = 0xd4; /* mov edx, esp */ \ - *(unsigned char*) &__tramp[7] = 0xe8; \ - *(unsigned int*) &__tramp[8] = __dis; /* call __fun */ \ - *(unsigned char*) &__tramp[12] = 0xC2; /* ret BYTES */ \ - *(unsigned short*) &__tramp[13] = BYTES; \ - } - /* the cif must already be prep'ed */ +extern void ffi_closure_OUTER(); ffi_status ffi_prep_closure (ffi_closure* closure, @@ -373,19 +399,78 @@ void *user_data) { short bytes; + char *tramp; +#ifdef _WIN64 + int mask; +#endif FFI_ASSERT (cif->abi == FFI_SYSV); if (cif->abi == FFI_SYSV) bytes = 0; +#if !defined(_WIN64) else if (cif->abi == FFI_STDCALL) bytes = cif->bytes; +#endif else return FFI_BAD_ABI; - FFI_INIT_TRAMPOLINE (&closure->tramp[0], - &ffi_closure_SYSV, - (void*)closure, - bytes); + tramp = &closure->tramp[0]; + +#define BYTES(text) memcpy(tramp, text, sizeof(text)), tramp += sizeof(text)-1 +#define POINTER(x) *(void**)tramp = (void*)(x), tramp += sizeof(void*) +#define SHORT(x) *(short*)tramp = x, tramp += sizeof(short) +#define INT(x) *(int*)tramp = x, tramp += sizeof(int) + +#ifdef _WIN64 + if (cif->nargs >= 1 && + (cif->arg_types[0]->type == FFI_TYPE_FLOAT + || cif->arg_types[0]->type == FFI_TYPE_DOUBLE)) + mask |= 1; + if (cif->nargs >= 2 && + (cif->arg_types[1]->type == FFI_TYPE_FLOAT + || cif->arg_types[1]->type == FFI_TYPE_DOUBLE)) + mask |= 2; + if (cif->nargs >= 3 && + (cif->arg_types[2]->type == FFI_TYPE_FLOAT + || cif->arg_types[2]->type == FFI_TYPE_DOUBLE)) + mask |= 4; + if (cif->nargs >= 4 && + (cif->arg_types[3]->type == FFI_TYPE_FLOAT + || cif->arg_types[3]->type == FFI_TYPE_DOUBLE)) + mask |= 8; + + /* 41 BB ---- mov r11d,mask */ + BYTES("\x41\xBB"); INT(mask); + + /* 48 B8 -------- mov rax, closure */ + BYTES("\x48\xB8"); POINTER(closure); + + /* 49 BA -------- mov r10, ffi_closure_OUTER */ + BYTES("\x49\xBA"); POINTER(ffi_closure_OUTER); + + /* 41 FF E2 jmp r10 */ + BYTES("\x41\xFF\xE2"); + +#else + + /* mov ecx, closure */ + BYTES("\xb9"); POINTER(closure); + + /* mov edx, esp */ + BYTES("\x8b\xd4"); + + /* call ffi_closure_SYSV */ + BYTES("\xe8"); POINTER((char*)&ffi_closure_SYSV - (tramp + 4)); + + /* ret bytes */ + BYTES("\xc2"); + SHORT(bytes); + +#endif + + if (tramp - &closure->tramp[0] > FFI_TRAMPOLINE_SIZE) + Py_FatalError("FFI_TRAMPOLINE_SIZE too small in " __FILE__); + closure->cif = cif; closure->user_data = user_data; closure->fun = fun; Modified: python/branches/p3yk-noslice/Modules/_ctypes/libffi_msvc/ffi.h ============================================================================== --- python/branches/p3yk-noslice/Modules/_ctypes/libffi_msvc/ffi.h (original) +++ python/branches/p3yk-noslice/Modules/_ctypes/libffi_msvc/ffi.h Fri Dec 15 05:21:50 2006 @@ -174,12 +174,10 @@ /* ---- Definitions for the raw API -------------------------------------- */ -#ifndef FFI_SIZEOF_ARG -# if LONG_MAX == 2147483647 -# define FFI_SIZEOF_ARG 4 -# elif LONG_MAX == 9223372036854775807 -# define FFI_SIZEOF_ARG 8 -# endif +#ifdef _WIN64 +#define FFI_SIZEOF_ARG 8 +#else +#define FFI_SIZEOF_ARG 4 #endif typedef union { Modified: python/branches/p3yk-noslice/Modules/_ctypes/libffi_msvc/ffitarget.h ============================================================================== --- python/branches/p3yk-noslice/Modules/_ctypes/libffi_msvc/ffitarget.h (original) +++ python/branches/p3yk-noslice/Modules/_ctypes/libffi_msvc/ffitarget.h Fri Dec 15 05:21:50 2006 @@ -44,7 +44,9 @@ /* ---- Intel x86 Win32 ---------- */ FFI_SYSV, +#ifndef _WIN64 FFI_STDCALL, +#endif /* TODO: Add fastcall support for the sake of completeness */ FFI_DEFAULT_ABI = FFI_SYSV, @@ -67,8 +69,8 @@ #define FFI_CLOSURES 1 -#ifdef X86_64 -#define FFI_TRAMPOLINE_SIZE 24 +#ifdef _WIN64 +#define FFI_TRAMPOLINE_SIZE 29 #define FFI_NATIVE_RAW_API 0 #else #define FFI_TRAMPOLINE_SIZE 15 Modified: python/branches/p3yk-noslice/Modules/_ctypes/stgdict.c ============================================================================== --- python/branches/p3yk-noslice/Modules/_ctypes/stgdict.c (original) +++ python/branches/p3yk-noslice/Modules/_ctypes/stgdict.c Fri Dec 15 05:21:50 2006 @@ -173,11 +173,11 @@ for (i = 0; i < PySequence_Fast_GET_SIZE(fieldlist); ++i) { PyObject *pair = PySequence_Fast_GET_ITEM(fieldlist, i); /* borrowed */ - PyObject *fname, *ftype; + PyObject *fname, *ftype, *bits; CFieldObject *fdescr; CFieldObject *new_descr; /* Convert to PyArg_UnpackTuple... */ - if (!PyArg_ParseTuple(pair, "OO", &fname, &ftype)) { + if (!PyArg_ParseTuple(pair, "OO|O", &fname, &ftype, &bits)) { Py_DECREF(fieldlist); return -1; } @@ -335,14 +335,14 @@ stgdict = PyType_stgdict(type); if (!stgdict) return -1; + /* If this structure/union is already marked final we cannot assign + _fields_ anymore. */ + if (stgdict->flags & DICTFLAG_FINAL) {/* is final ? */ PyErr_SetString(PyExc_AttributeError, "_fields_ is final"); return -1; } - /* XXX This should probably be moved to a point when all this - stuff is sucessfully finished. */ - stgdict->flags |= DICTFLAG_FINAL; /* set final */ if (stgdict->ffi_type_pointer.elements) PyMem_Free(stgdict->ffi_type_pointer.elements); @@ -476,5 +476,15 @@ stgdict->size = size; stgdict->align = total_align; stgdict->length = len; /* ADD ffi_ofs? */ + + /* We did check that this flag was NOT set above, it must not + have been set until now. */ + if (stgdict->flags & DICTFLAG_FINAL) { + PyErr_SetString(PyExc_AttributeError, + "Structure or union cannot contain itself"); + return -1; + } + stgdict->flags |= DICTFLAG_FINAL; + return MakeAnonFields(type); } Modified: python/branches/p3yk-noslice/Modules/_cursesmodule.c ============================================================================== --- python/branches/p3yk-noslice/Modules/_cursesmodule.c (original) +++ python/branches/p3yk-noslice/Modules/_cursesmodule.c Fri Dec 15 05:21:50 2006 @@ -2334,6 +2334,10 @@ } result = tparm(fmt,i1,i2,i3,i4,i5,i6,i7,i8,i9); + if (!result) { + PyErr_SetString(PyCursesError, "tparm() returned NULL"); + return NULL; + } return PyString_FromString(result); } Modified: python/branches/p3yk-noslice/Modules/_functoolsmodule.c ============================================================================== --- python/branches/p3yk-noslice/Modules/_functoolsmodule.c (original) +++ python/branches/p3yk-noslice/Modules/_functoolsmodule.c Fri Dec 15 05:21:50 2006 @@ -242,12 +242,88 @@ }; +/* reduce (used to be a builtin) ********************************************/ + +static PyObject * +functools_reduce(PyObject *self, PyObject *args) +{ + PyObject *seq, *func, *result = NULL, *it; + + if (!PyArg_UnpackTuple(args, "reduce", 2, 3, &func, &seq, &result)) + return NULL; + if (result != NULL) + Py_INCREF(result); + + it = PyObject_GetIter(seq); + if (it == NULL) { + PyErr_SetString(PyExc_TypeError, + "reduce() arg 2 must support iteration"); + Py_XDECREF(result); + return NULL; + } + + if ((args = PyTuple_New(2)) == NULL) + goto Fail; + + for (;;) { + PyObject *op2; + + if (args->ob_refcnt > 1) { + Py_DECREF(args); + if ((args = PyTuple_New(2)) == NULL) + goto Fail; + } + + op2 = PyIter_Next(it); + if (op2 == NULL) { + if (PyErr_Occurred()) + goto Fail; + break; + } + + if (result == NULL) + result = op2; + else { + PyTuple_SetItem(args, 0, result); + PyTuple_SetItem(args, 1, op2); + if ((result = PyEval_CallObject(func, args)) == NULL) + goto Fail; + } + } + + Py_DECREF(args); + + if (result == NULL) + PyErr_SetString(PyExc_TypeError, + "reduce() of empty sequence with no initial value"); + + Py_DECREF(it); + return result; + +Fail: + Py_XDECREF(args); + Py_XDECREF(result); + Py_DECREF(it); + return NULL; +} + +PyDoc_STRVAR(functools_reduce_doc, +"reduce(function, sequence[, initial]) -> value\n\ +\n\ +Apply a function of two arguments cumulatively to the items of a sequence,\n\ +from left to right, so as to reduce the sequence to a single value.\n\ +For example, reduce(lambda x, y: x+y, [1, 2, 3, 4, 5]) calculates\n\ +((((1+2)+3)+4)+5). If initial is present, it is placed before the items\n\ +of the sequence in the calculation, and serves as a default when the\n\ +sequence is empty."); + /* module level code ********************************************************/ PyDoc_STRVAR(module_doc, "Tools that operate on functions."); static PyMethodDef module_methods[] = { + {"reduce", functools_reduce, METH_VARARGS, functools_reduce_doc}, {NULL, NULL} /* sentinel */ }; Modified: python/branches/p3yk-noslice/Modules/_sre.c ============================================================================== --- python/branches/p3yk-noslice/Modules/_sre.c (original) +++ python/branches/p3yk-noslice/Modules/_sre.c Fri Dec 15 05:21:50 2006 @@ -1166,9 +1166,10 @@ /* install new repeat context */ ctx->u.rep = (SRE_REPEAT*) PyObject_MALLOC(sizeof(*ctx->u.rep)); - /* XXX(nnorwitz): anything else we need to do on error? */ - if (!ctx->u.rep) + if (!ctx->u.rep) { + PyErr_NoMemory(); RETURN_FAILURE; + } ctx->u.rep->count = -1; ctx->u.rep->pattern = ctx->pattern; ctx->u.rep->prev = state->repeat; @@ -1884,6 +1885,8 @@ } TRACE(("|%p|%p|END\n", PatternObject_GetCode(self), state.ptr)); + if (PyErr_Occurred()) + return NULL; state_fini(&state); @@ -1922,6 +1925,9 @@ state_fini(&state); + if (PyErr_Occurred()) + return NULL; + return pattern_new_match(self, &state, status); } @@ -2071,6 +2077,9 @@ #endif } + if (PyErr_Occurred()) + goto error; + if (status <= 0) { if (status == 0) break; @@ -2198,6 +2207,9 @@ #endif } + if (PyErr_Occurred()) + goto error; + if (status <= 0) { if (status == 0) break; @@ -2347,6 +2359,9 @@ #endif } + if (PyErr_Occurred()) + goto error; + if (status <= 0) { if (status == 0) break; @@ -3250,6 +3265,8 @@ status = sre_umatch(state, PatternObject_GetCode(self->pattern)); #endif } + if (PyErr_Occurred()) + return NULL; match = pattern_new_match((PatternObject*) self->pattern, state, status); @@ -3281,6 +3298,8 @@ status = sre_usearch(state, PatternObject_GetCode(self->pattern)); #endif } + if (PyErr_Occurred()) + return NULL; match = pattern_new_match((PatternObject*) self->pattern, state, status); Modified: python/branches/p3yk-noslice/Modules/_ssl.c ============================================================================== --- python/branches/p3yk-noslice/Modules/_ssl.c (original) +++ python/branches/p3yk-noslice/Modules/_ssl.c Fri Dec 15 05:21:50 2006 @@ -317,7 +317,7 @@ if (!PyArg_ParseTuple(args, "O!|zz:ssl", PySocketModule.Sock_Type, - (PyObject*)&Sock, + &Sock, &key_file, &cert_file)) return NULL; Modified: python/branches/p3yk-noslice/Modules/_testcapimodule.c ============================================================================== --- python/branches/p3yk-noslice/Modules/_testcapimodule.c (original) +++ python/branches/p3yk-noslice/Modules/_testcapimodule.c Fri Dec 15 05:21:50 2006 @@ -6,6 +6,8 @@ */ #include "Python.h" +#include +#include "structmember.h" #ifdef WITH_THREAD #include "pythread.h" @@ -35,13 +37,13 @@ platforms have these hardcoded. Better safe than sorry. */ static PyObject* -sizeof_error(const char* fatname, const char* typename, +sizeof_error(const char* fatname, const char* typname, int expected, int got) { char buf[1024]; PyOS_snprintf(buf, sizeof(buf), "%.200s #define == %d but sizeof(%.200s) == %d", - fatname, expected, typename, got); + fatname, expected, typname, got); PyErr_SetString(TestError, buf); return (PyObject*)NULL; } @@ -615,7 +617,7 @@ { PyObject *rc; PyGILState_STATE s = PyGILState_Ensure(); - rc = PyObject_CallFunction(callable, ""); + rc = PyObject_CallFunction((PyObject *)callable, ""); Py_XDECREF(rc); PyGILState_Release(s); } @@ -665,6 +667,9 @@ PyThread_acquire_lock(thread_done, 1); /* wait for thread to finish */ Py_END_ALLOW_THREADS + /* Release lock we acquired above. This is required on HP-UX. */ + PyThread_release_lock(thread_done); + PyThread_free_lock(thread_done); Py_RETURN_NONE; } @@ -756,6 +761,105 @@ #define AddSym(d, n, f, v) {PyObject *o = f(v); PyDict_SetItemString(d, n, o); Py_DECREF(o);} +typedef struct { + char byte_member; + unsigned char ubyte_member; + short short_member; + unsigned short ushort_member; + int int_member; + unsigned int uint_member; + long long_member; + unsigned long ulong_member; + float float_member; + double double_member; +} all_structmembers; + +typedef struct { + PyObject_HEAD + all_structmembers structmembers; +} test_structmembers; + +static struct PyMemberDef test_members[] = { + {"T_BYTE", T_BYTE, offsetof(test_structmembers, structmembers.byte_member), 0, NULL}, + {"T_UBYTE", T_UBYTE, offsetof(test_structmembers, structmembers.ubyte_member), 0, NULL}, + {"T_SHORT", T_SHORT, offsetof(test_structmembers, structmembers.short_member), 0, NULL}, + {"T_USHORT", T_USHORT, offsetof(test_structmembers, structmembers.ushort_member), 0, NULL}, + {"T_INT", T_INT, offsetof(test_structmembers, structmembers.int_member), 0, NULL}, + {"T_UINT", T_UINT, offsetof(test_structmembers, structmembers.uint_member), 0, NULL}, + {"T_LONG", T_LONG, offsetof(test_structmembers, structmembers.long_member), 0, NULL}, + {"T_ULONG", T_ULONG, offsetof(test_structmembers, structmembers.ulong_member), 0, NULL}, + {"T_FLOAT", T_FLOAT, offsetof(test_structmembers, structmembers.float_member), 0, NULL}, + {"T_DOUBLE", T_DOUBLE, offsetof(test_structmembers, structmembers.double_member), 0, NULL}, + {NULL} +}; + + +static PyObject *test_structmembers_new(PyTypeObject *type, PyObject *args, PyObject *kwargs){ + static char *keywords[]={"T_BYTE", "T_UBYTE", "T_SHORT", "T_USHORT", "T_INT", "T_UINT", + "T_LONG", "T_ULONG", "T_FLOAT", "T_DOUBLE", NULL}; + test_structmembers *ob=PyObject_New(test_structmembers, type); + if (ob==NULL) + return NULL; + memset(&ob->structmembers, 0, sizeof(all_structmembers)); + if (!PyArg_ParseTupleAndKeywords(args, kwargs, "|bBhHiIlkfd", keywords, + &ob->structmembers.byte_member, &ob->structmembers.ubyte_member, + &ob->structmembers.short_member, &ob->structmembers.ushort_member, + &ob->structmembers.int_member, &ob->structmembers.uint_member, + &ob->structmembers.long_member, &ob->structmembers.ulong_member, + &ob->structmembers.float_member, &ob->structmembers.double_member)){ + Py_DECREF(ob); + return NULL; + } + return (PyObject *)ob; +} + +static void test_structmembers_free(PyObject *ob){ + PyObject_FREE(ob); +} + +static PyTypeObject test_structmembersType = { + PyObject_HEAD_INIT(NULL) + 0, + "test_structmembersType", + sizeof(test_structmembers), /* tp_basicsize */ + 0, /* tp_itemsize */ + test_structmembers_free, /* destructor tp_dealloc */ + 0, /* tp_print */ + 0, /* tp_getattr */ + 0, /* tp_setattr */ + 0, /* tp_compare */ + 0, /* tp_repr */ + 0, /* tp_as_number */ + 0, /* tp_as_sequence */ + 0, /* tp_as_mapping */ + 0, /* tp_hash */ + 0, /* tp_call */ + 0, /* tp_str */ + PyObject_GenericGetAttr, + PyObject_GenericSetAttr, + 0, /* tp_as_buffer */ + 0, /* tp_flags */ + "Type containing all structmember types", + 0, /* traverseproc tp_traverse */ + 0, /* tp_clear */ + 0, /* tp_richcompare */ + 0, /* tp_weaklistoffset */ + 0, /* tp_iter */ + 0, /* tp_iternext */ + 0, /* tp_methods */ + test_members, /* tp_members */ + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + test_structmembers_new, /* tp_new */ +}; + + PyMODINIT_FUNC init_testcapi(void) { @@ -765,16 +869,28 @@ if (m == NULL) return; + test_structmembersType.ob_type=&PyType_Type; + Py_INCREF(&test_structmembersType); + PyModule_AddObject(m, "test_structmembersType", (PyObject *)&test_structmembersType); + + PyModule_AddObject(m, "CHAR_MAX", PyInt_FromLong(CHAR_MAX)); + PyModule_AddObject(m, "CHAR_MIN", PyInt_FromLong(CHAR_MIN)); PyModule_AddObject(m, "UCHAR_MAX", PyInt_FromLong(UCHAR_MAX)); + PyModule_AddObject(m, "SHRT_MAX", PyInt_FromLong(SHRT_MAX)); + PyModule_AddObject(m, "SHRT_MIN", PyInt_FromLong(SHRT_MIN)); PyModule_AddObject(m, "USHRT_MAX", PyInt_FromLong(USHRT_MAX)); + PyModule_AddObject(m, "INT_MAX", PyLong_FromLong(INT_MAX)); + PyModule_AddObject(m, "INT_MIN", PyLong_FromLong(INT_MIN)); PyModule_AddObject(m, "UINT_MAX", PyLong_FromUnsignedLong(UINT_MAX)); - PyModule_AddObject(m, "ULONG_MAX", PyLong_FromUnsignedLong(ULONG_MAX)); - PyModule_AddObject(m, "INT_MIN", PyInt_FromLong(INT_MIN)); - PyModule_AddObject(m, "LONG_MIN", PyInt_FromLong(LONG_MIN)); - PyModule_AddObject(m, "PY_SSIZE_T_MIN", PyInt_FromSsize_t(PY_SSIZE_T_MIN)); - PyModule_AddObject(m, "INT_MAX", PyInt_FromLong(INT_MAX)); PyModule_AddObject(m, "LONG_MAX", PyInt_FromLong(LONG_MAX)); + PyModule_AddObject(m, "LONG_MIN", PyInt_FromLong(LONG_MIN)); + PyModule_AddObject(m, "ULONG_MAX", PyLong_FromUnsignedLong(ULONG_MAX)); + PyModule_AddObject(m, "FLT_MAX", PyFloat_FromDouble(FLT_MAX)); + PyModule_AddObject(m, "FLT_MIN", PyFloat_FromDouble(FLT_MIN)); + PyModule_AddObject(m, "DBL_MAX", PyFloat_FromDouble(DBL_MAX)); + PyModule_AddObject(m, "DBL_MIN", PyFloat_FromDouble(DBL_MIN)); PyModule_AddObject(m, "PY_SSIZE_T_MAX", PyInt_FromSsize_t(PY_SSIZE_T_MAX)); + PyModule_AddObject(m, "PY_SSIZE_T_MIN", PyInt_FromSsize_t(PY_SSIZE_T_MIN)); TestError = PyErr_NewException("_testcapi.error", NULL, NULL); Py_INCREF(TestError); Modified: python/branches/p3yk-noslice/Modules/almodule.c ============================================================================== --- python/branches/p3yk-noslice/Modules/almodule.c (original) +++ python/branches/p3yk-noslice/Modules/almodule.c Fri Dec 15 05:21:50 2006 @@ -1686,7 +1686,7 @@ { int res, param; ALparamInfo pinfo; - PyObject *v, *item;; + PyObject *v, *item; if (!PyArg_ParseTuple(args, "ii:GetParamInfo", &res, ¶m)) return NULL; Modified: python/branches/p3yk-noslice/Modules/arraymodule.c ============================================================================== --- python/branches/p3yk-noslice/Modules/arraymodule.c (original) +++ python/branches/p3yk-noslice/Modules/arraymodule.c Fri Dec 15 05:21:50 2006 @@ -1495,7 +1495,7 @@ copy_doc}, {"count", (PyCFunction)array_count, METH_O, count_doc}, - {"__deepcopy__",(PyCFunction)array_copy, METH_NOARGS, + {"__deepcopy__",(PyCFunction)array_copy, METH_O, copy_doc}, {"extend", (PyCFunction)array_extend, METH_O, extend_doc}, Modified: python/branches/p3yk-noslice/Modules/audioop.c ============================================================================== --- python/branches/p3yk-noslice/Modules/audioop.c (original) +++ python/branches/p3yk-noslice/Modules/audioop.c Fri Dec 15 05:21:50 2006 @@ -472,8 +472,12 @@ double aj_m1, aj_lm1; double sum_ri_2, sum_aij_2, sum_aij_ri, result, best_result, factor; + /* Passing a short** for an 's' argument is correct only + if the string contents is aligned for interpretation + as short[]. Due to the definition of PyStringObject, + this is currently (Python 2.6) the case. */ if ( !PyArg_ParseTuple(args, "s#s#:findfit", - &cp1, &len1, &cp2, &len2) ) + (char**)&cp1, &len1, (char**)&cp2, &len2) ) return 0; if ( len1 & 1 || len2 & 1 ) { PyErr_SetString(AudioopError, "Strings should be even-sized"); @@ -530,7 +534,7 @@ double sum_ri_2, sum_aij_ri, result; if ( !PyArg_ParseTuple(args, "s#s#:findfactor", - &cp1, &len1, &cp2, &len2) ) + (char**)&cp1, &len1, (char**)&cp2, &len2) ) return 0; if ( len1 & 1 || len2 & 1 ) { PyErr_SetString(AudioopError, "Strings should be even-sized"); @@ -562,7 +566,8 @@ double aj_m1, aj_lm1; double result, best_result; - if ( !PyArg_ParseTuple(args, "s#i:findmax", &cp1, &len1, &len2) ) + if ( !PyArg_ParseTuple(args, "s#i:findmax", + (char**)&cp1, &len1, &len2) ) return 0; if ( len1 & 1 ) { PyErr_SetString(AudioopError, "Strings should be even-sized"); Modified: python/branches/p3yk-noslice/Modules/binascii.c ============================================================================== --- python/branches/p3yk-noslice/Modules/binascii.c (original) +++ python/branches/p3yk-noslice/Modules/binascii.c Fri Dec 15 05:21:50 2006 @@ -1057,8 +1057,7 @@ in++; if (in >= datalen) break; /* Soft line breaks */ - if ((data[in] == '\n') || (data[in] == '\r') || - (data[in] == ' ') || (data[in] == '\t')) { + if ((data[in] == '\n') || (data[in] == '\r')) { if (data[in] != '\n') { while (in < datalen && data[in] != '\n') in++; } Modified: python/branches/p3yk-noslice/Modules/bz2module.c ============================================================================== --- python/branches/p3yk-noslice/Modules/bz2module.c (original) +++ python/branches/p3yk-noslice/Modules/bz2module.c Fri Dec 15 05:21:50 2006 @@ -1016,12 +1016,12 @@ case MODE_CLOSED: PyErr_SetString(PyExc_ValueError, "I/O operation on closed file"); - goto cleanup;; + goto cleanup; default: PyErr_SetString(PyExc_IOError, "seek works only while reading"); - goto cleanup;; + goto cleanup; } if (where == 2) { Modified: python/branches/p3yk-noslice/Modules/cPickle.c ============================================================================== --- python/branches/p3yk-noslice/Modules/cPickle.c (original) +++ python/branches/p3yk-noslice/Modules/cPickle.c Fri Dec 15 05:21:50 2006 @@ -1024,7 +1024,7 @@ static int save_long(Picklerobject *self, PyObject *args) { - int size; + Py_ssize_t size; int res = -1; PyObject *repr = NULL; @@ -1066,7 +1066,7 @@ * byte at the start, and cut it back later if possible. */ nbytes = (nbits >> 3) + 1; - if ((int)nbytes < 0 || (size_t)(int)nbytes != nbytes) { + if (nbytes > INT_MAX) { PyErr_SetString(PyExc_OverflowError, "long too large " "to pickle"); goto finally; @@ -1208,12 +1208,14 @@ c_str[1] = size; len = 2; } - else { + else if (size <= INT_MAX) { c_str[0] = BINSTRING; for (i = 1; i < 5; i++) c_str[i] = (int)(size >> ((i - 1) * 8)); len = 5; } + else + return -1; /* string too large */ if (self->write_func(self, c_str, len) < 0) return -1; @@ -1286,7 +1288,7 @@ static int save_unicode(Picklerobject *self, PyObject *args, int doput) { - int size, len; + Py_ssize_t size, len; PyObject *repr=0; if (!PyUnicode_Check(args)) @@ -1325,6 +1327,8 @@ if ((size = PyString_Size(repr)) < 0) goto err; + if (size > INT_MAX) + return -1; /* string too large */ c_str[0] = BINUNICODE; for (i = 1; i < 5; i++) Modified: python/branches/p3yk-noslice/Modules/cStringIO.c ============================================================================== --- python/branches/p3yk-noslice/Modules/cStringIO.c (original) +++ python/branches/p3yk-noslice/Modules/cStringIO.c Fri Dec 15 05:21:50 2006 @@ -289,7 +289,17 @@ if (!IO__opencheck(self)) return NULL; if (!PyArg_ParseTuple(args, "|n:truncate", &pos)) return NULL; - if (pos < 0) pos = self->pos; + + if (PyTuple_Size(args) == 0) { + /* No argument passed, truncate to current position */ + pos = self->pos; + } + + if (pos < 0) { + errno = EINVAL; + PyErr_SetFromErrno(PyExc_IOError); + return NULL; + } if (self->string_size > pos) self->string_size = pos; self->pos = self->string_size; @@ -657,11 +667,9 @@ char *buf; Py_ssize_t size; - if (PyObject_AsReadBuffer(s, (const void **)&buf, &size)) { - PyErr_Format(PyExc_TypeError, "expected read buffer, %.200s found", - s->ob_type->tp_name); + if (PyObject_AsCharBuffer(s, (const char **)&buf, &size) != 0) return NULL; - } + self = PyObject_New(Iobject, &Itype); if (!self) return NULL; Py_INCREF(s); Modified: python/branches/p3yk-noslice/Modules/cgen.py ============================================================================== --- python/branches/p3yk-noslice/Modules/cgen.py (original) +++ python/branches/p3yk-noslice/Modules/cgen.py Fri Dec 15 05:21:50 2006 @@ -148,7 +148,7 @@ # N*argN # N*retval # - if rest[:1] <> '[' or rest[-1:] <> ']': + if rest[:1] != '[' or rest[-1:] != ']': raise arg_error, ('subscript expected', rest) sub = rest[1:-1] # @@ -167,9 +167,9 @@ raise arg_error, ('\'*\' expected', sub) if sub == 'retval': # size is retval -- must be a reply argument - if mode <> 'r': + if mode != 'r': raise arg_error, ('non-r mode with [retval]', mode) - elif not isnum(sub) and (sub[:3] <> 'arg' or not isnum(sub[3:])): + elif not isnum(sub) and (sub[:3] != 'arg' or not isnum(sub[3:])): raise arg_error, ('bad subscript', sub) # return type, mode, num, sub @@ -218,7 +218,7 @@ # # Declare return value if any # - if type <> 'void': + if type != 'void': print '\t' + type, 'retval;' # # Declare arguments @@ -283,7 +283,7 @@ print '(!geti' + xtype + 'arraysize(args,', print repr(n_in_args) + ',', print repr(in_pos[j]) + ',', - if xtype <> a_type: + if xtype != a_type: print '('+xtype+' *)', print '&arg' + repr(i+1) + '))' print '\t\treturn NULL;' @@ -311,21 +311,21 @@ if a_factor and a_sub: print '*', if a_sub: print a_sub, print ',', - if (a_sub and a_factor) or xtype <> a_type: + if (a_sub and a_factor) or xtype != a_type: print '('+xtype+' *)', print 'arg' + repr(i+1) + '))' else: # Get a simple variable print '(!geti' + xtype + 'arg(args,', print repr(n_in_args) + ',', print repr(in_pos[i]) + ',', - if xtype <> a_type: + if xtype != a_type: print '('+xtype+' *)', print '&arg' + repr(i+1) + '))' print '\t\treturn NULL;' # # Begin of function call # - if type <> 'void': + if type != 'void': print '\tretval =', func + '(', else: print '\t' + func + '(', @@ -356,7 +356,7 @@ # # Multiple return values -- construct a tuple # - if type <> 'void': + if type != 'void': n_out_args = n_out_args + 1 if n_out_args == 1: for i in range(len(database)): @@ -372,7 +372,7 @@ print n_out_args, ');' print '\t if (v == NULL) return NULL;' i_out = 0 - if type <> 'void': + if type != 'void': print '\t PyTuple_SetItem(v,', print repr(i_out) + ',', print mkobject(type, 'retval') + ');' @@ -489,7 +489,7 @@ elif len(words) < 2: err('Line', lno, ': no funcname :', line) else: - if len(words) % 2 <> 0: + if len(words) % 2 != 0: err('Line', lno, ': odd argument list :', words[2:]) else: database = [] Modified: python/branches/p3yk-noslice/Modules/cjkcodecs/_codecs_cn.c ============================================================================== --- python/branches/p3yk-noslice/Modules/cjkcodecs/_codecs_cn.c (original) +++ python/branches/p3yk-noslice/Modules/cjkcodecs/_codecs_cn.c Fri Dec 15 05:21:50 2006 @@ -15,14 +15,26 @@ #undef hz #endif -#define GBK_PREDECODE(dc1, dc2, assi) \ +/* GBK and GB2312 map differently in few codepoints that are listed below: + * + * gb2312 gbk + * A1A4 U+30FB KATAKANA MIDDLE DOT U+00B7 MIDDLE DOT + * A1AA U+2015 HORIZONTAL BAR U+2014 EM DASH + * A844 undefined U+2015 HORIZONTAL BAR + */ + +#define GBK_DECODE(dc1, dc2, assi) \ if ((dc1) == 0xa1 && (dc2) == 0xaa) (assi) = 0x2014; \ else if ((dc1) == 0xa8 && (dc2) == 0x44) (assi) = 0x2015; \ - else if ((dc1) == 0xa1 && (dc2) == 0xa4) (assi) = 0x00b7; -#define GBK_PREENCODE(code, assi) \ + else if ((dc1) == 0xa1 && (dc2) == 0xa4) (assi) = 0x00b7; \ + else TRYMAP_DEC(gb2312, assi, dc1 ^ 0x80, dc2 ^ 0x80); \ + else TRYMAP_DEC(gbkext, assi, dc1, dc2); + +#define GBK_ENCODE(code, assi) \ if ((code) == 0x2014) (assi) = 0xa1aa; \ else if ((code) == 0x2015) (assi) = 0xa844; \ - else if ((code) == 0x00b7) (assi) = 0xa1a4; + else if ((code) == 0x00b7) (assi) = 0xa1a4; \ + else if ((code) != 0x30fb && TRYMAP_ENC_COND(gbcommon, assi, code)); /* * GB2312 codec @@ -99,8 +111,7 @@ REQUIRE_OUTBUF(2) - GBK_PREENCODE(c, code) - else TRYMAP_ENC(gbcommon, code, c); + GBK_ENCODE(c, code) else return 1; OUT1((code >> 8) | 0x80) @@ -129,9 +140,7 @@ REQUIRE_INBUF(2) - GBK_PREDECODE(c, IN2, **outbuf) - else TRYMAP_DEC(gb2312, **outbuf, c ^ 0x80, IN2 ^ 0x80); - else TRYMAP_DEC(gbkext, **outbuf, c, IN2); + GBK_DECODE(c, IN2, **outbuf) else return 2; NEXT(2, 1) @@ -187,9 +196,7 @@ REQUIRE_OUTBUF(2) - GBK_PREENCODE(c, code) - else TRYMAP_ENC(gbcommon, code, c); - else TRYMAP_ENC(gb18030ext, code, c); + GBK_ENCODE(c, code) else { const struct _gb18030_to_unibmp_ranges *utrrange; @@ -287,9 +294,7 @@ return 4; } - GBK_PREDECODE(c, c2, **outbuf) - else TRYMAP_DEC(gb2312, **outbuf, c ^ 0x80, c2 ^ 0x80); - else TRYMAP_DEC(gbkext, **outbuf, c, c2); + GBK_DECODE(c, c2, **outbuf) else TRYMAP_DEC(gb18030ext, **outbuf, c, c2); else return 2; Modified: python/branches/p3yk-noslice/Modules/cjkcodecs/_codecs_iso2022.c ============================================================================== --- python/branches/p3yk-noslice/Modules/cjkcodecs/_codecs_iso2022.c (original) +++ python/branches/p3yk-noslice/Modules/cjkcodecs/_codecs_iso2022.c Fri Dec 15 05:21:50 2006 @@ -592,9 +592,11 @@ { DBCHAR coded; assert(*length == 1); - TRYMAP_ENC(cp949, coded, *data) - if (!(coded & 0x8000)) - return coded; + if (*data < 0x10000) { + TRYMAP_ENC(cp949, coded, *data) + if (!(coded & 0x8000)) + return coded; + } return MAP_UNMAPPABLE; } @@ -628,11 +630,13 @@ { DBCHAR coded; assert(*length == 1); - if (*data == 0xff3c) /* F/W REVERSE SOLIDUS */ - return 0x2140; - else TRYMAP_ENC(jisxcommon, coded, *data) { - if (!(coded & 0x8000)) - return coded; + if (*data < 0x10000) { + if (*data == 0xff3c) /* F/W REVERSE SOLIDUS */ + return 0x2140; + else TRYMAP_ENC(jisxcommon, coded, *data) { + if (!(coded & 0x8000)) + return coded; + } } return MAP_UNMAPPABLE; } @@ -665,9 +669,11 @@ { DBCHAR coded; assert(*length == 1); - TRYMAP_ENC(jisxcommon, coded, *data) { - if (coded & 0x8000) - return coded & 0x7fff; + if (*data < 0x10000) { + TRYMAP_ENC(jisxcommon, coded, *data) { + if (coded & 0x8000) + return coded & 0x7fff; + } } return MAP_UNMAPPABLE; } @@ -854,7 +860,7 @@ if (coded == MAP_UNMAPPABLE || coded == MAP_MULTIPLE_AVAIL) return coded; else if (coded & 0x8000) - return coded; + return coded & 0x7fff; else return MAP_UNMAPPABLE; } @@ -901,7 +907,7 @@ if (coded == MAP_UNMAPPABLE || coded == MAP_MULTIPLE_AVAIL) return coded; else if (coded & 0x8000) - return coded; + return coded & 0x7fff; else return MAP_UNMAPPABLE; } @@ -970,9 +976,11 @@ { DBCHAR coded; assert(*length == 1); - TRYMAP_ENC(gbcommon, coded, *data) { - if (!(coded & 0x8000)) - return coded; + if (*data < 0x10000) { + TRYMAP_ENC(gbcommon, coded, *data) { + if (!(coded & 0x8000)) + return coded; + } } return MAP_UNMAPPABLE; } @@ -992,7 +1000,10 @@ /*-*- registry tables -*-*/ -#define REGISTRY_KSX1001 { CHARSET_KSX1001, 1, 2, \ +#define REGISTRY_KSX1001_G0 { CHARSET_KSX1001, 0, 2, \ + ksx1001_init, \ + ksx1001_decoder, ksx1001_encoder } +#define REGISTRY_KSX1001_G1 { CHARSET_KSX1001, 1, 2, \ ksx1001_init, \ ksx1001_decoder, ksx1001_encoder } #define REGISTRY_JISX0201_R { CHARSET_JISX0201_R, 0, 1, \ @@ -1034,7 +1045,7 @@ jisx0213_init, \ jisx0213_2004_2_decoder, \ jisx0213_2004_2_encoder } -#define REGISTRY_GB2312 { CHARSET_GB2312, 1, 2, \ +#define REGISTRY_GB2312 { CHARSET_GB2312, 0, 2, \ gb2312_init, \ gb2312_decoder, gb2312_encoder } #define REGISTRY_CNS11643_1 { CHARSET_CNS11643_1, 1, 2, \ @@ -1054,7 +1065,7 @@ }; static const struct iso2022_designation iso2022_kr_designations[] = { - REGISTRY_KSX1001, REGISTRY_SENTINEL + REGISTRY_KSX1001_G1, REGISTRY_SENTINEL }; CONFIGDEF(kr, 0) @@ -1071,7 +1082,7 @@ CONFIGDEF(jp_1, NO_SHIFT | USE_JISX0208_EXT) static const struct iso2022_designation iso2022_jp_2_designations[] = { - REGISTRY_JISX0208, REGISTRY_JISX0212, REGISTRY_KSX1001, + REGISTRY_JISX0208, REGISTRY_JISX0212, REGISTRY_KSX1001_G0, REGISTRY_GB2312, REGISTRY_JISX0201_R, REGISTRY_JISX0208_O, REGISTRY_ISO8859_1, REGISTRY_ISO8859_7, REGISTRY_SENTINEL }; Modified: python/branches/p3yk-noslice/Modules/cjkcodecs/cjkcodecs.h ============================================================================== --- python/branches/p3yk-noslice/Modules/cjkcodecs/cjkcodecs.h (original) +++ python/branches/p3yk-noslice/Modules/cjkcodecs/cjkcodecs.h Fri Dec 15 05:21:50 2006 @@ -159,29 +159,32 @@ #endif #define _TRYMAP_ENC(m, assi, val) \ - if ((m)->map != NULL && (val) >= (m)->bottom && \ + ((m)->map != NULL && (val) >= (m)->bottom && \ (val)<= (m)->top && ((assi) = (m)->map[(val) - \ (m)->bottom]) != NOCHAR) -#define TRYMAP_ENC(charset, assi, uni) \ +#define TRYMAP_ENC_COND(charset, assi, uni) \ _TRYMAP_ENC(&charset##_encmap[(uni) >> 8], assi, (uni) & 0xff) +#define TRYMAP_ENC(charset, assi, uni) \ + if TRYMAP_ENC_COND(charset, assi, uni) + #define _TRYMAP_DEC(m, assi, val) \ - if ((m)->map != NULL && (val) >= (m)->bottom && \ + ((m)->map != NULL && (val) >= (m)->bottom && \ (val)<= (m)->top && ((assi) = (m)->map[(val) - \ (m)->bottom]) != UNIINV) #define TRYMAP_DEC(charset, assi, c1, c2) \ - _TRYMAP_DEC(&charset##_decmap[c1], assi, c2) + if _TRYMAP_DEC(&charset##_decmap[c1], assi, c2) #define _TRYMAP_ENC_MPLANE(m, assplane, asshi, asslo, val) \ - if ((m)->map != NULL && (val) >= (m)->bottom && \ + ((m)->map != NULL && (val) >= (m)->bottom && \ (val)<= (m)->top && \ ((assplane) = (m)->map[((val) - (m)->bottom)*3]) != 0 && \ (((asshi) = (m)->map[((val) - (m)->bottom)*3 + 1]), 1) && \ (((asslo) = (m)->map[((val) - (m)->bottom)*3 + 2]), 1)) #define TRYMAP_ENC_MPLANE(charset, assplane, asshi, asslo, uni) \ - _TRYMAP_ENC_MPLANE(&charset##_encmap[(uni) >> 8], \ + if _TRYMAP_ENC_MPLANE(&charset##_encmap[(uni) >> 8], \ assplane, asshi, asslo, (uni) & 0xff) #define TRYMAP_DEC_MPLANE(charset, assi, plane, c1, c2) \ - _TRYMAP_DEC(&charset##_decmap[plane][c1], assi, c2) + if _TRYMAP_DEC(&charset##_decmap[plane][c1], assi, c2) #if Py_UNICODE_SIZE == 2 #define DECODE_SURROGATE(c) \ Modified: python/branches/p3yk-noslice/Modules/datetimemodule.c ============================================================================== --- python/branches/p3yk-noslice/Modules/datetimemodule.c (original) +++ python/branches/p3yk-noslice/Modules/datetimemodule.c Fri Dec 15 05:21:50 2006 @@ -1149,9 +1149,9 @@ PyObject *newfmt = NULL; /* py string, the output format */ char *pnew; /* pointer to available byte in output format */ - char totalnew; /* number bytes total in output format buffer, + int totalnew; /* number bytes total in output format buffer, exclusive of trailing \0 */ - char usednew; /* number bytes used so far in output format buffer */ + int usednew; /* number bytes used so far in output format buffer */ char *ptoappend; /* pointer to string to append to output buffer */ int ntoappend; /* # of bytes to append to output buffer */ @@ -1387,7 +1387,7 @@ * Miscellaneous helpers. */ -/* For obscure reasons, we need to use tp_richcompare instead of tp_compare. +/* For various reasons, we need to use tp_richcompare instead of tp_compare. * The comparisons here all most naturally compute a cmp()-like result. * This little helper turns that into a bool result for rich comparisons. */ @@ -1705,31 +1705,23 @@ return result; } -/* This is more natural as a tp_compare, but doesn't work then: for whatever - * reason, Python's try_3way_compare ignores tp_compare unless - * PyInstance_Check returns true, but these aren't old-style classes. - */ static PyObject * -delta_richcompare(PyDateTime_Delta *self, PyObject *other, int op) +delta_richcompare(PyObject *self, PyObject *other, int op) { - int diff = 42; /* nonsense */ - if (PyDelta_Check(other)) { - diff = GET_TD_DAYS(self) - GET_TD_DAYS(other); + int diff = GET_TD_DAYS(self) - GET_TD_DAYS(other); if (diff == 0) { diff = GET_TD_SECONDS(self) - GET_TD_SECONDS(other); if (diff == 0) diff = GET_TD_MICROSECONDS(self) - GET_TD_MICROSECONDS(other); } + return diff_to_bool(diff, op); + } + else { + Py_INCREF(Py_NotImplemented); + return Py_NotImplemented; } - else if (op == Py_EQ || op == Py_NE) - diff = 1; /* any non-zero value will do */ - - else /* stop this from falling back to address comparison */ - return cmperror((PyObject *)self, other); - - return diff_to_bool(diff, op); } static PyObject *delta_getstate(PyDateTime_Delta *self); @@ -1966,7 +1958,7 @@ } static int -delta_nonzero(PyDateTime_Delta *self) +delta_bool(PyDateTime_Delta *self) { return (GET_TD_DAYS(self) != 0 || GET_TD_SECONDS(self) != 0 @@ -2091,7 +2083,7 @@ (unaryfunc)delta_negative, /* nb_negative */ (unaryfunc)delta_positive, /* nb_positive */ (unaryfunc)delta_abs, /* nb_absolute */ - (inquiry)delta_nonzero, /* nb_nonzero */ + (inquiry)delta_bool, /* nb_bool */ 0, /*nb_invert*/ 0, /*nb_lshift*/ 0, /*nb_rshift*/ @@ -2145,7 +2137,7 @@ delta_doc, /* tp_doc */ 0, /* tp_traverse */ 0, /* tp_clear */ - (richcmpfunc)delta_richcompare, /* tp_richcompare */ + delta_richcompare, /* tp_richcompare */ 0, /* tp_weaklistoffset */ 0, /* tp_iter */ 0, /* tp_iternext */ @@ -2499,31 +2491,19 @@ /* Miscellaneous methods. */ -/* This is more natural as a tp_compare, but doesn't work then: for whatever - * reason, Python's try_3way_compare ignores tp_compare unless - * PyInstance_Check returns true, but these aren't old-style classes. - */ static PyObject * -date_richcompare(PyDateTime_Date *self, PyObject *other, int op) +date_richcompare(PyObject *self, PyObject *other, int op) { - int diff = 42; /* nonsense */ - - if (PyDate_Check(other)) - diff = memcmp(self->data, ((PyDateTime_Date *)other)->data, - _PyDateTime_DATE_DATASIZE); - - else if (PyObject_HasAttrString(other, "timetuple")) { - /* A hook for other kinds of date objects. */ + if (PyDate_Check(other)) { + int diff = memcmp(((PyDateTime_Date *)self)->data, + ((PyDateTime_Date *)other)->data, + _PyDateTime_DATE_DATASIZE); + return diff_to_bool(diff, op); + } + else { Py_INCREF(Py_NotImplemented); return Py_NotImplemented; } - else if (op == Py_EQ || op == Py_NE) - diff = 1; /* any non-zero value will do */ - - else /* stop this from falling back to address comparison */ - return cmperror((PyObject *)self, other); - - return diff_to_bool(diff, op); } static PyObject * @@ -2673,7 +2653,7 @@ 0, /* nb_negative */ 0, /* nb_positive */ 0, /* nb_absolute */ - 0, /* nb_nonzero */ + 0, /* nb_bool */ }; static PyTypeObject PyDateTime_DateType = { @@ -2701,7 +2681,7 @@ date_doc, /* tp_doc */ 0, /* tp_traverse */ 0, /* tp_clear */ - (richcmpfunc)date_richcompare, /* tp_richcompare */ + date_richcompare, /* tp_richcompare */ 0, /* tp_weaklistoffset */ 0, /* tp_iter */ 0, /* tp_iternext */ @@ -3223,28 +3203,19 @@ * Miscellaneous methods. */ -/* This is more natural as a tp_compare, but doesn't work then: for whatever - * reason, Python's try_3way_compare ignores tp_compare unless - * PyInstance_Check returns true, but these aren't old-style classes. - */ static PyObject * -time_richcompare(PyDateTime_Time *self, PyObject *other, int op) +time_richcompare(PyObject *self, PyObject *other, int op) { int diff; naivety n1, n2; int offset1, offset2; if (! PyTime_Check(other)) { - if (op == Py_EQ || op == Py_NE) { - PyObject *result = op == Py_EQ ? Py_False : Py_True; - Py_INCREF(result); - return result; - } - /* Stop this from falling back to address comparison. */ - return cmperror((PyObject *)self, other); + Py_INCREF(Py_NotImplemented); + return Py_NotImplemented; } - if (classify_two_utcoffsets((PyObject *)self, &offset1, &n1, Py_None, - other, &offset2, &n2, Py_None) < 0) + if (classify_two_utcoffsets(self, &offset1, &n1, Py_None, + other, &offset2, &n2, Py_None) < 0) return NULL; assert(n1 != OFFSET_UNKNOWN && n2 != OFFSET_UNKNOWN); /* If they're both naive, or both aware and have the same offsets, @@ -3252,7 +3223,8 @@ * offset2 == 0 at this point. */ if (n1 == n2 && offset1 == offset2) { - diff = memcmp(self->data, ((PyDateTime_Time *)other)->data, + diff = memcmp(((PyDateTime_Time *)self)->data, + ((PyDateTime_Time *)other)->data, _PyDateTime_TIME_DATASIZE); return diff_to_bool(diff, op); } @@ -3352,7 +3324,7 @@ } static int -time_nonzero(PyDateTime_Time *self) +time_bool(PyDateTime_Time *self) { int offset; int none; @@ -3446,7 +3418,7 @@ 0, /* nb_negative */ 0, /* nb_positive */ 0, /* nb_absolute */ - (inquiry)time_nonzero, /* nb_nonzero */ + (inquiry)time_bool, /* nb_bool */ }; static PyTypeObject PyDateTime_TimeType = { @@ -3474,7 +3446,7 @@ time_doc, /* tp_doc */ 0, /* tp_traverse */ 0, /* tp_clear */ - (richcmpfunc)time_richcompare, /* tp_richcompare */ + time_richcompare, /* tp_richcompare */ 0, /* tp_weaklistoffset */ 0, /* tp_iter */ 0, /* tp_iternext */ @@ -4115,46 +4087,34 @@ /* Miscellaneous methods. */ -/* This is more natural as a tp_compare, but doesn't work then: for whatever - * reason, Python's try_3way_compare ignores tp_compare unless - * PyInstance_Check returns true, but these aren't old-style classes. - */ static PyObject * -datetime_richcompare(PyDateTime_DateTime *self, PyObject *other, int op) +datetime_richcompare(PyObject *self, PyObject *other, int op) { int diff; naivety n1, n2; int offset1, offset2; if (! PyDateTime_Check(other)) { - /* If other has a "timetuple" attr, that's an advertised - * hook for other classes to ask to get comparison control. - * However, date instances have a timetuple attr, and we - * don't want to allow that comparison. Because datetime - * is a subclass of date, when mixing date and datetime - * in a comparison, Python gives datetime the first shot - * (it's the more specific subtype). So we can stop that - * combination here reliably. - */ - if (PyObject_HasAttrString(other, "timetuple") && - ! PyDate_Check(other)) { - /* A hook for other kinds of datetime objects. */ - Py_INCREF(Py_NotImplemented); - return Py_NotImplemented; - } - if (op == Py_EQ || op == Py_NE) { - PyObject *result = op == Py_EQ ? Py_False : Py_True; - Py_INCREF(result); - return result; - } - /* Stop this from falling back to address comparison. */ - return cmperror((PyObject *)self, other); - } - - if (classify_two_utcoffsets((PyObject *)self, &offset1, &n1, - (PyObject *)self, - other, &offset2, &n2, - other) < 0) + if (PyDate_Check(other)) { + /* Prevent invocation of date_richcompare. We want to + return NotImplemented here to give the other object + a chance. But since DateTime is a subclass of + Date, if the other object is a Date, it would + compute an ordering based on the date part alone, + and we don't want that. So force unequal or + uncomparable here in that case. */ + if (op == Py_EQ) + Py_RETURN_FALSE; + if (op == Py_NE) + Py_RETURN_TRUE; + return cmperror(self, other); + } + Py_INCREF(Py_NotImplemented); + return Py_NotImplemented; + } + + if (classify_two_utcoffsets(self, &offset1, &n1, self, + other, &offset2, &n2, other) < 0) return NULL; assert(n1 != OFFSET_UNKNOWN && n2 != OFFSET_UNKNOWN); /* If they're both naive, or both aware and have the same offsets, @@ -4162,7 +4122,8 @@ * offset2 == 0 at this point. */ if (n1 == n2 && offset1 == offset2) { - diff = memcmp(self->data, ((PyDateTime_DateTime *)other)->data, + diff = memcmp(((PyDateTime_DateTime *)self)->data, + ((PyDateTime_DateTime *)other)->data, _PyDateTime_DATETIME_DATASIZE); return diff_to_bool(diff, op); } @@ -4540,7 +4501,7 @@ 0, /* nb_negative */ 0, /* nb_positive */ 0, /* nb_absolute */ - 0, /* nb_nonzero */ + 0, /* nb_bool */ }; static PyTypeObject PyDateTime_DateTimeType = { @@ -4568,7 +4529,7 @@ datetime_doc, /* tp_doc */ 0, /* tp_traverse */ 0, /* tp_clear */ - (richcmpfunc)datetime_richcompare, /* tp_richcompare */ + datetime_richcompare, /* tp_richcompare */ 0, /* tp_weaklistoffset */ 0, /* tp_iter */ 0, /* tp_iternext */ Modified: python/branches/p3yk-noslice/Modules/dbmmodule.c ============================================================================== --- python/branches/p3yk-noslice/Modules/dbmmodule.c (original) +++ python/branches/p3yk-noslice/Modules/dbmmodule.c Fri Dec 15 05:21:50 2006 @@ -246,11 +246,13 @@ { datum key, val; PyObject *defvalue = Py_None; + char *tmp_ptr; int tmp_size; if (!PyArg_ParseTuple(args, "s#|O:get", - &key.dptr, &tmp_size, &defvalue)) + &tmp_ptr, &tmp_size, &defvalue)) return NULL; + key.dptr = tmp_ptr; key.dsize = tmp_size; check_dbmobject_open(dp); val = dbm_fetch(dp->di_dbm, key); @@ -267,11 +269,13 @@ { datum key, val; PyObject *defvalue = NULL; + char *tmp_ptr; int tmp_size; if (!PyArg_ParseTuple(args, "s#|S:setdefault", - &key.dptr, &tmp_size, &defvalue)) + &tmp_ptr, &tmp_size, &defvalue)) return NULL; + key.dptr = tmp_ptr; key.dsize = tmp_size; check_dbmobject_open(dp); val = dbm_fetch(dp->di_dbm, key); Modified: python/branches/p3yk-noslice/Modules/gcmodule.c ============================================================================== --- python/branches/p3yk-noslice/Modules/gcmodule.c (original) +++ python/branches/p3yk-noslice/Modules/gcmodule.c Fri Dec 15 05:21:50 2006 @@ -1153,6 +1153,7 @@ "disable() -- Disable automatic garbage collection.\n" "isenabled() -- Returns true if automatic collection is enabled.\n" "collect() -- Do a full collection right now.\n" +"get_count() -- Return the current collection counts.\n" "set_debug() -- Set debugging flags.\n" "get_debug() -- Get debugging flags.\n" "set_threshold() -- Set the collection thresholds.\n" Modified: python/branches/p3yk-noslice/Modules/itertoolsmodule.c ============================================================================== --- python/branches/p3yk-noslice/Modules/itertoolsmodule.c (original) +++ python/branches/p3yk-noslice/Modules/itertoolsmodule.c Fri Dec 15 05:21:50 2006 @@ -618,11 +618,15 @@ static PyObject * tee(PyObject *self, PyObject *args) { - int i, n=2; + Py_ssize_t i, n=2; PyObject *it, *iterable, *copyable, *result; - if (!PyArg_ParseTuple(args, "O|i", &iterable, &n)) + if (!PyArg_ParseTuple(args, "O|n", &iterable, &n)) return NULL; + if (n < 0) { + PyErr_SetString(PyExc_ValueError, "n must be >= 0"); + return NULL; + } result = PyTuple_New(n); if (result == NULL) return NULL; @@ -2068,7 +2072,7 @@ static PyObject * count_next(countobject *lz) { - return PyInt_FromSize_t(lz->cnt++); + return PyInt_FromSsize_t(lz->cnt++); } static PyObject * Modified: python/branches/p3yk-noslice/Modules/linuxaudiodev.c ============================================================================== --- python/branches/p3yk-noslice/Modules/linuxaudiodev.c (original) +++ python/branches/p3yk-noslice/Modules/linuxaudiodev.c Fri Dec 15 05:21:50 2006 @@ -28,7 +28,9 @@ #if defined(linux) #include +#ifndef HAVE_STDINT_H typedef unsigned long uint32_t; +#endif #elif defined(__FreeBSD__) #include Modified: python/branches/p3yk-noslice/Modules/main.c ============================================================================== --- python/branches/p3yk-noslice/Modules/main.c (original) +++ python/branches/p3yk-noslice/Modules/main.c Fri Dec 15 05:21:50 2006 @@ -59,31 +59,32 @@ static char *usage_1 = "\ Options and arguments (and corresponding environment variables):\n\ -c cmd : program passed in as string (terminates option list)\n\ --d : debug output from parser (also PYTHONDEBUG=x)\n\ +-d : debug output from parser; also PYTHONDEBUG=x\n\ -E : ignore environment variables (such as PYTHONPATH)\n\ -h : print this help message and exit (also --help)\n\ --i : inspect interactively after running script, (also PYTHONINSPECT=x)\n\ - and force prompts, even if stdin does not appear to be a terminal\n\ +-i : inspect interactively after running script; forces a prompt even\n\ + if stdin does not appear to be a terminal; also PYTHONINSPECT=x\n\ "; static char *usage_2 = "\ -m mod : run library module as a script (terminates option list)\n\ --O : optimize generated bytecode (a tad; also PYTHONOPTIMIZE=x)\n\ +-O : optimize generated bytecode slightly; also PYTHONOPTIMIZE=x\n\ -OO : remove doc-strings in addition to the -O optimizations\n\ -S : don't imply 'import site' on initialization\n\ -t : issue warnings about inconsistent tab usage (-tt: issue errors)\n\ --u : unbuffered binary stdout and stderr (also PYTHONUNBUFFERED=x)\n\ +-u : unbuffered binary stdout and stderr; also PYTHONUNBUFFERED=x\n\ "; static char *usage_3 = "\ see man page for details on internal buffering relating to '-u'\n\ --v : verbose (trace import statements) (also PYTHONVERBOSE=x)\n\ +-v : verbose (trace import statements); also PYTHONVERBOSE=x\n\ + can be supplied multiple times to increase verbosity\n\ -V : print the Python version number and exit (also --version)\n\ --W arg : warning control (arg is action:message:category:module:lineno)\n\ +-W arg : warning control; arg is action:message:category:module:lineno\n\ -x : skip first line of source, allowing use of non-Unix forms of #!cmd\n\ file : program read from script file\n\ - : program read from stdin (default; interactive mode if a tty)\n\ "; static char *usage_4 = "\ -arg ...: arguments passed to program in sys.argv[1:]\n\ +arg ...: arguments passed to program in sys.argv[1:]\n\n\ Other environment variables:\n\ PYTHONSTARTUP: file executed on interactive startup (no default)\n\ PYTHONPATH : '%c'-separated list of directories prefixed to the\n\ Modified: python/branches/p3yk-noslice/Modules/mathmodule.c ============================================================================== --- python/branches/p3yk-noslice/Modules/mathmodule.c (original) +++ python/branches/p3yk-noslice/Modules/mathmodule.c Fri Dec 15 05:21:50 2006 @@ -48,10 +48,10 @@ } static PyObject * -math_1(PyObject *args, double (*func) (double), char *argsfmt) +math_1(PyObject *arg, double (*func) (double)) { - double x; - if (! PyArg_ParseTuple(args, argsfmt, &x)) + double x = PyFloat_AsDouble(arg); + if (x == -1.0 && PyErr_Occurred()) return NULL; errno = 0; PyFPE_START_PROTECT("in math_1", return 0) @@ -65,10 +65,15 @@ } static PyObject * -math_2(PyObject *args, double (*func) (double, double), char *argsfmt) +math_2(PyObject *args, double (*func) (double, double), char *funcname) { + PyObject *ox, *oy; double x, y; - if (! PyArg_ParseTuple(args, argsfmt, &x, &y)) + if (! PyArg_UnpackTuple(args, funcname, 2, 2, &ox, &oy)) + return NULL; + x = PyFloat_AsDouble(ox); + y = PyFloat_AsDouble(oy); + if ((x == -1.0 || y == -1.0) && PyErr_Occurred()) return NULL; errno = 0; PyFPE_START_PROTECT("in math_2", return 0) @@ -83,13 +88,13 @@ #define FUNC1(funcname, func, docstring) \ static PyObject * math_##funcname(PyObject *self, PyObject *args) { \ - return math_1(args, func, "d:" #funcname); \ + return math_1(args, func); \ }\ PyDoc_STRVAR(math_##funcname##_doc, docstring); #define FUNC2(funcname, func, docstring) \ static PyObject * math_##funcname(PyObject *self, PyObject *args) { \ - return math_2(args, func, "dd:" #funcname); \ + return math_2(args, func, #funcname); \ }\ PyDoc_STRVAR(math_##funcname##_doc, docstring); @@ -135,11 +140,11 @@ "tanh(x)\n\nReturn the hyperbolic tangent of x.") static PyObject * -math_frexp(PyObject *self, PyObject *args) +math_frexp(PyObject *self, PyObject *arg) { - double x; int i; - if (! PyArg_ParseTuple(args, "d:frexp", &x)) + double x = PyFloat_AsDouble(arg); + if (x == -1.0 && PyErr_Occurred()) return NULL; errno = 0; x = frexp(x, &i); @@ -179,10 +184,10 @@ "ldexp(x, i) -> x * (2**i)"); static PyObject * -math_modf(PyObject *self, PyObject *args) +math_modf(PyObject *self, PyObject *arg) { - double x, y; - if (! PyArg_ParseTuple(args, "d:modf", &x)) + double y, x = PyFloat_AsDouble(arg); + if (x == -1.0 && PyErr_Occurred()) return NULL; errno = 0; x = modf(x, &y); @@ -208,7 +213,7 @@ */ static PyObject* -loghelper(PyObject* args, double (*func)(double), char *format, PyObject *arg) +loghelper(PyObject* arg, double (*func)(double), char *funcname) { /* If it is long, do it ourselves. */ if (PyLong_Check(arg)) { @@ -229,7 +234,7 @@ } /* Else let libm handle it by itself. */ - return math_1(args, func, format); + return math_1(arg, func); } static PyObject * @@ -239,28 +244,15 @@ PyObject *base = NULL; PyObject *num, *den; PyObject *ans; - PyObject *newargs; if (!PyArg_UnpackTuple(args, "log", 1, 2, &arg, &base)) return NULL; - if (base == NULL) - return loghelper(args, log, "d:log", arg); - newargs = PyTuple_Pack(1, arg); - if (newargs == NULL) - return NULL; - num = loghelper(newargs, log, "d:log", arg); - Py_DECREF(newargs); - if (num == NULL) - return NULL; + num = loghelper(arg, log, "log"); + if (num == NULL || base == NULL) + return num; - newargs = PyTuple_Pack(1, base); - if (newargs == NULL) { - Py_DECREF(num); - return NULL; - } - den = loghelper(newargs, log, "d:log", base); - Py_DECREF(newargs); + den = loghelper(base, log, "log"); if (den == NULL) { Py_DECREF(num); return NULL; @@ -277,25 +269,23 @@ If the base not specified, returns the natural logarithm (base e) of x."); static PyObject * -math_log10(PyObject *self, PyObject *args) +math_log10(PyObject *self, PyObject *arg) { - PyObject *arg; - - if (!PyArg_UnpackTuple(args, "log10", 1, 1, &arg)) - return NULL; - return loghelper(args, log10, "d:log10", arg); + return loghelper(arg, log10, "log10"); } PyDoc_STRVAR(math_log10_doc, "log10(x) -> the base 10 logarithm of x."); +/* XXX(nnorwitz): Should we use the platform M_PI or something more accurate + like: 3.14159265358979323846264338327950288 */ static const double degToRad = 3.141592653589793238462643383 / 180.0; static PyObject * -math_degrees(PyObject *self, PyObject *args) +math_degrees(PyObject *self, PyObject *arg) { - double x; - if (! PyArg_ParseTuple(args, "d:degrees", &x)) + double x = PyFloat_AsDouble(arg); + if (x == -1.0 && PyErr_Occurred()) return NULL; return PyFloat_FromDouble(x / degToRad); } @@ -304,10 +294,10 @@ "degrees(x) -> converts angle x from radians to degrees"); static PyObject * -math_radians(PyObject *self, PyObject *args) +math_radians(PyObject *self, PyObject *arg) { - double x; - if (! PyArg_ParseTuple(args, "d:radians", &x)) + double x = PyFloat_AsDouble(arg); + if (x == -1.0 && PyErr_Occurred()) return NULL; return PyFloat_FromDouble(x * degToRad); } @@ -316,31 +306,31 @@ "radians(x) -> converts angle x from degrees to radians"); static PyMethodDef math_methods[] = { - {"acos", math_acos, METH_VARARGS, math_acos_doc}, - {"asin", math_asin, METH_VARARGS, math_asin_doc}, - {"atan", math_atan, METH_VARARGS, math_atan_doc}, + {"acos", math_acos, METH_O, math_acos_doc}, + {"asin", math_asin, METH_O, math_asin_doc}, + {"atan", math_atan, METH_O, math_atan_doc}, {"atan2", math_atan2, METH_VARARGS, math_atan2_doc}, - {"ceil", math_ceil, METH_VARARGS, math_ceil_doc}, - {"cos", math_cos, METH_VARARGS, math_cos_doc}, - {"cosh", math_cosh, METH_VARARGS, math_cosh_doc}, - {"degrees", math_degrees, METH_VARARGS, math_degrees_doc}, - {"exp", math_exp, METH_VARARGS, math_exp_doc}, - {"fabs", math_fabs, METH_VARARGS, math_fabs_doc}, - {"floor", math_floor, METH_VARARGS, math_floor_doc}, + {"ceil", math_ceil, METH_O, math_ceil_doc}, + {"cos", math_cos, METH_O, math_cos_doc}, + {"cosh", math_cosh, METH_O, math_cosh_doc}, + {"degrees", math_degrees, METH_O, math_degrees_doc}, + {"exp", math_exp, METH_O, math_exp_doc}, + {"fabs", math_fabs, METH_O, math_fabs_doc}, + {"floor", math_floor, METH_O, math_floor_doc}, {"fmod", math_fmod, METH_VARARGS, math_fmod_doc}, - {"frexp", math_frexp, METH_VARARGS, math_frexp_doc}, + {"frexp", math_frexp, METH_O, math_frexp_doc}, {"hypot", math_hypot, METH_VARARGS, math_hypot_doc}, {"ldexp", math_ldexp, METH_VARARGS, math_ldexp_doc}, {"log", math_log, METH_VARARGS, math_log_doc}, - {"log10", math_log10, METH_VARARGS, math_log10_doc}, - {"modf", math_modf, METH_VARARGS, math_modf_doc}, + {"log10", math_log10, METH_O, math_log10_doc}, + {"modf", math_modf, METH_O, math_modf_doc}, {"pow", math_pow, METH_VARARGS, math_pow_doc}, - {"radians", math_radians, METH_VARARGS, math_radians_doc}, - {"sin", math_sin, METH_VARARGS, math_sin_doc}, - {"sinh", math_sinh, METH_VARARGS, math_sinh_doc}, - {"sqrt", math_sqrt, METH_VARARGS, math_sqrt_doc}, - {"tan", math_tan, METH_VARARGS, math_tan_doc}, - {"tanh", math_tanh, METH_VARARGS, math_tanh_doc}, + {"radians", math_radians, METH_O, math_radians_doc}, + {"sin", math_sin, METH_O, math_sin_doc}, + {"sinh", math_sinh, METH_O, math_sinh_doc}, + {"sqrt", math_sqrt, METH_O, math_sqrt_doc}, + {"tan", math_tan, METH_O, math_tan_doc}, + {"tanh", math_tanh, METH_O, math_tanh_doc}, {NULL, NULL} /* sentinel */ }; @@ -358,6 +348,8 @@ if (m == NULL) goto finally; d = PyModule_GetDict(m); + if (d == NULL) + goto finally; if (!(v = PyFloat_FromDouble(atan(1.0) * 4.0))) goto finally; Modified: python/branches/p3yk-noslice/Modules/mmapmodule.c ============================================================================== --- python/branches/p3yk-noslice/Modules/mmapmodule.c (original) +++ python/branches/p3yk-noslice/Modules/mmapmodule.c Fri Dec 15 05:21:50 2006 @@ -470,7 +470,7 @@ mmap_tell_method(mmap_object *self, PyObject *unused) { CHECK_VALID(NULL); - return PyInt_FromLong((long) self->pos); + return PyInt_FromSize_t(self->pos); } static PyObject * Modified: python/branches/p3yk-noslice/Modules/ossaudiodev.c ============================================================================== --- python/branches/p3yk-noslice/Modules/ossaudiodev.c (original) +++ python/branches/p3yk-noslice/Modules/ossaudiodev.c Fri Dec 15 05:21:50 2006 @@ -34,7 +34,9 @@ #if defined(linux) +#ifndef HAVE_STDINT_H typedef unsigned long uint32_t; +#endif #elif defined(__FreeBSD__) Modified: python/branches/p3yk-noslice/Modules/parsermodule.c ============================================================================== --- python/branches/p3yk-noslice/Modules/parsermodule.c (original) +++ python/branches/p3yk-noslice/Modules/parsermodule.c Fri Dec 15 05:21:50 2006 @@ -74,7 +74,8 @@ node2tuple(node *n, /* node to convert */ SeqMaker mkseq, /* create sequence */ SeqInserter addelem, /* func. to add elem. in seq. */ - int lineno) /* include line numbers? */ + int lineno, /* include line numbers? */ + int col_offset) /* include column offsets? */ { if (n == NULL) { Py_INCREF(Py_None); @@ -95,7 +96,7 @@ } (void) addelem(v, 0, w); for (i = 0; i < NCH(n); i++) { - w = node2tuple(CHILD(n, i), mkseq, addelem, lineno); + w = node2tuple(CHILD(n, i), mkseq, addelem, lineno, col_offset); if (w == NULL) { Py_DECREF(v); return ((PyObject*) NULL); @@ -108,12 +109,14 @@ return (v); } else if (ISTERMINAL(TYPE(n))) { - PyObject *result = mkseq(2 + lineno); + PyObject *result = mkseq(2 + lineno + col_offset); if (result != NULL) { (void) addelem(result, 0, PyInt_FromLong(TYPE(n))); (void) addelem(result, 1, PyString_FromString(STR(n))); if (lineno == 1) (void) addelem(result, 2, PyInt_FromLong(n->n_lineno)); + if (col_offset == 1) + (void) addelem(result, 3, PyInt_FromLong(n->n_col_offset)); } return (result); } @@ -289,29 +292,35 @@ parser_st2tuple(PyST_Object *self, PyObject *args, PyObject *kw) { PyObject *line_option = 0; + PyObject *col_option = 0; PyObject *res = 0; int ok; - static char *keywords[] = {"ast", "line_info", NULL}; + static char *keywords[] = {"ast", "line_info", "col_info", NULL}; if (self == NULL) { - ok = PyArg_ParseTupleAndKeywords(args, kw, "O!|O:st2tuple", keywords, - &PyST_Type, &self, &line_option); + ok = PyArg_ParseTupleAndKeywords(args, kw, "O!|OO:st2tuple", keywords, + &PyST_Type, &self, &line_option, + &col_option); } else - ok = PyArg_ParseTupleAndKeywords(args, kw, "|O:totuple", &keywords[1], - &line_option); + ok = PyArg_ParseTupleAndKeywords(args, kw, "|OO:totuple", &keywords[1], + &line_option, &col_option); if (ok != 0) { int lineno = 0; + int col_offset = 0; if (line_option != NULL) { lineno = (PyObject_IsTrue(line_option) != 0) ? 1 : 0; } + if (col_option != NULL) { + col_offset = (PyObject_IsTrue(col_option) != 0) ? 1 : 0; + } /* * Convert ST into a tuple representation. Use Guido's function, * since it's known to work already. */ res = node2tuple(((PyST_Object*)self)->st_node, - PyTuple_New, PyTuple_SetItem, lineno); + PyTuple_New, PyTuple_SetItem, lineno, col_offset); } return (res); } @@ -327,28 +336,34 @@ parser_st2list(PyST_Object *self, PyObject *args, PyObject *kw) { PyObject *line_option = 0; + PyObject *col_option = 0; PyObject *res = 0; int ok; - static char *keywords[] = {"ast", "line_info", NULL}; + static char *keywords[] = {"ast", "line_info", "col_info", NULL}; if (self == NULL) - ok = PyArg_ParseTupleAndKeywords(args, kw, "O!|O:st2list", keywords, - &PyST_Type, &self, &line_option); + ok = PyArg_ParseTupleAndKeywords(args, kw, "O!|OO:st2list", keywords, + &PyST_Type, &self, &line_option, + &col_option); else - ok = PyArg_ParseTupleAndKeywords(args, kw, "|O:tolist", &keywords[1], - &line_option); + ok = PyArg_ParseTupleAndKeywords(args, kw, "|OO:tolist", &keywords[1], + &line_option, &col_option); if (ok) { int lineno = 0; + int col_offset = 0; if (line_option != 0) { lineno = PyObject_IsTrue(line_option) ? 1 : 0; } + if (col_option != NULL) { + col_offset = (PyObject_IsTrue(col_option) != 0) ? 1 : 0; + } /* * Convert ST into a tuple representation. Use Guido's function, * since it's known to work already. */ res = node2tuple(self->st_node, - PyList_New, PyList_SetItem, lineno); + PyList_New, PyList_SetItem, lineno, col_offset); } return (res); } @@ -848,7 +863,7 @@ VALIDATER(import_name); VALIDATER(import_from); VALIDATER(global_stmt); VALIDATER(list_if); VALIDATER(assert_stmt); VALIDATER(list_for); -VALIDATER(exec_stmt); VALIDATER(compound_stmt); +VALIDATER(compound_stmt); VALIDATER(while); VALIDATER(for); VALIDATER(try); VALIDATER(except_clause); VALIDATER(test); VALIDATER(and_test); @@ -860,7 +875,7 @@ VALIDATER(atom); VALIDATER(lambdef); VALIDATER(trailer); VALIDATER(subscript); VALIDATER(subscriptlist); VALIDATER(sliceop); -VALIDATER(exprlist); VALIDATER(dictmaker); +VALIDATER(exprlist); VALIDATER(dictsetmaker); VALIDATER(arglist); VALIDATER(argument); VALIDATER(listmaker); VALIDATER(yield_stmt); VALIDATER(testlist1); VALIDATER(gen_for); @@ -1105,13 +1120,13 @@ } -/* '*' NAME [',' '**' NAME] | '**' NAME +/* '*' [NAME] (',' NAME ['=' test])* [',' '**' NAME] | '**' NAME */ static int validate_varargslist_trailer(node *tree, int start) { int nch = NCH(tree); - int res = 0; + int res = 0, i; int sym; if (nch <= start) { @@ -1121,15 +1136,40 @@ sym = TYPE(CHILD(tree, start)); if (sym == STAR) { /* - * ('*' NAME [',' '**' NAME] + * '*' [NAME] (',' NAME ['=' test])* [',' '**' NAME] | '**' NAME */ if (nch-start == 2) res = validate_name(CHILD(tree, start+1), NULL); - else if (nch-start == 5) + else if (nch-start == 5 && TYPE(CHILD(tree, start+2)) == COMMA) res = (validate_name(CHILD(tree, start+1), NULL) && validate_comma(CHILD(tree, start+2)) && validate_doublestar(CHILD(tree, start+3)) && validate_name(CHILD(tree, start+4), NULL)); + else { + /* skip over [NAME] (',' NAME ['=' test])* */ + i = start + 1; + if (TYPE(CHILD(tree, i)) == NAME) { /* skip over [NAME] */ + i += 1; + } + while (res && i+1 < nch) { /* validate (',' NAME ['=' test])* */ + res = validate_comma(CHILD(tree, i)); + if (TYPE(CHILD(tree, i+1)) == DOUBLESTAR) + break; + res = res && validate_name(CHILD(tree, i+1), NULL); + if (res && i+2 < nch && TYPE(CHILD(tree, i+2)) == EQUAL) { + res = res && (i+3 < nch) + && validate_test(CHILD(tree, i+3)); + i += 4; + } + else { + i += 2; + } + } + /* [',' '**' NAME] */ + if (res && i+1 < nch && TYPE(CHILD(tree, i+1)) == DOUBLESTAR) { + res = validate_name(CHILD(tree, i+2), NULL); + } + } } else if (sym == DOUBLESTAR) { /* @@ -1148,9 +1188,8 @@ * * varargslist: * (fpdef ['=' test] ',')* - * ('*' NAME [',' '**' NAME] - * | '**' NAME) - * | fpdef ['=' test] (',' fpdef ['=' test])* [','] + * ('*' [NAME] (',' NAME ['=' test])* [',' '**' NAME] | '**' NAME) + * | fpdef ['=' test] (',' fpdef ['=' test])* [','] * */ static int @@ -1169,7 +1208,7 @@ sym = TYPE(CHILD(tree, 0)); if (sym == STAR || sym == DOUBLESTAR) /* whole thing matches: - * '*' NAME [',' '**' NAME] | '**' NAME + * '*' [NAME] (',' NAME ['=' test])* [',' '**' NAME] | '**' NAME */ res = validate_varargslist_trailer(tree, 0); else if (sym == fpdef) { @@ -1201,7 +1240,7 @@ break; } } - /* ... '*' NAME [',' '**' NAME] | '**' NAME + /* .. ('*' [NAME] (',' NAME ['=' test])* [',' '**' NAME] | '**' NAME) * i --^^^ */ if (res) @@ -1465,8 +1504,7 @@ || (ntype == flow_stmt) || (ntype == import_stmt) || (ntype == global_stmt) - || (ntype == assert_stmt) - || (ntype == exec_stmt)) + || (ntype == assert_stmt)) res = validate_node(CHILD(tree, 0)); else { res = 0; @@ -1888,32 +1926,6 @@ } -/* exec_stmt: - * - * 'exec' expr ['in' test [',' test]] - */ -static int -validate_exec_stmt(node *tree) -{ - int nch = NCH(tree); - int res = (validate_ntype(tree, exec_stmt) - && ((nch == 2) || (nch == 4) || (nch == 6)) - && validate_name(CHILD(tree, 0), "exec") - && validate_expr(CHILD(tree, 1))); - - if (!res && !PyErr_Occurred()) - err_string("illegal exec statement"); - if (res && (nch > 2)) - res = (validate_name(CHILD(tree, 2), "in") - && validate_test(CHILD(tree, 3))); - if (res && (nch == 6)) - res = (validate_comma(CHILD(tree, 4)) - && validate_test(CHILD(tree, 5))); - - return (res); -} - - /* assert_stmt: * * 'assert' test [',' test] @@ -2402,12 +2414,7 @@ && validate_ntype(CHILD(tree, nch - 1), RBRACE)); if (res && (nch == 3)) - res = validate_dictmaker(CHILD(tree, 1)); - break; - case BACKQUOTE: - res = ((nch == 3) - && validate_testlist1(CHILD(tree, 1)) - && validate_ntype(CHILD(tree, 2), BACKQUOTE)); + res = validate_dictsetmaker(CHILD(tree, 1)); break; case NAME: case NUMBER: @@ -2417,6 +2424,11 @@ for (pos = 1; res && (pos < nch); ++pos) res = validate_ntype(CHILD(tree, pos), STRING); break; + case DOT: + res = (nch == 3 && + validate_ntype(CHILD(tree, 1), DOT) && + validate_ntype(CHILD(tree, 2), DOT)); + break; default: res = 0; break; @@ -2843,10 +2855,10 @@ static int -validate_dictmaker(node *tree) +validate_dictsetmaker(node *tree) { int nch = NCH(tree); - int res = (validate_ntype(tree, dictmaker) + int res = (validate_ntype(tree, dictsetmaker) && (nch >= 3) && validate_test(CHILD(tree, 0)) && validate_colon(CHILD(tree, 1)) @@ -2919,7 +2931,7 @@ case small_stmt: /* * expr_stmt | print_stmt | del_stmt | pass_stmt | flow_stmt - * | import_stmt | global_stmt | exec_stmt | assert_stmt + * | import_stmt | global_stmt | assert_stmt */ res = validate_small_stmt(tree); break; @@ -2989,9 +3001,6 @@ case global_stmt: res = validate_global_stmt(tree); break; - case exec_stmt: - res = validate_exec_stmt(tree); - break; case assert_stmt: res = validate_assert_stmt(tree); break; Modified: python/branches/p3yk-noslice/Modules/posixmodule.c ============================================================================== --- python/branches/p3yk-noslice/Modules/posixmodule.c (original) +++ python/branches/p3yk-noslice/Modules/posixmodule.c Fri Dec 15 05:21:50 2006 @@ -792,7 +792,7 @@ /* XXX endianness */ __int64 out; out = time_in + secs_between_epochs; - out = out * 10000000 + nsec_in; + out = out * 10000000 + nsec_in / 100; memcpy(out_ptr, &out, sizeof(out)); } @@ -828,6 +828,106 @@ return 0; } +/* Emulate GetFileAttributesEx[AW] on Windows 95 */ +static int checked = 0; +static BOOL (CALLBACK *gfaxa)(LPCSTR, GET_FILEEX_INFO_LEVELS, LPVOID); +static BOOL (CALLBACK *gfaxw)(LPCWSTR, GET_FILEEX_INFO_LEVELS, LPVOID); +static void +check_gfax() +{ + HINSTANCE hKernel32; + if (checked) + return; + checked = 1; + hKernel32 = GetModuleHandle("KERNEL32"); + *(FARPROC*)&gfaxa = GetProcAddress(hKernel32, "GetFileAttributesExA"); + *(FARPROC*)&gfaxw = GetProcAddress(hKernel32, "GetFileAttributesExW"); +} + +static BOOL WINAPI +Py_GetFileAttributesExA(LPCSTR pszFile, + GET_FILEEX_INFO_LEVELS level, + LPVOID pv) +{ + BOOL result; + HANDLE hFindFile; + WIN32_FIND_DATAA FileData; + LPWIN32_FILE_ATTRIBUTE_DATA pfad = pv; + /* First try to use the system's implementation, if that is + available and either succeeds to gives an error other than + that it isn't implemented. */ + check_gfax(); + if (gfaxa) { + result = gfaxa(pszFile, level, pv); + if (result || GetLastError() != ERROR_CALL_NOT_IMPLEMENTED) + return result; + } + /* It's either not present, or not implemented. + Emulate using FindFirstFile. */ + if (level != GetFileExInfoStandard) { + SetLastError(ERROR_INVALID_PARAMETER); + return FALSE; + } + /* Use GetFileAttributes to validate that the file name + does not contain wildcards (which FindFirstFile would + accept). */ + if (GetFileAttributesA(pszFile) == 0xFFFFFFFF) + return FALSE; + hFindFile = FindFirstFileA(pszFile, &FileData); + if (hFindFile == INVALID_HANDLE_VALUE) + return FALSE; + FindClose(hFindFile); + pfad->dwFileAttributes = FileData.dwFileAttributes; + pfad->ftCreationTime = FileData.ftCreationTime; + pfad->ftLastAccessTime = FileData.ftLastAccessTime; + pfad->ftLastWriteTime = FileData.ftLastWriteTime; + pfad->nFileSizeHigh = FileData.nFileSizeHigh; + pfad->nFileSizeLow = FileData.nFileSizeLow; + return TRUE; +} + +static BOOL WINAPI +Py_GetFileAttributesExW(LPCWSTR pszFile, + GET_FILEEX_INFO_LEVELS level, + LPVOID pv) +{ + BOOL result; + HANDLE hFindFile; + WIN32_FIND_DATAW FileData; + LPWIN32_FILE_ATTRIBUTE_DATA pfad = pv; + /* First try to use the system's implementation, if that is + available and either succeeds to gives an error other than + that it isn't implemented. */ + check_gfax(); + if (gfaxa) { + result = gfaxw(pszFile, level, pv); + if (result || GetLastError() != ERROR_CALL_NOT_IMPLEMENTED) + return result; + } + /* It's either not present, or not implemented. + Emulate using FindFirstFile. */ + if (level != GetFileExInfoStandard) { + SetLastError(ERROR_INVALID_PARAMETER); + return FALSE; + } + /* Use GetFileAttributes to validate that the file name + does not contain wildcards (which FindFirstFile would + accept). */ + if (GetFileAttributesW(pszFile) == 0xFFFFFFFF) + return FALSE; + hFindFile = FindFirstFileW(pszFile, &FileData); + if (hFindFile == INVALID_HANDLE_VALUE) + return FALSE; + FindClose(hFindFile); + pfad->dwFileAttributes = FileData.dwFileAttributes; + pfad->ftCreationTime = FileData.ftCreationTime; + pfad->ftLastAccessTime = FileData.ftLastAccessTime; + pfad->ftLastWriteTime = FileData.ftLastWriteTime; + pfad->nFileSizeHigh = FileData.nFileSizeHigh; + pfad->nFileSizeLow = FileData.nFileSizeLow; + return TRUE; +} + static int win32_stat(const char* path, struct win32_stat *result) { @@ -835,7 +935,7 @@ int code; char *dot; /* XXX not supported on Win95 and NT 3.x */ - if (!GetFileAttributesExA(path, GetFileExInfoStandard, &info)) { + if (!Py_GetFileAttributesExA(path, GetFileExInfoStandard, &info)) { /* Protocol violation: we explicitly clear errno, instead of setting it to a POSIX error. Callers should use GetLastError. */ errno = 0; @@ -863,7 +963,7 @@ const wchar_t *dot; WIN32_FILE_ATTRIBUTE_DATA info; /* XXX not supported on Win95 and NT 3.x */ - if (!GetFileAttributesExW(path, GetFileExInfoStandard, &info)) { + if (!Py_GetFileAttributesExW(path, GetFileExInfoStandard, &info)) { /* Protocol violation: we explicitly clear errno, instead of setting it to a POSIX error. Callers should use GetLastError. */ errno = 0; @@ -2458,7 +2558,8 @@ wpath = PyUnicode_AS_UNICODE(obwpath); Py_BEGIN_ALLOW_THREADS hFile = CreateFileW(wpath, FILE_WRITE_ATTRIBUTES, 0, - NULL, OPEN_EXISTING, 0, NULL); + NULL, OPEN_EXISTING, + FILE_FLAG_BACKUP_SEMANTICS, NULL); Py_END_ALLOW_THREADS if (hFile == INVALID_HANDLE_VALUE) return win32_error_unicode("utime", wpath); @@ -2473,7 +2574,8 @@ return NULL; Py_BEGIN_ALLOW_THREADS hFile = CreateFileA(apath, FILE_WRITE_ATTRIBUTES, 0, - NULL, OPEN_EXISTING, 0, NULL); + NULL, OPEN_EXISTING, + FILE_FLAG_BACKUP_SEMANTICS, NULL); Py_END_ALLOW_THREADS if (hFile == INVALID_HANDLE_VALUE) { win32_error("utime", apath); @@ -2501,11 +2603,11 @@ if (extract_time(PyTuple_GET_ITEM(arg, 0), &atimesec, &ausec) == -1) goto done; - time_t_to_FILE_TIME(atimesec, ausec, &atime); + time_t_to_FILE_TIME(atimesec, 1000*ausec, &atime); if (extract_time(PyTuple_GET_ITEM(arg, 1), &mtimesec, &musec) == -1) goto done; - time_t_to_FILE_TIME(mtimesec, musec, &mtime); + time_t_to_FILE_TIME(mtimesec, 1000*musec, &mtime); } if (!SetFileTime(hFile, NULL, &atime, &mtime)) { /* Avoid putting the file name into the error here, @@ -5585,17 +5687,53 @@ static PyObject * posix_readlink(PyObject *self, PyObject *args) { + PyObject* v; char buf[MAXPATHLEN]; char *path; int n; - if (!PyArg_ParseTuple(args, "s:readlink", &path)) +#ifdef Py_USING_UNICODE + int arg_is_unicode = 0; +#endif + + if (!PyArg_ParseTuple(args, "et:readlink", + Py_FileSystemDefaultEncoding, &path)) return NULL; +#ifdef Py_USING_UNICODE + v = PySequence_GetItem(args, 0); + if (v == NULL) return NULL; + + if (PyUnicode_Check(v)) { + arg_is_unicode = 1; + } + Py_DECREF(v); +#endif + Py_BEGIN_ALLOW_THREADS n = readlink(path, buf, (int) sizeof buf); Py_END_ALLOW_THREADS if (n < 0) return posix_error_with_filename(path); - return PyString_FromStringAndSize(buf, n); + + v = PyString_FromStringAndSize(buf, n); +#ifdef Py_USING_UNICODE + if (arg_is_unicode) { + PyObject *w; + + w = PyUnicode_FromEncodedObject(v, + Py_FileSystemDefaultEncoding, + "strict"); + if (w != NULL) { + Py_DECREF(v); + v = w; + } + else { + /* fall back to the original byte string, as + discussed in patch #683592 */ + PyErr_Clear(); + } + } +#endif + return v; } #endif /* HAVE_READLINK */ @@ -7877,7 +8015,7 @@ pCryptGenRandom = (CRYPTGENRANDOM)GetProcAddress( hAdvAPI32, "CryptGenRandom"); - if (pCryptAcquireContext == NULL) + if (pCryptGenRandom == NULL) return PyErr_Format(PyExc_NotImplementedError, "CryptGenRandom not found"); @@ -8617,3 +8755,4 @@ } #endif + Modified: python/branches/p3yk-noslice/Modules/pyexpat.c ============================================================================== --- python/branches/p3yk-noslice/Modules/pyexpat.c (original) +++ python/branches/p3yk-noslice/Modules/pyexpat.c Fri Dec 15 05:21:50 2006 @@ -279,6 +279,7 @@ filename = PyString_FromString(__FILE__); handler_info[slot].tb_code = PyCode_New(0, /* argcount */ + 0, /* kwonlyargcount */ 0, /* nlocals */ 0, /* stacksize */ 0, /* flags */ Modified: python/branches/p3yk-noslice/Modules/readline.c ============================================================================== --- python/branches/p3yk-noslice/Modules/readline.c (original) +++ python/branches/p3yk-noslice/Modules/readline.c Fri Dec 15 05:21:50 2006 @@ -768,10 +768,16 @@ while (!has_input) { struct timeval timeout = {0, 100000}; /* 0.1 seconds */ + + /* [Bug #1552726] Only limit the pause if an input hook has been + defined. */ + struct timeval *timeoutp = NULL; + if (PyOS_InputHook) + timeoutp = &timeout; FD_SET(fileno(rl_instream), &selectset); /* select resets selectset if no input was available */ has_input = select(fileno(rl_instream) + 1, &selectset, - NULL, NULL, &timeout); + NULL, NULL, timeoutp); if(PyOS_InputHook) PyOS_InputHook(); } Modified: python/branches/p3yk-noslice/Modules/resource.c ============================================================================== --- python/branches/p3yk-noslice/Modules/resource.c (original) +++ python/branches/p3yk-noslice/Modules/resource.c Fri Dec 15 05:21:50 2006 @@ -298,6 +298,10 @@ PyModule_AddIntConstant(m, "RLIMIT_MEMLOCK", RLIMIT_MEMLOCK); #endif +#ifdef RLIMIT_SBSIZE + PyModule_AddIntConstant(m, "RLIMIT_SBSIZE", RLIMIT_SBSIZE); +#endif + #ifdef RUSAGE_SELF PyModule_AddIntConstant(m, "RUSAGE_SELF", RUSAGE_SELF); #endif Modified: python/branches/p3yk-noslice/Modules/socketmodule.c ============================================================================== --- python/branches/p3yk-noslice/Modules/socketmodule.c (original) +++ python/branches/p3yk-noslice/Modules/socketmodule.c Fri Dec 15 05:21:50 2006 @@ -364,19 +364,16 @@ #define BTPROTO_RFCOMM BLUETOOTH_PROTO_RFCOMM #define sockaddr_l2 sockaddr_l2cap #define sockaddr_rc sockaddr_rfcomm -#define _BT_SOCKADDR_MEMB(s, proto) &((s)->sock_addr) #define _BT_L2_MEMB(sa, memb) ((sa)->l2cap_##memb) #define _BT_RC_MEMB(sa, memb) ((sa)->rfcomm_##memb) #elif defined(__NetBSD__) #define sockaddr_l2 sockaddr_bt #define sockaddr_rc sockaddr_bt #define sockaddr_sco sockaddr_bt -#define _BT_SOCKADDR_MEMB(s, proto) &((s)->sock_addr) #define _BT_L2_MEMB(sa, memb) ((sa)->bt_##memb) #define _BT_RC_MEMB(sa, memb) ((sa)->bt_##memb) #define _BT_SCO_MEMB(sa, memb) ((sa)->bt_##memb) #else -#define _BT_SOCKADDR_MEMB(s, proto) (&((s)->sock_addr).bt_##proto) #define _BT_L2_MEMB(sa, memb) ((sa)->l2_##memb) #define _BT_RC_MEMB(sa, memb) ((sa)->rc_##memb) #define _BT_SCO_MEMB(sa, memb) ((sa)->sco_##memb) @@ -388,6 +385,8 @@ #define SEGMENT_SIZE (32 * 1024 -1) #endif +#define SAS2SA(x) ((struct sockaddr *)(x)) + /* * Constants for getnameinfo() */ @@ -1174,7 +1173,7 @@ static int getsockaddrarg(PySocketSockObject *s, PyObject *args, - struct sockaddr **addr_ret, int *len_ret) + struct sockaddr *addr_ret, int *len_ret) { switch (s->sock_family) { @@ -1184,9 +1183,10 @@ struct sockaddr_un* addr; char *path; int len; - addr = (struct sockaddr_un*)&(s->sock_addr).un; if (!PyArg_Parse(args, "t#", &path, &len)) return 0; + + addr = (struct sockaddr_un*)addr_ret; #ifdef linux if (len > 0 && path[0] == 0) { /* Linux abstract namespace extension */ @@ -1209,7 +1209,6 @@ } addr->sun_family = s->sock_family; memcpy(addr->sun_path, path, len); - *addr_ret = (struct sockaddr *) addr; #if defined(PYOS_OS2) *len_ret = sizeof(*addr); #else @@ -1224,7 +1223,7 @@ { struct sockaddr_nl* addr; int pid, groups; - addr = (struct sockaddr_nl *)&(s->sock_addr).nl; + addr = (struct sockaddr_nl *)addr_ret; if (!PyTuple_Check(args)) { PyErr_Format( PyExc_TypeError, @@ -1238,7 +1237,6 @@ addr->nl_family = AF_NETLINK; addr->nl_pid = pid; addr->nl_groups = groups; - *addr_ret = (struct sockaddr *) addr; *len_ret = sizeof(*addr); return 1; } @@ -1249,7 +1247,6 @@ struct sockaddr_in* addr; char *host; int port, result; - addr=(struct sockaddr_in*)&(s->sock_addr).in; if (!PyTuple_Check(args)) { PyErr_Format( PyExc_TypeError, @@ -1261,6 +1258,7 @@ if (!PyArg_ParseTuple(args, "eti:getsockaddrarg", "idna", &host, &port)) return 0; + addr=(struct sockaddr_in*)addr_ret; result = setipaddr(host, (struct sockaddr *)addr, sizeof(*addr), AF_INET); PyMem_Free(host); @@ -1268,7 +1266,6 @@ return 0; addr->sin_family = AF_INET; addr->sin_port = htons((short)port); - *addr_ret = (struct sockaddr *) addr; *len_ret = sizeof *addr; return 1; } @@ -1279,7 +1276,6 @@ struct sockaddr_in6* addr; char *host; int port, flowinfo, scope_id, result; - addr = (struct sockaddr_in6*)&(s->sock_addr).in6; flowinfo = scope_id = 0; if (!PyTuple_Check(args)) { PyErr_Format( @@ -1294,6 +1290,7 @@ &scope_id)) { return 0; } + addr = (struct sockaddr_in6*)addr_ret; result = setipaddr(host, (struct sockaddr *)addr, sizeof(*addr), AF_INET6); PyMem_Free(host); @@ -1303,7 +1300,6 @@ addr->sin6_port = htons((short)port); addr->sin6_flowinfo = flowinfo; addr->sin6_scope_id = scope_id; - *addr_ret = (struct sockaddr *) addr; *len_ret = sizeof *addr; return 1; } @@ -1315,9 +1311,10 @@ switch (s->sock_proto) { case BTPROTO_L2CAP: { - struct sockaddr_l2 *addr = (struct sockaddr_l2 *) _BT_SOCKADDR_MEMB(s, l2); + struct sockaddr_l2 *addr; char *straddr; + addr = (struct sockaddr_l2 *)addr_ret; _BT_L2_MEMB(addr, family) = AF_BLUETOOTH; if (!PyArg_ParseTuple(args, "si", &straddr, &_BT_L2_MEMB(addr, psm))) { @@ -1328,15 +1325,15 @@ if (setbdaddr(straddr, &_BT_L2_MEMB(addr, bdaddr)) < 0) return 0; - *addr_ret = (struct sockaddr *) addr; *len_ret = sizeof *addr; return 1; } case BTPROTO_RFCOMM: { - struct sockaddr_rc *addr = (struct sockaddr_rc *) _BT_SOCKADDR_MEMB(s, rc); + struct sockaddr_rc *addr; char *straddr; + addr = (struct sockaddr_rc *)addr_ret; _BT_RC_MEMB(addr, family) = AF_BLUETOOTH; if (!PyArg_ParseTuple(args, "si", &straddr, &_BT_RC_MEMB(addr, channel))) { @@ -1347,16 +1344,16 @@ if (setbdaddr(straddr, &_BT_RC_MEMB(addr, bdaddr)) < 0) return 0; - *addr_ret = (struct sockaddr *) addr; *len_ret = sizeof *addr; return 1; } #if !defined(__FreeBSD__) case BTPROTO_SCO: { - struct sockaddr_sco *addr = (struct sockaddr_sco *) _BT_SOCKADDR_MEMB(s, sco); + struct sockaddr_sco *addr; char *straddr; + addr = (struct sockaddr_sco *)addr_ret; _BT_SCO_MEMB(addr, family) = AF_BLUETOOTH; straddr = PyString_AsString(args); if (straddr == NULL) { @@ -1367,7 +1364,6 @@ if (setbdaddr(straddr, &_BT_SCO_MEMB(addr, bdaddr)) < 0) return 0; - *addr_ret = (struct sockaddr *) addr; *len_ret = sizeof *addr; return 1; } @@ -1409,22 +1405,21 @@ s->errorhandler(); return 0; } - addr = &(s->sock_addr.ll); - addr->sll_family = AF_PACKET; - addr->sll_protocol = htons((short)protoNumber); - addr->sll_ifindex = ifr.ifr_ifindex; - addr->sll_pkttype = pkttype; - addr->sll_hatype = hatype; if (halen > 8) { PyErr_SetString(PyExc_ValueError, "Hardware address must be 8 bytes or less"); return 0; } + addr = (struct sockaddr_ll*)addr_ret; + addr->sll_family = AF_PACKET; + addr->sll_protocol = htons((short)protoNumber); + addr->sll_ifindex = ifr.ifr_ifindex; + addr->sll_pkttype = pkttype; + addr->sll_hatype = hatype; if (halen != 0) { memcpy(&addr->sll_addr, haddr, halen); } addr->sll_halen = halen; - *addr_ret = (struct sockaddr *) addr; *len_ret = sizeof *addr; return 1; } @@ -1551,8 +1546,7 @@ Py_BEGIN_ALLOW_THREADS timeout = internal_select(s, 0); if (!timeout) - newfd = accept(s->sock_fd, (struct sockaddr *) &addrbuf, - &addrlen); + newfd = accept(s->sock_fd, SAS2SA(&addrbuf), &addrlen); Py_END_ALLOW_THREADS if (timeout == 1) { @@ -1578,7 +1572,7 @@ SOCKETCLOSE(newfd); goto finally; } - addr = makesockaddr(s->sock_fd, (struct sockaddr *) &addrbuf, + addr = makesockaddr(s->sock_fd, SAS2SA(&addrbuf), addrlen, s->sock_proto); if (addr == NULL) goto finally; @@ -1819,14 +1813,14 @@ static PyObject * sock_bind(PySocketSockObject *s, PyObject *addro) { - struct sockaddr *addr; + sock_addr_t addrbuf; int addrlen; int res; - if (!getsockaddrarg(s, addro, &addr, &addrlen)) + if (!getsockaddrarg(s, addro, SAS2SA(&addrbuf), &addrlen)) return NULL; Py_BEGIN_ALLOW_THREADS - res = bind(s->sock_fd, addr, addrlen); + res = bind(s->sock_fd, SAS2SA(&addrbuf), addrlen); Py_END_ALLOW_THREADS if (res < 0) return s->errorhandler(); @@ -1952,16 +1946,16 @@ static PyObject * sock_connect(PySocketSockObject *s, PyObject *addro) { - struct sockaddr *addr; + sock_addr_t addrbuf; int addrlen; int res; int timeout; - if (!getsockaddrarg(s, addro, &addr, &addrlen)) + if (!getsockaddrarg(s, addro, SAS2SA(&addrbuf), &addrlen)) return NULL; Py_BEGIN_ALLOW_THREADS - res = internal_connect(s, addr, addrlen, &timeout); + res = internal_connect(s, SAS2SA(&addrbuf), addrlen, &timeout); Py_END_ALLOW_THREADS if (timeout == 1) { @@ -1986,16 +1980,16 @@ static PyObject * sock_connect_ex(PySocketSockObject *s, PyObject *addro) { - struct sockaddr *addr; + sock_addr_t addrbuf; int addrlen; int res; int timeout; - if (!getsockaddrarg(s, addro, &addr, &addrlen)) + if (!getsockaddrarg(s, addro, SAS2SA(&addrbuf), &addrlen)) return NULL; Py_BEGIN_ALLOW_THREADS - res = internal_connect(s, addr, addrlen, &timeout); + res = internal_connect(s, SAS2SA(&addrbuf), addrlen, &timeout); Py_END_ALLOW_THREADS /* Signals are not errors (though they may raise exceptions). Adapted @@ -2075,11 +2069,11 @@ return NULL; memset(&addrbuf, 0, addrlen); Py_BEGIN_ALLOW_THREADS - res = getsockname(s->sock_fd, (struct sockaddr *) &addrbuf, &addrlen); + res = getsockname(s->sock_fd, SAS2SA(&addrbuf), &addrlen); Py_END_ALLOW_THREADS if (res < 0) return s->errorhandler(); - return makesockaddr(s->sock_fd, (struct sockaddr *) &addrbuf, addrlen, + return makesockaddr(s->sock_fd, SAS2SA(&addrbuf), addrlen, s->sock_proto); } @@ -2104,11 +2098,11 @@ return NULL; memset(&addrbuf, 0, addrlen); Py_BEGIN_ALLOW_THREADS - res = getpeername(s->sock_fd, (struct sockaddr *) &addrbuf, &addrlen); + res = getpeername(s->sock_fd, SAS2SA(&addrbuf), &addrlen); Py_END_ALLOW_THREADS if (res < 0) return s->errorhandler(); - return makesockaddr(s->sock_fd, (struct sockaddr *) &addrbuf, addrlen, + return makesockaddr(s->sock_fd, SAS2SA(&addrbuf), addrlen, s->sock_proto); } @@ -2443,14 +2437,14 @@ #ifndef MS_WINDOWS #if defined(PYOS_OS2) && !defined(PYCC_GCC) n = recvfrom(s->sock_fd, cbuf, len, flags, - (struct sockaddr *) &addrbuf, &addrlen); + SAS2SA(&addrbuf), &addrlen); #else n = recvfrom(s->sock_fd, cbuf, len, flags, (void *) &addrbuf, &addrlen); #endif #else n = recvfrom(s->sock_fd, cbuf, len, flags, - (struct sockaddr *) &addrbuf, &addrlen); + SAS2SA(&addrbuf), &addrlen); #endif } Py_END_ALLOW_THREADS @@ -2464,7 +2458,7 @@ return -1; } - if (!(*addr = makesockaddr(s->sock_fd, (struct sockaddr *) &addrbuf, + if (!(*addr = makesockaddr(s->sock_fd, SAS2SA(&addrbuf), addrlen, s->sock_proto))) return -1; @@ -2664,7 +2658,7 @@ { PyObject *addro; char *buf; - struct sockaddr *addr; + sock_addr_t addrbuf; int addrlen, len, n = -1, flags, timeout; flags = 0; @@ -2675,16 +2669,16 @@ return NULL; } - if (!getsockaddrarg(s, addro, &addr, &addrlen)) - return NULL; - if (!IS_SELECTABLE(s)) return select_error(); + if (!getsockaddrarg(s, addro, SAS2SA(&addrbuf), &addrlen)) + return NULL; + Py_BEGIN_ALLOW_THREADS timeout = internal_select(s, 1); if (!timeout) - n = sendto(s->sock_fd, buf, len, flags, addr, addrlen); + n = sendto(s->sock_fd, buf, len, flags, SAS2SA(&addrbuf), addrlen); Py_END_ALLOW_THREADS if (timeout == 1) { @@ -2973,10 +2967,9 @@ if (!PyArg_ParseTuple(args, "s:gethostbyname", &name)) return NULL; - if (setipaddr(name, (struct sockaddr *)&addrbuf, sizeof(addrbuf), AF_INET) < 0) + if (setipaddr(name, SAS2SA(&addrbuf), sizeof(addrbuf), AF_INET) < 0) return NULL; - return makeipaddr((struct sockaddr *)&addrbuf, - sizeof(struct sockaddr_in)); + return makeipaddr(SAS2SA(&addrbuf), sizeof(struct sockaddr_in)); } PyDoc_STRVAR(gethostbyname_doc, Modified: python/branches/p3yk-noslice/Modules/socketmodule.h ============================================================================== --- python/branches/p3yk-noslice/Modules/socketmodule.h (original) +++ python/branches/p3yk-noslice/Modules/socketmodule.h Fri Dec 15 05:21:50 2006 @@ -114,7 +114,6 @@ int sock_family; /* Address family, e.g., AF_INET */ int sock_type; /* Socket type, e.g., SOCK_STREAM */ int sock_proto; /* Protocol type, usually 0 */ - sock_addr_t sock_addr; /* Socket address */ PyObject *(*errorhandler)(void); /* Error handler; checks errno, returns NULL and sets a Python exception */ Modified: python/branches/p3yk-noslice/Modules/symtablemodule.c ============================================================================== --- python/branches/p3yk-noslice/Modules/symtablemodule.c (original) +++ python/branches/p3yk-noslice/Modules/symtablemodule.c Fri Dec 15 05:21:50 2006 @@ -73,8 +73,7 @@ PyModule_AddIntConstant(m, "TYPE_MODULE", ModuleBlock); PyModule_AddIntConstant(m, "OPT_IMPORT_STAR", OPT_IMPORT_STAR); - PyModule_AddIntConstant(m, "OPT_EXEC", OPT_EXEC); - PyModule_AddIntConstant(m, "OPT_BARE_EXEC", OPT_BARE_EXEC); + PyModule_AddIntConstant(m, "OPT_TOPLEVEL", OPT_TOPLEVEL); PyModule_AddIntConstant(m, "LOCAL", LOCAL); PyModule_AddIntConstant(m, "GLOBAL_EXPLICIT", GLOBAL_EXPLICIT); Modified: python/branches/p3yk-noslice/Modules/threadmodule.c ============================================================================== --- python/branches/p3yk-noslice/Modules/threadmodule.c (original) +++ python/branches/p3yk-noslice/Modules/threadmodule.c Fri Dec 15 05:21:50 2006 @@ -25,6 +25,7 @@ static void lock_dealloc(lockobject *self) { + assert(self->lock_lock); /* Unlock the lock so it's safe to free it */ PyThread_acquire_lock(self->lock_lock, 0); PyThread_release_lock(self->lock_lock); @@ -696,6 +697,8 @@ /* Initialize types: */ if (PyType_Ready(&localtype) < 0) return; + if (PyType_Ready(&Locktype) < 0) + return; /* Create the module and add the functions */ m = Py_InitModule3("thread", thread_methods, thread_doc); Modified: python/branches/p3yk-noslice/Modules/unicodedata.c ============================================================================== --- python/branches/p3yk-noslice/Modules/unicodedata.c (original) +++ python/branches/p3yk-noslice/Modules/unicodedata.c Fri Dec 15 05:21:50 2006 @@ -75,7 +75,7 @@ {NULL} }; -// forward declaration +/* forward declaration */ static PyTypeObject UCD_Type; static PyObject* Modified: python/branches/p3yk-noslice/Objects/abstract.c ============================================================================== --- python/branches/p3yk-noslice/Objects/abstract.c (original) +++ python/branches/p3yk-noslice/Objects/abstract.c Fri Dec 15 05:21:50 2006 @@ -1491,20 +1491,18 @@ if (cmp > 0) { switch (operation) { case PY_ITERSEARCH_COUNT: - ++n; - if (n <= 0) { - /* XXX(nnorwitz): int means ssize_t */ + if (n == PY_SSIZE_T_MAX) { PyErr_SetString(PyExc_OverflowError, - "count exceeds C int size"); + "count exceeds C integer size"); goto Fail; } + ++n; break; case PY_ITERSEARCH_INDEX: if (wrapped) { - /* XXX(nnorwitz): int means ssize_t */ PyErr_SetString(PyExc_OverflowError, - "index exceeds C int size"); + "index exceeds C integer size"); goto Fail; } goto Done; @@ -1519,9 +1517,9 @@ } if (operation == PY_ITERSEARCH_INDEX) { - ++n; - if (n <= 0) + if (n == PY_SSIZE_T_MAX) wrapped = 1; + ++n; } } Modified: python/branches/p3yk-noslice/Objects/boolobject.c ============================================================================== --- python/branches/p3yk-noslice/Objects/boolobject.c (original) +++ python/branches/p3yk-noslice/Objects/boolobject.c Fri Dec 15 05:21:50 2006 @@ -112,7 +112,7 @@ 0, /* nb_negative */ 0, /* nb_positive */ 0, /* nb_absolute */ - 0, /* nb_nonzero */ + 0, /* nb_bool */ 0, /* nb_invert */ 0, /* nb_lshift */ 0, /* nb_rshift */ Modified: python/branches/p3yk-noslice/Objects/bufferobject.c ============================================================================== --- python/branches/p3yk-noslice/Objects/bufferobject.c (original) +++ python/branches/p3yk-noslice/Objects/bufferobject.c Fri Dec 15 05:21:50 2006 @@ -252,23 +252,65 @@ } static int -buffer_compare(PyBufferObject *self, PyBufferObject *other) +get_bufx(PyObject *obj, void **ptr, Py_ssize_t *size) { - void *p1, *p2; - Py_ssize_t len_self, len_other, min_len; - int cmp; + PyBufferProcs *bp; - if (!get_buf(self, &p1, &len_self, ANY_BUFFER)) - return -1; - if (!get_buf(other, &p2, &len_other, ANY_BUFFER)) - return -1; - min_len = (len_self < len_other) ? len_self : len_other; - if (min_len > 0) { - cmp = memcmp(p1, p2, min_len); - if (cmp != 0) - return cmp < 0 ? -1 : 1; + if (PyBuffer_Check(obj)) { + if (!get_buf((PyBufferObject *)obj, ptr, size, ANY_BUFFER)) { + PyErr_Clear(); + return 0; + } + else + return 1; + } + bp = obj->ob_type->tp_as_buffer; + if (bp == NULL || + bp->bf_getreadbuffer == NULL || + bp->bf_getsegcount == NULL) + return 0; + if ((*bp->bf_getsegcount)(obj, NULL) != 1) + return 0; + *size = (*bp->bf_getreadbuffer)(obj, 0, ptr); + if (*size < 0) { + PyErr_Clear(); + return 0; } - return (len_self < len_other) ? -1 : (len_self > len_other) ? 1 : 0; + return 1; +} + +static PyObject * +buffer_richcompare(PyObject *self, PyObject *other, int op) +{ + void *p1, *p2; + Py_ssize_t len1, len2, min_len; + int cmp, ok; + + ok = 1; + if (!get_bufx(self, &p1, &len1)) + ok = 0; + if (!get_bufx(other, &p2, &len2)) + ok = 0; + if (!ok) { + /* If we can't get the buffers, + == and != are still defined + (and the objects are unequal) */ + PyObject *result; + if (op == Py_EQ) + result = Py_False; + else if (op == Py_NE) + result = Py_True; + else + result = Py_NotImplemented; + Py_INCREF(result); + return result; + } + min_len = (len1 < len2) ? len1 : len2; + cmp = memcmp(p1, p2, min_len); + if (cmp == 0) + cmp = (len1 < len2) ? -1 : + (len1 > len2) ? 1 : 0; + return Py_CmpToRich(op, cmp); } static PyObject * @@ -821,7 +863,7 @@ 0, /* tp_print */ 0, /* tp_getattr */ 0, /* tp_setattr */ - (cmpfunc)buffer_compare, /* tp_compare */ + 0, /* tp_compare */ (reprfunc)buffer_repr, /* tp_repr */ 0, /* tp_as_number */ &buffer_as_sequence, /* tp_as_sequence */ @@ -836,7 +878,7 @@ buffer_doc, /* tp_doc */ 0, /* tp_traverse */ 0, /* tp_clear */ - 0, /* tp_richcompare */ + buffer_richcompare, /* tp_richcompare */ 0, /* tp_weaklistoffset */ 0, /* tp_iter */ 0, /* tp_iternext */ Modified: python/branches/p3yk-noslice/Objects/bytesobject.c ============================================================================== --- python/branches/p3yk-noslice/Objects/bytesobject.c (original) +++ python/branches/p3yk-noslice/Objects/bytesobject.c Fri Dec 15 05:21:50 2006 @@ -365,6 +365,8 @@ if (lo < 0) lo = 0; + if (hi < lo) + hi = lo; if (hi > self->ob_size) hi = self->ob_size; Modified: python/branches/p3yk-noslice/Objects/cellobject.c ============================================================================== --- python/branches/p3yk-noslice/Objects/cellobject.c (original) +++ python/branches/p3yk-noslice/Objects/cellobject.c Fri Dec 15 05:21:50 2006 @@ -49,18 +49,6 @@ PyObject_GC_Del(op); } -static int -cell_compare(PyCellObject *a, PyCellObject *b) -{ - if (a->ob_ref == NULL) { - if (b->ob_ref == NULL) - return 0; - return -1; - } else if (b->ob_ref == NULL) - return 1; - return PyObject_Compare(a->ob_ref, b->ob_ref); -} - static PyObject * cell_repr(PyCellObject *op) { @@ -108,7 +96,7 @@ 0, /* tp_print */ 0, /* tp_getattr */ 0, /* tp_setattr */ - (cmpfunc)cell_compare, /* tp_compare */ + 0, /* tp_compare */ (reprfunc)cell_repr, /* tp_repr */ 0, /* tp_as_number */ 0, /* tp_as_sequence */ Modified: python/branches/p3yk-noslice/Objects/classobject.c ============================================================================== --- python/branches/p3yk-noslice/Objects/classobject.c (original) +++ python/branches/p3yk-noslice/Objects/classobject.c Fri Dec 15 05:21:50 2006 @@ -80,7 +80,7 @@ #define OFF(x) offsetof(PyMethodObject, x) -static PyMemberDef instancemethod_memberlist[] = { +static PyMemberDef method_memberlist[] = { {"im_class", T_OBJECT, OFF(im_class), READONLY|RESTRICTED, "the class associated with a method"}, {"im_func", T_OBJECT, OFF(im_func), READONLY|RESTRICTED, @@ -96,7 +96,7 @@ should only be used for the class, not for instances */ static PyObject * -instancemethod_get_doc(PyMethodObject *im, void *context) +method_get_doc(PyMethodObject *im, void *context) { static PyObject *docstr; if (docstr == NULL) { @@ -107,13 +107,13 @@ return PyObject_GetAttr(im->im_func, docstr); } -static PyGetSetDef instancemethod_getset[] = { - {"__doc__", (getter)instancemethod_get_doc, NULL, NULL}, +static PyGetSetDef method_getset[] = { + {"__doc__", (getter)method_get_doc, NULL, NULL}, {0} }; static PyObject * -instancemethod_getattro(PyObject *obj, PyObject *name) +method_getattro(PyObject *obj, PyObject *name) { PyMethodObject *im = (PyMethodObject *)obj; PyTypeObject *tp = obj->ob_type; @@ -140,19 +140,21 @@ return PyObject_GetAttr(im->im_func, name); } -PyDoc_STRVAR(instancemethod_doc, -"instancemethod(function, instance, class)\n\ +PyDoc_STRVAR(method_doc, +"method(function, instance, class)\n\ \n\ Create an instance method object."); static PyObject * -instancemethod_new(PyTypeObject* type, PyObject* args, PyObject *kw) +method_new(PyTypeObject* type, PyObject* args, PyObject *kw) { PyObject *func; PyObject *self; PyObject *classObj = NULL; - if (!PyArg_UnpackTuple(args, "instancemethod", 2, 3, + if (!_PyArg_NoKeywords("instancemethod", kw)) + return NULL; + if (!PyArg_UnpackTuple(args, "method", 2, 3, &func, &self, &classObj)) return NULL; if (!PyCallable_Check(func)) { @@ -172,7 +174,7 @@ } static void -instancemethod_dealloc(register PyMethodObject *im) +method_dealloc(register PyMethodObject *im) { _PyObject_GC_UNTRACK(im); if (im->im_weakreflist != NULL) @@ -184,24 +186,42 @@ free_list = im; } -static int -instancemethod_compare(PyMethodObject *a, PyMethodObject *b) +static PyObject * +method_richcompare(PyObject *self, PyObject *other, int op) { - int cmp; - cmp = PyObject_Compare(a->im_func, b->im_func); - if (cmp) - return cmp; - - if (a->im_self == b->im_self) - return 0; - if (a->im_self == NULL || b->im_self == NULL) - return (a->im_self < b->im_self) ? -1 : 1; + PyMethodObject *a, *b; + PyObject *res; + int eq; + + if ((op != Py_EQ && op != Py_NE) || + !PyMethod_Check(self) || + !PyMethod_Check(other)) + { + Py_INCREF(Py_NotImplemented); + return Py_NotImplemented; + } + a = (PyMethodObject *)self; + b = (PyMethodObject *)other; + eq = PyObject_RichCompareBool(a->im_func, b->im_func, Py_EQ); + if (eq == 1) { + if (a->im_self == NULL || b->im_self == NULL) + eq = a->im_self == b->im_self; + else + eq = PyObject_RichCompareBool(a->im_self, b->im_self, + Py_EQ); + } + if (eq < 0) + return NULL; + if (op == Py_EQ) + res = eq ? Py_True : Py_False; else - return PyObject_Compare(a->im_self, b->im_self); + res = eq ? Py_False : Py_True; + Py_INCREF(res); + return res; } static PyObject * -instancemethod_repr(PyMethodObject *a) +method_repr(PyMethodObject *a) { PyObject *self = a->im_self; PyObject *func = a->im_func; @@ -261,7 +281,7 @@ } static long -instancemethod_hash(PyMethodObject *a) +method_hash(PyMethodObject *a) { long x, y; if (a->im_self == NULL) @@ -280,7 +300,7 @@ } static int -instancemethod_traverse(PyMethodObject *im, visitproc visit, void *arg) +method_traverse(PyMethodObject *im, visitproc visit, void *arg) { Py_VISIT(im->im_func); Py_VISIT(im->im_self); @@ -333,7 +353,7 @@ } static PyObject * -instancemethod_call(PyObject *func, PyObject *arg, PyObject *kw) +method_call(PyObject *func, PyObject *arg, PyObject *kw) { PyObject *self = PyMethod_GET_SELF(func); PyObject *klass = PyMethod_GET_CLASS(func); @@ -392,7 +412,7 @@ } static PyObject * -instancemethod_descr_get(PyObject *meth, PyObject *obj, PyObject *cls) +method_descr_get(PyObject *meth, PyObject *obj, PyObject *cls) { /* Don't rebind an already bound method, or an unbound method of a class that's not a base class of cls. */ @@ -420,43 +440,43 @@ PyTypeObject PyMethod_Type = { PyObject_HEAD_INIT(&PyType_Type) 0, - "instancemethod", + "method", sizeof(PyMethodObject), 0, - (destructor)instancemethod_dealloc, /* tp_dealloc */ + (destructor)method_dealloc, /* tp_dealloc */ 0, /* tp_print */ 0, /* tp_getattr */ 0, /* tp_setattr */ - (cmpfunc)instancemethod_compare, /* tp_compare */ - (reprfunc)instancemethod_repr, /* tp_repr */ + 0, /* tp_compare */ + (reprfunc)method_repr, /* tp_repr */ 0, /* tp_as_number */ 0, /* tp_as_sequence */ 0, /* tp_as_mapping */ - (hashfunc)instancemethod_hash, /* tp_hash */ - instancemethod_call, /* tp_call */ + (hashfunc)method_hash, /* tp_hash */ + method_call, /* tp_call */ 0, /* tp_str */ - instancemethod_getattro, /* tp_getattro */ + method_getattro, /* tp_getattro */ PyObject_GenericSetAttr, /* tp_setattro */ 0, /* tp_as_buffer */ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC, /* tp_flags */ - instancemethod_doc, /* tp_doc */ - (traverseproc)instancemethod_traverse, /* tp_traverse */ + method_doc, /* tp_doc */ + (traverseproc)method_traverse, /* tp_traverse */ 0, /* tp_clear */ - 0, /* tp_richcompare */ + method_richcompare, /* tp_richcompare */ offsetof(PyMethodObject, im_weakreflist), /* tp_weaklistoffset */ 0, /* tp_iter */ 0, /* tp_iternext */ 0, /* tp_methods */ - instancemethod_memberlist, /* tp_members */ - instancemethod_getset, /* tp_getset */ + method_memberlist, /* tp_members */ + method_getset, /* tp_getset */ 0, /* tp_base */ 0, /* tp_dict */ - instancemethod_descr_get, /* tp_descr_get */ + method_descr_get, /* tp_descr_get */ 0, /* tp_descr_set */ 0, /* tp_dictoffset */ 0, /* tp_init */ 0, /* tp_alloc */ - instancemethod_new, /* tp_new */ + method_new, /* tp_new */ }; /* Clear out the free list */ Modified: python/branches/p3yk-noslice/Objects/codeobject.c ============================================================================== --- python/branches/p3yk-noslice/Objects/codeobject.c (original) +++ python/branches/p3yk-noslice/Objects/codeobject.c Fri Dec 15 05:21:50 2006 @@ -41,7 +41,8 @@ PyCodeObject * -PyCode_New(int argcount, int nlocals, int stacksize, int flags, +PyCode_New(int argcount, int kwonlyargcount, + int nlocals, int stacksize, int flags, PyObject *code, PyObject *consts, PyObject *names, PyObject *varnames, PyObject *freevars, PyObject *cellvars, PyObject *filename, PyObject *name, int firstlineno, @@ -80,6 +81,7 @@ co = PyObject_NEW(PyCodeObject, &PyCode_Type); if (co != NULL) { co->co_argcount = argcount; + co->co_kwonlyargcount = kwonlyargcount; co->co_nlocals = nlocals; co->co_stacksize = stacksize; co->co_flags = flags; @@ -112,6 +114,7 @@ static PyMemberDef code_memberlist[] = { {"co_argcount", T_INT, OFF(co_argcount), READONLY}, + {"co_kwonlyargcount", T_INT, OFF(co_kwonlyargcount), READONLY}, {"co_nlocals", T_INT, OFF(co_nlocals), READONLY}, {"co_stacksize",T_INT, OFF(co_stacksize), READONLY}, {"co_flags", T_INT, OFF(co_flags), READONLY}, @@ -182,6 +185,7 @@ code_new(PyTypeObject *type, PyObject *args, PyObject *kw) { int argcount; + int kwonlyargcount; int nlocals; int stacksize; int flags; @@ -197,8 +201,9 @@ int firstlineno; PyObject *lnotab; - if (!PyArg_ParseTuple(args, "iiiiSO!O!O!SSiS|O!O!:code", - &argcount, &nlocals, &stacksize, &flags, + if (!PyArg_ParseTuple(args, "iiiiiSO!O!O!SSiS|O!O!:code", + &argcount, &kwonlyargcount, + &nlocals, &stacksize, &flags, &code, &PyTuple_Type, &consts, &PyTuple_Type, &names, @@ -216,6 +221,12 @@ goto cleanup; } + if (kwonlyargcount < 0) { + PyErr_SetString( + PyExc_ValueError, + "code: kwonlyargcount must not be negative"); + goto cleanup; + } if (nlocals < 0) { PyErr_SetString( PyExc_ValueError, @@ -242,7 +253,8 @@ if (ourcellvars == NULL) goto cleanup; - co = (PyObject *)PyCode_New(argcount, nlocals, stacksize, flags, + co = (PyObject *)PyCode_New(argcount, kwonlyargcount, + nlocals, stacksize, flags, code, consts, ournames, ourvarnames, ourfreevars, ourcellvars, filename, name, firstlineno, lnotab); @@ -291,40 +303,65 @@ return PyString_FromString(buf); } -static int -code_compare(PyCodeObject *co, PyCodeObject *cp) +static PyObject * +code_richcompare(PyObject *self, PyObject *other, int op) { - int cmp; - cmp = PyObject_Compare(co->co_name, cp->co_name); - if (cmp) return cmp; - cmp = co->co_argcount - cp->co_argcount; - if (cmp) goto normalize; - cmp = co->co_nlocals - cp->co_nlocals; - if (cmp) goto normalize; - cmp = co->co_flags - cp->co_flags; - if (cmp) goto normalize; - cmp = co->co_firstlineno - cp->co_firstlineno; - if (cmp) goto normalize; - cmp = PyObject_Compare(co->co_code, cp->co_code); - if (cmp) return cmp; - cmp = PyObject_Compare(co->co_consts, cp->co_consts); - if (cmp) return cmp; - cmp = PyObject_Compare(co->co_names, cp->co_names); - if (cmp) return cmp; - cmp = PyObject_Compare(co->co_varnames, cp->co_varnames); - if (cmp) return cmp; - cmp = PyObject_Compare(co->co_freevars, cp->co_freevars); - if (cmp) return cmp; - cmp = PyObject_Compare(co->co_cellvars, cp->co_cellvars); - return cmp; - - normalize: - if (cmp > 0) - return 1; - else if (cmp < 0) - return -1; + PyCodeObject *co, *cp; + int eq; + PyObject *res; + + if ((op != Py_EQ && op != Py_NE) || + !PyCode_Check(self) || + !PyCode_Check(other)) { + Py_INCREF(Py_NotImplemented); + return Py_NotImplemented; + } + + co = (PyCodeObject *)self; + cp = (PyCodeObject *)other; + + eq = PyObject_RichCompareBool(co->co_name, cp->co_name, Py_EQ); + if (eq <= 0) goto unequal; + eq = co->co_argcount == cp->co_argcount; + if (!eq) goto unequal; + eq = co->co_kwonlyargcount == cp->co_kwonlyargcount; + if (!eq) goto unequal; + eq = co->co_nlocals == cp->co_nlocals; + if (!eq) goto unequal; + eq = co->co_flags == cp->co_flags; + if (!eq) goto unequal; + eq = co->co_firstlineno == cp->co_firstlineno; + if (!eq) goto unequal; + eq = PyObject_RichCompareBool(co->co_code, cp->co_code, Py_EQ); + if (eq <= 0) goto unequal; + eq = PyObject_RichCompareBool(co->co_consts, cp->co_consts, Py_EQ); + if (eq <= 0) goto unequal; + eq = PyObject_RichCompareBool(co->co_names, cp->co_names, Py_EQ); + if (eq <= 0) goto unequal; + eq = PyObject_RichCompareBool(co->co_varnames, cp->co_varnames, Py_EQ); + if (eq <= 0) goto unequal; + eq = PyObject_RichCompareBool(co->co_freevars, cp->co_freevars, Py_EQ); + if (eq <= 0) goto unequal; + eq = PyObject_RichCompareBool(co->co_cellvars, cp->co_cellvars, Py_EQ); + if (eq <= 0) goto unequal; + + if (op == Py_EQ) + res = Py_True; + else + res = Py_False; + goto done; + + unequal: + if (eq < 0) + return NULL; + if (op == Py_NE) + res = Py_True; else - return 0; + res = Py_False; + + done: + Py_INCREF(res); + return res; } static long @@ -346,7 +383,8 @@ h6 = PyObject_Hash(co->co_cellvars); if (h6 == -1) return -1; h = h0 ^ h1 ^ h2 ^ h3 ^ h4 ^ h5 ^ h6 ^ - co->co_argcount ^ co->co_nlocals ^ co->co_flags; + co->co_argcount ^ co->co_kwonlyargcount ^ + co->co_nlocals ^ co->co_flags; if (h == -1) h = -2; return h; } @@ -363,7 +401,7 @@ 0, /* tp_print */ 0, /* tp_getattr */ 0, /* tp_setattr */ - (cmpfunc)code_compare, /* tp_compare */ + 0, /* tp_compare */ (reprfunc)code_repr, /* tp_repr */ 0, /* tp_as_number */ 0, /* tp_as_sequence */ @@ -378,7 +416,7 @@ code_doc, /* tp_doc */ 0, /* tp_traverse */ 0, /* tp_clear */ - 0, /* tp_richcompare */ + code_richcompare, /* tp_richcompare */ 0, /* tp_weaklistoffset */ 0, /* tp_iter */ 0, /* tp_iternext */ Modified: python/branches/p3yk-noslice/Objects/complexobject.c ============================================================================== --- python/branches/p3yk-noslice/Objects/complexobject.c (original) +++ python/branches/p3yk-noslice/Objects/complexobject.c Fri Dec 15 05:21:50 2006 @@ -568,7 +568,7 @@ } static int -complex_nonzero(PyComplexObject *v) +complex_bool(PyComplexObject *v) { return v->cval.real != 0.0 || v->cval.imag != 0.0; } @@ -938,7 +938,7 @@ (unaryfunc)complex_neg, /* nb_negative */ (unaryfunc)complex_pos, /* nb_positive */ (unaryfunc)complex_abs, /* nb_absolute */ - (inquiry)complex_nonzero, /* nb_nonzero */ + (inquiry)complex_bool, /* nb_bool */ 0, /* nb_invert */ 0, /* nb_lshift */ 0, /* nb_rshift */ Modified: python/branches/p3yk-noslice/Objects/dictobject.c ============================================================================== --- python/branches/p3yk-noslice/Objects/dictobject.c (original) +++ python/branches/p3yk-noslice/Objects/dictobject.c Fri Dec 15 05:21:50 2006 @@ -12,6 +12,20 @@ typedef PyDictEntry dictentry; typedef PyDictObject dictobject; +/* Set a key error with the specified argument, wrapping it in a + * tuple automatically so that tuple keys are not unpacked as the + * exception arguments. */ +static void +set_key_error(PyObject *arg) +{ + PyObject *tup; + tup = PyTuple_Pack(1, arg); + if (!tup) + return; /* caller will expect error to be set anyway */ + PyErr_SetObject(PyExc_KeyError, tup); + Py_DECREF(tup); +} + /* Define this out if you don't want conversion statistics on exit. */ #undef SHOW_CONVERSION_COUNTS @@ -24,11 +38,11 @@ important hash functions (for strings and ints) are very regular in common cases: ->>> map(hash, (0, 1, 2, 3)) -[0, 1, 2, 3] ->>> map(hash, ("namea", "nameb", "namec", "named")) -[-1658398457, -1658398460, -1658398459, -1658398462] ->>> + >>> map(hash, (0, 1, 2, 3)) + [0, 1, 2, 3] + >>> map(hash, ("namea", "nameb", "namec", "named")) + [-1658398457, -1658398460, -1658398459, -1658398462] + >>> This isn't necessarily bad! To the contrary, in a table of size 2**i, taking the low-order i bits as the initial table index is extremely fast, and there @@ -39,9 +53,9 @@ OTOH, when collisions occur, the tendency to fill contiguous slices of the hash table makes a good collision resolution strategy crucial. Taking only the last i bits of the hash code is also vulnerable: for example, consider -[i << 16 for i in range(20000)] as a set of keys. Since ints are their own -hash codes, and this fits in a dict of size 2**15, the last 15 bits of every -hash code are all 0: they *all* map to the same table index. +the list [i << 16 for i in range(20000)] as a set of keys. Since ints are +their own hash codes, and this fits in a dict of size 2**15, the last 15 bits + of every hash code are all 0: they *all* map to the same table index. But catering to unusual cases should not slow the usual ones, so we just take the last i bits anyway. It's up to collision resolution to do the rest. If @@ -97,19 +111,19 @@ best" in minimizing total collisions across experiments Tim Peters ran (on both normal and pathological cases), but 4 and 6 weren't significantly worse. -Historical: Reimer Behrends contributed the idea of using a polynomial-based +Historical: Reimer Behrends contributed the idea of using a polynomial-based approach, using repeated multiplication by x in GF(2**n) where an irreducible polynomial for each table size was chosen such that x was a primitive root. Christian Tismer later extended that to use division by x instead, as an efficient way to get the high bits of the hash code into play. This scheme -also gave excellent collision statistics, but was more expensive: two -if-tests were required inside the loop; computing "the next" index took about -the same number of operations but without as much potential parallelism -(e.g., computing 5*j can go on at the same time as computing 1+perturb in the -above, and then shifting perturb can be done while the table index is being -masked); and the dictobject struct required a member to hold the table's -polynomial. In Tim's experiments the current scheme ran faster, produced -equally good collision statistics, needed less code & used less memory. +also gave excellent collision statistics, but was more expensive: two if-tests +were required inside the loop; computing "the next" index took about the same +number of operations but without as much potential parallelism (e.g., +computing 5*j can go on at the same time as computing 1+perturb in the above, +and then shifting perturb can be done while the table index is being masked); +and the dictobject struct required a member to hold the table's polynomial. +In Tim's experiments the current scheme ran faster, produced equally good +collision statistics, needed less code & used less memory. Theoretical Python 2.5 headache: hash codes are only C "long", but sizeof(Py_ssize_t) > sizeof(long) may be possible. In that case, and if a @@ -223,9 +237,9 @@ All arithmetic on hash should ignore overflow. -(The details in this version are due to Tim Peters, building on many past +The details in this version are due to Tim Peters, building on many past contributions by Reimer Behrends, Jyrki Alakuijala, Vladimir Marangozov and -Christian Tismer). +Christian Tismer. lookdict() is general-purpose, and may return NULL if (and only if) a comparison raises an exception (this was new in Python 2.5). @@ -307,6 +321,8 @@ else if (ep->me_key == dummy && freeslot == NULL) freeslot = ep; } + assert(0); /* NOT REACHED */ + return 0; } /* @@ -366,6 +382,8 @@ if (ep->me_key == dummy && freeslot == NULL) freeslot = ep; } + assert(0); /* NOT REACHED */ + return 0; } /* @@ -582,6 +600,36 @@ return ep->me_value; } +/* Variant of PyDict_GetItem() that doesn't suppress exceptions. + This returns NULL *with* an exception set if an exception occurred. + It returns NULL *without* an exception set if the key wasn't present. +*/ +PyObject * +PyDict_GetItemWithError(PyObject *op, PyObject *key) +{ + long hash; + dictobject *mp = (dictobject *)op; + dictentry *ep; + + if (!PyDict_Check(op)) { + PyErr_BadInternalCall(); + return NULL; + } + if (!PyString_CheckExact(key) || + (hash = ((PyStringObject *) key)->ob_shash) == -1) + { + hash = PyObject_Hash(key); + if (hash == -1) { + return NULL; + } + } + + ep = (mp->ma_lookup)(mp, key, hash); + if (ep == NULL) + return NULL; + return ep->me_value; +} + /* CAUTION: PyDict_SetItem() must guarantee that it won't resize the * dictionary if it's merely replacing the value for an existing key. * This means that it's safe to loop over a dictionary with PyDict_Next() @@ -661,7 +709,7 @@ if (ep == NULL) return -1; if (ep->me_value == NULL) { - PyErr_SetObject(PyExc_KeyError, key); + set_key_error(key); return -1; } old_key = ep->me_key; @@ -970,7 +1018,7 @@ return PyObject_CallFunctionObjArgs(missing, (PyObject *)mp, key, NULL); } - PyErr_SetObject(PyExc_KeyError, key); + set_key_error(key); return NULL; } else @@ -1432,136 +1480,6 @@ return dict_items((dictobject *)mp); } -/* Subroutine which returns the smallest key in a for which b's value - is different or absent. The value is returned too, through the - pval argument. Both are NULL if no key in a is found for which b's status - differs. The refcounts on (and only on) non-NULL *pval and function return - values must be decremented by the caller (characterize() increments them - to ensure that mutating comparison and PyDict_GetItem calls can't delete - them before the caller is done looking at them). */ - -static PyObject * -characterize(dictobject *a, dictobject *b, PyObject **pval) -{ - PyObject *akey = NULL; /* smallest key in a s.t. a[akey] != b[akey] */ - PyObject *aval = NULL; /* a[akey] */ - Py_ssize_t i; - int cmp; - - for (i = 0; i <= a->ma_mask; i++) { - PyObject *thiskey, *thisaval, *thisbval; - if (a->ma_table[i].me_value == NULL) - continue; - thiskey = a->ma_table[i].me_key; - Py_INCREF(thiskey); /* keep alive across compares */ - if (akey != NULL) { - cmp = PyObject_RichCompareBool(akey, thiskey, Py_LT); - if (cmp < 0) { - Py_DECREF(thiskey); - goto Fail; - } - if (cmp > 0 || - i > a->ma_mask || - a->ma_table[i].me_value == NULL) - { - /* Not the *smallest* a key; or maybe it is - * but the compare shrunk the dict so we can't - * find its associated value anymore; or - * maybe it is but the compare deleted the - * a[thiskey] entry. - */ - Py_DECREF(thiskey); - continue; - } - } - - /* Compare a[thiskey] to b[thiskey]; cmp <- true iff equal. */ - thisaval = a->ma_table[i].me_value; - assert(thisaval); - Py_INCREF(thisaval); /* keep alive */ - thisbval = PyDict_GetItem((PyObject *)b, thiskey); - if (thisbval == NULL) - cmp = 0; - else { - /* both dicts have thiskey: same values? */ - cmp = PyObject_RichCompareBool( - thisaval, thisbval, Py_EQ); - if (cmp < 0) { - Py_DECREF(thiskey); - Py_DECREF(thisaval); - goto Fail; - } - } - if (cmp == 0) { - /* New winner. */ - Py_XDECREF(akey); - Py_XDECREF(aval); - akey = thiskey; - aval = thisaval; - } - else { - Py_DECREF(thiskey); - Py_DECREF(thisaval); - } - } - *pval = aval; - return akey; - -Fail: - Py_XDECREF(akey); - Py_XDECREF(aval); - *pval = NULL; - return NULL; -} - -static int -dict_compare(dictobject *a, dictobject *b) -{ - PyObject *adiff, *bdiff, *aval, *bval; - int res; - - /* Compare lengths first */ - if (a->ma_used < b->ma_used) - return -1; /* a is shorter */ - else if (a->ma_used > b->ma_used) - return 1; /* b is shorter */ - - /* Same length -- check all keys */ - bdiff = bval = NULL; - adiff = characterize(a, b, &aval); - if (adiff == NULL) { - assert(!aval); - /* Either an error, or a is a subset with the same length so - * must be equal. - */ - res = PyErr_Occurred() ? -1 : 0; - goto Finished; - } - bdiff = characterize(b, a, &bval); - if (bdiff == NULL && PyErr_Occurred()) { - assert(!bval); - res = -1; - goto Finished; - } - res = 0; - if (bdiff) { - /* bdiff == NULL "should be" impossible now, but perhaps - * the last comparison done by the characterize() on a had - * the side effect of making the dicts equal! - */ - res = PyObject_Compare(adiff, bdiff); - } - if (res == 0 && bval != NULL) - res = PyObject_Compare(aval, bval); - -Finished: - Py_XDECREF(adiff); - Py_XDECREF(bdiff); - Py_XDECREF(aval); - Py_XDECREF(bval); - return res; -} - /* Return 1 if dicts equal, 0 if not, -1 if error. * Gets out as soon as any difference is detected. * Uses only Py_EQ comparison. @@ -1585,9 +1503,14 @@ /* temporarily bump aval's refcount to ensure it stays alive until we're done with it */ Py_INCREF(aval); - bval = PyDict_GetItem((PyObject *)b, key); + /* ditto for key */ + Py_INCREF(key); + bval = PyDict_GetItemWithError((PyObject *)b, key); + Py_DECREF(key); if (bval == NULL) { Py_DECREF(aval); + if (PyErr_Occurred()) + return -1; return 0; } cmp = PyObject_RichCompareBool(aval, bval, Py_EQ); @@ -1739,7 +1662,7 @@ Py_INCREF(deflt); return deflt; } - PyErr_SetObject(PyExc_KeyError, key); + set_key_error(key); return NULL; } old_key = ep->me_key; @@ -2028,7 +1951,7 @@ (printfunc)dict_print, /* tp_print */ 0, /* tp_getattr */ 0, /* tp_setattr */ - (cmpfunc)dict_compare, /* tp_compare */ + 0, /* tp_compare */ (reprfunc)dict_repr, /* tp_repr */ 0, /* tp_as_number */ &dict_as_sequence, /* tp_as_sequence */ Modified: python/branches/p3yk-noslice/Objects/exceptions.c ============================================================================== --- python/branches/p3yk-noslice/Objects/exceptions.c (original) +++ python/branches/p3yk-noslice/Objects/exceptions.c Fri Dec 15 05:21:50 2006 @@ -81,6 +81,7 @@ static void BaseException_dealloc(PyBaseExceptionObject *self) { + _PyObject_GC_UNTRACK(self); BaseException_clear(self); self->ob_type->tp_free((PyObject *)self); } @@ -174,27 +175,10 @@ Py_RETURN_NONE; } -#ifdef Py_USING_UNICODE -/* while this method generates fairly uninspired output, it a least - * guarantees that we can display exceptions that have unicode attributes - */ -static PyObject * -BaseException_unicode(PyBaseExceptionObject *self) -{ - if (PyTuple_GET_SIZE(self->args) == 0) - return PyUnicode_FromUnicode(NULL, 0); - if (PyTuple_GET_SIZE(self->args) == 1) - return PyObject_Unicode(PyTuple_GET_ITEM(self->args, 0)); - return PyObject_Unicode(self->args); -} -#endif /* Py_USING_UNICODE */ static PyMethodDef BaseException_methods[] = { {"__reduce__", (PyCFunction)BaseException_reduce, METH_NOARGS }, {"__setstate__", (PyCFunction)BaseException_setstate, METH_O }, -#ifdef Py_USING_UNICODE - {"__unicode__", (PyCFunction)BaseException_unicode, METH_NOARGS }, -#endif {NULL, NULL, 0, NULL}, }; @@ -206,12 +190,19 @@ return PySequence_GetItem(self->args, index); } +static PyObject * +BaseException_getslice(PyBaseExceptionObject *self, + Py_ssize_t start, Py_ssize_t stop) +{ + return PySequence_GetSlice(self->args, start, stop); +} + static PySequenceMethods BaseException_as_sequence = { 0, /* sq_length; */ 0, /* sq_concat; */ 0, /* sq_repeat; */ (ssizeargfunc)BaseException_getitem, /* sq_item; */ - 0, /* sq_slice; */ + (ssizessizeargfunc)BaseException_getslice, /* sq_slice; */ 0, /* sq_ass_item; */ 0, /* sq_ass_slice; */ 0, /* sq_contains; */ @@ -456,6 +447,7 @@ static void SystemExit_dealloc(PySystemExitObject *self) { + _PyObject_GC_UNTRACK(self); SystemExit_clear(self); self->ob_type->tp_free((PyObject *)self); } @@ -518,7 +510,7 @@ if (BaseException_init((PyBaseExceptionObject *)self, args, kwds) == -1) return -1; - if (PyTuple_GET_SIZE(args) <= 1) { + if (PyTuple_GET_SIZE(args) <= 1 || PyTuple_GET_SIZE(args) > 3) { return 0; } @@ -562,6 +554,7 @@ static void EnvironmentError_dealloc(PyEnvironmentErrorObject *self) { + _PyObject_GC_UNTRACK(self); EnvironmentError_clear(self); self->ob_type->tp_free((PyObject *)self); } @@ -760,6 +753,7 @@ static void WindowsError_dealloc(PyWindowsErrorObject *self) { + _PyObject_GC_UNTRACK(self); WindowsError_clear(self); self->ob_type->tp_free((PyObject *)self); } @@ -834,9 +828,9 @@ return NULL; } - if (self->myerrno) { - Py_INCREF(self->myerrno); - PyTuple_SET_ITEM(tuple, 0, self->myerrno); + if (self->winerror) { + Py_INCREF(self->winerror); + PyTuple_SET_ITEM(tuple, 0, self->winerror); } else { Py_INCREF(Py_None); @@ -858,7 +852,7 @@ Py_DECREF(fmt); Py_DECREF(tuple); } - else if (self->myerrno && self->strerror) { + else if (self->winerror && self->strerror) { PyObject *fmt; PyObject *tuple; @@ -872,9 +866,9 @@ return NULL; } - if (self->myerrno) { - Py_INCREF(self->myerrno); - PyTuple_SET_ITEM(tuple, 0, self->myerrno); + if (self->winerror) { + Py_INCREF(self->winerror); + PyTuple_SET_ITEM(tuple, 0, self->winerror); } else { Py_INCREF(Py_None); @@ -1035,6 +1029,7 @@ static void SyntaxError_dealloc(PySyntaxErrorObject *self) { + _PyObject_GC_UNTRACK(self); SyntaxError_clear(self); self->ob_type->tp_free((PyObject *)self); } @@ -1551,6 +1546,7 @@ static void UnicodeError_dealloc(PyUnicodeErrorObject *self) { + _PyObject_GC_UNTRACK(self); UnicodeError_clear(self); self->ob_type->tp_free((PyObject *)self); } @@ -1637,7 +1633,7 @@ static PyTypeObject _PyExc_UnicodeEncodeError = { PyObject_HEAD_INIT(NULL) 0, - "UnicodeEncodeError", + EXC_MODULE_NAME "UnicodeEncodeError", sizeof(PyUnicodeErrorObject), 0, (destructor)UnicodeError_dealloc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, (reprfunc)UnicodeEncodeError_str, 0, 0, 0, @@ -1812,7 +1808,7 @@ (destructor)UnicodeError_dealloc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, (reprfunc)UnicodeTranslateError_str, 0, 0, 0, Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE | Py_TPFLAGS_HAVE_GC, - PyDoc_STR("Unicode decoding error."), (traverseproc)UnicodeError_traverse, + PyDoc_STR("Unicode translation error."), (traverseproc)UnicodeError_traverse, (inquiry)UnicodeError_clear, 0, 0, 0, 0, 0, UnicodeError_members, 0, &_PyExc_UnicodeError, 0, 0, 0, offsetof(PyUnicodeErrorObject, dict), (initproc)UnicodeTranslateError_init, 0, BaseException_new, Modified: python/branches/p3yk-noslice/Objects/fileobject.c ============================================================================== --- python/branches/p3yk-noslice/Objects/fileobject.c (original) +++ python/branches/p3yk-noslice/Objects/fileobject.c Fri Dec 15 05:21:50 2006 @@ -540,7 +540,7 @@ int whence; int ret; Py_off_t offset; - PyObject *offobj; + PyObject *offobj, *off_index; if (f->f_fp == NULL) return err_closed(); @@ -548,12 +548,25 @@ whence = 0; if (!PyArg_ParseTuple(args, "O|i:seek", &offobj, &whence)) return NULL; + off_index = PyNumber_Index(offobj); + if (!off_index) { + if (!PyFloat_Check(offobj)) + return NULL; + /* Deprecated in 2.6 */ + PyErr_Clear(); + if (PyErr_Warn(PyExc_DeprecationWarning, + "integer argument expected, got float")) + return NULL; + off_index = offobj; + Py_INCREF(offobj); + } #if !defined(HAVE_LARGEFILE_SUPPORT) - offset = PyInt_AsLong(offobj); + offset = PyInt_AsLong(off_index); #else - offset = PyLong_Check(offobj) ? - PyLong_AsLongLong(offobj) : PyInt_AsLong(offobj); + offset = PyLong_Check(off_index) ? + PyLong_AsLongLong(off_index) : PyInt_AsLong(off_index); #endif + Py_DECREF(off_index); if (PyErr_Occurred()) return NULL; @@ -927,7 +940,7 @@ ndone += nnow; ntodo -= nnow; } - return PyInt_FromLong((long)ndone); + return PyInt_FromSsize_t(ndone); } /************************************************************************** @@ -1006,6 +1019,7 @@ size_t nfree; /* # of free buffer slots; pvend-pvfree */ size_t total_v_size; /* total # of slots in buffer */ size_t increment; /* amount to increment the buffer */ + size_t prev_v_size; /* Optimize for normal case: avoid _PyString_Resize if at all * possible via first reading into stack buffer "buf". @@ -1120,8 +1134,11 @@ /* expand buffer and try again */ assert(*(pvend-1) == '\0'); increment = total_v_size >> 2; /* mild exponential growth */ + prev_v_size = total_v_size; total_v_size += increment; - if (total_v_size > PY_SSIZE_T_MAX) { + /* check for overflow */ + if (total_v_size <= prev_v_size || + total_v_size > PY_SSIZE_T_MAX) { PyErr_SetString(PyExc_OverflowError, "line is longer than a Python string can hold"); Py_DECREF(v); @@ -1130,7 +1147,7 @@ if (_PyString_Resize(&v, (int)total_v_size) < 0) return NULL; /* overwrite the trailing null byte */ - pvfree = BUF(v) + (total_v_size - increment - 1); + pvfree = BUF(v) + (prev_v_size - 1); } if (BUF(v) + total_v_size != p) _PyString_Resize(&v, p - BUF(v)); @@ -2014,7 +2031,7 @@ if (!PyArg_ParseTupleAndKeywords(args, kwds, "O|si:file", kwlist, &o_name, &mode, &bufsize)) - return -1; + goto Error; if (fill_file_fields(foself, NULL, o_name, mode, fclose) == NULL) Modified: python/branches/p3yk-noslice/Objects/floatobject.c ============================================================================== --- python/branches/p3yk-noslice/Objects/floatobject.c (original) +++ python/branches/p3yk-noslice/Objects/floatobject.c Fri Dec 15 05:21:50 2006 @@ -837,7 +837,7 @@ } static int -float_nonzero(PyFloatObject *v) +float_bool(PyFloatObject *v) { return v->ob_fval != 0.0; } @@ -1087,7 +1087,7 @@ (unaryfunc)float_neg, /*nb_negative*/ (unaryfunc)float_pos, /*nb_positive*/ (unaryfunc)float_abs, /*nb_absolute*/ - (inquiry)float_nonzero, /*nb_nonzero*/ + (inquiry)float_bool, /*nb_bool*/ 0, /*nb_invert*/ 0, /*nb_lshift*/ 0, /*nb_rshift*/ Modified: python/branches/p3yk-noslice/Objects/funcobject.c ============================================================================== --- python/branches/p3yk-noslice/Objects/funcobject.c (original) +++ python/branches/p3yk-noslice/Objects/funcobject.c Fri Dec 15 05:21:50 2006 @@ -24,6 +24,7 @@ op->func_name = ((PyCodeObject *)code)->co_name; Py_INCREF(op->func_name); op->func_defaults = NULL; /* No default arguments */ + op->func_kwdefaults = NULL; /* No keyword only defaults */ op->func_closure = NULL; consts = ((PyCodeObject *)code)->co_consts; if (PyTuple_Size(consts) >= 1) { @@ -122,6 +123,38 @@ } PyObject * +PyFunction_GetKwDefaults(PyObject *op) +{ + if (!PyFunction_Check(op)) { + PyErr_BadInternalCall(); + return NULL; + } + return ((PyFunctionObject *) op) -> func_kwdefaults; +} + +int +PyFunction_SetKwDefaults(PyObject *op, PyObject *defaults) +{ + if (!PyFunction_Check(op)) { + PyErr_BadInternalCall(); + return -1; + } + if (defaults == Py_None) + defaults = NULL; + else if (defaults && PyDict_Check(defaults)) { + Py_INCREF(defaults); + } + else { + PyErr_SetString(PyExc_SystemError, + "non-dict keyword only default args"); + return -1; + } + Py_XDECREF(((PyFunctionObject *)op) -> func_kwdefaults); + ((PyFunctionObject *) op) -> func_kwdefaults = defaults; + return 0; +} + +PyObject * PyFunction_GetClosure(PyObject *op) { if (!PyFunction_Check(op)) { @@ -325,10 +358,49 @@ return 0; } +static PyObject * +func_get_kwdefaults(PyFunctionObject *op) +{ + if (restricted()) + return NULL; + if (op->func_kwdefaults == NULL) { + Py_INCREF(Py_None); + return Py_None; + } + Py_INCREF(op->func_kwdefaults); + return op->func_kwdefaults; +} + +static int +func_set_kwdefaults(PyFunctionObject *op, PyObject *value) +{ + PyObject *tmp; + + if (restricted()) + return -1; + + if (value == Py_None) + value = NULL; + /* Legal to del f.func_defaults. + * Can only set func_kwdefaults to NULL or a dict. */ + if (value != NULL && !PyDict_Check(value)) { + PyErr_SetString(PyExc_TypeError, + "func_kwdefaults must be set to a dict object"); + return -1; + } + tmp = op->func_kwdefaults; + Py_XINCREF(value); + op->func_kwdefaults = value; + Py_XDECREF(tmp); + return 0; +} + static PyGetSetDef func_getsetlist[] = { {"func_code", (getter)func_get_code, (setter)func_set_code}, {"func_defaults", (getter)func_get_defaults, (setter)func_set_defaults}, + {"func_kwdefaults", (getter)func_get_kwdefaults, + (setter)func_set_kwdefaults}, {"func_dict", (getter)func_get_dict, (setter)func_set_dict}, {"__dict__", (getter)func_get_dict, (setter)func_set_dict}, {"func_name", (getter)func_get_name, (setter)func_set_name}, @@ -519,6 +591,7 @@ PyFunction_GET_GLOBALS(func), (PyObject *)NULL, &PyTuple_GET_ITEM(arg, 0), PyTuple_Size(arg), k, nk, d, nd, + PyFunction_GET_KW_DEFAULTS(func), PyFunction_GET_CLOSURE(func)); if (k != NULL) Modified: python/branches/p3yk-noslice/Objects/intobject.c ============================================================================== --- python/branches/p3yk-noslice/Objects/intobject.c (original) +++ python/branches/p3yk-noslice/Objects/intobject.c Fri Dec 15 05:21:50 2006 @@ -446,6 +446,17 @@ return (i < j) ? -1 : (i > j) ? 1 : 0; } +static PyObject * +int_richcompare(PyObject *self, PyObject *other, int op) +{ + if (!PyInt_Check(self) || !PyInt_Check(other)) { + Py_INCREF(Py_NotImplemented); + return Py_NotImplemented; + } + return Py_CmpToRich(op, int_compare((PyIntObject *)self, + (PyIntObject *)other)); +} + static long int_hash(PyIntObject *v) { @@ -546,6 +557,17 @@ } } +/* Integer overflow checking for unary negation: on a 2's-complement + * box, -x overflows iff x is the most negative long. In this case we + * get -x == x. However, -x is undefined (by C) if x /is/ the most + * negative long (it's a signed overflow case), and some compilers care. + * So we cast x to unsigned long first. However, then other compilers + * warn about applying unary minus to an unsigned operand. Hence the + * weird "0-". + */ +#define UNARY_NEG_WOULD_OVERFLOW(x) \ + ((x) < 0 && (unsigned long)(x) == 0-(unsigned long)(x)) + /* Return type of i_divmod */ enum divmod_result { DIVMOD_OK, /* Correct result */ @@ -565,7 +587,7 @@ return DIVMOD_ERROR; } /* (-sys.maxint-1)/-1 is the only overflow case. */ - if (y == -1 && x < 0 && x == -x) + if (y == -1 && UNARY_NEG_WOULD_OVERFLOW(x)) return DIVMOD_OVERFLOW; xdivy = x / y; xmody = x - xdivy * y; @@ -733,10 +755,10 @@ static PyObject * int_neg(PyIntObject *v) { - register long a, x; + register long a; a = v->ob_ival; - x = -a; - if (a < 0 && x < 0) { + /* check for overflow */ + if (UNARY_NEG_WOULD_OVERFLOW(a)) { PyObject *o = PyLong_FromLong(a); if (o != NULL) { PyObject *result = PyNumber_Negative(o); @@ -745,7 +767,7 @@ } return NULL; } - return PyInt_FromLong(x); + return PyInt_FromLong(-a); } static PyObject * @@ -769,7 +791,7 @@ } static int -int_nonzero(PyIntObject *v) +int_bool(PyIntObject *v) { return v->ob_ival != 0; } @@ -944,8 +966,25 @@ return PyInt_FromLong(0L); if (base == -909) return PyNumber_Int(x); - if (PyString_Check(x)) - return PyInt_FromString(PyString_AS_STRING(x), NULL, base); + if (PyString_Check(x)) { + /* Since PyInt_FromString doesn't have a length parameter, + * check here for possible NULs in the string. */ + char *string = PyString_AS_STRING(x); + if (strlen(string) != PyString_Size(x)) { + /* create a repr() of the input string, + * just like PyInt_FromString does */ + PyObject *srepr; + srepr = PyObject_Repr(x); + if (srepr == NULL) + return NULL; + PyErr_Format(PyExc_ValueError, + "invalid literal for int() with base %d: %s", + base, PyString_AS_STRING(srepr)); + Py_DECREF(srepr); + return NULL; + } + return PyInt_FromString(string, NULL, base); + } #ifdef Py_USING_UNICODE if (PyUnicode_Check(x)) return PyInt_FromUnicode(PyUnicode_AS_UNICODE(x), @@ -1023,14 +1062,14 @@ (unaryfunc)int_neg, /*nb_negative*/ (unaryfunc)int_pos, /*nb_positive*/ (unaryfunc)int_abs, /*nb_absolute*/ - (inquiry)int_nonzero, /*nb_nonzero*/ + (inquiry)int_bool, /*nb_bool*/ (unaryfunc)int_invert, /*nb_invert*/ (binaryfunc)int_lshift, /*nb_lshift*/ (binaryfunc)int_rshift, /*nb_rshift*/ (binaryfunc)int_and, /*nb_and*/ (binaryfunc)int_xor, /*nb_xor*/ (binaryfunc)int_or, /*nb_or*/ - 0, /*nb_coerce*/ + 0, /*nb_coerce*/ (unaryfunc)int_int, /*nb_int*/ (unaryfunc)int_long, /*nb_long*/ (unaryfunc)int_float, /*nb_float*/ @@ -1063,7 +1102,7 @@ (printfunc)int_print, /* tp_print */ 0, /* tp_getattr */ 0, /* tp_setattr */ - (cmpfunc)int_compare, /* tp_compare */ + 0, /* tp_compare */ (reprfunc)int_repr, /* tp_repr */ &int_as_number, /* tp_as_number */ 0, /* tp_as_sequence */ @@ -1078,7 +1117,7 @@ int_doc, /* tp_doc */ 0, /* tp_traverse */ 0, /* tp_clear */ - 0, /* tp_richcompare */ + int_richcompare, /* tp_richcompare */ 0, /* tp_weaklistoffset */ 0, /* tp_iter */ 0, /* tp_iternext */ Modified: python/branches/p3yk-noslice/Objects/iterobject.c ============================================================================== --- python/branches/p3yk-noslice/Objects/iterobject.c (original) +++ python/branches/p3yk-noslice/Objects/iterobject.c Fri Dec 15 05:21:50 2006 @@ -230,3 +230,176 @@ (iternextfunc)calliter_iternext, /* tp_iternext */ 0, /* tp_methods */ }; + + +/*********************** Zip Iterator **************************/ +/* Largely copied from itertools.c by Brian Holmes */ + +typedef struct zipiterobject_t { + PyObject_HEAD + PyTupleObject *it_tuple; /* Set to NULL when iterator is exhausted */ + Py_ssize_t resultsize; + PyTupleObject *result; /* Reusable tuple for optimization */ +} zipiterobject; + +static PyTypeObject PyZipIter_Type; /* Forward */ + +PyObject * +_PyZip_CreateIter(PyObject* args) +{ + Py_ssize_t i; + Py_ssize_t tuplesize; + PyObject* ziptuple; + PyObject* result; + struct zipiterobject_t* zipiter; + + assert(PyTuple_Check(args)); + + if (PyZipIter_Type.ob_type == NULL) { + if (PyType_Ready(&PyZipIter_Type) < 0) + return NULL; + } + + tuplesize = PySequence_Length((PyObject*) args); + + ziptuple = PyTuple_New(tuplesize); + if (ziptuple == NULL) + return NULL; + + for (i = 0; i < tuplesize; i++) { + PyObject *o = PyTuple_GET_ITEM(args, i); + PyObject *it = PyObject_GetIter(o); + if (it == NULL) { + /* XXX Should we do this? + if (PyErr_ExceptionMatches(PyExc_TypeError)) + PyErr_Format(PyExc_TypeError, + "zip argument #%zd must support iteration", + I+1); + */ + Py_DECREF(ziptuple); + return NULL; + } + PyTuple_SET_ITEM(ziptuple, i, it); + } + + /* create a reusable result holder */ + result = PyTuple_New(tuplesize); + if (result == NULL) { + Py_DECREF(ziptuple); + return NULL; + } + for (i = 0; i < tuplesize; i++) { + Py_INCREF(Py_None); + PyTuple_SET_ITEM(result, i, Py_None); + } + + zipiter = PyObject_GC_New(zipiterobject, &PyZipIter_Type); + if (zipiter == NULL) { + Py_DECREF(ziptuple); + Py_DECREF(result); + return NULL; + } + + zipiter->result = (PyTupleObject*) result; + zipiter->resultsize = tuplesize; + Py_INCREF(ziptuple); + zipiter->it_tuple = (PyTupleObject *) ziptuple; + _PyObject_GC_TRACK(zipiter); + return (PyObject *)zipiter; +} + +static void +zipiter_dealloc(zipiterobject *it) +{ + _PyObject_GC_UNTRACK(it); + Py_XDECREF(it->it_tuple); + Py_XDECREF(it->result); + PyObject_GC_Del(it); +} + +static int +zipiter_traverse(zipiterobject *it, visitproc visit, void *arg) +{ + Py_VISIT(it->it_tuple); + Py_VISIT(it->result); + return 0; +} + +static PyObject * +zipiter_next(zipiterobject *zit) +{ + Py_ssize_t i; + Py_ssize_t tuplesize = zit->resultsize; + PyObject *result = (PyObject*) zit->result; + PyObject *olditem; + + if (tuplesize == 0) + return NULL; + + if (result->ob_refcnt == 1) { + Py_INCREF(result); + for (i = 0; i < tuplesize; i++) { + PyObject *it = PyTuple_GET_ITEM(zit->it_tuple, i); + PyObject *item; + assert(PyIter_Check(it)); + item = (*it->ob_type->tp_iternext)(it); + if (item == NULL) { + Py_DECREF(result); + return NULL; + } + olditem = PyTuple_GET_ITEM(result, i); + PyTuple_SET_ITEM(result, i, item); + Py_DECREF(olditem); + } + } else { + result = PyTuple_New(tuplesize); + if (result == NULL) + return NULL; + for (i = 0; i < tuplesize; i++) { + PyObject *it = PyTuple_GET_ITEM(zit->it_tuple, i); + PyObject *item; + assert(PyIter_Check(it)); + item = (*it->ob_type->tp_iternext)(it); + if (item == NULL) { + Py_DECREF(result); + return NULL; + } + PyTuple_SET_ITEM(result, i, item); + } + } + return result; +} + +static PyTypeObject PyZipIter_Type = { + PyObject_HEAD_INIT(0) + 0, /* ob_size */ + "zipiterator", /* tp_name */ + sizeof(zipiterobject), /* tp_basicsize */ + 0, /* tp_itemsize */ + /* methods */ + (destructor)zipiter_dealloc, /* tp_dealloc */ + 0, /* tp_print */ + 0, /* tp_getattr */ + 0, /* tp_setattr */ + 0, /* tp_compare */ + 0, /* tp_repr */ + 0, /* tp_as_number */ + 0, /* tp_as_sequence */ + 0, /* tp_as_mapping */ + 0, /* tp_hash */ + 0, /* tp_call */ + 0, /* tp_str */ + PyObject_GenericGetAttr, /* tp_getattro */ + 0, /* tp_setattro */ + 0, /* tp_as_buffer */ + Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC,/* tp_flags */ + 0, /* tp_doc */ + (traverseproc)zipiter_traverse, /* tp_traverse */ + 0, /* tp_clear */ + 0, /* tp_richcompare */ + 0, /* tp_weakzipoffset */ + PyObject_SelfIter, /* tp_iter */ + (iternextfunc)zipiter_next, /* tp_iternext */ + 0, /* tp_methods */ + 0, /* tp_members */ +}; Modified: python/branches/p3yk-noslice/Objects/listobject.c ============================================================================== --- python/branches/p3yk-noslice/Objects/listobject.c (original) +++ python/branches/p3yk-noslice/Objects/listobject.c Fri Dec 15 05:21:50 2006 @@ -863,17 +863,12 @@ listpop(PyListObject *self, PyObject *args) { Py_ssize_t i = -1; - PyObject *v, *arg = NULL; + PyObject *v; int status; - if (!PyArg_UnpackTuple(args, "pop", 0, 1, &arg)) + if (!PyArg_ParseTuple(args, "|n:pop", &i)) return NULL; - if (arg != NULL) { - if (PyInt_Check(arg)) - i = PyInt_AS_LONG((PyIntObject*) arg); - else if (!PyArg_ParseTuple(args, "|n:pop", &i)) - return NULL; - } + if (self->ob_size == 0) { /* Special-case most common failure cause */ PyErr_SetString(PyExc_IndexError, "pop from empty list"); @@ -951,9 +946,10 @@ if (res == NULL) return -1; if (!PyInt_Check(res)) { + PyErr_Format(PyExc_TypeError, + "comparison function must return int, not %.200s", + res->ob_type->tp_name); Py_DECREF(res); - PyErr_SetString(PyExc_TypeError, - "comparison function must return int"); return -1; } i = PyInt_AsLong(res); @@ -1971,6 +1967,26 @@ return (PyObject *)co; } +static int +is_default_cmp(PyObject *cmpfunc) +{ + PyCFunctionObject *f; + if (cmpfunc == NULL || cmpfunc == Py_None) + return 1; + if (!PyCFunction_Check(cmpfunc)) + return 0; + f = (PyCFunctionObject *)cmpfunc; + if (f->m_self != NULL) + return 0; + if (!PyString_Check(f->m_module)) + return 0; + if (strcmp(PyString_AS_STRING(f->m_module), "__builtin__") != 0) + return 0; + if (strcmp(f->m_ml->ml_name, "cmp") != 0) + return 0; + return 1; +} + /* An adaptive, stable, natural mergesort. See listsort.txt. * Returns Py_None on success, NULL on error. Even in case of error, the * list will be some permutation of its input state (nothing is lost or @@ -2001,7 +2017,7 @@ kwlist, &compare, &keyfunc, &reverse)) return NULL; } - if (compare == Py_None) + if (is_default_cmp(compare)) compare = NULL; if (keyfunc == Py_None) keyfunc = NULL; @@ -2490,8 +2506,9 @@ } } else { - PyErr_SetString(PyExc_TypeError, - "list indices must be integers"); + PyErr_Format(PyExc_TypeError, + "list indices must be integers, not %.200s", + item->ob_type->tp_name); return NULL; } } @@ -2613,6 +2630,11 @@ garbage = (PyObject**) PyMem_MALLOC(slicelength*sizeof(PyObject*)); + if (!garbage) { + Py_DECREF(seq); + PyErr_NoMemory(); + return -1; + } selfitems = self->ob_item; seqitems = PySequence_Fast_ITEMS(seq); @@ -2635,8 +2657,9 @@ } } else { - PyErr_SetString(PyExc_TypeError, - "list indices must be integers"); + PyErr_Format(PyExc_TypeError, + "list indices must be integers, not %.200s", + item->ob_type->tp_name); return -1; } } Modified: python/branches/p3yk-noslice/Objects/longobject.c ============================================================================== --- python/branches/p3yk-noslice/Objects/longobject.c (original) +++ python/branches/p3yk-noslice/Objects/longobject.c Fri Dec 15 05:21:50 2006 @@ -1,5 +1,3 @@ - - /* Long (arbitrary precision) integer object implementation */ /* XXX The functional organization of this file is terrible */ @@ -193,6 +191,18 @@ return (PyObject *)v; } +/* Checking for overflow in PyLong_AsLong is a PITA since C doesn't define + * anything about what happens when a signed integer operation overflows, + * and some compilers think they're doing you a favor by being "clever" + * then. The bit pattern for the largest postive signed long is + * (unsigned long)LONG_MAX, and for the smallest negative signed long + * it is abs(LONG_MIN), which we could write -(unsigned long)LONG_MIN. + * However, some other compilers warn about applying unary minus to an + * unsigned operand. Hence the weird "0-". + */ +#define PY_ABS_LONG_MIN (0-(unsigned long)LONG_MIN) +#define PY_ABS_SSIZE_T_MIN (0-(size_t)PY_SSIZE_T_MIN) + /* Get a C long int from a long int object. Returns -1 and sets an error condition if overflow occurs. */ @@ -225,14 +235,16 @@ if ((x >> SHIFT) != prev) goto overflow; } - /* Haven't lost any bits, but if the sign bit is set we're in - * trouble *unless* this is the min negative number. So, - * trouble iff sign bit set && (positive || some bit set other - * than the sign bit). - */ - if ((long)x < 0 && (sign > 0 || (x << 1) != 0)) - goto overflow; - return (long)x * sign; + /* Haven't lost any bits, but casting to long requires extra care + * (see comment above). + */ + if (x <= (unsigned long)LONG_MAX) { + return (long)x * sign; + } + else if (sign < 0 && x == PY_ABS_LONG_MIN) { + return LONG_MIN; + } + /* else overflow */ overflow: PyErr_SetString(PyExc_OverflowError, @@ -268,14 +280,16 @@ if ((x >> SHIFT) != prev) goto overflow; } - /* Haven't lost any bits, but if the sign bit is set we're in - * trouble *unless* this is the min negative number. So, - * trouble iff sign bit set && (positive || some bit set other - * than the sign bit). + /* Haven't lost any bits, but casting to a signed type requires + * extra care (see comment above). */ - if ((Py_ssize_t)x < 0 && (sign > 0 || (x << 1) != 0)) - goto overflow; - return (Py_ssize_t)x * sign; + if (x <= (size_t)PY_SSIZE_T_MAX) { + return (Py_ssize_t)x * sign; + } + else if (sign < 0 && x == PY_ABS_SSIZE_T_MIN) { + return PY_SSIZE_T_MIN; + } + /* else overflow */ overflow: PyErr_SetString(PyExc_OverflowError, @@ -1167,7 +1181,7 @@ { register PyLongObject *a = (PyLongObject *)aa; PyStringObject *str; - Py_ssize_t i; + Py_ssize_t i, j, sz; Py_ssize_t size_a; char *p; int bits; @@ -1187,11 +1201,18 @@ ++bits; i >>= 1; } - i = 5 + (size_a*SHIFT + bits-1) / bits; - str = (PyStringObject *) PyString_FromStringAndSize((char *)0, i); + i = 5; + j = size_a*SHIFT + bits-1; + sz = i + j / bits; + if (j / SHIFT < size_a || sz < i) { + PyErr_SetString(PyExc_OverflowError, + "long is too large to format"); + return NULL; + } + str = (PyStringObject *) PyString_FromStringAndSize((char *)0, sz); if (str == NULL) return NULL; - p = PyString_AS_STRING(str) + i; + p = PyString_AS_STRING(str) + sz; *p = '\0'; if (a->ob_size < 0) sign = '-'; @@ -1303,7 +1324,7 @@ } while ((*q++ = *p++) != '\0'); q--; _PyString_Resize((PyObject **)&str, - (int) (q - PyString_AS_STRING(str))); + (Py_ssize_t) (q - PyString_AS_STRING(str))); } return (PyObject *)str; } @@ -1361,14 +1382,14 @@ while (_PyLong_DigitValue[Py_CHARMASK(*p)] < base) ++p; *str = p; - n = (p - start) * bits_per_char; - if (n / bits_per_char != p - start) { + /* n <- # of Python digits needed, = ceiling(n/SHIFT). */ + n = (p - start) * bits_per_char + SHIFT - 1; + if (n / bits_per_char < p - start) { PyErr_SetString(PyExc_ValueError, "long string too large to convert"); return NULL; } - /* n <- # of Python digits needed, = ceiling(n/SHIFT). */ - n = (n + SHIFT - 1) / SHIFT; + n = n / SHIFT; z = _PyLong_New(n); if (z == NULL) return NULL; @@ -1882,6 +1903,14 @@ return sign < 0 ? -1 : sign > 0 ? 1 : 0; } +static PyObject * +long_richcompare(PyObject *self, PyObject *other, int op) +{ + PyLongObject *a, *b; + CONVERT_BINOP((PyObject *)self, (PyObject *)other, &a, &b); + return Py_CmpToRich(op, long_compare(a, b)); +} + static long long_hash(PyLongObject *v) { @@ -2880,7 +2909,7 @@ } static int -long_nonzero(PyLongObject *v) +long_bool(PyLongObject *v) { return ABS(v->ob_size) != 0; } @@ -3152,22 +3181,6 @@ return c; } -static int -long_coerce(PyObject **pv, PyObject **pw) -{ - if (PyInt_Check(*pw)) { - *pw = PyLong_FromLong(PyInt_AS_LONG(*pw)); - Py_INCREF(*pv); - return 0; - } - else if (PyLong_Check(*pw)) { - Py_INCREF(*pv); - Py_INCREF(*pw); - return 0; - } - return 1; /* Can't do it */ -} - static PyObject * long_long(PyObject *v) { @@ -3317,14 +3330,14 @@ (unaryfunc) long_neg, /*nb_negative*/ (unaryfunc) long_pos, /*tp_positive*/ (unaryfunc) long_abs, /*tp_absolute*/ - (inquiry) long_nonzero, /*tp_nonzero*/ + (inquiry) long_bool, /*tp_bool*/ (unaryfunc) long_invert, /*nb_invert*/ long_lshift, /*nb_lshift*/ (binaryfunc) long_rshift, /*nb_rshift*/ long_and, /*nb_and*/ long_xor, /*nb_xor*/ long_or, /*nb_or*/ - long_coerce, /*nb_coerce*/ + 0, /*nb_coerce*/ long_int, /*nb_int*/ long_long, /*nb_long*/ long_float, /*nb_float*/ @@ -3357,7 +3370,7 @@ 0, /* tp_print */ 0, /* tp_getattr */ 0, /* tp_setattr */ - (cmpfunc)long_compare, /* tp_compare */ + 0, /* tp_compare */ long_repr, /* tp_repr */ &long_as_number, /* tp_as_number */ 0, /* tp_as_sequence */ @@ -3372,7 +3385,7 @@ long_doc, /* tp_doc */ 0, /* tp_traverse */ 0, /* tp_clear */ - 0, /* tp_richcompare */ + long_richcompare, /* tp_richcompare */ 0, /* tp_weaklistoffset */ 0, /* tp_iter */ 0, /* tp_iternext */ Modified: python/branches/p3yk-noslice/Objects/methodobject.c ============================================================================== --- python/branches/p3yk-noslice/Objects/methodobject.c (original) +++ python/branches/p3yk-noslice/Objects/methodobject.c Fri Dec 15 05:21:50 2006 @@ -196,17 +196,31 @@ m->m_self); } -static int -meth_compare(PyCFunctionObject *a, PyCFunctionObject *b) +static PyObject * +meth_richcompare(PyObject *self, PyObject *other, int op) { - if (a->m_self != b->m_self) - return (a->m_self < b->m_self) ? -1 : 1; - if (a->m_ml->ml_meth == b->m_ml->ml_meth) - return 0; - if (strcmp(a->m_ml->ml_name, b->m_ml->ml_name) < 0) - return -1; + PyCFunctionObject *a, *b; + PyObject *res; + int eq; + + if ((op != Py_EQ && op != Py_NE) || + !PyCFunction_Check(self) || + !PyCFunction_Check(other)) + { + Py_INCREF(Py_NotImplemented); + return Py_NotImplemented; + } + a = (PyCFunctionObject *)self; + b = (PyCFunctionObject *)other; + eq = a->m_self == b->m_self; + if (eq) + eq = a->m_ml->ml_meth == b->m_ml->ml_meth; + if (op == Py_EQ) + res = eq ? Py_True : Py_False; else - return 1; + res = eq ? Py_False : Py_True; + Py_INCREF(res); + return res; } static long @@ -240,7 +254,7 @@ 0, /* tp_print */ 0, /* tp_getattr */ 0, /* tp_setattr */ - (cmpfunc)meth_compare, /* tp_compare */ + 0, /* tp_compare */ (reprfunc)meth_repr, /* tp_repr */ 0, /* tp_as_number */ 0, /* tp_as_sequence */ @@ -255,7 +269,7 @@ 0, /* tp_doc */ (traverseproc)meth_traverse, /* tp_traverse */ 0, /* tp_clear */ - 0, /* tp_richcompare */ + meth_richcompare, /* tp_richcompare */ 0, /* tp_weaklistoffset */ 0, /* tp_iter */ 0, /* tp_iternext */ Modified: python/branches/p3yk-noslice/Objects/object.c ============================================================================== --- python/branches/p3yk-noslice/Objects/object.c (original) +++ python/branches/p3yk-noslice/Objects/object.c Fri Dec 15 05:21:50 2006 @@ -252,14 +252,6 @@ return PyObject_INIT_VAR(op, tp, nitems); } -/* for binary compatibility with 2.2 */ -#undef _PyObject_Del -void -_PyObject_Del(PyObject *op) -{ - PyObject_FREE(op); -} - /* Implementation of PyObject_Print with recursion checking */ static int internal_print(PyObject *op, FILE *fp, int flags, int nesting) @@ -513,431 +505,200 @@ #endif -/* Helper to warn about deprecated tp_compare return values. Return: - -2 for an exception; - -1 if v < w; - 0 if v == w; - 1 if v > w. - (This function cannot return 2.) -*/ -static int -adjust_tp_compare(int c) -{ - if (PyErr_Occurred()) { - if (c != -1 && c != -2) { - PyObject *t, *v, *tb; - PyErr_Fetch(&t, &v, &tb); - if (PyErr_Warn(PyExc_RuntimeWarning, - "tp_compare didn't return -1 or -2 " - "for exception") < 0) { - Py_XDECREF(t); - Py_XDECREF(v); - Py_XDECREF(tb); - } - else - PyErr_Restore(t, v, tb); - } - return -2; - } - else if (c < -1 || c > 1) { - if (PyErr_Warn(PyExc_RuntimeWarning, - "tp_compare didn't return -1, 0 or 1") < 0) - return -2; - else - return c < -1 ? -1 : 1; - } - else { - assert(c >= -1 && c <= 1); - return c; - } -} +/* The new comparison philosophy is: we completely separate three-way + comparison from rich comparison. That is, PyObject_Compare() and + PyObject_Cmp() *just* use the tp_compare slot. And PyObject_RichCompare() + and PyObject_RichCompareBool() *just* use the tp_richcompare slot. + + See (*) below for practical amendments. + IOW, only cmp() uses tp_compare; the comparison operators (==, !=, <=, <, + >=, >) only use tp_richcompare. Note that list.sort() only uses <. -/* Macro to get the tp_richcompare field of a type if defined */ -#define RICHCOMPARE(t) ((t)->tp_richcompare) + (And yes, eventually we'll rip out cmp() and tp_compare.) -/* Map rich comparison operators to their swapped version, e.g. LT --> GT */ -int _Py_SwappedOp[] = {Py_GT, Py_GE, Py_EQ, Py_NE, Py_LT, Py_LE}; + The calling conventions are different: tp_compare only gets called with two + objects of the appropriate type; tp_richcompare gets called with a first + argument of the appropriate type and a second object of an arbitrary type. + We never do any kind of coercion. -/* Try a genuine rich comparison, returning an object. Return: - NULL for exception; - NotImplemented if this particular rich comparison is not implemented or - undefined; - some object not equal to NotImplemented if it is implemented - (this latter object may not be a Boolean). -*/ -static PyObject * -try_rich_compare(PyObject *v, PyObject *w, int op) -{ - richcmpfunc f; - PyObject *res; - - if (v->ob_type != w->ob_type && - PyType_IsSubtype(w->ob_type, v->ob_type) && - (f = RICHCOMPARE(w->ob_type)) != NULL) { - res = (*f)(w, v, _Py_SwappedOp[op]); - if (res != Py_NotImplemented) - return res; - Py_DECREF(res); - } - if ((f = RICHCOMPARE(v->ob_type)) != NULL) { - res = (*f)(v, w, op); - if (res != Py_NotImplemented) - return res; - Py_DECREF(res); - } - if ((f = RICHCOMPARE(w->ob_type)) != NULL) { - return (*f)(w, v, _Py_SwappedOp[op]); - } - res = Py_NotImplemented; - Py_INCREF(res); - return res; -} + The return conventions are also different. -/* Try a genuine rich comparison, returning an int. Return: - -1 for exception (including the case where try_rich_compare() returns an - object that's not a Boolean); - 0 if the outcome is false; - 1 if the outcome is true; - 2 if this particular rich comparison is not implemented or undefined. -*/ -static int -try_rich_compare_bool(PyObject *v, PyObject *w, int op) -{ - PyObject *res; - int ok; + The tp_compare slot should return a C int, as follows: - if (RICHCOMPARE(v->ob_type) == NULL && RICHCOMPARE(w->ob_type) == NULL) - return 2; /* Shortcut, avoid INCREF+DECREF */ - res = try_rich_compare(v, w, op); - if (res == NULL) - return -1; - if (res == Py_NotImplemented) { - Py_DECREF(res); - return 2; - } - ok = PyObject_IsTrue(res); - Py_DECREF(res); - return ok; -} + -1 if a < b or if an exception occurred + 0 if a == b + +1 if a > b -/* Try rich comparisons to determine a 3-way comparison. Return: - -2 for an exception; - -1 if v < w; - 0 if v == w; - 1 if v > w; - 2 if this particular rich comparison is not implemented or undefined. -*/ -static int -try_rich_to_3way_compare(PyObject *v, PyObject *w) -{ - static struct { int op; int outcome; } tries[3] = { - /* Try this operator, and if it is true, use this outcome: */ - {Py_EQ, 0}, - {Py_LT, -1}, - {Py_GT, 1}, - }; - int i; + No other return values are allowed. PyObject_Compare() has the same + calling convention. - if (RICHCOMPARE(v->ob_type) == NULL && RICHCOMPARE(w->ob_type) == NULL) - return 2; /* Shortcut */ + The tp_richcompare slot should return an object, as follows: - for (i = 0; i < 3; i++) { - switch (try_rich_compare_bool(v, w, tries[i].op)) { - case -1: - return -2; - case 1: - return tries[i].outcome; - } - } + NULL if an exception occurred + NotImplemented if the requested comparison is not implemented + any other false value if the requested comparison is false + any other true value if the requested comparison is true - return 2; -} + The PyObject_RichCompare[Bool]() wrappers raise TypeError when they get + NotImplemented. -/* Try a 3-way comparison, returning an int. Return: - -2 for an exception; - -1 if v < w; - 0 if v == w; - 1 if v > w; - 2 if this particular 3-way comparison is not implemented or undefined. -*/ -static int -try_3way_compare(PyObject *v, PyObject *w) -{ - int c; - cmpfunc f; + (*) Practical amendments: - /* Comparisons involving instances are given to instance_compare, - which has the same return conventions as this function. */ + - If rich comparison returns NotImplemented, == and != are decided by + comparing the object pointer (i.e. falling back to the base object + implementation). - f = v->ob_type->tp_compare; + - If three-way comparison is not implemented, it falls back on rich + comparison (but not the other way around!). - /* If both have the same (non-NULL) tp_compare, use it. */ - if (f != NULL && f == w->ob_type->tp_compare) { - c = (*f)(v, w); - return adjust_tp_compare(c); - } - - /* If either tp_compare is _PyObject_SlotCompare, that's safe. */ - if (f == _PyObject_SlotCompare || - w->ob_type->tp_compare == _PyObject_SlotCompare) - return _PyObject_SlotCompare(v, w); - - /* If we're here, v and w, - a) are not instances; - b) have different types or a type without tp_compare; and - c) don't have a user-defined tp_compare. - tp_compare implementations in C assume that both arguments - have their type, so we give up if the coercion fails. - */ - c = PyNumber_CoerceEx(&v, &w); - if (c < 0) - return -2; - if (c > 0) - return 2; - f = v->ob_type->tp_compare; - if (f != NULL && f == w->ob_type->tp_compare) { - c = (*f)(v, w); - Py_DECREF(v); - Py_DECREF(w); - return adjust_tp_compare(c); - } - - /* No comparison defined */ - Py_DECREF(v); - Py_DECREF(w); - return 2; -} - -/* Final fallback 3-way comparison, returning an int. Return: - -2 if an error occurred; - -1 if v < w; - 0 if v == w; - 1 if v > w. */ -static int -default_3way_compare(PyObject *v, PyObject *w) -{ - int c; - const char *vname, *wname; - - if (v->ob_type == w->ob_type) { - /* When comparing these pointers, they must be cast to - * integer types (i.e. Py_uintptr_t, our spelling of C9X's - * uintptr_t). ANSI specifies that pointer compares other - * than == and != to non-related structures are undefined. - */ - Py_uintptr_t vv = (Py_uintptr_t)v; - Py_uintptr_t ww = (Py_uintptr_t)w; - return (vv < ww) ? -1 : (vv > ww) ? 1 : 0; - } - - /* None is smaller than anything */ - if (v == Py_None) - return -1; - if (w == Py_None) - return 1; - /* different type: compare type names; numbers are smaller */ - if (PyNumber_Check(v)) - vname = ""; - else - vname = v->ob_type->tp_name; - if (PyNumber_Check(w)) - wname = ""; - else - wname = w->ob_type->tp_name; - c = strcmp(vname, wname); - if (c < 0) - return -1; - if (c > 0) - return 1; - /* Same type name, or (more likely) incomparable numeric types */ - return ((Py_uintptr_t)(v->ob_type) < ( - Py_uintptr_t)(w->ob_type)) ? -1 : 1; -} +/* Forward */ +static PyObject *do_richcompare(PyObject *v, PyObject *w, int op); -/* Do a 3-way comparison, by hook or by crook. Return: - -2 for an exception (but see below); - -1 if v < w; - 0 if v == w; - 1 if v > w; - BUT: if the object implements a tp_compare function, it returns - whatever this function returns (whether with an exception or not). -*/ +/* Perform a three-way comparison, raising TypeError if three-way comparison + is not supported. */ static int -do_cmp(PyObject *v, PyObject *w) +do_compare(PyObject *v, PyObject *w) { - int c; cmpfunc f; + int ok; - if (v->ob_type == w->ob_type - && (f = v->ob_type->tp_compare) != NULL) { - c = (*f)(v, w); - return adjust_tp_compare(c); - } - /* We only get here if one of the following is true: - a) v and w have different types - b) v and w have the same type, which doesn't have tp_compare - c) v and w are instances, and either __cmp__ is not defined or - __cmp__ returns NotImplemented - */ - c = try_rich_to_3way_compare(v, w); - if (c < 2) - return c; - c = try_3way_compare(v, w); - if (c < 2) - return c; - return default_3way_compare(v, w); -} - -/* Compare v to w. Return - -1 if v < w or exception (PyErr_Occurred() true in latter case). - 0 if v == w. - 1 if v > w. - XXX The docs (C API manual) say the return value is undefined in case - XXX of error. -*/ + if (v->ob_type == w->ob_type && + (f = v->ob_type->tp_compare) != NULL) { + return (*f)(v, w); + } + + /* Now try three-way compare before giving up. This is intentionally + elaborate; if you have a it will raise TypeError if it detects two + objects that aren't ordered with respect to each other. */ + ok = PyObject_RichCompareBool(v, w, Py_LT); + if (ok < 0) + return -1; /* Error */ + if (ok) + return -1; /* Less than */ + ok = PyObject_RichCompareBool(v, w, Py_GT); + if (ok < 0) + return -1; /* Error */ + if (ok) + return 1; /* Greater than */ + ok = PyObject_RichCompareBool(v, w, Py_EQ); + if (ok < 0) + return -1; /* Error */ + if (ok) + return 0; /* Equal */ + + /* Give up */ + PyErr_Format(PyExc_TypeError, + "unorderable types: '%.100s' != '%.100s'", + v->ob_type->tp_name, + w->ob_type->tp_name); + return -1; +} + +/* Perform a three-way comparison. This wraps do_compare() with a check for + NULL arguments and a recursion check. */ int PyObject_Compare(PyObject *v, PyObject *w) { - int result; + int res; if (v == NULL || w == NULL) { - PyErr_BadInternalCall(); + if (!PyErr_Occurred()) + PyErr_BadInternalCall(); return -1; } - if (v == w) - return 0; if (Py_EnterRecursiveCall(" in cmp")) return -1; - result = do_cmp(v, w); + res = do_compare(v, w); Py_LeaveRecursiveCall(); - return result < 0 ? -1 : result; + return res < 0 ? -1 : res; } -/* Return (new reference to) Py_True or Py_False. */ -static PyObject * -convert_3way_to_object(int op, int c) -{ - PyObject *result; - switch (op) { - case Py_LT: c = c < 0; break; - case Py_LE: c = c <= 0; break; - case Py_EQ: c = c == 0; break; - case Py_NE: c = c != 0; break; - case Py_GT: c = c > 0; break; - case Py_GE: c = c >= 0; break; - } - result = c ? Py_True : Py_False; - Py_INCREF(result); - return result; -} - -/* We want a rich comparison but don't have one. Try a 3-way cmp instead. - Return - NULL if error - Py_True if v op w - Py_False if not (v op w) -*/ -static PyObject * -try_3way_to_rich_compare(PyObject *v, PyObject *w, int op) -{ - int c; +/* Map rich comparison operators to their swapped version, e.g. LT <--> GT */ +int _Py_SwappedOp[] = {Py_GT, Py_GE, Py_EQ, Py_NE, Py_LT, Py_LE}; - c = try_3way_compare(v, w); - if (c >= 2) - c = default_3way_compare(v, w); - if (c <= -2) - return NULL; - return convert_3way_to_object(op, c); -} +static char *opstrings[] = {">", ">=", "==", "!=", "<", "<="}; -/* Do rich comparison on v and w. Return - NULL if error - Else a new reference to an object other than Py_NotImplemented, usually(?): - Py_True if v op w - Py_False if not (v op w) -*/ +/* Perform a rich comparison, raising TypeError when the requested comparison + operator is not supported. */ static PyObject * -do_richcmp(PyObject *v, PyObject *w, int op) +do_richcompare(PyObject *v, PyObject *w, int op) { + richcmpfunc f; PyObject *res; - res = try_rich_compare(v, w, op); - if (res != Py_NotImplemented) - return res; - Py_DECREF(res); - - return try_3way_to_rich_compare(v, w, op); + if (v->ob_type != w->ob_type && + PyType_IsSubtype(w->ob_type, v->ob_type) && + (f = w->ob_type->tp_richcompare) != NULL) { + res = (*f)(w, v, _Py_SwappedOp[op]); + if (res != Py_NotImplemented) + return res; + Py_DECREF(res); + } + if ((f = v->ob_type->tp_richcompare) != NULL) { + res = (*f)(v, w, op); + if (res != Py_NotImplemented) + return res; + Py_DECREF(res); + } + if ((f = w->ob_type->tp_richcompare) != NULL) { + res = (*f)(w, v, _Py_SwappedOp[op]); + if (res != Py_NotImplemented) + return res; + Py_DECREF(res); + } + /* If neither object implements it, provide a sensible default + for == and !=, but raise an exception for ordering. */ + switch (op) { + case Py_EQ: + res = (v == w) ? Py_True : Py_False; + break; + case Py_NE: + res = (v != w) ? Py_True : Py_False; + break; + default: + PyErr_Format(PyExc_TypeError, + "unorderable types: %.100s() %s %.100s()", + v->ob_type->tp_name, + opstrings[op], + w->ob_type->tp_name); + return NULL; + } + Py_INCREF(res); + return res; } -/* Return: - NULL for exception; - some object not equal to NotImplemented if it is implemented - (this latter object may not be a Boolean). -*/ +/* Perform a rich comparison with object result. This wraps do_richcompare() + with a check for NULL arguments and a recursion check. */ + PyObject * PyObject_RichCompare(PyObject *v, PyObject *w, int op) { PyObject *res; assert(Py_LT <= op && op <= Py_GE); - if (Py_EnterRecursiveCall(" in cmp")) + if (v == NULL || w == NULL) { + if (!PyErr_Occurred()) + PyErr_BadInternalCall(); return NULL; - - /* If the types are equal, and not old-style instances, try to - get out cheap (don't bother with coercions etc.). */ - if (v->ob_type == w->ob_type) { - cmpfunc fcmp; - richcmpfunc frich = RICHCOMPARE(v->ob_type); - /* If the type has richcmp, try it first. try_rich_compare - tries it two-sided, which is not needed since we've a - single type only. */ - if (frich != NULL) { - res = (*frich)(v, w, op); - if (res != Py_NotImplemented) - goto Done; - Py_DECREF(res); - } - /* No richcmp, or this particular richmp not implemented. - Try 3-way cmp. */ - fcmp = v->ob_type->tp_compare; - if (fcmp != NULL) { - int c = (*fcmp)(v, w); - c = adjust_tp_compare(c); - if (c == -2) { - res = NULL; - goto Done; - } - res = convert_3way_to_object(op, c); - goto Done; - } } - - /* Fast path not taken, or couldn't deliver a useful result. */ - res = do_richcmp(v, w, op); -Done: + if (Py_EnterRecursiveCall(" in cmp")) + return NULL; + res = do_richcompare(v, w, op); Py_LeaveRecursiveCall(); return res; } -/* Return -1 if error; 1 if v op w; 0 if not (v op w). */ +/* Perform a rich comparison with integer result. This wraps + PyObject_RichCompare(), returning -1 for error, 0 for false, 1 for true. */ int PyObject_RichCompareBool(PyObject *v, PyObject *w, int op) { PyObject *res; int ok; - /* Quick result when objects are the same. - Guarantees that identity implies equality. */ - if (v == w) { - if (op == Py_EQ) - return 1; - else if (op == Py_NE) - return 0; - } - res = PyObject_RichCompare(v, w, op); if (res == NULL) return -1; @@ -949,6 +710,44 @@ return ok; } +/* Turn the result of a three-way comparison into the result expected by a + rich comparison. */ +PyObject * +Py_CmpToRich(int op, int cmp) +{ + PyObject *res; + int ok; + + if (PyErr_Occurred()) + return NULL; + switch (op) { + case Py_LT: + ok = cmp < 0; + break; + case Py_LE: + ok = cmp <= 0; + break; + case Py_EQ: + ok = cmp == 0; + break; + case Py_NE: + ok = cmp != 0; + break; + case Py_GT: + ok = cmp > 0; + break; + case Py_GE: + ok = cmp >= 0; + break; + default: + PyErr_BadArgument(); + return NULL; + } + res = ok ? Py_True : Py_False; + Py_INCREF(res); + return res; +} + /* Set of hash utility functions to help maintaining the invariant that if a==b then hash(a)==hash(b) @@ -1447,8 +1246,8 @@ if (v == Py_None) return 0; else if (v->ob_type->tp_as_number != NULL && - v->ob_type->tp_as_number->nb_nonzero != NULL) - res = (*v->ob_type->tp_as_number->nb_nonzero)(v); + v->ob_type->tp_as_number->nb_bool != NULL) + res = (*v->ob_type->tp_as_number->nb_bool)(v); else if (v->ob_type->tp_as_mapping != NULL && v->ob_type->tp_as_mapping->mp_length != NULL) res = (*v->ob_type->tp_as_mapping->mp_length)(v); @@ -1474,33 +1273,6 @@ return res == 0; } -/* Coerce two numeric types to the "larger" one. - Increment the reference count on each argument. - Return value: - -1 if an error occurred; - 0 if the coercion succeeded (and then the reference counts are increased); - 1 if no coercion is possible (and no error is raised). -*/ -int -PyNumber_CoerceEx(PyObject **pv, PyObject **pw) -{ - register PyObject *v = *pv; - register PyObject *w = *pw; - int res; - - if (v->ob_type->tp_as_number && v->ob_type->tp_as_number->nb_coerce) { - res = (*v->ob_type->tp_as_number->nb_coerce)(pv, pw); - if (res <= 0) - return res; - } - if (w->ob_type->tp_as_number && w->ob_type->tp_as_number->nb_coerce) { - res = (*w->ob_type->tp_as_number->nb_coerce)(pw, pv); - if (res <= 0) - return res; - } - return 1; -} - /* Test whether an object can be called */ int @@ -1832,6 +1604,9 @@ if (PyType_Ready(&PyNotImplemented_Type) < 0) Py_FatalError("Can't initialize type(NotImplemented)"); + + if (PyType_Ready(&PyCode_Type) < 0) + Py_FatalError("Can't initialize 'code'"); } Modified: python/branches/p3yk-noslice/Objects/obmalloc.c ============================================================================== --- python/branches/p3yk-noslice/Objects/obmalloc.c (original) +++ python/branches/p3yk-noslice/Objects/obmalloc.c Fri Dec 15 05:21:50 2006 @@ -691,7 +691,8 @@ #undef Py_ADDRESS_IN_RANGE -#if defined(__GNUC__) && (__GNUC__ == 3) && (__GNUC_MINOR__ >= 1) +#if defined(__GNUC__) && ((__GNUC__ == 3) && (__GNUC_MINOR__ >= 1) || \ + (__GNUC__ >= 4)) #define Py_NO_INLINE __attribute__((__noinline__)) #else #define Py_NO_INLINE Modified: python/branches/p3yk-noslice/Objects/setobject.c ============================================================================== --- python/branches/p3yk-noslice/Objects/setobject.c (original) +++ python/branches/p3yk-noslice/Objects/setobject.c Fri Dec 15 05:21:50 2006 @@ -10,6 +10,20 @@ #include "Python.h" #include "structmember.h" +/* Set a key error with the specified argument, wrapping it in a + * tuple automatically so that tuple keys are not unpacked as the + * exception arguments. */ +static void +set_key_error(PyObject *arg) +{ + PyObject *tup; + tup = PyTuple_Pack(1, arg); + if (!tup) + return; /* caller will expect error to be set anyway */ + PyErr_SetObject(PyExc_KeyError, tup); + Py_DECREF(tup); +} + /* This must be >= 1. */ #define PERTURB_SHIFT 5 @@ -179,11 +193,13 @@ if (entry->key == dummy && freeslot == NULL) freeslot = entry; } + assert(0); /* NOT REACHED */ + return 0; } /* Internal routine to insert a new key into the table. -Used both by the internal resize routine and by the public insert routine. +Used by the public insert routine. Eats a reference to key. */ static int @@ -216,6 +232,35 @@ } /* +Internal routine used by set_table_resize() to insert an item which is +known to be absent from the set. This routine also assumes that +the set contains no deleted entries. Besides the performance benefit, +using set_insert_clean() in set_table_resize() is dangerous (SF bug #1456209). +Note that no refcounts are changed by this routine; if needed, the caller +is responsible for incref'ing `key`. +*/ +static void +set_insert_clean(register PySetObject *so, PyObject *key, long hash) +{ + register size_t i; + register size_t perturb; + register size_t mask = (size_t)so->mask; + setentry *table = so->table; + register setentry *entry; + + i = hash & mask; + entry = &table[i]; + for (perturb = hash; entry->key != NULL; perturb >>= PERTURB_SHIFT) { + i = (i << 2) + i + perturb + 1; + entry = &table[i & mask]; + } + so->fill++; + entry->key = key; + entry->hash = hash; + so->used++; +} + +/* Restructure the table by allocating a new table and reinserting all keys again. When entries have been deleted, the new table may actually be smaller than the old one. @@ -296,11 +341,7 @@ } else { /* ACTIVE */ --i; - if(set_insert_key(so, entry->key, entry->hash) == -1) { - if (is_oldtable_malloced) - PyMem_DEL(oldtable); - return -1; - } + set_insert_clean(so, entry->key, entry->hash); } } @@ -319,8 +360,10 @@ assert(so->fill <= so->mask); /* at least one empty slot */ n_used = so->used; Py_INCREF(entry->key); - if (set_insert_key(so, entry->key, entry->hash) == -1) + if (set_insert_key(so, entry->key, entry->hash) == -1) { + Py_DECREF(entry->key); return -1; + } if (!(so->used > n_used && so->fill*3 >= (so->mask+1)*2)) return 0; return set_table_resize(so, so->used>50000 ? so->used*2 : so->used*4); @@ -529,15 +572,28 @@ Py_ssize_t pos=0; char *emit = ""; /* No separator emitted on first pass */ char *separator = ", "; + int literalform = 0; - fprintf(fp, "%s([", so->ob_type->tp_name); + if (!so->used) { + fprintf(fp, "%s()", so->ob_type->tp_name); + return 0; + } + + if (so->ob_type == &PySet_Type) { + literalform = 1; + fprintf(fp, "{"); + } else + fprintf(fp, "%s([", so->ob_type->tp_name); while (set_next(so, &pos, &entry)) { fputs(emit, fp); emit = separator; if (PyObject_Print(entry->key, fp, 0) != 0) return -1; } - fputs("])", fp); + if (literalform) + fputs("}", fp); + else + fputs("])", fp); return 0; } @@ -546,6 +602,10 @@ { PyObject *keys, *result, *listrepr; + /* shortcut for the empty set */ + if (!so->used) + return PyString_FromFormat("%s()", so->ob_type->tp_name); + keys = PySequence_List((PyObject *)so); if (keys == NULL) return NULL; @@ -554,8 +614,15 @@ if (listrepr == NULL) return NULL; - result = PyString_FromFormat("%s(%s)", so->ob_type->tp_name, - PyString_AS_STRING(listrepr)); + if (so->ob_type == &PySet_Type) { + char *s = PyString_AS_STRING(listrepr); + s += 1; + s[strlen(s)-1] = 0; + result = PyString_FromFormat("{%s}", s); + } else { + result = PyString_FromFormat("%s(%s)", so->ob_type->tp_name, + PyString_AS_STRING(listrepr)); + } Py_DECREF(listrepr); return result; } @@ -1131,7 +1198,12 @@ } while (set_next((PySetObject *)other, &pos, &entry)) { - if (set_contains_entry(so, entry)) { + int rv = set_contains_entry(so, entry); + if (rv == -1) { + Py_DECREF(result); + return NULL; + } + if (rv) { if (set_add_entry(result, entry) == -1) { Py_DECREF(result); return NULL; @@ -1148,8 +1220,27 @@ } while ((key = PyIter_Next(it)) != NULL) { - if (set_contains_key(so, key)) { - if (set_add_key(result, key) == -1) { + int rv; + setentry entry; + long hash = PyObject_Hash(key); + + if (hash == -1) { + Py_DECREF(it); + Py_DECREF(result); + Py_DECREF(key); + return NULL; + } + entry.hash = hash; + entry.key = key; + rv = set_contains_entry(so, &entry); + if (rv == -1) { + Py_DECREF(it); + Py_DECREF(result); + Py_DECREF(key); + return NULL; + } + if (rv) { + if (set_add_entry(result, &entry) == -1) { Py_DECREF(it); Py_DECREF(result); Py_DECREF(key); @@ -1225,7 +1316,8 @@ Py_ssize_t pos = 0; while (set_next((PySetObject *)other, &pos, &entry)) - set_discard_entry(so, entry); + if (set_discard_entry(so, entry) == -1) + return -1; } else { PyObject *key, *it; it = PyObject_GetIter(other); @@ -1288,17 +1380,26 @@ entrycopy.hash = entry->hash; entrycopy.key = entry->key; if (!PyDict_Contains(other, entry->key)) { - if (set_add_entry((PySetObject *)result, &entrycopy) == -1) + if (set_add_entry((PySetObject *)result, &entrycopy) == -1) { + Py_DECREF(result); return NULL; + } } } return result; } while (set_next(so, &pos, &entry)) { - if (!set_contains_entry((PySetObject *)other, entry)) { - if (set_add_entry((PySetObject *)result, entry) == -1) + int rv = set_contains_entry((PySetObject *)other, entry); + if (rv == -1) { + Py_DECREF(result); + return NULL; + } + if (!rv) { + if (set_add_entry((PySetObject *)result, entry) == -1) { + Py_DECREF(result); return NULL; + } } } return result; @@ -1350,11 +1451,18 @@ PyObject *value; int rv; while (PyDict_Next(other, &pos, &key, &value)) { - rv = set_discard_key(so, key); + setentry an_entry; + long hash = PyObject_Hash(key); + + if (hash == -1) + return NULL; + an_entry.hash = hash; + an_entry.key = key; + rv = set_discard_entry(so, &an_entry); if (rv == -1) return NULL; if (rv == DISCARD_NOTFOUND) { - if (set_add_key(so, key) == -1) + if (set_add_entry(so, &an_entry) == -1) return NULL; } } @@ -1457,7 +1565,10 @@ Py_RETURN_FALSE; while (set_next(so, &pos, &entry)) { - if (!set_contains_entry((PySetObject *)other, entry)) + int rv = set_contains_entry((PySetObject *)other, entry); + if (rv == -1) + return NULL; + if (!rv) Py_RETURN_FALSE; } Py_RETURN_TRUE; @@ -1604,7 +1715,7 @@ Py_DECREF(tmpkey); return result; } else if (rv == DISCARD_NOTFOUND) { - PyErr_SetObject(PyExc_KeyError, key); + set_key_error(key); return NULL; } Py_RETURN_NONE; @@ -1760,7 +1871,7 @@ 0, /*nb_negative*/ 0, /*nb_positive*/ 0, /*nb_absolute*/ - 0, /*nb_nonzero*/ + 0, /*nb_bool*/ 0, /*nb_invert*/ 0, /*nb_lshift*/ 0, /*nb_rshift*/ @@ -1870,7 +1981,7 @@ 0, /*nb_negative*/ 0, /*nb_positive*/ 0, /*nb_absolute*/ - 0, /*nb_nonzero*/ + 0, /*nb_bool*/ 0, /*nb_invert*/ 0, /*nb_lshift*/ 0, /*nb_rshift*/ Modified: python/branches/p3yk-noslice/Objects/sliceobject.c ============================================================================== --- python/branches/p3yk-noslice/Objects/sliceobject.c (original) +++ python/branches/p3yk-noslice/Objects/sliceobject.c Fri Dec 15 05:21:50 2006 @@ -280,25 +280,55 @@ {NULL, NULL} }; -static int -slice_compare(PySliceObject *v, PySliceObject *w) +static PyObject * +slice_richcompare(PyObject *v, PyObject *w, int op) { - int result = 0; + PyObject *t1; + PyObject *t2; + PyObject *res; - if (v == w) - return 0; + if (v == w) { + /* XXX Do we really need this shortcut? + There's a unit test for it, but is that fair? */ + switch (op) { + case Py_EQ: + case Py_LE: + case Py_GE: + res = Py_True; + break; + default: + res = Py_False; + break; + } + Py_INCREF(res); + return res; + } - if (PyObject_Cmp(v->start, w->start, &result) < 0) - return -2; - if (result != 0) - return result; - if (PyObject_Cmp(v->stop, w->stop, &result) < 0) - return -2; - if (result != 0) - return result; - if (PyObject_Cmp(v->step, w->step, &result) < 0) - return -2; - return result; + t1 = PyTuple_New(3); + t2 = PyTuple_New(3); + if (t1 == NULL || t2 == NULL) + return NULL; + + PyTuple_SET_ITEM(t1, 0, ((PySliceObject *)v)->start); + PyTuple_SET_ITEM(t1, 1, ((PySliceObject *)v)->stop); + PyTuple_SET_ITEM(t1, 2, ((PySliceObject *)v)->step); + PyTuple_SET_ITEM(t2, 0, ((PySliceObject *)w)->start); + PyTuple_SET_ITEM(t2, 1, ((PySliceObject *)w)->stop); + PyTuple_SET_ITEM(t2, 2, ((PySliceObject *)w)->step); + + res = PyObject_RichCompare(t1, t2, op); + + PyTuple_SET_ITEM(t1, 0, NULL); + PyTuple_SET_ITEM(t1, 1, NULL); + PyTuple_SET_ITEM(t1, 2, NULL); + PyTuple_SET_ITEM(t2, 0, NULL); + PyTuple_SET_ITEM(t2, 1, NULL); + PyTuple_SET_ITEM(t2, 2, NULL); + + Py_DECREF(t1); + Py_DECREF(t2); + + return res; } static long @@ -318,7 +348,7 @@ 0, /* tp_print */ 0, /* tp_getattr */ 0, /* tp_setattr */ - (cmpfunc)slice_compare, /* tp_compare */ + 0, /* tp_compare */ (reprfunc)slice_repr, /* tp_repr */ 0, /* tp_as_number */ 0, /* tp_as_sequence */ @@ -333,7 +363,7 @@ slice_doc, /* tp_doc */ 0, /* tp_traverse */ 0, /* tp_clear */ - 0, /* tp_richcompare */ + slice_richcompare, /* tp_richcompare */ 0, /* tp_weaklistoffset */ 0, /* tp_iter */ 0, /* tp_iternext */ Modified: python/branches/p3yk-noslice/Objects/stringlib/partition.h ============================================================================== --- python/branches/p3yk-noslice/Objects/stringlib/partition.h (original) +++ python/branches/p3yk-noslice/Objects/stringlib/partition.h Fri Dec 15 05:21:50 2006 @@ -78,12 +78,12 @@ } if (pos < 0) { - Py_INCREF(str_obj); - PyTuple_SET_ITEM(out, 0, (PyObject*) str_obj); Py_INCREF(STRINGLIB_EMPTY); - PyTuple_SET_ITEM(out, 1, (PyObject*) STRINGLIB_EMPTY); + PyTuple_SET_ITEM(out, 0, (PyObject*) STRINGLIB_EMPTY); Py_INCREF(STRINGLIB_EMPTY); - PyTuple_SET_ITEM(out, 2, (PyObject*) STRINGLIB_EMPTY); + PyTuple_SET_ITEM(out, 1, (PyObject*) STRINGLIB_EMPTY); + Py_INCREF(str_obj); + PyTuple_SET_ITEM(out, 2, (PyObject*) str_obj); return out; } Modified: python/branches/p3yk-noslice/Objects/stringobject.c ============================================================================== --- python/branches/p3yk-noslice/Objects/stringobject.c (original) +++ python/branches/p3yk-noslice/Objects/stringobject.c Fri Dec 15 05:21:50 2006 @@ -804,10 +804,22 @@ return ret; } if (flags & Py_PRINT_RAW) { + char *data = op->ob_sval; + Py_ssize_t size = op->ob_size; + while (size > INT_MAX) { + /* Very long strings cannot be written atomically. + * But don't write exactly INT_MAX bytes at a time + * to avoid memory aligment issues. + */ + const int chunk_size = INT_MAX & ~0x3FFF; + fwrite(data, 1, chunk_size, fp); + data += chunk_size; + size -= chunk_size; + } #ifdef __VMS - if (op->ob_size) fwrite(op->ob_sval, (int) op->ob_size, 1, fp); + if (size) fwrite(data, (int)size, 1, fp); #else - fwrite(op->ob_sval, 1, (int) op->ob_size, fp); + fwrite(data, 1, (int)size, fp); #endif return 0; } @@ -844,7 +856,7 @@ register PyStringObject* op = (PyStringObject*) obj; size_t newsize = 2 + 4 * op->ob_size; PyObject *v; - if (newsize > PY_SSIZE_T_MAX) { + if (newsize > PY_SSIZE_T_MAX || newsize / 4 != op->ob_size) { PyErr_SetString(PyExc_OverflowError, "string is too large to make repr"); } @@ -1059,8 +1071,9 @@ return PyUnicode_Contains(str_obj, sub_obj); #endif if (!PyString_Check(sub_obj)) { - PyErr_SetString(PyExc_TypeError, - "'in ' requires string as left operand"); + PyErr_Format(PyExc_TypeError, + "'in ' requires string as left operand, " + "not %.200s", sub_obj->ob_type->tp_name); return -1; } } @@ -1239,8 +1252,9 @@ } } else { - PyErr_SetString(PyExc_TypeError, - "string indices must be integers"); + PyErr_Format(PyExc_TypeError, + "string indices must be integers, not %.200s", + item->ob_type->tp_name); return NULL; } } @@ -1554,11 +1568,11 @@ } PyDoc_STRVAR(rpartition__doc__, -"S.rpartition(sep) -> (head, sep, tail)\n\ +"S.rpartition(sep) -> (tail, sep, head)\n\ \n\ Searches for the separator sep in S, starting at the end of S, and returns\n\ the part before it, the separator itself, and the part after it. If the\n\ -separator is not found, returns S and two empty strings."); +separator is not found, returns two empty strings and S."); static PyObject * string_rpartition(PyStringObject *self, PyObject *sep_obj) @@ -4147,7 +4161,8 @@ double x; x = PyFloat_AsDouble(v); if (x == -1.0 && PyErr_Occurred()) { - PyErr_SetString(PyExc_TypeError, "float argument required"); + PyErr_Format(PyExc_TypeError, "float argument required, " + "not %.200s", v->ob_type->tp_name); return -1; } if (prec < 0) @@ -4248,7 +4263,7 @@ return NULL; } llen = PyString_Size(result); - if (llen > PY_SSIZE_T_MAX) { + if (llen > INT_MAX) { PyErr_SetString(PyExc_ValueError, "string too large in _PyString_FormatLong"); return NULL; } @@ -4342,7 +4357,8 @@ x = PyInt_AsLong(v); if (x == -1 && PyErr_Occurred()) { - PyErr_SetString(PyExc_TypeError, "int argument required"); + PyErr_Format(PyExc_TypeError, "int argument required, not %.200s", + v->ob_type->tp_name); return -1; } if (x < 0 && type == 'u') { @@ -4737,9 +4753,10 @@ default: PyErr_Format(PyExc_ValueError, "unsupported format character '%c' (0x%x) " - "at index %i", + "at index %zd", c, c, - (int)(fmt - 1 - PyString_AsString(format))); + (Py_ssize_t)(fmt - 1 - + PyString_AsString(format))); goto error; } if (sign) { Modified: python/branches/p3yk-noslice/Objects/tupleobject.c ============================================================================== --- python/branches/p3yk-noslice/Objects/tupleobject.c (original) +++ python/branches/p3yk-noslice/Objects/tupleobject.c Fri Dec 15 05:21:50 2006 @@ -626,8 +626,9 @@ } } else { - PyErr_SetString(PyExc_TypeError, - "tuple indices must be integers"); + PyErr_Format(PyExc_TypeError, + "tuple indices must be integers, not %.200s", + item->ob_type->tp_name); return NULL; } } Modified: python/branches/p3yk-noslice/Objects/typeobject.c ============================================================================== --- python/branches/p3yk-noslice/Objects/typeobject.c (original) +++ python/branches/p3yk-noslice/Objects/typeobject.c Fri Dec 15 05:21:50 2006 @@ -98,7 +98,7 @@ s = strrchr(type->tp_name, '.'); if (s != NULL) return PyString_FromStringAndSize( - type->tp_name, (int)(s - type->tp_name)); + type->tp_name, (Py_ssize_t)(s - type->tp_name)); return PyString_FromString("__builtin__"); } } @@ -361,16 +361,6 @@ {0} }; -static int -type_compare(PyObject *v, PyObject *w) -{ - /* This is called with type objects only. So we - can just compare the addresses. */ - Py_uintptr_t vv = (Py_uintptr_t)v; - Py_uintptr_t ww = (Py_uintptr_t)w; - return (vv < ww) ? -1 : (vv > ww) ? 1 : 0; -} - static PyObject * type_repr(PyTypeObject *type) { @@ -2191,12 +2181,12 @@ 0, /* tp_print */ 0, /* tp_getattr */ 0, /* tp_setattr */ - type_compare, /* tp_compare */ + 0, /* tp_compare */ (reprfunc)type_repr, /* tp_repr */ 0, /* tp_as_number */ 0, /* tp_as_sequence */ 0, /* tp_as_mapping */ - (hashfunc)_Py_HashPointer, /* tp_hash */ + 0, /* tp_hash */ (ternaryfunc)type_call, /* tp_call */ 0, /* tp_str */ (getattrofunc)type_getattro, /* tp_getattro */ @@ -2301,6 +2291,30 @@ } static PyObject * +object_richcompare(PyObject *self, PyObject *other, int op) +{ + PyObject *res; + + switch (op) { + + case Py_EQ: + res = (self == other) ? Py_True : Py_False; + break; + + case Py_NE: + res = (self != other) ? Py_True : Py_False; + break; + + default: + res = Py_NotImplemented; + break; + } + + Py_INCREF(res); + return res; +} + +static PyObject * object_get_class(PyObject *self, void *closure) { Py_INCREF(self->ob_type); @@ -2702,7 +2716,7 @@ PyDoc_STR("The most base type"), /* tp_doc */ 0, /* tp_traverse */ 0, /* tp_clear */ - 0, /* tp_richcompare */ + object_richcompare, /* tp_richcompare */ 0, /* tp_weaklistoffset */ 0, /* tp_iter */ 0, /* tp_iternext */ @@ -2913,14 +2927,13 @@ COPYNUM(nb_negative); COPYNUM(nb_positive); COPYNUM(nb_absolute); - COPYNUM(nb_nonzero); + COPYNUM(nb_bool); COPYNUM(nb_invert); COPYNUM(nb_lshift); COPYNUM(nb_rshift); COPYNUM(nb_and); COPYNUM(nb_xor); COPYNUM(nb_or); - COPYNUM(nb_coerce); COPYNUM(nb_int); COPYNUM(nb_long); COPYNUM(nb_float); @@ -3612,7 +3625,7 @@ while (type && type->tp_flags & Py_TPFLAGS_HEAPTYPE) type = type->tp_base; /* If type is NULL now, this is a really weird type. - In the same of backwards compatibility (?), just shut up. */ + In the spirit of backwards compatibility (?), just shut up. */ if (type && type->tp_setattro != func) { PyErr_Format(PyExc_TypeError, "can't apply this %s to %s object", @@ -3829,7 +3842,7 @@ while (staticbase && (staticbase->tp_flags & Py_TPFLAGS_HEAPTYPE)) staticbase = staticbase->tp_base; /* If staticbase is NULL now, it is a really weird type. - In the same of backwards compatibility (?), just shut up. */ + In the spirit of backwards compatibility (?), just shut up. */ if (staticbase && staticbase->tp_new != type->tp_new) { PyErr_Format(PyExc_TypeError, "%s.__new__(%s) is not safe, use %s.__new__()", @@ -3985,19 +3998,10 @@ return -1; len = PyInt_AsSsize_t(res); Py_DECREF(res); - if (len == -1 && PyErr_Occurred()) - return -1; -#if SIZEOF_SIZE_T < SIZEOF_INT - /* Overflow check -- range of PyInt is more than C ssize_t */ - if (len != (int)len) { - PyErr_SetString(PyExc_OverflowError, - "__len__() should return 0 <= outcome < 2**31"); - return -1; - } -#endif if (len < 0) { - PyErr_SetString(PyExc_ValueError, - "__len__() should return >= 0"); + if (!PyErr_Occurred()) + PyErr_SetString(PyExc_ValueError, + "__len__() should return >= 0"); return -1; } return len; @@ -4154,32 +4158,39 @@ SLOT0(slot_nb_absolute, "__abs__") static int -slot_nb_nonzero(PyObject *self) +slot_nb_bool(PyObject *self) { PyObject *func, *args; - static PyObject *nonzero_str, *len_str; + static PyObject *bool_str, *len_str; int result = -1; + int from_len = 0; - func = lookup_maybe(self, "__nonzero__", &nonzero_str); + func = lookup_maybe(self, "__bool__", &bool_str); if (func == NULL) { if (PyErr_Occurred()) return -1; func = lookup_maybe(self, "__len__", &len_str); if (func == NULL) return PyErr_Occurred() ? -1 : 1; + from_len = 1; } args = PyTuple_New(0); if (args != NULL) { PyObject *temp = PyObject_Call(func, args, NULL); Py_DECREF(args); if (temp != NULL) { - if (PyInt_CheckExact(temp) || PyBool_Check(temp)) + if (from_len) { + /* enforced by slot_nb_len */ result = PyObject_IsTrue(temp); + } + else if (PyBool_Check(temp)) { + result = PyObject_IsTrue(temp); + } else { PyErr_Format(PyExc_TypeError, - "__nonzero__ should return " - "bool or int, returned %s", - temp->ob_type->tp_name); + "__bool__ should return " + "bool, returned %s", + temp->ob_type->tp_name); result = -1; } Py_DECREF(temp); @@ -4822,7 +4833,7 @@ UNSLOT("__pos__", nb_positive, slot_nb_positive, wrap_unaryfunc, "+x"), UNSLOT("__abs__", nb_absolute, slot_nb_absolute, wrap_unaryfunc, "abs(x)"), - UNSLOT("__nonzero__", nb_nonzero, slot_nb_nonzero, wrap_inquirypred, + UNSLOT("__bool__", nb_bool, slot_nb_bool, wrap_inquirypred, "x != 0"), UNSLOT("__invert__", nb_invert, slot_nb_invert, wrap_unaryfunc, "~x"), BINSLOT("__lshift__", nb_lshift, slot_nb_lshift, "<<"), @@ -5511,6 +5522,8 @@ PyObject *obj = NULL; PyTypeObject *obj_type = NULL; + if (!_PyArg_NoKeywords("super", kwds)) + return -1; if (!PyArg_ParseTuple(args, "O!|O:super", &PyType_Type, &type, &obj)) return -1; if (obj == Py_None) Modified: python/branches/p3yk-noslice/Objects/unicodeobject.c ============================================================================== --- python/branches/p3yk-noslice/Objects/unicodeobject.c (original) +++ python/branches/p3yk-noslice/Objects/unicodeobject.c Fri Dec 15 05:21:50 2006 @@ -2040,7 +2040,32 @@ static const char *hexdigit = "0123456789abcdef"; - repr = PyString_FromStringAndSize(NULL, 2 + 6*size + 1); + /* XXX(nnorwitz): rather than over-allocating, it would be + better to choose a different scheme. Perhaps scan the + first N-chars of the string and allocate based on that size. + */ + /* Initial allocation is based on the longest-possible unichr + escape. + + In wide (UTF-32) builds '\U00xxxxxx' is 10 chars per source + unichr, so in this case it's the longest unichr escape. In + narrow (UTF-16) builds this is five chars per source unichr + since there are two unichrs in the surrogate pair, so in narrow + (UTF-16) builds it's not the longest unichr escape. + + In wide or narrow builds '\uxxxx' is 6 chars per source unichr, + so in the narrow (UTF-16) build case it's the longest unichr + escape. + */ + + repr = PyString_FromStringAndSize(NULL, + 2 +#ifdef Py_UNICODE_WIDE + + 10*size +#else + + 6*size +#endif + + 1); if (repr == NULL) return NULL; @@ -2065,15 +2090,6 @@ #ifdef Py_UNICODE_WIDE /* Map 21-bit characters to '\U00xxxxxx' */ else if (ch >= 0x10000) { - Py_ssize_t offset = p - PyString_AS_STRING(repr); - - /* Resize the string if necessary */ - if (offset + 12 > PyString_GET_SIZE(repr)) { - if (_PyString_Resize(&repr, PyString_GET_SIZE(repr) + 100)) - return NULL; - p = PyString_AS_STRING(repr) + offset; - } - *p++ = '\\'; *p++ = 'U'; *p++ = hexdigit[(ch >> 28) & 0x0000000F]; @@ -2086,8 +2102,8 @@ *p++ = hexdigit[ch & 0x0000000F]; continue; } -#endif - /* Map UTF-16 surrogate pairs to Unicode \UXXXXXXXX escapes */ +#else + /* Map UTF-16 surrogate pairs to '\U00xxxxxx' */ else if (ch >= 0xD800 && ch < 0xDC00) { Py_UNICODE ch2; Py_UCS4 ucs; @@ -2112,6 +2128,7 @@ s--; size++; } +#endif /* Map 16-bit characters to '\uxxxx' */ if (ch >= 256) { @@ -2367,6 +2384,7 @@ Py_UNICODE unimax = PyUnicode_GetMax(); #endif + /* XXX overflow detection missing */ v = _PyUnicode_New((size+Py_UNICODE_SIZE-1)/ Py_UNICODE_SIZE); if (v == NULL) goto onError; @@ -3153,6 +3171,7 @@ Py_ssize_t needed = (targetsize - extrachars) + \ (targetsize << 2); extrachars += needed; + /* XXX overflow detection missing */ if (_PyUnicode_Resize(&v, PyUnicode_GET_SIZE(v) + needed) < 0) { Py_DECREF(x); @@ -6695,11 +6714,11 @@ } PyDoc_STRVAR(rpartition__doc__, -"S.rpartition(sep) -> (head, sep, tail)\n\ +"S.rpartition(sep) -> (tail, sep, head)\n\ \n\ Searches for the separator sep in S, starting at the end of S, and returns\n\ the part before it, the separator itself, and the part after it. If the\n\ -separator is not found, returns S and two empty strings."); +separator is not found, returns two empty strings and S."); static PyObject* unicode_rpartition(PyUnicodeObject *self, PyObject *separator) @@ -7750,10 +7769,11 @@ default: PyErr_Format(PyExc_ValueError, "unsupported format character '%c' (0x%x) " - "at index %i", + "at index %zd", (31<=c && c<=126) ? (char)c : '?', (int)c, - (int)(fmt -1 - PyUnicode_AS_UNICODE(uformat))); + (Py_ssize_t)(fmt - 1 - + PyUnicode_AS_UNICODE(uformat))); goto onError; } if (sign) { Modified: python/branches/p3yk-noslice/Objects/weakrefobject.c ============================================================================== --- python/branches/p3yk-noslice/Objects/weakrefobject.c (original) +++ python/branches/p3yk-noslice/Objects/weakrefobject.c Fri Dec 15 05:21:50 2006 @@ -184,7 +184,9 @@ static PyObject * weakref_richcompare(PyWeakReference* self, PyWeakReference* other, int op) { - if (op != Py_EQ || self->ob_type != other->ob_type) { + if ((op != Py_EQ && op != Py_NE) || + !PyWeakref_Check(self) || + !PyWeakref_Check(other)) { Py_INCREF(Py_NotImplemented); return Py_NotImplemented; } @@ -458,12 +460,12 @@ return PyObject_SetAttr(PyWeakref_GET_OBJECT(proxy), name, value); } -static int -proxy_compare(PyObject *proxy, PyObject *v) +static PyObject * +proxy_richcompare(PyObject *proxy, PyObject *v, int op) { - UNWRAP_I(proxy); - UNWRAP_I(v); - return PyObject_Compare(proxy, v); + UNWRAP(proxy); + UNWRAP(v); + return PyObject_RichCompare(proxy, v, op); } /* number slots */ @@ -497,7 +499,7 @@ WRAP_BINARY(proxy_ior, PyNumber_InPlaceOr) static int -proxy_nonzero(PyWeakReference *proxy) +proxy_bool(PyWeakReference *proxy) { PyObject *o = PyWeakref_GET_OBJECT(proxy); if (!proxy_checkref(proxy)) @@ -586,7 +588,7 @@ proxy_neg, /*nb_negative*/ proxy_pos, /*nb_positive*/ proxy_abs, /*nb_absolute*/ - (inquiry)proxy_nonzero, /*nb_nonzero*/ + (inquiry)proxy_bool, /*nb_bool*/ proxy_invert, /*nb_invert*/ proxy_lshift, /*nb_lshift*/ proxy_rshift, /*nb_rshift*/ @@ -641,7 +643,7 @@ 0, /* tp_print */ 0, /* tp_getattr */ 0, /* tp_setattr */ - proxy_compare, /* tp_compare */ + 0, /* tp_compare */ (reprfunc)proxy_repr, /* tp_repr */ &proxy_as_number, /* tp_as_number */ &proxy_as_sequence, /* tp_as_sequence */ @@ -656,7 +658,7 @@ 0, /* tp_doc */ (traverseproc)gc_traverse, /* tp_traverse */ (inquiry)gc_clear, /* tp_clear */ - 0, /* tp_richcompare */ + proxy_richcompare, /* tp_richcompare */ 0, /* tp_weaklistoffset */ (getiterfunc)proxy_iter, /* tp_iter */ (iternextfunc)proxy_iternext, /* tp_iternext */ @@ -675,7 +677,7 @@ 0, /* tp_print */ 0, /* tp_getattr */ 0, /* tp_setattr */ - proxy_compare, /* tp_compare */ + 0, /* tp_compare */ (unaryfunc)proxy_repr, /* tp_repr */ &proxy_as_number, /* tp_as_number */ &proxy_as_sequence, /* tp_as_sequence */ @@ -690,7 +692,7 @@ 0, /* tp_doc */ (traverseproc)gc_traverse, /* tp_traverse */ (inquiry)gc_clear, /* tp_clear */ - 0, /* tp_richcompare */ + proxy_richcompare, /* tp_richcompare */ 0, /* tp_weaklistoffset */ (getiterfunc)proxy_iter, /* tp_iter */ (iternextfunc)proxy_iternext, /* tp_iternext */ Modified: python/branches/p3yk-noslice/PC/VC6/_bsddb.dsp ============================================================================== Binary files. No diff available. Modified: python/branches/p3yk-noslice/PC/VC6/_ssl.mak ============================================================================== --- python/branches/p3yk-noslice/PC/VC6/_ssl.mak (original) +++ python/branches/p3yk-noslice/PC/VC6/_ssl.mak Fri Dec 15 05:21:50 2006 @@ -2,17 +2,17 @@ !IFDEF DEBUG MODULE=_ssl_d.pyd TEMP_DIR=x86-temp-debug/_ssl -CFLAGS=/Od /Zi /MDd /LDd /DDEBUG /D_DEBUG +CFLAGS=/Od /Zi /MDd /LDd /DDEBUG /D_DEBUG /DWIN32 SSL_LIB_DIR=$(SSL_DIR)/out32.dbg !ELSE MODULE=_ssl.pyd TEMP_DIR=x86-temp-release/_ssl -CFLAGS=/Ox /MD /LD +CFLAGS=/Ox /MD /LD /DWIN32 SSL_LIB_DIR=$(SSL_DIR)/out32 !ENDIF INCLUDES=-I ../../Include -I .. -I $(SSL_DIR)/inc32 -LIBS=gdi32.lib wsock32.lib /libpath:$(SSL_LIB_DIR) libeay32.lib ssleay32.lib +LIBS=gdi32.lib wsock32.lib user32.lib advapi32.lib /libpath:$(SSL_LIB_DIR) libeay32.lib ssleay32.lib SOURCE=../../Modules/_ssl.c $(SSL_LIB_DIR)/libeay32.lib $(SSL_LIB_DIR)/ssleay32.lib Modified: python/branches/p3yk-noslice/PC/VC6/_tkinter.dsp ============================================================================== Binary files. No diff available. Modified: python/branches/p3yk-noslice/PC/VC6/bz2.dsp ============================================================================== Binary files. No diff available. Modified: python/branches/p3yk-noslice/PC/VC6/pcbuild.dsw ============================================================================== Binary files. No diff available. Modified: python/branches/p3yk-noslice/PC/VC6/pythoncore.dsp ============================================================================== Binary files. No diff available. Modified: python/branches/p3yk-noslice/PC/VC6/readme.txt ============================================================================== --- python/branches/p3yk-noslice/PC/VC6/readme.txt (original) +++ python/branches/p3yk-noslice/PC/VC6/readme.txt Fri Dec 15 05:21:50 2006 @@ -62,40 +62,37 @@ _tkinter Python wrapper for the Tk windowing system. Requires building - Tcl/Tk first. Following are instructions for Tcl/Tk 8.4.3: + Tcl/Tk first. Following are instructions for Tcl/Tk 8.4.12. Get source ---------- - Go to - http://prdownloads.sourceforge.net/tcl/ - and download - tcl843-src.zip - tk843-src.zip - Unzip into - dist\tcl8.4.3\ - dist\tk8.4.3\ - respectively. + In the dist directory, run + svn export http://svn.python.org/projects/external/tcl8.4.12 + svn export http://svn.python.org/projects/external/tk8.4.12 + svn export http://svn.python.org/projects/external/tix-8.4.0 - Build Tcl first (done here w/ MSVC 6 on Win98SE) + Build Tcl first (done here w/ MSVC 6 on Win2K) --------------- - cd dist\tcl8.4.3\win - run vcvars32.bat [necessary even on Win2K] + cd dist\tcl8.4.12\win + run vcvars32.bat nmake -f makefile.vc - nmake -f makefile.vc INSTALLDIR=..\..\tcl84 install + nmake -f makefile.vc INSTALLDIR=..\..\tcltk install XXX Should we compile with OPTS=threads? - XXX Some tests failed in "nmake -f makefile.vc test". - XXX all.tcl: Total 10480 Passed 9743 Skipped 719 Failed 18 - XXX - XXX That was on Win98SE. On Win2K: - XXX all.tcl Total 10480 Passed 9781 Skipped 698 Failed 1 + Optional: run tests, via + nmake -f makefile.vc test + + all.tcl: Total 10835 Passed 10096 Skipped 732 Failed 7 + Sourced 129 Test Files. + Files with failing tests: exec.test expr.test io.test main.test string.test stri + ngObj.test Build Tk -------- - cd dist\tk8.4.3\win - nmake -f makefile.vc TCLDIR=..\..\tcl8.4.3 - nmake -f makefile.vc TCLDIR=..\..\tcl8.4.3 INSTALLDIR=..\..\tcl84 install + cd dist\tk8.4.12\win + nmake -f makefile.vc TCLDIR=..\..\tcl8.4.12 + nmake -f makefile.vc TCLDIR=..\..\tcl8.4.12 INSTALLDIR=..\..\tcltk install XXX Should we compile with OPTS=threads? @@ -103,96 +100,59 @@ XXX failed. It popped up tons of little windows, and did lots of XXX stuff, and nothing blew up. - XXX Our installer copies a lot of stuff out of the Tcl/Tk install - XXX directory. Is all of that really needed for Python use of Tcl/Tk? - - Make sure the installer matches - ------------------------------- - Ensure that the Wise compiler vrbl _TCLDIR_ is set to the name of - the common Tcl/Tk installation directory (tcl84 for the instructions - above). This is needed so the installer can copy various Tcl/Tk - files into the Python distribution. - - -zlib - Python wrapper for the zlib compression library. Get the source code - for version 1.1.4 from a convenient mirror at: - http://www.gzip.org/zlib/ - Unpack into dist\zlib-1.1.4. - A custom pre-link step in the zlib project settings should manage to - build zlib-1.1.4\zlib.lib by magic before zlib.pyd (or zlib_d.pyd) is - linked in PCbuild\. - However, the zlib project is not smart enough to remove anything under - zlib-1.1.4\ when you do a clean, so if you want to rebuild zlib.lib - you need to clean up zlib-1.1.4\ by hand. + Built Tix + --------- + cd dist\tix-8.4.0\win + nmake -f python.mak + nmake -f python.mak install bz2 Python wrapper for the libbz2 compression library. Homepage http://sources.redhat.com/bzip2/ - Download the source tarball, bzip2-1.0.2.tar.gz. - Unpack into dist\bzip2-1.0.2. WARNING: If you're using WinZip, you - must disable its "TAR file smart CR/LF conversion" feature (under - Options -> Configuration -> Miscellaneous -> Other) for the duration. - - A custom pre-link step in the bz2 project settings should manage to - build bzip2-1.0.2\libbz2.lib by magic before bz2.pyd (or bz2_d.pyd) is - linked in PCbuild\. - However, the bz2 project is not smart enough to remove anything under - bzip2-1.0.2\ when you do a clean, so if you want to rebuild bzip2.lib - you need to clean up bzip2-1.0.2\ by hand. - - The build step shouldn't yield any warnings or errors, and should end - by displaying 6 blocks each terminated with - FC: no differences encountered - If FC finds differences, see the warning abou WinZip above (when I - first tried it, sample3.ref failed due to CRLF conversion). + Download the source from the python.org copy into the dist + directory: + + svn export http://svn.python.org/projects/external/bzip2-1.0.3 + + And requires building bz2 first. - All of this managed to build bzip2-1.0.2\libbz2.lib, which the Python + cd dist\bzip2-1.0.3 + nmake -f makefile.msc + + All of this managed to build bzip2-1.0.3\libbz2.lib, which the Python project links in. _bsddb - Go to Sleepycat's download page: - http://www.sleepycat.com/download/ + To use the version of bsddb that Python is built with by default, invoke + (in the dist directory) + + svn export http://svn.python.org/projects/external/db-4.4.20 + + Then open db-4.4.20\build_win32\Berkeley_DB.dsw and build the "db_static" + project for "Release" mode. + + Alternatively, if you want to start with the original sources, + go to Sleepycat's download page: + http://www.sleepycat.com/downloads/releasehistorybdb.html + + and download version 4.4.20. - and download version 4.1.25. The file name is db-4.1.25.NC.zip. - XXX with or without strong cryptography? I picked "without". + With or without strong cryptography? You can choose either with or + without strong cryptography, as per the instructions below. By + default, Python is built and distributed WITHOUT strong crypto. - Unpack into - dist\db-4.1.25 + Unpack the sources; if you downloaded the non-crypto version, rename + the directory from db-4.4.20.NC to db-4.4.20. - [If using WinZip to unpack the db-4.1.25.NC distro, that requires - renaming the directory (to remove ".NC") after unpacking. - ] - - Open - dist\db-4.1.25\docs\index.html - - and follow the Windows instructions for building the Sleepycat - software. Note that Berkeley_DB.dsw is in the build_win32 subdirectory. - Build the Release version ("build_all -- Win32 Release"). - - XXX We're actually linking against Release_static\libdb41s.lib. - XXX This yields the following warnings: -""" -Compiling... -_bsddb.c -Linking... - Creating library ./_bsddb.lib and object ./_bsddb.exp -LINK : warning LNK4049: locally defined symbol "_malloc" imported -LINK : warning LNK4049: locally defined symbol "_free" imported -LINK : warning LNK4049: locally defined symbol "_fclose" imported -LINK : warning LNK4049: locally defined symbol "_fopen" imported -_bsddb.pyd - 0 error(s), 4 warning(s) -""" - XXX This isn't encouraging, but I don't know what to do about it. + Now apply any patches that apply to your version. To run extensive tests, pass "-u bsddb" to regrtest.py. test_bsddb3.py is then enabled. Running in verbose mode may be helpful. XXX The test_bsddb3 tests don't always pass, on Windows (according to - XXX me) or on Linux (according to Barry). I had much better luck - XXX on Win2K than on Win98SE. The common failure mode across platforms + XXX me) or on Linux (according to Barry). (I had much better luck + XXX on Win2K than on Win98SE.) The common failure mode across platforms XXX is XXX DBAgainError: (11, 'Resource temporarily unavailable -- unable XXX to join the environment') Deleted: /python/branches/p3yk-noslice/PC/VC6/zlib.dsp ============================================================================== Binary file. No diff available. Modified: python/branches/p3yk-noslice/PC/_msi.c ============================================================================== --- python/branches/p3yk-noslice/PC/_msi.c (original) +++ python/branches/p3yk-noslice/PC/_msi.c Fri Dec 15 05:21:50 2006 @@ -495,7 +495,7 @@ status = MsiSummaryInfoGetProperty(si->h, field, &type, &ival, &fval, sval, &ssize); - if (status = ERROR_MORE_DATA) { + if (status == ERROR_MORE_DATA) { sval = malloc(ssize); status = MsiSummaryInfoGetProperty(si->h, field, &type, &ival, &fval, sval, &ssize); Modified: python/branches/p3yk-noslice/PC/_winreg.c ============================================================================== --- python/branches/p3yk-noslice/PC/_winreg.c (original) +++ python/branches/p3yk-noslice/PC/_winreg.c Fri Dec 15 05:21:50 2006 @@ -305,7 +305,7 @@ "handle - The integer Win32 handle.\n" "\n" "Operations:\n" -"__nonzero__ - Handles with an open object return true, otherwise false.\n" +"__bool__ - Handles with an open object return true, otherwise false.\n" "__int__ - Converting a handle to an integer returns the Win32 handle.\n" "__cmp__ - Handle objects are compared using the handle value."); @@ -375,7 +375,7 @@ } static int -PyHKEY_nonzeroFunc(PyObject *ob) +PyHKEY_boolFunc(PyObject *ob) { return ((PyHKEYObject *)ob)->hkey != 0; } @@ -437,7 +437,7 @@ PyHKEY_unaryFailureFunc, /* nb_negative */ PyHKEY_unaryFailureFunc, /* nb_positive */ PyHKEY_unaryFailureFunc, /* nb_absolute */ - PyHKEY_nonzeroFunc, /* nb_nonzero */ + PyHKEY_boolFunc, /* nb_bool */ PyHKEY_unaryFailureFunc, /* nb_invert */ PyHKEY_binaryFailureFunc, /* nb_lshift */ PyHKEY_binaryFailureFunc, /* nb_rshift */ Modified: python/branches/p3yk-noslice/PC/example_nt/example.vcproj ============================================================================== --- python/branches/p3yk-noslice/PC/example_nt/example.vcproj (original) +++ python/branches/p3yk-noslice/PC/example_nt/example.vcproj Fri Dec 15 05:21:50 2006 @@ -39,7 +39,7 @@ + + + + + + + + + + + + + + + + + Modified: python/branches/p3yk-noslice/PCbuild/pythoncore.vcproj ============================================================================== --- python/branches/p3yk-noslice/PCbuild/pythoncore.vcproj (original) +++ python/branches/p3yk-noslice/PCbuild/pythoncore.vcproj Fri Dec 15 05:21:50 2006 @@ -683,6 +683,9 @@ RelativePath="..\Parser\parsetok.c"> + + - - - - + + + @@ -236,17 +236,17 @@ /> @@ -327,17 +325,17 @@ /> + + @@ -238,18 +238,18 @@ /> @@ -330,18 +327,18 @@ /> #include -/* This file creates the getbuildinfo.o object, by first - invoking subwcrev.exe (if found), and then invoking cl.exe. - As a side effect, it might generate PCBuild\getbuildinfo2.c - also. If this isn't a subversion checkout, or subwcrev isn't - found, it compiles ..\\Modules\\getbuildinfo.c instead. +/* This file creates the getbuildinfo2.c file, by + invoking subwcrev.exe (if found). + If this isn't a subversion checkout, or subwcrev isn't + found, it copies ..\\Modules\\getbuildinfo.c instead. + + A file, getbuildinfo2.h is then updated to define + SUBWCREV if it was a subversion checkout. + + getbuildinfo2.c is part of the pythoncore project with + getbuildinfo2.h as a forced include. This helps + VisualStudio refrain from unnecessary compiles much of the + time. Currently, subwcrev.exe is found from the registry entries of TortoiseSVN. - No attempt is made to place getbuildinfo.o into the proper - binary directory. This isn't necessary, as this tool is - invoked as a pre-link step for pythoncore, so that overwrites - any previous getbuildinfo.o. + make_buildinfo.exe is called as a pre-build step for pythoncore. */ @@ -40,11 +44,11 @@ type != REG_SZ) /* Registry corrupted */ return 0; - strcat(command, "bin\\subwcrev.exe"); + strcat_s(command, sizeof(command), "bin\\subwcrev.exe"); if (_stat(command+1, &st) < 0) /* subwcrev.exe not part of the release */ return 0; - strcat(command, "\" .. ..\\Modules\\getbuildinfo.c getbuildinfo2.c"); + strcat_s(command, sizeof(command), "\" .. ..\\Modules\\getbuildinfo.c getbuildinfo2.c"); puts(command); fflush(stdout); if (system(command) < 0) return 0; @@ -53,40 +57,25 @@ int main(int argc, char*argv[]) { - char command[500] = "cl.exe -c -D_WIN32 -DUSE_DL_EXPORT -D_WINDOWS -DWIN32 -D_WINDLL "; - int do_unlink, result; - if (argc != 2) { - fprintf(stderr, "make_buildinfo $(ConfigurationName)\n"); - return EXIT_FAILURE; - } - if (strcmp(argv[1], "Release") == 0) { - strcat(command, "-MD "); - } - else if (strcmp(argv[1], "Debug") == 0) { - strcat(command, "-D_DEBUG -MDd "); - } - else if (strcmp(argv[1], "ReleaseItanium") == 0) { - strcat(command, "-MD /USECL:MS_ITANIUM "); - } - else if (strcmp(argv[1], "ReleaseAMD64") == 0) { - strcat(command, "-MD "); - strcat(command, "-MD /USECL:MS_OPTERON "); - } - else { - fprintf(stderr, "unsupported configuration %s\n", argv[1]); - return EXIT_FAILURE; - } + char command[500] = ""; + int svn; + FILE *f; - if ((do_unlink = make_buildinfo2())) - strcat(command, "getbuildinfo2.c -DSUBWCREV "); - else - strcat(command, "..\\Modules\\getbuildinfo.c"); - strcat(command, " -Fogetbuildinfo.o -I..\\Include -I..\\PC"); - puts(command); fflush(stdout); - result = system(command); - if (do_unlink) - unlink("getbuildinfo2.c"); - if (result < 0) + if (fopen_s(&f, "getbuildinfo2.h", "w")) return EXIT_FAILURE; + /* Get getbuildinfo.c from svn as getbuildinfo2.c */ + svn = make_buildinfo2(); + if (svn) { + puts("got getbuildinfo2.c from svn. Updating getbuildinfo2.h"); + /* yes. make sure SUBWCREV is defined */ + fprintf(f, "#define SUBWCREV\n"); + } else { + puts("didn't get getbuildinfo2.c from svn. Copying from Modules and clearing getbuildinfo2.h"); + strcat_s(command, sizeof(command), "copy ..\\Modules\\getbuildinfo.c getbuildinfo2.c"); + puts(command); fflush(stdout); + if (system(command) < 0) + return EXIT_FAILURE; + } + fclose(f); return 0; } \ No newline at end of file Modified: python/branches/p3yk-noslice/PCbuild8/make_buildinfo.vcproj ============================================================================== --- python/branches/p3yk-noslice/PCbuild8/make_buildinfo.vcproj (original) +++ python/branches/p3yk-noslice/PCbuild8/make_buildinfo.vcproj Fri Dec 15 05:21:50 2006 @@ -4,6 +4,7 @@ Version="8,00" Name="make_buildinfo" ProjectGUID="{C73F0EC1-358B-4177-940F-0846AC8B04CD}" + RootNamespace="make_buildinfo" Keyword="Win32Proj" > @@ -40,7 +41,7 @@ - - - - - - - - - - - - - - - - - - - - Modified: python/branches/p3yk-noslice/PCbuild8/pcbuild.sln ============================================================================== --- python/branches/p3yk-noslice/PCbuild8/pcbuild.sln (original) +++ python/branches/p3yk-noslice/PCbuild8/pcbuild.sln Fri Dec 15 05:21:50 2006 @@ -2,8 +2,8 @@ # Visual Studio 2005 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "pythoncore", "pythoncore.vcproj", "{CF7AC3D1-E2DF-41D2-BEA6-1E2556CDEA26}" ProjectSection(ProjectDependencies) = postProject - {C73F0EC1-358B-4177-940F-0846AC8B04CD} = {C73F0EC1-358B-4177-940F-0846AC8B04CD} {F0E0541E-F17D-430B-97C4-93ADF0DD284E} = {F0E0541E-F17D-430B-97C4-93ADF0DD284E} + {C73F0EC1-358B-4177-940F-0846AC8B04CD} = {C73F0EC1-358B-4177-940F-0846AC8B04CD} EndProjectSection EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "pythonw", "pythonw.vcproj", "{F4229CC3-873C-49AE-9729-DD308ED4CD4A}" @@ -61,137 +61,244 @@ readme.txt = readme.txt EndProjectSection EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "pythoncore_pgo", "pythoncore_pgo.vcproj", "{8B59C1FF-2439-4BE9-9F24-84D4982D28D4}" +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "python", "python.vcproj", "{B11D750F-CD1F-4A96-85CE-E69A5C5259F9}" ProjectSection(ProjectDependencies) = postProject {CF7AC3D1-E2DF-41D2-BEA6-1E2556CDEA26} = {CF7AC3D1-E2DF-41D2-BEA6-1E2556CDEA26} EndProjectSection EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "python", "python.vcproj", "{B11D750F-CD1F-4A96-85CE-E69A5C5259F9}" -EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "make_versioninfo", "make_versioninfo.vcproj", "{F0E0541E-F17D-430B-97C4-93ADF0DD284E}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Win32 = Debug|Win32 + Debug|x64 = Debug|x64 + PGIRelease|Win32 = PGIRelease|Win32 + PGIRelease|x64 = PGIRelease|x64 + PGORelease|Win32 = PGORelease|Win32 + PGORelease|x64 = PGORelease|x64 Release|Win32 = Release|Win32 - ReleaseAMD64|Win32 = ReleaseAMD64|Win32 - ReleaseItanium|Win32 = ReleaseItanium|Win32 + Release|x64 = Release|x64 EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution {CF7AC3D1-E2DF-41D2-BEA6-1E2556CDEA26}.Debug|Win32.ActiveCfg = Debug|Win32 {CF7AC3D1-E2DF-41D2-BEA6-1E2556CDEA26}.Debug|Win32.Build.0 = Debug|Win32 + {CF7AC3D1-E2DF-41D2-BEA6-1E2556CDEA26}.Debug|x64.ActiveCfg = Debug|x64 + {CF7AC3D1-E2DF-41D2-BEA6-1E2556CDEA26}.Debug|x64.Build.0 = Debug|x64 + {CF7AC3D1-E2DF-41D2-BEA6-1E2556CDEA26}.PGIRelease|Win32.ActiveCfg = PGIRelease|Win32 + {CF7AC3D1-E2DF-41D2-BEA6-1E2556CDEA26}.PGIRelease|Win32.Build.0 = PGIRelease|Win32 + {CF7AC3D1-E2DF-41D2-BEA6-1E2556CDEA26}.PGIRelease|x64.ActiveCfg = PGIRelease|x64 + {CF7AC3D1-E2DF-41D2-BEA6-1E2556CDEA26}.PGIRelease|x64.Build.0 = PGIRelease|x64 + {CF7AC3D1-E2DF-41D2-BEA6-1E2556CDEA26}.PGORelease|Win32.ActiveCfg = PGORelease|Win32 + {CF7AC3D1-E2DF-41D2-BEA6-1E2556CDEA26}.PGORelease|Win32.Build.0 = PGORelease|Win32 + {CF7AC3D1-E2DF-41D2-BEA6-1E2556CDEA26}.PGORelease|x64.ActiveCfg = PGORelease|x64 + {CF7AC3D1-E2DF-41D2-BEA6-1E2556CDEA26}.PGORelease|x64.Build.0 = PGORelease|x64 {CF7AC3D1-E2DF-41D2-BEA6-1E2556CDEA26}.Release|Win32.ActiveCfg = Release|Win32 {CF7AC3D1-E2DF-41D2-BEA6-1E2556CDEA26}.Release|Win32.Build.0 = Release|Win32 - {CF7AC3D1-E2DF-41D2-BEA6-1E2556CDEA26}.ReleaseAMD64|Win32.ActiveCfg = ReleaseAMD64|Win32 - {CF7AC3D1-E2DF-41D2-BEA6-1E2556CDEA26}.ReleaseAMD64|Win32.Build.0 = ReleaseAMD64|Win32 - {CF7AC3D1-E2DF-41D2-BEA6-1E2556CDEA26}.ReleaseItanium|Win32.ActiveCfg = ReleaseItanium|Win32 - {CF7AC3D1-E2DF-41D2-BEA6-1E2556CDEA26}.ReleaseItanium|Win32.Build.0 = ReleaseItanium|Win32 + {CF7AC3D1-E2DF-41D2-BEA6-1E2556CDEA26}.Release|x64.ActiveCfg = Release|x64 + {CF7AC3D1-E2DF-41D2-BEA6-1E2556CDEA26}.Release|x64.Build.0 = Release|x64 {F4229CC3-873C-49AE-9729-DD308ED4CD4A}.Debug|Win32.ActiveCfg = Debug|Win32 {F4229CC3-873C-49AE-9729-DD308ED4CD4A}.Debug|Win32.Build.0 = Debug|Win32 + {F4229CC3-873C-49AE-9729-DD308ED4CD4A}.Debug|x64.ActiveCfg = Debug|x64 + {F4229CC3-873C-49AE-9729-DD308ED4CD4A}.Debug|x64.Build.0 = Debug|x64 + {F4229CC3-873C-49AE-9729-DD308ED4CD4A}.PGIRelease|Win32.ActiveCfg = Release|Win32 + {F4229CC3-873C-49AE-9729-DD308ED4CD4A}.PGIRelease|Win32.Build.0 = Release|Win32 + {F4229CC3-873C-49AE-9729-DD308ED4CD4A}.PGIRelease|x64.ActiveCfg = Release|x64 + {F4229CC3-873C-49AE-9729-DD308ED4CD4A}.PGIRelease|x64.Build.0 = Release|x64 + {F4229CC3-873C-49AE-9729-DD308ED4CD4A}.PGORelease|Win32.ActiveCfg = Release|Win32 + {F4229CC3-873C-49AE-9729-DD308ED4CD4A}.PGORelease|Win32.Build.0 = Release|Win32 + {F4229CC3-873C-49AE-9729-DD308ED4CD4A}.PGORelease|x64.ActiveCfg = Release|x64 + {F4229CC3-873C-49AE-9729-DD308ED4CD4A}.PGORelease|x64.Build.0 = Release|x64 {F4229CC3-873C-49AE-9729-DD308ED4CD4A}.Release|Win32.ActiveCfg = Release|Win32 {F4229CC3-873C-49AE-9729-DD308ED4CD4A}.Release|Win32.Build.0 = Release|Win32 - {F4229CC3-873C-49AE-9729-DD308ED4CD4A}.ReleaseAMD64|Win32.ActiveCfg = ReleaseAMD64|Win32 - {F4229CC3-873C-49AE-9729-DD308ED4CD4A}.ReleaseAMD64|Win32.Build.0 = ReleaseAMD64|Win32 - {F4229CC3-873C-49AE-9729-DD308ED4CD4A}.ReleaseItanium|Win32.ActiveCfg = ReleaseItanium|Win32 - {F4229CC3-873C-49AE-9729-DD308ED4CD4A}.ReleaseItanium|Win32.Build.0 = ReleaseItanium|Win32 + {F4229CC3-873C-49AE-9729-DD308ED4CD4A}.Release|x64.ActiveCfg = Release|x64 + {F4229CC3-873C-49AE-9729-DD308ED4CD4A}.Release|x64.Build.0 = Release|x64 {97239A56-DBC0-41D2-BC14-C87D9B97D63B}.Debug|Win32.ActiveCfg = Debug|Win32 {97239A56-DBC0-41D2-BC14-C87D9B97D63B}.Debug|Win32.Build.0 = Debug|Win32 + {97239A56-DBC0-41D2-BC14-C87D9B97D63B}.Debug|x64.ActiveCfg = Debug|x64 + {97239A56-DBC0-41D2-BC14-C87D9B97D63B}.Debug|x64.Build.0 = Debug|x64 + {97239A56-DBC0-41D2-BC14-C87D9B97D63B}.PGIRelease|Win32.ActiveCfg = Release|Win32 + {97239A56-DBC0-41D2-BC14-C87D9B97D63B}.PGIRelease|Win32.Build.0 = Release|Win32 + {97239A56-DBC0-41D2-BC14-C87D9B97D63B}.PGIRelease|x64.ActiveCfg = Release|x64 + {97239A56-DBC0-41D2-BC14-C87D9B97D63B}.PGIRelease|x64.Build.0 = Release|x64 + {97239A56-DBC0-41D2-BC14-C87D9B97D63B}.PGORelease|Win32.ActiveCfg = Release|Win32 + {97239A56-DBC0-41D2-BC14-C87D9B97D63B}.PGORelease|Win32.Build.0 = Release|Win32 + {97239A56-DBC0-41D2-BC14-C87D9B97D63B}.PGORelease|x64.ActiveCfg = Release|x64 + {97239A56-DBC0-41D2-BC14-C87D9B97D63B}.PGORelease|x64.Build.0 = Release|x64 {97239A56-DBC0-41D2-BC14-C87D9B97D63B}.Release|Win32.ActiveCfg = Release|Win32 {97239A56-DBC0-41D2-BC14-C87D9B97D63B}.Release|Win32.Build.0 = Release|Win32 - {97239A56-DBC0-41D2-BC14-C87D9B97D63B}.ReleaseAMD64|Win32.ActiveCfg = ReleaseAMD64|Win32 - {97239A56-DBC0-41D2-BC14-C87D9B97D63B}.ReleaseAMD64|Win32.Build.0 = ReleaseAMD64|Win32 - {97239A56-DBC0-41D2-BC14-C87D9B97D63B}.ReleaseItanium|Win32.ActiveCfg = ReleaseItanium|Win32 - {97239A56-DBC0-41D2-BC14-C87D9B97D63B}.ReleaseItanium|Win32.Build.0 = ReleaseItanium|Win32 + {97239A56-DBC0-41D2-BC14-C87D9B97D63B}.Release|x64.ActiveCfg = Release|x64 + {97239A56-DBC0-41D2-BC14-C87D9B97D63B}.Release|x64.Build.0 = Release|x64 {FA5FC7EB-C72F-415F-AE42-91DD605ABDDA}.Debug|Win32.ActiveCfg = Debug|Win32 {FA5FC7EB-C72F-415F-AE42-91DD605ABDDA}.Debug|Win32.Build.0 = Debug|Win32 + {FA5FC7EB-C72F-415F-AE42-91DD605ABDDA}.Debug|x64.ActiveCfg = Debug|x64 + {FA5FC7EB-C72F-415F-AE42-91DD605ABDDA}.Debug|x64.Build.0 = Debug|x64 + {FA5FC7EB-C72F-415F-AE42-91DD605ABDDA}.PGIRelease|Win32.ActiveCfg = Release|Win32 + {FA5FC7EB-C72F-415F-AE42-91DD605ABDDA}.PGIRelease|Win32.Build.0 = Release|Win32 + {FA5FC7EB-C72F-415F-AE42-91DD605ABDDA}.PGIRelease|x64.ActiveCfg = Release|x64 + {FA5FC7EB-C72F-415F-AE42-91DD605ABDDA}.PGIRelease|x64.Build.0 = Release|x64 + {FA5FC7EB-C72F-415F-AE42-91DD605ABDDA}.PGORelease|Win32.ActiveCfg = Release|Win32 + {FA5FC7EB-C72F-415F-AE42-91DD605ABDDA}.PGORelease|Win32.Build.0 = Release|Win32 + {FA5FC7EB-C72F-415F-AE42-91DD605ABDDA}.PGORelease|x64.ActiveCfg = Release|x64 + {FA5FC7EB-C72F-415F-AE42-91DD605ABDDA}.PGORelease|x64.Build.0 = Release|x64 {FA5FC7EB-C72F-415F-AE42-91DD605ABDDA}.Release|Win32.ActiveCfg = Release|Win32 {FA5FC7EB-C72F-415F-AE42-91DD605ABDDA}.Release|Win32.Build.0 = Release|Win32 - {FA5FC7EB-C72F-415F-AE42-91DD605ABDDA}.ReleaseAMD64|Win32.ActiveCfg = ReleaseAMD64|Win32 - {FA5FC7EB-C72F-415F-AE42-91DD605ABDDA}.ReleaseAMD64|Win32.Build.0 = ReleaseAMD64|Win32 - {FA5FC7EB-C72F-415F-AE42-91DD605ABDDA}.ReleaseItanium|Win32.ActiveCfg = ReleaseItanium|Win32 - {FA5FC7EB-C72F-415F-AE42-91DD605ABDDA}.ReleaseItanium|Win32.Build.0 = ReleaseItanium|Win32 + {FA5FC7EB-C72F-415F-AE42-91DD605ABDDA}.Release|x64.ActiveCfg = Release|x64 + {FA5FC7EB-C72F-415F-AE42-91DD605ABDDA}.Release|x64.Build.0 = Release|x64 {E9E0A1F6-0009-4E8C-B8F8-1B8F5D49A058}.Debug|Win32.ActiveCfg = Debug|Win32 {E9E0A1F6-0009-4E8C-B8F8-1B8F5D49A058}.Debug|Win32.Build.0 = Debug|Win32 + {E9E0A1F6-0009-4E8C-B8F8-1B8F5D49A058}.Debug|x64.ActiveCfg = Debug|x64 + {E9E0A1F6-0009-4E8C-B8F8-1B8F5D49A058}.Debug|x64.Build.0 = Debug|x64 + {E9E0A1F6-0009-4E8C-B8F8-1B8F5D49A058}.PGIRelease|Win32.ActiveCfg = Release|Win32 + {E9E0A1F6-0009-4E8C-B8F8-1B8F5D49A058}.PGIRelease|Win32.Build.0 = Release|Win32 + {E9E0A1F6-0009-4E8C-B8F8-1B8F5D49A058}.PGIRelease|x64.ActiveCfg = Release|x64 + {E9E0A1F6-0009-4E8C-B8F8-1B8F5D49A058}.PGIRelease|x64.Build.0 = Release|x64 + {E9E0A1F6-0009-4E8C-B8F8-1B8F5D49A058}.PGORelease|Win32.ActiveCfg = Release|Win32 + {E9E0A1F6-0009-4E8C-B8F8-1B8F5D49A058}.PGORelease|Win32.Build.0 = Release|Win32 + {E9E0A1F6-0009-4E8C-B8F8-1B8F5D49A058}.PGORelease|x64.ActiveCfg = Release|x64 + {E9E0A1F6-0009-4E8C-B8F8-1B8F5D49A058}.PGORelease|x64.Build.0 = Release|x64 {E9E0A1F6-0009-4E8C-B8F8-1B8F5D49A058}.Release|Win32.ActiveCfg = Release|Win32 {E9E0A1F6-0009-4E8C-B8F8-1B8F5D49A058}.Release|Win32.Build.0 = Release|Win32 - {E9E0A1F6-0009-4E8C-B8F8-1B8F5D49A058}.ReleaseAMD64|Win32.ActiveCfg = Release|Win32 - {E9E0A1F6-0009-4E8C-B8F8-1B8F5D49A058}.ReleaseItanium|Win32.ActiveCfg = Release|Win32 + {E9E0A1F6-0009-4E8C-B8F8-1B8F5D49A058}.Release|x64.ActiveCfg = Release|x64 + {E9E0A1F6-0009-4E8C-B8F8-1B8F5D49A058}.Release|x64.Build.0 = Release|x64 {51F35FAE-FB92-4B2C-9187-1542C065AD77}.Debug|Win32.ActiveCfg = Debug|Win32 {51F35FAE-FB92-4B2C-9187-1542C065AD77}.Debug|Win32.Build.0 = Debug|Win32 + {51F35FAE-FB92-4B2C-9187-1542C065AD77}.Debug|x64.ActiveCfg = Debug|x64 + {51F35FAE-FB92-4B2C-9187-1542C065AD77}.Debug|x64.Build.0 = Debug|x64 + {51F35FAE-FB92-4B2C-9187-1542C065AD77}.PGIRelease|Win32.ActiveCfg = Release|Win32 + {51F35FAE-FB92-4B2C-9187-1542C065AD77}.PGIRelease|Win32.Build.0 = Release|Win32 + {51F35FAE-FB92-4B2C-9187-1542C065AD77}.PGIRelease|x64.ActiveCfg = Release|x64 + {51F35FAE-FB92-4B2C-9187-1542C065AD77}.PGIRelease|x64.Build.0 = Release|x64 + {51F35FAE-FB92-4B2C-9187-1542C065AD77}.PGORelease|Win32.ActiveCfg = Release|Win32 + {51F35FAE-FB92-4B2C-9187-1542C065AD77}.PGORelease|Win32.Build.0 = Release|Win32 + {51F35FAE-FB92-4B2C-9187-1542C065AD77}.PGORelease|x64.ActiveCfg = Release|x64 + {51F35FAE-FB92-4B2C-9187-1542C065AD77}.PGORelease|x64.Build.0 = Release|x64 {51F35FAE-FB92-4B2C-9187-1542C065AD77}.Release|Win32.ActiveCfg = Release|Win32 {51F35FAE-FB92-4B2C-9187-1542C065AD77}.Release|Win32.Build.0 = Release|Win32 - {51F35FAE-FB92-4B2C-9187-1542C065AD77}.ReleaseAMD64|Win32.ActiveCfg = ReleaseAMD64|Win32 - {51F35FAE-FB92-4B2C-9187-1542C065AD77}.ReleaseAMD64|Win32.Build.0 = ReleaseAMD64|Win32 - {51F35FAE-FB92-4B2C-9187-1542C065AD77}.ReleaseItanium|Win32.ActiveCfg = ReleaseItanium|Win32 - {51F35FAE-FB92-4B2C-9187-1542C065AD77}.ReleaseItanium|Win32.Build.0 = ReleaseItanium|Win32 + {51F35FAE-FB92-4B2C-9187-1542C065AD77}.Release|x64.ActiveCfg = Release|x64 + {51F35FAE-FB92-4B2C-9187-1542C065AD77}.Release|x64.Build.0 = Release|x64 {1966DDE2-4AB7-4E4E-ACC9-C121E4D37F8E}.Debug|Win32.ActiveCfg = Debug|Win32 {1966DDE2-4AB7-4E4E-ACC9-C121E4D37F8E}.Debug|Win32.Build.0 = Debug|Win32 + {1966DDE2-4AB7-4E4E-ACC9-C121E4D37F8E}.Debug|x64.ActiveCfg = Debug|x64 + {1966DDE2-4AB7-4E4E-ACC9-C121E4D37F8E}.Debug|x64.Build.0 = Debug|x64 + {1966DDE2-4AB7-4E4E-ACC9-C121E4D37F8E}.PGIRelease|Win32.ActiveCfg = Release|Win32 + {1966DDE2-4AB7-4E4E-ACC9-C121E4D37F8E}.PGIRelease|Win32.Build.0 = Release|Win32 + {1966DDE2-4AB7-4E4E-ACC9-C121E4D37F8E}.PGIRelease|x64.ActiveCfg = Release|x64 + {1966DDE2-4AB7-4E4E-ACC9-C121E4D37F8E}.PGIRelease|x64.Build.0 = Release|x64 + {1966DDE2-4AB7-4E4E-ACC9-C121E4D37F8E}.PGORelease|Win32.ActiveCfg = Release|Win32 + {1966DDE2-4AB7-4E4E-ACC9-C121E4D37F8E}.PGORelease|Win32.Build.0 = Release|Win32 + {1966DDE2-4AB7-4E4E-ACC9-C121E4D37F8E}.PGORelease|x64.ActiveCfg = Release|x64 + {1966DDE2-4AB7-4E4E-ACC9-C121E4D37F8E}.PGORelease|x64.Build.0 = Release|x64 {1966DDE2-4AB7-4E4E-ACC9-C121E4D37F8E}.Release|Win32.ActiveCfg = Release|Win32 {1966DDE2-4AB7-4E4E-ACC9-C121E4D37F8E}.Release|Win32.Build.0 = Release|Win32 - {1966DDE2-4AB7-4E4E-ACC9-C121E4D37F8E}.ReleaseAMD64|Win32.ActiveCfg = ReleaseAMD64|Win32 - {1966DDE2-4AB7-4E4E-ACC9-C121E4D37F8E}.ReleaseAMD64|Win32.Build.0 = ReleaseAMD64|Win32 - {1966DDE2-4AB7-4E4E-ACC9-C121E4D37F8E}.ReleaseItanium|Win32.ActiveCfg = ReleaseItanium|Win32 - {1966DDE2-4AB7-4E4E-ACC9-C121E4D37F8E}.ReleaseItanium|Win32.Build.0 = ReleaseItanium|Win32 + {1966DDE2-4AB7-4E4E-ACC9-C121E4D37F8E}.Release|x64.ActiveCfg = Release|x64 + {1966DDE2-4AB7-4E4E-ACC9-C121E4D37F8E}.Release|x64.Build.0 = Release|x64 {C73F0EC1-358B-4177-940F-0846AC8B04CD}.Debug|Win32.ActiveCfg = Debug|Win32 {C73F0EC1-358B-4177-940F-0846AC8B04CD}.Debug|Win32.Build.0 = Debug|Win32 - {C73F0EC1-358B-4177-940F-0846AC8B04CD}.Release|Win32.ActiveCfg = Release|Win32 - {C73F0EC1-358B-4177-940F-0846AC8B04CD}.Release|Win32.Build.0 = Release|Win32 - {C73F0EC1-358B-4177-940F-0846AC8B04CD}.ReleaseAMD64|Win32.ActiveCfg = Release|Win32 - {C73F0EC1-358B-4177-940F-0846AC8B04CD}.ReleaseAMD64|Win32.Build.0 = Release|Win32 - {C73F0EC1-358B-4177-940F-0846AC8B04CD}.ReleaseItanium|Win32.ActiveCfg = Release|Win32 - {C73F0EC1-358B-4177-940F-0846AC8B04CD}.ReleaseItanium|Win32.Build.0 = Release|Win32 + {C73F0EC1-358B-4177-940F-0846AC8B04CD}.Debug|x64.ActiveCfg = Debug|Win32 + {C73F0EC1-358B-4177-940F-0846AC8B04CD}.Debug|x64.Build.0 = Debug|Win32 + {C73F0EC1-358B-4177-940F-0846AC8B04CD}.PGIRelease|Win32.ActiveCfg = Debug|Win32 + {C73F0EC1-358B-4177-940F-0846AC8B04CD}.PGIRelease|Win32.Build.0 = Debug|Win32 + {C73F0EC1-358B-4177-940F-0846AC8B04CD}.PGIRelease|x64.ActiveCfg = Debug|Win32 + {C73F0EC1-358B-4177-940F-0846AC8B04CD}.PGORelease|Win32.ActiveCfg = Debug|Win32 + {C73F0EC1-358B-4177-940F-0846AC8B04CD}.PGORelease|Win32.Build.0 = Debug|Win32 + {C73F0EC1-358B-4177-940F-0846AC8B04CD}.PGORelease|x64.ActiveCfg = Debug|Win32 + {C73F0EC1-358B-4177-940F-0846AC8B04CD}.Release|Win32.ActiveCfg = Debug|Win32 + {C73F0EC1-358B-4177-940F-0846AC8B04CD}.Release|Win32.Build.0 = Debug|Win32 + {C73F0EC1-358B-4177-940F-0846AC8B04CD}.Release|x64.ActiveCfg = Debug|Win32 + {C73F0EC1-358B-4177-940F-0846AC8B04CD}.Release|x64.Build.0 = Debug|Win32 {2C0BEFB9-70E2-4F80-AC5B-4AB8EE023574}.Debug|Win32.ActiveCfg = Debug|Win32 {2C0BEFB9-70E2-4F80-AC5B-4AB8EE023574}.Debug|Win32.Build.0 = Debug|Win32 + {2C0BEFB9-70E2-4F80-AC5B-4AB8EE023574}.Debug|x64.ActiveCfg = Debug|x64 + {2C0BEFB9-70E2-4F80-AC5B-4AB8EE023574}.Debug|x64.Build.0 = Debug|x64 + {2C0BEFB9-70E2-4F80-AC5B-4AB8EE023574}.PGIRelease|Win32.ActiveCfg = Release|Win32 + {2C0BEFB9-70E2-4F80-AC5B-4AB8EE023574}.PGIRelease|Win32.Build.0 = Release|Win32 + {2C0BEFB9-70E2-4F80-AC5B-4AB8EE023574}.PGIRelease|x64.ActiveCfg = Release|x64 + {2C0BEFB9-70E2-4F80-AC5B-4AB8EE023574}.PGIRelease|x64.Build.0 = Release|x64 + {2C0BEFB9-70E2-4F80-AC5B-4AB8EE023574}.PGORelease|Win32.ActiveCfg = Release|Win32 + {2C0BEFB9-70E2-4F80-AC5B-4AB8EE023574}.PGORelease|Win32.Build.0 = Release|Win32 + {2C0BEFB9-70E2-4F80-AC5B-4AB8EE023574}.PGORelease|x64.ActiveCfg = Release|x64 + {2C0BEFB9-70E2-4F80-AC5B-4AB8EE023574}.PGORelease|x64.Build.0 = Release|x64 {2C0BEFB9-70E2-4F80-AC5B-4AB8EE023574}.Release|Win32.ActiveCfg = Release|Win32 {2C0BEFB9-70E2-4F80-AC5B-4AB8EE023574}.Release|Win32.Build.0 = Release|Win32 - {2C0BEFB9-70E2-4F80-AC5B-4AB8EE023574}.ReleaseAMD64|Win32.ActiveCfg = ReleaseAMD64|Win32 - {2C0BEFB9-70E2-4F80-AC5B-4AB8EE023574}.ReleaseAMD64|Win32.Build.0 = ReleaseAMD64|Win32 - {2C0BEFB9-70E2-4F80-AC5B-4AB8EE023574}.ReleaseItanium|Win32.ActiveCfg = ReleaseItanium|Win32 - {2C0BEFB9-70E2-4F80-AC5B-4AB8EE023574}.ReleaseItanium|Win32.Build.0 = ReleaseItanium|Win32 + {2C0BEFB9-70E2-4F80-AC5B-4AB8EE023574}.Release|x64.ActiveCfg = Release|x64 + {2C0BEFB9-70E2-4F80-AC5B-4AB8EE023574}.Release|x64.Build.0 = Release|x64 {F22F40F4-D318-40DC-96B3-88DC81CE0894}.Debug|Win32.ActiveCfg = Debug|Win32 {F22F40F4-D318-40DC-96B3-88DC81CE0894}.Debug|Win32.Build.0 = Debug|Win32 + {F22F40F4-D318-40DC-96B3-88DC81CE0894}.Debug|x64.ActiveCfg = Debug|x64 + {F22F40F4-D318-40DC-96B3-88DC81CE0894}.Debug|x64.Build.0 = Debug|x64 + {F22F40F4-D318-40DC-96B3-88DC81CE0894}.PGIRelease|Win32.ActiveCfg = Release|Win32 + {F22F40F4-D318-40DC-96B3-88DC81CE0894}.PGIRelease|Win32.Build.0 = Release|Win32 + {F22F40F4-D318-40DC-96B3-88DC81CE0894}.PGIRelease|x64.ActiveCfg = Release|x64 + {F22F40F4-D318-40DC-96B3-88DC81CE0894}.PGIRelease|x64.Build.0 = Release|x64 + {F22F40F4-D318-40DC-96B3-88DC81CE0894}.PGORelease|Win32.ActiveCfg = Release|Win32 + {F22F40F4-D318-40DC-96B3-88DC81CE0894}.PGORelease|Win32.Build.0 = Release|Win32 + {F22F40F4-D318-40DC-96B3-88DC81CE0894}.PGORelease|x64.ActiveCfg = Release|x64 + {F22F40F4-D318-40DC-96B3-88DC81CE0894}.PGORelease|x64.Build.0 = Release|x64 {F22F40F4-D318-40DC-96B3-88DC81CE0894}.Release|Win32.ActiveCfg = Release|Win32 {F22F40F4-D318-40DC-96B3-88DC81CE0894}.Release|Win32.Build.0 = Release|Win32 - {F22F40F4-D318-40DC-96B3-88DC81CE0894}.ReleaseAMD64|Win32.ActiveCfg = ReleaseAMD64|Win32 - {F22F40F4-D318-40DC-96B3-88DC81CE0894}.ReleaseItanium|Win32.ActiveCfg = ReleaseItanium|Win32 + {F22F40F4-D318-40DC-96B3-88DC81CE0894}.Release|x64.ActiveCfg = Release|x64 {8CF334D9-4F82-42EB-97AF-83592C5AFD2F}.Debug|Win32.ActiveCfg = Debug|Win32 {8CF334D9-4F82-42EB-97AF-83592C5AFD2F}.Debug|Win32.Build.0 = Debug|Win32 + {8CF334D9-4F82-42EB-97AF-83592C5AFD2F}.Debug|x64.ActiveCfg = Debug|x64 + {8CF334D9-4F82-42EB-97AF-83592C5AFD2F}.Debug|x64.Build.0 = Debug|x64 + {8CF334D9-4F82-42EB-97AF-83592C5AFD2F}.PGIRelease|Win32.ActiveCfg = Release|Win32 + {8CF334D9-4F82-42EB-97AF-83592C5AFD2F}.PGIRelease|Win32.Build.0 = Release|Win32 + {8CF334D9-4F82-42EB-97AF-83592C5AFD2F}.PGIRelease|x64.ActiveCfg = Release|x64 + {8CF334D9-4F82-42EB-97AF-83592C5AFD2F}.PGIRelease|x64.Build.0 = Release|x64 + {8CF334D9-4F82-42EB-97AF-83592C5AFD2F}.PGORelease|Win32.ActiveCfg = Release|Win32 + {8CF334D9-4F82-42EB-97AF-83592C5AFD2F}.PGORelease|Win32.Build.0 = Release|Win32 + {8CF334D9-4F82-42EB-97AF-83592C5AFD2F}.PGORelease|x64.ActiveCfg = Release|x64 + {8CF334D9-4F82-42EB-97AF-83592C5AFD2F}.PGORelease|x64.Build.0 = Release|x64 {8CF334D9-4F82-42EB-97AF-83592C5AFD2F}.Release|Win32.ActiveCfg = Release|Win32 {8CF334D9-4F82-42EB-97AF-83592C5AFD2F}.Release|Win32.Build.0 = Release|Win32 - {8CF334D9-4F82-42EB-97AF-83592C5AFD2F}.ReleaseAMD64|Win32.ActiveCfg = ReleaseAMD64|Win32 - {8CF334D9-4F82-42EB-97AF-83592C5AFD2F}.ReleaseItanium|Win32.ActiveCfg = ReleaseItanium|Win32 + {8CF334D9-4F82-42EB-97AF-83592C5AFD2F}.Release|x64.ActiveCfg = Release|x64 + {8CF334D9-4F82-42EB-97AF-83592C5AFD2F}.Release|x64.Build.0 = Release|x64 {2FF0A312-22F9-4C34-B070-842916DE27A9}.Debug|Win32.ActiveCfg = Debug|Win32 {2FF0A312-22F9-4C34-B070-842916DE27A9}.Debug|Win32.Build.0 = Debug|Win32 + {2FF0A312-22F9-4C34-B070-842916DE27A9}.Debug|x64.ActiveCfg = Debug|x64 + {2FF0A312-22F9-4C34-B070-842916DE27A9}.Debug|x64.Build.0 = Debug|x64 + {2FF0A312-22F9-4C34-B070-842916DE27A9}.PGIRelease|Win32.ActiveCfg = Release|Win32 + {2FF0A312-22F9-4C34-B070-842916DE27A9}.PGIRelease|Win32.Build.0 = Release|Win32 + {2FF0A312-22F9-4C34-B070-842916DE27A9}.PGIRelease|x64.ActiveCfg = Release|x64 + {2FF0A312-22F9-4C34-B070-842916DE27A9}.PGIRelease|x64.Build.0 = Release|x64 + {2FF0A312-22F9-4C34-B070-842916DE27A9}.PGORelease|Win32.ActiveCfg = Release|Win32 + {2FF0A312-22F9-4C34-B070-842916DE27A9}.PGORelease|Win32.Build.0 = Release|Win32 + {2FF0A312-22F9-4C34-B070-842916DE27A9}.PGORelease|x64.ActiveCfg = Release|x64 + {2FF0A312-22F9-4C34-B070-842916DE27A9}.PGORelease|x64.Build.0 = Release|x64 {2FF0A312-22F9-4C34-B070-842916DE27A9}.Release|Win32.ActiveCfg = Release|Win32 {2FF0A312-22F9-4C34-B070-842916DE27A9}.Release|Win32.Build.0 = Release|Win32 - {2FF0A312-22F9-4C34-B070-842916DE27A9}.ReleaseAMD64|Win32.ActiveCfg = ReleaseAMD64|Win32 - {2FF0A312-22F9-4C34-B070-842916DE27A9}.ReleaseAMD64|Win32.Build.0 = ReleaseAMD64|Win32 - {2FF0A312-22F9-4C34-B070-842916DE27A9}.ReleaseItanium|Win32.ActiveCfg = ReleaseItanium|Win32 - {2FF0A312-22F9-4C34-B070-842916DE27A9}.ReleaseItanium|Win32.Build.0 = ReleaseItanium|Win32 - {8B59C1FF-2439-4BE9-9F24-84D4982D28D4}.Debug|Win32.ActiveCfg = Release|Win32 - {8B59C1FF-2439-4BE9-9F24-84D4982D28D4}.Debug|Win32.Build.0 = Release|Win32 - {8B59C1FF-2439-4BE9-9F24-84D4982D28D4}.Release|Win32.ActiveCfg = Release|Win32 - {8B59C1FF-2439-4BE9-9F24-84D4982D28D4}.Release|Win32.Build.0 = Release|Win32 - {8B59C1FF-2439-4BE9-9F24-84D4982D28D4}.ReleaseAMD64|Win32.ActiveCfg = Release|Win32 - {8B59C1FF-2439-4BE9-9F24-84D4982D28D4}.ReleaseAMD64|Win32.Build.0 = Release|Win32 - {8B59C1FF-2439-4BE9-9F24-84D4982D28D4}.ReleaseItanium|Win32.ActiveCfg = Release|Win32 - {8B59C1FF-2439-4BE9-9F24-84D4982D28D4}.ReleaseItanium|Win32.Build.0 = Release|Win32 + {2FF0A312-22F9-4C34-B070-842916DE27A9}.Release|x64.ActiveCfg = Release|x64 + {2FF0A312-22F9-4C34-B070-842916DE27A9}.Release|x64.Build.0 = Release|x64 {B11D750F-CD1F-4A96-85CE-E69A5C5259F9}.Debug|Win32.ActiveCfg = Debug|Win32 {B11D750F-CD1F-4A96-85CE-E69A5C5259F9}.Debug|Win32.Build.0 = Debug|Win32 + {B11D750F-CD1F-4A96-85CE-E69A5C5259F9}.Debug|x64.ActiveCfg = Debug|x64 + {B11D750F-CD1F-4A96-85CE-E69A5C5259F9}.Debug|x64.Build.0 = Debug|x64 + {B11D750F-CD1F-4A96-85CE-E69A5C5259F9}.PGIRelease|Win32.ActiveCfg = Release|Win32 + {B11D750F-CD1F-4A96-85CE-E69A5C5259F9}.PGIRelease|Win32.Build.0 = Release|Win32 + {B11D750F-CD1F-4A96-85CE-E69A5C5259F9}.PGIRelease|x64.ActiveCfg = Release|x64 + {B11D750F-CD1F-4A96-85CE-E69A5C5259F9}.PGIRelease|x64.Build.0 = Release|x64 + {B11D750F-CD1F-4A96-85CE-E69A5C5259F9}.PGORelease|Win32.ActiveCfg = Release|Win32 + {B11D750F-CD1F-4A96-85CE-E69A5C5259F9}.PGORelease|Win32.Build.0 = Release|Win32 + {B11D750F-CD1F-4A96-85CE-E69A5C5259F9}.PGORelease|x64.ActiveCfg = Release|x64 + {B11D750F-CD1F-4A96-85CE-E69A5C5259F9}.PGORelease|x64.Build.0 = Release|x64 {B11D750F-CD1F-4A96-85CE-E69A5C5259F9}.Release|Win32.ActiveCfg = Release|Win32 {B11D750F-CD1F-4A96-85CE-E69A5C5259F9}.Release|Win32.Build.0 = Release|Win32 - {B11D750F-CD1F-4A96-85CE-E69A5C5259F9}.ReleaseAMD64|Win32.ActiveCfg = ReleaseAMD64|Win32 - {B11D750F-CD1F-4A96-85CE-E69A5C5259F9}.ReleaseAMD64|Win32.Build.0 = ReleaseAMD64|Win32 - {B11D750F-CD1F-4A96-85CE-E69A5C5259F9}.ReleaseItanium|Win32.ActiveCfg = ReleaseItanium|Win32 - {B11D750F-CD1F-4A96-85CE-E69A5C5259F9}.ReleaseItanium|Win32.Build.0 = ReleaseItanium|Win32 + {B11D750F-CD1F-4A96-85CE-E69A5C5259F9}.Release|x64.ActiveCfg = Release|x64 + {B11D750F-CD1F-4A96-85CE-E69A5C5259F9}.Release|x64.Build.0 = Release|x64 {F0E0541E-F17D-430B-97C4-93ADF0DD284E}.Debug|Win32.ActiveCfg = Debug|Win32 {F0E0541E-F17D-430B-97C4-93ADF0DD284E}.Debug|Win32.Build.0 = Debug|Win32 + {F0E0541E-F17D-430B-97C4-93ADF0DD284E}.Debug|x64.ActiveCfg = Debug|Win32 + {F0E0541E-F17D-430B-97C4-93ADF0DD284E}.Debug|x64.Build.0 = Debug|Win32 + {F0E0541E-F17D-430B-97C4-93ADF0DD284E}.PGIRelease|Win32.ActiveCfg = Release|Win32 + {F0E0541E-F17D-430B-97C4-93ADF0DD284E}.PGIRelease|Win32.Build.0 = Release|Win32 + {F0E0541E-F17D-430B-97C4-93ADF0DD284E}.PGIRelease|x64.ActiveCfg = Release|Win32 + {F0E0541E-F17D-430B-97C4-93ADF0DD284E}.PGORelease|Win32.ActiveCfg = Release|Win32 + {F0E0541E-F17D-430B-97C4-93ADF0DD284E}.PGORelease|Win32.Build.0 = Release|Win32 + {F0E0541E-F17D-430B-97C4-93ADF0DD284E}.PGORelease|x64.ActiveCfg = Release|Win32 {F0E0541E-F17D-430B-97C4-93ADF0DD284E}.Release|Win32.ActiveCfg = Release|Win32 {F0E0541E-F17D-430B-97C4-93ADF0DD284E}.Release|Win32.Build.0 = Release|Win32 - {F0E0541E-F17D-430B-97C4-93ADF0DD284E}.ReleaseAMD64|Win32.ActiveCfg = Release|Win32 - {F0E0541E-F17D-430B-97C4-93ADF0DD284E}.ReleaseAMD64|Win32.Build.0 = Release|Win32 - {F0E0541E-F17D-430B-97C4-93ADF0DD284E}.ReleaseItanium|Win32.ActiveCfg = Release|Win32 - {F0E0541E-F17D-430B-97C4-93ADF0DD284E}.ReleaseItanium|Win32.Build.0 = Release|Win32 + {F0E0541E-F17D-430B-97C4-93ADF0DD284E}.Release|x64.ActiveCfg = Release|Win32 + {F0E0541E-F17D-430B-97C4-93ADF0DD284E}.Release|x64.Build.0 = Release|Win32 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE Modified: python/branches/p3yk-noslice/PCbuild8/python.vcproj ============================================================================== --- python/branches/p3yk-noslice/PCbuild8/python.vcproj (original) +++ python/branches/p3yk-noslice/PCbuild8/python.vcproj Fri Dec 15 05:21:50 2006 @@ -4,19 +4,23 @@ Version="8,00" Name="python" ProjectGUID="{B11D750F-CD1F-4A96-85CE-E69A5C5259F9}" + RootNamespace="python" > + @@ -239,25 +241,26 @@ /> @@ -333,25 +331,26 @@ /> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -253,23 +440,21 @@ /> @@ -350,23 +537,21 @@ /> - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -558,6 +1297,10 @@ > + + @@ -738,6 +1481,74 @@ > + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -797,6 +1608,14 @@ /> + + + + + + + + + + + + + + Deleted: /python/branches/p3yk-noslice/PCbuild8/pythoncore_pgo.vcproj ============================================================================== --- /python/branches/p3yk-noslice/PCbuild8/pythoncore_pgo.vcproj Fri Dec 15 05:21:50 2006 +++ (empty file) @@ -1,781 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Deleted: /python/branches/p3yk-noslice/PCbuild8/pythoncore_pgo_link.txt ============================================================================== --- /python/branches/p3yk-noslice/PCbuild8/pythoncore_pgo_link.txt Fri Dec 15 05:21:50 2006 +++ (empty file) @@ -1,311 +0,0 @@ -/OUT:".\pythoncore_pgo/python25.dll" /INCREMENTAL:NO /DLL /MANIFEST /MANIFESTFILE:".\x86-temp-release\pythoncore_pgo\python25.dll.intermediate.manifest" /NODEFAULTLIB:"libc" /DEBUG /PDB:".\pythoncore_pgo/python25.pdb" /SUBSYSTEM:WINDOWS /LTCG:PGINSTRUMENT /PGD:".\pythoncore_pgo\python25.pgd" /BASE:"0x1e000000" /IMPLIB:"pythoncore_pgo/python25.lib" /MACHINE:X86 getbuildinfo.o kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib - -".\x86-temp-release\pythoncore_pgo\adler32.obj" - -".\x86-temp-release\pythoncore_pgo\compress.obj" - -".\x86-temp-release\pythoncore_pgo\crc32.obj" - -".\x86-temp-release\pythoncore_pgo\deflate.obj" - -".\x86-temp-release\pythoncore_pgo\gzio.obj" - -".\x86-temp-release\pythoncore_pgo\infback.obj" - -".\x86-temp-release\pythoncore_pgo\inffast.obj" - -".\x86-temp-release\pythoncore_pgo\inflate.obj" - -".\x86-temp-release\pythoncore_pgo\inftrees.obj" - -".\x86-temp-release\pythoncore_pgo\trees.obj" - -".\x86-temp-release\pythoncore_pgo\uncompr.obj" - -".\x86-temp-release\pythoncore_pgo\zlibmodule.obj" - -".\x86-temp-release\pythoncore_pgo\zutil.obj" - -".\x86-temp-release\pythoncore_pgo\_bisectmodule.obj" - -".\x86-temp-release\pythoncore_pgo\_codecs_cn.obj" - -".\x86-temp-release\pythoncore_pgo\_codecs_hk.obj" - -".\x86-temp-release\pythoncore_pgo\_codecs_iso2022.obj" - -".\x86-temp-release\pythoncore_pgo\_codecs_jp.obj" - -".\x86-temp-release\pythoncore_pgo\_codecs_kr.obj" - -".\x86-temp-release\pythoncore_pgo\_codecs_tw.obj" - -".\x86-temp-release\pythoncore_pgo\_codecsmodule.obj" - -".\x86-temp-release\pythoncore_pgo\_csv.obj" - -".\x86-temp-release\pythoncore_pgo\_functoolsmodule.obj" - -".\x86-temp-release\pythoncore_pgo\_heapqmodule.obj" - -".\x86-temp-release\pythoncore_pgo\_hotshot.obj" - -".\x86-temp-release\pythoncore_pgo\_localemodule.obj" - -".\x86-temp-release\pythoncore_pgo\_lsprof.obj" - -".\x86-temp-release\pythoncore_pgo\_randommodule.obj" - -".\x86-temp-release\pythoncore_pgo\_sre.obj" - -".\x86-temp-release\pythoncore_pgo\_struct.obj" - -".\x86-temp-release\pythoncore_pgo\_subprocess.obj" - -".\x86-temp-release\pythoncore_pgo\_weakref.obj" - -".\x86-temp-release\pythoncore_pgo\_winreg.obj" - -".\x86-temp-release\pythoncore_pgo\abstract.obj" - -".\x86-temp-release\pythoncore_pgo\acceler.obj" - -".\x86-temp-release\pythoncore_pgo\arraymodule.obj" - -".\x86-temp-release\pythoncore_pgo\asdl.obj" - -".\x86-temp-release\pythoncore_pgo\ast.obj" - -".\x86-temp-release\pythoncore_pgo\audioop.obj" - -".\x86-temp-release\pythoncore_pgo\binascii.obj" - -".\x86-temp-release\pythoncore_pgo\bitset.obj" - -".\x86-temp-release\pythoncore_pgo\bltinmodule.obj" - -".\x86-temp-release\pythoncore_pgo\boolobject.obj" - -".\x86-temp-release\pythoncore_pgo\bufferobject.obj" - -".\x86-temp-release\pythoncore_pgo\cellobject.obj" - -".\x86-temp-release\pythoncore_pgo\ceval.obj" - -".\x86-temp-release\pythoncore_pgo\classobject.obj" - -".\x86-temp-release\pythoncore_pgo\cmathmodule.obj" - -".\x86-temp-release\pythoncore_pgo\cobject.obj" - -".\x86-temp-release\pythoncore_pgo\codecs.obj" - -".\x86-temp-release\pythoncore_pgo\codeobject.obj" - -".\x86-temp-release\pythoncore_pgo\collectionsmodule.obj" - -".\x86-temp-release\pythoncore_pgo\compile.obj" - -".\x86-temp-release\pythoncore_pgo\complexobject.obj" - -".\x86-temp-release\pythoncore_pgo\config.obj" - -".\x86-temp-release\pythoncore_pgo\cPickle.obj" - -".\x86-temp-release\pythoncore_pgo\cStringIO.obj" - -".\x86-temp-release\pythoncore_pgo\datetimemodule.obj" - -".\x86-temp-release\pythoncore_pgo\descrobject.obj" - -".\x86-temp-release\pythoncore_pgo\dictobject.obj" - -".\x86-temp-release\pythoncore_pgo\dl_nt.obj" - -".\x86-temp-release\pythoncore_pgo\dynload_win.obj" - -".\x86-temp-release\pythoncore_pgo\enumobject.obj" - -".\x86-temp-release\pythoncore_pgo\errnomodule.obj" - -".\x86-temp-release\pythoncore_pgo\errors.obj" - -".\x86-temp-release\pythoncore_pgo\exceptions.obj" - -".\x86-temp-release\pythoncore_pgo\fileobject.obj" - -".\x86-temp-release\pythoncore_pgo\firstsets.obj" - -".\x86-temp-release\pythoncore_pgo\floatobject.obj" - -".\x86-temp-release\pythoncore_pgo\frameobject.obj" - -".\x86-temp-release\pythoncore_pgo\frozen.obj" - -".\x86-temp-release\pythoncore_pgo\funcobject.obj" - -".\x86-temp-release\pythoncore_pgo\future.obj" - -".\x86-temp-release\pythoncore_pgo\gcmodule.obj" - -".\x86-temp-release\pythoncore_pgo\genobject.obj" - -".\x86-temp-release\pythoncore_pgo\getargs.obj" - -".\x86-temp-release\pythoncore_pgo\getcompiler.obj" - -".\x86-temp-release\pythoncore_pgo\getcopyright.obj" - -".\x86-temp-release\pythoncore_pgo\getmtime.obj" - -".\x86-temp-release\pythoncore_pgo\getopt.obj" - -".\x86-temp-release\pythoncore_pgo\getpathp.obj" - -".\x86-temp-release\pythoncore_pgo\getplatform.obj" - -".\x86-temp-release\pythoncore_pgo\getversion.obj" - -".\x86-temp-release\pythoncore_pgo\graminit.obj" - -".\x86-temp-release\pythoncore_pgo\grammar.obj" - -".\x86-temp-release\pythoncore_pgo\grammar1.obj" - -".\x86-temp-release\pythoncore_pgo\imageop.obj" - -".\x86-temp-release\pythoncore_pgo\import.obj" - -".\x86-temp-release\pythoncore_pgo\import_nt.obj" - -".\x86-temp-release\pythoncore_pgo\importdl.obj" - -".\x86-temp-release\pythoncore_pgo\intobject.obj" - -".\x86-temp-release\pythoncore_pgo\iterobject.obj" - -".\x86-temp-release\pythoncore_pgo\itertoolsmodule.obj" - -".\x86-temp-release\pythoncore_pgo\listnode.obj" - -".\x86-temp-release\pythoncore_pgo\listobject.obj" - -".\x86-temp-release\pythoncore_pgo\longobject.obj" - -".\x86-temp-release\pythoncore_pgo\main.obj" - -".\x86-temp-release\pythoncore_pgo\marshal.obj" - -".\x86-temp-release\pythoncore_pgo\mathmodule.obj" - -".\x86-temp-release\pythoncore_pgo\md5.obj" - -".\x86-temp-release\pythoncore_pgo\md5module.obj" - -".\x86-temp-release\pythoncore_pgo\metagrammar.obj" - -".\x86-temp-release\pythoncore_pgo\methodobject.obj" - -".\x86-temp-release\pythoncore_pgo\mmapmodule.obj" - -".\x86-temp-release\pythoncore_pgo\modsupport.obj" - -".\x86-temp-release\pythoncore_pgo\moduleobject.obj" - -".\x86-temp-release\pythoncore_pgo\msvcrtmodule.obj" - -".\x86-temp-release\pythoncore_pgo\multibytecodec.obj" - -".\x86-temp-release\pythoncore_pgo\myreadline.obj" - -".\x86-temp-release\pythoncore_pgo\mysnprintf.obj" - -".\x86-temp-release\pythoncore_pgo\mystrtoul.obj" - -".\x86-temp-release\pythoncore_pgo\node.obj" - -".\x86-temp-release\pythoncore_pgo\object.obj" - -".\x86-temp-release\pythoncore_pgo\obmalloc.obj" - -".\x86-temp-release\pythoncore_pgo\operator.obj" - -".\x86-temp-release\pythoncore_pgo\parser.obj" - -".\x86-temp-release\pythoncore_pgo\parsermodule.obj" - -".\x86-temp-release\pythoncore_pgo\parsetok.obj" - -".\x86-temp-release\pythoncore_pgo\posixmodule.obj" - -".\x86-temp-release\pythoncore_pgo\pyarena.obj" - -".\x86-temp-release\pythoncore_pgo\pyfpe.obj" - -".\x86-temp-release\pythoncore_pgo\pystate.obj" - -".\x86-temp-release\pythoncore_pgo\pystrtod.obj" - -".\x86-temp-release\pythoncore_pgo\Python-ast.obj" - -".\x86-temp-release\pythoncore_pgo\python_nt.res" - -".\x86-temp-release\pythoncore_pgo\pythonrun.obj" - -".\x86-temp-release\pythoncore_pgo\rangeobject.obj" - -".\x86-temp-release\pythoncore_pgo\rgbimgmodule.obj" - -".\x86-temp-release\pythoncore_pgo\rotatingtree.obj" - -".\x86-temp-release\pythoncore_pgo\setobject.obj" - -".\x86-temp-release\pythoncore_pgo\sha256module.obj" - -".\x86-temp-release\pythoncore_pgo\sha512module.obj" - -".\x86-temp-release\pythoncore_pgo\shamodule.obj" - -".\x86-temp-release\pythoncore_pgo\signalmodule.obj" - -".\x86-temp-release\pythoncore_pgo\sliceobject.obj" - -".\x86-temp-release\pythoncore_pgo\stringobject.obj" - -".\x86-temp-release\pythoncore_pgo\stropmodule.obj" - -".\x86-temp-release\pythoncore_pgo\structmember.obj" - -".\x86-temp-release\pythoncore_pgo\structseq.obj" - -".\x86-temp-release\pythoncore_pgo\symtable.obj" - -".\x86-temp-release\pythoncore_pgo\symtablemodule.obj" - -".\x86-temp-release\pythoncore_pgo\sysmodule.obj" - -".\x86-temp-release\pythoncore_pgo\thread.obj" - -".\x86-temp-release\pythoncore_pgo\threadmodule.obj" - -".\x86-temp-release\pythoncore_pgo\timemodule.obj" - -".\x86-temp-release\pythoncore_pgo\tokenizer.obj" - -".\x86-temp-release\pythoncore_pgo\traceback.obj" - -".\x86-temp-release\pythoncore_pgo\tupleobject.obj" - -".\x86-temp-release\pythoncore_pgo\typeobject.obj" - -".\x86-temp-release\pythoncore_pgo\unicodectype.obj" - -".\x86-temp-release\pythoncore_pgo\unicodeobject.obj" - -".\x86-temp-release\pythoncore_pgo\weakrefobject.obj" - -".\x86-temp-release\pythoncore_pgo\xxsubtype.obj" - -".\x86-temp-release\pythoncore_pgo\yuvconvert.obj" - -".\x86-temp-release\pythoncore_pgo\zipimport.obj" Modified: python/branches/p3yk-noslice/PCbuild8/pythonw.vcproj ============================================================================== --- python/branches/p3yk-noslice/PCbuild8/pythonw.vcproj (original) +++ python/branches/p3yk-noslice/PCbuild8/pythonw.vcproj Fri Dec 15 05:21:50 2006 @@ -4,19 +4,23 @@ Version="8,00" Name="pythonw" ProjectGUID="{F4229CC3-873C-49AE-9729-DD308ED4CD4A}" + RootNamespace="pythonw" > + @@ -240,16 +240,16 @@ /> @@ -332,16 +329,16 @@ /> + @@ -238,18 +241,18 @@ /> @@ -330,18 +327,18 @@ /> + @@ -234,14 +237,15 @@ /> @@ -323,14 +322,15 @@ /> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Modified: python/branches/p3yk-noslice/PCbuild8/winsound.vcproj ============================================================================== --- python/branches/p3yk-noslice/PCbuild8/winsound.vcproj (original) +++ python/branches/p3yk-noslice/PCbuild8/winsound.vcproj Fri Dec 15 05:21:50 2006 @@ -4,19 +4,23 @@ Version="8,00" Name="winsound" ProjectGUID="{51F35FAE-FB92-4B2C-9187-1542C065AD77}" + RootNamespace="winsound" > + p_stack.s_top->s_parent; - node *ch; + node *ch, *cch; int i; /* from __future__ import ..., must have at least 4 children */ @@ -197,15 +197,17 @@ if (NCH(ch) == 1 && STR(CHILD(ch, 0)) && strcmp(STR(CHILD(ch, 0)), "__future__") != 0) return; - for (i = 3; i < NCH(n); i += 2) { - /* XXX: assume we don't have parentheses in import: - from __future__ import (x, y, z) - */ - ch = CHILD(n, i); - if (NCH(ch) == 1) - ch = CHILD(ch, 0); - if (NCH(ch) >= 1 && TYPE(CHILD(ch, 0)) == NAME && - strcmp(STR(CHILD(ch, 0)), "with_statement") == 0) { + ch = CHILD(n, 3); + /* ch can be a star, a parenthesis or import_as_names */ + if (TYPE(ch) == STAR) + return; + if (TYPE(ch) == LPAR) + ch = CHILD(n, 4); + + for (i = 0; i < NCH(ch); i += 2) { + cch = CHILD(ch, i); + if (NCH(cch) >= 1 && TYPE(CHILD(cch, 0)) == NAME && + strcmp(STR(CHILD(cch, 0)), "with_statement") == 0) { ps->p_flags |= CO_FUTURE_WITH_STATEMENT; break; } Modified: python/branches/p3yk-noslice/Parser/parsetok.c ============================================================================== --- python/branches/p3yk-noslice/Parser/parsetok.c (original) +++ python/branches/p3yk-noslice/Parser/parsetok.c Fri Dec 15 05:21:50 2006 @@ -82,9 +82,6 @@ return parsetok(tok, g, start, err_ret, flags); } -/* Parse input coming from the given tokenizer structure. - Return error code. */ - #ifdef PY_PARSER_REQUIRES_FUTURE_KEYWORD static char with_msg[] = "%s:%d: Warning: 'with' will become a reserved keyword in Python 2.6\n"; @@ -101,6 +98,9 @@ } #endif +/* Parse input coming from the given tokenizer structure. + Return error code. */ + static node * parsetok(struct tok_state *tok, grammar *g, int start, perrdetail *err_ret, int flags) Modified: python/branches/p3yk-noslice/Parser/tokenizer.c ============================================================================== --- python/branches/p3yk-noslice/Parser/tokenizer.c (original) +++ python/branches/p3yk-noslice/Parser/tokenizer.c Fri Dec 15 05:21:50 2006 @@ -67,7 +67,6 @@ "EQUAL", "DOT", "PERCENT", - "BACKQUOTE", "LBRACE", "RBRACE", "EQEQUAL", @@ -897,7 +896,7 @@ tok->cur = tok->buf + cur; tok->line_start = tok->cur; /* replace "\r\n" with "\n" */ - /* For Mac leave the \r, giving syntax error */ + /* For Mac leave the \r, giving a syntax error */ pt = tok->inp - 2; if (pt >= tok->buf && *pt == '\r') { *pt++ = '\n'; @@ -955,7 +954,6 @@ case '=': return EQUAL; case '.': return DOT; case '%': return PERCENT; - case '`': return BACKQUOTE; case '{': return LBRACE; case '}': return RBRACE; case '^': return CIRCUMFLEX; @@ -982,7 +980,6 @@ break; case '<': switch (c2) { - case '>': return NOTEQUAL; case '=': return LESSEQUAL; case '<': return LEFTSHIFT; } Modified: python/branches/p3yk-noslice/Python/Python-ast.c ============================================================================== --- python/branches/p3yk-noslice/Python/Python-ast.c (original) +++ python/branches/p3yk-noslice/Python/Python-ast.c Fri Dec 15 05:21:50 2006 @@ -123,12 +123,6 @@ "names", "level", }; -static PyTypeObject *Exec_type; -static char *Exec_fields[]={ - "body", - "globals", - "locals", -}; static PyTypeObject *Global_type; static char *Global_fields[]={ "names", @@ -178,6 +172,10 @@ "keys", "values", }; +static PyTypeObject *Set_type; +static char *Set_fields[]={ + "elts", +}; static PyTypeObject *ListComp_type; static char *ListComp_fields[]={ "elt", @@ -206,10 +204,6 @@ "starargs", "kwargs", }; -static PyTypeObject *Repr_type; -static char *Repr_fields[]={ - "value", -}; static PyTypeObject *Num_type; static char *Num_fields[]={ "n", @@ -218,6 +212,7 @@ static char *Str_fields[]={ "s", }; +static PyTypeObject *Ellipsis_type; static PyTypeObject *Attribute_type; static char *Attribute_fields[]={ "value", @@ -257,7 +252,6 @@ static PyTypeObject *Param_type; static PyTypeObject *slice_type; static PyObject* ast2obj_slice(void*); -static PyTypeObject *Ellipsis_type; static PyTypeObject *Slice_type; static char *Slice_fields[]={ "lower", @@ -339,8 +333,10 @@ static char *arguments_fields[]={ "args", "vararg", + "kwonlyargs", "kwarg", "defaults", + "kw_defaults", }; static PyTypeObject *keyword_type; static PyObject* ast2obj_keyword(void*); @@ -494,8 +490,6 @@ ImportFrom_type = make_type("ImportFrom", stmt_type, ImportFrom_fields, 3); if (!ImportFrom_type) return 0; - Exec_type = make_type("Exec", stmt_type, Exec_fields, 3); - if (!Exec_type) return 0; Global_type = make_type("Global", stmt_type, Global_fields, 1); if (!Global_type) return 0; Expr_type = make_type("Expr", stmt_type, Expr_fields, 1); @@ -521,6 +515,8 @@ if (!IfExp_type) return 0; Dict_type = make_type("Dict", expr_type, Dict_fields, 2); if (!Dict_type) return 0; + Set_type = make_type("Set", expr_type, Set_fields, 1); + if (!Set_type) return 0; ListComp_type = make_type("ListComp", expr_type, ListComp_fields, 2); if (!ListComp_type) return 0; GeneratorExp_type = make_type("GeneratorExp", expr_type, @@ -532,12 +528,12 @@ if (!Compare_type) return 0; Call_type = make_type("Call", expr_type, Call_fields, 5); if (!Call_type) return 0; - Repr_type = make_type("Repr", expr_type, Repr_fields, 1); - if (!Repr_type) return 0; Num_type = make_type("Num", expr_type, Num_fields, 1); if (!Num_type) return 0; Str_type = make_type("Str", expr_type, Str_fields, 1); if (!Str_type) return 0; + Ellipsis_type = make_type("Ellipsis", expr_type, NULL, 0); + if (!Ellipsis_type) return 0; Attribute_type = make_type("Attribute", expr_type, Attribute_fields, 3); if (!Attribute_type) return 0; Subscript_type = make_type("Subscript", expr_type, Subscript_fields, 3); @@ -578,8 +574,6 @@ slice_type = make_type("slice", AST_type, NULL, 0); if (!slice_type) return 0; if (!add_attributes(slice_type, NULL, 0)) return 0; - Ellipsis_type = make_type("Ellipsis", slice_type, NULL, 0); - if (!Ellipsis_type) return 0; Slice_type = make_type("Slice", slice_type, Slice_fields, 3); if (!Slice_type) return 0; ExtSlice_type = make_type("ExtSlice", slice_type, ExtSlice_fields, 1); @@ -716,7 +710,7 @@ excepthandler_type = make_type("excepthandler", AST_type, excepthandler_fields, 5); if (!excepthandler_type) return 0; - arguments_type = make_type("arguments", AST_type, arguments_fields, 4); + arguments_type = make_type("arguments", AST_type, arguments_fields, 6); if (!arguments_type) return 0; keyword_type = make_type("keyword", AST_type, keyword_fields, 2); if (!keyword_type) return 0; @@ -1170,30 +1164,6 @@ } stmt_ty -Exec(expr_ty body, expr_ty globals, expr_ty locals, int lineno, int col_offset, - PyArena *arena) -{ - stmt_ty p; - if (!body) { - PyErr_SetString(PyExc_ValueError, - "field body is required for Exec"); - return NULL; - } - p = (stmt_ty)PyArena_Malloc(arena, sizeof(*p)); - if (!p) { - PyErr_NoMemory(); - return NULL; - } - p->kind = Exec_kind; - p->v.Exec.body = body; - p->v.Exec.globals = globals; - p->v.Exec.locals = locals; - p->lineno = lineno; - p->col_offset = col_offset; - return p; -} - -stmt_ty Global(asdl_seq * names, int lineno, int col_offset, PyArena *arena) { stmt_ty p; @@ -1441,6 +1411,22 @@ } expr_ty +Set(asdl_seq * elts, int lineno, int col_offset, PyArena *arena) +{ + expr_ty p; + p = (expr_ty)PyArena_Malloc(arena, sizeof(*p)); + if (!p) { + PyErr_NoMemory(); + return NULL; + } + p->kind = Set_kind; + p->v.Set.elts = elts; + p->lineno = lineno; + p->col_offset = col_offset; + return p; +} + +expr_ty ListComp(expr_ty elt, asdl_seq * generators, int lineno, int col_offset, PyArena *arena) { @@ -1553,12 +1539,12 @@ } expr_ty -Repr(expr_ty value, int lineno, int col_offset, PyArena *arena) +Num(object n, int lineno, int col_offset, PyArena *arena) { expr_ty p; - if (!value) { + if (!n) { PyErr_SetString(PyExc_ValueError, - "field value is required for Repr"); + "field n is required for Num"); return NULL; } p = (expr_ty)PyArena_Malloc(arena, sizeof(*p)); @@ -1566,20 +1552,20 @@ PyErr_NoMemory(); return NULL; } - p->kind = Repr_kind; - p->v.Repr.value = value; + p->kind = Num_kind; + p->v.Num.n = n; p->lineno = lineno; p->col_offset = col_offset; return p; } expr_ty -Num(object n, int lineno, int col_offset, PyArena *arena) +Str(string s, int lineno, int col_offset, PyArena *arena) { expr_ty p; - if (!n) { + if (!s) { PyErr_SetString(PyExc_ValueError, - "field n is required for Num"); + "field s is required for Str"); return NULL; } p = (expr_ty)PyArena_Malloc(arena, sizeof(*p)); @@ -1587,29 +1573,23 @@ PyErr_NoMemory(); return NULL; } - p->kind = Num_kind; - p->v.Num.n = n; + p->kind = Str_kind; + p->v.Str.s = s; p->lineno = lineno; p->col_offset = col_offset; return p; } expr_ty -Str(string s, int lineno, int col_offset, PyArena *arena) +Ellipsis(int lineno, int col_offset, PyArena *arena) { expr_ty p; - if (!s) { - PyErr_SetString(PyExc_ValueError, - "field s is required for Str"); - return NULL; - } p = (expr_ty)PyArena_Malloc(arena, sizeof(*p)); if (!p) { PyErr_NoMemory(); return NULL; } - p->kind = Str_kind; - p->v.Str.s = s; + p->kind = Ellipsis_kind; p->lineno = lineno; p->col_offset = col_offset; return p; @@ -1758,19 +1738,6 @@ } slice_ty -Ellipsis(PyArena *arena) -{ - slice_ty p; - p = (slice_ty)PyArena_Malloc(arena, sizeof(*p)); - if (!p) { - PyErr_NoMemory(); - return NULL; - } - p->kind = Ellipsis_kind; - return p; -} - -slice_ty Slice(expr_ty lower, expr_ty upper, expr_ty step, PyArena *arena) { slice_ty p; @@ -1863,8 +1830,8 @@ } arguments_ty -arguments(asdl_seq * args, identifier vararg, identifier kwarg, asdl_seq * - defaults, PyArena *arena) +arguments(asdl_seq * args, identifier vararg, asdl_seq * kwonlyargs, identifier + kwarg, asdl_seq * defaults, asdl_seq * kw_defaults, PyArena *arena) { arguments_ty p; p = (arguments_ty)PyArena_Malloc(arena, sizeof(*p)); @@ -1874,8 +1841,10 @@ } p->args = args; p->vararg = vararg; + p->kwonlyargs = kwonlyargs; p->kwarg = kwarg; p->defaults = defaults; + p->kw_defaults = kw_defaults; return p; } @@ -2279,25 +2248,6 @@ goto failed; Py_DECREF(value); break; - case Exec_kind: - result = PyType_GenericNew(Exec_type, NULL, NULL); - if (!result) goto failed; - value = ast2obj_expr(o->v.Exec.body); - if (!value) goto failed; - if (PyObject_SetAttrString(result, "body", value) == -1) - goto failed; - Py_DECREF(value); - value = ast2obj_expr(o->v.Exec.globals); - if (!value) goto failed; - if (PyObject_SetAttrString(result, "globals", value) == -1) - goto failed; - Py_DECREF(value); - value = ast2obj_expr(o->v.Exec.locals); - if (!value) goto failed; - if (PyObject_SetAttrString(result, "locals", value) == -1) - goto failed; - Py_DECREF(value); - break; case Global_kind: result = PyType_GenericNew(Global_type, NULL, NULL); if (!result) goto failed; @@ -2451,6 +2401,15 @@ goto failed; Py_DECREF(value); break; + case Set_kind: + result = PyType_GenericNew(Set_type, NULL, NULL); + if (!result) goto failed; + value = ast2obj_list(o->v.Set.elts, ast2obj_expr); + if (!value) goto failed; + if (PyObject_SetAttrString(result, "elts", value) == -1) + goto failed; + Py_DECREF(value); + break; case ListComp_kind: result = PyType_GenericNew(ListComp_type, NULL, NULL); if (!result) goto failed; @@ -2544,15 +2503,6 @@ goto failed; Py_DECREF(value); break; - case Repr_kind: - result = PyType_GenericNew(Repr_type, NULL, NULL); - if (!result) goto failed; - value = ast2obj_expr(o->v.Repr.value); - if (!value) goto failed; - if (PyObject_SetAttrString(result, "value", value) == -1) - goto failed; - Py_DECREF(value); - break; case Num_kind: result = PyType_GenericNew(Num_type, NULL, NULL); if (!result) goto failed; @@ -2571,6 +2521,10 @@ goto failed; Py_DECREF(value); break; + case Ellipsis_kind: + result = PyType_GenericNew(Ellipsis_type, NULL, NULL); + if (!result) goto failed; + break; case Attribute_kind: result = PyType_GenericNew(Attribute_type, NULL, NULL); if (!result) goto failed; @@ -2704,10 +2658,6 @@ } switch (o->kind) { - case Ellipsis_kind: - result = PyType_GenericNew(Ellipsis_type, NULL, NULL); - if (!result) goto failed; - break; case Slice_kind: result = PyType_GenericNew(Slice_type, NULL, NULL); if (!result) goto failed; @@ -2961,6 +2911,11 @@ if (PyObject_SetAttrString(result, "vararg", value) == -1) goto failed; Py_DECREF(value); + value = ast2obj_list(o->kwonlyargs, ast2obj_expr); + if (!value) goto failed; + if (PyObject_SetAttrString(result, "kwonlyargs", value) == -1) + goto failed; + Py_DECREF(value); value = ast2obj_identifier(o->kwarg); if (!value) goto failed; if (PyObject_SetAttrString(result, "kwarg", value) == -1) @@ -2971,6 +2926,11 @@ if (PyObject_SetAttrString(result, "defaults", value) == -1) goto failed; Py_DECREF(value); + value = ast2obj_list(o->kw_defaults, ast2obj_expr); + if (!value) goto failed; + if (PyObject_SetAttrString(result, "kw_defaults", value) == -1) + goto failed; + Py_DECREF(value); return result; failed: Py_XDECREF(value); @@ -3087,7 +3047,6 @@ return; if (PyDict_SetItemString(d, "ImportFrom", (PyObject*)ImportFrom_type) < 0) return; - if (PyDict_SetItemString(d, "Exec", (PyObject*)Exec_type) < 0) return; if (PyDict_SetItemString(d, "Global", (PyObject*)Global_type) < 0) return; if (PyDict_SetItemString(d, "Expr", (PyObject*)Expr_type) < 0) return; @@ -3105,6 +3064,7 @@ return; if (PyDict_SetItemString(d, "IfExp", (PyObject*)IfExp_type) < 0) return; if (PyDict_SetItemString(d, "Dict", (PyObject*)Dict_type) < 0) return; + if (PyDict_SetItemString(d, "Set", (PyObject*)Set_type) < 0) return; if (PyDict_SetItemString(d, "ListComp", (PyObject*)ListComp_type) < 0) return; if (PyDict_SetItemString(d, "GeneratorExp", @@ -3113,9 +3073,10 @@ if (PyDict_SetItemString(d, "Compare", (PyObject*)Compare_type) < 0) return; if (PyDict_SetItemString(d, "Call", (PyObject*)Call_type) < 0) return; - if (PyDict_SetItemString(d, "Repr", (PyObject*)Repr_type) < 0) return; if (PyDict_SetItemString(d, "Num", (PyObject*)Num_type) < 0) return; if (PyDict_SetItemString(d, "Str", (PyObject*)Str_type) < 0) return; + if (PyDict_SetItemString(d, "Ellipsis", (PyObject*)Ellipsis_type) < 0) + return; if (PyDict_SetItemString(d, "Attribute", (PyObject*)Attribute_type) < 0) return; if (PyDict_SetItemString(d, "Subscript", (PyObject*)Subscript_type) < @@ -3134,8 +3095,6 @@ return; if (PyDict_SetItemString(d, "Param", (PyObject*)Param_type) < 0) return; if (PyDict_SetItemString(d, "slice", (PyObject*)slice_type) < 0) return; - if (PyDict_SetItemString(d, "Ellipsis", (PyObject*)Ellipsis_type) < 0) - return; if (PyDict_SetItemString(d, "Slice", (PyObject*)Slice_type) < 0) return; if (PyDict_SetItemString(d, "ExtSlice", (PyObject*)ExtSlice_type) < 0) return; Modified: python/branches/p3yk-noslice/Python/ast.c ============================================================================== --- python/branches/p3yk-noslice/Python/ast.c (original) +++ python/branches/p3yk-noslice/Python/ast.c Fri Dec 15 05:21:50 2006 @@ -15,12 +15,6 @@ #include -/* XXX TO DO - - re-indent this file (should be done) - - internal error checking (freeing memory, etc.) - - syntax errors -*/ - /* Data structure used internally */ struct compiling { char *c_encoding; /* source encoding */ @@ -43,7 +37,7 @@ static PyObject *parsestrplus(struct compiling *, const node *n); #ifndef LINENO -#define LINENO(n) ((n)->n_lineno) +#define LINENO(n) ((n)->n_lineno) #endif static identifier @@ -68,7 +62,7 @@ { PyObject *u = Py_BuildValue("zi", errstr, LINENO(n)); if (!u) - return 0; + return 0; PyErr_SetObject(PyExc_SyntaxError, u); Py_DECREF(u); return 0; @@ -82,36 +76,36 @@ assert(PyErr_Occurred()); if (!PyErr_ExceptionMatches(PyExc_SyntaxError)) - return; + return; PyErr_Fetch(&type, &value, &tback); errstr = PyTuple_GetItem(value, 0); if (!errstr) - return; + return; Py_INCREF(errstr); lineno = PyInt_AsLong(PyTuple_GetItem(value, 1)); if (lineno == -1) { - Py_DECREF(errstr); - return; + Py_DECREF(errstr); + return; } Py_DECREF(value); loc = PyErr_ProgramText(filename, lineno); if (!loc) { - Py_INCREF(Py_None); - loc = Py_None; + Py_INCREF(Py_None); + loc = Py_None; } tmp = Py_BuildValue("(zlOO)", filename, lineno, Py_None, loc); Py_DECREF(loc); if (!tmp) { - Py_DECREF(errstr); - return; + Py_DECREF(errstr); + return; } value = PyTuple_Pack(2, errstr, tmp); Py_DECREF(errstr); Py_DECREF(tmp); if (!value) - return; + return; PyErr_Restore(type, value, tback); } @@ -246,7 +240,7 @@ if (TYPE(CHILD(n, 0)) == NEWLINE) { stmts = asdl_seq_new(1, arena); if (!stmts) - goto error; + goto error; asdl_seq_SET(stmts, 0, Pass(n->n_lineno, n->n_col_offset, arena)); return Interactive(stmts, arena); @@ -256,11 +250,11 @@ num = num_stmts(n); stmts = asdl_seq_new(num, arena); if (!stmts) - goto error; + goto error; if (num == 1) { - s = ast_for_stmt(&c, n); - if (!s) - goto error; + s = ast_for_stmt(&c, n); + if (!s) + goto error; asdl_seq_SET(stmts, 0, s); } else { @@ -347,38 +341,38 @@ switch (e->kind) { case Attribute_kind: - if (ctx == Store && - !strcmp(PyString_AS_STRING(e->v.Attribute.attr), "None")) { - return ast_error(n, "assignment to None"); - } - e->v.Attribute.ctx = ctx; - break; + if (ctx == Store && + !strcmp(PyString_AS_STRING(e->v.Attribute.attr), "None")) { + return ast_error(n, "assignment to None"); + } + e->v.Attribute.ctx = ctx; + break; case Subscript_kind: - e->v.Subscript.ctx = ctx; - break; + e->v.Subscript.ctx = ctx; + break; case Name_kind: - if (ctx == Store && - !strcmp(PyString_AS_STRING(e->v.Name.id), "None")) { - return ast_error(n, "assignment to None"); - } - e->v.Name.ctx = ctx; - break; + if (ctx == Store && + !strcmp(PyString_AS_STRING(e->v.Name.id), "None")) { + return ast_error(n, "assignment to None"); + } + e->v.Name.ctx = ctx; + break; case List_kind: - e->v.List.ctx = ctx; - s = e->v.List.elts; - break; + e->v.List.ctx = ctx; + s = e->v.List.elts; + break; case Tuple_kind: if (asdl_seq_LEN(e->v.Tuple.elts) == 0) return ast_error(n, "can't assign to ()"); - e->v.Tuple.ctx = ctx; - s = e->v.Tuple.elts; - break; + e->v.Tuple.ctx = ctx; + s = e->v.Tuple.elts; + break; case Lambda_kind: expr_name = "lambda"; break; case Call_kind: expr_name = "function call"; - break; + break; case BoolOp_kind: case BinOp_kind: case UnaryOp_kind: @@ -394,16 +388,17 @@ expr_name = "list comprehension"; break; case Dict_kind: + case Set_kind: case Num_kind: case Str_kind: expr_name = "literal"; break; + case Ellipsis_kind: + expr_name = "Ellipsis"; + break; case Compare_kind: expr_name = "comparison"; break; - case Repr_kind: - expr_name = "repr"; - break; case IfExp_kind: expr_name = "conditional expression"; break; @@ -427,12 +422,12 @@ context for all the contained elements. */ if (s) { - int i; + int i; - for (i = 0; i < asdl_seq_LEN(s); i++) { - if (!set_context((expr_ty)asdl_seq_GET(s, i), ctx, n)) - return 0; - } + for (i = 0; i < asdl_seq_LEN(s); i++) { + if (!set_context((expr_ty)asdl_seq_GET(s, i), ctx, n)) + return 0; + } } return 1; } @@ -478,18 +473,18 @@ static cmpop_ty ast_for_comp_op(const node *n) { - /* comp_op: '<'|'>'|'=='|'>='|'<='|'<>'|'!='|'in'|'not' 'in'|'is' + /* comp_op: '<'|'>'|'=='|'>='|'<='|'!='|'in'|'not' 'in'|'is' |'is' 'not' */ REQ(n, comp_op); if (NCH(n) == 1) { - n = CHILD(n, 0); - switch (TYPE(n)) { + n = CHILD(n, 0); + switch (TYPE(n)) { case LESS: return Lt; case GREATER: return Gt; - case EQEQUAL: /* == */ + case EQEQUAL: /* == */ return Eq; case LESSEQUAL: return LtE; @@ -506,11 +501,11 @@ PyErr_Format(PyExc_SystemError, "invalid comp_op: %s", STR(n)); return (cmpop_ty)0; - } + } } else if (NCH(n) == 2) { - /* handle "not in" and "is not" */ - switch (TYPE(CHILD(n, 0))) { + /* handle "not in" and "is not" */ + switch (TYPE(CHILD(n, 0))) { case NAME: if (strcmp(STR(CHILD(n, 1)), "in") == 0) return NotIn; @@ -520,7 +515,7 @@ PyErr_Format(PyExc_SystemError, "invalid comp_op: %s %s", STR(CHILD(n, 0)), STR(CHILD(n, 1))); return (cmpop_ty)0; - } + } } PyErr_Format(PyExc_SystemError, "invalid comp_op: has %d children", NCH(n)); @@ -535,10 +530,11 @@ expr_ty expression; int i; assert(TYPE(n) == testlist - || TYPE(n) == listmaker - || TYPE(n) == testlist_gexp - || TYPE(n) == testlist_safe - ); + || TYPE(n) == listmaker + || TYPE(n) == testlist_gexp + || TYPE(n) == testlist_safe + || TYPE(n) == testlist1 + ); seq = asdl_seq_new((NCH(n) + 1) / 2, c->c_arena); if (!seq) @@ -566,20 +562,37 @@ if (!args) return NULL; + /* fpdef: NAME | '(' fplist ')' + fplist: fpdef (',' fpdef)* [','] + */ REQ(n, fplist); for (i = 0; i < len; i++) { - const node *child = CHILD(CHILD(n, 2*i), 0); + const node *fpdef_node = CHILD(n, 2*i); + const node *child; expr_ty arg; +set_name: + /* fpdef_node is either a NAME or an fplist */ + child = CHILD(fpdef_node, 0); if (TYPE(child) == NAME) { - if (!strcmp(STR(child), "None")) { - ast_error(child, "assignment to None"); - return NULL; - } + if (!strcmp(STR(child), "None")) { + ast_error(child, "assignment to None"); + return NULL; + } arg = Name(NEW_IDENTIFIER(child), Store, LINENO(child), child->n_col_offset, c->c_arena); - } + } else { - arg = compiler_complex_args(c, CHILD(CHILD(n, 2*i), 1)); + assert(TYPE(fpdef_node) == fpdef); + /* fpdef_node[0] is not a name, so it must be a '(', get CHILD[1] */ + child = CHILD(fpdef_node, 1); + assert(TYPE(child) == fplist); + /* NCH == 1 means we have (x), we need to elide the extra parens */ + if (NCH(child) == 1) { + fpdef_node = CHILD(child, 0); + assert(TYPE(fpdef_node) == fpdef); + goto set_name; + } + arg = compiler_complex_args(c, child); } asdl_seq_SET(args, i, arg); } @@ -590,6 +603,63 @@ return result; } +/* returns -1 if failed to handle keyword only arguments + returns new position to keep processing if successful + (',' NAME ['=' test])* + ^^^ + start pointing here + */ +static int +handle_keywordonly_args(struct compiling *c, const node *n, int start, + asdl_seq *kwonlyargs, asdl_seq *kwdefaults) +{ + node *ch; + expr_ty name; + int i = start; + int j = 0; /* index for kwdefaults and kwonlyargs */ + assert(kwonlyargs != NULL); + assert(kwdefaults != NULL); + while (i < NCH(n)) { + ch = CHILD(n, i); + switch (TYPE(ch)) { + case NAME: + if (i + 1 < NCH(n) && TYPE(CHILD(n, i + 1)) == EQUAL) { + expr_ty expression = ast_for_expr(c, CHILD(n, i + 2)); + if (!expression) { + ast_error(ch, "assignment to None"); + goto error; + } + asdl_seq_SET(kwdefaults, j, expression); + i += 2; /* '=' and test */ + } + else { /* setting NULL if no default value exists */ + asdl_seq_SET(kwdefaults, j, NULL); + } + if (!strcmp(STR(ch), "None")) { + ast_error(ch, "assignment to None"); + goto error; + } + name = Name(NEW_IDENTIFIER(ch), + Param, LINENO(ch), ch->n_col_offset, + c->c_arena); + if (!name) { + ast_error(ch, "expecting name"); + goto error; + } + asdl_seq_SET(kwonlyargs, j++, name); + i += 2; /* the name and the comma */ + break; + case DOUBLESTAR: + return i; + default: + ast_error(ch, "unexpected node"); + goto error; + } + } + return i; + error: + return -1; +} /* Create AST for argument list. */ @@ -597,35 +667,71 @@ ast_for_arguments(struct compiling *c, const node *n) { /* parameters: '(' [varargslist] ')' - varargslist: (fpdef ['=' test] ',')* ('*' NAME [',' '**' NAME] - | '**' NAME) | fpdef ['=' test] (',' fpdef ['=' test])* [','] + varargslist: (fpdef ['=' test] ',')* + ('*' [NAME] (',' fpdef ['=' test])* [',' '**' NAME] | '**' NAME) + | fpdef ['=' test] (',' fpdef ['=' test])* [','] */ - int i, j, k, n_args = 0, n_defaults = 0, found_default = 0; - asdl_seq *args, *defaults; + int i, j, k, nposargs = 0, nkwonlyargs = 0; + int nposdefaults = 0, found_default = 0; + asdl_seq *posargs, *posdefaults, *kwonlyargs, *kwdefaults; identifier vararg = NULL, kwarg = NULL; node *ch; if (TYPE(n) == parameters) { - if (NCH(n) == 2) /* () as argument list */ - return arguments(NULL, NULL, NULL, NULL, c->c_arena); - n = CHILD(n, 1); + if (NCH(n) == 2) /* () as argument list */ + return arguments(NULL, NULL, NULL, NULL, NULL, NULL, c->c_arena); + n = CHILD(n, 1); } REQ(n, varargslist); - /* first count the number of normal args & defaults */ + /* first count the number of positional args & defaults */ for (i = 0; i < NCH(n); i++) { - ch = CHILD(n, i); - if (TYPE(ch) == fpdef) - n_args++; - if (TYPE(ch) == EQUAL) - n_defaults++; - } - args = (n_args ? asdl_seq_new(n_args, c->c_arena) : NULL); - if (!args && n_args) - return NULL; /* Don't need to goto error; no objects allocated */ - defaults = (n_defaults ? asdl_seq_new(n_defaults, c->c_arena) : NULL); - if (!defaults && n_defaults) - return NULL; /* Don't need to goto error; no objects allocated */ + ch = CHILD(n, i); + if (TYPE(ch) == STAR) { + if (TYPE(CHILD(n, i+1)) == NAME) { + /* skip NAME of vararg */ + /* so that following can count only keyword only args */ + i += 2; + } + else { + i++; + } + break; + } + if (TYPE(ch) == fpdef) nposargs++; + if (TYPE(ch) == EQUAL) nposdefaults++; + } + /* count the number of keyword only args & + defaults for keyword only args */ + for ( ; i < NCH(n); ++i) { + ch = CHILD(n, i); + if (TYPE(ch) == DOUBLESTAR) break; + if (TYPE(ch) == NAME) nkwonlyargs++; + } + + posargs = (nposargs ? asdl_seq_new(nposargs, c->c_arena) : NULL); + if (!posargs && nposargs) + return NULL; /* Don't need to goto error; no objects allocated */ + kwonlyargs = (nkwonlyargs ? + asdl_seq_new(nkwonlyargs, c->c_arena) : NULL); + if (!kwonlyargs && nkwonlyargs) + return NULL; /* Don't need to goto error; no objects allocated */ + posdefaults = (nposdefaults ? + asdl_seq_new(nposdefaults, c->c_arena) : NULL); + if (!posdefaults && nposdefaults) + return NULL; /* Don't need to goto error; no objects allocated */ + /* The length of kwonlyargs and kwdefaults are same + since we set NULL as default for keyword only argument w/o default + - we have sequence data structure, but no dictionary */ + kwdefaults = (nkwonlyargs ? + asdl_seq_new(nkwonlyargs, c->c_arena) : NULL); + if (!kwdefaults && nkwonlyargs) + return NULL; /* Don't need to goto error; no objects allocated */ + + if (nposargs + nkwonlyargs > 255) { + ast_error(n, "more than 255 arguments"); + return NULL; + } /* fpdef: NAME | '(' fplist ')' fplist: fpdef (',' fpdef)* [','] @@ -634,66 +740,94 @@ j = 0; /* index for defaults */ k = 0; /* index for args */ while (i < NCH(n)) { - ch = CHILD(n, i); - switch (TYPE(ch)) { + ch = CHILD(n, i); + switch (TYPE(ch)) { case fpdef: + handle_fpdef: /* XXX Need to worry about checking if TYPE(CHILD(n, i+1)) is anything other than EQUAL or a comma? */ /* XXX Should NCH(n) check be made a separate check? */ if (i + 1 < NCH(n) && TYPE(CHILD(n, i + 1)) == EQUAL) { expr_ty expression = ast_for_expr(c, CHILD(n, i + 2)); if (!expression) - goto error; - assert(defaults != NULL); - asdl_seq_SET(defaults, j++, expression); + goto error; + assert(posdefaults != NULL); + asdl_seq_SET(posdefaults, j++, expression); + i += 2; - found_default = 1; + found_default = 1; + } + else if (found_default) { + ast_error(n, + "non-default argument follows default argument"); + goto error; } - else if (found_default) { - ast_error(n, - "non-default argument follows default argument"); - goto error; - } if (NCH(ch) == 3) { - ch = CHILD(ch, 1); - /* def foo((x)): is not complex, special case. */ - if (NCH(ch) != 1) { - /* We have complex arguments, setup for unpacking. */ - asdl_seq_SET(args, k++, compiler_complex_args(c, ch)); - } else { - /* def foo((x)): setup for checking NAME below. */ - ch = CHILD(ch, 0); - } + ch = CHILD(ch, 1); + /* def foo((x)): is not complex, special case. */ + if (NCH(ch) != 1) { + /* We have complex arguments, setup for unpacking. */ + asdl_seq_SET(posargs, k++, + compiler_complex_args(c, ch)); + } else { + /* def foo((x)): setup for checking NAME below. */ + /* Loop because there can be many parens and tuple + unpacking mixed in. */ + ch = CHILD(ch, 0); + assert(TYPE(ch) == fpdef); + goto handle_fpdef; + } } if (TYPE(CHILD(ch, 0)) == NAME) { - expr_ty name; - if (!strcmp(STR(CHILD(ch, 0)), "None")) { - ast_error(CHILD(ch, 0), "assignment to None"); - goto error; - } + expr_ty name; + if (!strcmp(STR(CHILD(ch, 0)), "None")) { + ast_error(CHILD(ch, 0), "assignment to None"); + goto error; + } name = Name(NEW_IDENTIFIER(CHILD(ch, 0)), Param, LINENO(ch), ch->n_col_offset, c->c_arena); if (!name) goto error; - asdl_seq_SET(args, k++, name); - - } + asdl_seq_SET(posargs, k++, name); + + } i += 2; /* the name and the comma */ break; case STAR: - if (!strcmp(STR(CHILD(n, i+1)), "None")) { - ast_error(CHILD(n, i+1), "assignment to None"); - goto error; - } - vararg = NEW_IDENTIFIER(CHILD(n, i+1)); - i += 3; + if (i+1 >= NCH(n)) { + ast_error(CHILD(n, i), "no name for vararg"); + goto error; + } + if (!strcmp(STR(CHILD(n, i+1)), "None")) { + ast_error(CHILD(n, i+1), "assignment to None"); + goto error; + } + if (TYPE(CHILD(n, i+1)) == COMMA) { + int res = 0; + i += 2; /* now follows keyword only arguments */ + res = handle_keywordonly_args(c, n, i, + kwonlyargs, kwdefaults); + if (res == -1) goto error; + i = res; /* res has new position to process */ + } + else { + vararg = NEW_IDENTIFIER(CHILD(n, i+1)); + i += 3; + if (i < NCH(n) && TYPE(CHILD(n, i)) == NAME) { + int res = 0; + res = handle_keywordonly_args(c, n, i, + kwonlyargs, kwdefaults); + if (res == -1) goto error; + i = res; /* res has new position to process */ + } + } break; case DOUBLESTAR: - if (!strcmp(STR(CHILD(n, i+1)), "None")) { - ast_error(CHILD(n, i+1), "assignment to None"); - goto error; - } + if (!strcmp(STR(CHILD(n, i+1)), "None")) { + ast_error(CHILD(n, i+1), "assignment to None"); + goto error; + } kwarg = NEW_IDENTIFIER(CHILD(n, i+1)); i += 3; break; @@ -702,11 +836,10 @@ "unexpected node in varargslist: %d @ %d", TYPE(ch), i); goto error; - } + } } - - return arguments(args, vararg, kwarg, defaults, c->c_arena); - + return arguments(posargs, vararg, kwonlyargs, kwarg, + posdefaults, kwdefaults, c->c_arena); error: Py_XDECREF(vararg); Py_XDECREF(kwarg); @@ -731,15 +864,15 @@ return NULL; e = Name(id, Load, lineno, col_offset, c->c_arena); if (!e) - return NULL; + return NULL; for (i = 2; i < NCH(n); i+=2) { id = NEW_IDENTIFIER(CHILD(n, i)); - if (!id) - return NULL; - e = Attribute(e, id, Load, lineno, col_offset, c->c_arena); - if (!e) - return NULL; + if (!id) + return NULL; + e = Attribute(e, id, Load, lineno, col_offset, c->c_arena); + if (!e) + return NULL; } return e; @@ -758,24 +891,24 @@ name_expr = ast_for_dotted_name(c, CHILD(n, 1)); if (!name_expr) - return NULL; - + return NULL; + if (NCH(n) == 3) { /* No arguments */ - d = name_expr; - name_expr = NULL; + d = name_expr; + name_expr = NULL; } else if (NCH(n) == 5) { /* Call with no arguments */ - d = Call(name_expr, NULL, NULL, NULL, NULL, LINENO(n), + d = Call(name_expr, NULL, NULL, NULL, NULL, LINENO(n), n->n_col_offset, c->c_arena); - if (!d) - return NULL; - name_expr = NULL; + if (!d) + return NULL; + name_expr = NULL; } else { - d = ast_for_call(c, CHILD(n, 3), name_expr); - if (!d) - return NULL; - name_expr = NULL; + d = ast_for_call(c, CHILD(n, 3), name_expr); + if (!d) + return NULL; + name_expr = NULL; } return d; @@ -792,12 +925,12 @@ decorator_seq = asdl_seq_new(NCH(n), c->c_arena); if (!decorator_seq) return NULL; - + for (i = 0; i < NCH(n); i++) { d = ast_for_decorator(c, CHILD(n, i)); - if (!d) - return NULL; - asdl_seq_SET(decorator_seq, i, d); + if (!d) + return NULL; + asdl_seq_SET(decorator_seq, i, d); } return decorator_seq; } @@ -815,28 +948,28 @@ REQ(n, funcdef); if (NCH(n) == 6) { /* decorators are present */ - decorator_seq = ast_for_decorators(c, CHILD(n, 0)); - if (!decorator_seq) - return NULL; - name_i = 2; + decorator_seq = ast_for_decorators(c, CHILD(n, 0)); + if (!decorator_seq) + return NULL; + name_i = 2; } else { - name_i = 1; + name_i = 1; } name = NEW_IDENTIFIER(CHILD(n, name_i)); if (!name) - return NULL; + return NULL; else if (!strcmp(STR(CHILD(n, name_i)), "None")) { - ast_error(CHILD(n, name_i), "assignment to None"); - return NULL; + ast_error(CHILD(n, name_i), "assignment to None"); + return NULL; } args = ast_for_arguments(c, CHILD(n, name_i + 1)); if (!args) - return NULL; + return NULL; body = ast_for_suite(c, CHILD(n, name_i + 3)); if (!body) - return NULL; + return NULL; return FunctionDef(name, args, body, decorator_seq, LINENO(n), n->n_col_offset, c->c_arena); @@ -850,7 +983,7 @@ expr_ty expression; if (NCH(n) == 3) { - args = arguments(NULL, NULL, NULL, NULL, c->c_arena); + args = arguments(NULL, NULL, NULL, NULL, NULL, NULL, c->c_arena); if (!args) return NULL; expression = ast_for_expr(c, CHILD(n, 2)); @@ -878,17 +1011,22 @@ assert(NCH(n) == 5); body = ast_for_expr(c, CHILD(n, 0)); if (!body) - return NULL; + return NULL; expression = ast_for_expr(c, CHILD(n, 2)); if (!expression) - return NULL; + return NULL; orelse = ast_for_expr(c, CHILD(n, 4)); if (!orelse) - return NULL; + return NULL; return IfExp(expression, body, orelse, LINENO(n), n->n_col_offset, c->c_arena); } +/* XXX(nnorwitz): the listcomp and genexpr code should be refactored + so there is only a single version. Possibly for loops can also re-use + the code. +*/ + /* Count the number of 'for' loop in a list comprehension. Helper for ast_for_listcomp(). @@ -904,14 +1042,14 @@ n_fors++; REQ(ch, list_for); if (NCH(ch) == 5) - ch = CHILD(ch, 4); + ch = CHILD(ch, 4); else - return n_fors; + return n_fors; count_list_iter: REQ(ch, list_iter); ch = CHILD(ch, 0); if (TYPE(ch) == list_for) - goto count_list_for; + goto count_list_for; else if (TYPE(ch) == list_if) { if (NCH(ch) == 3) { ch = CHILD(ch, 2); @@ -939,12 +1077,12 @@ count_list_iter: REQ(n, list_iter); if (TYPE(CHILD(n, 0)) == list_for) - return n_ifs; + return n_ifs; n = CHILD(n, 0); REQ(n, list_if); n_ifs++; if (NCH(n) == 2) - return n_ifs; + return n_ifs; n = CHILD(n, 2); goto count_list_iter; } @@ -976,61 +1114,65 @@ listcomps = asdl_seq_new(n_fors, c->c_arena); if (!listcomps) - return NULL; + return NULL; ch = CHILD(n, 1); for (i = 0; i < n_fors; i++) { - comprehension_ty lc; - asdl_seq *t; + comprehension_ty lc; + asdl_seq *t; expr_ty expression; + node *for_ch; - REQ(ch, list_for); + REQ(ch, list_for); - t = ast_for_exprlist(c, CHILD(ch, 1), Store); + for_ch = CHILD(ch, 1); + t = ast_for_exprlist(c, for_ch, Store); if (!t) return NULL; expression = ast_for_testlist(c, CHILD(ch, 3)); if (!expression) return NULL; - if (asdl_seq_LEN(t) == 1) - lc = comprehension((expr_ty)asdl_seq_GET(t, 0), expression, NULL, + /* Check the # of children rather than the length of t, since + [x for x, in ... ] has 1 element in t, but still requires a Tuple. */ + if (NCH(for_ch) == 1) + lc = comprehension((expr_ty)asdl_seq_GET(t, 0), expression, NULL, c->c_arena); - else - lc = comprehension(Tuple(t, Store, LINENO(ch), ch->n_col_offset, + else + lc = comprehension(Tuple(t, Store, LINENO(ch), ch->n_col_offset, c->c_arena), expression, NULL, c->c_arena); if (!lc) return NULL; - if (NCH(ch) == 5) { - int j, n_ifs; - asdl_seq *ifs; + if (NCH(ch) == 5) { + int j, n_ifs; + asdl_seq *ifs; - ch = CHILD(ch, 4); - n_ifs = count_list_ifs(ch); + ch = CHILD(ch, 4); + n_ifs = count_list_ifs(ch); if (n_ifs == -1) return NULL; - ifs = asdl_seq_new(n_ifs, c->c_arena); - if (!ifs) - return NULL; + ifs = asdl_seq_new(n_ifs, c->c_arena); + if (!ifs) + return NULL; - for (j = 0; j < n_ifs; j++) { + for (j = 0; j < n_ifs; j++) { REQ(ch, list_iter); - ch = CHILD(ch, 0); - REQ(ch, list_if); + ch = CHILD(ch, 0); + REQ(ch, list_if); - asdl_seq_SET(ifs, j, ast_for_expr(c, CHILD(ch, 1))); - if (NCH(ch) == 3) - ch = CHILD(ch, 2); - } - /* on exit, must guarantee that ch is a list_for */ - if (TYPE(ch) == list_iter) - ch = CHILD(ch, 0); + asdl_seq_SET(ifs, j, ast_for_expr(c, CHILD(ch, 1))); + if (NCH(ch) == 3) + ch = CHILD(ch, 2); + } + /* on exit, must guarantee that ch is a list_for */ + if (TYPE(ch) == list_iter) + ch = CHILD(ch, 0); lc->ifs = ifs; - } - asdl_seq_SET(listcomps, i, lc); + } + asdl_seq_SET(listcomps, i, lc); } return ListComp(elt, listcomps, LINENO(n), n->n_col_offset, c->c_arena); @@ -1045,34 +1187,34 @@ static int count_gen_fors(const node *n) { - int n_fors = 0; - node *ch = CHILD(n, 1); + int n_fors = 0; + node *ch = CHILD(n, 1); count_gen_for: - n_fors++; - REQ(ch, gen_for); - if (NCH(ch) == 5) - ch = CHILD(ch, 4); - else - return n_fors; + n_fors++; + REQ(ch, gen_for); + if (NCH(ch) == 5) + ch = CHILD(ch, 4); + else + return n_fors; count_gen_iter: - REQ(ch, gen_iter); - ch = CHILD(ch, 0); - if (TYPE(ch) == gen_for) - goto count_gen_for; - else if (TYPE(ch) == gen_if) { - if (NCH(ch) == 3) { - ch = CHILD(ch, 2); - goto count_gen_iter; - } - else - return n_fors; - } - - /* Should never be reached */ - PyErr_SetString(PyExc_SystemError, - "logic error in count_gen_fors"); - return -1; + REQ(ch, gen_iter); + ch = CHILD(ch, 0); + if (TYPE(ch) == gen_for) + goto count_gen_for; + else if (TYPE(ch) == gen_if) { + if (NCH(ch) == 3) { + ch = CHILD(ch, 2); + goto count_gen_iter; + } + else + return n_fors; + } + + /* Should never be reached */ + PyErr_SetString(PyExc_SystemError, + "logic error in count_gen_fors"); + return -1; } /* Count the number of 'if' statements in a generator expression. @@ -1083,19 +1225,19 @@ static int count_gen_ifs(const node *n) { - int n_ifs = 0; + int n_ifs = 0; - while (1) { - REQ(n, gen_iter); - if (TYPE(CHILD(n, 0)) == gen_for) - return n_ifs; - n = CHILD(n, 0); - REQ(n, gen_if); - n_ifs++; - if (NCH(n) == 2) - return n_ifs; - n = CHILD(n, 2); - } + while (1) { + REQ(n, gen_iter); + if (TYPE(CHILD(n, 0)) == gen_for) + return n_ifs; + n = CHILD(n, 0); + REQ(n, gen_if); + n_ifs++; + if (NCH(n) == 2) + return n_ifs; + n = CHILD(n, 2); + } } /* TODO(jhylton): Combine with list comprehension code? */ @@ -1103,7 +1245,7 @@ ast_for_genexp(struct compiling *c, const node *n) { /* testlist_gexp: test ( gen_for | (',' test)* [','] ) - argument: [test '='] test [gen_for] # Really [keyword '='] test */ + argument: [test '='] test [gen_for] # Really [keyword '='] test */ expr_ty elt; asdl_seq *genexps; int i, n_fors; @@ -1129,17 +1271,21 @@ comprehension_ty ge; asdl_seq *t; expr_ty expression; + node *for_ch; REQ(ch, gen_for); - t = ast_for_exprlist(c, CHILD(ch, 1), Store); + for_ch = CHILD(ch, 1); + t = ast_for_exprlist(c, for_ch, Store); if (!t) return NULL; expression = ast_for_expr(c, CHILD(ch, 3)); if (!expression) return NULL; - if (asdl_seq_LEN(t) == 1) + /* Check the # of children rather than the length of t, since + (x for x, in ...) has 1 element in t, but still requires a Tuple. */ + if (NCH(for_ch) == 1) ge = comprehension((expr_ty)asdl_seq_GET(t, 0), expression, NULL, c->c_arena); else @@ -1190,102 +1336,117 @@ ast_for_atom(struct compiling *c, const node *n) { /* atom: '(' [yield_expr|testlist_gexp] ')' | '[' [listmaker] ']' - | '{' [dictmaker] '}' | '`' testlist '`' | NAME | NUMBER | STRING+ + | '{' [dictsetmaker] '}' | NAME | NUMBER | STRING+ */ node *ch = CHILD(n, 0); switch (TYPE(ch)) { case NAME: - /* All names start in Load context, but may later be - changed. */ - return Name(NEW_IDENTIFIER(ch), Load, LINENO(n), n->n_col_offset, c->c_arena); + /* All names start in Load context, but may later be + changed. */ + return Name(NEW_IDENTIFIER(ch), Load, LINENO(n), n->n_col_offset, c->c_arena); case STRING: { - PyObject *str = parsestrplus(c, n); - if (!str) - return NULL; + PyObject *str = parsestrplus(c, n); + if (!str) + return NULL; - PyArena_AddPyObject(c->c_arena, str); - return Str(str, LINENO(n), n->n_col_offset, c->c_arena); + PyArena_AddPyObject(c->c_arena, str); + return Str(str, LINENO(n), n->n_col_offset, c->c_arena); } case NUMBER: { - PyObject *pynum = parsenumber(STR(ch)); - if (!pynum) - return NULL; + PyObject *pynum = parsenumber(STR(ch)); + if (!pynum) + return NULL; - PyArena_AddPyObject(c->c_arena, pynum); - return Num(pynum, LINENO(n), n->n_col_offset, c->c_arena); + PyArena_AddPyObject(c->c_arena, pynum); + return Num(pynum, LINENO(n), n->n_col_offset, c->c_arena); } + case DOT: + /* Ellipsis */ + return Ellipsis(LINENO(n), n->n_col_offset, c->c_arena); case LPAR: /* some parenthesized expressions */ - ch = CHILD(n, 1); - - if (TYPE(ch) == RPAR) - return Tuple(NULL, Load, LINENO(n), n->n_col_offset, c->c_arena); - - if (TYPE(ch) == yield_expr) - return ast_for_expr(c, ch); - - if ((NCH(ch) > 1) && (TYPE(CHILD(ch, 1)) == gen_for)) - return ast_for_genexp(c, ch); - - return ast_for_testlist_gexp(c, ch); + ch = CHILD(n, 1); + + if (TYPE(ch) == RPAR) + return Tuple(NULL, Load, LINENO(n), n->n_col_offset, c->c_arena); + + if (TYPE(ch) == yield_expr) + return ast_for_expr(c, ch); + + if ((NCH(ch) > 1) && (TYPE(CHILD(ch, 1)) == gen_for)) + return ast_for_genexp(c, ch); + + return ast_for_testlist_gexp(c, ch); case LSQB: /* list (or list comprehension) */ - ch = CHILD(n, 1); - - if (TYPE(ch) == RSQB) - return List(NULL, Load, LINENO(n), n->n_col_offset, c->c_arena); - - REQ(ch, listmaker); - if (NCH(ch) == 1 || TYPE(CHILD(ch, 1)) == COMMA) { - asdl_seq *elts = seq_for_testlist(c, ch); - if (!elts) - return NULL; + ch = CHILD(n, 1); + + if (TYPE(ch) == RSQB) + return List(NULL, Load, LINENO(n), n->n_col_offset, c->c_arena); + + REQ(ch, listmaker); + if (NCH(ch) == 1 || TYPE(CHILD(ch, 1)) == COMMA) { + asdl_seq *elts = seq_for_testlist(c, ch); + if (!elts) + return NULL; - return List(elts, Load, LINENO(n), n->n_col_offset, c->c_arena); - } - else - return ast_for_listcomp(c, ch); + return List(elts, Load, LINENO(n), n->n_col_offset, c->c_arena); + } + else + return ast_for_listcomp(c, ch); case LBRACE: { - /* dictmaker: test ':' test (',' test ':' test)* [','] */ + /* dictsetmaker: test ':' test (',' test ':' test)* [','] | + * test (',' test)* [','] */ int i, size; asdl_seq *keys, *values; ch = CHILD(n, 1); - size = (NCH(ch) + 1) / 4; /* +1 in case no trailing comma */ - keys = asdl_seq_new(size, c->c_arena); - if (!keys) - return NULL; - - values = asdl_seq_new(size, c->c_arena); - if (!values) - return NULL; - - for (i = 0; i < NCH(ch); i += 4) { - expr_ty expression; - - expression = ast_for_expr(c, CHILD(ch, i)); - if (!expression) - return NULL; + if (NCH(ch) == 1 || (NCH(ch) > 0 && STR(CHILD(ch, 1))[0] == ',')) { + /* it's a set */ + size = (NCH(ch) + 1) / 2; /* +1 in case no trailing comma */ + keys = asdl_seq_new(size, c->c_arena); + if (!keys) + return NULL; - asdl_seq_SET(keys, i / 4, expression); + for (i = 0; i < NCH(ch); i += 2) { + expr_ty expression; + expression = ast_for_expr(c, CHILD(ch, i)); + if (!expression) + return NULL; + asdl_seq_SET(keys, i / 2, expression); + } + return Set(keys, LINENO(n), n->n_col_offset, c->c_arena); + } else { + /* it's a dict */ + size = (NCH(ch) + 1) / 4; /* +1 in case no trailing comma */ + keys = asdl_seq_new(size, c->c_arena); + if (!keys) + return NULL; + + values = asdl_seq_new(size, c->c_arena); + if (!values) + return NULL; + + for (i = 0; i < NCH(ch); i += 4) { + expr_ty expression; + + expression = ast_for_expr(c, CHILD(ch, i)); + if (!expression) + return NULL; - expression = ast_for_expr(c, CHILD(ch, i + 2)); - if (!expression) - return NULL; + asdl_seq_SET(keys, i / 4, expression); - asdl_seq_SET(values, i / 4, expression); - } - return Dict(keys, values, LINENO(n), n->n_col_offset, c->c_arena); - } - case BACKQUOTE: { /* repr */ - expr_ty expression = ast_for_testlist(c, CHILD(n, 1)); - if (!expression) - return NULL; + expression = ast_for_expr(c, CHILD(ch, i + 2)); + if (!expression) + return NULL; - return Repr(expression, LINENO(n), n->n_col_offset, c->c_arena); + asdl_seq_SET(values, i / 4, expression); + } + return Dict(keys, values, LINENO(n), n->n_col_offset, c->c_arena); + } } default: - PyErr_Format(PyExc_SystemError, "unhandled atom %d", TYPE(ch)); - return NULL; + PyErr_Format(PyExc_SystemError, "unhandled atom %d", TYPE(ch)); + return NULL; } } @@ -1298,13 +1459,10 @@ REQ(n, subscript); /* - subscript: '.' '.' '.' | test | [test] ':' [test] [sliceop] + subscript: test | [test] ':' [test] [sliceop] sliceop: ':' [test] */ ch = CHILD(n, 0); - if (TYPE(ch) == DOT) - return Ellipsis(c->c_arena); - if (NCH(n) == 1 && TYPE(ch) == test) { /* 'step' variable hold no significance in terms of being used over other vars */ @@ -1312,31 +1470,31 @@ if (!step) return NULL; - return Index(step, c->c_arena); + return Index(step, c->c_arena); } if (TYPE(ch) == test) { - lower = ast_for_expr(c, ch); + lower = ast_for_expr(c, ch); if (!lower) return NULL; } /* If there's an upper bound it's in the second or third position. */ if (TYPE(ch) == COLON) { - if (NCH(n) > 1) { - node *n2 = CHILD(n, 1); + if (NCH(n) > 1) { + node *n2 = CHILD(n, 1); - if (TYPE(n2) == test) { - upper = ast_for_expr(c, n2); + if (TYPE(n2) == test) { + upper = ast_for_expr(c, n2); if (!upper) return NULL; } - } + } } else if (NCH(n) > 2) { - node *n2 = CHILD(n, 2); + node *n2 = CHILD(n, 2); - if (TYPE(n2) == test) { - upper = ast_for_expr(c, n2); + if (TYPE(n2) == test) { + upper = ast_for_expr(c, n2); if (!upper) return NULL; } @@ -1367,13 +1525,13 @@ static expr_ty ast_for_binop(struct compiling *c, const node *n) { - /* Must account for a sequence of expressions. - How should A op B op C by represented? - BinOp(BinOp(A, op, B), op, C). - */ + /* Must account for a sequence of expressions. + How should A op B op C by represented? + BinOp(BinOp(A, op, B), op, C). + */ - int i, nops; - expr_ty expr1, expr2, result; + int i, nops; + expr_ty expr1, expr2, result; operator_ty newoperator; expr1 = ast_for_expr(c, CHILD(n, 0)); @@ -1388,17 +1546,17 @@ if (!newoperator) return NULL; - result = BinOp(expr1, newoperator, expr2, LINENO(n), n->n_col_offset, + result = BinOp(expr1, newoperator, expr2, LINENO(n), n->n_col_offset, c->c_arena); - if (!result) + if (!result) return NULL; - nops = (NCH(n) - 1) / 2; - for (i = 1; i < nops; i++) { - expr_ty tmp_result, tmp; - const node* next_oper = CHILD(n, i * 2 + 1); + nops = (NCH(n) - 1) / 2; + for (i = 1; i < nops; i++) { + expr_ty tmp_result, tmp; + const node* next_oper = CHILD(n, i * 2 + 1); - newoperator = get_operator(next_oper); + newoperator = get_operator(next_oper); if (!newoperator) return NULL; @@ -1407,13 +1565,13 @@ return NULL; tmp_result = BinOp(result, newoperator, tmp, - LINENO(next_oper), next_oper->n_col_offset, + LINENO(next_oper), next_oper->n_col_offset, c->c_arena); - if (!tmp) - return NULL; - result = tmp_result; - } - return result; + if (!tmp) + return NULL; + result = tmp_result; + } + return result; } static expr_ty @@ -1560,8 +1718,8 @@ tmp = ast_for_trailer(c, ch, e); if (!tmp) return NULL; - tmp->lineno = e->lineno; - tmp->col_offset = e->col_offset; + tmp->lineno = e->lineno; + tmp->col_offset = e->col_offset; e = tmp; } if (TYPE(CHILD(n, NCH(n) - 1)) == factor) { @@ -1619,8 +1777,8 @@ return ast_for_lambdef(c, CHILD(n, 0)); else if (NCH(n) > 1) return ast_for_ifexpr(c, n); - /* Fallthrough */ - case or_test: + /* Fallthrough */ + case or_test: case and_test: if (NCH(n) == 1) { n = CHILD(n, 0); @@ -1661,7 +1819,7 @@ else { expr_ty expression; asdl_int_seq *ops; - asdl_seq *cmps; + asdl_seq *cmps; ops = asdl_int_seq_new(NCH(n) / 2, c->c_arena); if (!ops) return NULL; @@ -1675,12 +1833,12 @@ newoperator = ast_for_comp_op(CHILD(n, i)); if (!newoperator) { return NULL; - } + } expression = ast_for_expr(c, CHILD(n, i + 1)); if (!expression) { return NULL; - } + } asdl_seq_SET(ops, i / 2, newoperator); asdl_seq_SET(cmps, i / 2, expression); @@ -1688,7 +1846,7 @@ expression = ast_for_expr(c, CHILD(n, 0)); if (!expression) { return NULL; - } + } return Compare(expression, ops, cmps, LINENO(n), n->n_col_offset, c->c_arena); @@ -1711,20 +1869,20 @@ } return ast_for_binop(c, n); case yield_expr: { - expr_ty exp = NULL; - if (NCH(n) == 2) { - exp = ast_for_testlist(c, CHILD(n, 1)); - if (!exp) - return NULL; - } - return Yield(exp, LINENO(n), n->n_col_offset, c->c_arena); - } + expr_ty exp = NULL; + if (NCH(n) == 2) { + exp = ast_for_testlist(c, CHILD(n, 1)); + if (!exp) + return NULL; + } + return Yield(exp, LINENO(n), n->n_col_offset, c->c_arena); + } case factor: if (NCH(n) == 1) { n = CHILD(n, 0); goto loop; } - return ast_for_factor(c, n); + return ast_for_factor(c, n); case power: return ast_for_power(c, n); default: @@ -1741,7 +1899,7 @@ /* arglist: (argument ',')* (argument [',']| '*' test [',' '**' test] | '**' test) - argument: [test '='] test [gen_for] # Really [keyword '='] test + argument: [test '='] test [gen_for] # Really [keyword '='] test */ int i, nargs, nkeywords, ngens; @@ -1755,20 +1913,20 @@ nkeywords = 0; ngens = 0; for (i = 0; i < NCH(n); i++) { - node *ch = CHILD(n, i); - if (TYPE(ch) == argument) { - if (NCH(ch) == 1) - nargs++; - else if (TYPE(CHILD(ch, 1)) == gen_for) - ngens++; + node *ch = CHILD(n, i); + if (TYPE(ch) == argument) { + if (NCH(ch) == 1) + nargs++; + else if (TYPE(CHILD(ch, 1)) == gen_for) + ngens++; else - nkeywords++; - } + nkeywords++; + } } if (ngens > 1 || (ngens && (nargs || nkeywords))) { ast_error(n, "Generator expression must be parenthesized " - "if not sole argument"); - return NULL; + "if not sole argument"); + return NULL; } if (nargs + nkeywords + ngens > 255) { @@ -1785,32 +1943,32 @@ nargs = 0; nkeywords = 0; for (i = 0; i < NCH(n); i++) { - node *ch = CHILD(n, i); - if (TYPE(ch) == argument) { - expr_ty e; - if (NCH(ch) == 1) { - if (nkeywords) { - ast_error(CHILD(ch, 0), - "non-keyword arg after keyword arg"); - return NULL; - } - e = ast_for_expr(c, CHILD(ch, 0)); + node *ch = CHILD(n, i); + if (TYPE(ch) == argument) { + expr_ty e; + if (NCH(ch) == 1) { + if (nkeywords) { + ast_error(CHILD(ch, 0), + "non-keyword arg after keyword arg"); + return NULL; + } + e = ast_for_expr(c, CHILD(ch, 0)); if (!e) return NULL; - asdl_seq_SET(args, nargs++, e); - } - else if (TYPE(CHILD(ch, 1)) == gen_for) { - e = ast_for_genexp(c, ch); + asdl_seq_SET(args, nargs++, e); + } + else if (TYPE(CHILD(ch, 1)) == gen_for) { + e = ast_for_genexp(c, ch); if (!e) return NULL; - asdl_seq_SET(args, nargs++, e); + asdl_seq_SET(args, nargs++, e); } - else { - keyword_ty kw; - identifier key; + else { + keyword_ty kw; + identifier key; - /* CHILD(ch, 0) is test, but must be an identifier? */ - e = ast_for_expr(c, CHILD(ch, 0)); + /* CHILD(ch, 0) is test, but must be an identifier? */ + e = ast_for_expr(c, CHILD(ch, 0)); if (!e) return NULL; /* f(lambda x: x[0] = 3) ends up getting parsed with @@ -1825,24 +1983,24 @@ ast_error(CHILD(ch, 0), "keyword can't be an expression"); return NULL; } - key = e->v.Name.id; - e = ast_for_expr(c, CHILD(ch, 2)); + key = e->v.Name.id; + e = ast_for_expr(c, CHILD(ch, 2)); if (!e) return NULL; - kw = keyword(key, e, c->c_arena); + kw = keyword(key, e, c->c_arena); if (!kw) return NULL; - asdl_seq_SET(keywords, nkeywords++, kw); - } - } - else if (TYPE(ch) == STAR) { - vararg = ast_for_expr(c, CHILD(n, i+1)); - i++; - } - else if (TYPE(ch) == DOUBLESTAR) { - kwarg = ast_for_expr(c, CHILD(n, i+1)); - i++; - } + asdl_seq_SET(keywords, nkeywords++, kw); + } + } + else if (TYPE(ch) == STAR) { + vararg = ast_for_expr(c, CHILD(n, i+1)); + i++; + } + else if (TYPE(ch) == DOUBLESTAR) { + kwarg = ast_for_expr(c, CHILD(n, i+1)); + i++; + } } return Call(func, args, keywords, vararg, kwarg, func->lineno, func->col_offset, c->c_arena); @@ -1866,12 +2024,12 @@ TYPE(n) == testlist1); } if (NCH(n) == 1) - return ast_for_expr(c, CHILD(n, 0)); + return ast_for_expr(c, CHILD(n, 0)); else { asdl_seq *tmp = seq_for_testlist(c, n); if (!tmp) return NULL; - return Tuple(tmp, Load, LINENO(n), n->n_col_offset, c->c_arena); + return Tuple(tmp, Load, LINENO(n), n->n_col_offset, c->c_arena); } } @@ -1882,7 +2040,7 @@ /* argument: test [ gen_for ] */ assert(TYPE(n) == testlist_gexp || TYPE(n) == argument); if (NCH(n) > 1 && TYPE(CHILD(n, 1)) == gen_for) - return ast_for_genexp(c, n); + return ast_for_genexp(c, n); return ast_for_testlist(c, n); } @@ -1916,23 +2074,23 @@ | ('=' (yield_expr|testlist))*) testlist: test (',' test)* [','] augassign: '+=' | '-=' | '*=' | '/=' | '%=' | '&=' | '|=' | '^=' - | '<<=' | '>>=' | '**=' | '//=' + | '<<=' | '>>=' | '**=' | '//=' test: ... here starts the operator precendence dance */ if (NCH(n) == 1) { - expr_ty e = ast_for_testlist(c, CHILD(n, 0)); + expr_ty e = ast_for_testlist(c, CHILD(n, 0)); if (!e) return NULL; - return Expr(e, LINENO(n), n->n_col_offset, c->c_arena); + return Expr(e, LINENO(n), n->n_col_offset, c->c_arena); } else if (TYPE(CHILD(n, 1)) == augassign) { expr_ty expr1, expr2; operator_ty newoperator; - node *ch = CHILD(n, 0); + node *ch = CHILD(n, 0); - expr1 = ast_for_testlist(c, ch); + expr1 = ast_for_testlist(c, ch); if (!expr1) return NULL; /* TODO(nas): Remove duplicated error checks (set_context does it) */ @@ -1961,13 +2119,13 @@ "assignment"); return NULL; } - set_context(expr1, Store, ch); + set_context(expr1, Store, ch); - ch = CHILD(n, 2); - if (TYPE(ch) == testlist) - expr2 = ast_for_testlist(c, ch); - else - expr2 = ast_for_expr(c, ch); + ch = CHILD(n, 2); + if (TYPE(ch) == testlist) + expr2 = ast_for_testlist(c, ch); + else + expr2 = ast_for_expr(c, ch); if (!expr2) return NULL; @@ -1975,45 +2133,45 @@ if (!newoperator) return NULL; - return AugAssign(expr1, newoperator, expr2, LINENO(n), n->n_col_offset, c->c_arena); + return AugAssign(expr1, newoperator, expr2, LINENO(n), n->n_col_offset, c->c_arena); } else { - int i; - asdl_seq *targets; - node *value; + int i; + asdl_seq *targets; + node *value; expr_ty expression; - /* a normal assignment */ - REQ(CHILD(n, 1), EQUAL); - targets = asdl_seq_new(NCH(n) / 2, c->c_arena); - if (!targets) - return NULL; - for (i = 0; i < NCH(n) - 2; i += 2) { - expr_ty e; - node *ch = CHILD(n, i); - if (TYPE(ch) == yield_expr) { - ast_error(ch, "assignment to yield expression not possible"); - return NULL; - } - e = ast_for_testlist(c, ch); + /* a normal assignment */ + REQ(CHILD(n, 1), EQUAL); + targets = asdl_seq_new(NCH(n) / 2, c->c_arena); + if (!targets) + return NULL; + for (i = 0; i < NCH(n) - 2; i += 2) { + expr_ty e; + node *ch = CHILD(n, i); + if (TYPE(ch) == yield_expr) { + ast_error(ch, "assignment to yield expression not possible"); + return NULL; + } + e = ast_for_testlist(c, ch); + + /* set context to assign */ + if (!e) + return NULL; + + if (!set_context(e, Store, CHILD(n, i))) + return NULL; - /* set context to assign */ - if (!e) - return NULL; - - if (!set_context(e, Store, CHILD(n, i))) - return NULL; - - asdl_seq_SET(targets, i / 2, e); - } - value = CHILD(n, NCH(n) - 1); - if (TYPE(value) == testlist) - expression = ast_for_testlist(c, value); - else - expression = ast_for_expr(c, value); - if (!expression) - return NULL; - return Assign(targets, expression, LINENO(n), n->n_col_offset, c->c_arena); + asdl_seq_SET(targets, i / 2, e); + } + value = CHILD(n, NCH(n) - 1); + if (TYPE(value) == testlist) + expression = ast_for_testlist(c, value); + else + expression = ast_for_expr(c, value); + if (!expression) + return NULL; + return Assign(targets, expression, LINENO(n), n->n_col_offset, c->c_arena); } } @@ -2030,19 +2188,19 @@ REQ(n, print_stmt); if (NCH(n) >= 2 && TYPE(CHILD(n, 1)) == RIGHTSHIFT) { - dest = ast_for_expr(c, CHILD(n, 2)); + dest = ast_for_expr(c, CHILD(n, 2)); if (!dest) return NULL; - start = 4; + start = 4; } seq = asdl_seq_new((NCH(n) + 1 - start) / 2, c->c_arena); if (!seq) - return NULL; + return NULL; for (i = start, j = 0; i < NCH(n); i += 2, ++j) { expression = ast_for_expr(c, CHILD(n, i)); if (!expression) return NULL; - asdl_seq_SET(seq, j, expression); + asdl_seq_SET(seq, j, expression); } nl = (TYPE(CHILD(n, NCH(n) - 1)) == COMMA) ? false : true; return Print(dest, seq, nl, LINENO(n), n->n_col_offset, c->c_arena); @@ -2059,14 +2217,14 @@ seq = asdl_seq_new((NCH(n) + 1) / 2, c->c_arena); if (!seq) - return NULL; + return NULL; for (i = 0; i < NCH(n); i += 2) { - e = ast_for_expr(c, CHILD(n, i)); - if (!e) - return NULL; - asdl_seq_SET(seq, i / 2, e); - if (context && !set_context(e, context, CHILD(n, i))) - return NULL; + e = ast_for_expr(c, CHILD(n, i)); + if (!e) + return NULL; + asdl_seq_SET(seq, i / 2, e); + if (context && !set_context(e, context, CHILD(n, i))) + return NULL; } return seq; } @@ -2108,9 +2266,9 @@ case continue_stmt: return Continue(LINENO(n), n->n_col_offset, c->c_arena); case yield_stmt: { /* will reduce to yield_expr */ - expr_ty exp = ast_for_expr(c, CHILD(ch, 0)); - if (!exp) - return NULL; + expr_ty exp = ast_for_expr(c, CHILD(ch, 0)); + if (!exp) + return NULL; return Expr(exp, LINENO(n), n->n_col_offset, c->c_arena); } case return_stmt: @@ -2183,10 +2341,6 @@ case import_as_name: str = NULL; if (NCH(n) == 3) { - if (strcmp(STR(CHILD(n, 1)), "as") != 0) { - ast_error(n, "must use 'as' in import"); - return NULL; - } str = NEW_IDENTIFIER(CHILD(n, 2)); } return alias(NEW_IDENTIFIER(CHILD(n, 0)), str, c->c_arena); @@ -2199,10 +2353,6 @@ alias_ty a = alias_for_import_name(c, CHILD(n, 0)); if (!a) return NULL; - if (strcmp(STR(CHILD(n, 1)), "as") != 0) { - ast_error(n, "must use 'as' in import"); - return NULL; - } assert(!a->asname); a->asname = NEW_IDENTIFIER(CHILD(n, 2)); return a; @@ -2237,13 +2387,13 @@ --s; *s = '\0'; PyString_InternInPlace(&str); - PyArena_AddPyObject(c->c_arena, str); + PyArena_AddPyObject(c->c_arena, str); return alias(str, NULL, c->c_arena); } break; case STAR: - str = PyString_InternFromString("*"); - PyArena_AddPyObject(c->c_arena, str); + str = PyString_InternFromString("*"); + PyArena_AddPyObject(c->c_arena, str); return alias(str, NULL, c->c_arena); default: PyErr_Format(PyExc_SystemError, @@ -2275,69 +2425,69 @@ n = CHILD(n, 0); if (TYPE(n) == import_name) { n = CHILD(n, 1); - REQ(n, dotted_as_names); - aliases = asdl_seq_new((NCH(n) + 1) / 2, c->c_arena); - if (!aliases) - return NULL; - for (i = 0; i < NCH(n); i += 2) { + REQ(n, dotted_as_names); + aliases = asdl_seq_new((NCH(n) + 1) / 2, c->c_arena); + if (!aliases) + return NULL; + for (i = 0; i < NCH(n); i += 2) { alias_ty import_alias = alias_for_import_name(c, CHILD(n, i)); if (!import_alias) return NULL; - asdl_seq_SET(aliases, i / 2, import_alias); + asdl_seq_SET(aliases, i / 2, import_alias); } - return Import(aliases, lineno, col_offset, c->c_arena); + return Import(aliases, lineno, col_offset, c->c_arena); } else if (TYPE(n) == import_from) { int n_children; - int idx, ndots = 0; - alias_ty mod = NULL; - identifier modname; - + int idx, ndots = 0; + alias_ty mod = NULL; + identifier modname; + /* Count the number of dots (for relative imports) and check for the optional module name */ - for (idx = 1; idx < NCH(n); idx++) { - if (TYPE(CHILD(n, idx)) == dotted_name) { - mod = alias_for_import_name(c, CHILD(n, idx)); - idx++; - break; - } else if (TYPE(CHILD(n, idx)) != DOT) { - break; - } - ndots++; - } - idx++; /* skip over the 'import' keyword */ + for (idx = 1; idx < NCH(n); idx++) { + if (TYPE(CHILD(n, idx)) == dotted_name) { + mod = alias_for_import_name(c, CHILD(n, idx)); + idx++; + break; + } else if (TYPE(CHILD(n, idx)) != DOT) { + break; + } + ndots++; + } + idx++; /* skip over the 'import' keyword */ switch (TYPE(CHILD(n, idx))) { case STAR: /* from ... import * */ - n = CHILD(n, idx); - n_children = 1; - if (ndots) { - ast_error(n, "'import *' not allowed with 'from .'"); - return NULL; - } - break; - case LPAR: - /* from ... import (x, y, z) */ - n = CHILD(n, idx + 1); - n_children = NCH(n); - break; - case import_as_names: - /* from ... import x, y, z */ - n = CHILD(n, idx); - n_children = NCH(n); + n = CHILD(n, idx); + n_children = 1; + if (ndots) { + ast_error(n, "'import *' not allowed with 'from .'"); + return NULL; + } + break; + case LPAR: + /* from ... import (x, y, z) */ + n = CHILD(n, idx + 1); + n_children = NCH(n); + break; + case import_as_names: + /* from ... import x, y, z */ + n = CHILD(n, idx); + n_children = NCH(n); if (n_children % 2 == 0) { ast_error(n, "trailing comma not allowed without" " surrounding parentheses"); return NULL; } - break; - default: - ast_error(n, "Unexpected node-type in from-import"); - return NULL; - } + break; + default: + ast_error(n, "Unexpected node-type in from-import"); + return NULL; + } - aliases = asdl_seq_new((n_children + 1) / 2, c->c_arena); - if (!aliases) + aliases = asdl_seq_new((n_children + 1) / 2, c->c_arena); + if (!aliases) return NULL; /* handle "from ... import *" special b/c there's no children */ @@ -2345,14 +2495,14 @@ alias_ty import_alias = alias_for_import_name(c, n); if (!import_alias) return NULL; - asdl_seq_SET(aliases, 0, import_alias); + asdl_seq_SET(aliases, 0, import_alias); } else { - for (i = 0; i < NCH(n); i += 2) { + for (i = 0; i < NCH(n); i += 2) { alias_ty import_alias = alias_for_import_name(c, CHILD(n, i)); if (!import_alias) return NULL; - asdl_seq_SET(aliases, i / 2, import_alias); + asdl_seq_SET(aliases, i / 2, import_alias); } } if (mod != NULL) @@ -2379,45 +2529,14 @@ REQ(n, global_stmt); s = asdl_seq_new(NCH(n) / 2, c->c_arena); if (!s) - return NULL; - for (i = 1; i < NCH(n); i += 2) { - name = NEW_IDENTIFIER(CHILD(n, i)); - if (!name) - return NULL; - asdl_seq_SET(s, i / 2, name); - } - return Global(s, LINENO(n), n->n_col_offset, c->c_arena); -} - -static stmt_ty -ast_for_exec_stmt(struct compiling *c, const node *n) -{ - expr_ty expr1, globals = NULL, locals = NULL; - int n_children = NCH(n); - if (n_children != 2 && n_children != 4 && n_children != 6) { - PyErr_Format(PyExc_SystemError, - "poorly formed 'exec' statement: %d parts to statement", - n_children); - return NULL; - } - - /* exec_stmt: 'exec' expr ['in' test [',' test]] */ - REQ(n, exec_stmt); - expr1 = ast_for_expr(c, CHILD(n, 1)); - if (!expr1) return NULL; - if (n_children >= 4) { - globals = ast_for_expr(c, CHILD(n, 3)); - if (!globals) - return NULL; - } - if (n_children == 6) { - locals = ast_for_expr(c, CHILD(n, 5)); - if (!locals) + for (i = 1; i < NCH(n); i += 2) { + name = NEW_IDENTIFIER(CHILD(n, i)); + if (!name) return NULL; + asdl_seq_SET(s, i / 2, name); } - - return Exec(expr1, globals, locals, LINENO(n), n->n_col_offset, c->c_arena); + return Global(s, LINENO(n), n->n_col_offset, c->c_arena); } static stmt_ty @@ -2429,7 +2548,7 @@ expr_ty expression = ast_for_expr(c, CHILD(n, 1)); if (!expression) return NULL; - return Assert(expression, NULL, LINENO(n), n->n_col_offset, c->c_arena); + return Assert(expression, NULL, LINENO(n), n->n_col_offset, c->c_arena); } else if (NCH(n) == 4) { expr_ty expr1, expr2; @@ -2441,7 +2560,7 @@ if (!expr2) return NULL; - return Assert(expr1, expr2, LINENO(n), n->n_col_offset, c->c_arena); + return Assert(expr1, expr2, LINENO(n), n->n_col_offset, c->c_arena); } PyErr_Format(PyExc_SystemError, "improper number of parts to 'assert' statement: %d", @@ -2463,53 +2582,53 @@ total = num_stmts(n); seq = asdl_seq_new(total, c->c_arena); if (!seq) - return NULL; + return NULL; if (TYPE(CHILD(n, 0)) == simple_stmt) { - n = CHILD(n, 0); - /* simple_stmt always ends with a NEWLINE, - and may have a trailing SEMI - */ - end = NCH(n) - 1; - if (TYPE(CHILD(n, end - 1)) == SEMI) - end--; + n = CHILD(n, 0); + /* simple_stmt always ends with a NEWLINE, + and may have a trailing SEMI + */ + end = NCH(n) - 1; + if (TYPE(CHILD(n, end - 1)) == SEMI) + end--; /* loop by 2 to skip semi-colons */ - for (i = 0; i < end; i += 2) { - ch = CHILD(n, i); - s = ast_for_stmt(c, ch); - if (!s) - return NULL; - asdl_seq_SET(seq, pos++, s); - } + for (i = 0; i < end; i += 2) { + ch = CHILD(n, i); + s = ast_for_stmt(c, ch); + if (!s) + return NULL; + asdl_seq_SET(seq, pos++, s); + } } else { - for (i = 2; i < (NCH(n) - 1); i++) { - ch = CHILD(n, i); - REQ(ch, stmt); - num = num_stmts(ch); - if (num == 1) { - /* small_stmt or compound_stmt with only one child */ - s = ast_for_stmt(c, ch); - if (!s) - return NULL; - asdl_seq_SET(seq, pos++, s); - } - else { - int j; - ch = CHILD(ch, 0); - REQ(ch, simple_stmt); - for (j = 0; j < NCH(ch); j += 2) { - /* statement terminates with a semi-colon ';' */ - if (NCH(CHILD(ch, j)) == 0) { - assert((j + 1) == NCH(ch)); - break; - } - s = ast_for_stmt(c, CHILD(ch, j)); - if (!s) - return NULL; - asdl_seq_SET(seq, pos++, s); - } - } - } + for (i = 2; i < (NCH(n) - 1); i++) { + ch = CHILD(n, i); + REQ(ch, stmt); + num = num_stmts(ch); + if (num == 1) { + /* small_stmt or compound_stmt with only one child */ + s = ast_for_stmt(c, ch); + if (!s) + return NULL; + asdl_seq_SET(seq, pos++, s); + } + else { + int j; + ch = CHILD(ch, 0); + REQ(ch, simple_stmt); + for (j = 0; j < NCH(ch); j += 2) { + /* statement terminates with a semi-colon ';' */ + if (NCH(CHILD(ch, j)) == 0) { + assert((j + 1) == NCH(ch)); + break; + } + s = ast_for_stmt(c, CHILD(ch, j)); + if (!s) + return NULL; + asdl_seq_SET(seq, pos++, s); + } + } + } } assert(pos == seq->size); return seq; @@ -2536,7 +2655,7 @@ if (!suite_seq) return NULL; - return If(expression, suite_seq, NULL, LINENO(n), n->n_col_offset, c->c_arena); + return If(expression, suite_seq, NULL, LINENO(n), n->n_col_offset, c->c_arena); } s = STR(CHILD(n, 4)); @@ -2558,28 +2677,28 @@ if (!seq2) return NULL; - return If(expression, seq1, seq2, LINENO(n), n->n_col_offset, c->c_arena); + return If(expression, seq1, seq2, LINENO(n), n->n_col_offset, c->c_arena); } else if (s[2] == 'i') { - int i, n_elif, has_else = 0; - asdl_seq *orelse = NULL; - n_elif = NCH(n) - 4; + int i, n_elif, has_else = 0; + asdl_seq *orelse = NULL; + n_elif = NCH(n) - 4; /* must reference the child n_elif+1 since 'else' token is third, not fourth, child from the end. */ - if (TYPE(CHILD(n, (n_elif + 1))) == NAME - && STR(CHILD(n, (n_elif + 1)))[2] == 's') { - has_else = 1; - n_elif -= 3; - } - n_elif /= 4; + if (TYPE(CHILD(n, (n_elif + 1))) == NAME + && STR(CHILD(n, (n_elif + 1)))[2] == 's') { + has_else = 1; + n_elif -= 3; + } + n_elif /= 4; - if (has_else) { + if (has_else) { expr_ty expression; asdl_seq *seq1, *seq2; - orelse = asdl_seq_new(1, c->c_arena); - if (!orelse) - return NULL; + orelse = asdl_seq_new(1, c->c_arena); + if (!orelse) + return NULL; expression = ast_for_expr(c, CHILD(n, NCH(n) - 6)); if (!expression) return NULL; @@ -2590,20 +2709,20 @@ if (!seq2) return NULL; - asdl_seq_SET(orelse, 0, If(expression, seq1, seq2, - LINENO(CHILD(n, NCH(n) - 6)), CHILD(n, NCH(n) - 6)->n_col_offset, + asdl_seq_SET(orelse, 0, If(expression, seq1, seq2, + LINENO(CHILD(n, NCH(n) - 6)), CHILD(n, NCH(n) - 6)->n_col_offset, c->c_arena)); - /* the just-created orelse handled the last elif */ - n_elif--; - } + /* the just-created orelse handled the last elif */ + n_elif--; + } - for (i = 0; i < n_elif; i++) { - int off = 5 + (n_elif - i - 1) * 4; + for (i = 0; i < n_elif; i++) { + int off = 5 + (n_elif - i - 1) * 4; expr_ty expression; asdl_seq *suite_seq; - asdl_seq *newobj = asdl_seq_new(1, c->c_arena); - if (!newobj) - return NULL; + asdl_seq *newobj = asdl_seq_new(1, c->c_arena); + if (!newobj) + return NULL; expression = ast_for_expr(c, CHILD(n, off)); if (!expression) return NULL; @@ -2611,14 +2730,14 @@ if (!suite_seq) return NULL; - asdl_seq_SET(newobj, 0, - If(expression, suite_seq, orelse, - LINENO(CHILD(n, off)), CHILD(n, off)->n_col_offset, c->c_arena)); - orelse = newobj; - } - return If(ast_for_expr(c, CHILD(n, 1)), - ast_for_suite(c, CHILD(n, 3)), - orelse, LINENO(n), n->n_col_offset, c->c_arena); + asdl_seq_SET(newobj, 0, + If(expression, suite_seq, orelse, + LINENO(CHILD(n, off)), CHILD(n, off)->n_col_offset, c->c_arena)); + orelse = newobj; + } + return If(ast_for_expr(c, CHILD(n, 1)), + ast_for_suite(c, CHILD(n, 3)), + orelse, LINENO(n), n->n_col_offset, c->c_arena); } PyErr_Format(PyExc_SystemError, @@ -2642,7 +2761,7 @@ suite_seq = ast_for_suite(c, CHILD(n, 3)); if (!suite_seq) return NULL; - return While(expression, suite_seq, NULL, LINENO(n), n->n_col_offset, c->c_arena); + return While(expression, suite_seq, NULL, LINENO(n), n->n_col_offset, c->c_arena); } else if (NCH(n) == 7) { expr_ty expression; @@ -2658,7 +2777,7 @@ if (!seq2) return NULL; - return While(expression, seq1, seq2, LINENO(n), n->n_col_offset, c->c_arena); + return While(expression, seq1, seq2, LINENO(n), n->n_col_offset, c->c_arena); } PyErr_Format(PyExc_SystemError, @@ -2678,7 +2797,7 @@ REQ(n, for_stmt); if (NCH(n) == 9) { - seq = ast_for_suite(c, CHILD(n, 8)); + seq = ast_for_suite(c, CHILD(n, 8)); if (!seq) return NULL; } @@ -2690,9 +2809,9 @@ /* Check the # of children rather than the length of _target, since for x, in ... has 1 element in _target, but still requires a Tuple. */ if (NCH(node_target) == 1) - target = (expr_ty)asdl_seq_GET(_target, 0); + target = (expr_ty)asdl_seq_GET(_target, 0); else - target = Tuple(_target, Store, LINENO(n), n->n_col_offset, c->c_arena); + target = Tuple(_target, Store, LINENO(n), n->n_col_offset, c->c_arena); expression = ast_for_testlist(c, CHILD(n, 3)); if (!expression) @@ -2717,7 +2836,7 @@ if (!suite_seq) return NULL; - return excepthandler(NULL, NULL, suite_seq, LINENO(exc), + return excepthandler(NULL, NULL, suite_seq, LINENO(exc), exc->n_col_offset, c->c_arena); } else if (NCH(exc) == 2) { @@ -2731,16 +2850,16 @@ if (!suite_seq) return NULL; - return excepthandler(expression, NULL, suite_seq, LINENO(exc), + return excepthandler(expression, NULL, suite_seq, LINENO(exc), exc->n_col_offset, c->c_arena); } else if (NCH(exc) == 4) { asdl_seq *suite_seq; expr_ty expression; - expr_ty e = ast_for_expr(c, CHILD(exc, 3)); - if (!e) + expr_ty e = ast_for_expr(c, CHILD(exc, 3)); + if (!e) return NULL; - if (!set_context(e, Store, CHILD(exc, 3))) + if (!set_context(e, Store, CHILD(exc, 3))) return NULL; expression = ast_for_expr(c, CHILD(exc, 1)); if (!expression) @@ -2749,7 +2868,7 @@ if (!suite_seq) return NULL; - return excepthandler(expression, e, suite_seq, LINENO(exc), + return excepthandler(expression, e, suite_seq, LINENO(exc), exc->n_col_offset, c->c_arena); } @@ -2804,8 +2923,8 @@ } if (n_except > 0) { - int i; - stmt_ty except_st; + int i; + stmt_ty except_st; /* process except statements to create a try ... except */ asdl_seq *handlers = asdl_seq_new(n_except, c->c_arena); if (handlers == NULL) @@ -2819,17 +2938,17 @@ asdl_seq_SET(handlers, i, e); } - except_st = TryExcept(body, handlers, orelse, LINENO(n), + except_st = TryExcept(body, handlers, orelse, LINENO(n), n->n_col_offset, c->c_arena); if (!finally) - return except_st; + return except_st; /* if a 'finally' is present too, we nest the TryExcept within a TryFinally to emulate try ... except ... finally */ - body = asdl_seq_new(1, c->c_arena); - if (body == NULL) - return NULL; - asdl_seq_SET(body, 0, except_st); + body = asdl_seq_new(1, c->c_arena); + if (body == NULL) + return NULL; + asdl_seq_SET(body, 0, except_st); } /* must be a try ... finally (except clauses are in body, if any exist) */ @@ -2841,10 +2960,6 @@ ast_for_with_var(struct compiling *c, const node *n) { REQ(n, with_var); - if (strcmp(STR(CHILD(n, 0)), "as") != 0) { - ast_error(n, "expected \"with [expr] as [var]\""); - return NULL; - } return ast_for_expr(c, CHILD(n, 1)); } @@ -2864,9 +2979,9 @@ if (!optional_vars) { return NULL; } - if (!set_context(optional_vars, Store, n)) { - return NULL; - } + if (!set_context(optional_vars, Store, n)) { + return NULL; + } suite_index = 4; } @@ -2875,7 +2990,7 @@ return NULL; } return With(context_expr, optional_vars, suite_seq, LINENO(n), - n->n_col_offset, c->c_arena); + n->n_col_offset, c->c_arena); } static stmt_ty @@ -2887,23 +3002,23 @@ REQ(n, classdef); if (!strcmp(STR(CHILD(n, 1)), "None")) { - ast_error(n, "assignment to None"); - return NULL; + ast_error(n, "assignment to None"); + return NULL; } if (NCH(n) == 4) { s = ast_for_suite(c, CHILD(n, 3)); if (!s) return NULL; - return ClassDef(NEW_IDENTIFIER(CHILD(n, 1)), NULL, s, LINENO(n), + return ClassDef(NEW_IDENTIFIER(CHILD(n, 1)), NULL, s, LINENO(n), n->n_col_offset, c->c_arena); } /* check for empty base list */ if (TYPE(CHILD(n,3)) == RPAR) { - s = ast_for_suite(c, CHILD(n,5)); - if (!s) - return NULL; - return ClassDef(NEW_IDENTIFIER(CHILD(n, 1)), NULL, s, LINENO(n), + s = ast_for_suite(c, CHILD(n,5)); + if (!s) + return NULL; + return ClassDef(NEW_IDENTIFIER(CHILD(n, 1)), NULL, s, LINENO(n), n->n_col_offset, c->c_arena); } @@ -2923,21 +3038,20 @@ ast_for_stmt(struct compiling *c, const node *n) { if (TYPE(n) == stmt) { - assert(NCH(n) == 1); - n = CHILD(n, 0); + assert(NCH(n) == 1); + n = CHILD(n, 0); } if (TYPE(n) == simple_stmt) { - assert(num_stmts(n) == 1); - n = CHILD(n, 0); + assert(num_stmts(n) == 1); + n = CHILD(n, 0); } if (TYPE(n) == small_stmt) { REQ(n, small_stmt); n = CHILD(n, 0); /* small_stmt: expr_stmt | print_stmt | del_stmt | pass_stmt - | flow_stmt | import_stmt | global_stmt | exec_stmt - | assert_stmt - */ - switch (TYPE(n)) { + | flow_stmt | import_stmt | global_stmt | assert_stmt + */ + switch (TYPE(n)) { case expr_stmt: return ast_for_expr_stmt(c, n); case print_stmt: @@ -2952,8 +3066,6 @@ return ast_for_import_stmt(c, n); case global_stmt: return ast_for_global_stmt(c, n); - case exec_stmt: - return ast_for_exec_stmt(c, n); case assert_stmt: return ast_for_assert_stmt(c, n); default: @@ -2965,11 +3077,11 @@ } else { /* compound_stmt: if_stmt | while_stmt | for_stmt | try_stmt - | funcdef | classdef - */ - node *ch = CHILD(n, 0); - REQ(n, compound_stmt); - switch (TYPE(ch)) { + | funcdef | classdef + */ + node *ch = CHILD(n, 0); + REQ(n, compound_stmt); + switch (TYPE(ch)) { case if_stmt: return ast_for_if_stmt(c, ch); case while_stmt: @@ -2989,144 +3101,144 @@ "unhandled small_stmt: TYPE=%d NCH=%d\n", TYPE(n), NCH(n)); return NULL; - } + } } } static PyObject * parsenumber(const char *s) { - const char *end; - long x; - double dx; + const char *end; + long x; + double dx; #ifndef WITHOUT_COMPLEX - Py_complex c; - int imflag; + Py_complex c; + int imflag; #endif - errno = 0; - end = s + strlen(s) - 1; + errno = 0; + end = s + strlen(s) - 1; #ifndef WITHOUT_COMPLEX - imflag = *end == 'j' || *end == 'J'; + imflag = *end == 'j' || *end == 'J'; #endif - if (*end == 'l' || *end == 'L') - return PyLong_FromString((char *)s, (char **)0, 0); - if (s[0] == '0') { - x = (long) PyOS_strtoul((char *)s, (char **)&end, 0); - if (x < 0 && errno == 0) { - return PyLong_FromString((char *)s, - (char **)0, - 0); - } - } - else - x = PyOS_strtol((char *)s, (char **)&end, 0); - if (*end == '\0') { - if (errno != 0) - return PyLong_FromString((char *)s, (char **)0, 0); - return PyInt_FromLong(x); - } - /* XXX Huge floats may silently fail */ + if (*end == 'l' || *end == 'L') + return PyLong_FromString((char *)s, (char **)0, 0); + if (s[0] == '0') { + x = (long) PyOS_strtoul((char *)s, (char **)&end, 0); + if (x < 0 && errno == 0) { + return PyLong_FromString((char *)s, + (char **)0, + 0); + } + } + else + x = PyOS_strtol((char *)s, (char **)&end, 0); + if (*end == '\0') { + if (errno != 0) + return PyLong_FromString((char *)s, (char **)0, 0); + return PyInt_FromLong(x); + } + /* XXX Huge floats may silently fail */ #ifndef WITHOUT_COMPLEX - if (imflag) { - c.real = 0.; - PyFPE_START_PROTECT("atof", return 0) - c.imag = PyOS_ascii_atof(s); - PyFPE_END_PROTECT(c) - return PyComplex_FromCComplex(c); - } - else + if (imflag) { + c.real = 0.; + PyFPE_START_PROTECT("atof", return 0) + c.imag = PyOS_ascii_atof(s); + PyFPE_END_PROTECT(c) + return PyComplex_FromCComplex(c); + } + else #endif - { - PyFPE_START_PROTECT("atof", return 0) - dx = PyOS_ascii_atof(s); - PyFPE_END_PROTECT(dx) - return PyFloat_FromDouble(dx); - } + { + PyFPE_START_PROTECT("atof", return 0) + dx = PyOS_ascii_atof(s); + PyFPE_END_PROTECT(dx) + return PyFloat_FromDouble(dx); + } } static PyObject * decode_utf8(const char **sPtr, const char *end, char* encoding) { #ifndef Py_USING_UNICODE - Py_FatalError("decode_utf8 should not be called in this build."); + Py_FatalError("decode_utf8 should not be called in this build."); return NULL; #else - PyObject *u, *v; - char *s, *t; - t = s = (char *)*sPtr; - /* while (s < end && *s != '\\') s++; */ /* inefficient for u".." */ - while (s < end && (*s & 0x80)) s++; - *sPtr = s; - u = PyUnicode_DecodeUTF8(t, s - t, NULL); - if (u == NULL) - return NULL; - v = PyUnicode_AsEncodedString(u, encoding, NULL); - Py_DECREF(u); - return v; + PyObject *u, *v; + char *s, *t; + t = s = (char *)*sPtr; + /* while (s < end && *s != '\\') s++; */ /* inefficient for u".." */ + while (s < end && (*s & 0x80)) s++; + *sPtr = s; + u = PyUnicode_DecodeUTF8(t, s - t, NULL); + if (u == NULL) + return NULL; + v = PyUnicode_AsEncodedString(u, encoding, NULL); + Py_DECREF(u); + return v; #endif } static PyObject * decode_unicode(const char *s, size_t len, int rawmode, const char *encoding) { - PyObject *v, *u; - char *buf; - char *p; - const char *end; - if (encoding == NULL) { - buf = (char *)s; - u = NULL; - } else if (strcmp(encoding, "iso-8859-1") == 0) { - buf = (char *)s; - u = NULL; - } else { - /* "\XX" may become "\u005c\uHHLL" (12 bytes) */ - u = PyString_FromStringAndSize((char *)NULL, len * 4); - if (u == NULL) - return NULL; - p = buf = PyString_AsString(u); - end = s + len; - while (s < end) { - if (*s == '\\') { - *p++ = *s++; - if (*s & 0x80) { - strcpy(p, "u005c"); - p += 5; - } - } - if (*s & 0x80) { /* XXX inefficient */ - PyObject *w; - char *r; - Py_ssize_t rn, i; - w = decode_utf8(&s, end, "utf-16-be"); - if (w == NULL) { - Py_DECREF(u); - return NULL; - } - r = PyString_AsString(w); - rn = PyString_Size(w); - assert(rn % 2 == 0); - for (i = 0; i < rn; i += 2) { - sprintf(p, "\\u%02x%02x", - r[i + 0] & 0xFF, - r[i + 1] & 0xFF); - p += 6; - } - Py_DECREF(w); - } else { - *p++ = *s++; - } - } - len = p - buf; - s = buf; - } - if (rawmode) - v = PyUnicode_DecodeRawUnicodeEscape(s, len, NULL); - else - v = PyUnicode_DecodeUnicodeEscape(s, len, NULL); - Py_XDECREF(u); - return v; + PyObject *v, *u; + char *buf; + char *p; + const char *end; + if (encoding == NULL) { + buf = (char *)s; + u = NULL; + } else if (strcmp(encoding, "iso-8859-1") == 0) { + buf = (char *)s; + u = NULL; + } else { + /* "\XX" may become "\u005c\uHHLL" (12 bytes) */ + u = PyString_FromStringAndSize((char *)NULL, len * 4); + if (u == NULL) + return NULL; + p = buf = PyString_AsString(u); + end = s + len; + while (s < end) { + if (*s == '\\') { + *p++ = *s++; + if (*s & 0x80) { + strcpy(p, "u005c"); + p += 5; + } + } + if (*s & 0x80) { /* XXX inefficient */ + PyObject *w; + char *r; + Py_ssize_t rn, i; + w = decode_utf8(&s, end, "utf-16-be"); + if (w == NULL) { + Py_DECREF(u); + return NULL; + } + r = PyString_AsString(w); + rn = PyString_Size(w); + assert(rn % 2 == 0); + for (i = 0; i < rn; i += 2) { + sprintf(p, "\\u%02x%02x", + r[i + 0] & 0xFF, + r[i + 1] & 0xFF); + p += 6; + } + Py_DECREF(w); + } else { + *p++ = *s++; + } + } + len = p - buf; + s = buf; + } + if (rawmode) + v = PyUnicode_DecodeRawUnicodeEscape(s, len, NULL); + else + v = PyUnicode_DecodeUnicodeEscape(s, len, NULL); + Py_XDECREF(u); + return v; } /* s is a Python string literal, including the bracketing quote characters, @@ -3136,75 +3248,75 @@ static PyObject * parsestr(const char *s, const char *encoding) { - size_t len; - int quote = Py_CHARMASK(*s); - int rawmode = 0; - int need_encoding; - int unicode = 0; - - if (isalpha(quote) || quote == '_') { - if (quote == 'u' || quote == 'U') { - quote = *++s; - unicode = 1; - } - if (quote == 'r' || quote == 'R') { - quote = *++s; - rawmode = 1; - } - } - if (quote != '\'' && quote != '\"') { - PyErr_BadInternalCall(); - return NULL; - } - s++; - len = strlen(s); - if (len > INT_MAX) { - PyErr_SetString(PyExc_OverflowError, - "string to parse is too long"); - return NULL; - } - if (s[--len] != quote) { - PyErr_BadInternalCall(); - return NULL; - } - if (len >= 4 && s[0] == quote && s[1] == quote) { - s += 2; - len -= 2; - if (s[--len] != quote || s[--len] != quote) { - PyErr_BadInternalCall(); - return NULL; - } - } + size_t len; + int quote = Py_CHARMASK(*s); + int rawmode = 0; + int need_encoding; + int unicode = 0; + + if (isalpha(quote) || quote == '_') { + if (quote == 'u' || quote == 'U') { + quote = *++s; + unicode = 1; + } + if (quote == 'r' || quote == 'R') { + quote = *++s; + rawmode = 1; + } + } + if (quote != '\'' && quote != '\"') { + PyErr_BadInternalCall(); + return NULL; + } + s++; + len = strlen(s); + if (len > INT_MAX) { + PyErr_SetString(PyExc_OverflowError, + "string to parse is too long"); + return NULL; + } + if (s[--len] != quote) { + PyErr_BadInternalCall(); + return NULL; + } + if (len >= 4 && s[0] == quote && s[1] == quote) { + s += 2; + len -= 2; + if (s[--len] != quote || s[--len] != quote) { + PyErr_BadInternalCall(); + return NULL; + } + } #ifdef Py_USING_UNICODE - if (unicode || Py_UnicodeFlag) { - return decode_unicode(s, len, rawmode, encoding); - } + if (unicode || Py_UnicodeFlag) { + return decode_unicode(s, len, rawmode, encoding); + } #endif - need_encoding = (encoding != NULL && - strcmp(encoding, "utf-8") != 0 && - strcmp(encoding, "iso-8859-1") != 0); - if (rawmode || strchr(s, '\\') == NULL) { - if (need_encoding) { + need_encoding = (encoding != NULL && + strcmp(encoding, "utf-8") != 0 && + strcmp(encoding, "iso-8859-1") != 0); + if (rawmode || strchr(s, '\\') == NULL) { + if (need_encoding) { #ifndef Py_USING_UNICODE - /* This should not happen - we never see any other - encoding. */ - Py_FatalError( + /* This should not happen - we never see any other + encoding. */ + Py_FatalError( "cannot deal with encodings in this build."); #else - PyObject *v, *u = PyUnicode_DecodeUTF8(s, len, NULL); - if (u == NULL) - return NULL; - v = PyUnicode_AsEncodedString(u, encoding, NULL); - Py_DECREF(u); - return v; + PyObject *v, *u = PyUnicode_DecodeUTF8(s, len, NULL); + if (u == NULL) + return NULL; + v = PyUnicode_AsEncodedString(u, encoding, NULL); + Py_DECREF(u); + return v; #endif - } else { - return PyString_FromStringAndSize(s, len); - } - } + } else { + return PyString_FromStringAndSize(s, len); + } + } - return PyString_DecodeEscape(s, len, NULL, unicode, - need_encoding ? encoding : NULL); + return PyString_DecodeEscape(s, len, NULL, unicode, + need_encoding ? encoding : NULL); } /* Build a Python string object out of a STRING atom. This takes care of @@ -3214,36 +3326,36 @@ static PyObject * parsestrplus(struct compiling *c, const node *n) { - PyObject *v; - int i; - REQ(CHILD(n, 0), STRING); - if ((v = parsestr(STR(CHILD(n, 0)), c->c_encoding)) != NULL) { - /* String literal concatenation */ - for (i = 1; i < NCH(n); i++) { - PyObject *s; - s = parsestr(STR(CHILD(n, i)), c->c_encoding); - if (s == NULL) - goto onError; - if (PyString_Check(v) && PyString_Check(s)) { - PyString_ConcatAndDel(&v, s); - if (v == NULL) - goto onError; - } + PyObject *v; + int i; + REQ(CHILD(n, 0), STRING); + if ((v = parsestr(STR(CHILD(n, 0)), c->c_encoding)) != NULL) { + /* String literal concatenation */ + for (i = 1; i < NCH(n); i++) { + PyObject *s; + s = parsestr(STR(CHILD(n, i)), c->c_encoding); + if (s == NULL) + goto onError; + if (PyString_Check(v) && PyString_Check(s)) { + PyString_ConcatAndDel(&v, s); + if (v == NULL) + goto onError; + } #ifdef Py_USING_UNICODE - else { - PyObject *temp = PyUnicode_Concat(v, s); - Py_DECREF(s); - Py_DECREF(v); - v = temp; - if (v == NULL) - goto onError; - } + else { + PyObject *temp = PyUnicode_Concat(v, s); + Py_DECREF(s); + Py_DECREF(v); + v = temp; + if (v == NULL) + goto onError; + } #endif - } - } - return v; + } + } + return v; onError: - Py_XDECREF(v); - return NULL; + Py_XDECREF(v); + return NULL; } Modified: python/branches/p3yk-noslice/Python/bltinmodule.c ============================================================================== --- python/branches/p3yk-noslice/Python/bltinmodule.c (original) +++ python/branches/p3yk-noslice/Python/bltinmodule.c Fri Dec 15 05:21:50 2006 @@ -403,7 +403,7 @@ "compile(source, filename, mode[, flags[, dont_inherit]]) -> code object\n\ \n\ Compile the source string (a Python module, statement or expression)\n\ -into a code object that can be executed by the exec statement or eval().\n\ +into a code object that can be executed by exec() or eval().\n\ The filename will be used for run-time error messages.\n\ The mode must be 'exec' to compile a module, 'single' to compile a\n\ single (interactive) statement, or 'eval' to compile an expression.\n\ @@ -539,10 +539,118 @@ Evaluate the source in the context of globals and locals.\n\ The source may be a string representing a Python expression\n\ or a code object as returned by compile().\n\ -The globals must be a dictionary and locals can be any mappping,\n\ +The globals must be a dictionary and locals can be any mapping,\n\ defaulting to the current globals and locals.\n\ If only globals is given, locals defaults to it.\n"); +static PyObject * +builtin_exec(PyObject *self, PyObject *args) +{ + PyObject *v; + PyObject *prog, *globals = Py_None, *locals = Py_None; + int plain = 0; + + if (!PyArg_ParseTuple(args, "O|OO:exec", &prog, &globals, &locals)) + return NULL; + + if (globals == Py_None) { + globals = PyEval_GetGlobals(); + if (locals == Py_None) { + locals = PyEval_GetLocals(); + plain = 1; + } + if (!globals || !locals) { + PyErr_SetString(PyExc_SystemError, + "globals and locals cannot be NULL"); + return NULL; + } + } + else if (locals == Py_None) + locals = globals; + if (!PyString_Check(prog) && + !PyUnicode_Check(prog) && + !PyCode_Check(prog) && + !PyFile_Check(prog)) { + PyErr_Format(PyExc_TypeError, + "exec() arg 1 must be a string, file, or code " + "object, not %.100s", prog->ob_type->tp_name); + return NULL; + } + if (!PyDict_Check(globals)) { + PyErr_Format(PyExc_TypeError, "exec() arg 2 must be a dict, not %.100s", + globals->ob_type->tp_name); + return NULL; + } + if (!PyMapping_Check(locals)) { + PyErr_Format(PyExc_TypeError, + "arg 3 must be a mapping or None, not %.100s", + locals->ob_type->tp_name); + return NULL; + } + if (PyDict_GetItemString(globals, "__builtins__") == NULL) { + if (PyDict_SetItemString(globals, "__builtins__", + PyEval_GetBuiltins()) != 0) + return NULL; + } + + if (PyCode_Check(prog)) { + if (PyCode_GetNumFree((PyCodeObject *)prog) > 0) { + PyErr_SetString(PyExc_TypeError, + "code object passed to exec() may not " + "contain free variables"); + return NULL; + } + v = PyEval_EvalCode((PyCodeObject *) prog, globals, locals); + } + else if (PyFile_Check(prog)) { + FILE *fp = PyFile_AsFile(prog); + char *name = PyString_AsString(PyFile_Name(prog)); + PyCompilerFlags cf; + cf.cf_flags = 0; + if (PyEval_MergeCompilerFlags(&cf)) + v = PyRun_FileFlags(fp, name, Py_file_input, globals, + locals, &cf); + else + v = PyRun_File(fp, name, Py_file_input, globals, + locals); + } + else { + PyObject *tmp = NULL; + char *str; + PyCompilerFlags cf; + cf.cf_flags = 0; +#ifdef Py_USING_UNICODE + if (PyUnicode_Check(prog)) { + tmp = PyUnicode_AsUTF8String(prog); + if (tmp == NULL) + return NULL; + prog = tmp; + cf.cf_flags |= PyCF_SOURCE_IS_UTF8; + } +#endif + if (PyString_AsStringAndSize(prog, &str, NULL)) + return NULL; + if (PyEval_MergeCompilerFlags(&cf)) + v = PyRun_StringFlags(str, Py_file_input, globals, + locals, &cf); + else + v = PyRun_String(str, Py_file_input, globals, locals); + Py_XDECREF(tmp); + } + if (v == NULL) + return NULL; + Py_DECREF(v); + Py_RETURN_NONE; +} + +PyDoc_STRVAR(exec_doc, +"exec(object[, globals[, locals]])\n\ +\n\ +Read and execute code from a object, which can be a string, a code\n\ +object or a file object.\n\ +The globals and locals are dictionaries, defaulting to the current\n\ +globals and locals. If only globals is given, locals defaults to it."); + static PyObject * builtin_execfile(PyObject *self, PyObject *args) @@ -1305,6 +1413,73 @@ +static PyObject * +builtin_print(PyObject *self, PyObject *args, PyObject *kwds) +{ + static char *kwlist[] = {"sep", "end", "file", 0}; + PyObject *dummy_args = PyTuple_New(0); + PyObject *sep = NULL, *end = NULL, *file = NULL; + int i, err; + + if (dummy_args == NULL) + return NULL; + if (!PyArg_ParseTupleAndKeywords(dummy_args, kwds, "|OOO:Print", + kwlist, &sep, &end, &file)) + return NULL; + if (file == NULL || file == Py_None) + file = PySys_GetObject("stdout"); + + if (sep && sep != Py_None && !PyString_Check(sep) && + !PyUnicode_Check(sep)) { + PyErr_Format(PyExc_TypeError, + "sep must be None, str or unicode, not %.200s", + sep->ob_type->tp_name); + return NULL; + } + if (end && end != Py_None && !PyString_Check(end) && + !PyUnicode_Check(end)) { + PyErr_Format(PyExc_TypeError, + "end must be None, str or unicode, not %.200s", + end->ob_type->tp_name); + return NULL; + } + + for (i = 0; i < PyTuple_Size(args); i++) { + if (i > 0) { + if (sep == NULL || sep == Py_None) + err = PyFile_WriteString(" ", file); + else + err = PyFile_WriteObject(sep, file, + Py_PRINT_RAW); + if (err) + return NULL; + } + err = PyFile_WriteObject(PyTuple_GetItem(args, i), file, + Py_PRINT_RAW); + if (err) + return NULL; + } + + if (end == NULL || end == Py_None) + err = PyFile_WriteString("\n", file); + else + err = PyFile_WriteObject(end, file, Py_PRINT_RAW); + if (err) + return NULL; + + Py_RETURN_NONE; +} + +PyDoc_STRVAR(print_doc, +"Print(value, ..., file=None, sep=' ', end='\\n')\n\ +\n\ +Prints the values to a stream, or to sys.stdout by default.\n\ +Optional keyword arguments:\n\ +file: a file-like object (stream); defaults to the current sys.stdout.\n\ +sep: string inserted between values, default a space.\n\ +end: string appended after the last value, default a newline."); + + /* Return number of items in range (lo, hi, step), when arguments are * PyInt or PyLong objects. step > 0 required. Return a value < 0 if * & only if the true value is too large to fit in a signed long. @@ -1324,9 +1499,10 @@ PyObject *tmp1 = NULL, *tmp2 = NULL, *tmp3 = NULL; /* holds sub-expression evaluations */ - /* if (lo >= hi), return length of 0. */ - if (PyObject_Compare(lo, hi) >= 0) - return 0; + /* If (lo >= hi), return length of 0 (or error). */ + n = PyObject_RichCompareBool(lo, hi, Py_LT); + if (n <= 0) + return n; if ((one = PyLong_FromLong(1L)) == NULL) goto Fail; @@ -1378,7 +1554,7 @@ PyObject *v = NULL; long bign; int i, n; - int cmp_result; + int step_pos; PyObject *zero = PyLong_FromLong(0); @@ -1439,18 +1615,22 @@ goto Fail; } - if (PyObject_Cmp(istep, zero, &cmp_result) == -1) - goto Fail; - if (cmp_result == 0) { - PyErr_SetString(PyExc_ValueError, - "range() step argument must not be zero"); + step_pos = PyObject_RichCompareBool(istep, zero, Py_GT); + if (step_pos < 0) goto Fail; - } - - if (cmp_result > 0) + if (step_pos) bign = get_len_of_range_longs(ilow, ihigh, istep); else { - PyObject *neg_istep = PyNumber_Negative(istep); + int step_zero = PyObject_RichCompareBool(istep, zero, Py_EQ); + PyObject *neg_istep; + if (step_zero < 0) + goto Fail; + if (step_zero) { + PyErr_SetString(PyExc_ValueError, + "range() step argument must not be zero"); + goto Fail; + } + neg_istep = PyNumber_Negative(istep); if (neg_istep == NULL) goto Fail; bign = get_len_of_range_longs(ihigh, ilow, neg_istep); @@ -1792,10 +1972,11 @@ } PyDoc_STRVAR(sum_doc, -"sum(sequence, start=0) -> value\n\ +"sum(sequence[, start]) -> value\n\ \n\ Returns the sum of a sequence of numbers (NOT strings) plus the value\n\ -of parameter 'start'. When the sequence is empty, returns start."); +of parameter 'start' (which defaults to 0). When the sequence is\n\ +empty, returns start."); static PyObject * @@ -1850,116 +2031,20 @@ static PyObject* builtin_zip(PyObject *self, PyObject *args) { - PyObject *ret; - const Py_ssize_t itemsize = PySequence_Length(args); - Py_ssize_t i; - PyObject *itlist; /* tuple of iterators */ - Py_ssize_t len; /* guess at result length */ - - if (itemsize == 0) - return PyList_New(0); - /* args must be a tuple */ assert(PyTuple_Check(args)); - /* Guess at result length: the shortest of the input lengths. - If some argument refuses to say, we refuse to guess too, lest - an argument like xrange(sys.maxint) lead us astray.*/ - len = -1; /* unknown */ - for (i = 0; i < itemsize; ++i) { - PyObject *item = PyTuple_GET_ITEM(args, i); - Py_ssize_t thislen = _PyObject_LengthHint(item); - if (thislen < 0) { - if (!PyErr_ExceptionMatches(PyExc_TypeError) && - !PyErr_ExceptionMatches(PyExc_AttributeError)) { - return NULL; - } - PyErr_Clear(); - len = -1; - break; - } - else if (len < 0 || thislen < len) - len = thislen; - } - - /* allocate result list */ - if (len < 0) - len = 10; /* arbitrary */ - if ((ret = PyList_New(len)) == NULL) - return NULL; - - /* obtain iterators */ - itlist = PyTuple_New(itemsize); - if (itlist == NULL) - goto Fail_ret; - for (i = 0; i < itemsize; ++i) { - PyObject *item = PyTuple_GET_ITEM(args, i); - PyObject *it = PyObject_GetIter(item); - if (it == NULL) { - if (PyErr_ExceptionMatches(PyExc_TypeError)) - PyErr_Format(PyExc_TypeError, - "zip argument #%zd must support iteration", - i+1); - goto Fail_ret_itlist; - } - PyTuple_SET_ITEM(itlist, i, it); - } - - /* build result into ret list */ - for (i = 0; ; ++i) { - int j; - PyObject *next = PyTuple_New(itemsize); - if (!next) - goto Fail_ret_itlist; - - for (j = 0; j < itemsize; j++) { - PyObject *it = PyTuple_GET_ITEM(itlist, j); - PyObject *item = PyIter_Next(it); - if (!item) { - if (PyErr_Occurred()) { - Py_DECREF(ret); - ret = NULL; - } - Py_DECREF(next); - Py_DECREF(itlist); - goto Done; - } - PyTuple_SET_ITEM(next, j, item); - } - - if (i < len) - PyList_SET_ITEM(ret, i, next); - else { - int status = PyList_Append(ret, next); - Py_DECREF(next); - ++len; - if (status < 0) - goto Fail_ret_itlist; - } - } - -Done: - if (ret != NULL && i < len) { - /* The list is too big. */ - if (PyList_SetSlice(ret, i, len, NULL) < 0) - return NULL; - } - return ret; - -Fail_ret_itlist: - Py_DECREF(itlist); -Fail_ret: - Py_DECREF(ret); - return NULL; + return _PyZip_CreateIter(args); } PyDoc_STRVAR(zip_doc, -"zip(seq1 [, seq2 [...]]) -> [(seq1[0], seq2[0] ...), (...)]\n\ +"zip(it1 [, it2 [...]]) -> iter([(it1[0], it2[0] ...), ...])\n\ \n\ -Return a list of tuples, where each tuple contains the i-th element\n\ -from each of the argument sequences. The returned list is truncated\n\ -in length to the length of the shortest argument sequence."); +Return an iterator yielding tuples, where each tuple contains the\n\ +corresponding element from each of the argument iterables.\n\ +The returned iterator ends when the shortest argument iterable is exhausted.\n\ +NOTE: This is implemented using itertools.izip()."); static PyMethodDef builtin_methods[] = { @@ -1975,6 +2060,7 @@ {"dir", builtin_dir, METH_VARARGS, dir_doc}, {"divmod", builtin_divmod, METH_VARARGS, divmod_doc}, {"eval", builtin_eval, METH_VARARGS, eval_doc}, + {"exec", builtin_exec, METH_VARARGS, exec_doc}, {"execfile", builtin_execfile, METH_VARARGS, execfile_doc}, {"filter", builtin_filter, METH_VARARGS, filter_doc}, {"getattr", builtin_getattr, METH_VARARGS, getattr_doc}, @@ -1996,6 +2082,7 @@ {"open", (PyCFunction)builtin_open, METH_VARARGS | METH_KEYWORDS, open_doc}, {"ord", builtin_ord, METH_O, ord_doc}, {"pow", builtin_pow, METH_VARARGS, pow_doc}, + {"Print", (PyCFunction)builtin_print, METH_VARARGS | METH_KEYWORDS, print_doc}, {"range", builtin_range, METH_VARARGS, range_doc}, {"reload", builtin_reload, METH_O, reload_doc}, {"repr", builtin_repr, METH_O, repr_doc}, Modified: python/branches/p3yk-noslice/Python/ceval.c ============================================================================== --- python/branches/p3yk-noslice/Python/ceval.c (original) +++ python/branches/p3yk-noslice/Python/ceval.c Fri Dec 15 05:21:50 2006 @@ -115,8 +115,6 @@ static PyObject * import_from(PyObject *, PyObject *); static int import_all_from(PyObject *, PyObject *); static PyObject * build_class(PyObject *, PyObject *, PyObject *); -static int exec_statement(PyFrameObject *, - PyObject *, PyObject *, PyObject *); static void set_exc_info(PyThreadState *, PyObject *, PyObject *, PyObject *); static void reset_exc_info(PyThreadState *); static void format_exc_check_arg(PyObject *, char *, PyObject *); @@ -183,10 +181,10 @@ PyObject * PyEval_GetCallStats(PyObject *self) { - return Py_BuildValue("iiiiiiiiii", + return Py_BuildValue("iiiiiiiiiii", pcall[0], pcall[1], pcall[2], pcall[3], pcall[4], pcall[5], pcall[6], pcall[7], - pcall[8], pcall[9]); + pcall[8], pcall[9], pcall[10]); } #else #define PCALL(O) @@ -493,7 +491,7 @@ (PyObject **)NULL, 0, (PyObject **)NULL, 0, (PyObject **)NULL, 0, - NULL); + NULL, NULL); } @@ -576,7 +574,6 @@ It's a case-by-case judgement. I'll use intr1 for the following cases: - EXEC_STMT IMPORT_STAR IMPORT_FROM CALL_FUNCTION (and friends) @@ -1036,14 +1033,6 @@ STACKADJ(-1); break; - case UNARY_CONVERT: - v = TOP(); - x = PyObject_Repr(v); - Py_DECREF(v); - SET_TOP(x); - if (x != NULL) continue; - break; - case UNARY_INVERT: v = TOP(); x = PyNumber_Invert(v); @@ -1562,19 +1551,6 @@ why = WHY_YIELD; goto fast_yield; - case EXEC_STMT: - w = TOP(); - v = SECOND(); - u = THIRD(); - STACKADJ(-3); - READ_TIMESTAMP(intr0); - err = exec_statement(f, u, v, w); - READ_TIMESTAMP(intr1); - Py_DECREF(u); - Py_DECREF(v); - Py_DECREF(w); - break; - case POP_BLOCK: { PyTryBlock *b = PyFrame_BlockPop(f); @@ -1885,6 +1861,24 @@ } break; + case BUILD_SET: + x = PySet_New(NULL); + if (x != NULL) { + for (; --oparg >= 0;) { + w = POP(); + if (err == 0) + err = PySet_Add(x, w); + Py_DECREF(w); + } + if (err != 0) { + Py_DECREF(x); + break; + } + PUSH(x); + continue; + } + break; + case BUILD_MAP: x = PyDict_New(); PUSH(x); @@ -2228,26 +2222,46 @@ } case MAKE_FUNCTION: + { + int posdefaults = oparg & 0xff; + int kwdefaults = (oparg>>8) & 0xff; + v = POP(); /* code object */ x = PyFunction_New(v, f->f_globals); Py_DECREF(v); /* XXX Maybe this should be a separate opcode? */ - if (x != NULL && oparg > 0) { - v = PyTuple_New(oparg); + if (x != NULL && posdefaults > 0) { + v = PyTuple_New(posdefaults); if (v == NULL) { Py_DECREF(x); x = NULL; break; } - while (--oparg >= 0) { + while (--posdefaults >= 0) { w = POP(); - PyTuple_SET_ITEM(v, oparg, w); + PyTuple_SET_ITEM(v, posdefaults, w); } err = PyFunction_SetDefaults(x, v); Py_DECREF(v); } + if (x != NULL && kwdefaults > 0) { + v = PyDict_New(); + if (v == NULL) { + Py_DECREF(x); + x = NULL; + break; + } + while (--kwdefaults >= 0) { + w = POP(); /* default value */ + u = POP(); /* kw only arg name */ + PyDict_SetItem(v, u, w); + } + err = PyFunction_SetKwDefaults(x, v); + Py_DECREF(v); + } PUSH(x); break; + } case MAKE_CLOSURE: { @@ -2515,7 +2529,7 @@ PyObject * PyEval_EvalCodeEx(PyCodeObject *co, PyObject *globals, PyObject *locals, PyObject **args, int argcount, PyObject **kws, int kwcount, - PyObject **defs, int defcount, PyObject *closure) + PyObject **defs, int defcount, PyObject *kwdefs, PyObject *closure) { register PyFrameObject *f; register PyObject *retval = NULL; @@ -2539,6 +2553,7 @@ freevars = f->f_localsplus + co->co_nlocals; if (co->co_argcount > 0 || + co->co_kwonlyargcount > 0 || co->co_flags & (CO_VARARGS | CO_VARKEYWORDS)) { int i; int n = argcount; @@ -2547,7 +2562,7 @@ kwdict = PyDict_New(); if (kwdict == NULL) goto fail; - i = co->co_argcount; + i = co->co_argcount + co->co_kwonlyargcount; if (co->co_flags & CO_VARARGS) i++; SETLOCAL(i, kwdict); @@ -2556,7 +2571,7 @@ if (!(co->co_flags & CO_VARARGS)) { PyErr_Format(PyExc_TypeError, "%.200s() takes %s %d " - "%sargument%s (%d given)", + "%spositional argument%s (%d given)", PyString_AsString(co->co_name), defcount ? "at most" : "exactly", co->co_argcount, @@ -2576,7 +2591,7 @@ u = PyTuple_New(argcount - n); if (u == NULL) goto fail; - SETLOCAL(co->co_argcount, u); + SETLOCAL(co->co_argcount + co->co_kwonlyargcount, u); for (i = n; i < argcount; i++) { x = args[i]; Py_INCREF(x); @@ -2594,7 +2609,9 @@ goto fail; } /* XXX slow -- speed up using dictionary? */ - for (j = 0; j < co->co_argcount; j++) { + for (j = 0; + j < co->co_argcount + co->co_kwonlyargcount; + j++) { PyObject *nm = PyTuple_GET_ITEM( co->co_varnames, j); int cmp = PyObject_RichCompareBool( @@ -2607,7 +2624,7 @@ /* Check errors from Compare */ if (PyErr_Occurred()) goto fail; - if (j >= co->co_argcount) { + if (j >= co->co_argcount + co->co_kwonlyargcount) { if (kwdict == NULL) { PyErr_Format(PyExc_TypeError, "%.200s() got an unexpected " @@ -2632,13 +2649,38 @@ SETLOCAL(j, value); } } + if (co->co_kwonlyargcount > 0) { + for (i = co->co_argcount; + i < co->co_argcount + co->co_kwonlyargcount; + i++) { + PyObject *name, *def; + if (GETLOCAL(i) != NULL) + continue; + name = PyTuple_GET_ITEM(co->co_varnames, i); + def = NULL; + if (kwdefs != NULL) + def = PyDict_GetItem(kwdefs, name); + if (def != NULL) { + Py_INCREF(def); + SETLOCAL(i, def); + continue; + } + PyErr_Format(PyExc_TypeError, + "%.200s() needs " + "keyword only argument %s", + PyString_AsString(co->co_name), + PyString_AsString(name)); + goto fail; + } + } if (argcount < co->co_argcount) { int m = co->co_argcount - defcount; for (i = argcount; i < m; i++) { if (GETLOCAL(i) == NULL) { PyErr_Format(PyExc_TypeError, "%.200s() takes %s %d " - "%sargument%s (%d given)", + "%spositional argument%s " + "(%d given)", PyString_AsString(co->co_name), ((co->co_flags & CO_VARARGS) || defcount) ? "at least" @@ -3503,12 +3545,14 @@ PyCodeObject *co = (PyCodeObject *)PyFunction_GET_CODE(func); PyObject *globals = PyFunction_GET_GLOBALS(func); PyObject *argdefs = PyFunction_GET_DEFAULTS(func); + PyObject *kwdefs = PyFunction_GET_KW_DEFAULTS(func); PyObject **d = NULL; int nd = 0; PCALL(PCALL_FUNCTION); PCALL(PCALL_FAST_FUNCTION); - if (argdefs == NULL && co->co_argcount == n && nk==0 && + if (argdefs == NULL && co->co_argcount == n && + co->co_kwonlyargcount == 0 && nk==0 && co->co_flags == (CO_OPTIMIZED | CO_NEWLOCALS | CO_NOFREE)) { PyFrameObject *f; PyObject *retval = NULL; @@ -3546,7 +3590,7 @@ } return PyEval_EvalCodeEx(co, globals, (PyObject *)NULL, (*pp_stack)-n, na, - (*pp_stack)-2*nk, nk, d, nd, + (*pp_stack)-2*nk, nk, d, nd, kwdefs, PyFunction_GET_CLOSURE(func)); } @@ -3867,8 +3911,10 @@ value = PyObject_GetAttr(v, name); if (value == NULL) err = -1; - else + else if (PyDict_CheckExact(locals)) err = PyDict_SetItem(locals, name, value); + else + err = PyObject_SetItem(locals, name, value); Py_DECREF(name); Py_XDECREF(value); if (err != 0) @@ -3930,107 +3976,6 @@ return result; } -static int -exec_statement(PyFrameObject *f, PyObject *prog, PyObject *globals, - PyObject *locals) -{ - int n; - PyObject *v; - int plain = 0; - - if (PyTuple_Check(prog) && globals == Py_None && locals == Py_None && - ((n = PyTuple_Size(prog)) == 2 || n == 3)) { - /* Backward compatibility hack */ - globals = PyTuple_GetItem(prog, 1); - if (n == 3) - locals = PyTuple_GetItem(prog, 2); - prog = PyTuple_GetItem(prog, 0); - } - if (globals == Py_None) { - globals = PyEval_GetGlobals(); - if (locals == Py_None) { - locals = PyEval_GetLocals(); - plain = 1; - } - if (!globals || !locals) { - PyErr_SetString(PyExc_SystemError, - "globals and locals cannot be NULL"); - return -1; - } - } - else if (locals == Py_None) - locals = globals; - if (!PyString_Check(prog) && - !PyUnicode_Check(prog) && - !PyCode_Check(prog) && - !PyFile_Check(prog)) { - PyErr_SetString(PyExc_TypeError, - "exec: arg 1 must be a string, file, or code object"); - return -1; - } - if (!PyDict_Check(globals)) { - PyErr_SetString(PyExc_TypeError, - "exec: arg 2 must be a dictionary or None"); - return -1; - } - if (!PyMapping_Check(locals)) { - PyErr_SetString(PyExc_TypeError, - "exec: arg 3 must be a mapping or None"); - return -1; - } - if (PyDict_GetItemString(globals, "__builtins__") == NULL) - PyDict_SetItemString(globals, "__builtins__", f->f_builtins); - if (PyCode_Check(prog)) { - if (PyCode_GetNumFree((PyCodeObject *)prog) > 0) { - PyErr_SetString(PyExc_TypeError, - "code object passed to exec may not contain free variables"); - return -1; - } - v = PyEval_EvalCode((PyCodeObject *) prog, globals, locals); - } - else if (PyFile_Check(prog)) { - FILE *fp = PyFile_AsFile(prog); - char *name = PyString_AsString(PyFile_Name(prog)); - PyCompilerFlags cf; - cf.cf_flags = 0; - if (PyEval_MergeCompilerFlags(&cf)) - v = PyRun_FileFlags(fp, name, Py_file_input, globals, - locals, &cf); - else - v = PyRun_File(fp, name, Py_file_input, globals, - locals); - } - else { - PyObject *tmp = NULL; - char *str; - PyCompilerFlags cf; - cf.cf_flags = 0; -#ifdef Py_USING_UNICODE - if (PyUnicode_Check(prog)) { - tmp = PyUnicode_AsUTF8String(prog); - if (tmp == NULL) - return -1; - prog = tmp; - cf.cf_flags |= PyCF_SOURCE_IS_UTF8; - } -#endif - if (PyString_AsStringAndSize(prog, &str, NULL)) - return -1; - if (PyEval_MergeCompilerFlags(&cf)) - v = PyRun_StringFlags(str, Py_file_input, globals, - locals, &cf); - else - v = PyRun_String(str, Py_file_input, globals, locals); - Py_XDECREF(tmp); - } - if (plain) - PyFrame_LocalsToFast(f, 0); - if (v == NULL) - return -1; - Py_DECREF(v); - return 0; -} - static void format_exc_check_arg(PyObject *exc, char *format_str, PyObject *obj) { Modified: python/branches/p3yk-noslice/Python/compile.c ============================================================================== --- python/branches/p3yk-noslice/Python/compile.c (original) +++ python/branches/p3yk-noslice/Python/compile.c Fri Dec 15 05:21:50 2006 @@ -6,9 +6,10 @@ * object: * 1. Checks for future statements. See future.c * 2. Builds a symbol table. See symtable.c. - * 3. Generate code for basic blocks. See compiler_mod() in this file. + * 3. Generate code for basic blocks. See compiler_mod() in this file. * 4. Assemble the basic blocks into final code. See assemble() in - * this file. + * this file. + * 5. Optimize the byte code (peephole optimizations). See peephole.c * * Note that compiler_mod() suggests module, but the module ast type * (mod_ty) has cases for expressions and interactive statements. @@ -16,7 +17,8 @@ * CAUTION: The VISIT_* macros abort the current function when they * encounter a problem. So don't invoke them when there is memory * which needs to be released. Code blocks are OK, as the compiler - * structure takes care of releasing those. + * structure takes care of releasing those. Use the arena to manage + * objects. */ #include "Python.h" @@ -32,16 +34,6 @@ int Py_OptimizeFlag = 0; -/* - ISSUES: - - opcode_stack_effect() function should be reviewed since stack depth bugs - could be really hard to find later. - - Dead code is being generated (i.e. after unconditional jumps). - XXX(nnorwitz): not sure this is still true -*/ - #define DEFAULT_BLOCK_SIZE 16 #define DEFAULT_BLOCKS 8 #define DEFAULT_CODE_SIZE 128 @@ -115,11 +107,12 @@ PyObject *u_private; /* for private name mangling */ int u_argcount; /* number of arguments for block */ - /* Pointer to the most recently allocated block. By following b_list - members, you can reach all early allocated blocks. */ + int u_kwonlyargcount; /* number of keyword only arguments for block */ + /* Pointer to the most recently allocated block. By following b_list + members, you can reach all early allocated blocks. */ basicblock *u_blocks; basicblock *u_curblock; /* pointer to current block */ - int u_tmpname; /* temporary variables for list comps */ + int u_tmpname; /* temporary variables for list comps */ int u_nfblocks; struct fblockinfo u_fblock[CO_MAXBLOCKS]; @@ -152,17 +145,6 @@ PyArena *c_arena; /* pointer to memory allocation arena */ }; -struct assembler { - PyObject *a_bytecode; /* string containing bytecode */ - int a_offset; /* offset into bytecode */ - int a_nblocks; /* number of reachable blocks */ - basicblock **a_postorder; /* list of blocks in dfs postorder */ - PyObject *a_lnotab; /* string containing lnotab */ - int a_lnotab_off; /* offset into lnotab */ - int a_lineno; /* last lineno of emitted instruction */ - int a_lineno_off; /* bytecode offset of last lineno */ -}; - static int compiler_enter_scope(struct compiler *, identifier, void *, int); static void compiler_free(struct compiler *); static basicblock *compiler_new_block(struct compiler *); @@ -187,6 +169,8 @@ basicblock *); static void compiler_pop_fblock(struct compiler *, enum fblocktype, basicblock *); +/* Returns true if there is a loop on the fblock stack. */ +static int compiler_in_loop(struct compiler *); static int inplace_binop(struct compiler *, operator_ty); static int expr_constant(expr_ty e); @@ -394,47 +378,6 @@ return dest; } -/* - -Leave this debugging code for just a little longer. - -static void -compiler_display_symbols(PyObject *name, PyObject *symbols) -{ -PyObject *key, *value; -int flags; -Py_ssize_t pos = 0; - -fprintf(stderr, "block %s\n", PyString_AS_STRING(name)); -while (PyDict_Next(symbols, &pos, &key, &value)) { -flags = PyInt_AsLong(value); -fprintf(stderr, "var %s:", PyString_AS_STRING(key)); -if (flags & DEF_GLOBAL) -fprintf(stderr, " declared_global"); -if (flags & DEF_LOCAL) -fprintf(stderr, " local"); -if (flags & DEF_PARAM) -fprintf(stderr, " param"); -if (flags & DEF_STAR) -fprintf(stderr, " stararg"); -if (flags & DEF_DOUBLESTAR) -fprintf(stderr, " starstar"); -if (flags & DEF_INTUPLE) -fprintf(stderr, " tuple"); -if (flags & DEF_FREE) -fprintf(stderr, " free"); -if (flags & DEF_FREE_GLOBAL) -fprintf(stderr, " global"); -if (flags & DEF_FREE_CLASS) -fprintf(stderr, " free/class"); -if (flags & DEF_IMPORT) -fprintf(stderr, " import"); -fprintf(stderr, "\n"); -} - fprintf(stderr, "\n"); -} -*/ - static void compiler_unit_check(struct compiler_unit *u) { @@ -494,6 +437,7 @@ } memset(u, 0, sizeof(struct compiler_unit)); u->u_argcount = 0; + u->u_kwonlyargcount = 0; u->u_ste = PySymtable_Lookup(c->c_st, key); if (!u->u_ste) { compiler_unit_free(u); @@ -608,7 +552,7 @@ return NULL; } memset((void *)b, 0, sizeof(basicblock)); - /* Extend the singly linked list of blocks with new block. */ + /* Extend the singly linked list of blocks with new block. */ b->b_list = u->u_blocks; u->u_blocks = b; return b; @@ -647,7 +591,7 @@ /* Returns the offset of the next instruction in the current block's b_instr array. Resizes the b_instr as necessary. Returns -1 on failure. - */ +*/ static int compiler_next_instr(struct compiler *c, basicblock *b) @@ -691,7 +635,7 @@ already been set. If it has been set, the call has no effect. Every time a new node is b - */ +*/ static void compiler_set_lineno(struct compiler *c, int off) @@ -721,7 +665,6 @@ case UNARY_POSITIVE: case UNARY_NEGATIVE: case UNARY_NOT: - case UNARY_CONVERT: case UNARY_INVERT: return 0; @@ -788,8 +731,6 @@ return -1; case IMPORT_STAR: return -1; - case EXEC_STMT: - return -3; case YIELD_VALUE: return 0; @@ -825,6 +766,7 @@ return 1; case BUILD_TUPLE: case BUILD_LIST: + case BUILD_SET: return 1-oparg; case BUILD_MAP: return 1; @@ -871,9 +813,9 @@ return -NARGS(oparg)-1; case CALL_FUNCTION_VAR_KW: return -NARGS(oparg)-2; -#undef NARGS case MAKE_FUNCTION: - return -oparg; + return -NARGS(oparg); +#undef NARGS case BUILD_SLICE: if (oparg == 3) return -2; @@ -932,6 +874,8 @@ v = PyDict_GetItem(dict, t); if (!v) { + if (PyErr_Occurred()) + return -1; arg = PyDict_Size(dict); v = PyInt_FromLong(arg); if (!v) { @@ -1024,8 +968,8 @@ from the current block to the new block. */ -/* XXX The returns inside these macros make it impossible to decref - objects created in the local function. +/* The returns inside these macros make it impossible to decref objects + created in the local function. Local objects should use the arena. */ @@ -1320,6 +1264,25 @@ } static int +compiler_visit_kwonlydefaults(struct compiler *c, asdl_seq *kwonlyargs, + asdl_seq *kw_defaults) +{ + int i, default_count = 0; + for (i = 0; i < asdl_seq_LEN(kwonlyargs); i++) { + expr_ty arg = asdl_seq_GET(kwonlyargs, i); + expr_ty default_ = asdl_seq_GET(kw_defaults, i); + if (default_) { + ADDOP_O(c, LOAD_CONST, arg->v.Name.id, consts); + if (!compiler_visit_expr(c, default_)) { + return -1; + } + default_count++; + } + } + return default_count; +} + +static int compiler_function(struct compiler *c, stmt_ty s) { PyCodeObject *co; @@ -1327,14 +1290,22 @@ arguments_ty args = s->v.FunctionDef.args; asdl_seq* decos = s->v.FunctionDef.decorators; stmt_ty st; - int i, n, docstring; + int i, n, docstring, kw_default_count = 0, arglength; assert(s->kind == FunctionDef_kind); if (!compiler_decorators(c, decos)) return 0; + if (args->kwonlyargs) { + int res = compiler_visit_kwonlydefaults(c, args->kwonlyargs, + args->kw_defaults); + if (res < 0) + return 0; + kw_default_count = res; + } if (args->defaults) VISIT_SEQ(c, expr, args->defaults); + if (!compiler_enter_scope(c, s->v.FunctionDef.name, (void *)s, s->lineno)) return 0; @@ -1352,6 +1323,7 @@ compiler_arguments(c, args); c->u->u_argcount = asdl_seq_LEN(args->args); + c->u->u_kwonlyargcount = asdl_seq_LEN(args->kwonlyargs); n = asdl_seq_LEN(s->v.FunctionDef.body); /* if there was a docstring, we need to skip the first statement */ for (i = docstring; i < n; i++) { @@ -1363,7 +1335,9 @@ if (co == NULL) return 0; - compiler_make_closure(c, co, asdl_seq_LEN(args->defaults)); + arglength = asdl_seq_LEN(args->defaults); + arglength |= kw_default_count << 8; + compiler_make_closure(c, co, arglength); Py_DECREF(co); for (i = 0; i < asdl_seq_LEN(decos); i++) { @@ -1458,6 +1432,7 @@ { PyCodeObject *co; static identifier name; + int kw_default_count = 0, arglength; arguments_ty args = e->v.Lambda.args; assert(e->kind == Lambda_kind); @@ -1467,6 +1442,12 @@ return 0; } + if (args->kwonlyargs) { + int res = compiler_visit_kwonlydefaults(c, args->kwonlyargs, + args->kw_defaults); + if (res < 0) return 0; + kw_default_count = res; + } if (args->defaults) VISIT_SEQ(c, expr, args->defaults); if (!compiler_enter_scope(c, name, (void *)e, e->lineno)) @@ -1476,6 +1457,7 @@ compiler_arguments(c, args); c->u->u_argcount = asdl_seq_LEN(args->args); + c->u->u_kwonlyargcount = asdl_seq_LEN(args->kwonlyargs); VISIT_IN_SCOPE(c, expr, e->v.Lambda.body); ADDOP_IN_SCOPE(c, RETURN_VALUE); co = assemble(c, 1); @@ -1483,7 +1465,9 @@ if (co == NULL) return 0; - compiler_make_closure(c, co, asdl_seq_LEN(args->defaults)); + arglength = asdl_seq_LEN(args->defaults); + arglength |= kw_default_count << 8; + compiler_make_closure(c, co, arglength); Py_DECREF(co); return 1; @@ -1653,6 +1637,8 @@ compiler_continue(struct compiler *c) { static const char LOOP_ERROR_MSG[] = "'continue' not properly in loop"; + static const char IN_FINALLY_ERROR_MSG[] = + "'continue' not supported inside 'finally' clause"; int i; if (!c->u->u_nfblocks) @@ -1664,15 +1650,18 @@ break; case EXCEPT: case FINALLY_TRY: - while (--i >= 0 && c->u->u_fblock[i].fb_type != LOOP) - ; + while (--i >= 0 && c->u->u_fblock[i].fb_type != LOOP) { + /* Prevent continue anywhere under a finally + even if hidden in a sub-try or except. */ + if (c->u->u_fblock[i].fb_type == FINALLY_END) + return compiler_error(c, IN_FINALLY_ERROR_MSG); + } if (i == -1) return compiler_error(c, LOOP_ERROR_MSG); ADDOP_JABS(c, CONTINUE_LOOP, c->u->u_fblock[i].fb_block); break; case FINALLY_END: - return compiler_error(c, - "'continue' not supported inside 'finally' clause"); + return compiler_error(c, IN_FINALLY_ERROR_MSG); } return 1; @@ -2015,7 +2004,7 @@ { int i, n; - /* Always assign a lineno to the next instruction for a stmt. */ + /* Always assign a lineno to the next instruction for a stmt. */ c->u->u_lineno = s->lineno; c->u->u_lineno_set = false; @@ -2083,21 +2072,6 @@ return compiler_import(c, s); case ImportFrom_kind: return compiler_from_import(c, s); - case Exec_kind: - VISIT(c, expr, s->v.Exec.body); - if (s->v.Exec.globals) { - VISIT(c, expr, s->v.Exec.globals); - if (s->v.Exec.locals) { - VISIT(c, expr, s->v.Exec.locals); - } else { - ADDOP(c, DUP_TOP); - } - } else { - ADDOP_O(c, LOAD_CONST, Py_None, consts); - ADDOP(c, DUP_TOP); - } - ADDOP(c, EXEC_STMT); - break; case Global_kind: break; case Expr_kind: @@ -2114,7 +2088,7 @@ case Pass_kind: break; case Break_kind: - if (!c->u->u_nfblocks) + if (!compiler_in_loop(c)) return compiler_error(c, "'break' outside loop"); ADDOP(c, BREAK_LOOP); break; @@ -2468,7 +2442,6 @@ } return 1; } -#undef CMPCAST static int compiler_call(struct compiler *c, expr_ty e) @@ -2568,7 +2541,7 @@ } ADDOP_JABS(c, JUMP_ABSOLUTE, start); compiler_use_next_block(c, anchor); - /* delete the append method added to locals */ + /* delete the temporary list name added to locals */ if (gen_index == 1) if (!compiler_nameop(c, tmpname, Del)) return 0; @@ -2581,15 +2554,9 @@ { identifier tmp; int rc = 0; - static identifier append; asdl_seq *generators = e->v.ListComp.generators; assert(e->kind == ListComp_kind); - if (!append) { - append = PyString_InternFromString("append"); - if (!append) - return 0; - } tmp = compiler_new_tmpname(c); if (!tmp) return 0; @@ -2734,6 +2701,8 @@ expr_constant(expr_ty e) { switch (e->kind) { + case Ellipsis_kind: + return 1; case Num_kind: return PyObject_IsTrue(e->v.Num.n); case Str_kind: @@ -2888,9 +2857,9 @@ { int i, n; - /* If expr e has a different line number than the last expr/stmt, - set a new line number for the next instruction. - */ + /* If expr e has a different line number than the last expr/stmt, + set a new line number for the next instruction. + */ if (e->lineno > c->u->u_lineno) { c->u->u_lineno = e->lineno; c->u->u_lineno_set = false; @@ -2927,6 +2896,11 @@ ADDOP(c, STORE_SUBSCR); } break; + case Set_kind: + n = asdl_seq_LEN(e->v.Set.elts); + VISIT_SEQ(c, expr, e->v.Set.elts); + ADDOP_I(c, BUILD_SET, n); + break; case ListComp_kind: return compiler_listcomp(c, e); case GeneratorExp_kind: @@ -2934,14 +2908,6 @@ case Yield_kind: if (c->u->u_ste->ste_type != FunctionBlock) return compiler_error(c, "'yield' outside function"); - /* - for (i = 0; i < c->u->u_nfblocks; i++) { - if (c->u->u_fblock[i].fb_type == FINALLY_TRY) - return compiler_error( - c, "'yield' not allowed in a 'try' " - "block with a 'finally' clause"); - } - */ if (e->v.Yield.value) { VISIT(c, expr, e->v.Yield.value); } @@ -2954,16 +2920,15 @@ return compiler_compare(c, e); case Call_kind: return compiler_call(c, e); - case Repr_kind: - VISIT(c, expr, e->v.Repr.value); - ADDOP(c, UNARY_CONVERT); - break; case Num_kind: ADDOP_O(c, LOAD_CONST, e->v.Num.n, consts); break; case Str_kind: ADDOP_O(c, LOAD_CONST, e->v.Str.s, consts); break; + case Ellipsis_kind: + ADDOP_O(c, LOAD_CONST, Py_Ellipsis, consts); + break; /* The following exprs can be assignment targets. */ case Attribute_kind: if (e->v.Attribute.ctx != AugStore) @@ -3080,8 +3045,11 @@ compiler_push_fblock(struct compiler *c, enum fblocktype t, basicblock *b) { struct fblockinfo *f; - if (c->u->u_nfblocks >= CO_MAXBLOCKS) + if (c->u->u_nfblocks >= CO_MAXBLOCKS) { + PyErr_SetString(PyExc_SystemError, + "too many statically nested blocks"); return 0; + } f = &c->u->u_fblock[c->u->u_nfblocks++]; f->fb_type = t; f->fb_block = b; @@ -3098,6 +3066,16 @@ assert(u->u_fblock[u->u_nfblocks].fb_block == b); } +static int +compiler_in_loop(struct compiler *c) { + int i; + struct compiler_unit *u = c->u; + for (i = 0; i < u->u_nfblocks; ++i) { + if (u->u_fblock[i].fb_type == LOOP) + return 1; + } + return 0; +} /* Raises a SyntaxError and returns 0. If something goes wrong, a different exception may be raised. */ @@ -3191,9 +3169,6 @@ expr_context_ty ctx) { switch (s->kind) { - case Ellipsis_kind: - ADDOP_O(c, LOAD_CONST, Py_Ellipsis, consts); - break; case Slice_kind: return compiler_slice(c, s, ctx); case Index_kind: @@ -3208,7 +3183,6 @@ return 1; } - static int compiler_visit_slice(struct compiler *c, slice_ty s, expr_context_ty ctx) { @@ -3220,12 +3194,6 @@ VISIT(c, expr, s->v.Index.value); } break; - case Ellipsis_kind: - kindname = "ellipsis"; - if (ctx != AugStore) { - ADDOP_O(c, LOAD_CONST, Py_Ellipsis, consts); - } - break; case Slice_kind: kindname = "slice"; if (ctx != AugStore) { @@ -3254,12 +3222,26 @@ return compiler_handle_subscr(c, kindname, ctx); } + +/* End of the compiler section, beginning of the assembler section */ + /* do depth-first search of basic block graph, starting with block. post records the block indices in post-order. XXX must handle implicit jumps from one block to next */ +struct assembler { + PyObject *a_bytecode; /* string containing bytecode */ + int a_offset; /* offset into bytecode */ + int a_nblocks; /* number of reachable blocks */ + basicblock **a_postorder; /* list of blocks in dfs postorder */ + PyObject *a_lnotab; /* string containing lnotab */ + int a_lnotab_off; /* offset into lnotab */ + int a_lineno; /* last lineno of emitted instruction */ + int a_lineno_off; /* bytecode offset of last lineno */ +}; + static void dfs(struct compiler *c, basicblock *b, struct assembler *a) { @@ -3729,7 +3711,8 @@ Py_DECREF(consts); consts = tmp; - co = PyCode_New(c->u->u_argcount, nlocals, stackdepth(c), flags, + co = PyCode_New(c->u->u_argcount, c->u->u_kwonlyargcount, + nlocals, stackdepth(c), flags, bytecode, consts, names, varnames, freevars, cellvars, filename, c->u->u_name, Modified: python/branches/p3yk-noslice/Python/errors.c ============================================================================== --- python/branches/p3yk-noslice/Python/errors.c (original) +++ python/branches/p3yk-noslice/Python/errors.c Fri Dec 15 05:21:50 2006 @@ -560,7 +560,8 @@ goto failure; } if (PyDict_GetItemString(dict, "__module__") == NULL) { - modulename = PyString_FromStringAndSize(name, (int)(dot-name)); + modulename = PyString_FromStringAndSize(name, + (Py_ssize_t)(dot-name)); if (modulename == NULL) goto failure; if (PyDict_SetItemString(dict, "__module__", modulename) != 0) Modified: python/branches/p3yk-noslice/Python/frozen.c ============================================================================== --- python/branches/p3yk-noslice/Python/frozen.c (original) +++ python/branches/p3yk-noslice/Python/frozen.c Fri Dec 15 05:21:50 2006 @@ -12,13 +12,14 @@ the appropriate bytes from M___main__.c. */ static unsigned char M___hello__[] = { - 99,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0, - 0,115,9,0,0,0,100,0,0,71,72,100,1,0,83,40, - 2,0,0,0,115,14,0,0,0,72,101,108,108,111,32,119, - 111,114,108,100,46,46,46,78,40,0,0,0,0,40,0,0, - 0,0,40,0,0,0,0,40,0,0,0,0,115,8,0,0, - 0,104,101,108,108,111,46,112,121,115,1,0,0,0,63,1, - 0,0,0,115,0,0,0,0, + 99,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0, + 0,64,0,0,0,115,9,0,0,0,100,0,0,71,72,100, + 1,0,83,40,2,0,0,0,115,14,0,0,0,72,101,108, + 108,111,32,119,111,114,108,100,46,46,46,78,40,0,0,0, + 0,40,0,0,0,0,40,0,0,0,0,40,0,0,0,0, + 115,8,0,0,0,104,101,108,108,111,46,112,121,115,8,0, + 0,0,60,109,111,100,117,108,101,62,1,0,0,0,115,0, + 0,0,0, }; #define SIZE (int)sizeof(M___hello__) Modified: python/branches/p3yk-noslice/Python/getargs.c ============================================================================== --- python/branches/p3yk-noslice/Python/getargs.c (original) +++ python/branches/p3yk-noslice/Python/getargs.c Fri Dec 15 05:21:50 2006 @@ -816,7 +816,7 @@ #endif else return converterr("string", arg, msgbuf, bufsize); - if ((int)strlen(*p) != PyString_Size(arg)) + if ((Py_ssize_t)strlen(*p) != PyString_Size(arg)) return converterr("string without null bytes", arg, msgbuf, bufsize); } @@ -883,7 +883,7 @@ format++; } else if (*p != NULL && - (int)strlen(*p) != PyString_Size(arg)) + (Py_ssize_t)strlen(*p) != PyString_Size(arg)) return converterr( "string without null bytes or None", arg, msgbuf, bufsize); @@ -1030,7 +1030,8 @@ PyMem_Free()ing it after usage */ - if ((int)strlen(PyString_AS_STRING(s)) != size) { + if ((Py_ssize_t)strlen(PyString_AS_STRING(s)) + != size) { Py_DECREF(s); return converterr( "(encoded string without NULL bytes)", @@ -1746,7 +1747,7 @@ /* For type constructors that don't take keyword args * * Sets a TypeError and returns 0 if the kwds dict is - * not emtpy, returns 1 otherwise + * not empty, returns 1 otherwise */ int _PyArg_NoKeywords(const char *funcname, PyObject *kw) Modified: python/branches/p3yk-noslice/Python/graminit.c ============================================================================== --- python/branches/p3yk-noslice/Python/graminit.c (original) +++ python/branches/p3yk-noslice/Python/graminit.c Fri Dec 15 05:21:50 2006 @@ -146,14 +146,16 @@ {27, 5}, {0, 1}, }; -static arc arcs_7_2[1] = { +static arc arcs_7_2[3] = { {19, 6}, + {27, 7}, + {0, 2}, }; static arc arcs_7_3[1] = { - {19, 7}, + {19, 8}, }; static arc arcs_7_4[1] = { - {26, 8}, + {26, 9}, }; static arc arcs_7_5[4] = { {24, 1}, @@ -162,30 +164,41 @@ {0, 5}, }; static arc arcs_7_6[2] = { - {27, 9}, + {27, 7}, {0, 6}, }; -static arc arcs_7_7[1] = { - {0, 7}, +static arc arcs_7_7[2] = { + {19, 10}, + {29, 3}, }; -static arc arcs_7_8[2] = { - {27, 5}, +static arc arcs_7_8[1] = { {0, 8}, }; -static arc arcs_7_9[1] = { - {29, 3}, +static arc arcs_7_9[2] = { + {27, 5}, + {0, 9}, +}; +static arc arcs_7_10[3] = { + {27, 7}, + {25, 11}, + {0, 10}, +}; +static arc arcs_7_11[1] = { + {26, 6}, }; -static state states_7[10] = { +static state states_7[12] = { {3, arcs_7_0}, {3, arcs_7_1}, - {1, arcs_7_2}, + {3, arcs_7_2}, {1, arcs_7_3}, {1, arcs_7_4}, {4, arcs_7_5}, {2, arcs_7_6}, - {1, arcs_7_7}, - {2, arcs_7_8}, - {1, arcs_7_9}, + {2, arcs_7_7}, + {1, arcs_7_8}, + {2, arcs_7_9}, + {3, arcs_7_10}, + {1, arcs_7_11}, }; static arc arcs_8_0[2] = { {19, 1}, @@ -253,7 +266,7 @@ {2, arcs_11_2}, {1, arcs_11_3}, }; -static arc arcs_12_0[9] = { +static arc arcs_12_0[8] = { {33, 1}, {34, 1}, {35, 1}, @@ -262,29 +275,28 @@ {38, 1}, {39, 1}, {40, 1}, - {41, 1}, }; static arc arcs_12_1[1] = { {0, 1}, }; static state states_12[2] = { - {9, arcs_12_0}, + {8, arcs_12_0}, {1, arcs_12_1}, }; static arc arcs_13_0[1] = { {9, 1}, }; static arc arcs_13_1[3] = { - {42, 2}, + {41, 2}, {25, 3}, {0, 1}, }; static arc arcs_13_2[2] = { - {43, 4}, + {42, 4}, {9, 4}, }; static arc arcs_13_3[2] = { - {43, 5}, + {42, 5}, {9, 5}, }; static arc arcs_13_4[1] = { @@ -303,6 +315,7 @@ {2, arcs_13_5}, }; static arc arcs_14_0[12] = { + {43, 1}, {44, 1}, {45, 1}, {46, 1}, @@ -314,7 +327,6 @@ {52, 1}, {53, 1}, {54, 1}, - {55, 1}, }; static arc arcs_14_1[1] = { {0, 1}, @@ -324,11 +336,11 @@ {1, arcs_14_1}, }; static arc arcs_15_0[1] = { - {56, 1}, + {55, 1}, }; static arc arcs_15_1[3] = { {26, 2}, - {57, 3}, + {56, 3}, {0, 1}, }; static arc arcs_15_2[2] = { @@ -369,10 +381,10 @@ {2, arcs_15_8}, }; static arc arcs_16_0[1] = { - {58, 1}, + {57, 1}, }; static arc arcs_16_1[1] = { - {59, 2}, + {58, 2}, }; static arc arcs_16_2[1] = { {0, 2}, @@ -383,7 +395,7 @@ {1, arcs_16_2}, }; static arc arcs_17_0[1] = { - {60, 1}, + {59, 1}, }; static arc arcs_17_1[1] = { {0, 1}, @@ -393,11 +405,11 @@ {1, arcs_17_1}, }; static arc arcs_18_0[5] = { + {60, 1}, {61, 1}, {62, 1}, {63, 1}, {64, 1}, - {65, 1}, }; static arc arcs_18_1[1] = { {0, 1}, @@ -407,7 +419,7 @@ {1, arcs_18_1}, }; static arc arcs_19_0[1] = { - {66, 1}, + {65, 1}, }; static arc arcs_19_1[1] = { {0, 1}, @@ -417,7 +429,7 @@ {1, arcs_19_1}, }; static arc arcs_20_0[1] = { - {67, 1}, + {66, 1}, }; static arc arcs_20_1[1] = { {0, 1}, @@ -427,7 +439,7 @@ {1, arcs_20_1}, }; static arc arcs_21_0[1] = { - {68, 1}, + {67, 1}, }; static arc arcs_21_1[2] = { {9, 2}, @@ -442,7 +454,7 @@ {1, arcs_21_2}, }; static arc arcs_22_0[1] = { - {43, 1}, + {42, 1}, }; static arc arcs_22_1[1] = { {0, 1}, @@ -452,7 +464,7 @@ {1, arcs_22_1}, }; static arc arcs_23_0[1] = { - {69, 1}, + {68, 1}, }; static arc arcs_23_1[2] = { {26, 2}, @@ -485,8 +497,8 @@ {1, arcs_23_6}, }; static arc arcs_24_0[2] = { + {69, 1}, {70, 1}, - {71, 1}, }; static arc arcs_24_1[1] = { {0, 1}, @@ -496,10 +508,10 @@ {1, arcs_24_1}, }; static arc arcs_25_0[1] = { - {72, 1}, + {71, 1}, }; static arc arcs_25_1[1] = { - {73, 2}, + {72, 2}, }; static arc arcs_25_2[1] = { {0, 2}, @@ -510,30 +522,30 @@ {1, arcs_25_2}, }; static arc arcs_26_0[1] = { - {74, 1}, + {73, 1}, }; static arc arcs_26_1[2] = { - {75, 2}, + {74, 2}, {12, 3}, }; static arc arcs_26_2[3] = { - {75, 2}, + {74, 2}, {12, 3}, - {72, 4}, + {71, 4}, }; static arc arcs_26_3[1] = { - {72, 4}, + {71, 4}, }; static arc arcs_26_4[3] = { {28, 5}, {13, 6}, - {76, 5}, + {75, 5}, }; static arc arcs_26_5[1] = { {0, 5}, }; static arc arcs_26_6[1] = { - {76, 7}, + {75, 7}, }; static arc arcs_26_7[1] = { {15, 5}, @@ -552,7 +564,7 @@ {19, 1}, }; static arc arcs_27_1[2] = { - {78, 2}, + {77, 2}, {0, 1}, }; static arc arcs_27_2[1] = { @@ -571,7 +583,7 @@ {12, 1}, }; static arc arcs_28_1[2] = { - {78, 2}, + {77, 2}, {0, 1}, }; static arc arcs_28_2[1] = { @@ -587,14 +599,14 @@ {1, arcs_28_3}, }; static arc arcs_29_0[1] = { - {77, 1}, + {76, 1}, }; static arc arcs_29_1[2] = { {27, 2}, {0, 1}, }; static arc arcs_29_2[2] = { - {77, 1}, + {76, 1}, {0, 2}, }; static state states_29[3] = { @@ -603,7 +615,7 @@ {2, arcs_29_2}, }; static arc arcs_30_0[1] = { - {79, 1}, + {78, 1}, }; static arc arcs_30_1[2] = { {27, 0}, @@ -617,7 +629,7 @@ {19, 1}, }; static arc arcs_31_1[2] = { - {75, 0}, + {74, 0}, {0, 1}, }; static state states_31[2] = { @@ -625,7 +637,7 @@ {2, arcs_31_1}, }; static arc arcs_32_0[1] = { - {80, 1}, + {79, 1}, }; static arc arcs_32_1[1] = { {19, 2}, @@ -640,78 +652,82 @@ {2, arcs_32_2}, }; static arc arcs_33_0[1] = { - {81, 1}, + {80, 1}, }; static arc arcs_33_1[1] = { - {82, 2}, + {26, 2}, }; static arc arcs_33_2[2] = { - {83, 3}, + {27, 3}, {0, 2}, }; static arc arcs_33_3[1] = { {26, 4}, }; -static arc arcs_33_4[2] = { - {27, 5}, +static arc arcs_33_4[1] = { {0, 4}, }; -static arc arcs_33_5[1] = { - {26, 6}, -}; -static arc arcs_33_6[1] = { - {0, 6}, -}; -static state states_33[7] = { +static state states_33[5] = { {1, arcs_33_0}, {1, arcs_33_1}, {2, arcs_33_2}, {1, arcs_33_3}, - {2, arcs_33_4}, - {1, arcs_33_5}, - {1, arcs_33_6}, + {1, arcs_33_4}, }; -static arc arcs_34_0[1] = { +static arc arcs_34_0[7] = { + {81, 1}, + {82, 1}, + {83, 1}, {84, 1}, + {85, 1}, + {17, 1}, + {86, 1}, }; static arc arcs_34_1[1] = { + {0, 1}, +}; +static state states_34[2] = { + {7, arcs_34_0}, + {1, arcs_34_1}, +}; +static arc arcs_35_0[1] = { + {87, 1}, +}; +static arc arcs_35_1[1] = { {26, 2}, }; -static arc arcs_34_2[2] = { - {27, 3}, - {0, 2}, +static arc arcs_35_2[1] = { + {21, 3}, }; -static arc arcs_34_3[1] = { - {26, 4}, +static arc arcs_35_3[1] = { + {22, 4}, }; -static arc arcs_34_4[1] = { +static arc arcs_35_4[3] = { + {88, 1}, + {89, 5}, {0, 4}, }; -static state states_34[5] = { - {1, arcs_34_0}, - {1, arcs_34_1}, - {2, arcs_34_2}, - {1, arcs_34_3}, - {1, arcs_34_4}, +static arc arcs_35_5[1] = { + {21, 6}, }; -static arc arcs_35_0[7] = { - {85, 1}, - {86, 1}, - {87, 1}, - {88, 1}, - {89, 1}, - {17, 1}, - {90, 1}, +static arc arcs_35_6[1] = { + {22, 7}, }; -static arc arcs_35_1[1] = { - {0, 1}, +static arc arcs_35_7[1] = { + {0, 7}, }; -static state states_35[2] = { - {7, arcs_35_0}, +static state states_35[8] = { + {1, arcs_35_0}, {1, arcs_35_1}, + {1, arcs_35_2}, + {1, arcs_35_3}, + {3, arcs_35_4}, + {1, arcs_35_5}, + {1, arcs_35_6}, + {1, arcs_35_7}, }; static arc arcs_36_0[1] = { - {91, 1}, + {90, 1}, }; static arc arcs_36_1[1] = { {26, 2}, @@ -722,9 +738,8 @@ static arc arcs_36_3[1] = { {22, 4}, }; -static arc arcs_36_4[3] = { - {92, 1}, - {93, 5}, +static arc arcs_36_4[2] = { + {89, 5}, {0, 4}, }; static arc arcs_36_5[1] = { @@ -741,323 +756,299 @@ {1, arcs_36_1}, {1, arcs_36_2}, {1, arcs_36_3}, - {3, arcs_36_4}, + {2, arcs_36_4}, {1, arcs_36_5}, {1, arcs_36_6}, {1, arcs_36_7}, }; static arc arcs_37_0[1] = { - {94, 1}, + {91, 1}, }; static arc arcs_37_1[1] = { - {26, 2}, + {58, 2}, }; static arc arcs_37_2[1] = { - {21, 3}, + {92, 3}, }; static arc arcs_37_3[1] = { - {22, 4}, + {9, 4}, }; -static arc arcs_37_4[2] = { - {93, 5}, - {0, 4}, +static arc arcs_37_4[1] = { + {21, 5}, }; static arc arcs_37_5[1] = { - {21, 6}, + {22, 6}, }; -static arc arcs_37_6[1] = { - {22, 7}, +static arc arcs_37_6[2] = { + {89, 7}, + {0, 6}, }; static arc arcs_37_7[1] = { - {0, 7}, + {21, 8}, +}; +static arc arcs_37_8[1] = { + {22, 9}, +}; +static arc arcs_37_9[1] = { + {0, 9}, }; -static state states_37[8] = { +static state states_37[10] = { {1, arcs_37_0}, {1, arcs_37_1}, {1, arcs_37_2}, {1, arcs_37_3}, - {2, arcs_37_4}, + {1, arcs_37_4}, {1, arcs_37_5}, - {1, arcs_37_6}, + {2, arcs_37_6}, {1, arcs_37_7}, + {1, arcs_37_8}, + {1, arcs_37_9}, }; static arc arcs_38_0[1] = { - {95, 1}, + {93, 1}, }; static arc arcs_38_1[1] = { - {59, 2}, + {21, 2}, }; static arc arcs_38_2[1] = { - {83, 3}, + {22, 3}, }; -static arc arcs_38_3[1] = { - {9, 4}, +static arc arcs_38_3[2] = { + {94, 4}, + {95, 5}, }; static arc arcs_38_4[1] = { - {21, 5}, + {21, 6}, }; static arc arcs_38_5[1] = { - {22, 6}, + {21, 7}, }; -static arc arcs_38_6[2] = { - {93, 7}, - {0, 6}, +static arc arcs_38_6[1] = { + {22, 8}, }; static arc arcs_38_7[1] = { - {21, 8}, -}; -static arc arcs_38_8[1] = { {22, 9}, }; +static arc arcs_38_8[4] = { + {94, 4}, + {89, 10}, + {95, 5}, + {0, 8}, +}; static arc arcs_38_9[1] = { {0, 9}, }; -static state states_38[10] = { +static arc arcs_38_10[1] = { + {21, 11}, +}; +static arc arcs_38_11[1] = { + {22, 12}, +}; +static arc arcs_38_12[2] = { + {95, 5}, + {0, 12}, +}; +static state states_38[13] = { {1, arcs_38_0}, {1, arcs_38_1}, {1, arcs_38_2}, - {1, arcs_38_3}, + {2, arcs_38_3}, {1, arcs_38_4}, {1, arcs_38_5}, - {2, arcs_38_6}, + {1, arcs_38_6}, {1, arcs_38_7}, - {1, arcs_38_8}, + {4, arcs_38_8}, {1, arcs_38_9}, + {1, arcs_38_10}, + {1, arcs_38_11}, + {2, arcs_38_12}, }; static arc arcs_39_0[1] = { {96, 1}, }; static arc arcs_39_1[1] = { - {21, 2}, + {26, 2}, }; -static arc arcs_39_2[1] = { - {22, 3}, +static arc arcs_39_2[2] = { + {97, 3}, + {21, 4}, }; -static arc arcs_39_3[2] = { - {97, 4}, - {98, 5}, +static arc arcs_39_3[1] = { + {21, 4}, }; static arc arcs_39_4[1] = { - {21, 6}, + {22, 5}, }; static arc arcs_39_5[1] = { - {21, 7}, -}; -static arc arcs_39_6[1] = { - {22, 8}, -}; -static arc arcs_39_7[1] = { - {22, 9}, -}; -static arc arcs_39_8[4] = { - {97, 4}, - {93, 10}, - {98, 5}, - {0, 8}, -}; -static arc arcs_39_9[1] = { - {0, 9}, -}; -static arc arcs_39_10[1] = { - {21, 11}, -}; -static arc arcs_39_11[1] = { - {22, 12}, -}; -static arc arcs_39_12[2] = { - {98, 5}, - {0, 12}, + {0, 5}, }; -static state states_39[13] = { +static state states_39[6] = { {1, arcs_39_0}, {1, arcs_39_1}, - {1, arcs_39_2}, - {2, arcs_39_3}, + {2, arcs_39_2}, + {1, arcs_39_3}, {1, arcs_39_4}, {1, arcs_39_5}, - {1, arcs_39_6}, - {1, arcs_39_7}, - {4, arcs_39_8}, - {1, arcs_39_9}, - {1, arcs_39_10}, - {1, arcs_39_11}, - {2, arcs_39_12}, }; static arc arcs_40_0[1] = { - {99, 1}, + {77, 1}, }; static arc arcs_40_1[1] = { - {26, 2}, -}; -static arc arcs_40_2[2] = { - {100, 3}, - {21, 4}, -}; -static arc arcs_40_3[1] = { - {21, 4}, -}; -static arc arcs_40_4[1] = { - {22, 5}, + {98, 2}, }; -static arc arcs_40_5[1] = { - {0, 5}, +static arc arcs_40_2[1] = { + {0, 2}, }; -static state states_40[6] = { +static state states_40[3] = { {1, arcs_40_0}, {1, arcs_40_1}, - {2, arcs_40_2}, - {1, arcs_40_3}, - {1, arcs_40_4}, - {1, arcs_40_5}, + {1, arcs_40_2}, }; static arc arcs_41_0[1] = { - {78, 1}, -}; -static arc arcs_41_1[1] = { - {82, 2}, -}; -static arc arcs_41_2[1] = { - {0, 2}, -}; -static state states_41[3] = { - {1, arcs_41_0}, - {1, arcs_41_1}, - {1, arcs_41_2}, -}; -static arc arcs_42_0[1] = { - {101, 1}, + {99, 1}, }; -static arc arcs_42_1[2] = { +static arc arcs_41_1[2] = { {26, 2}, {0, 1}, }; -static arc arcs_42_2[2] = { +static arc arcs_41_2[2] = { {27, 3}, {0, 2}, }; -static arc arcs_42_3[1] = { +static arc arcs_41_3[1] = { {26, 4}, }; -static arc arcs_42_4[1] = { +static arc arcs_41_4[1] = { {0, 4}, }; -static state states_42[5] = { - {1, arcs_42_0}, - {2, arcs_42_1}, - {2, arcs_42_2}, - {1, arcs_42_3}, - {1, arcs_42_4}, +static state states_41[5] = { + {1, arcs_41_0}, + {2, arcs_41_1}, + {2, arcs_41_2}, + {1, arcs_41_3}, + {1, arcs_41_4}, }; -static arc arcs_43_0[2] = { +static arc arcs_42_0[2] = { {3, 1}, {2, 2}, }; -static arc arcs_43_1[1] = { +static arc arcs_42_1[1] = { {0, 1}, }; -static arc arcs_43_2[1] = { - {102, 3}, +static arc arcs_42_2[1] = { + {100, 3}, }; -static arc arcs_43_3[1] = { +static arc arcs_42_3[1] = { {6, 4}, }; -static arc arcs_43_4[2] = { +static arc arcs_42_4[2] = { {6, 4}, - {103, 1}, + {101, 1}, }; -static state states_43[5] = { - {2, arcs_43_0}, - {1, arcs_43_1}, - {1, arcs_43_2}, - {1, arcs_43_3}, - {2, arcs_43_4}, +static state states_42[5] = { + {2, arcs_42_0}, + {1, arcs_42_1}, + {1, arcs_42_2}, + {1, arcs_42_3}, + {2, arcs_42_4}, }; -static arc arcs_44_0[1] = { - {105, 1}, +static arc arcs_43_0[1] = { + {103, 1}, }; -static arc arcs_44_1[2] = { +static arc arcs_43_1[2] = { {27, 2}, {0, 1}, }; -static arc arcs_44_2[1] = { - {105, 3}, +static arc arcs_43_2[1] = { + {103, 3}, }; -static arc arcs_44_3[2] = { +static arc arcs_43_3[2] = { {27, 4}, {0, 3}, }; -static arc arcs_44_4[2] = { - {105, 3}, +static arc arcs_43_4[2] = { + {103, 3}, {0, 4}, }; -static state states_44[5] = { - {1, arcs_44_0}, - {2, arcs_44_1}, - {1, arcs_44_2}, - {2, arcs_44_3}, - {2, arcs_44_4}, +static state states_43[5] = { + {1, arcs_43_0}, + {2, arcs_43_1}, + {1, arcs_43_2}, + {2, arcs_43_3}, + {2, arcs_43_4}, }; -static arc arcs_45_0[2] = { - {106, 1}, - {107, 1}, +static arc arcs_44_0[2] = { + {104, 1}, + {105, 1}, }; -static arc arcs_45_1[1] = { +static arc arcs_44_1[1] = { {0, 1}, }; -static state states_45[2] = { - {2, arcs_45_0}, - {1, arcs_45_1}, +static state states_44[2] = { + {2, arcs_44_0}, + {1, arcs_44_1}, }; -static arc arcs_46_0[1] = { - {108, 1}, +static arc arcs_45_0[1] = { + {106, 1}, }; -static arc arcs_46_1[2] = { +static arc arcs_45_1[2] = { {23, 2}, {21, 3}, }; -static arc arcs_46_2[1] = { +static arc arcs_45_2[1] = { {21, 3}, }; +static arc arcs_45_3[1] = { + {103, 4}, +}; +static arc arcs_45_4[1] = { + {0, 4}, +}; +static state states_45[5] = { + {1, arcs_45_0}, + {2, arcs_45_1}, + {1, arcs_45_2}, + {1, arcs_45_3}, + {1, arcs_45_4}, +}; +static arc arcs_46_0[2] = { + {104, 1}, + {107, 2}, +}; +static arc arcs_46_1[2] = { + {87, 3}, + {0, 1}, +}; +static arc arcs_46_2[1] = { + {0, 2}, +}; static arc arcs_46_3[1] = { - {105, 4}, + {104, 4}, }; static arc arcs_46_4[1] = { - {0, 4}, + {89, 5}, }; -static state states_46[5] = { - {1, arcs_46_0}, +static arc arcs_46_5[1] = { + {26, 2}, +}; +static state states_46[6] = { + {2, arcs_46_0}, {2, arcs_46_1}, {1, arcs_46_2}, {1, arcs_46_3}, {1, arcs_46_4}, + {1, arcs_46_5}, }; -static arc arcs_47_0[2] = { - {106, 1}, - {109, 2}, +static arc arcs_47_0[1] = { + {108, 1}, }; static arc arcs_47_1[2] = { - {91, 3}, + {109, 0}, {0, 1}, }; -static arc arcs_47_2[1] = { - {0, 2}, -}; -static arc arcs_47_3[1] = { - {106, 4}, -}; -static arc arcs_47_4[1] = { - {93, 5}, -}; -static arc arcs_47_5[1] = { - {26, 2}, -}; -static state states_47[6] = { - {2, arcs_47_0}, +static state states_47[2] = { + {1, arcs_47_0}, {2, arcs_47_1}, - {1, arcs_47_2}, - {1, arcs_47_3}, - {1, arcs_47_4}, - {1, arcs_47_5}, }; static arc arcs_48_0[1] = { {110, 1}, @@ -1070,76 +1061,75 @@ {1, arcs_48_0}, {2, arcs_48_1}, }; -static arc arcs_49_0[1] = { +static arc arcs_49_0[2] = { {112, 1}, + {113, 2}, }; -static arc arcs_49_1[2] = { - {113, 0}, - {0, 1}, -}; -static state states_49[2] = { - {1, arcs_49_0}, - {2, arcs_49_1}, +static arc arcs_49_1[1] = { + {110, 2}, }; -static arc arcs_50_0[2] = { - {114, 1}, - {115, 2}, -}; -static arc arcs_50_1[1] = { - {112, 2}, -}; -static arc arcs_50_2[1] = { +static arc arcs_49_2[1] = { {0, 2}, }; -static state states_50[3] = { - {2, arcs_50_0}, - {1, arcs_50_1}, - {1, arcs_50_2}, +static state states_49[3] = { + {2, arcs_49_0}, + {1, arcs_49_1}, + {1, arcs_49_2}, }; -static arc arcs_51_0[1] = { - {82, 1}, +static arc arcs_50_0[1] = { + {98, 1}, }; -static arc arcs_51_1[2] = { - {116, 0}, +static arc arcs_50_1[2] = { + {114, 0}, {0, 1}, }; -static state states_51[2] = { - {1, arcs_51_0}, - {2, arcs_51_1}, +static state states_50[2] = { + {1, arcs_50_0}, + {2, arcs_50_1}, }; -static arc arcs_52_0[10] = { +static arc arcs_51_0[9] = { + {115, 1}, + {116, 1}, {117, 1}, {118, 1}, {119, 1}, {120, 1}, - {121, 1}, - {122, 1}, - {123, 1}, - {83, 1}, - {114, 2}, - {124, 3}, + {92, 1}, + {112, 2}, + {121, 3}, }; -static arc arcs_52_1[1] = { +static arc arcs_51_1[1] = { {0, 1}, }; -static arc arcs_52_2[1] = { - {83, 1}, +static arc arcs_51_2[1] = { + {92, 1}, }; -static arc arcs_52_3[2] = { - {114, 1}, +static arc arcs_51_3[2] = { + {112, 1}, {0, 3}, }; -static state states_52[4] = { - {10, arcs_52_0}, - {1, arcs_52_1}, - {1, arcs_52_2}, - {2, arcs_52_3}, +static state states_51[4] = { + {9, arcs_51_0}, + {1, arcs_51_1}, + {1, arcs_51_2}, + {2, arcs_51_3}, +}; +static arc arcs_52_0[1] = { + {122, 1}, +}; +static arc arcs_52_1[2] = { + {123, 0}, + {0, 1}, +}; +static state states_52[2] = { + {1, arcs_52_0}, + {2, arcs_52_1}, }; static arc arcs_53_0[1] = { - {125, 1}, + {124, 1}, }; static arc arcs_53_1[2] = { - {126, 0}, + {125, 0}, {0, 1}, }; static state states_53[2] = { @@ -1147,10 +1137,10 @@ {2, arcs_53_1}, }; static arc arcs_54_0[1] = { - {127, 1}, + {126, 1}, }; static arc arcs_54_1[2] = { - {128, 0}, + {127, 0}, {0, 1}, }; static state states_54[2] = { @@ -1158,22 +1148,23 @@ {2, arcs_54_1}, }; static arc arcs_55_0[1] = { - {129, 1}, + {128, 1}, }; -static arc arcs_55_1[2] = { - {130, 0}, +static arc arcs_55_1[3] = { + {129, 0}, + {56, 0}, {0, 1}, }; static state states_55[2] = { {1, arcs_55_0}, - {2, arcs_55_1}, + {3, arcs_55_1}, }; static arc arcs_56_0[1] = { - {131, 1}, + {130, 1}, }; static arc arcs_56_1[3] = { + {131, 0}, {132, 0}, - {57, 0}, {0, 1}, }; static state states_56[2] = { @@ -1183,128 +1174,142 @@ static arc arcs_57_0[1] = { {133, 1}, }; -static arc arcs_57_1[3] = { +static arc arcs_57_1[5] = { + {28, 0}, {134, 0}, {135, 0}, + {136, 0}, {0, 1}, }; static state states_57[2] = { {1, arcs_57_0}, - {3, arcs_57_1}, -}; -static arc arcs_58_0[1] = { - {136, 1}, -}; -static arc arcs_58_1[5] = { - {28, 0}, - {137, 0}, - {138, 0}, - {139, 0}, - {0, 1}, + {5, arcs_57_1}, }; -static state states_58[2] = { - {1, arcs_58_0}, - {5, arcs_58_1}, -}; -static arc arcs_59_0[4] = { - {134, 1}, - {135, 1}, - {140, 1}, - {141, 2}, +static arc arcs_58_0[4] = { + {131, 1}, + {132, 1}, + {137, 1}, + {138, 2}, }; -static arc arcs_59_1[1] = { - {136, 2}, +static arc arcs_58_1[1] = { + {133, 2}, }; -static arc arcs_59_2[1] = { +static arc arcs_58_2[1] = { {0, 2}, }; -static state states_59[3] = { - {4, arcs_59_0}, - {1, arcs_59_1}, - {1, arcs_59_2}, +static state states_58[3] = { + {4, arcs_58_0}, + {1, arcs_58_1}, + {1, arcs_58_2}, }; -static arc arcs_60_0[1] = { - {142, 1}, +static arc arcs_59_0[1] = { + {139, 1}, }; -static arc arcs_60_1[3] = { - {143, 1}, +static arc arcs_59_1[3] = { + {140, 1}, {29, 2}, {0, 1}, }; -static arc arcs_60_2[1] = { - {136, 3}, +static arc arcs_59_2[1] = { + {133, 3}, }; -static arc arcs_60_3[1] = { +static arc arcs_59_3[1] = { {0, 3}, }; -static state states_60[4] = { - {1, arcs_60_0}, - {3, arcs_60_1}, - {1, arcs_60_2}, - {1, arcs_60_3}, +static state states_59[4] = { + {1, arcs_59_0}, + {3, arcs_59_1}, + {1, arcs_59_2}, + {1, arcs_59_3}, }; -static arc arcs_61_0[7] = { +static arc arcs_60_0[7] = { {13, 1}, - {145, 2}, - {148, 3}, - {151, 4}, - {19, 5}, - {153, 5}, - {154, 6}, -}; -static arc arcs_61_1[3] = { - {43, 7}, - {144, 7}, - {15, 5}, -}; -static arc arcs_61_2[2] = { - {146, 8}, - {147, 5}, + {142, 2}, + {145, 3}, + {19, 4}, + {148, 4}, + {149, 5}, + {74, 6}, }; -static arc arcs_61_3[2] = { - {149, 9}, - {150, 5}, +static arc arcs_60_1[3] = { + {42, 7}, + {141, 7}, + {15, 4}, +}; +static arc arcs_60_2[2] = { + {143, 8}, + {144, 4}, +}; +static arc arcs_60_3[2] = { + {146, 9}, + {147, 4}, }; -static arc arcs_61_4[1] = { - {152, 10}, +static arc arcs_60_4[1] = { + {0, 4}, }; -static arc arcs_61_5[1] = { +static arc arcs_60_5[2] = { + {149, 5}, {0, 5}, }; -static arc arcs_61_6[2] = { - {154, 6}, - {0, 6}, +static arc arcs_60_6[1] = { + {74, 10}, }; -static arc arcs_61_7[1] = { - {15, 5}, +static arc arcs_60_7[1] = { + {15, 4}, }; -static arc arcs_61_8[1] = { - {147, 5}, +static arc arcs_60_8[1] = { + {144, 4}, }; -static arc arcs_61_9[1] = { - {150, 5}, +static arc arcs_60_9[1] = { + {147, 4}, }; -static arc arcs_61_10[1] = { - {151, 5}, +static arc arcs_60_10[1] = { + {74, 4}, }; -static state states_61[11] = { - {7, arcs_61_0}, - {3, arcs_61_1}, - {2, arcs_61_2}, - {2, arcs_61_3}, - {1, arcs_61_4}, - {1, arcs_61_5}, - {2, arcs_61_6}, - {1, arcs_61_7}, - {1, arcs_61_8}, - {1, arcs_61_9}, - {1, arcs_61_10}, +static state states_60[11] = { + {7, arcs_60_0}, + {3, arcs_60_1}, + {2, arcs_60_2}, + {2, arcs_60_3}, + {1, arcs_60_4}, + {2, arcs_60_5}, + {1, arcs_60_6}, + {1, arcs_60_7}, + {1, arcs_60_8}, + {1, arcs_60_9}, + {1, arcs_60_10}, +}; +static arc arcs_61_0[1] = { + {26, 1}, +}; +static arc arcs_61_1[3] = { + {150, 2}, + {27, 3}, + {0, 1}, +}; +static arc arcs_61_2[1] = { + {0, 2}, +}; +static arc arcs_61_3[2] = { + {26, 4}, + {0, 3}, +}; +static arc arcs_61_4[2] = { + {27, 3}, + {0, 4}, +}; +static state states_61[5] = { + {1, arcs_61_0}, + {3, arcs_61_1}, + {1, arcs_61_2}, + {2, arcs_61_3}, + {2, arcs_61_4}, }; static arc arcs_62_0[1] = { {26, 1}, }; static arc arcs_62_1[3] = { - {155, 2}, + {151, 2}, {27, 3}, {0, 1}, }; @@ -1327,163 +1332,144 @@ {2, arcs_62_4}, }; static arc arcs_63_0[1] = { - {26, 1}, + {106, 1}, }; -static arc arcs_63_1[3] = { - {156, 2}, - {27, 3}, - {0, 1}, +static arc arcs_63_1[2] = { + {23, 2}, + {21, 3}, }; static arc arcs_63_2[1] = { - {0, 2}, + {21, 3}, }; -static arc arcs_63_3[2] = { +static arc arcs_63_3[1] = { {26, 4}, - {0, 3}, }; -static arc arcs_63_4[2] = { - {27, 3}, +static arc arcs_63_4[1] = { {0, 4}, }; static state states_63[5] = { {1, arcs_63_0}, - {3, arcs_63_1}, + {2, arcs_63_1}, {1, arcs_63_2}, - {2, arcs_63_3}, - {2, arcs_63_4}, + {1, arcs_63_3}, + {1, arcs_63_4}, }; -static arc arcs_64_0[1] = { - {108, 1}, +static arc arcs_64_0[3] = { + {13, 1}, + {142, 2}, + {74, 3}, }; static arc arcs_64_1[2] = { - {23, 2}, - {21, 3}, + {14, 4}, + {15, 5}, }; static arc arcs_64_2[1] = { - {21, 3}, + {152, 6}, }; static arc arcs_64_3[1] = { - {26, 4}, + {19, 5}, }; static arc arcs_64_4[1] = { - {0, 4}, + {15, 5}, +}; +static arc arcs_64_5[1] = { + {0, 5}, +}; +static arc arcs_64_6[1] = { + {144, 5}, }; -static state states_64[5] = { - {1, arcs_64_0}, +static state states_64[7] = { + {3, arcs_64_0}, {2, arcs_64_1}, {1, arcs_64_2}, {1, arcs_64_3}, {1, arcs_64_4}, + {1, arcs_64_5}, + {1, arcs_64_6}, }; -static arc arcs_65_0[3] = { - {13, 1}, - {145, 2}, - {75, 3}, +static arc arcs_65_0[1] = { + {153, 1}, }; static arc arcs_65_1[2] = { - {14, 4}, - {15, 5}, -}; -static arc arcs_65_2[1] = { - {157, 6}, -}; -static arc arcs_65_3[1] = { - {19, 5}, -}; -static arc arcs_65_4[1] = { - {15, 5}, -}; -static arc arcs_65_5[1] = { - {0, 5}, + {27, 2}, + {0, 1}, }; -static arc arcs_65_6[1] = { - {147, 5}, +static arc arcs_65_2[2] = { + {153, 1}, + {0, 2}, }; -static state states_65[7] = { - {3, arcs_65_0}, +static state states_65[3] = { + {1, arcs_65_0}, {2, arcs_65_1}, - {1, arcs_65_2}, - {1, arcs_65_3}, - {1, arcs_65_4}, - {1, arcs_65_5}, - {1, arcs_65_6}, + {2, arcs_65_2}, }; -static arc arcs_66_0[1] = { - {158, 1}, +static arc arcs_66_0[2] = { + {26, 1}, + {21, 2}, }; static arc arcs_66_1[2] = { - {27, 2}, + {21, 2}, {0, 1}, }; -static arc arcs_66_2[2] = { - {158, 1}, +static arc arcs_66_2[3] = { + {26, 3}, + {154, 4}, {0, 2}, }; -static state states_66[3] = { - {1, arcs_66_0}, - {2, arcs_66_1}, - {2, arcs_66_2}, -}; -static arc arcs_67_0[3] = { - {75, 1}, - {26, 2}, - {21, 3}, -}; -static arc arcs_67_1[1] = { - {75, 4}, +static arc arcs_66_3[2] = { + {154, 4}, + {0, 3}, }; -static arc arcs_67_2[2] = { - {21, 3}, - {0, 2}, +static arc arcs_66_4[1] = { + {0, 4}, }; -static arc arcs_67_3[3] = { - {26, 5}, - {159, 6}, - {0, 3}, +static state states_66[5] = { + {2, arcs_66_0}, + {2, arcs_66_1}, + {3, arcs_66_2}, + {2, arcs_66_3}, + {1, arcs_66_4}, }; -static arc arcs_67_4[1] = { - {75, 6}, +static arc arcs_67_0[1] = { + {21, 1}, }; -static arc arcs_67_5[2] = { - {159, 6}, - {0, 5}, +static arc arcs_67_1[2] = { + {26, 2}, + {0, 1}, }; -static arc arcs_67_6[1] = { - {0, 6}, +static arc arcs_67_2[1] = { + {0, 2}, }; -static state states_67[7] = { - {3, arcs_67_0}, - {1, arcs_67_1}, - {2, arcs_67_2}, - {3, arcs_67_3}, - {1, arcs_67_4}, - {2, arcs_67_5}, - {1, arcs_67_6}, +static state states_67[3] = { + {1, arcs_67_0}, + {2, arcs_67_1}, + {1, arcs_67_2}, }; static arc arcs_68_0[1] = { - {21, 1}, + {98, 1}, }; static arc arcs_68_1[2] = { - {26, 2}, + {27, 2}, {0, 1}, }; -static arc arcs_68_2[1] = { +static arc arcs_68_2[2] = { + {98, 1}, {0, 2}, }; static state states_68[3] = { {1, arcs_68_0}, {2, arcs_68_1}, - {1, arcs_68_2}, + {2, arcs_68_2}, }; static arc arcs_69_0[1] = { - {82, 1}, + {26, 1}, }; static arc arcs_69_1[2] = { {27, 2}, {0, 1}, }; static arc arcs_69_2[2] = { - {82, 1}, + {26, 1}, {0, 2}, }; static state states_69[3] = { @@ -1494,297 +1480,297 @@ static arc arcs_70_0[1] = { {26, 1}, }; -static arc arcs_70_1[2] = { - {27, 2}, +static arc arcs_70_1[3] = { + {21, 2}, + {27, 3}, {0, 1}, }; -static arc arcs_70_2[2] = { - {26, 1}, - {0, 2}, -}; -static state states_70[3] = { - {1, arcs_70_0}, - {2, arcs_70_1}, - {2, arcs_70_2}, +static arc arcs_70_2[1] = { + {26, 4}, }; -static arc arcs_71_0[1] = { - {26, 1}, +static arc arcs_70_3[2] = { + {26, 5}, + {0, 3}, }; -static arc arcs_71_1[1] = { - {21, 2}, +static arc arcs_70_4[2] = { + {27, 6}, + {0, 4}, }; -static arc arcs_71_2[1] = { - {26, 3}, +static arc arcs_70_5[2] = { + {27, 3}, + {0, 5}, }; -static arc arcs_71_3[2] = { - {27, 4}, - {0, 3}, +static arc arcs_70_6[2] = { + {26, 7}, + {0, 6}, }; -static arc arcs_71_4[2] = { - {26, 1}, - {0, 4}, +static arc arcs_70_7[1] = { + {21, 2}, }; -static state states_71[5] = { - {1, arcs_71_0}, - {1, arcs_71_1}, - {1, arcs_71_2}, - {2, arcs_71_3}, - {2, arcs_71_4}, +static state states_70[8] = { + {1, arcs_70_0}, + {3, arcs_70_1}, + {1, arcs_70_2}, + {2, arcs_70_3}, + {2, arcs_70_4}, + {2, arcs_70_5}, + {2, arcs_70_6}, + {1, arcs_70_7}, }; -static arc arcs_72_0[1] = { - {160, 1}, +static arc arcs_71_0[1] = { + {155, 1}, }; -static arc arcs_72_1[1] = { +static arc arcs_71_1[1] = { {19, 2}, }; -static arc arcs_72_2[2] = { +static arc arcs_71_2[2] = { {13, 3}, {21, 4}, }; -static arc arcs_72_3[2] = { +static arc arcs_71_3[2] = { {9, 5}, {15, 6}, }; -static arc arcs_72_4[1] = { +static arc arcs_71_4[1] = { {22, 7}, }; -static arc arcs_72_5[1] = { +static arc arcs_71_5[1] = { {15, 6}, }; -static arc arcs_72_6[1] = { +static arc arcs_71_6[1] = { {21, 4}, }; -static arc arcs_72_7[1] = { +static arc arcs_71_7[1] = { {0, 7}, }; -static state states_72[8] = { - {1, arcs_72_0}, - {1, arcs_72_1}, - {2, arcs_72_2}, - {2, arcs_72_3}, - {1, arcs_72_4}, - {1, arcs_72_5}, - {1, arcs_72_6}, - {1, arcs_72_7}, +static state states_71[8] = { + {1, arcs_71_0}, + {1, arcs_71_1}, + {2, arcs_71_2}, + {2, arcs_71_3}, + {1, arcs_71_4}, + {1, arcs_71_5}, + {1, arcs_71_6}, + {1, arcs_71_7}, }; -static arc arcs_73_0[3] = { - {161, 1}, +static arc arcs_72_0[3] = { + {156, 1}, {28, 2}, {29, 3}, }; -static arc arcs_73_1[2] = { +static arc arcs_72_1[2] = { {27, 4}, {0, 1}, }; -static arc arcs_73_2[1] = { +static arc arcs_72_2[1] = { {26, 5}, }; -static arc arcs_73_3[1] = { +static arc arcs_72_3[1] = { {26, 6}, }; -static arc arcs_73_4[4] = { - {161, 1}, +static arc arcs_72_4[4] = { + {156, 1}, {28, 2}, {29, 3}, {0, 4}, }; -static arc arcs_73_5[2] = { +static arc arcs_72_5[2] = { {27, 7}, {0, 5}, }; -static arc arcs_73_6[1] = { +static arc arcs_72_6[1] = { {0, 6}, }; -static arc arcs_73_7[1] = { +static arc arcs_72_7[1] = { {29, 3}, }; -static state states_73[8] = { - {3, arcs_73_0}, - {2, arcs_73_1}, - {1, arcs_73_2}, - {1, arcs_73_3}, - {4, arcs_73_4}, - {2, arcs_73_5}, - {1, arcs_73_6}, - {1, arcs_73_7}, +static state states_72[8] = { + {3, arcs_72_0}, + {2, arcs_72_1}, + {1, arcs_72_2}, + {1, arcs_72_3}, + {4, arcs_72_4}, + {2, arcs_72_5}, + {1, arcs_72_6}, + {1, arcs_72_7}, }; -static arc arcs_74_0[1] = { +static arc arcs_73_0[1] = { {26, 1}, }; -static arc arcs_74_1[3] = { - {156, 2}, +static arc arcs_73_1[3] = { + {151, 2}, {25, 3}, {0, 1}, }; -static arc arcs_74_2[1] = { +static arc arcs_73_2[1] = { {0, 2}, }; -static arc arcs_74_3[1] = { +static arc arcs_73_3[1] = { {26, 2}, }; -static state states_74[4] = { - {1, arcs_74_0}, - {3, arcs_74_1}, - {1, arcs_74_2}, - {1, arcs_74_3}, +static state states_73[4] = { + {1, arcs_73_0}, + {3, arcs_73_1}, + {1, arcs_73_2}, + {1, arcs_73_3}, }; -static arc arcs_75_0[2] = { - {155, 1}, - {163, 1}, +static arc arcs_74_0[2] = { + {150, 1}, + {158, 1}, }; -static arc arcs_75_1[1] = { +static arc arcs_74_1[1] = { {0, 1}, }; -static state states_75[2] = { - {2, arcs_75_0}, - {1, arcs_75_1}, +static state states_74[2] = { + {2, arcs_74_0}, + {1, arcs_74_1}, }; -static arc arcs_76_0[1] = { - {95, 1}, +static arc arcs_75_0[1] = { + {91, 1}, }; -static arc arcs_76_1[1] = { - {59, 2}, +static arc arcs_75_1[1] = { + {58, 2}, }; -static arc arcs_76_2[1] = { - {83, 3}, +static arc arcs_75_2[1] = { + {92, 3}, }; -static arc arcs_76_3[1] = { - {104, 4}, +static arc arcs_75_3[1] = { + {102, 4}, }; -static arc arcs_76_4[2] = { - {162, 5}, +static arc arcs_75_4[2] = { + {157, 5}, {0, 4}, }; -static arc arcs_76_5[1] = { +static arc arcs_75_5[1] = { {0, 5}, }; -static state states_76[6] = { - {1, arcs_76_0}, - {1, arcs_76_1}, - {1, arcs_76_2}, - {1, arcs_76_3}, - {2, arcs_76_4}, - {1, arcs_76_5}, +static state states_75[6] = { + {1, arcs_75_0}, + {1, arcs_75_1}, + {1, arcs_75_2}, + {1, arcs_75_3}, + {2, arcs_75_4}, + {1, arcs_75_5}, }; -static arc arcs_77_0[1] = { - {91, 1}, +static arc arcs_76_0[1] = { + {87, 1}, }; -static arc arcs_77_1[1] = { - {105, 2}, +static arc arcs_76_1[1] = { + {103, 2}, }; -static arc arcs_77_2[2] = { - {162, 3}, +static arc arcs_76_2[2] = { + {157, 3}, {0, 2}, }; -static arc arcs_77_3[1] = { +static arc arcs_76_3[1] = { {0, 3}, }; -static state states_77[4] = { - {1, arcs_77_0}, - {1, arcs_77_1}, - {2, arcs_77_2}, - {1, arcs_77_3}, +static state states_76[4] = { + {1, arcs_76_0}, + {1, arcs_76_1}, + {2, arcs_76_2}, + {1, arcs_76_3}, }; -static arc arcs_78_0[2] = { - {156, 1}, - {165, 1}, +static arc arcs_77_0[2] = { + {151, 1}, + {160, 1}, }; -static arc arcs_78_1[1] = { +static arc arcs_77_1[1] = { {0, 1}, }; -static state states_78[2] = { - {2, arcs_78_0}, - {1, arcs_78_1}, +static state states_77[2] = { + {2, arcs_77_0}, + {1, arcs_77_1}, }; -static arc arcs_79_0[1] = { - {95, 1}, +static arc arcs_78_0[1] = { + {91, 1}, }; -static arc arcs_79_1[1] = { - {59, 2}, +static arc arcs_78_1[1] = { + {58, 2}, }; -static arc arcs_79_2[1] = { - {83, 3}, +static arc arcs_78_2[1] = { + {92, 3}, }; -static arc arcs_79_3[1] = { - {106, 4}, +static arc arcs_78_3[1] = { + {104, 4}, }; -static arc arcs_79_4[2] = { - {164, 5}, +static arc arcs_78_4[2] = { + {159, 5}, {0, 4}, }; -static arc arcs_79_5[1] = { +static arc arcs_78_5[1] = { {0, 5}, }; -static state states_79[6] = { - {1, arcs_79_0}, - {1, arcs_79_1}, - {1, arcs_79_2}, - {1, arcs_79_3}, - {2, arcs_79_4}, - {1, arcs_79_5}, +static state states_78[6] = { + {1, arcs_78_0}, + {1, arcs_78_1}, + {1, arcs_78_2}, + {1, arcs_78_3}, + {2, arcs_78_4}, + {1, arcs_78_5}, }; -static arc arcs_80_0[1] = { - {91, 1}, +static arc arcs_79_0[1] = { + {87, 1}, }; -static arc arcs_80_1[1] = { - {105, 2}, +static arc arcs_79_1[1] = { + {103, 2}, }; -static arc arcs_80_2[2] = { - {164, 3}, +static arc arcs_79_2[2] = { + {159, 3}, {0, 2}, }; -static arc arcs_80_3[1] = { +static arc arcs_79_3[1] = { {0, 3}, }; -static state states_80[4] = { - {1, arcs_80_0}, - {1, arcs_80_1}, - {2, arcs_80_2}, - {1, arcs_80_3}, +static state states_79[4] = { + {1, arcs_79_0}, + {1, arcs_79_1}, + {2, arcs_79_2}, + {1, arcs_79_3}, }; -static arc arcs_81_0[1] = { +static arc arcs_80_0[1] = { {26, 1}, }; -static arc arcs_81_1[2] = { +static arc arcs_80_1[2] = { {27, 0}, {0, 1}, }; -static state states_81[2] = { - {1, arcs_81_0}, - {2, arcs_81_1}, +static state states_80[2] = { + {1, arcs_80_0}, + {2, arcs_80_1}, }; -static arc arcs_82_0[1] = { +static arc arcs_81_0[1] = { {19, 1}, }; -static arc arcs_82_1[1] = { +static arc arcs_81_1[1] = { {0, 1}, }; -static state states_82[2] = { - {1, arcs_82_0}, - {1, arcs_82_1}, +static state states_81[2] = { + {1, arcs_81_0}, + {1, arcs_81_1}, }; -static arc arcs_83_0[1] = { - {167, 1}, +static arc arcs_82_0[1] = { + {163, 1}, }; -static arc arcs_83_1[2] = { +static arc arcs_82_1[2] = { {9, 2}, {0, 1}, }; -static arc arcs_83_2[1] = { +static arc arcs_82_2[1] = { {0, 2}, }; -static state states_83[3] = { - {1, arcs_83_0}, - {2, arcs_83_1}, - {1, arcs_83_2}, +static state states_82[3] = { + {1, arcs_82_0}, + {2, arcs_82_1}, + {1, arcs_82_2}, }; -static dfa dfas[84] = { +static dfa dfas[83] = { {256, "single_input", 0, 3, states_0, - "\004\050\014\000\000\000\000\025\074\005\023\310\011\020\004\000\300\020\222\006\201"}, + "\004\050\014\000\000\000\200\012\236\206\201\054\001\004\001\000\030\102\062\010\010"}, {257, "file_input", 0, 2, states_1, - "\204\050\014\000\000\000\000\025\074\005\023\310\011\020\004\000\300\020\222\006\201"}, + "\204\050\014\000\000\000\200\012\236\206\201\054\001\004\001\000\030\102\062\010\010"}, {258, "eval_input", 0, 3, states_2, - "\000\040\010\000\000\000\000\000\000\000\000\000\000\020\004\000\300\020\222\006\000"}, + "\000\040\010\000\000\000\000\000\000\004\000\000\000\004\001\000\030\102\062\000\000"}, {259, "decorator", 0, 7, states_3, "\000\010\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000"}, {260, "decorators", 0, 2, states_4, @@ -1793,46 +1779,46 @@ "\000\010\004\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000"}, {262, "parameters", 0, 4, states_6, "\000\040\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000"}, - {263, "varargslist", 0, 10, states_7, + {263, "varargslist", 0, 12, states_7, "\000\040\010\060\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000"}, {264, "fpdef", 0, 4, states_8, "\000\040\010\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000"}, {265, "fplist", 0, 3, states_9, "\000\040\010\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000"}, {266, "stmt", 0, 2, states_10, - "\000\050\014\000\000\000\000\025\074\005\023\310\011\020\004\000\300\020\222\006\201"}, + "\000\050\014\000\000\000\200\012\236\206\201\054\001\004\001\000\030\102\062\010\010"}, {267, "simple_stmt", 0, 4, states_11, - "\000\040\010\000\000\000\000\025\074\005\023\000\000\020\004\000\300\020\222\006\200"}, + "\000\040\010\000\000\000\200\012\236\206\001\000\000\004\001\000\030\102\062\000\010"}, {268, "small_stmt", 0, 2, states_12, - "\000\040\010\000\000\000\000\025\074\005\023\000\000\020\004\000\300\020\222\006\200"}, + "\000\040\010\000\000\000\200\012\236\206\001\000\000\004\001\000\030\102\062\000\010"}, {269, "expr_stmt", 0, 6, states_13, - "\000\040\010\000\000\000\000\000\000\000\000\000\000\020\004\000\300\020\222\006\000"}, + "\000\040\010\000\000\000\000\000\000\004\000\000\000\004\001\000\030\102\062\000\000"}, {270, "augassign", 0, 2, states_14, - "\000\000\000\000\000\360\377\000\000\000\000\000\000\000\000\000\000\000\000\000\000"}, + "\000\000\000\000\000\370\177\000\000\000\000\000\000\000\000\000\000\000\000\000\000"}, {271, "print_stmt", 0, 9, states_15, - "\000\000\000\000\000\000\000\001\000\000\000\000\000\000\000\000\000\000\000\000\000"}, + "\000\000\000\000\000\000\200\000\000\000\000\000\000\000\000\000\000\000\000\000\000"}, {272, "del_stmt", 0, 3, states_16, - "\000\000\000\000\000\000\000\004\000\000\000\000\000\000\000\000\000\000\000\000\000"}, + "\000\000\000\000\000\000\000\002\000\000\000\000\000\000\000\000\000\000\000\000\000"}, {273, "pass_stmt", 0, 2, states_17, - "\000\000\000\000\000\000\000\020\000\000\000\000\000\000\000\000\000\000\000\000\000"}, + "\000\000\000\000\000\000\000\010\000\000\000\000\000\000\000\000\000\000\000\000\000"}, {274, "flow_stmt", 0, 2, states_18, - "\000\000\000\000\000\000\000\000\074\000\000\000\000\000\000\000\000\000\000\000\200"}, + "\000\000\000\000\000\000\000\000\036\000\000\000\000\000\000\000\000\000\000\000\010"}, {275, "break_stmt", 0, 2, states_19, - "\000\000\000\000\000\000\000\000\004\000\000\000\000\000\000\000\000\000\000\000\000"}, + "\000\000\000\000\000\000\000\000\002\000\000\000\000\000\000\000\000\000\000\000\000"}, {276, "continue_stmt", 0, 2, states_20, - "\000\000\000\000\000\000\000\000\010\000\000\000\000\000\000\000\000\000\000\000\000"}, + "\000\000\000\000\000\000\000\000\004\000\000\000\000\000\000\000\000\000\000\000\000"}, {277, "return_stmt", 0, 3, states_21, - "\000\000\000\000\000\000\000\000\020\000\000\000\000\000\000\000\000\000\000\000\000"}, + "\000\000\000\000\000\000\000\000\010\000\000\000\000\000\000\000\000\000\000\000\000"}, {278, "yield_stmt", 0, 2, states_22, - "\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\200"}, + "\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\010"}, {279, "raise_stmt", 0, 7, states_23, - "\000\000\000\000\000\000\000\000\040\000\000\000\000\000\000\000\000\000\000\000\000"}, + "\000\000\000\000\000\000\000\000\020\000\000\000\000\000\000\000\000\000\000\000\000"}, {280, "import_stmt", 0, 2, states_24, - "\000\000\000\000\000\000\000\000\000\005\000\000\000\000\000\000\000\000\000\000\000"}, + "\000\000\000\000\000\000\000\000\200\002\000\000\000\000\000\000\000\000\000\000\000"}, {281, "import_name", 0, 3, states_25, - "\000\000\000\000\000\000\000\000\000\001\000\000\000\000\000\000\000\000\000\000\000"}, + "\000\000\000\000\000\000\000\000\200\000\000\000\000\000\000\000\000\000\000\000\000"}, {282, "import_from", 0, 8, states_26, - "\000\000\000\000\000\000\000\000\000\004\000\000\000\000\000\000\000\000\000\000\000"}, + "\000\000\000\000\000\000\000\000\000\002\000\000\000\000\000\000\000\000\000\000\000"}, {283, "import_as_name", 0, 4, states_27, "\000\000\010\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000"}, {284, "dotted_as_name", 0, 4, states_28, @@ -1844,126 +1830,124 @@ {287, "dotted_name", 0, 2, states_31, "\000\000\010\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000"}, {288, "global_stmt", 0, 3, states_32, + "\000\000\000\000\000\000\000\000\000\200\000\000\000\000\000\000\000\000\000\000\000"}, + {289, "assert_stmt", 0, 5, states_33, "\000\000\000\000\000\000\000\000\000\000\001\000\000\000\000\000\000\000\000\000\000"}, - {289, "exec_stmt", 0, 7, states_33, - "\000\000\000\000\000\000\000\000\000\000\002\000\000\000\000\000\000\000\000\000\000"}, - {290, "assert_stmt", 0, 5, states_34, - "\000\000\000\000\000\000\000\000\000\000\020\000\000\000\000\000\000\000\000\000\000"}, - {291, "compound_stmt", 0, 2, states_35, - "\000\010\004\000\000\000\000\000\000\000\000\310\011\000\000\000\000\000\000\000\001"}, - {292, "if_stmt", 0, 8, states_36, + {290, "compound_stmt", 0, 2, states_34, + "\000\010\004\000\000\000\000\000\000\000\200\054\001\000\000\000\000\000\000\010\000"}, + {291, "if_stmt", 0, 8, states_35, + "\000\000\000\000\000\000\000\000\000\000\200\000\000\000\000\000\000\000\000\000\000"}, + {292, "while_stmt", 0, 8, states_36, + "\000\000\000\000\000\000\000\000\000\000\000\004\000\000\000\000\000\000\000\000\000"}, + {293, "for_stmt", 0, 10, states_37, "\000\000\000\000\000\000\000\000\000\000\000\010\000\000\000\000\000\000\000\000\000"}, - {293, "while_stmt", 0, 8, states_37, - "\000\000\000\000\000\000\000\000\000\000\000\100\000\000\000\000\000\000\000\000\000"}, - {294, "for_stmt", 0, 10, states_38, - "\000\000\000\000\000\000\000\000\000\000\000\200\000\000\000\000\000\000\000\000\000"}, - {295, "try_stmt", 0, 13, states_39, + {294, "try_stmt", 0, 13, states_38, + "\000\000\000\000\000\000\000\000\000\000\000\040\000\000\000\000\000\000\000\000\000"}, + {295, "with_stmt", 0, 6, states_39, "\000\000\000\000\000\000\000\000\000\000\000\000\001\000\000\000\000\000\000\000\000"}, - {296, "with_stmt", 0, 6, states_40, + {296, "with_var", 0, 3, states_40, + "\000\000\000\000\000\000\000\000\000\040\000\000\000\000\000\000\000\000\000\000\000"}, + {297, "except_clause", 0, 5, states_41, "\000\000\000\000\000\000\000\000\000\000\000\000\010\000\000\000\000\000\000\000\000"}, - {297, "with_var", 0, 3, states_41, - "\000\000\000\000\000\000\000\000\000\100\000\000\000\000\000\000\000\000\000\000\000"}, - {298, "except_clause", 0, 5, states_42, - "\000\000\000\000\000\000\000\000\000\000\000\000\040\000\000\000\000\000\000\000\000"}, - {299, "suite", 0, 5, states_43, - "\004\040\010\000\000\000\000\025\074\005\023\000\000\020\004\000\300\020\222\006\200"}, - {300, "testlist_safe", 0, 5, states_44, - "\000\040\010\000\000\000\000\000\000\000\000\000\000\020\004\000\300\020\222\006\000"}, - {301, "old_test", 0, 2, states_45, - "\000\040\010\000\000\000\000\000\000\000\000\000\000\020\004\000\300\020\222\006\000"}, - {302, "old_lambdef", 0, 5, states_46, - "\000\000\000\000\000\000\000\000\000\000\000\000\000\020\000\000\000\000\000\000\000"}, - {303, "test", 0, 6, states_47, - "\000\040\010\000\000\000\000\000\000\000\000\000\000\020\004\000\300\020\222\006\000"}, - {304, "or_test", 0, 2, states_48, - "\000\040\010\000\000\000\000\000\000\000\000\000\000\000\004\000\300\020\222\006\000"}, - {305, "and_test", 0, 2, states_49, - "\000\040\010\000\000\000\000\000\000\000\000\000\000\000\004\000\300\020\222\006\000"}, - {306, "not_test", 0, 3, states_50, - "\000\040\010\000\000\000\000\000\000\000\000\000\000\000\004\000\300\020\222\006\000"}, - {307, "comparison", 0, 2, states_51, - "\000\040\010\000\000\000\000\000\000\000\000\000\000\000\000\000\300\020\222\006\000"}, - {308, "comp_op", 0, 4, states_52, - "\000\000\000\000\000\000\000\000\000\000\010\000\000\000\344\037\000\000\000\000\000"}, - {309, "expr", 0, 2, states_53, - "\000\040\010\000\000\000\000\000\000\000\000\000\000\000\000\000\300\020\222\006\000"}, - {310, "xor_expr", 0, 2, states_54, - "\000\040\010\000\000\000\000\000\000\000\000\000\000\000\000\000\300\020\222\006\000"}, - {311, "and_expr", 0, 2, states_55, - "\000\040\010\000\000\000\000\000\000\000\000\000\000\000\000\000\300\020\222\006\000"}, - {312, "shift_expr", 0, 2, states_56, - "\000\040\010\000\000\000\000\000\000\000\000\000\000\000\000\000\300\020\222\006\000"}, - {313, "arith_expr", 0, 2, states_57, - "\000\040\010\000\000\000\000\000\000\000\000\000\000\000\000\000\300\020\222\006\000"}, - {314, "term", 0, 2, states_58, - "\000\040\010\000\000\000\000\000\000\000\000\000\000\000\000\000\300\020\222\006\000"}, - {315, "factor", 0, 3, states_59, - "\000\040\010\000\000\000\000\000\000\000\000\000\000\000\000\000\300\020\222\006\000"}, - {316, "power", 0, 4, states_60, - "\000\040\010\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\222\006\000"}, - {317, "atom", 0, 11, states_61, - "\000\040\010\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\222\006\000"}, - {318, "listmaker", 0, 5, states_62, - "\000\040\010\000\000\000\000\000\000\000\000\000\000\020\004\000\300\020\222\006\000"}, - {319, "testlist_gexp", 0, 5, states_63, - "\000\040\010\000\000\000\000\000\000\000\000\000\000\020\004\000\300\020\222\006\000"}, - {320, "lambdef", 0, 5, states_64, - "\000\000\000\000\000\000\000\000\000\000\000\000\000\020\000\000\000\000\000\000\000"}, - {321, "trailer", 0, 7, states_65, - "\000\040\000\000\000\000\000\000\000\010\000\000\000\000\000\000\000\000\002\000\000"}, - {322, "subscriptlist", 0, 3, states_66, - "\000\040\050\000\000\000\000\000\000\010\000\000\000\020\004\000\300\020\222\006\000"}, - {323, "subscript", 0, 7, states_67, - "\000\040\050\000\000\000\000\000\000\010\000\000\000\020\004\000\300\020\222\006\000"}, - {324, "sliceop", 0, 3, states_68, + {298, "suite", 0, 5, states_42, + "\004\040\010\000\000\000\200\012\236\206\001\000\000\004\001\000\030\102\062\000\010"}, + {299, "testlist_safe", 0, 5, states_43, + "\000\040\010\000\000\000\000\000\000\004\000\000\000\004\001\000\030\102\062\000\000"}, + {300, "old_test", 0, 2, states_44, + "\000\040\010\000\000\000\000\000\000\004\000\000\000\004\001\000\030\102\062\000\000"}, + {301, "old_lambdef", 0, 5, states_45, + "\000\000\000\000\000\000\000\000\000\000\000\000\000\004\000\000\000\000\000\000\000"}, + {302, "test", 0, 6, states_46, + "\000\040\010\000\000\000\000\000\000\004\000\000\000\004\001\000\030\102\062\000\000"}, + {303, "or_test", 0, 2, states_47, + "\000\040\010\000\000\000\000\000\000\004\000\000\000\000\001\000\030\102\062\000\000"}, + {304, "and_test", 0, 2, states_48, + "\000\040\010\000\000\000\000\000\000\004\000\000\000\000\001\000\030\102\062\000\000"}, + {305, "not_test", 0, 3, states_49, + "\000\040\010\000\000\000\000\000\000\004\000\000\000\000\001\000\030\102\062\000\000"}, + {306, "comparison", 0, 2, states_50, + "\000\040\010\000\000\000\000\000\000\004\000\000\000\000\000\000\030\102\062\000\000"}, + {307, "comp_op", 0, 4, states_51, + "\000\000\000\000\000\000\000\000\000\000\000\020\000\000\371\003\000\000\000\000\000"}, + {308, "expr", 0, 2, states_52, + "\000\040\010\000\000\000\000\000\000\004\000\000\000\000\000\000\030\102\062\000\000"}, + {309, "xor_expr", 0, 2, states_53, + "\000\040\010\000\000\000\000\000\000\004\000\000\000\000\000\000\030\102\062\000\000"}, + {310, "and_expr", 0, 2, states_54, + "\000\040\010\000\000\000\000\000\000\004\000\000\000\000\000\000\030\102\062\000\000"}, + {311, "shift_expr", 0, 2, states_55, + "\000\040\010\000\000\000\000\000\000\004\000\000\000\000\000\000\030\102\062\000\000"}, + {312, "arith_expr", 0, 2, states_56, + "\000\040\010\000\000\000\000\000\000\004\000\000\000\000\000\000\030\102\062\000\000"}, + {313, "term", 0, 2, states_57, + "\000\040\010\000\000\000\000\000\000\004\000\000\000\000\000\000\030\102\062\000\000"}, + {314, "factor", 0, 3, states_58, + "\000\040\010\000\000\000\000\000\000\004\000\000\000\000\000\000\030\102\062\000\000"}, + {315, "power", 0, 4, states_59, + "\000\040\010\000\000\000\000\000\000\004\000\000\000\000\000\000\000\100\062\000\000"}, + {316, "atom", 0, 11, states_60, + "\000\040\010\000\000\000\000\000\000\004\000\000\000\000\000\000\000\100\062\000\000"}, + {317, "listmaker", 0, 5, states_61, + "\000\040\010\000\000\000\000\000\000\004\000\000\000\004\001\000\030\102\062\000\000"}, + {318, "testlist_gexp", 0, 5, states_62, + "\000\040\010\000\000\000\000\000\000\004\000\000\000\004\001\000\030\102\062\000\000"}, + {319, "lambdef", 0, 5, states_63, + "\000\000\000\000\000\000\000\000\000\000\000\000\000\004\000\000\000\000\000\000\000"}, + {320, "trailer", 0, 7, states_64, + "\000\040\000\000\000\000\000\000\000\004\000\000\000\000\000\000\000\100\000\000\000"}, + {321, "subscriptlist", 0, 3, states_65, + "\000\040\050\000\000\000\000\000\000\004\000\000\000\004\001\000\030\102\062\000\000"}, + {322, "subscript", 0, 5, states_66, + "\000\040\050\000\000\000\000\000\000\004\000\000\000\004\001\000\030\102\062\000\000"}, + {323, "sliceop", 0, 3, states_67, "\000\000\040\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000"}, - {325, "exprlist", 0, 3, states_69, - "\000\040\010\000\000\000\000\000\000\000\000\000\000\000\000\000\300\020\222\006\000"}, - {326, "testlist", 0, 3, states_70, - "\000\040\010\000\000\000\000\000\000\000\000\000\000\020\004\000\300\020\222\006\000"}, - {327, "dictmaker", 0, 5, states_71, - "\000\040\010\000\000\000\000\000\000\000\000\000\000\020\004\000\300\020\222\006\000"}, - {328, "classdef", 0, 8, states_72, - "\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\001"}, - {329, "arglist", 0, 8, states_73, - "\000\040\010\060\000\000\000\000\000\000\000\000\000\020\004\000\300\020\222\006\000"}, - {330, "argument", 0, 4, states_74, - "\000\040\010\000\000\000\000\000\000\000\000\000\000\020\004\000\300\020\222\006\000"}, - {331, "list_iter", 0, 2, states_75, - "\000\000\000\000\000\000\000\000\000\000\000\210\000\000\000\000\000\000\000\000\000"}, - {332, "list_for", 0, 6, states_76, - "\000\000\000\000\000\000\000\000\000\000\000\200\000\000\000\000\000\000\000\000\000"}, - {333, "list_if", 0, 4, states_77, + {324, "exprlist", 0, 3, states_68, + "\000\040\010\000\000\000\000\000\000\004\000\000\000\000\000\000\030\102\062\000\000"}, + {325, "testlist", 0, 3, states_69, + "\000\040\010\000\000\000\000\000\000\004\000\000\000\004\001\000\030\102\062\000\000"}, + {326, "dictsetmaker", 0, 8, states_70, + "\000\040\010\000\000\000\000\000\000\004\000\000\000\004\001\000\030\102\062\000\000"}, + {327, "classdef", 0, 8, states_71, + "\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\010\000"}, + {328, "arglist", 0, 8, states_72, + "\000\040\010\060\000\000\000\000\000\004\000\000\000\004\001\000\030\102\062\000\000"}, + {329, "argument", 0, 4, states_73, + "\000\040\010\000\000\000\000\000\000\004\000\000\000\004\001\000\030\102\062\000\000"}, + {330, "list_iter", 0, 2, states_74, + "\000\000\000\000\000\000\000\000\000\000\200\010\000\000\000\000\000\000\000\000\000"}, + {331, "list_for", 0, 6, states_75, "\000\000\000\000\000\000\000\000\000\000\000\010\000\000\000\000\000\000\000\000\000"}, - {334, "gen_iter", 0, 2, states_78, - "\000\000\000\000\000\000\000\000\000\000\000\210\000\000\000\000\000\000\000\000\000"}, - {335, "gen_for", 0, 6, states_79, - "\000\000\000\000\000\000\000\000\000\000\000\200\000\000\000\000\000\000\000\000\000"}, - {336, "gen_if", 0, 4, states_80, + {332, "list_if", 0, 4, states_76, + "\000\000\000\000\000\000\000\000\000\000\200\000\000\000\000\000\000\000\000\000\000"}, + {333, "gen_iter", 0, 2, states_77, + "\000\000\000\000\000\000\000\000\000\000\200\010\000\000\000\000\000\000\000\000\000"}, + {334, "gen_for", 0, 6, states_78, "\000\000\000\000\000\000\000\000\000\000\000\010\000\000\000\000\000\000\000\000\000"}, - {337, "testlist1", 0, 2, states_81, - "\000\040\010\000\000\000\000\000\000\000\000\000\000\020\004\000\300\020\222\006\000"}, - {338, "encoding_decl", 0, 2, states_82, + {335, "gen_if", 0, 4, states_79, + "\000\000\000\000\000\000\000\000\000\000\200\000\000\000\000\000\000\000\000\000\000"}, + {336, "testlist1", 0, 2, states_80, + "\000\040\010\000\000\000\000\000\000\004\000\000\000\004\001\000\030\102\062\000\000"}, + {337, "encoding_decl", 0, 2, states_81, "\000\000\010\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000"}, - {339, "yield_expr", 0, 3, states_83, - "\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\200"}, + {338, "yield_expr", 0, 3, states_82, + "\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\010"}, }; -static label labels[168] = { +static label labels[164] = { {0, "EMPTY"}, {256, 0}, {4, 0}, {267, 0}, - {291, 0}, + {290, 0}, {257, 0}, {266, 0}, {0, 0}, {258, 0}, - {326, 0}, + {325, 0}, {259, 0}, {50, 0}, {287, 0}, {7, 0}, - {329, 0}, + {328, 0}, {8, 0}, {260, 0}, {261, 0}, @@ -1971,11 +1955,11 @@ {1, 0}, {262, 0}, {11, 0}, - {299, 0}, + {298, 0}, {263, 0}, {264, 0}, {22, 0}, - {303, 0}, + {302, 0}, {12, 0}, {16, 0}, {36, 0}, @@ -1990,9 +1974,8 @@ {280, 0}, {288, 0}, {289, 0}, - {290, 0}, {270, 0}, - {339, 0}, + {338, 0}, {37, 0}, {38, 0}, {39, 0}, @@ -2008,7 +1991,7 @@ {1, "print"}, {35, 0}, {1, "del"}, - {325, 0}, + {324, 0}, {1, "pass"}, {275, 0}, {276, 0}, @@ -2030,97 +2013,94 @@ {1, "as"}, {284, 0}, {1, "global"}, - {1, "exec"}, - {309, 0}, - {1, "in"}, {1, "assert"}, + {291, 0}, {292, 0}, {293, 0}, {294, 0}, {295, 0}, - {296, 0}, - {328, 0}, + {327, 0}, {1, "if"}, {1, "elif"}, {1, "else"}, {1, "while"}, {1, "for"}, + {1, "in"}, {1, "try"}, - {298, 0}, + {297, 0}, {1, "finally"}, {1, "with"}, - {297, 0}, + {296, 0}, + {308, 0}, {1, "except"}, {5, 0}, {6, 0}, + {299, 0}, {300, 0}, + {303, 0}, {301, 0}, - {304, 0}, - {302, 0}, {1, "lambda"}, - {320, 0}, - {305, 0}, + {319, 0}, + {304, 0}, {1, "or"}, - {306, 0}, + {305, 0}, {1, "and"}, {1, "not"}, + {306, 0}, {307, 0}, - {308, 0}, {20, 0}, {21, 0}, {28, 0}, {31, 0}, {30, 0}, {29, 0}, - {29, 0}, {1, "is"}, - {310, 0}, + {309, 0}, {18, 0}, - {311, 0}, + {310, 0}, {33, 0}, - {312, 0}, + {311, 0}, {19, 0}, - {313, 0}, + {312, 0}, {34, 0}, - {314, 0}, + {313, 0}, {14, 0}, {15, 0}, - {315, 0}, + {314, 0}, {17, 0}, {24, 0}, {48, 0}, {32, 0}, + {315, 0}, {316, 0}, - {317, 0}, - {321, 0}, - {319, 0}, - {9, 0}, + {320, 0}, {318, 0}, + {9, 0}, + {317, 0}, {10, 0}, {26, 0}, - {327, 0}, + {326, 0}, {27, 0}, - {25, 0}, - {337, 0}, {2, 0}, {3, 0}, - {332, 0}, - {335, 0}, + {331, 0}, + {334, 0}, + {321, 0}, {322, 0}, {323, 0}, - {324, 0}, {1, "class"}, + {329, 0}, {330, 0}, - {331, 0}, + {332, 0}, {333, 0}, - {334, 0}, + {335, 0}, {336, 0}, - {338, 0}, + {337, 0}, {1, "yield"}, }; grammar _PyParser_Grammar = { - 84, + 83, dfas, - {168, labels}, + {164, labels}, 256 }; Modified: python/branches/p3yk-noslice/Python/import.c ============================================================================== --- python/branches/p3yk-noslice/Python/import.c (original) +++ python/branches/p3yk-noslice/Python/import.c Fri Dec 15 05:21:50 2006 @@ -64,10 +64,15 @@ Python 2.5b3: 62111 (fix wrong code: x += yield) Python 2.5c1: 62121 (fix wrong lnotab with for loops and storing constants that should have been removed) + Python 2.5c2: 62131 (fix wrong code: for x, in ... in listcomp/genexp) + Python 2.6a0: 62141 (peephole optimizations) Python 3000: 3000 + 3010 (removed UNARY_CONVERT) + 3020 (added BUILD_SET) + 3030 (added keyword-only parameters) . */ -#define MAGIC (3000 | ((long)'\r'<<16) | ((long)'\n'<<24)) +#define MAGIC (3030 | ((long)'\r'<<16) | ((long)'\n'<<24)) /* Magic word as global; note that _PyImport_Init() can change the value of this global to accommodate for alterations of how the @@ -796,14 +801,16 @@ { PyCodeObject *co = NULL; mod_ty mod; - PyArena *arena = PyArena_New(); + PyArena *arena = PyArena_New(); + if (arena == NULL) + return NULL; mod = PyParser_ASTFromFile(fp, pathname, Py_file_input, 0, 0, 0, NULL, arena); if (mod) { co = PyAST_Compile(mod, pathname, NULL, arena); } - PyArena_Free(arena); + PyArena_Free(arena); return co; } @@ -1027,7 +1034,7 @@ /* Return an importer object for a sys.path/pkg.__path__ item 'p', possibly by fetching it from the path_importer_cache dict. If it - wasn't yet cached, traverse path_hooks until it a hook is found + wasn't yet cached, traverse path_hooks until a hook is found that can handle the path item. Return None if no hook could; this tells our caller it should fall back to the builtin import mechanism. Cache the result in path_importer_cache. @@ -1799,7 +1806,7 @@ /* Initialize a built-in module. - Return 1 for succes, 0 if the module is not found, and -1 with + Return 1 for success, 0 if the module is not found, and -1 with an exception set if the initialization failed. */ static int @@ -2114,7 +2121,7 @@ size_t len; if (lastdot == NULL && level > 0) { PyErr_SetString(PyExc_ValueError, - "Relative importpath too deep"); + "Attempted relative import in non-package"); return NULL; } if (lastdot == NULL) @@ -2133,7 +2140,8 @@ char *dot = strrchr(buf, '.'); if (dot == NULL) { PyErr_SetString(PyExc_ValueError, - "Relative importpath too deep"); + "Attempted relative import beyond " + "toplevel package"); return NULL; } *dot = '\0'; Modified: python/branches/p3yk-noslice/Python/marshal.c ============================================================================== --- python/branches/p3yk-noslice/Python/marshal.c (original) +++ python/branches/p3yk-noslice/Python/marshal.c Fri Dec 15 05:21:50 2006 @@ -349,6 +349,7 @@ PyCodeObject *co = (PyCodeObject *)v; w_byte(TYPE_CODE, p); w_long(co->co_argcount, p); + w_long(co->co_kwonlyargcount, p); w_long(co->co_nlocals, p); w_long(co->co_stacksize, p); w_long(co->co_flags, p); @@ -546,6 +547,11 @@ int size; PyLongObject *ob; n = r_long(p); + if (n < -INT_MAX || n > INT_MAX) { + PyErr_SetString(PyExc_ValueError, + "bad marshal data"); + return NULL; + } size = n<0 ? -n : n; ob = _PyLong_New(size); if (ob == NULL) @@ -654,7 +660,7 @@ case TYPE_INTERNED: case TYPE_STRING: n = r_long(p); - if (n < 0) { + if (n < 0 || n > INT_MAX) { PyErr_SetString(PyExc_ValueError, "bad marshal data"); return NULL; } @@ -689,7 +695,7 @@ char *buffer; n = r_long(p); - if (n < 0) { + if (n < 0 || n > INT_MAX) { PyErr_SetString(PyExc_ValueError, "bad marshal data"); return NULL; } @@ -710,7 +716,7 @@ case TYPE_TUPLE: n = r_long(p); - if (n < 0) { + if (n < 0 || n > INT_MAX) { PyErr_SetString(PyExc_ValueError, "bad marshal data"); return NULL; } @@ -733,7 +739,7 @@ case TYPE_LIST: n = r_long(p); - if (n < 0) { + if (n < 0 || n > INT_MAX) { PyErr_SetString(PyExc_ValueError, "bad marshal data"); return NULL; } @@ -815,6 +821,7 @@ } else { int argcount; + int kwonlyargcount; int nlocals; int stacksize; int flags; @@ -831,10 +838,12 @@ v = NULL; - argcount = r_long(p); - nlocals = r_long(p); - stacksize = r_long(p); - flags = r_long(p); + /* XXX ignore long->int overflows for now */ + argcount = (int)r_long(p); + kwonlyargcount = (int)r_long(p); + nlocals = (int)r_long(p); + stacksize = (int)r_long(p); + flags = (int)r_long(p); code = r_object(p); if (code == NULL) goto code_error; @@ -859,13 +868,14 @@ name = r_object(p); if (name == NULL) goto code_error; - firstlineno = r_long(p); + firstlineno = (int)r_long(p); lnotab = r_object(p); if (lnotab == NULL) goto code_error; v = (PyObject *) PyCode_New( - argcount, nlocals, stacksize, flags, + argcount, kwonlyargcount, + nlocals, stacksize, flags, code, consts, names, varnames, freevars, cellvars, filename, name, firstlineno, lnotab); @@ -1031,10 +1041,16 @@ wf.strings = (version > 0) ? PyDict_New() : NULL; w_object(x, &wf); Py_XDECREF(wf.strings); - if (wf.str != NULL) - _PyString_Resize(&wf.str, - (int) (wf.ptr - - PyString_AS_STRING((PyStringObject *)wf.str))); + if (wf.str != NULL) { + char *base = PyString_AS_STRING((PyStringObject *)wf.str); + if (wf.ptr - base > PY_SSIZE_T_MAX) { + Py_DECREF(wf.str); + PyErr_SetString(PyExc_OverflowError, + "too much marshall data for a string"); + return NULL; + } + _PyString_Resize(&wf.str, (Py_ssize_t)(wf.ptr - base)); + } if (wf.error) { Py_XDECREF(wf.str); PyErr_SetString(PyExc_ValueError, Modified: python/branches/p3yk-noslice/Python/modsupport.c ============================================================================== --- python/branches/p3yk-noslice/Python/modsupport.c (original) +++ python/branches/p3yk-noslice/Python/modsupport.c Fri Dec 15 05:21:50 2006 @@ -421,7 +421,7 @@ "string too long for Python string"); return NULL; } - n = (int)m; + n = (Py_ssize_t)m; } v = PyString_FromStringAndSize(str, n); } Modified: python/branches/p3yk-noslice/Python/mystrtoul.c ============================================================================== --- python/branches/p3yk-noslice/Python/mystrtoul.c (original) +++ python/branches/p3yk-noslice/Python/mystrtoul.c Fri Dec 15 05:21:50 2006 @@ -195,13 +195,10 @@ return (unsigned long)-1; } -/* Checking for overflow in PyOS_strtol is a PITA since C doesn't define - * anything about what happens when a signed integer operation overflows, - * and some compilers think they're doing you a favor by being "clever" - * then. Python assumes a 2's-complement representation, so that the bit - * pattern for the largest postive signed long is LONG_MAX, and for - * the smallest negative signed long is LONG_MAX + 1. +/* Checking for overflow in PyOS_strtol is a PITA; see comments + * about PY_ABS_LONG_MIN in longobject.c. */ +#define PY_ABS_LONG_MIN (0-(unsigned long)LONG_MIN) long PyOS_strtol(char *str, char **ptr, int base) @@ -224,8 +221,7 @@ if (sign == '-') result = -result; } - else if (sign == '-' && uresult == (unsigned long)LONG_MAX + 1) { - assert(LONG_MIN == -LONG_MAX-1); + else if (sign == '-' && uresult == PY_ABS_LONG_MIN) { result = LONG_MIN; } else { Modified: python/branches/p3yk-noslice/Python/peephole.c ============================================================================== --- python/branches/p3yk-noslice/Python/peephole.c (original) +++ python/branches/p3yk-noslice/Python/peephole.c Fri Dec 15 05:21:50 2006 @@ -189,9 +189,6 @@ if (PyObject_IsTrue(v) == 1) newconst = PyNumber_Negative(v); break; - case UNARY_CONVERT: - newconst = PyObject_Repr(v); - break; case UNARY_INVERT: newconst = PyNumber_Invert(v); break; @@ -470,7 +467,6 @@ /* Fold unary ops on constants. LOAD_CONST c1 UNARY_OP --> LOAD_CONST unary_op(c) */ case UNARY_NEGATIVE: - case UNARY_CONVERT: case UNARY_INVERT: if (lastlc >= 1 && ISBASICBLOCK(blocks, i-3, 4) && @@ -518,6 +514,13 @@ case SETUP_EXCEPT: case SETUP_FINALLY: tgt = GETJUMPTGT(codestr, i); + /* Replace JUMP_* to a RETURN into just a RETURN */ + if (UNCONDITIONAL_JUMP(opcode) && + codestr[tgt] == RETURN_VALUE) { + codestr[i] = RETURN_VALUE; + memset(codestr+i+1, NOP, 2); + continue; + } if (!UNCONDITIONAL_JUMP(codestr[tgt])) continue; tgttgt = GETJUMPTGT(codestr, tgt); @@ -535,12 +538,16 @@ goto exitUnchanged; /* Replace RETURN LOAD_CONST None RETURN with just RETURN */ + /* Remove unreachable JUMPs after RETURN */ case RETURN_VALUE: - if (i+4 >= codelen || - codestr[i+4] != RETURN_VALUE || - !ISBASICBLOCK(blocks,i,5)) + if (i+4 >= codelen) continue; - memset(codestr+i+1, NOP, 4); + if (codestr[i+4] == RETURN_VALUE && + ISBASICBLOCK(blocks,i,5)) + memset(codestr+i+1, NOP, 4); + else if (UNCONDITIONAL_JUMP(codestr[i+1]) && + ISBASICBLOCK(blocks,i,4)) + memset(codestr+i+1, NOP, 3); break; } } Modified: python/branches/p3yk-noslice/Python/pystate.c ============================================================================== --- python/branches/p3yk-noslice/Python/pystate.c (original) +++ python/branches/p3yk-noslice/Python/pystate.c Fri Dec 15 05:21:50 2006 @@ -309,9 +309,14 @@ */ #if defined(Py_DEBUG) && defined(WITH_THREAD) if (newts) { + /* This can be called from PyEval_RestoreThread(). Similar + to it, we need to ensure errno doesn't change. + */ + int err = errno; PyThreadState *check = PyGILState_GetThisThreadState(); if (check && check->interp == newts->interp && check != newts) Py_FatalError("Invalid thread state for this thread"); + errno = err; } #endif return oldts; @@ -496,7 +501,7 @@ { PyThread_delete_key(autoTLSkey); autoTLSkey = 0; - autoInterpreterState = NULL;; + autoInterpreterState = NULL; } /* When a thread state is created for a thread by some mechanism other than @@ -504,7 +509,7 @@ it so it doesn't try to create another thread state for the thread (this is a better fix for SF bug #1010677 than the first one attempted). */ -void +static void _PyGILState_NoteThreadState(PyThreadState* tstate) { /* If autoTLSkey is 0, this must be the very first threadstate created Modified: python/branches/p3yk-noslice/Python/pythonrun.c ============================================================================== --- python/branches/p3yk-noslice/Python/pythonrun.c (original) +++ python/branches/p3yk-noslice/Python/pythonrun.c Fri Dec 15 05:21:50 2006 @@ -527,11 +527,15 @@ bimod = _PyImport_FindExtension("__builtin__", "__builtin__"); if (bimod != NULL) { interp->builtins = PyModule_GetDict(bimod); + if (interp->builtins == NULL) + goto handle_error; Py_INCREF(interp->builtins); } sysmod = _PyImport_FindExtension("sys", "sys"); if (bimod != NULL && sysmod != NULL) { interp->sysdict = PyModule_GetDict(sysmod); + if (interp->sysdict == NULL) + goto handle_error; Py_INCREF(interp->sysdict); PySys_SetPath(Py_GetPath()); PyDict_SetItemString(interp->sysdict, "modules", @@ -545,6 +549,7 @@ if (!PyErr_Occurred()) return tstate; +handle_error: /* Oops, it didn't work. Undo it all. */ PyErr_Print(); @@ -718,6 +723,15 @@ ((flags) ? ((((flags)->cf_flags & PyCF_DONT_IMPLY_DEDENT) ? \ PyPARSE_DONT_IMPLY_DEDENT : 0)) : 0) +#if 0 +/* Keep an example of flags with future keyword support. */ +#define PARSER_FLAGS(flags) \ + ((flags) ? ((((flags)->cf_flags & PyCF_DONT_IMPLY_DEDENT) ? \ + PyPARSE_DONT_IMPLY_DEDENT : 0) \ + | ((flags)->cf_flags & CO_FUTURE_WITH_STATEMENT ? \ + PyPARSE_WITH_IS_KEYWORD : 0)) : 0) +#endif + int PyRun_InteractiveOneFlags(FILE *fp, const char *filename, PyCompilerFlags *flags) { Modified: python/branches/p3yk-noslice/Python/structmember.c ============================================================================== --- python/branches/p3yk-noslice/Python/structmember.c (original) +++ python/branches/p3yk-noslice/Python/structmember.c Fri Dec 15 05:21:50 2006 @@ -62,29 +62,28 @@ addr += l->offset; switch (l->type) { case T_BYTE: - v = PyInt_FromLong( - (long) (((*(char*)addr & 0xff) ^ 0x80) - 0x80)); + v = PyInt_FromLong(*(char*)addr); break; case T_UBYTE: - v = PyInt_FromLong((long) *(char*)addr & 0xff); + v = PyLong_FromUnsignedLong(*(unsigned char*)addr); break; case T_SHORT: - v = PyInt_FromLong((long) *(short*)addr); + v = PyInt_FromLong(*(short*)addr); break; case T_USHORT: - v = PyInt_FromLong((long) *(unsigned short*)addr); + v = PyLong_FromUnsignedLong(*(unsigned short*)addr); break; case T_INT: - v = PyInt_FromLong((long) *(int*)addr); + v = PyInt_FromLong(*(int*)addr); break; case T_UINT: - v = PyInt_FromLong((long) *(unsigned int*)addr); + v = PyLong_FromUnsignedLong(*(unsigned int*)addr); break; case T_LONG: v = PyInt_FromLong(*(long*)addr); break; case T_ULONG: - v = PyLong_FromDouble((double) *(unsigned long*)addr); + v = PyLong_FromUnsignedLong(*(unsigned long*)addr); break; case T_FLOAT: v = PyFloat_FromDouble((double)*(float*)addr); @@ -179,68 +178,107 @@ } addr += l->offset; switch (l->type) { - case T_BYTE: - case T_UBYTE: - if (!PyInt_Check(v)) { - PyErr_BadArgument(); + case T_BYTE:{ + long long_val; + long_val = PyInt_AsLong(v); + if ((long_val == -1) && PyErr_Occurred()) return -1; - } - *(char*)addr = (char) PyInt_AsLong(v); + /* XXX: For compatibility, only warn about truncations + for now. */ + if ((long_val > CHAR_MAX) || (long_val < CHAR_MIN)) + PyErr_Warn(PyExc_RuntimeWarning, "Truncation of value to char"); + *(char*)addr = (char)long_val; break; - case T_SHORT: - case T_USHORT: - if (!PyInt_Check(v)) { - PyErr_BadArgument(); - return -1; } - *(short*)addr = (short) PyInt_AsLong(v); - break; - case T_UINT: - case T_INT: - if (!PyInt_Check(v)) { - PyErr_BadArgument(); + case T_UBYTE:{ + long long_val; + long_val = PyInt_AsLong(v); + if ((long_val == -1) && PyErr_Occurred()) return -1; - } - *(int*)addr = (int) PyInt_AsLong(v); + if ((long_val > UCHAR_MAX) || (long_val < 0)) + PyErr_Warn(PyExc_RuntimeWarning, "Truncation of value to unsigned char"); + *(unsigned char*)addr = (unsigned char)long_val; break; - case T_LONG: - if (!PyInt_Check(v)) { - PyErr_BadArgument(); + } + case T_SHORT:{ + long long_val; + long_val = PyInt_AsLong(v); + if ((long_val == -1) && PyErr_Occurred()) return -1; + if ((long_val > SHRT_MAX) || (long_val < SHRT_MIN)) + PyErr_Warn(PyExc_RuntimeWarning, "Truncation of value to short"); + *(short*)addr = (short)long_val; + break; } - *(long*)addr = PyInt_AsLong(v); + case T_USHORT:{ + long long_val; + long_val = PyInt_AsLong(v); + if ((long_val == -1) && PyErr_Occurred()) + return -1; + if ((long_val > USHRT_MAX) || (long_val < 0)) + PyErr_Warn(PyExc_RuntimeWarning, "Truncation of value to unsigned short"); + *(unsigned short*)addr = (unsigned short)long_val; break; - case T_ULONG: - if (PyInt_Check(v)) - *(long*)addr = PyInt_AsLong(v); - else if (PyLong_Check(v)) - *(long*)addr = PyLong_AsLong(v); - else { - PyErr_BadArgument(); + } + case T_INT:{ + long long_val; + long_val = PyInt_AsLong(v); + if ((long_val == -1) && PyErr_Occurred()) return -1; + if ((long_val > INT_MAX) || (long_val < INT_MIN)) + PyErr_Warn(PyExc_RuntimeWarning, "Truncation of value to int"); + *(int *)addr = (int)long_val; + break; + } + case T_UINT:{ + unsigned long ulong_val; + ulong_val = PyLong_AsUnsignedLong(v); + if ((ulong_val == (unsigned int)-1) && PyErr_Occurred()) { + /* XXX: For compatibility, accept negative int values + as well. */ + PyErr_Clear(); + ulong_val = PyLong_AsLong(v); + if ((ulong_val == (unsigned int)-1) && PyErr_Occurred()) + return -1; + PyErr_Warn(PyExc_RuntimeWarning, "Writing negative value into unsigned field"); + } + if (ulong_val > UINT_MAX) + PyErr_Warn(PyExc_RuntimeWarning, "Truncation of value to unsigned int"); + *(unsigned int *)addr = (unsigned int)ulong_val; + break; + } + case T_LONG:{ + *(long*)addr = PyLong_AsLong(v); + if ((*(long*)addr == -1) && PyErr_Occurred()) + return -1; + break; + } + case T_ULONG:{ + *(unsigned long*)addr = PyLong_AsUnsignedLong(v); + if ((*(unsigned long*)addr == (unsigned long)-1) + && PyErr_Occurred()) { + /* XXX: For compatibility, accept negative int values + as well. */ + PyErr_Clear(); + *(unsigned long*)addr = PyLong_AsLong(v); + if ((*(unsigned long*)addr == (unsigned int)-1) && PyErr_Occurred()) + return -1; + PyErr_Warn(PyExc_RuntimeWarning, "Writing negative value into unsigned field"); } break; - case T_FLOAT: - if (PyInt_Check(v)) - *(float*)addr = - (float) PyInt_AsLong(v); - else if (PyFloat_Check(v)) - *(float*)addr = - (float) PyFloat_AsDouble(v); - else { - PyErr_BadArgument(); - return -1; } + case T_FLOAT:{ + double double_val; + double_val = PyFloat_AsDouble(v); + if ((double_val == -1) && PyErr_Occurred()) + return -1; + *(float*)addr = (float)double_val; break; + } case T_DOUBLE: - if (PyInt_Check(v)) - *(double*)addr = (double) PyInt_AsLong(v); - else if (PyFloat_Check(v)) - *(double*)addr = PyFloat_AsDouble(v); - else { - PyErr_BadArgument(); + *(double*)addr = PyFloat_AsDouble(v); + if ((*(double*)addr == -1) && PyErr_Occurred()) return -1; - } break; case T_OBJECT: case T_OBJECT_EX: Modified: python/branches/p3yk-noslice/Python/symtable.c ============================================================================== --- python/branches/p3yk-noslice/Python/symtable.c (original) +++ python/branches/p3yk-noslice/Python/symtable.c Fri Dec 15 05:21:50 2006 @@ -480,8 +480,7 @@ "is a nested function"); switch (ste->ste_unoptimized) { - case OPT_TOPLEVEL: /* exec / import * at top-level is fine */ - case OPT_EXEC: /* qualified exec is fine */ + case OPT_TOPLEVEL: /* import * at top-level is fine */ return 1; case OPT_IMPORT_STAR: PyOS_snprintf(buf, sizeof(buf), @@ -489,18 +488,6 @@ "because it is %s", PyString_AS_STRING(ste->ste_name), trailer); break; - case OPT_BARE_EXEC: - PyOS_snprintf(buf, sizeof(buf), - "unqualified exec is not allowed in function " - "'%.100s' it %s", - PyString_AS_STRING(ste->ste_name), trailer); - break; - default: - PyOS_snprintf(buf, sizeof(buf), - "function '%.100s' uses import * and bare exec, " - "which are illegal because it %s", - PyString_AS_STRING(ste->ste_name), trailer); - break; } PyErr_SetString(PyExc_SyntaxError, buf); @@ -906,6 +893,17 @@ } \ } +#define VISIT_KWONLYDEFAULTS(ST, KW_DEFAULTS) { \ + int i = 0; \ + asdl_seq *seq = (KW_DEFAULTS); /* avoid variable capture */ \ + for (i = 0; i < asdl_seq_LEN(seq); i++) { \ + expr_ty elt = (expr_ty)asdl_seq_GET(seq, i); \ + if (!elt) continue; /* can be NULL */ \ + if (!symtable_visit_expr((ST), elt)) \ + return 0; \ + } \ +} + static int symtable_new_tmpname(struct symtable *st) { @@ -923,6 +921,8 @@ return 1; } + + static int symtable_visit_stmt(struct symtable *st, stmt_ty s) { @@ -932,6 +932,9 @@ return 0; if (s->v.FunctionDef.args->defaults) VISIT_SEQ(st, expr, s->v.FunctionDef.args->defaults); + if (s->v.FunctionDef.args->kw_defaults) + VISIT_KWONLYDEFAULTS(st, + s->v.FunctionDef.args->kw_defaults); if (s->v.FunctionDef.decorators) VISIT_SEQ(st, expr, s->v.FunctionDef.decorators); if (!symtable_enter_block(st, s->v.FunctionDef.name, @@ -1045,19 +1048,6 @@ if (st->st_cur->ste_unoptimized && !st->st_cur->ste_opt_lineno) st->st_cur->ste_opt_lineno = s->lineno; break; - case Exec_kind: - VISIT(st, expr, s->v.Exec.body); - if (!st->st_cur->ste_opt_lineno) - st->st_cur->ste_opt_lineno = s->lineno; - if (s->v.Exec.globals) { - st->st_cur->ste_unoptimized |= OPT_EXEC; - VISIT(st, expr, s->v.Exec.globals); - if (s->v.Exec.locals) - VISIT(st, expr, s->v.Exec.locals); - } else { - st->st_cur->ste_unoptimized |= OPT_BARE_EXEC; - } - break; case Global_kind: { int i; asdl_seq *seq = s->v.Global.names; @@ -1147,6 +1137,9 @@ VISIT_SEQ(st, expr, e->v.Dict.keys); VISIT_SEQ(st, expr, e->v.Dict.values); break; + case Set_kind: + VISIT_SEQ(st, expr, e->v.Set.elts); + break; case ListComp_kind: if (!symtable_new_tmpname(st)) return 0; @@ -1182,11 +1175,9 @@ if (e->v.Call.kwargs) VISIT(st, expr, e->v.Call.kwargs); break; - case Repr_kind: - VISIT(st, expr, e->v.Repr.value); - break; case Num_kind: case Str_kind: + case Ellipsis_kind: /* Nothing to do here. */ break; /* The following exprs can be assignment targets. */ @@ -1287,6 +1278,8 @@ */ if (a->args && !symtable_visit_params(st, a->args, 1)) return 0; + if (a->kwonlyargs && !symtable_visit_params(st, a->kwonlyargs, 1)) + return 0; if (a->vararg) { if (!symtable_add_def(st, a->vararg, DEF_PARAM)) return 0; @@ -1391,8 +1384,6 @@ case Index_kind: VISIT(st, expr, s->v.Index.value) break; - case Ellipsis_kind: - break; } return 1; } Modified: python/branches/p3yk-noslice/Python/sysmodule.c ============================================================================== --- python/branches/p3yk-noslice/Python/sysmodule.c (original) +++ python/branches/p3yk-noslice/Python/sysmodule.c Fri Dec 15 05:21:50 2006 @@ -979,6 +979,8 @@ br_start = python + 8; br_end = strchr(br_start, '/'); + assert(br_end); + /* Works even for trunk, as we are in trunk/Python/sysmodule.c */ br_end2 = strchr(br_end+1, '/'); @@ -991,6 +993,8 @@ } else if (istag || strncmp(br_start, "branches", 8) == 0) { len = br_end2 - br_start; + assert(len >= 13); + assert(len < (sizeof(patchlevel_revision) - 13)); strncpy(branch, br_start, len); branch[len] = '\0'; @@ -1221,7 +1225,7 @@ p = strchr(path, delim); if (p == NULL) p = strchr(path, '\0'); /* End of string */ - w = PyString_FromStringAndSize(path, (int) (p - path)); + w = PyString_FromStringAndSize(path, (Py_ssize_t) (p - path)); if (w == NULL) { Py_DECREF(v); return NULL; Modified: python/branches/p3yk-noslice/README ============================================================================== --- python/branches/p3yk-noslice/README (original) +++ python/branches/p3yk-noslice/README Fri Dec 15 05:21:50 2006 @@ -231,6 +231,11 @@ available for all modern systems, either in the form of updated compilers from the vendor, or one of the free compilers (gcc). +If "make install" fails mysteriously during the "compiling the library" +step, make sure that you don't have any of the PYTHONPATH or PYTHONHOME +environment variables set, as they may interfere with the newly built +executable which is compiling the library. + Unsupported systems ------------------- Modified: python/branches/p3yk-noslice/Tools/compiler/ast.txt ============================================================================== --- python/branches/p3yk-noslice/Tools/compiler/ast.txt (original) +++ python/branches/p3yk-noslice/Tools/compiler/ast.txt Fri Dec 15 05:21:50 2006 @@ -12,8 +12,8 @@ Module: doc*, node Stmt: nodes! Decorators: nodes! -Function: decorators&, name*, argnames*, defaults!, flags*, doc*, code -Lambda: argnames*, defaults!, flags*, code +Function: decorators&, name*, argnames*, defaults!, kwonlyargs*, flags*, doc*, code +Lambda: argnames*, defaults!, kwonlyargs*, flags*, code Class: name*, bases!, doc*, code Pass: Break: @@ -23,7 +23,6 @@ With: expr, vars&, body If: tests!, else_& IfExp: test, then, else_ -Exec: expr, locals&, globals& From: modname*, names*, level* Import: names* Raise: expr1&, expr2&, expr3& @@ -50,16 +49,15 @@ GenExprIf: test List: nodes! Dict: items! +Set: items! Not: expr Compare: expr, ops! Name: name* Global: names* -Backquote: expr Getattr: expr, attrname* CallFunc: node, args!, star_args& = None, dstar_args& = None Keyword: name*, expr Subscript: expr, flags*, subs! -Ellipsis: Sliceobj: nodes! Slice: expr, flags*, lower&, upper& Assert: test, fail& @@ -97,8 +95,9 @@ self.kwargs = 1 init(GenExpr): - self.argnames = ['[outmost-iterable]'] + self.argnames = ['.0'] self.varargs = self.kwargs = None + self.kwonlyargs = () init(GenExprFor): self.is_outmost = False Modified: python/branches/p3yk-noslice/Tools/compiler/astgen.py ============================================================================== --- python/branches/p3yk-noslice/Tools/compiler/astgen.py (original) +++ python/branches/p3yk-noslice/Tools/compiler/astgen.py Fri Dec 15 05:21:50 2006 @@ -235,7 +235,7 @@ This file is automatically generated by Tools/compiler/astgen.py """ -from consts import CO_VARARGS, CO_VARKEYWORDS +from compiler.consts import CO_VARARGS, CO_VARKEYWORDS def flatten(seq): l = [] Modified: python/branches/p3yk-noslice/Tools/modulator/modulator.py ============================================================================== --- python/branches/p3yk-noslice/Tools/modulator/modulator.py (original) +++ python/branches/p3yk-noslice/Tools/modulator/modulator.py Fri Dec 15 05:21:50 2006 @@ -126,7 +126,7 @@ fp = open(fn, 'w') try: - exec pycode + exec(pycode) except: message('An error occurred:-)') return @@ -371,7 +371,7 @@ fp = open(sys.argv[1]) pycode = fp.read() try: - exec pycode + exec(pycode) except: sys.stderr.write('An error occurred:-)\n') sys.exit(1) Modified: python/branches/p3yk-noslice/Tools/msi/msi.py ============================================================================== --- python/branches/p3yk-noslice/Tools/msi/msi.py (original) +++ python/branches/p3yk-noslice/Tools/msi/msi.py Fri Dec 15 05:21:50 2006 @@ -872,6 +872,12 @@ version=version, language=lang) tmpfiles.append("msvcr71.dll") + # Check if _ctypes.pyd exists + have_ctypes = os.path.exists(srcdir+"/PCBuild/_ctypes.pyd") + if not have_ctypes: + print "WARNING: _ctypes.pyd not found, ctypes will not be included" + extensions.remove("_ctypes.pyd") + # Add all .py files in Lib, except lib-tk, test dirs={} pydirs = [(root,"Lib")] @@ -889,6 +895,8 @@ # data: Lib/email/test # output: Lib/test testsuite.set_current() + elif not have_ctypes and dir == "ctypes": + continue else: default_feature.set_current() lib = PyDirectory(db, cab, parent, dir, dir, "%s|%s" % (parent.make_short(dir), dir)) @@ -913,6 +921,7 @@ lib.add_file("185test.db") lib.add_file("audiotest.au") lib.add_file("cfgparser.1") + lib.add_file("sgml_input.html") lib.add_file("test.xml") lib.add_file("test.xml.out") lib.add_file("testtar.tar") Modified: python/branches/p3yk-noslice/Tools/msi/uuids.py ============================================================================== --- python/branches/p3yk-noslice/Tools/msi/uuids.py (original) +++ python/branches/p3yk-noslice/Tools/msi/uuids.py Fri Dec 15 05:21:50 2006 @@ -22,6 +22,8 @@ '2.4.2150':'{b191e49c-ea23-43b2-b28a-14e0784069b8}', # 2.4.2 '2.4.3121':'{f669ed4d-1dce-41c4-9617-d985397187a1}', # 2.4.3c1 '2.4.3150':'{75e71add-042c-4f30-bfac-a9ec42351313}', # 2.4.3 + '2.4.4121':'{cd2862db-22a4-4688-8772-85407ea21550}', # 2.4.4c1 + '2.4.4150':'{60e2c8c9-6cf3-4b1a-9618-e304946c94e6}', # 2.4.4 '2.5.101': '{bc14ce3e-5e72-4a64-ac1f-bf59a571898c}', # 2.5a1 '2.5.102': '{5eed51c1-8e9d-4071-94c5-b40de5d49ba5}', # 2.5a2 '2.5.103': '{73dcd966-ffec-415f-bb39-8342c1f47017}', # 2.5a3 Modified: python/branches/p3yk-noslice/Tools/pybench/pybench.py ============================================================================== --- python/branches/p3yk-noslice/Tools/pybench/pybench.py (original) +++ python/branches/p3yk-noslice/Tools/pybench/pybench.py Fri Dec 15 05:21:50 2006 @@ -885,7 +885,7 @@ else: bench.print_benchmark(hidenoise=hidenoise, limitnames=limitnames) - except IOError: + except IOError, reason: print '* Error opening/reading file %s: %s' % ( repr(show_bench), reason) @@ -931,8 +931,13 @@ bench.name = reportfile pickle.dump(bench,f) f.close() - except IOError: + except IOError, reason: print '* Error opening/writing reportfile' + except IOError, reason: + print '* Error opening/writing reportfile %s: %s' % ( + reportfile, + reason) + print if __name__ == '__main__': PyBenchCmdline() Modified: python/branches/p3yk-noslice/Tools/scripts/findnocoding.py ============================================================================== --- python/branches/p3yk-noslice/Tools/scripts/findnocoding.py (original) +++ python/branches/p3yk-noslice/Tools/scripts/findnocoding.py Fri Dec 15 05:21:50 2006 @@ -5,7 +5,7 @@ Usage: nocoding.py dir1 [dir2...] """ -__author__ = "Oleg Broytmann, Reinhold Birkenfeld" +__author__ = "Oleg Broytmann, Georg Brandl" import sys, os, re, getopt Modified: python/branches/p3yk-noslice/Tools/scripts/fixdiv.py ============================================================================== --- python/branches/p3yk-noslice/Tools/scripts/fixdiv.py (original) +++ python/branches/p3yk-noslice/Tools/scripts/fixdiv.py Fri Dec 15 05:21:50 2006 @@ -113,7 +113,7 @@ future division statement. - Warnings may be issued for code not read from a file, but executed - using an exec statement or the eval() function. These may have + using the exec() or eval() functions. These may have in the filename position, in which case the fixdiv script will attempt and fail to open a file named '' and issue a warning about this failure; or these may be reported as 'Phantom' Modified: python/branches/p3yk-noslice/Tools/scripts/h2py.py ============================================================================== --- python/branches/p3yk-noslice/Tools/scripts/h2py.py (original) +++ python/branches/p3yk-noslice/Tools/scripts/h2py.py Fri Dec 15 05:21:50 2006 @@ -130,7 +130,7 @@ ok = 0 stmt = '%s = %s\n' % (name, body.strip()) try: - exec stmt in env + exec(stmt, env) except: sys.stderr.write('Skipping: %s' % stmt) else: @@ -142,7 +142,7 @@ body = pytify(body) stmt = 'def %s(%s): return %s\n' % (macro, arg, body) try: - exec stmt in env + exec(stmt, env) except: sys.stderr.write('Skipping: %s' % stmt) else: Modified: python/branches/p3yk-noslice/Tools/scripts/pysource.py ============================================================================== --- python/branches/p3yk-noslice/Tools/scripts/pysource.py (original) +++ python/branches/p3yk-noslice/Tools/scripts/pysource.py Fri Dec 15 05:21:50 2006 @@ -15,7 +15,7 @@ walk_python_files() recursively lists all Python files under the given directories. """ -__author__ = "Oleg Broytmann, Reinhold Birkenfeld" +__author__ = "Oleg Broytmann, Georg Brandl" __all__ = ["has_python_ext", "looks_like_python", "can_be_compiled", "walk_python_files"] Modified: python/branches/p3yk-noslice/configure ============================================================================== --- python/branches/p3yk-noslice/configure (original) +++ python/branches/p3yk-noslice/configure Fri Dec 15 05:21:50 2006 @@ -1,7 +1,7 @@ #! /bin/sh -# From configure.in Revision: 46754 . +# From configure.in Revision: 51211 . # Guess values for system-dependent variables and create Makefiles. -# Generated by GNU Autoconf 2.60 for python 3.0. +# Generated by GNU Autoconf 2.61 for python 3.0. # # Report bugs to . # @@ -13,7 +13,8 @@ ## M4sh Initialization. ## ## --------------------- ## -# Be Bourne compatible +# Be more Bourne compatible +DUALCASE=1; export DUALCASE # for MKS sh if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then emulate sh NULLCMD=: @@ -22,10 +23,13 @@ alias -g '${1+"$@"}'='"$@"' setopt NO_GLOB_SUBST else - case `(set -o) 2>/dev/null` in *posix*) set -o posix;; esac + case `(set -o) 2>/dev/null` in + *posix*) set -o posix ;; +esac + fi -BIN_SH=xpg4; export BIN_SH # for Tru64 -DUALCASE=1; export DUALCASE # for MKS sh + + # PATH needs CR @@ -218,7 +222,7 @@ else as_candidate_shells= as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in /usr/bin/posix$PATH_SEPARATOR/bin$PATH_SEPARATOR/usr/bin$PATH_SEPARATOR$PATH +for as_dir in /bin$PATH_SEPARATOR/usr/bin$PATH_SEPARATOR$PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. @@ -236,7 +240,6 @@ # Try only shells that exist, to save several forks. if { test -f "$as_shell" || test -f "$as_shell.exe"; } && { ("$as_shell") 2> /dev/null <<\_ASEOF -# Be Bourne compatible if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then emulate sh NULLCMD=: @@ -245,10 +248,12 @@ alias -g '${1+"$@"}'='"$@"' setopt NO_GLOB_SUBST else - case `(set -o) 2>/dev/null` in *posix*) set -o posix;; esac + case `(set -o) 2>/dev/null` in + *posix*) set -o posix ;; +esac + fi -BIN_SH=xpg4; export BIN_SH # for Tru64 -DUALCASE=1; export DUALCASE # for MKS sh + : _ASEOF @@ -256,7 +261,6 @@ CONFIG_SHELL=$as_shell as_have_required=yes if { "$as_shell" 2> /dev/null <<\_ASEOF -# Be Bourne compatible if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then emulate sh NULLCMD=: @@ -265,10 +269,12 @@ alias -g '${1+"$@"}'='"$@"' setopt NO_GLOB_SUBST else - case `(set -o) 2>/dev/null` in *posix*) set -o posix;; esac + case `(set -o) 2>/dev/null` in + *posix*) set -o posix ;; +esac + fi -BIN_SH=xpg4; export BIN_SH # for Tru64 -DUALCASE=1; export DUALCASE # for MKS sh + : (as_func_return () { @@ -515,19 +521,28 @@ as_mkdir_p=false fi -# Find out whether ``test -x'' works. Don't use a zero-byte file, as -# systems may use methods other than mode bits to determine executability. -cat >conf$$.file <<_ASEOF -#! /bin/sh -exit 0 -_ASEOF -chmod +x conf$$.file -if test -x conf$$.file >/dev/null 2>&1; then - as_executable_p="test -x" +if test -x / >/dev/null 2>&1; then + as_test_x='test -x' else - as_executable_p=: + if ls -dL / >/dev/null 2>&1; then + as_ls_L_option=L + else + as_ls_L_option= + fi + as_test_x=' + eval sh -c '\'' + if test -d "$1"; then + test -d "$1/."; + else + case $1 in + -*)set "./$1";; + esac; + case `ls -ld'$as_ls_L_option' "$1" 2>/dev/null` in + ???[sx]*):;;*)false;;esac;fi + '\'' sh + ' fi -rm -f conf$$.file +as_executable_p=$as_test_x # Sed expression to map a string onto a valid CPP name. as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'" @@ -568,36 +583,36 @@ # Factoring default headers for most tests. ac_includes_default="\ #include -#if HAVE_SYS_TYPES_H +#ifdef HAVE_SYS_TYPES_H # include #endif -#if HAVE_SYS_STAT_H +#ifdef HAVE_SYS_STAT_H # include #endif -#if STDC_HEADERS +#ifdef STDC_HEADERS # include # include #else -# if HAVE_STDLIB_H +# ifdef HAVE_STDLIB_H # include # endif #endif -#if HAVE_STRING_H -# if !STDC_HEADERS && HAVE_MEMORY_H +#ifdef HAVE_STRING_H +# if !defined STDC_HEADERS && defined HAVE_MEMORY_H # include # endif # include #endif -#if HAVE_STRINGS_H +#ifdef HAVE_STRINGS_H # include #endif -#if HAVE_INTTYPES_H +#ifdef HAVE_INTTYPES_H # include #endif -#if HAVE_STDINT_H +#ifdef HAVE_STDINT_H # include #endif -#if HAVE_UNISTD_H +#ifdef HAVE_UNISTD_H # include #endif" @@ -724,6 +739,7 @@ CC CFLAGS LDFLAGS +LIBS CPPFLAGS CPP' @@ -831,10 +847,10 @@ -disable-* | --disable-*) ac_feature=`expr "x$ac_option" : 'x-*disable-\(.*\)'` # Reject names that are not valid shell variable names. - expr "x$ac_feature" : ".*[^-_$as_cr_alnum]" >/dev/null && + expr "x$ac_feature" : ".*[^-._$as_cr_alnum]" >/dev/null && { echo "$as_me: error: invalid feature name: $ac_feature" >&2 { (exit 1); exit 1; }; } - ac_feature=`echo $ac_feature | sed 's/-/_/g'` + ac_feature=`echo $ac_feature | sed 's/[-.]/_/g'` eval enable_$ac_feature=no ;; -docdir | --docdir | --docdi | --doc | --do) @@ -850,10 +866,10 @@ -enable-* | --enable-*) ac_feature=`expr "x$ac_option" : 'x-*enable-\([^=]*\)'` # Reject names that are not valid shell variable names. - expr "x$ac_feature" : ".*[^-_$as_cr_alnum]" >/dev/null && + expr "x$ac_feature" : ".*[^-._$as_cr_alnum]" >/dev/null && { echo "$as_me: error: invalid feature name: $ac_feature" >&2 { (exit 1); exit 1; }; } - ac_feature=`echo $ac_feature | sed 's/-/_/g'` + ac_feature=`echo $ac_feature | sed 's/[-.]/_/g'` eval enable_$ac_feature=\$ac_optarg ;; -exec-prefix | --exec_prefix | --exec-prefix | --exec-prefi \ @@ -1047,19 +1063,19 @@ -with-* | --with-*) ac_package=`expr "x$ac_option" : 'x-*with-\([^=]*\)'` # Reject names that are not valid shell variable names. - expr "x$ac_package" : ".*[^-_$as_cr_alnum]" >/dev/null && + expr "x$ac_package" : ".*[^-._$as_cr_alnum]" >/dev/null && { echo "$as_me: error: invalid package name: $ac_package" >&2 { (exit 1); exit 1; }; } - ac_package=`echo $ac_package| sed 's/-/_/g'` + ac_package=`echo $ac_package | sed 's/[-.]/_/g'` eval with_$ac_package=\$ac_optarg ;; -without-* | --without-*) ac_package=`expr "x$ac_option" : 'x-*without-\(.*\)'` # Reject names that are not valid shell variable names. - expr "x$ac_package" : ".*[^-_$as_cr_alnum]" >/dev/null && + expr "x$ac_package" : ".*[^-._$as_cr_alnum]" >/dev/null && { echo "$as_me: error: invalid package name: $ac_package" >&2 { (exit 1); exit 1; }; } - ac_package=`echo $ac_package | sed 's/-/_/g'` + ac_package=`echo $ac_package | sed 's/[-.]/_/g'` eval with_$ac_package=no ;; --x) @@ -1339,6 +1355,7 @@ CFLAGS C compiler flags LDFLAGS linker flags, e.g. -L if you have libraries in a nonstandard directory + LIBS libraries to pass to the linker, e.g. -l CPPFLAGS C/C++/Objective C preprocessor flags, e.g. -I if you have headers in a nonstandard directory CPP C preprocessor @@ -1408,7 +1425,7 @@ if $ac_init_version; then cat <<\_ACEOF python configure 3.0 -generated by GNU Autoconf 2.60 +generated by GNU Autoconf 2.61 Copyright (C) 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006 Free Software Foundation, Inc. @@ -1422,7 +1439,7 @@ running configure, to aid debugging if configure makes a mistake. It was created by python $as_me 3.0, which was -generated by GNU Autoconf 2.60. Invocation command line was +generated by GNU Autoconf 2.61. Invocation command line was $ $0 $@ @@ -1986,7 +2003,12 @@ # On OpenBSD, select(2) is not available if _XOPEN_SOURCE is defined, # even though select is a POSIX function. Reported by J. Ribbens. # Reconfirmed for OpenBSD 3.3 by Zachary Hamm, for 3.4 by Jason Ish. - OpenBSD/2.* | OpenBSD/3.[0123456789]) + OpenBSD/2.* | OpenBSD/3.[0123456789] | OpenBSD/4.[0]) + define_xopen_source=no;; + # Defining _XOPEN_SOURCE on NetBSD version prior to the introduction of + # _NETBSD_SOURCE disables certain features (eg. setgroups). Reported by + # Marc Recht + NetBSD/1.5 | NetBSD/1.5.* | NetBSD/1.6 | NetBSD/1.6.* | NetBSD/1.6A-S) define_xopen_source=no;; # On Solaris 2.6, sys/wait.h is inconsistent in the usage # of union __?sigval. Reported by Stuart Bishop. @@ -2218,7 +2240,7 @@ IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; }; then + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_CC="${ac_tool_prefix}gcc" echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 @@ -2258,7 +2280,7 @@ IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; }; then + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_ac_ct_CC="gcc" echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 @@ -2315,7 +2337,7 @@ IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; }; then + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_CC="${ac_tool_prefix}cc" echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 @@ -2356,7 +2378,7 @@ IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; }; then + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then if test "$as_dir/$ac_word$ac_exec_ext" = "/usr/ucb/cc"; then ac_prog_rejected=yes continue @@ -2414,7 +2436,7 @@ IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; }; then + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_CC="$ac_tool_prefix$ac_prog" echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 @@ -2458,7 +2480,7 @@ IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; }; then + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_ac_ct_CC="$ac_prog" echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 @@ -2599,7 +2621,7 @@ # in a Makefile. We should not override ac_cv_exeext if it was cached, # so that the user can short-circuit this test for compilers unknown to # Autoconf. -for ac_file in $ac_files +for ac_file in $ac_files '' do test -f "$ac_file" || continue case $ac_file in @@ -2627,6 +2649,12 @@ test "$ac_cv_exeext" = no && ac_cv_exeext= else + ac_file='' +fi + +{ echo "$as_me:$LINENO: result: $ac_file" >&5 +echo "${ECHO_T}$ac_file" >&6; } +if test -z "$ac_file"; then echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 @@ -2638,8 +2666,6 @@ fi ac_exeext=$ac_cv_exeext -{ echo "$as_me:$LINENO: result: $ac_file" >&5 -echo "${ECHO_T}$ac_file" >&6; } # Check that the compiler produces executables we can run. If not, either # the compiler is broken, or we cross compile. @@ -2817,27 +2843,10 @@ rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then ac_compiler_gnu=yes else echo "$as_me: failed program was:" >&5 @@ -2892,27 +2901,10 @@ rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then ac_cv_prog_cc_g=yes else echo "$as_me: failed program was:" >&5 @@ -2947,27 +2939,10 @@ rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then : else echo "$as_me: failed program was:" >&5 @@ -3003,27 +2978,10 @@ rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then ac_cv_prog_cc_g=yes else echo "$as_me: failed program was:" >&5 @@ -3139,27 +3097,10 @@ rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then ac_cv_prog_cc_c89=$ac_arg else echo "$as_me: failed program was:" >&5 @@ -3250,7 +3191,7 @@ IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; }; then + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_path_CXX="$as_dir/$ac_word$ac_exec_ext" echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 @@ -3291,7 +3232,7 @@ IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; }; then + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_path_CXX="$as_dir/$ac_word$ac_exec_ext" echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 @@ -3340,7 +3281,7 @@ IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; }; then + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_CXX="$ac_prog" echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 @@ -3439,17 +3380,10 @@ rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } >/dev/null; then - if test -s conftest.err; then - ac_cpp_err=$ac_c_preproc_warn_flag - ac_cpp_err=$ac_cpp_err$ac_c_werror_flag - else - ac_cpp_err= - fi -else - ac_cpp_err=yes -fi -if test -z "$ac_cpp_err"; then + (exit $ac_status); } >/dev/null && { + test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || + test ! -s conftest.err + }; then : else echo "$as_me: failed program was:" >&5 @@ -3483,17 +3417,10 @@ rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } >/dev/null; then - if test -s conftest.err; then - ac_cpp_err=$ac_c_preproc_warn_flag - ac_cpp_err=$ac_cpp_err$ac_c_werror_flag - else - ac_cpp_err= - fi -else - ac_cpp_err=yes -fi -if test -z "$ac_cpp_err"; then + (exit $ac_status); } >/dev/null && { + test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || + test ! -s conftest.err + }; then # Broken: success on invalid input. continue else @@ -3558,17 +3485,10 @@ rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } >/dev/null; then - if test -s conftest.err; then - ac_cpp_err=$ac_c_preproc_warn_flag - ac_cpp_err=$ac_cpp_err$ac_c_werror_flag - else - ac_cpp_err= - fi -else - ac_cpp_err=yes -fi -if test -z "$ac_cpp_err"; then + (exit $ac_status); } >/dev/null && { + test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || + test ! -s conftest.err + }; then : else echo "$as_me: failed program was:" >&5 @@ -3602,17 +3522,10 @@ rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } >/dev/null; then - if test -s conftest.err; then - ac_cpp_err=$ac_c_preproc_warn_flag - ac_cpp_err=$ac_cpp_err$ac_c_werror_flag - else - ac_cpp_err= - fi -else - ac_cpp_err=yes -fi -if test -z "$ac_cpp_err"; then + (exit $ac_status); } >/dev/null && { + test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || + test ! -s conftest.err + }; then # Broken: success on invalid input. continue else @@ -3667,7 +3580,7 @@ for ac_prog in grep ggrep; do for ac_exec_ext in '' $ac_executable_extensions; do ac_path_GREP="$as_dir/$ac_prog$ac_exec_ext" - { test -f "$ac_path_GREP" && $as_executable_p "$ac_path_GREP"; } || continue + { test -f "$ac_path_GREP" && $as_test_x "$ac_path_GREP"; } || continue # Check for GNU ac_path_GREP and select it if it is found. # Check for GNU $ac_path_GREP case `"$ac_path_GREP" --version 2>&1` in @@ -3749,7 +3662,7 @@ for ac_prog in egrep; do for ac_exec_ext in '' $ac_executable_extensions; do ac_path_EGREP="$as_dir/$ac_prog$ac_exec_ext" - { test -f "$ac_path_EGREP" && $as_executable_p "$ac_path_EGREP"; } || continue + { test -f "$ac_path_EGREP" && $as_test_x "$ac_path_EGREP"; } || continue # Check for GNU ac_path_EGREP and select it if it is found. # Check for GNU $ac_path_EGREP case `"$ac_path_EGREP" --version 2>&1` in @@ -4159,7 +4072,7 @@ IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; }; then + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_RANLIB="${ac_tool_prefix}ranlib" echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 @@ -4199,7 +4112,7 @@ IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; }; then + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_ac_ct_RANLIB="ranlib" echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 @@ -4257,7 +4170,7 @@ IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; }; then + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_AR="$ac_prog" echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 @@ -4300,7 +4213,7 @@ IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; }; then + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_SVNVERSION="found" echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 @@ -4404,7 +4317,7 @@ # by default. for ac_prog in ginstall scoinst install; do for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_prog$ac_exec_ext" && $as_executable_p "$as_dir/$ac_prog$ac_exec_ext"; }; then + if { test -f "$as_dir/$ac_prog$ac_exec_ext" && $as_test_x "$as_dir/$ac_prog$ac_exec_ext"; }; then if test $ac_prog = install && grep dspmsg "$as_dir/$ac_prog$ac_exec_ext" >/dev/null 2>&1; then # AIX install. It has an incompatible calling convention. @@ -4785,6 +4698,67 @@ fi fi +# Check whether GCC supports PyArg_ParseTuple format +if test "$GCC" = "yes" +then + { echo "$as_me:$LINENO: checking whether gcc supports ParseTuple __format__" >&5 +echo $ECHO_N "checking whether gcc supports ParseTuple __format__... $ECHO_C" >&6; } + save_CFLAGS=$CFLAGS + CFLAGS="$CFLAGS -Werror" + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + + void f(char*,...)__attribute((format(PyArg_ParseTuple, 1, 2))); + +int +main () +{ + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_compile") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then + +cat >>confdefs.h <<\_ACEOF +#define HAVE_ATTRIBUTE_FORMAT_PARSETUPLE 1 +_ACEOF + + { echo "$as_me:$LINENO: result: yes" >&5 +echo "${ECHO_T}yes" >&6; } +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + { echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6; } + +fi + +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + CFLAGS=$save_CFLAGS +fi + # On some compilers, pthreads are available without further options # (e.g. MacOS X). On some of these systems, the compiler will not # complain if unaccepted options are passed (e.g. gcc on Mac OS X). @@ -5175,27 +5149,10 @@ rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then ac_cv_header_stdc=yes else echo "$as_me: failed program was:" >&5 @@ -5371,27 +5328,10 @@ rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then eval "$as_ac_Header=yes" else echo "$as_me: failed program was:" >&5 @@ -5463,10 +5403,11 @@ + for ac_header in asm/types.h conio.h curses.h direct.h dlfcn.h errno.h \ fcntl.h grp.h \ -shadow.h io.h langinfo.h libintl.h ncurses.h poll.h process.h pthread.h \ -signal.h stropts.h termios.h thread.h \ +io.h langinfo.h libintl.h ncurses.h poll.h process.h pthread.h \ +shadow.h signal.h stdint.h stropts.h termios.h thread.h \ unistd.h utime.h \ sys/audioio.h sys/bsdtty.h sys/file.h sys/loadavg.h sys/lock.h sys/mkdev.h \ sys/modem.h \ @@ -5512,27 +5453,10 @@ rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then ac_header_compiler=yes else echo "$as_me: failed program was:" >&5 @@ -5568,17 +5492,10 @@ rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } >/dev/null; then - if test -s conftest.err; then - ac_cpp_err=$ac_c_preproc_warn_flag - ac_cpp_err=$ac_cpp_err$ac_c_werror_flag - else - ac_cpp_err= - fi -else - ac_cpp_err=yes -fi -if test -z "$ac_cpp_err"; then + (exit $ac_status); } >/dev/null && { + test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || + test ! -s conftest.err + }; then ac_header_preproc=yes else echo "$as_me: failed program was:" >&5 @@ -5686,27 +5603,10 @@ rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then eval "$as_ac_Header=yes" else echo "$as_me: failed program was:" >&5 @@ -5779,27 +5679,11 @@ rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest$ac_exeext' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest$ac_exeext && + $as_test_x conftest$ac_exeext; then ac_cv_search_opendir=$ac_res else echo "$as_me: failed program was:" >&5 @@ -5808,7 +5692,7 @@ fi -rm -f core conftest.err conftest.$ac_objext \ +rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ conftest$ac_exeext if test "${ac_cv_search_opendir+set}" = set; then break @@ -5879,27 +5763,11 @@ rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest$ac_exeext' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest$ac_exeext && + $as_test_x conftest$ac_exeext; then ac_cv_search_opendir=$ac_res else echo "$as_me: failed program was:" >&5 @@ -5908,7 +5776,7 @@ fi -rm -f core conftest.err conftest.$ac_objext \ +rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ conftest$ac_exeext if test "${ac_cv_search_opendir+set}" = set; then break @@ -5965,27 +5833,11 @@ rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest$ac_exeext' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest$ac_exeext && + $as_test_x conftest$ac_exeext; then ac_cv_header_sys_types_h_makedev=yes else echo "$as_me: failed program was:" >&5 @@ -5994,7 +5846,7 @@ ac_cv_header_sys_types_h_makedev=no fi -rm -f core conftest.err conftest.$ac_objext \ +rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ conftest$ac_exeext conftest.$ac_ext fi @@ -6036,27 +5888,10 @@ rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then ac_header_compiler=yes else echo "$as_me: failed program was:" >&5 @@ -6092,17 +5927,10 @@ rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } >/dev/null; then - if test -s conftest.err; then - ac_cpp_err=$ac_c_preproc_warn_flag - ac_cpp_err=$ac_cpp_err$ac_c_werror_flag - else - ac_cpp_err= - fi -else - ac_cpp_err=yes -fi -if test -z "$ac_cpp_err"; then + (exit $ac_status); } >/dev/null && { + test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || + test ! -s conftest.err + }; then ac_header_preproc=yes else echo "$as_me: failed program was:" >&5 @@ -6201,27 +6029,10 @@ rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then ac_header_compiler=yes else echo "$as_me: failed program was:" >&5 @@ -6257,17 +6068,10 @@ rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } >/dev/null; then - if test -s conftest.err; then - ac_cpp_err=$ac_c_preproc_warn_flag - ac_cpp_err=$ac_cpp_err$ac_c_werror_flag - else - ac_cpp_err= - fi -else - ac_cpp_err=yes -fi -if test -z "$ac_cpp_err"; then + (exit $ac_status); } >/dev/null && { + test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || + test ! -s conftest.err + }; then ac_header_preproc=yes else echo "$as_me: failed program was:" >&5 @@ -6371,27 +6175,10 @@ rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then eval "$as_ac_Header=yes" else echo "$as_me: failed program was:" >&5 @@ -6455,27 +6242,10 @@ rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then eval "$as_ac_Header=yes" else echo "$as_me: failed program was:" >&5 @@ -6560,27 +6330,11 @@ rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest$ac_exeext' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest$ac_exeext && + $as_test_x conftest$ac_exeext; then ac_cv_has_makedev=yes else echo "$as_me: failed program was:" >&5 @@ -6589,7 +6343,7 @@ ac_cv_has_makedev=no fi -rm -f core conftest.err conftest.$ac_objext \ +rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ conftest$ac_exeext conftest.$ac_ext if test "$ac_cv_has_makedev" = "no"; then # we didn't link, try if _OSF_SOURCE will allow us to link @@ -6624,27 +6378,11 @@ rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest$ac_exeext' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest$ac_exeext && + $as_test_x conftest$ac_exeext; then ac_cv_has_makedev=yes else echo "$as_me: failed program was:" >&5 @@ -6653,7 +6391,7 @@ ac_cv_has_makedev=no fi -rm -f core conftest.err conftest.$ac_objext \ +rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ conftest$ac_exeext conftest.$ac_ext if test "$ac_cv_has_makedev" = "yes"; then @@ -6715,27 +6453,10 @@ rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then sol_lfs_bug=no else echo "$as_me: failed program was:" >&5 @@ -6811,27 +6532,10 @@ rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then ac_cv_type_mode_t=yes else echo "$as_me: failed program was:" >&5 @@ -6891,27 +6595,10 @@ rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then ac_cv_type_off_t=yes else echo "$as_me: failed program was:" >&5 @@ -6971,27 +6658,10 @@ rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then ac_cv_type_pid_t=yes else echo "$as_me: failed program was:" >&5 @@ -7049,27 +6719,10 @@ rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then ac_cv_type_signal=int else echo "$as_me: failed program was:" >&5 @@ -7125,27 +6778,10 @@ rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then ac_cv_type_size_t=yes else echo "$as_me: failed program was:" >&5 @@ -7243,27 +6879,10 @@ rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then ac_cv_type_ssize_t=yes else echo "$as_me: failed program was:" >&5 @@ -7324,27 +6943,10 @@ rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then ac_cv_type_int=yes else echo "$as_me: failed program was:" >&5 @@ -7358,16 +6960,15 @@ { echo "$as_me:$LINENO: result: $ac_cv_type_int" >&5 echo "${ECHO_T}$ac_cv_type_int" >&6; } +# The cast to long int works around a bug in the HP C Compiler +# version HP92453-01 B.11.11.23709.GP, which incorrectly rejects +# declarations like `int a3[[(sizeof (unsigned char)) >= 0]];'. +# This bug is HP SR number 8606223364. { echo "$as_me:$LINENO: checking size of int" >&5 echo $ECHO_N "checking size of int... $ECHO_C" >&6; } if test "${ac_cv_sizeof_int+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else - if test "$ac_cv_type_int" = yes; then - # The cast to long int works around a bug in the HP C Compiler - # version HP92453-01 B.11.11.23709.GP, which incorrectly rejects - # declarations like `int a3[[(sizeof (unsigned char)) >= 0]];'. - # This bug is HP SR number 8606223364. if test "$cross_compiling" = yes; then # Depending upon the size, compute the lo and hi bounds. cat >conftest.$ac_ext <<_ACEOF @@ -7377,7 +6978,7 @@ cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ $ac_includes_default - typedef int ac__type_sizeof_; + typedef int ac__type_sizeof_; int main () { @@ -7401,27 +7002,10 @@ rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then ac_lo=0 ac_mid=0 while :; do cat >conftest.$ac_ext <<_ACEOF @@ -7431,7 +7015,7 @@ cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ $ac_includes_default - typedef int ac__type_sizeof_; + typedef int ac__type_sizeof_; int main () { @@ -7455,27 +7039,10 @@ rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then ac_hi=$ac_mid; break else echo "$as_me: failed program was:" >&5 @@ -7502,7 +7069,7 @@ cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ $ac_includes_default - typedef int ac__type_sizeof_; + typedef int ac__type_sizeof_; int main () { @@ -7526,27 +7093,10 @@ rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then ac_hi=-1 ac_mid=-1 while :; do cat >conftest.$ac_ext <<_ACEOF @@ -7556,7 +7106,7 @@ cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ $ac_includes_default - typedef int ac__type_sizeof_; + typedef int ac__type_sizeof_; int main () { @@ -7580,27 +7130,10 @@ rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then ac_lo=$ac_mid; break else echo "$as_me: failed program was:" >&5 @@ -7637,7 +7170,7 @@ cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ $ac_includes_default - typedef int ac__type_sizeof_; + typedef int ac__type_sizeof_; int main () { @@ -7661,27 +7194,10 @@ rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then ac_hi=$ac_mid else echo "$as_me: failed program was:" >&5 @@ -7694,11 +7210,15 @@ done case $ac_lo in ?*) ac_cv_sizeof_int=$ac_lo;; -'') { { echo "$as_me:$LINENO: error: cannot compute sizeof (int) +'') if test "$ac_cv_type_int" = yes; then + { { echo "$as_me:$LINENO: error: cannot compute sizeof (int) See \`config.log' for more details." >&5 echo "$as_me: error: cannot compute sizeof (int) See \`config.log' for more details." >&2;} - { (exit 77); exit 77; }; } ;; + { (exit 77); exit 77; }; } + else + ac_cv_sizeof_int=0 + fi ;; esac else cat >conftest.$ac_ext <<_ACEOF @@ -7708,7 +7228,7 @@ cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ $ac_includes_default - typedef int ac__type_sizeof_; + typedef int ac__type_sizeof_; static long int longval () { return (long int) (sizeof (ac__type_sizeof_)); } static unsigned long int ulongval () { return (long int) (sizeof (ac__type_sizeof_)); } #include @@ -7767,21 +7287,25 @@ sed 's/^/| /' conftest.$ac_ext >&5 ( exit $ac_status ) -{ { echo "$as_me:$LINENO: error: cannot compute sizeof (int) +if test "$ac_cv_type_int" = yes; then + { { echo "$as_me:$LINENO: error: cannot compute sizeof (int) See \`config.log' for more details." >&5 echo "$as_me: error: cannot compute sizeof (int) See \`config.log' for more details." >&2;} { (exit 77); exit 77; }; } + else + ac_cv_sizeof_int=0 + fi fi rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext fi rm -f conftest.val -else - ac_cv_sizeof_int=0 -fi fi { echo "$as_me:$LINENO: result: $ac_cv_sizeof_int" >&5 echo "${ECHO_T}$ac_cv_sizeof_int" >&6; } + + + cat >>confdefs.h <<_ACEOF #define SIZEOF_INT $ac_cv_sizeof_int _ACEOF @@ -7824,27 +7348,10 @@ rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then ac_cv_type_long=yes else echo "$as_me: failed program was:" >&5 @@ -7858,16 +7365,15 @@ { echo "$as_me:$LINENO: result: $ac_cv_type_long" >&5 echo "${ECHO_T}$ac_cv_type_long" >&6; } +# The cast to long int works around a bug in the HP C Compiler +# version HP92453-01 B.11.11.23709.GP, which incorrectly rejects +# declarations like `int a3[[(sizeof (unsigned char)) >= 0]];'. +# This bug is HP SR number 8606223364. { echo "$as_me:$LINENO: checking size of long" >&5 echo $ECHO_N "checking size of long... $ECHO_C" >&6; } if test "${ac_cv_sizeof_long+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else - if test "$ac_cv_type_long" = yes; then - # The cast to long int works around a bug in the HP C Compiler - # version HP92453-01 B.11.11.23709.GP, which incorrectly rejects - # declarations like `int a3[[(sizeof (unsigned char)) >= 0]];'. - # This bug is HP SR number 8606223364. if test "$cross_compiling" = yes; then # Depending upon the size, compute the lo and hi bounds. cat >conftest.$ac_ext <<_ACEOF @@ -7877,7 +7383,7 @@ cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ $ac_includes_default - typedef long ac__type_sizeof_; + typedef long ac__type_sizeof_; int main () { @@ -7901,27 +7407,10 @@ rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then ac_lo=0 ac_mid=0 while :; do cat >conftest.$ac_ext <<_ACEOF @@ -7931,7 +7420,7 @@ cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ $ac_includes_default - typedef long ac__type_sizeof_; + typedef long ac__type_sizeof_; int main () { @@ -7955,27 +7444,10 @@ rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then ac_hi=$ac_mid; break else echo "$as_me: failed program was:" >&5 @@ -8002,7 +7474,7 @@ cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ $ac_includes_default - typedef long ac__type_sizeof_; + typedef long ac__type_sizeof_; int main () { @@ -8026,27 +7498,10 @@ rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then ac_hi=-1 ac_mid=-1 while :; do cat >conftest.$ac_ext <<_ACEOF @@ -8056,7 +7511,7 @@ cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ $ac_includes_default - typedef long ac__type_sizeof_; + typedef long ac__type_sizeof_; int main () { @@ -8080,27 +7535,10 @@ rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then ac_lo=$ac_mid; break else echo "$as_me: failed program was:" >&5 @@ -8137,7 +7575,7 @@ cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ $ac_includes_default - typedef long ac__type_sizeof_; + typedef long ac__type_sizeof_; int main () { @@ -8161,27 +7599,10 @@ rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then ac_hi=$ac_mid else echo "$as_me: failed program was:" >&5 @@ -8194,11 +7615,15 @@ done case $ac_lo in ?*) ac_cv_sizeof_long=$ac_lo;; -'') { { echo "$as_me:$LINENO: error: cannot compute sizeof (long) +'') if test "$ac_cv_type_long" = yes; then + { { echo "$as_me:$LINENO: error: cannot compute sizeof (long) See \`config.log' for more details." >&5 echo "$as_me: error: cannot compute sizeof (long) See \`config.log' for more details." >&2;} - { (exit 77); exit 77; }; } ;; + { (exit 77); exit 77; }; } + else + ac_cv_sizeof_long=0 + fi ;; esac else cat >conftest.$ac_ext <<_ACEOF @@ -8208,7 +7633,7 @@ cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ $ac_includes_default - typedef long ac__type_sizeof_; + typedef long ac__type_sizeof_; static long int longval () { return (long int) (sizeof (ac__type_sizeof_)); } static unsigned long int ulongval () { return (long int) (sizeof (ac__type_sizeof_)); } #include @@ -8267,21 +7692,25 @@ sed 's/^/| /' conftest.$ac_ext >&5 ( exit $ac_status ) -{ { echo "$as_me:$LINENO: error: cannot compute sizeof (long) +if test "$ac_cv_type_long" = yes; then + { { echo "$as_me:$LINENO: error: cannot compute sizeof (long) See \`config.log' for more details." >&5 echo "$as_me: error: cannot compute sizeof (long) See \`config.log' for more details." >&2;} { (exit 77); exit 77; }; } + else + ac_cv_sizeof_long=0 + fi fi rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext fi rm -f conftest.val -else - ac_cv_sizeof_long=0 -fi fi { echo "$as_me:$LINENO: result: $ac_cv_sizeof_long" >&5 echo "${ECHO_T}$ac_cv_sizeof_long" >&6; } + + + cat >>confdefs.h <<_ACEOF #define SIZEOF_LONG $ac_cv_sizeof_long _ACEOF @@ -8324,27 +7753,10 @@ rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then ac_cv_type_void_p=yes else echo "$as_me: failed program was:" >&5 @@ -8358,16 +7770,15 @@ { echo "$as_me:$LINENO: result: $ac_cv_type_void_p" >&5 echo "${ECHO_T}$ac_cv_type_void_p" >&6; } +# The cast to long int works around a bug in the HP C Compiler +# version HP92453-01 B.11.11.23709.GP, which incorrectly rejects +# declarations like `int a3[[(sizeof (unsigned char)) >= 0]];'. +# This bug is HP SR number 8606223364. { echo "$as_me:$LINENO: checking size of void *" >&5 echo $ECHO_N "checking size of void *... $ECHO_C" >&6; } if test "${ac_cv_sizeof_void_p+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else - if test "$ac_cv_type_void_p" = yes; then - # The cast to long int works around a bug in the HP C Compiler - # version HP92453-01 B.11.11.23709.GP, which incorrectly rejects - # declarations like `int a3[[(sizeof (unsigned char)) >= 0]];'. - # This bug is HP SR number 8606223364. if test "$cross_compiling" = yes; then # Depending upon the size, compute the lo and hi bounds. cat >conftest.$ac_ext <<_ACEOF @@ -8377,7 +7788,7 @@ cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ $ac_includes_default - typedef void * ac__type_sizeof_; + typedef void * ac__type_sizeof_; int main () { @@ -8401,27 +7812,10 @@ rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then ac_lo=0 ac_mid=0 while :; do cat >conftest.$ac_ext <<_ACEOF @@ -8431,7 +7825,7 @@ cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ $ac_includes_default - typedef void * ac__type_sizeof_; + typedef void * ac__type_sizeof_; int main () { @@ -8455,27 +7849,10 @@ rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then ac_hi=$ac_mid; break else echo "$as_me: failed program was:" >&5 @@ -8502,7 +7879,7 @@ cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ $ac_includes_default - typedef void * ac__type_sizeof_; + typedef void * ac__type_sizeof_; int main () { @@ -8526,27 +7903,10 @@ rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then ac_hi=-1 ac_mid=-1 while :; do cat >conftest.$ac_ext <<_ACEOF @@ -8556,7 +7916,7 @@ cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ $ac_includes_default - typedef void * ac__type_sizeof_; + typedef void * ac__type_sizeof_; int main () { @@ -8580,27 +7940,10 @@ rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then ac_lo=$ac_mid; break else echo "$as_me: failed program was:" >&5 @@ -8637,7 +7980,7 @@ cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ $ac_includes_default - typedef void * ac__type_sizeof_; + typedef void * ac__type_sizeof_; int main () { @@ -8661,27 +8004,10 @@ rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then ac_hi=$ac_mid else echo "$as_me: failed program was:" >&5 @@ -8694,11 +8020,15 @@ done case $ac_lo in ?*) ac_cv_sizeof_void_p=$ac_lo;; -'') { { echo "$as_me:$LINENO: error: cannot compute sizeof (void *) +'') if test "$ac_cv_type_void_p" = yes; then + { { echo "$as_me:$LINENO: error: cannot compute sizeof (void *) See \`config.log' for more details." >&5 echo "$as_me: error: cannot compute sizeof (void *) See \`config.log' for more details." >&2;} - { (exit 77); exit 77; }; } ;; + { (exit 77); exit 77; }; } + else + ac_cv_sizeof_void_p=0 + fi ;; esac else cat >conftest.$ac_ext <<_ACEOF @@ -8708,7 +8038,7 @@ cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ $ac_includes_default - typedef void * ac__type_sizeof_; + typedef void * ac__type_sizeof_; static long int longval () { return (long int) (sizeof (ac__type_sizeof_)); } static unsigned long int ulongval () { return (long int) (sizeof (ac__type_sizeof_)); } #include @@ -8767,21 +8097,25 @@ sed 's/^/| /' conftest.$ac_ext >&5 ( exit $ac_status ) -{ { echo "$as_me:$LINENO: error: cannot compute sizeof (void *) +if test "$ac_cv_type_void_p" = yes; then + { { echo "$as_me:$LINENO: error: cannot compute sizeof (void *) See \`config.log' for more details." >&5 echo "$as_me: error: cannot compute sizeof (void *) See \`config.log' for more details." >&2;} { (exit 77); exit 77; }; } + else + ac_cv_sizeof_void_p=0 + fi fi rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext fi rm -f conftest.val -else - ac_cv_sizeof_void_p=0 -fi fi { echo "$as_me:$LINENO: result: $ac_cv_sizeof_void_p" >&5 echo "${ECHO_T}$ac_cv_sizeof_void_p" >&6; } + + + cat >>confdefs.h <<_ACEOF #define SIZEOF_VOID_P $ac_cv_sizeof_void_p _ACEOF @@ -8824,27 +8158,10 @@ rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then ac_cv_type_short=yes else echo "$as_me: failed program was:" >&5 @@ -8858,16 +8175,15 @@ { echo "$as_me:$LINENO: result: $ac_cv_type_short" >&5 echo "${ECHO_T}$ac_cv_type_short" >&6; } +# The cast to long int works around a bug in the HP C Compiler +# version HP92453-01 B.11.11.23709.GP, which incorrectly rejects +# declarations like `int a3[[(sizeof (unsigned char)) >= 0]];'. +# This bug is HP SR number 8606223364. { echo "$as_me:$LINENO: checking size of short" >&5 echo $ECHO_N "checking size of short... $ECHO_C" >&6; } if test "${ac_cv_sizeof_short+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else - if test "$ac_cv_type_short" = yes; then - # The cast to long int works around a bug in the HP C Compiler - # version HP92453-01 B.11.11.23709.GP, which incorrectly rejects - # declarations like `int a3[[(sizeof (unsigned char)) >= 0]];'. - # This bug is HP SR number 8606223364. if test "$cross_compiling" = yes; then # Depending upon the size, compute the lo and hi bounds. cat >conftest.$ac_ext <<_ACEOF @@ -8877,7 +8193,7 @@ cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ $ac_includes_default - typedef short ac__type_sizeof_; + typedef short ac__type_sizeof_; int main () { @@ -8901,27 +8217,10 @@ rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then ac_lo=0 ac_mid=0 while :; do cat >conftest.$ac_ext <<_ACEOF @@ -8931,7 +8230,7 @@ cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ $ac_includes_default - typedef short ac__type_sizeof_; + typedef short ac__type_sizeof_; int main () { @@ -8955,27 +8254,10 @@ rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then ac_hi=$ac_mid; break else echo "$as_me: failed program was:" >&5 @@ -9002,7 +8284,7 @@ cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ $ac_includes_default - typedef short ac__type_sizeof_; + typedef short ac__type_sizeof_; int main () { @@ -9026,27 +8308,10 @@ rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then ac_hi=-1 ac_mid=-1 while :; do cat >conftest.$ac_ext <<_ACEOF @@ -9056,7 +8321,7 @@ cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ $ac_includes_default - typedef short ac__type_sizeof_; + typedef short ac__type_sizeof_; int main () { @@ -9080,27 +8345,10 @@ rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then ac_lo=$ac_mid; break else echo "$as_me: failed program was:" >&5 @@ -9137,7 +8385,7 @@ cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ $ac_includes_default - typedef short ac__type_sizeof_; + typedef short ac__type_sizeof_; int main () { @@ -9161,27 +8409,10 @@ rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then ac_hi=$ac_mid else echo "$as_me: failed program was:" >&5 @@ -9194,11 +8425,15 @@ done case $ac_lo in ?*) ac_cv_sizeof_short=$ac_lo;; -'') { { echo "$as_me:$LINENO: error: cannot compute sizeof (short) +'') if test "$ac_cv_type_short" = yes; then + { { echo "$as_me:$LINENO: error: cannot compute sizeof (short) See \`config.log' for more details." >&5 echo "$as_me: error: cannot compute sizeof (short) See \`config.log' for more details." >&2;} - { (exit 77); exit 77; }; } ;; + { (exit 77); exit 77; }; } + else + ac_cv_sizeof_short=0 + fi ;; esac else cat >conftest.$ac_ext <<_ACEOF @@ -9208,7 +8443,7 @@ cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ $ac_includes_default - typedef short ac__type_sizeof_; + typedef short ac__type_sizeof_; static long int longval () { return (long int) (sizeof (ac__type_sizeof_)); } static unsigned long int ulongval () { return (long int) (sizeof (ac__type_sizeof_)); } #include @@ -9267,21 +8502,25 @@ sed 's/^/| /' conftest.$ac_ext >&5 ( exit $ac_status ) -{ { echo "$as_me:$LINENO: error: cannot compute sizeof (short) +if test "$ac_cv_type_short" = yes; then + { { echo "$as_me:$LINENO: error: cannot compute sizeof (short) See \`config.log' for more details." >&5 echo "$as_me: error: cannot compute sizeof (short) See \`config.log' for more details." >&2;} { (exit 77); exit 77; }; } + else + ac_cv_sizeof_short=0 + fi fi rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext fi rm -f conftest.val -else - ac_cv_sizeof_short=0 -fi fi { echo "$as_me:$LINENO: result: $ac_cv_sizeof_short" >&5 echo "${ECHO_T}$ac_cv_sizeof_short" >&6; } + + + cat >>confdefs.h <<_ACEOF #define SIZEOF_SHORT $ac_cv_sizeof_short _ACEOF @@ -9324,27 +8563,10 @@ rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then ac_cv_type_float=yes else echo "$as_me: failed program was:" >&5 @@ -9358,16 +8580,15 @@ { echo "$as_me:$LINENO: result: $ac_cv_type_float" >&5 echo "${ECHO_T}$ac_cv_type_float" >&6; } +# The cast to long int works around a bug in the HP C Compiler +# version HP92453-01 B.11.11.23709.GP, which incorrectly rejects +# declarations like `int a3[[(sizeof (unsigned char)) >= 0]];'. +# This bug is HP SR number 8606223364. { echo "$as_me:$LINENO: checking size of float" >&5 echo $ECHO_N "checking size of float... $ECHO_C" >&6; } if test "${ac_cv_sizeof_float+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else - if test "$ac_cv_type_float" = yes; then - # The cast to long int works around a bug in the HP C Compiler - # version HP92453-01 B.11.11.23709.GP, which incorrectly rejects - # declarations like `int a3[[(sizeof (unsigned char)) >= 0]];'. - # This bug is HP SR number 8606223364. if test "$cross_compiling" = yes; then # Depending upon the size, compute the lo and hi bounds. cat >conftest.$ac_ext <<_ACEOF @@ -9377,7 +8598,7 @@ cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ $ac_includes_default - typedef float ac__type_sizeof_; + typedef float ac__type_sizeof_; int main () { @@ -9401,27 +8622,10 @@ rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then ac_lo=0 ac_mid=0 while :; do cat >conftest.$ac_ext <<_ACEOF @@ -9431,7 +8635,7 @@ cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ $ac_includes_default - typedef float ac__type_sizeof_; + typedef float ac__type_sizeof_; int main () { @@ -9455,27 +8659,10 @@ rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then ac_hi=$ac_mid; break else echo "$as_me: failed program was:" >&5 @@ -9502,7 +8689,7 @@ cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ $ac_includes_default - typedef float ac__type_sizeof_; + typedef float ac__type_sizeof_; int main () { @@ -9526,27 +8713,10 @@ rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then ac_hi=-1 ac_mid=-1 while :; do cat >conftest.$ac_ext <<_ACEOF @@ -9556,7 +8726,7 @@ cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ $ac_includes_default - typedef float ac__type_sizeof_; + typedef float ac__type_sizeof_; int main () { @@ -9580,27 +8750,10 @@ rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then ac_lo=$ac_mid; break else echo "$as_me: failed program was:" >&5 @@ -9637,7 +8790,7 @@ cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ $ac_includes_default - typedef float ac__type_sizeof_; + typedef float ac__type_sizeof_; int main () { @@ -9661,27 +8814,10 @@ rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then ac_hi=$ac_mid else echo "$as_me: failed program was:" >&5 @@ -9694,11 +8830,15 @@ done case $ac_lo in ?*) ac_cv_sizeof_float=$ac_lo;; -'') { { echo "$as_me:$LINENO: error: cannot compute sizeof (float) +'') if test "$ac_cv_type_float" = yes; then + { { echo "$as_me:$LINENO: error: cannot compute sizeof (float) See \`config.log' for more details." >&5 echo "$as_me: error: cannot compute sizeof (float) See \`config.log' for more details." >&2;} - { (exit 77); exit 77; }; } ;; + { (exit 77); exit 77; }; } + else + ac_cv_sizeof_float=0 + fi ;; esac else cat >conftest.$ac_ext <<_ACEOF @@ -9708,7 +8848,7 @@ cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ $ac_includes_default - typedef float ac__type_sizeof_; + typedef float ac__type_sizeof_; static long int longval () { return (long int) (sizeof (ac__type_sizeof_)); } static unsigned long int ulongval () { return (long int) (sizeof (ac__type_sizeof_)); } #include @@ -9767,21 +8907,25 @@ sed 's/^/| /' conftest.$ac_ext >&5 ( exit $ac_status ) -{ { echo "$as_me:$LINENO: error: cannot compute sizeof (float) +if test "$ac_cv_type_float" = yes; then + { { echo "$as_me:$LINENO: error: cannot compute sizeof (float) See \`config.log' for more details." >&5 echo "$as_me: error: cannot compute sizeof (float) See \`config.log' for more details." >&2;} { (exit 77); exit 77; }; } + else + ac_cv_sizeof_float=0 + fi fi rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext fi rm -f conftest.val -else - ac_cv_sizeof_float=0 -fi fi { echo "$as_me:$LINENO: result: $ac_cv_sizeof_float" >&5 echo "${ECHO_T}$ac_cv_sizeof_float" >&6; } + + + cat >>confdefs.h <<_ACEOF #define SIZEOF_FLOAT $ac_cv_sizeof_float _ACEOF @@ -9824,27 +8968,10 @@ rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then ac_cv_type_double=yes else echo "$as_me: failed program was:" >&5 @@ -9858,16 +8985,15 @@ { echo "$as_me:$LINENO: result: $ac_cv_type_double" >&5 echo "${ECHO_T}$ac_cv_type_double" >&6; } +# The cast to long int works around a bug in the HP C Compiler +# version HP92453-01 B.11.11.23709.GP, which incorrectly rejects +# declarations like `int a3[[(sizeof (unsigned char)) >= 0]];'. +# This bug is HP SR number 8606223364. { echo "$as_me:$LINENO: checking size of double" >&5 echo $ECHO_N "checking size of double... $ECHO_C" >&6; } if test "${ac_cv_sizeof_double+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else - if test "$ac_cv_type_double" = yes; then - # The cast to long int works around a bug in the HP C Compiler - # version HP92453-01 B.11.11.23709.GP, which incorrectly rejects - # declarations like `int a3[[(sizeof (unsigned char)) >= 0]];'. - # This bug is HP SR number 8606223364. if test "$cross_compiling" = yes; then # Depending upon the size, compute the lo and hi bounds. cat >conftest.$ac_ext <<_ACEOF @@ -9877,7 +9003,7 @@ cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ $ac_includes_default - typedef double ac__type_sizeof_; + typedef double ac__type_sizeof_; int main () { @@ -9901,27 +9027,10 @@ rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then ac_lo=0 ac_mid=0 while :; do cat >conftest.$ac_ext <<_ACEOF @@ -9931,7 +9040,7 @@ cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ $ac_includes_default - typedef double ac__type_sizeof_; + typedef double ac__type_sizeof_; int main () { @@ -9955,27 +9064,10 @@ rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then ac_hi=$ac_mid; break else echo "$as_me: failed program was:" >&5 @@ -10002,7 +9094,7 @@ cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ $ac_includes_default - typedef double ac__type_sizeof_; + typedef double ac__type_sizeof_; int main () { @@ -10026,27 +9118,10 @@ rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then ac_hi=-1 ac_mid=-1 while :; do cat >conftest.$ac_ext <<_ACEOF @@ -10056,7 +9131,7 @@ cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ $ac_includes_default - typedef double ac__type_sizeof_; + typedef double ac__type_sizeof_; int main () { @@ -10080,27 +9155,10 @@ rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then ac_lo=$ac_mid; break else echo "$as_me: failed program was:" >&5 @@ -10137,7 +9195,7 @@ cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ $ac_includes_default - typedef double ac__type_sizeof_; + typedef double ac__type_sizeof_; int main () { @@ -10161,27 +9219,10 @@ rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then ac_hi=$ac_mid else echo "$as_me: failed program was:" >&5 @@ -10194,11 +9235,15 @@ done case $ac_lo in ?*) ac_cv_sizeof_double=$ac_lo;; -'') { { echo "$as_me:$LINENO: error: cannot compute sizeof (double) +'') if test "$ac_cv_type_double" = yes; then + { { echo "$as_me:$LINENO: error: cannot compute sizeof (double) See \`config.log' for more details." >&5 echo "$as_me: error: cannot compute sizeof (double) See \`config.log' for more details." >&2;} - { (exit 77); exit 77; }; } ;; + { (exit 77); exit 77; }; } + else + ac_cv_sizeof_double=0 + fi ;; esac else cat >conftest.$ac_ext <<_ACEOF @@ -10208,7 +9253,7 @@ cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ $ac_includes_default - typedef double ac__type_sizeof_; + typedef double ac__type_sizeof_; static long int longval () { return (long int) (sizeof (ac__type_sizeof_)); } static unsigned long int ulongval () { return (long int) (sizeof (ac__type_sizeof_)); } #include @@ -10267,21 +9312,25 @@ sed 's/^/| /' conftest.$ac_ext >&5 ( exit $ac_status ) -{ { echo "$as_me:$LINENO: error: cannot compute sizeof (double) +if test "$ac_cv_type_double" = yes; then + { { echo "$as_me:$LINENO: error: cannot compute sizeof (double) See \`config.log' for more details." >&5 echo "$as_me: error: cannot compute sizeof (double) See \`config.log' for more details." >&2;} { (exit 77); exit 77; }; } + else + ac_cv_sizeof_double=0 + fi fi rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext fi rm -f conftest.val -else - ac_cv_sizeof_double=0 -fi fi { echo "$as_me:$LINENO: result: $ac_cv_sizeof_double" >&5 echo "${ECHO_T}$ac_cv_sizeof_double" >&6; } + + + cat >>confdefs.h <<_ACEOF #define SIZEOF_DOUBLE $ac_cv_sizeof_double _ACEOF @@ -10324,27 +9373,10 @@ rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then ac_cv_type_fpos_t=yes else echo "$as_me: failed program was:" >&5 @@ -10358,16 +9390,15 @@ { echo "$as_me:$LINENO: result: $ac_cv_type_fpos_t" >&5 echo "${ECHO_T}$ac_cv_type_fpos_t" >&6; } +# The cast to long int works around a bug in the HP C Compiler +# version HP92453-01 B.11.11.23709.GP, which incorrectly rejects +# declarations like `int a3[[(sizeof (unsigned char)) >= 0]];'. +# This bug is HP SR number 8606223364. { echo "$as_me:$LINENO: checking size of fpos_t" >&5 echo $ECHO_N "checking size of fpos_t... $ECHO_C" >&6; } if test "${ac_cv_sizeof_fpos_t+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else - if test "$ac_cv_type_fpos_t" = yes; then - # The cast to long int works around a bug in the HP C Compiler - # version HP92453-01 B.11.11.23709.GP, which incorrectly rejects - # declarations like `int a3[[(sizeof (unsigned char)) >= 0]];'. - # This bug is HP SR number 8606223364. if test "$cross_compiling" = yes; then # Depending upon the size, compute the lo and hi bounds. cat >conftest.$ac_ext <<_ACEOF @@ -10377,7 +9408,7 @@ cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ $ac_includes_default - typedef fpos_t ac__type_sizeof_; + typedef fpos_t ac__type_sizeof_; int main () { @@ -10401,27 +9432,10 @@ rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then ac_lo=0 ac_mid=0 while :; do cat >conftest.$ac_ext <<_ACEOF @@ -10431,7 +9445,7 @@ cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ $ac_includes_default - typedef fpos_t ac__type_sizeof_; + typedef fpos_t ac__type_sizeof_; int main () { @@ -10455,27 +9469,10 @@ rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then ac_hi=$ac_mid; break else echo "$as_me: failed program was:" >&5 @@ -10502,7 +9499,7 @@ cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ $ac_includes_default - typedef fpos_t ac__type_sizeof_; + typedef fpos_t ac__type_sizeof_; int main () { @@ -10526,27 +9523,10 @@ rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then ac_hi=-1 ac_mid=-1 while :; do cat >conftest.$ac_ext <<_ACEOF @@ -10556,7 +9536,7 @@ cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ $ac_includes_default - typedef fpos_t ac__type_sizeof_; + typedef fpos_t ac__type_sizeof_; int main () { @@ -10580,27 +9560,10 @@ rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then ac_lo=$ac_mid; break else echo "$as_me: failed program was:" >&5 @@ -10637,7 +9600,7 @@ cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ $ac_includes_default - typedef fpos_t ac__type_sizeof_; + typedef fpos_t ac__type_sizeof_; int main () { @@ -10661,27 +9624,10 @@ rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then ac_hi=$ac_mid else echo "$as_me: failed program was:" >&5 @@ -10694,11 +9640,15 @@ done case $ac_lo in ?*) ac_cv_sizeof_fpos_t=$ac_lo;; -'') { { echo "$as_me:$LINENO: error: cannot compute sizeof (fpos_t) +'') if test "$ac_cv_type_fpos_t" = yes; then + { { echo "$as_me:$LINENO: error: cannot compute sizeof (fpos_t) See \`config.log' for more details." >&5 echo "$as_me: error: cannot compute sizeof (fpos_t) See \`config.log' for more details." >&2;} - { (exit 77); exit 77; }; } ;; + { (exit 77); exit 77; }; } + else + ac_cv_sizeof_fpos_t=0 + fi ;; esac else cat >conftest.$ac_ext <<_ACEOF @@ -10708,7 +9658,7 @@ cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ $ac_includes_default - typedef fpos_t ac__type_sizeof_; + typedef fpos_t ac__type_sizeof_; static long int longval () { return (long int) (sizeof (ac__type_sizeof_)); } static unsigned long int ulongval () { return (long int) (sizeof (ac__type_sizeof_)); } #include @@ -10767,21 +9717,25 @@ sed 's/^/| /' conftest.$ac_ext >&5 ( exit $ac_status ) -{ { echo "$as_me:$LINENO: error: cannot compute sizeof (fpos_t) +if test "$ac_cv_type_fpos_t" = yes; then + { { echo "$as_me:$LINENO: error: cannot compute sizeof (fpos_t) See \`config.log' for more details." >&5 echo "$as_me: error: cannot compute sizeof (fpos_t) See \`config.log' for more details." >&2;} { (exit 77); exit 77; }; } + else + ac_cv_sizeof_fpos_t=0 + fi fi rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext fi rm -f conftest.val -else - ac_cv_sizeof_fpos_t=0 -fi fi { echo "$as_me:$LINENO: result: $ac_cv_sizeof_fpos_t" >&5 echo "${ECHO_T}$ac_cv_sizeof_fpos_t" >&6; } + + + cat >>confdefs.h <<_ACEOF #define SIZEOF_FPOS_T $ac_cv_sizeof_fpos_t _ACEOF @@ -10824,27 +9778,10 @@ rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then ac_cv_type_size_t=yes else echo "$as_me: failed program was:" >&5 @@ -10858,16 +9795,15 @@ { echo "$as_me:$LINENO: result: $ac_cv_type_size_t" >&5 echo "${ECHO_T}$ac_cv_type_size_t" >&6; } +# The cast to long int works around a bug in the HP C Compiler +# version HP92453-01 B.11.11.23709.GP, which incorrectly rejects +# declarations like `int a3[[(sizeof (unsigned char)) >= 0]];'. +# This bug is HP SR number 8606223364. { echo "$as_me:$LINENO: checking size of size_t" >&5 echo $ECHO_N "checking size of size_t... $ECHO_C" >&6; } if test "${ac_cv_sizeof_size_t+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else - if test "$ac_cv_type_size_t" = yes; then - # The cast to long int works around a bug in the HP C Compiler - # version HP92453-01 B.11.11.23709.GP, which incorrectly rejects - # declarations like `int a3[[(sizeof (unsigned char)) >= 0]];'. - # This bug is HP SR number 8606223364. if test "$cross_compiling" = yes; then # Depending upon the size, compute the lo and hi bounds. cat >conftest.$ac_ext <<_ACEOF @@ -10877,7 +9813,7 @@ cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ $ac_includes_default - typedef size_t ac__type_sizeof_; + typedef size_t ac__type_sizeof_; int main () { @@ -10901,27 +9837,10 @@ rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then ac_lo=0 ac_mid=0 while :; do cat >conftest.$ac_ext <<_ACEOF @@ -10931,7 +9850,7 @@ cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ $ac_includes_default - typedef size_t ac__type_sizeof_; + typedef size_t ac__type_sizeof_; int main () { @@ -10955,27 +9874,10 @@ rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then ac_hi=$ac_mid; break else echo "$as_me: failed program was:" >&5 @@ -11002,7 +9904,7 @@ cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ $ac_includes_default - typedef size_t ac__type_sizeof_; + typedef size_t ac__type_sizeof_; int main () { @@ -11026,27 +9928,10 @@ rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then ac_hi=-1 ac_mid=-1 while :; do cat >conftest.$ac_ext <<_ACEOF @@ -11056,7 +9941,7 @@ cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ $ac_includes_default - typedef size_t ac__type_sizeof_; + typedef size_t ac__type_sizeof_; int main () { @@ -11080,27 +9965,10 @@ rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then ac_lo=$ac_mid; break else echo "$as_me: failed program was:" >&5 @@ -11137,7 +10005,7 @@ cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ $ac_includes_default - typedef size_t ac__type_sizeof_; + typedef size_t ac__type_sizeof_; int main () { @@ -11161,27 +10029,10 @@ rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then ac_hi=$ac_mid else echo "$as_me: failed program was:" >&5 @@ -11194,11 +10045,15 @@ done case $ac_lo in ?*) ac_cv_sizeof_size_t=$ac_lo;; -'') { { echo "$as_me:$LINENO: error: cannot compute sizeof (size_t) +'') if test "$ac_cv_type_size_t" = yes; then + { { echo "$as_me:$LINENO: error: cannot compute sizeof (size_t) See \`config.log' for more details." >&5 echo "$as_me: error: cannot compute sizeof (size_t) See \`config.log' for more details." >&2;} - { (exit 77); exit 77; }; } ;; + { (exit 77); exit 77; }; } + else + ac_cv_sizeof_size_t=0 + fi ;; esac else cat >conftest.$ac_ext <<_ACEOF @@ -11208,7 +10063,7 @@ cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ $ac_includes_default - typedef size_t ac__type_sizeof_; + typedef size_t ac__type_sizeof_; static long int longval () { return (long int) (sizeof (ac__type_sizeof_)); } static unsigned long int ulongval () { return (long int) (sizeof (ac__type_sizeof_)); } #include @@ -11267,21 +10122,25 @@ sed 's/^/| /' conftest.$ac_ext >&5 ( exit $ac_status ) -{ { echo "$as_me:$LINENO: error: cannot compute sizeof (size_t) +if test "$ac_cv_type_size_t" = yes; then + { { echo "$as_me:$LINENO: error: cannot compute sizeof (size_t) See \`config.log' for more details." >&5 echo "$as_me: error: cannot compute sizeof (size_t) See \`config.log' for more details." >&2;} { (exit 77); exit 77; }; } + else + ac_cv_sizeof_size_t=0 + fi fi rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext fi rm -f conftest.val -else - ac_cv_sizeof_size_t=0 -fi fi { echo "$as_me:$LINENO: result: $ac_cv_sizeof_size_t" >&5 echo "${ECHO_T}$ac_cv_sizeof_size_t" >&6; } + + + cat >>confdefs.h <<_ACEOF #define SIZEOF_SIZE_T $ac_cv_sizeof_size_t _ACEOF @@ -11319,27 +10178,10 @@ rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then cat >>confdefs.h <<\_ACEOF @@ -11396,27 +10238,10 @@ rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then ac_cv_type_long_long=yes else echo "$as_me: failed program was:" >&5 @@ -11430,16 +10255,15 @@ { echo "$as_me:$LINENO: result: $ac_cv_type_long_long" >&5 echo "${ECHO_T}$ac_cv_type_long_long" >&6; } +# The cast to long int works around a bug in the HP C Compiler +# version HP92453-01 B.11.11.23709.GP, which incorrectly rejects +# declarations like `int a3[[(sizeof (unsigned char)) >= 0]];'. +# This bug is HP SR number 8606223364. { echo "$as_me:$LINENO: checking size of long long" >&5 echo $ECHO_N "checking size of long long... $ECHO_C" >&6; } if test "${ac_cv_sizeof_long_long+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else - if test "$ac_cv_type_long_long" = yes; then - # The cast to long int works around a bug in the HP C Compiler - # version HP92453-01 B.11.11.23709.GP, which incorrectly rejects - # declarations like `int a3[[(sizeof (unsigned char)) >= 0]];'. - # This bug is HP SR number 8606223364. if test "$cross_compiling" = yes; then # Depending upon the size, compute the lo and hi bounds. cat >conftest.$ac_ext <<_ACEOF @@ -11449,7 +10273,7 @@ cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ $ac_includes_default - typedef long long ac__type_sizeof_; + typedef long long ac__type_sizeof_; int main () { @@ -11473,27 +10297,10 @@ rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then ac_lo=0 ac_mid=0 while :; do cat >conftest.$ac_ext <<_ACEOF @@ -11503,7 +10310,7 @@ cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ $ac_includes_default - typedef long long ac__type_sizeof_; + typedef long long ac__type_sizeof_; int main () { @@ -11527,27 +10334,10 @@ rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then ac_hi=$ac_mid; break else echo "$as_me: failed program was:" >&5 @@ -11574,7 +10364,7 @@ cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ $ac_includes_default - typedef long long ac__type_sizeof_; + typedef long long ac__type_sizeof_; int main () { @@ -11598,27 +10388,10 @@ rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then ac_hi=-1 ac_mid=-1 while :; do cat >conftest.$ac_ext <<_ACEOF @@ -11628,7 +10401,7 @@ cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ $ac_includes_default - typedef long long ac__type_sizeof_; + typedef long long ac__type_sizeof_; int main () { @@ -11652,27 +10425,10 @@ rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then ac_lo=$ac_mid; break else echo "$as_me: failed program was:" >&5 @@ -11709,7 +10465,7 @@ cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ $ac_includes_default - typedef long long ac__type_sizeof_; + typedef long long ac__type_sizeof_; int main () { @@ -11733,27 +10489,10 @@ rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then ac_hi=$ac_mid else echo "$as_me: failed program was:" >&5 @@ -11766,11 +10505,15 @@ done case $ac_lo in ?*) ac_cv_sizeof_long_long=$ac_lo;; -'') { { echo "$as_me:$LINENO: error: cannot compute sizeof (long long) +'') if test "$ac_cv_type_long_long" = yes; then + { { echo "$as_me:$LINENO: error: cannot compute sizeof (long long) See \`config.log' for more details." >&5 echo "$as_me: error: cannot compute sizeof (long long) See \`config.log' for more details." >&2;} - { (exit 77); exit 77; }; } ;; + { (exit 77); exit 77; }; } + else + ac_cv_sizeof_long_long=0 + fi ;; esac else cat >conftest.$ac_ext <<_ACEOF @@ -11780,7 +10523,7 @@ cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ $ac_includes_default - typedef long long ac__type_sizeof_; + typedef long long ac__type_sizeof_; static long int longval () { return (long int) (sizeof (ac__type_sizeof_)); } static unsigned long int ulongval () { return (long int) (sizeof (ac__type_sizeof_)); } #include @@ -11839,21 +10582,25 @@ sed 's/^/| /' conftest.$ac_ext >&5 ( exit $ac_status ) -{ { echo "$as_me:$LINENO: error: cannot compute sizeof (long long) +if test "$ac_cv_type_long_long" = yes; then + { { echo "$as_me:$LINENO: error: cannot compute sizeof (long long) See \`config.log' for more details." >&5 echo "$as_me: error: cannot compute sizeof (long long) See \`config.log' for more details." >&2;} { (exit 77); exit 77; }; } + else + ac_cv_sizeof_long_long=0 + fi fi rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext fi rm -f conftest.val -else - ac_cv_sizeof_long_long=0 -fi fi { echo "$as_me:$LINENO: result: $ac_cv_sizeof_long_long" >&5 echo "${ECHO_T}$ac_cv_sizeof_long_long" >&6; } + + + cat >>confdefs.h <<_ACEOF #define SIZEOF_LONG_LONG $ac_cv_sizeof_long_long _ACEOF @@ -11861,20 +10608,29 @@ fi -{ echo "$as_me:$LINENO: checking for uintptr_t support" >&5 -echo $ECHO_N "checking for uintptr_t support... $ECHO_C" >&6; } -have_uintptr_t=no -cat >conftest.$ac_ext <<_ACEOF +{ echo "$as_me:$LINENO: checking for uintptr_t" >&5 +echo $ECHO_N "checking for uintptr_t... $ECHO_C" >&6; } +if test "${ac_cv_type_uintptr_t+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ +#ifdef HAVE_STDINT_H + #include + #endif +typedef uintptr_t ac__type_new_; int main () { -uintptr_t x; x = (uintptr_t)0; +if ((ac__type_new_ *) 0) + return 0; +if (sizeof (ac__type_new_)) + return 0; ; return 0; } @@ -11892,46 +10648,28 @@ rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then - - -cat >>confdefs.h <<\_ACEOF -#define HAVE_UINTPTR_T 1 -_ACEOF - - have_uintptr_t=yes - + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then + ac_cv_type_uintptr_t=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 - + ac_cv_type_uintptr_t=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext -{ echo "$as_me:$LINENO: result: $have_uintptr_t" >&5 -echo "${ECHO_T}$have_uintptr_t" >&6; } -if test "$have_uintptr_t" = yes ; then +fi +{ echo "$as_me:$LINENO: result: $ac_cv_type_uintptr_t" >&5 +echo "${ECHO_T}$ac_cv_type_uintptr_t" >&6; } +if test $ac_cv_type_uintptr_t = yes; then + +cat >>confdefs.h <<_ACEOF +#define HAVE_UINTPTR_T 1 +_ACEOF + { echo "$as_me:$LINENO: checking for uintptr_t" >&5 echo $ECHO_N "checking for uintptr_t... $ECHO_C" >&6; } if test "${ac_cv_type_uintptr_t+set}" = set; then @@ -11969,27 +10707,10 @@ rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then ac_cv_type_uintptr_t=yes else echo "$as_me: failed program was:" >&5 @@ -12003,16 +10724,15 @@ { echo "$as_me:$LINENO: result: $ac_cv_type_uintptr_t" >&5 echo "${ECHO_T}$ac_cv_type_uintptr_t" >&6; } +# The cast to long int works around a bug in the HP C Compiler +# version HP92453-01 B.11.11.23709.GP, which incorrectly rejects +# declarations like `int a3[[(sizeof (unsigned char)) >= 0]];'. +# This bug is HP SR number 8606223364. { echo "$as_me:$LINENO: checking size of uintptr_t" >&5 echo $ECHO_N "checking size of uintptr_t... $ECHO_C" >&6; } if test "${ac_cv_sizeof_uintptr_t+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else - if test "$ac_cv_type_uintptr_t" = yes; then - # The cast to long int works around a bug in the HP C Compiler - # version HP92453-01 B.11.11.23709.GP, which incorrectly rejects - # declarations like `int a3[[(sizeof (unsigned char)) >= 0]];'. - # This bug is HP SR number 8606223364. if test "$cross_compiling" = yes; then # Depending upon the size, compute the lo and hi bounds. cat >conftest.$ac_ext <<_ACEOF @@ -12022,7 +10742,7 @@ cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ $ac_includes_default - typedef uintptr_t ac__type_sizeof_; + typedef uintptr_t ac__type_sizeof_; int main () { @@ -12046,27 +10766,10 @@ rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then ac_lo=0 ac_mid=0 while :; do cat >conftest.$ac_ext <<_ACEOF @@ -12076,7 +10779,7 @@ cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ $ac_includes_default - typedef uintptr_t ac__type_sizeof_; + typedef uintptr_t ac__type_sizeof_; int main () { @@ -12100,27 +10803,10 @@ rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then ac_hi=$ac_mid; break else echo "$as_me: failed program was:" >&5 @@ -12147,7 +10833,7 @@ cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ $ac_includes_default - typedef uintptr_t ac__type_sizeof_; + typedef uintptr_t ac__type_sizeof_; int main () { @@ -12171,27 +10857,10 @@ rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then ac_hi=-1 ac_mid=-1 while :; do cat >conftest.$ac_ext <<_ACEOF @@ -12201,7 +10870,7 @@ cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ $ac_includes_default - typedef uintptr_t ac__type_sizeof_; + typedef uintptr_t ac__type_sizeof_; int main () { @@ -12225,27 +10894,10 @@ rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then ac_lo=$ac_mid; break else echo "$as_me: failed program was:" >&5 @@ -12282,7 +10934,7 @@ cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ $ac_includes_default - typedef uintptr_t ac__type_sizeof_; + typedef uintptr_t ac__type_sizeof_; int main () { @@ -12306,27 +10958,10 @@ rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then ac_hi=$ac_mid else echo "$as_me: failed program was:" >&5 @@ -12339,11 +10974,15 @@ done case $ac_lo in ?*) ac_cv_sizeof_uintptr_t=$ac_lo;; -'') { { echo "$as_me:$LINENO: error: cannot compute sizeof (uintptr_t) +'') if test "$ac_cv_type_uintptr_t" = yes; then + { { echo "$as_me:$LINENO: error: cannot compute sizeof (uintptr_t) See \`config.log' for more details." >&5 echo "$as_me: error: cannot compute sizeof (uintptr_t) See \`config.log' for more details." >&2;} - { (exit 77); exit 77; }; } ;; + { (exit 77); exit 77; }; } + else + ac_cv_sizeof_uintptr_t=0 + fi ;; esac else cat >conftest.$ac_ext <<_ACEOF @@ -12353,7 +10992,7 @@ cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ $ac_includes_default - typedef uintptr_t ac__type_sizeof_; + typedef uintptr_t ac__type_sizeof_; static long int longval () { return (long int) (sizeof (ac__type_sizeof_)); } static unsigned long int ulongval () { return (long int) (sizeof (ac__type_sizeof_)); } #include @@ -12412,21 +11051,25 @@ sed 's/^/| /' conftest.$ac_ext >&5 ( exit $ac_status ) -{ { echo "$as_me:$LINENO: error: cannot compute sizeof (uintptr_t) +if test "$ac_cv_type_uintptr_t" = yes; then + { { echo "$as_me:$LINENO: error: cannot compute sizeof (uintptr_t) See \`config.log' for more details." >&5 echo "$as_me: error: cannot compute sizeof (uintptr_t) See \`config.log' for more details." >&2;} { (exit 77); exit 77; }; } + else + ac_cv_sizeof_uintptr_t=0 + fi fi rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext fi rm -f conftest.val -else - ac_cv_sizeof_uintptr_t=0 -fi fi { echo "$as_me:$LINENO: result: $ac_cv_sizeof_uintptr_t" >&5 echo "${ECHO_T}$ac_cv_sizeof_uintptr_t" >&6; } + + + cat >>confdefs.h <<_ACEOF #define SIZEOF_UINTPTR_T $ac_cv_sizeof_uintptr_t _ACEOF @@ -12434,6 +11077,8 @@ fi + + # Hmph. AC_CHECK_SIZEOF() doesn't include . { echo "$as_me:$LINENO: checking size of off_t" >&5 echo $ECHO_N "checking size of off_t... $ECHO_C" >&6; } @@ -12630,27 +11275,10 @@ rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then have_pthread_t=yes else echo "$as_me: failed program was:" >&5 @@ -13168,27 +11796,11 @@ rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest$ac_exeext' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest$ac_exeext && + $as_test_x conftest$ac_exeext; then ac_cv_lib_dl_dlopen=yes else echo "$as_me: failed program was:" >&5 @@ -13197,7 +11809,7 @@ ac_cv_lib_dl_dlopen=no fi -rm -f core conftest.err conftest.$ac_objext \ +rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi @@ -13255,27 +11867,11 @@ rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest$ac_exeext' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest$ac_exeext && + $as_test_x conftest$ac_exeext; then ac_cv_lib_dld_shl_load=yes else echo "$as_me: failed program was:" >&5 @@ -13284,7 +11880,7 @@ ac_cv_lib_dld_shl_load=no fi -rm -f core conftest.err conftest.$ac_objext \ +rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi @@ -13350,27 +11946,11 @@ rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest$ac_exeext' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest$ac_exeext && + $as_test_x conftest$ac_exeext; then ac_cv_search_sem_init=$ac_res else echo "$as_me: failed program was:" >&5 @@ -13379,7 +11959,7 @@ fi -rm -f core conftest.err conftest.$ac_objext \ +rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ conftest$ac_exeext if test "${ac_cv_search_sem_init+set}" = set; then break @@ -13448,27 +12028,11 @@ rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest$ac_exeext' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest$ac_exeext && + $as_test_x conftest$ac_exeext; then ac_cv_lib_intl_textdomain=yes else echo "$as_me: failed program was:" >&5 @@ -13477,7 +12041,7 @@ ac_cv_lib_intl_textdomain=no fi -rm -f core conftest.err conftest.$ac_objext \ +rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi @@ -13524,27 +12088,11 @@ rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest$ac_exeext' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest$ac_exeext && + $as_test_x conftest$ac_exeext; then cat >>confdefs.h <<\_ACEOF #define AIX_GENUINE_CPLUSPLUS 1 @@ -13560,7 +12108,7 @@ echo "${ECHO_T}no" >&6; } fi -rm -f core conftest.err conftest.$ac_objext \ +rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ conftest$ac_exeext conftest.$ac_ext;; *) ;; esac @@ -13609,27 +12157,11 @@ rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest$ac_exeext' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest$ac_exeext && + $as_test_x conftest$ac_exeext; then ac_cv_lib_nsl_t_open=yes else echo "$as_me: failed program was:" >&5 @@ -13638,7 +12170,7 @@ ac_cv_lib_nsl_t_open=no fi -rm -f core conftest.err conftest.$ac_objext \ +rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi @@ -13690,27 +12222,11 @@ rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest$ac_exeext' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest$ac_exeext && + $as_test_x conftest$ac_exeext; then ac_cv_lib_socket_socket=yes else echo "$as_me: failed program was:" >&5 @@ -13719,7 +12235,7 @@ ac_cv_lib_socket_socket=no fi -rm -f core conftest.err conftest.$ac_objext \ +rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi @@ -13774,27 +12290,11 @@ rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest$ac_exeext' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest$ac_exeext && + $as_test_x conftest$ac_exeext; then ac_cv_lib_net_socket=yes else echo "$as_me: failed program was:" >&5 @@ -13803,7 +12303,7 @@ ac_cv_lib_net_socket=no fi -rm -f core conftest.err conftest.$ac_objext \ +rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi @@ -14057,27 +12557,10 @@ rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then ac_header_compiler=yes else echo "$as_me: failed program was:" >&5 @@ -14113,17 +12596,10 @@ rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } >/dev/null; then - if test -s conftest.err; then - ac_cpp_err=$ac_c_preproc_warn_flag - ac_cpp_err=$ac_cpp_err$ac_c_werror_flag - else - ac_cpp_err= - fi -else - ac_cpp_err=yes -fi -if test -z "$ac_cpp_err"; then + (exit $ac_status); } >/dev/null && { + test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || + test ! -s conftest.err + }; then ac_header_preproc=yes else echo "$as_me: failed program was:" >&5 @@ -14229,27 +12705,10 @@ rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then ac_header_compiler=yes else echo "$as_me: failed program was:" >&5 @@ -14285,17 +12744,10 @@ rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } >/dev/null; then - if test -s conftest.err; then - ac_cpp_err=$ac_c_preproc_warn_flag - ac_cpp_err=$ac_cpp_err$ac_c_werror_flag - else - ac_cpp_err= - fi -else - ac_cpp_err=yes -fi -if test -z "$ac_cpp_err"; then + (exit $ac_status); } >/dev/null && { + test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || + test ! -s conftest.err + }; then ac_header_preproc=yes else echo "$as_me: failed program was:" >&5 @@ -14426,27 +12878,11 @@ rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest$ac_exeext' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest$ac_exeext && + $as_test_x conftest$ac_exeext; then { echo "$as_me:$LINENO: result: yes" >&5 echo "${ECHO_T}yes" >&6; } @@ -14525,27 +12961,11 @@ rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest$ac_exeext' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest$ac_exeext && + $as_test_x conftest$ac_exeext; then ac_cv_func_pthread_detach=yes else echo "$as_me: failed program was:" >&5 @@ -14554,7 +12974,7 @@ ac_cv_func_pthread_detach=no fi -rm -f core conftest.err conftest.$ac_objext \ +rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ conftest$ac_exeext conftest.$ac_ext fi { echo "$as_me:$LINENO: result: $ac_cv_func_pthread_detach" >&5 @@ -14602,27 +13022,10 @@ rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then ac_header_compiler=yes else echo "$as_me: failed program was:" >&5 @@ -14658,17 +13061,10 @@ rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } >/dev/null; then - if test -s conftest.err; then - ac_cpp_err=$ac_c_preproc_warn_flag - ac_cpp_err=$ac_cpp_err$ac_c_werror_flag - else - ac_cpp_err= - fi -else - ac_cpp_err=yes -fi -if test -z "$ac_cpp_err"; then + (exit $ac_status); } >/dev/null && { + test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || + test ! -s conftest.err + }; then ac_header_preproc=yes else echo "$as_me: failed program was:" >&5 @@ -14769,27 +13165,10 @@ rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then ac_header_compiler=yes else echo "$as_me: failed program was:" >&5 @@ -14825,17 +13204,10 @@ rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } >/dev/null; then - if test -s conftest.err; then - ac_cpp_err=$ac_c_preproc_warn_flag - ac_cpp_err=$ac_cpp_err$ac_c_werror_flag - else - ac_cpp_err= - fi -else - ac_cpp_err=yes -fi -if test -z "$ac_cpp_err"; then + (exit $ac_status); } >/dev/null && { + test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || + test ! -s conftest.err + }; then ac_header_preproc=yes else echo "$as_me: failed program was:" >&5 @@ -14944,27 +13316,11 @@ rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest$ac_exeext' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest$ac_exeext && + $as_test_x conftest$ac_exeext; then ac_cv_lib_pthreads_pthread_create=yes else echo "$as_me: failed program was:" >&5 @@ -14973,7 +13329,7 @@ ac_cv_lib_pthreads_pthread_create=no fi -rm -f core conftest.err conftest.$ac_objext \ +rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi @@ -15031,27 +13387,11 @@ rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest$ac_exeext' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest$ac_exeext && + $as_test_x conftest$ac_exeext; then ac_cv_lib_c_r_pthread_create=yes else echo "$as_me: failed program was:" >&5 @@ -15060,7 +13400,7 @@ ac_cv_lib_c_r_pthread_create=no fi -rm -f core conftest.err conftest.$ac_objext \ +rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi @@ -15118,27 +13458,11 @@ rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest$ac_exeext' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest$ac_exeext && + $as_test_x conftest$ac_exeext; then ac_cv_lib_pthread___pthread_create_system=yes else echo "$as_me: failed program was:" >&5 @@ -15147,7 +13471,7 @@ ac_cv_lib_pthread___pthread_create_system=no fi -rm -f core conftest.err conftest.$ac_objext \ +rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi @@ -15205,27 +13529,11 @@ rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest$ac_exeext' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest$ac_exeext && + $as_test_x conftest$ac_exeext; then ac_cv_lib_cma_pthread_create=yes else echo "$as_me: failed program was:" >&5 @@ -15234,7 +13542,7 @@ ac_cv_lib_cma_pthread_create=no fi -rm -f core conftest.err conftest.$ac_objext \ +rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi @@ -15270,7 +13578,7 @@ fi -rm -f core conftest.err conftest.$ac_objext \ +rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ conftest$ac_exeext conftest.$ac_ext fi @@ -15323,27 +13631,11 @@ rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest$ac_exeext' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest$ac_exeext && + $as_test_x conftest$ac_exeext; then ac_cv_lib_mpc_usconfig=yes else echo "$as_me: failed program was:" >&5 @@ -15352,7 +13644,7 @@ ac_cv_lib_mpc_usconfig=no fi -rm -f core conftest.err conftest.$ac_objext \ +rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi @@ -15412,27 +13704,11 @@ rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest$ac_exeext' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest$ac_exeext && + $as_test_x conftest$ac_exeext; then ac_cv_lib_thread_thr_create=yes else echo "$as_me: failed program was:" >&5 @@ -15441,7 +13717,7 @@ ac_cv_lib_thread_thr_create=no fi -rm -f core conftest.err conftest.$ac_objext \ +rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi @@ -15633,27 +13909,11 @@ rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest$ac_exeext' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest$ac_exeext && + $as_test_x conftest$ac_exeext; then eval "$as_ac_var=yes" else echo "$as_me: failed program was:" >&5 @@ -15662,7 +13922,7 @@ eval "$as_ac_var=no" fi -rm -f core conftest.err conftest.$ac_objext \ +rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ conftest$ac_exeext conftest.$ac_ext fi ac_res=`eval echo '${'$as_ac_var'}'` @@ -15806,27 +14066,10 @@ rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then { echo "$as_me:$LINENO: result: yes" >&5 echo "${ECHO_T}yes" >&6; } ipv6=yes @@ -16205,27 +14448,11 @@ rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest$ac_exeext' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest$ac_exeext && + $as_test_x conftest$ac_exeext; then eval "$as_ac_var=yes" else echo "$as_me: failed program was:" >&5 @@ -16234,7 +14461,7 @@ eval "$as_ac_var=no" fi -rm -f core conftest.err conftest.$ac_objext \ +rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ conftest$ac_exeext conftest.$ac_ext fi ac_res=`eval echo '${'$as_ac_var'}'` @@ -16457,27 +14684,11 @@ rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest$ac_exeext' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest$ac_exeext && + $as_test_x conftest$ac_exeext; then eval "$as_ac_var=yes" else echo "$as_me: failed program was:" >&5 @@ -16486,7 +14697,7 @@ eval "$as_ac_var=no" fi -rm -f core conftest.err conftest.$ac_objext \ +rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ conftest$ac_exeext conftest.$ac_ext fi ac_res=`eval echo '${'$as_ac_var'}'` @@ -16533,27 +14744,10 @@ rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then cat >>confdefs.h <<\_ACEOF #define HAVE_CHROOT 1 @@ -16601,27 +14795,10 @@ rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then cat >>confdefs.h <<\_ACEOF #define HAVE_LINK 1 @@ -16669,27 +14846,10 @@ rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then cat >>confdefs.h <<\_ACEOF #define HAVE_SYMLINK 1 @@ -16737,27 +14897,10 @@ rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then cat >>confdefs.h <<\_ACEOF #define HAVE_FCHDIR 1 @@ -16805,27 +14948,10 @@ rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then cat >>confdefs.h <<\_ACEOF #define HAVE_FSYNC 1 @@ -16873,27 +14999,10 @@ rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then cat >>confdefs.h <<\_ACEOF #define HAVE_FDATASYNC 1 @@ -16951,27 +15060,10 @@ rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then cat >>confdefs.h <<\_ACEOF #define HAVE_CTERMID_R 1 @@ -17023,27 +15115,10 @@ rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then cat >>confdefs.h <<\_ACEOF #define HAVE_FLOCK 1 @@ -17095,27 +15170,10 @@ rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then cat >>confdefs.h <<\_ACEOF #define HAVE_GETPAGESIZE 1 @@ -17152,7 +15210,7 @@ IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; }; then + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_TRUE="$ac_prog" echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 @@ -17220,27 +15278,11 @@ rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest$ac_exeext' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest$ac_exeext && + $as_test_x conftest$ac_exeext; then ac_cv_lib_c_inet_aton=yes else echo "$as_me: failed program was:" >&5 @@ -17249,7 +15291,7 @@ ac_cv_lib_c_inet_aton=no fi -rm -f core conftest.err conftest.$ac_objext \ +rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi @@ -17301,27 +15343,11 @@ rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest$ac_exeext' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest$ac_exeext && + $as_test_x conftest$ac_exeext; then ac_cv_lib_resolv_inet_aton=yes else echo "$as_me: failed program was:" >&5 @@ -17330,7 +15356,7 @@ ac_cv_lib_resolv_inet_aton=no fi -rm -f core conftest.err conftest.$ac_objext \ +rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi @@ -17400,27 +15426,11 @@ rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest$ac_exeext' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest$ac_exeext && + $as_test_x conftest$ac_exeext; then ac_cv_lib_z_inflateCopy=yes else echo "$as_me: failed program was:" >&5 @@ -17429,7 +15439,7 @@ ac_cv_lib_z_inflateCopy=no fi -rm -f core conftest.err conftest.$ac_objext \ +rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi @@ -17484,27 +15494,11 @@ rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest$ac_exeext' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest$ac_exeext && + $as_test_x conftest$ac_exeext; then cat >>confdefs.h <<\_ACEOF #define HAVE_HSTRERROR 1 @@ -17521,7 +15515,7 @@ fi -rm -f core conftest.err conftest.$ac_objext \ +rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ conftest$ac_exeext conftest.$ac_ext { echo "$as_me:$LINENO: checking for inet_aton" >&5 @@ -17560,27 +15554,11 @@ rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest$ac_exeext' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest$ac_exeext && + $as_test_x conftest$ac_exeext; then cat >>confdefs.h <<\_ACEOF #define HAVE_INET_ATON 1 @@ -17597,7 +15575,7 @@ fi -rm -f core conftest.err conftest.$ac_objext \ +rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ conftest$ac_exeext conftest.$ac_ext { echo "$as_me:$LINENO: checking for inet_pton" >&5 @@ -17636,27 +15614,10 @@ rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then cat >>confdefs.h <<\_ACEOF #define HAVE_INET_PTON 1 @@ -17712,27 +15673,10 @@ rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then cat >>confdefs.h <<\_ACEOF #define HAVE_SETGROUPS 1 @@ -17820,27 +15764,11 @@ rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest$ac_exeext' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest$ac_exeext && + $as_test_x conftest$ac_exeext; then eval "$as_ac_var=yes" else echo "$as_me: failed program was:" >&5 @@ -17849,7 +15777,7 @@ eval "$as_ac_var=no" fi -rm -f core conftest.err conftest.$ac_objext \ +rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ conftest$ac_exeext conftest.$ac_ext fi ac_res=`eval echo '${'$as_ac_var'}'` @@ -17903,27 +15831,11 @@ rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest$ac_exeext' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest$ac_exeext && + $as_test_x conftest$ac_exeext; then ac_cv_lib_util_openpty=yes else echo "$as_me: failed program was:" >&5 @@ -17932,7 +15844,7 @@ ac_cv_lib_util_openpty=no fi -rm -f core conftest.err conftest.$ac_objext \ +rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi @@ -17986,27 +15898,11 @@ rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest$ac_exeext' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest$ac_exeext && + $as_test_x conftest$ac_exeext; then ac_cv_lib_bsd_openpty=yes else echo "$as_me: failed program was:" >&5 @@ -18015,7 +15911,7 @@ ac_cv_lib_bsd_openpty=no fi -rm -f core conftest.err conftest.$ac_objext \ +rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi @@ -18102,27 +15998,11 @@ rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest$ac_exeext' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest$ac_exeext && + $as_test_x conftest$ac_exeext; then eval "$as_ac_var=yes" else echo "$as_me: failed program was:" >&5 @@ -18131,7 +16011,7 @@ eval "$as_ac_var=no" fi -rm -f core conftest.err conftest.$ac_objext \ +rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ conftest$ac_exeext conftest.$ac_ext fi ac_res=`eval echo '${'$as_ac_var'}'` @@ -18185,27 +16065,11 @@ rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest$ac_exeext' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest$ac_exeext && + $as_test_x conftest$ac_exeext; then ac_cv_lib_util_forkpty=yes else echo "$as_me: failed program was:" >&5 @@ -18214,7 +16078,7 @@ ac_cv_lib_util_forkpty=no fi -rm -f core conftest.err conftest.$ac_objext \ +rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi @@ -18268,27 +16132,11 @@ rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest$ac_exeext' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest$ac_exeext && + $as_test_x conftest$ac_exeext; then ac_cv_lib_bsd_forkpty=yes else echo "$as_me: failed program was:" >&5 @@ -18297,7 +16145,7 @@ ac_cv_lib_bsd_forkpty=no fi -rm -f core conftest.err conftest.$ac_objext \ +rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi @@ -18391,27 +16239,11 @@ rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest$ac_exeext' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest$ac_exeext && + $as_test_x conftest$ac_exeext; then eval "$as_ac_var=yes" else echo "$as_me: failed program was:" >&5 @@ -18420,7 +16252,7 @@ eval "$as_ac_var=no" fi -rm -f core conftest.err conftest.$ac_objext \ +rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ conftest$ac_exeext conftest.$ac_ext fi ac_res=`eval echo '${'$as_ac_var'}'` @@ -18506,27 +16338,11 @@ rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest$ac_exeext' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest$ac_exeext && + $as_test_x conftest$ac_exeext; then eval "$as_ac_var=yes" else echo "$as_me: failed program was:" >&5 @@ -18535,7 +16351,7 @@ eval "$as_ac_var=no" fi -rm -f core conftest.err conftest.$ac_objext \ +rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ conftest$ac_exeext conftest.$ac_ext fi ac_res=`eval echo '${'$as_ac_var'}'` @@ -18624,27 +16440,11 @@ rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest$ac_exeext' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest$ac_exeext && + $as_test_x conftest$ac_exeext; then eval "$as_ac_var=yes" else echo "$as_me: failed program was:" >&5 @@ -18653,7 +16453,7 @@ eval "$as_ac_var=no" fi -rm -f core conftest.err conftest.$ac_objext \ +rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ conftest$ac_exeext conftest.$ac_ext fi ac_res=`eval echo '${'$as_ac_var'}'` @@ -18691,27 +16491,10 @@ rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then cat >>confdefs.h <<\_ACEOF #define GETPGRP_HAVE_ARG 1 @@ -18797,27 +16580,11 @@ rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest$ac_exeext' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest$ac_exeext && + $as_test_x conftest$ac_exeext; then eval "$as_ac_var=yes" else echo "$as_me: failed program was:" >&5 @@ -18826,7 +16593,7 @@ eval "$as_ac_var=no" fi -rm -f core conftest.err conftest.$ac_objext \ +rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ conftest$ac_exeext conftest.$ac_ext fi ac_res=`eval echo '${'$as_ac_var'}'` @@ -18864,27 +16631,10 @@ rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then cat >>confdefs.h <<\_ACEOF #define SETPGRP_HAVE_ARG 1 @@ -18970,27 +16720,11 @@ rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest$ac_exeext' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest$ac_exeext && + $as_test_x conftest$ac_exeext; then eval "$as_ac_var=yes" else echo "$as_me: failed program was:" >&5 @@ -18999,7 +16733,7 @@ eval "$as_ac_var=no" fi -rm -f core conftest.err conftest.$ac_objext \ +rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ conftest$ac_exeext conftest.$ac_ext fi ac_res=`eval echo '${'$as_ac_var'}'` @@ -19037,27 +16771,10 @@ rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then : else echo "$as_me: failed program was:" >&5 @@ -19117,27 +16834,11 @@ rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest$ac_exeext' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest$ac_exeext && + $as_test_x conftest$ac_exeext; then cat >>confdefs.h <<\_ACEOF @@ -19157,7 +16858,7 @@ fi -rm -f core conftest.err conftest.$ac_objext \ +rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ conftest$ac_exeext conftest.$ac_ext # On OSF/1 V5.1, getaddrinfo is available, but a define @@ -19199,27 +16900,11 @@ rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest$ac_exeext' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest$ac_exeext && + $as_test_x conftest$ac_exeext; then { echo "$as_me:$LINENO: result: yes" >&5 echo "${ECHO_T}yes" >&6; } @@ -19372,7 +17057,7 @@ fi -rm -f core conftest.err conftest.$ac_objext \ +rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ conftest$ac_exeext conftest.$ac_ext if test "$buggygetaddrinfo" = "yes"; then @@ -19455,27 +17140,11 @@ rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest$ac_exeext' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest$ac_exeext && + $as_test_x conftest$ac_exeext; then eval "$as_ac_var=yes" else echo "$as_me: failed program was:" >&5 @@ -19484,7 +17153,7 @@ eval "$as_ac_var=no" fi -rm -f core conftest.err conftest.$ac_objext \ +rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ conftest$ac_exeext conftest.$ac_ext fi ac_res=`eval echo '${'$as_ac_var'}'` @@ -19537,27 +17206,10 @@ rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then ac_cv_header_time=yes else echo "$as_me: failed program was:" >&5 @@ -19595,7 +17247,9 @@ int main () { -struct tm *tp; tp->tm_sec; +struct tm tm; + int *p = &tm.tm_sec; + return !p; ; return 0; } @@ -19613,27 +17267,10 @@ rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then ac_cv_struct_tm=time.h else echo "$as_me: failed program was:" >&5 @@ -19692,27 +17329,10 @@ rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then ac_cv_member_struct_tm_tm_zone=yes else echo "$as_me: failed program was:" >&5 @@ -19751,27 +17371,10 @@ rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then ac_cv_member_struct_tm_tm_zone=yes else echo "$as_me: failed program was:" >&5 @@ -19820,8 +17423,7 @@ main () { #ifndef tzname - char *p = (char *) tzname; - return !p; + (void) tzname; #endif ; @@ -19841,27 +17443,10 @@ rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then ac_cv_have_decl_tzname=yes else echo "$as_me: failed program was:" >&5 @@ -19927,27 +17512,11 @@ rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest$ac_exeext' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest$ac_exeext && + $as_test_x conftest$ac_exeext; then ac_cv_var_tzname=yes else echo "$as_me: failed program was:" >&5 @@ -19956,7 +17525,7 @@ ac_cv_var_tzname=no fi -rm -f core conftest.err conftest.$ac_objext \ +rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ conftest$ac_exeext conftest.$ac_ext fi { echo "$as_me:$LINENO: result: $ac_cv_var_tzname" >&5 @@ -20005,27 +17574,10 @@ rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then ac_cv_member_struct_stat_st_rdev=yes else echo "$as_me: failed program was:" >&5 @@ -20061,27 +17613,10 @@ rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then ac_cv_member_struct_stat_st_rdev=yes else echo "$as_me: failed program was:" >&5 @@ -20141,27 +17676,10 @@ rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then ac_cv_member_struct_stat_st_blksize=yes else echo "$as_me: failed program was:" >&5 @@ -20197,27 +17715,10 @@ rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then ac_cv_member_struct_stat_st_blksize=yes else echo "$as_me: failed program was:" >&5 @@ -20277,27 +17778,10 @@ rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then ac_cv_member_struct_stat_st_flags=yes else echo "$as_me: failed program was:" >&5 @@ -20333,27 +17817,10 @@ rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then ac_cv_member_struct_stat_st_flags=yes else echo "$as_me: failed program was:" >&5 @@ -20413,27 +17880,10 @@ rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then ac_cv_member_struct_stat_st_gen=yes else echo "$as_me: failed program was:" >&5 @@ -20469,27 +17919,10 @@ rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then ac_cv_member_struct_stat_st_gen=yes else echo "$as_me: failed program was:" >&5 @@ -20549,27 +17982,10 @@ rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then ac_cv_member_struct_stat_st_birthtime=yes else echo "$as_me: failed program was:" >&5 @@ -20605,27 +18021,10 @@ rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then ac_cv_member_struct_stat_st_birthtime=yes else echo "$as_me: failed program was:" >&5 @@ -20685,27 +18084,10 @@ rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then ac_cv_member_struct_stat_st_blocks=yes else echo "$as_me: failed program was:" >&5 @@ -20741,27 +18123,10 @@ rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then ac_cv_member_struct_stat_st_blocks=yes else echo "$as_me: failed program was:" >&5 @@ -20832,27 +18197,10 @@ rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then ac_cv_header_time_altzone=yes else echo "$as_me: failed program was:" >&5 @@ -20909,27 +18257,10 @@ rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then cat >>confdefs.h <<\_ACEOF @@ -20983,27 +18314,10 @@ rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then ac_cv_struct_addrinfo=yes else echo "$as_me: failed program was:" >&5 @@ -21060,27 +18374,10 @@ rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then ac_cv_struct_sockaddr_storage=yes else echo "$as_me: failed program was:" >&5 @@ -21140,27 +18437,10 @@ rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then ac_cv_c_char_unsigned=no else echo "$as_me: failed program was:" >&5 @@ -21199,10 +18479,10 @@ #ifndef __cplusplus /* Ultrix mips cc rejects this. */ typedef int charset[2]; - const charset x; + const charset cs; /* SunOS 4.1.1 cc rejects this. */ - char const *const *ccp; - char **p; + char const *const *pcpcc; + char **ppc; /* NEC SVR4.0.2 mips cc rejects this. */ struct point {int x, y;}; static struct point const zero = {0,0}; @@ -21211,11 +18491,11 @@ an arm of an if-expression whose if-part is not a constant expression */ const char *g = "string"; - ccp = &g + (g ? g-g : 0); + pcpcc = &g + (g ? g-g : 0); /* HPUX 7.0 cc rejects these. */ - ++ccp; - p = (char**) ccp; - ccp = (char const *const *) p; + ++pcpcc; + ppc = (char**) pcpcc; + pcpcc = (char const *const *) ppc; { /* SCO 3.2v4 cc rejects this. */ char *t; char const *s = 0 ? (char *) 0 : (char const *) 0; @@ -21242,7 +18522,7 @@ const int foo = 10; if (!foo) return 0; } - return !x[0] && !zero.x; + return !cs[0] && !zero.x; #endif ; @@ -21262,27 +18542,10 @@ rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then ac_cv_c_const=yes else echo "$as_me: failed program was:" >&5 @@ -21335,27 +18598,10 @@ rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then works=yes else echo "$as_me: failed program was:" >&5 @@ -21404,27 +18650,10 @@ rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then works=yes else echo "$as_me: failed program was:" >&5 @@ -21473,27 +18702,10 @@ rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then cat >>confdefs.h <<\_ACEOF @@ -21538,43 +18750,26 @@ { return foo(10, "", 3.14); ; - return 0; -} -_ACEOF -rm -f conftest.$ac_objext -if { (ac_try="$ac_compile" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_compile") 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (case "(($ac_try" in + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (ac_try="$ac_compile" +case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 + (eval "$ac_compile") 2>conftest.er1 ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then cat >>confdefs.h <<\_ACEOF @@ -21628,27 +18823,10 @@ rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then cat >>confdefs.h <<\_ACEOF #define HAVE_SOCKETPAIR 1 @@ -21700,27 +18878,10 @@ rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then { echo "$as_me:$LINENO: result: yes" >&5 echo "${ECHO_T}yes" >&6; } @@ -21775,27 +18936,10 @@ rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then : else echo "$as_me: failed program was:" >&5 @@ -21882,27 +19026,11 @@ rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest$ac_exeext' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest$ac_exeext && + $as_test_x conftest$ac_exeext; then ac_cv_func_gethostbyname_r=yes else echo "$as_me: failed program was:" >&5 @@ -21911,7 +19039,7 @@ ac_cv_func_gethostbyname_r=no fi -rm -f core conftest.err conftest.$ac_objext \ +rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ conftest$ac_exeext conftest.$ac_ext fi { echo "$as_me:$LINENO: result: $ac_cv_func_gethostbyname_r" >&5 @@ -21964,27 +19092,10 @@ rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then cat >>confdefs.h <<\_ACEOF #define HAVE_GETHOSTBYNAME_R 1 @@ -22045,27 +19156,10 @@ rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then cat >>confdefs.h <<\_ACEOF #define HAVE_GETHOSTBYNAME_R 1 @@ -22124,27 +19218,10 @@ rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then cat >>confdefs.h <<\_ACEOF #define HAVE_GETHOSTBYNAME_R 1 @@ -22248,27 +19325,11 @@ rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest$ac_exeext' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest$ac_exeext && + $as_test_x conftest$ac_exeext; then eval "$as_ac_var=yes" else echo "$as_me: failed program was:" >&5 @@ -22277,7 +19338,7 @@ eval "$as_ac_var=no" fi -rm -f core conftest.err conftest.$ac_objext \ +rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ conftest$ac_exeext conftest.$ac_ext fi ac_res=`eval echo '${'$as_ac_var'}'` @@ -22367,27 +19428,11 @@ rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest$ac_exeext' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest$ac_exeext && + $as_test_x conftest$ac_exeext; then ac_cv_func___fpu_control=yes else echo "$as_me: failed program was:" >&5 @@ -22396,7 +19441,7 @@ ac_cv_func___fpu_control=no fi -rm -f core conftest.err conftest.$ac_objext \ +rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ conftest$ac_exeext conftest.$ac_ext fi { echo "$as_me:$LINENO: result: $ac_cv_func___fpu_control" >&5 @@ -22447,27 +19492,11 @@ rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest$ac_exeext' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest$ac_exeext && + $as_test_x conftest$ac_exeext; then ac_cv_lib_ieee___fpu_control=yes else echo "$as_me: failed program was:" >&5 @@ -22476,7 +19505,7 @@ ac_cv_lib_ieee___fpu_control=no fi -rm -f core conftest.err conftest.$ac_objext \ +rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi @@ -22647,27 +19676,11 @@ rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest$ac_exeext' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest$ac_exeext && + $as_test_x conftest$ac_exeext; then eval "$as_ac_var=yes" else echo "$as_me: failed program was:" >&5 @@ -22676,7 +19689,7 @@ eval "$as_ac_var=no" fi -rm -f core conftest.err conftest.$ac_objext \ +rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ conftest$ac_exeext conftest.$ac_ext fi ac_res=`eval echo '${'$as_ac_var'}'` @@ -22735,27 +19748,10 @@ rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then ac_header_compiler=yes else echo "$as_me: failed program was:" >&5 @@ -22791,17 +19787,10 @@ rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } >/dev/null; then - if test -s conftest.err; then - ac_cpp_err=$ac_c_preproc_warn_flag - ac_cpp_err=$ac_cpp_err$ac_c_werror_flag - else - ac_cpp_err= - fi -else - ac_cpp_err=yes -fi -if test -z "$ac_cpp_err"; then + (exit $ac_status); } >/dev/null && { + test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || + test ! -s conftest.err + }; then ac_header_preproc=yes else echo "$as_me: failed program was:" >&5 @@ -22912,27 +19901,10 @@ rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then ac_cv_type_wchar_t=yes else echo "$as_me: failed program was:" >&5 @@ -22946,16 +19918,15 @@ { echo "$as_me:$LINENO: result: $ac_cv_type_wchar_t" >&5 echo "${ECHO_T}$ac_cv_type_wchar_t" >&6; } +# The cast to long int works around a bug in the HP C Compiler +# version HP92453-01 B.11.11.23709.GP, which incorrectly rejects +# declarations like `int a3[[(sizeof (unsigned char)) >= 0]];'. +# This bug is HP SR number 8606223364. { echo "$as_me:$LINENO: checking size of wchar_t" >&5 echo $ECHO_N "checking size of wchar_t... $ECHO_C" >&6; } if test "${ac_cv_sizeof_wchar_t+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else - if test "$ac_cv_type_wchar_t" = yes; then - # The cast to long int works around a bug in the HP C Compiler - # version HP92453-01 B.11.11.23709.GP, which incorrectly rejects - # declarations like `int a3[[(sizeof (unsigned char)) >= 0]];'. - # This bug is HP SR number 8606223364. if test "$cross_compiling" = yes; then # Depending upon the size, compute the lo and hi bounds. cat >conftest.$ac_ext <<_ACEOF @@ -22966,7 +19937,7 @@ /* end confdefs.h. */ #include - typedef wchar_t ac__type_sizeof_; + typedef wchar_t ac__type_sizeof_; int main () { @@ -22986,31 +19957,14 @@ eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_compile") 2>conftest.er1 ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then ac_lo=0 ac_mid=0 while :; do cat >conftest.$ac_ext <<_ACEOF @@ -23021,7 +19975,7 @@ /* end confdefs.h. */ #include - typedef wchar_t ac__type_sizeof_; + typedef wchar_t ac__type_sizeof_; int main () { @@ -23045,27 +19999,10 @@ rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then ac_hi=$ac_mid; break else echo "$as_me: failed program was:" >&5 @@ -23093,7 +20030,7 @@ /* end confdefs.h. */ #include - typedef wchar_t ac__type_sizeof_; + typedef wchar_t ac__type_sizeof_; int main () { @@ -23117,27 +20054,10 @@ rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then ac_hi=-1 ac_mid=-1 while :; do cat >conftest.$ac_ext <<_ACEOF @@ -23148,7 +20068,7 @@ /* end confdefs.h. */ #include - typedef wchar_t ac__type_sizeof_; + typedef wchar_t ac__type_sizeof_; int main () { @@ -23172,27 +20092,10 @@ rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then ac_lo=$ac_mid; break else echo "$as_me: failed program was:" >&5 @@ -23230,7 +20133,7 @@ /* end confdefs.h. */ #include - typedef wchar_t ac__type_sizeof_; + typedef wchar_t ac__type_sizeof_; int main () { @@ -23254,27 +20157,10 @@ rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then ac_hi=$ac_mid else echo "$as_me: failed program was:" >&5 @@ -23287,11 +20173,15 @@ done case $ac_lo in ?*) ac_cv_sizeof_wchar_t=$ac_lo;; -'') { { echo "$as_me:$LINENO: error: cannot compute sizeof (wchar_t) +'') if test "$ac_cv_type_wchar_t" = yes; then + { { echo "$as_me:$LINENO: error: cannot compute sizeof (wchar_t) See \`config.log' for more details." >&5 echo "$as_me: error: cannot compute sizeof (wchar_t) See \`config.log' for more details." >&2;} - { (exit 77); exit 77; }; } ;; + { (exit 77); exit 77; }; } + else + ac_cv_sizeof_wchar_t=0 + fi ;; esac else cat >conftest.$ac_ext <<_ACEOF @@ -23302,7 +20192,7 @@ /* end confdefs.h. */ #include - typedef wchar_t ac__type_sizeof_; + typedef wchar_t ac__type_sizeof_; static long int longval () { return (long int) (sizeof (ac__type_sizeof_)); } static unsigned long int ulongval () { return (long int) (sizeof (ac__type_sizeof_)); } #include @@ -23361,21 +20251,25 @@ sed 's/^/| /' conftest.$ac_ext >&5 ( exit $ac_status ) -{ { echo "$as_me:$LINENO: error: cannot compute sizeof (wchar_t) +if test "$ac_cv_type_wchar_t" = yes; then + { { echo "$as_me:$LINENO: error: cannot compute sizeof (wchar_t) See \`config.log' for more details." >&5 echo "$as_me: error: cannot compute sizeof (wchar_t) See \`config.log' for more details." >&2;} { (exit 77); exit 77; }; } + else + ac_cv_sizeof_wchar_t=0 + fi fi rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext fi rm -f conftest.val -else - ac_cv_sizeof_wchar_t=0 -fi fi { echo "$as_me:$LINENO: result: $ac_cv_sizeof_wchar_t" >&5 echo "${ECHO_T}$ac_cv_sizeof_wchar_t" >&6; } + + + cat >>confdefs.h <<_ACEOF #define SIZEOF_WCHAR_T $ac_cv_sizeof_wchar_t _ACEOF @@ -23418,27 +20312,10 @@ rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then cat >>confdefs.h <<\_ACEOF @@ -23634,7 +20511,8 @@ int main () { -#if !BYTE_ORDER || !BIG_ENDIAN || !LITTLE_ENDIAN +#if ! (defined BYTE_ORDER && defined BIG_ENDIAN && defined LITTLE_ENDIAN \ + && BYTE_ORDER && BIG_ENDIAN && LITTLE_ENDIAN) bogus endian macros #endif @@ -23655,27 +20533,10 @@ rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then # It does; now see whether it defined to BIG_ENDIAN or not. cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ @@ -23710,27 +20571,10 @@ rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then ac_cv_c_bigendian=yes else echo "$as_me: failed program was:" >&5 @@ -23781,27 +20625,10 @@ rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then if grep BIGenDianSyS conftest.$ac_objext >/dev/null ; then ac_cv_c_bigendian=yes fi @@ -24015,27 +20842,11 @@ rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest$ac_exeext' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest$ac_exeext && + $as_test_x conftest$ac_exeext; then ac_cv_have_getc_unlocked=yes else echo "$as_me: failed program was:" >&5 @@ -24044,7 +20855,7 @@ ac_cv_have_getc_unlocked=no fi -rm -f core conftest.err conftest.$ac_objext \ +rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ conftest$ac_exeext conftest.$ac_ext fi @@ -24105,27 +20916,11 @@ rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest$ac_exeext' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest$ac_exeext && + $as_test_x conftest$ac_exeext; then ac_cv_lib_readline_readline=yes else echo "$as_me: failed program was:" >&5 @@ -24134,7 +20929,7 @@ ac_cv_lib_readline_readline=no fi -rm -f core conftest.err conftest.$ac_objext \ +rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi @@ -24194,27 +20989,11 @@ rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest$ac_exeext' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest$ac_exeext && + $as_test_x conftest$ac_exeext; then ac_cv_lib_termcap_readline=yes else echo "$as_me: failed program was:" >&5 @@ -24223,7 +21002,7 @@ ac_cv_lib_termcap_readline=no fi -rm -f core conftest.err conftest.$ac_objext \ +rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi @@ -24283,27 +21062,11 @@ rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest$ac_exeext' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest$ac_exeext && + $as_test_x conftest$ac_exeext; then ac_cv_lib_readline_rl_callback_handler_install=yes else echo "$as_me: failed program was:" >&5 @@ -24312,7 +21075,7 @@ ac_cv_lib_readline_rl_callback_handler_install=no fi -rm -f core conftest.err conftest.$ac_objext \ +rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi @@ -24348,17 +21111,10 @@ rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } >/dev/null; then - if test -s conftest.err; then - ac_cpp_err=$ac_c_preproc_warn_flag - ac_cpp_err=$ac_cpp_err$ac_c_werror_flag - else - ac_cpp_err= - fi -else - ac_cpp_err=yes -fi -if test -z "$ac_cpp_err"; then + (exit $ac_status); } >/dev/null && { + test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || + test ! -s conftest.err + }; then have_readline=yes else echo "$as_me: failed program was:" >&5 @@ -24434,27 +21190,11 @@ rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest$ac_exeext' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest$ac_exeext && + $as_test_x conftest$ac_exeext; then ac_cv_lib_readline_rl_pre_input_hook=yes else echo "$as_me: failed program was:" >&5 @@ -24463,7 +21203,7 @@ ac_cv_lib_readline_rl_pre_input_hook=no fi -rm -f core conftest.err conftest.$ac_objext \ +rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi @@ -24518,30 +21258,14 @@ (eval "$ac_link") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest$ac_exeext' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? + rm -f conftest.er1 + cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest$ac_exeext && + $as_test_x conftest$ac_exeext; then ac_cv_lib_readline_rl_completion_matches=yes else echo "$as_me: failed program was:" >&5 @@ -24550,7 +21274,7 @@ ac_cv_lib_readline_rl_completion_matches=no fi -rm -f core conftest.err conftest.$ac_objext \ +rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi @@ -24586,17 +21310,10 @@ rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } >/dev/null; then - if test -s conftest.err; then - ac_cpp_err=$ac_c_preproc_warn_flag - ac_cpp_err=$ac_cpp_err$ac_c_werror_flag - else - ac_cpp_err= - fi -else - ac_cpp_err=yes -fi -if test -z "$ac_cpp_err"; then + (exit $ac_status); } >/dev/null && { + test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || + test ! -s conftest.err + }; then have_readline=yes else echo "$as_me: failed program was:" >&5 @@ -24825,27 +21542,10 @@ rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then ac_cv_member_struct_tm_tm_zone=yes else echo "$as_me: failed program was:" >&5 @@ -24884,27 +21584,10 @@ rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then ac_cv_member_struct_tm_tm_zone=yes else echo "$as_me: failed program was:" >&5 @@ -24953,8 +21636,7 @@ main () { #ifndef tzname - char *p = (char *) tzname; - return !p; + (void) tzname; #endif ; @@ -24974,27 +21656,10 @@ rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then ac_cv_have_decl_tzname=yes else echo "$as_me: failed program was:" >&5 @@ -25060,27 +21725,11 @@ rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest$ac_exeext' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest$ac_exeext && + $as_test_x conftest$ac_exeext; then ac_cv_var_tzname=yes else echo "$as_me: failed program was:" >&5 @@ -25089,7 +21738,7 @@ ac_cv_var_tzname=no fi -rm -f core conftest.err conftest.$ac_objext \ +rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ conftest$ac_exeext conftest.$ac_ext fi { echo "$as_me:$LINENO: result: $ac_cv_var_tzname" >&5 @@ -25268,27 +21917,10 @@ rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then ac_cv_stat_tv_nsec=yes else echo "$as_me: failed program was:" >&5 @@ -25348,27 +21980,10 @@ rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then ac_cv_stat_tv_nsec2=yes else echo "$as_me: failed program was:" >&5 @@ -25428,27 +22043,10 @@ rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then ac_cv_mvwdelch_is_expression=yes else echo "$as_me: failed program was:" >&5 @@ -25508,27 +22106,10 @@ rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then ac_cv_window_has_flags=yes else echo "$as_me: failed program was:" >&5 @@ -25583,27 +22164,10 @@ rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then cat >>confdefs.h <<\_ACEOF #define HAVE_CURSES_IS_TERM_RESIZED 1 @@ -25652,27 +22216,10 @@ rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then cat >>confdefs.h <<\_ACEOF #define HAVE_CURSES_RESIZE_TERM 1 @@ -25721,27 +22268,10 @@ rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then cat >>confdefs.h <<\_ACEOF #define HAVE_CURSES_RESIZETERM 1 @@ -25762,55 +22292,38 @@ { echo "$as_me:$LINENO: checking for /dev/ptmx" >&5 echo $ECHO_N "checking for /dev/ptmx... $ECHO_C" >&6; } -if test "${ac_cv_file__dev_ptmx+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 -else - test "$cross_compiling" = yes && - { { echo "$as_me:$LINENO: error: cannot check for file existence when cross compiling" >&5 -echo "$as_me: error: cannot check for file existence when cross compiling" >&2;} - { (exit 1); exit 1; }; } -if test -r "/dev/ptmx"; then - ac_cv_file__dev_ptmx=yes -else - ac_cv_file__dev_ptmx=no -fi -fi -{ echo "$as_me:$LINENO: result: $ac_cv_file__dev_ptmx" >&5 -echo "${ECHO_T}$ac_cv_file__dev_ptmx" >&6; } -if test $ac_cv_file__dev_ptmx = yes; then + +if test -r /dev/ptmx +then + { echo "$as_me:$LINENO: result: yes" >&5 +echo "${ECHO_T}yes" >&6; } cat >>confdefs.h <<\_ACEOF #define HAVE_DEV_PTMX 1 _ACEOF +else + { echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6; } fi { echo "$as_me:$LINENO: checking for /dev/ptc" >&5 echo $ECHO_N "checking for /dev/ptc... $ECHO_C" >&6; } -if test "${ac_cv_file__dev_ptc+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 -else - test "$cross_compiling" = yes && - { { echo "$as_me:$LINENO: error: cannot check for file existence when cross compiling" >&5 -echo "$as_me: error: cannot check for file existence when cross compiling" >&2;} - { (exit 1); exit 1; }; } -if test -r "/dev/ptc"; then - ac_cv_file__dev_ptc=yes -else - ac_cv_file__dev_ptc=no -fi -fi -{ echo "$as_me:$LINENO: result: $ac_cv_file__dev_ptc" >&5 -echo "${ECHO_T}$ac_cv_file__dev_ptc" >&6; } -if test $ac_cv_file__dev_ptc = yes; then + +if test -r /dev/ptc +then + { echo "$as_me:$LINENO: result: yes" >&5 +echo "${ECHO_T}yes" >&6; } cat >>confdefs.h <<\_ACEOF #define HAVE_DEV_PTC 1 _ACEOF +else + { echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6; } fi - { echo "$as_me:$LINENO: checking for %zd printf() format support" >&5 echo $ECHO_N "checking for %zd printf() format support... $ECHO_C" >&6; } if test "$cross_compiling" = yes; then @@ -25832,12 +22345,26 @@ int main() { - char buffer[4]; + char buffer[256]; + +#ifdef HAVE_SSIZE_T +typedef ssize_t Py_ssize_t; +#elif SIZEOF_VOID_P == SIZEOF_LONG +typedef long Py_ssize_t; +#else +typedef int Py_ssize_t; +#endif if(sprintf(buffer, "%zd", (size_t)123) < 0) return 1; - if (strncmp(buffer, "123", 3)) + if (strcmp(buffer, "123")) + return 1; + + if (sprintf(buffer, "%zd", (Py_ssize_t)-123) < 0) + return 1; + + if (strcmp(buffer, "-123")) return 1; return 0; @@ -25929,27 +22456,10 @@ rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then ac_cv_type_socklen_t=yes else echo "$as_me: failed program was:" >&5 @@ -26115,7 +22625,8 @@ ## M4sh Initialization. ## ## --------------------- ## -# Be Bourne compatible +# Be more Bourne compatible +DUALCASE=1; export DUALCASE # for MKS sh if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then emulate sh NULLCMD=: @@ -26124,10 +22635,13 @@ alias -g '${1+"$@"}'='"$@"' setopt NO_GLOB_SUBST else - case `(set -o) 2>/dev/null` in *posix*) set -o posix;; esac + case `(set -o) 2>/dev/null` in + *posix*) set -o posix ;; +esac + fi -BIN_SH=xpg4; export BIN_SH # for Tru64 -DUALCASE=1; export DUALCASE # for MKS sh + + # PATH needs CR @@ -26351,19 +22865,28 @@ as_mkdir_p=false fi -# Find out whether ``test -x'' works. Don't use a zero-byte file, as -# systems may use methods other than mode bits to determine executability. -cat >conf$$.file <<_ASEOF -#! /bin/sh -exit 0 -_ASEOF -chmod +x conf$$.file -if test -x conf$$.file >/dev/null 2>&1; then - as_executable_p="test -x" +if test -x / >/dev/null 2>&1; then + as_test_x='test -x' else - as_executable_p=: + if ls -dL / >/dev/null 2>&1; then + as_ls_L_option=L + else + as_ls_L_option= + fi + as_test_x=' + eval sh -c '\'' + if test -d "$1"; then + test -d "$1/."; + else + case $1 in + -*)set "./$1";; + esac; + case `ls -ld'$as_ls_L_option' "$1" 2>/dev/null` in + ???[sx]*):;;*)false;;esac;fi + '\'' sh + ' fi -rm -f conf$$.file +as_executable_p=$as_test_x # Sed expression to map a string onto a valid CPP name. as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'" @@ -26379,7 +22902,7 @@ # values after options handling. ac_log=" This file was extended by python $as_me 3.0, which was -generated by GNU Autoconf 2.60. Invocation command line was +generated by GNU Autoconf 2.61. Invocation command line was CONFIG_FILES = $CONFIG_FILES CONFIG_HEADERS = $CONFIG_HEADERS @@ -26407,7 +22930,7 @@ Usage: $0 [OPTIONS] [FILE]... -h, --help print this help, then exit - -V, --version print version number, then exit + -V, --version print version number and configuration settings, then exit -q, --quiet do not print progress messages -d, --debug don't remove temporary files --recheck update $as_me by reconfiguring in the same conditions @@ -26428,7 +22951,7 @@ cat >>$CONFIG_STATUS <<_ACEOF ac_cs_version="\\ python config.status 3.0 -configured by $0, generated by GNU Autoconf 2.60, +configured by $0, generated by GNU Autoconf 2.61, with options \\"`echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`\\" Copyright (C) 2006 Free Software Foundation, Inc. Modified: python/branches/p3yk-noslice/configure.in ============================================================================== --- python/branches/p3yk-noslice/configure.in (original) +++ python/branches/p3yk-noslice/configure.in Fri Dec 15 05:21:50 2006 @@ -201,7 +201,12 @@ # On OpenBSD, select(2) is not available if _XOPEN_SOURCE is defined, # even though select is a POSIX function. Reported by J. Ribbens. # Reconfirmed for OpenBSD 3.3 by Zachary Hamm, for 3.4 by Jason Ish. - OpenBSD/2.* | OpenBSD/3.@<:@0123456789@:>@) + OpenBSD/2.* | OpenBSD/3.@<:@0123456789@:>@ | OpenBSD/4.@<:@0@:>@) + define_xopen_source=no;; + # Defining _XOPEN_SOURCE on NetBSD version prior to the introduction of + # _NETBSD_SOURCE disables certain features (eg. setgroups). Reported by + # Marc Recht + NetBSD/1.5 | NetBSD/1.5.* | NetBSD/1.6 | NetBSD/1.6.* | NetBSD/1.6[A-S]) define_xopen_source=no;; # On Solaris 2.6, sys/wait.h is inconsistent in the usage # of union __?sigval. Reported by Stuart Bishop. @@ -890,6 +895,22 @@ fi fi +# Check whether GCC supports PyArg_ParseTuple format +if test "$GCC" = "yes" +then + AC_MSG_CHECKING(whether gcc supports ParseTuple __format__) + save_CFLAGS=$CFLAGS + CFLAGS="$CFLAGS -Werror" + AC_TRY_COMPILE([ + void f(char*,...)__attribute((format(PyArg_ParseTuple, 1, 2))); + ],, + AC_DEFINE(HAVE_ATTRIBUTE_FORMAT_PARSETUPLE, 1, [Define if GCC supports __attribute__((format(PyArg_ParseTuple, 2, 3)))]) + AC_MSG_RESULT(yes), + AC_MSG_RESULT(no) + ) + CFLAGS=$save_CFLAGS +fi + # On some compilers, pthreads are available without further options # (e.g. MacOS X). On some of these systems, the compiler will not # complain if unaccepted options are passed (e.g. gcc on Mac OS X). @@ -1068,8 +1089,8 @@ AC_HEADER_STDC AC_CHECK_HEADERS(asm/types.h conio.h curses.h direct.h dlfcn.h errno.h \ fcntl.h grp.h \ -shadow.h io.h langinfo.h libintl.h ncurses.h poll.h process.h pthread.h \ -signal.h stropts.h termios.h thread.h \ +io.h langinfo.h libintl.h ncurses.h poll.h process.h pthread.h \ +shadow.h signal.h stdint.h stropts.h termios.h thread.h \ unistd.h utime.h \ sys/audioio.h sys/bsdtty.h sys/file.h sys/loadavg.h sys/lock.h sys/mkdev.h \ sys/modem.h \ @@ -1197,16 +1218,12 @@ AC_CHECK_SIZEOF(long long, 8) fi -AC_MSG_CHECKING(for uintptr_t support) -have_uintptr_t=no -AC_TRY_COMPILE([], [uintptr_t x; x = (uintptr_t)0;], [ - AC_DEFINE(HAVE_UINTPTR_T, 1, [Define this if you have the type uintptr_t.]) - have_uintptr_t=yes -]) -AC_MSG_RESULT($have_uintptr_t) -if test "$have_uintptr_t" = yes ; then -AC_CHECK_SIZEOF(uintptr_t, 4) -fi +AC_CHECK_TYPES(uintptr_t, + [AC_CHECK_SIZEOF(uintptr_t, 4)], + [], [#ifdef HAVE_STDINT_H + #include + #endif]) + # Hmph. AC_CHECK_SIZEOF() doesn't include . AC_MSG_CHECKING(size of off_t) @@ -3342,8 +3359,27 @@ AC_MSG_RESULT(no) ) -AC_CHECK_FILE(/dev/ptmx, AC_DEFINE(HAVE_DEV_PTMX, 1, [Define if we have /dev/ptmx.])) -AC_CHECK_FILE(/dev/ptc, AC_DEFINE(HAVE_DEV_PTC, 1, [Define if we have /dev/ptc.])) +AC_MSG_CHECKING(for /dev/ptmx) + +if test -r /dev/ptmx +then + AC_MSG_RESULT(yes) + AC_DEFINE(HAVE_DEV_PTMX, 1, + [Define if we have /dev/ptmx.]) +else + AC_MSG_RESULT(no) +fi + +AC_MSG_CHECKING(for /dev/ptc) + +if test -r /dev/ptc +then + AC_MSG_RESULT(yes) + AC_DEFINE(HAVE_DEV_PTC, 1, + [Define if we have /dev/ptc.]) +else + AC_MSG_RESULT(no) +fi AC_MSG_CHECKING(for %zd printf() format support) AC_TRY_RUN([#include @@ -3352,14 +3388,28 @@ int main() { - char buffer[4]; + char buffer[256]; + +#ifdef HAVE_SSIZE_T +typedef ssize_t Py_ssize_t; +#elif SIZEOF_VOID_P == SIZEOF_LONG +typedef long Py_ssize_t; +#else +typedef int Py_ssize_t; +#endif if(sprintf(buffer, "%zd", (size_t)123) < 0) return 1; - if (strncmp(buffer, "123", 3)) + if (strcmp(buffer, "123")) return 1; - + + if (sprintf(buffer, "%zd", (Py_ssize_t)-123) < 0) + return 1; + + if (strcmp(buffer, "-123")) + return 1; + return 0; }], [AC_MSG_RESULT(yes) Modified: python/branches/p3yk-noslice/pyconfig.h.in ============================================================================== --- python/branches/p3yk-noslice/pyconfig.h.in (original) +++ python/branches/p3yk-noslice/pyconfig.h.in Fri Dec 15 05:21:50 2006 @@ -40,6 +40,9 @@ /* Define to 1 if you have the header file. */ #undef HAVE_ASM_TYPES_H +/* Define if GCC supports __attribute__((format(PyArg_ParseTuple, 2, 3))) */ +#undef HAVE_ATTRIBUTE_FORMAT_PARSETUPLE + /* Define to 1 if you have the `bind_textdomain_codeset' function. */ #undef HAVE_BIND_TEXTDOMAIN_CODESET @@ -677,7 +680,7 @@ /* Define this if you have tcl and TCL_UTF_MAX==6 */ #undef HAVE_UCS4_TCL -/* Define this if you have the type uintptr_t. */ +/* Define to 1 if the system has the type `uintptr_t'. */ #undef HAVE_UINTPTR_T /* Define to 1 if you have the `uname' function. */ Modified: python/branches/p3yk-noslice/setup.py ============================================================================== --- python/branches/p3yk-noslice/setup.py (original) +++ python/branches/p3yk-noslice/setup.py Fri Dec 15 05:21:50 2006 @@ -679,7 +679,8 @@ # save the include directory with the db.h version # (first occurrance only) db_ver_inc_map[db_ver] = d - print "db.h: found", db_ver, "in", d + if db_setup_debug: + print "db.h: found", db_ver, "in", d else: # we already found a header for this library version if db_setup_debug: print "db.h: ignoring", d @@ -719,8 +720,9 @@ if db_setup_debug: print "db lib: ", dblib, "not found" except db_found: - print "db lib: using", db_ver, dblib - if db_setup_debug: print "db: lib dir", dblib_dir, "inc dir", db_incdir + if db_setup_debug: + print "db lib: using", db_ver, dblib + print "db: lib dir", dblib_dir, "inc dir", db_incdir db_incs = [db_incdir] dblibs = [dblib] # We add the runtime_library_dirs argument because the @@ -741,7 +743,7 @@ dblib_dir = None # The sqlite interface - sqlite_setup_debug = True # verbose debug prints from this script? + sqlite_setup_debug = False # verbose debug prints from this script? # We hunt for #define SQLITE_VERSION "n.n.n" # We need to find >= sqlite version 3.0.8 @@ -773,7 +775,8 @@ for x in sqlite_version.split(".")]) if sqlite_version_tuple >= MIN_SQLITE_VERSION_NUMBER: # we win! - print "%s/sqlite3.h: version %s"%(d, sqlite_version) + if sqlite_setup_debug: + print "%s/sqlite3.h: version %s"%(d, sqlite_version) sqlite_incdir = d break else: From python-checkins at python.org Fri Dec 15 05:37:14 2006 From: python-checkins at python.org (thomas.wouters) Date: Fri, 15 Dec 2006 05:37:14 +0100 (CET) Subject: [Python-checkins] r53041 - in python/branches/p3yk-noslice: Modules/mmapmodule.c Objects/bufferobject.c Objects/bytesobject.c Objects/stringobject.c Objects/typeobject.c Objects/unicodeobject.c Objects/weakrefobject.c Python/Python-ast.c Message-ID: <20061215043714.D537F1E4007@bag.python.org> Author: thomas.wouters Date: Fri Dec 15 05:37:10 2006 New Revision: 53041 Modified: python/branches/p3yk-noslice/Modules/mmapmodule.c python/branches/p3yk-noslice/Objects/bufferobject.c python/branches/p3yk-noslice/Objects/bytesobject.c python/branches/p3yk-noslice/Objects/stringobject.c python/branches/p3yk-noslice/Objects/typeobject.c python/branches/p3yk-noslice/Objects/unicodeobject.c python/branches/p3yk-noslice/Objects/weakrefobject.c python/branches/p3yk-noslice/Python/Python-ast.c Log: Throw away now-unused functions (and the warnings about same.) Modified: python/branches/p3yk-noslice/Modules/mmapmodule.c ============================================================================== --- python/branches/p3yk-noslice/Modules/mmapmodule.c (original) +++ python/branches/p3yk-noslice/Modules/mmapmodule.c Fri Dec 15 05:37:10 2006 @@ -663,24 +663,6 @@ } static PyObject * -mmap_slice(mmap_object *self, Py_ssize_t ilow, Py_ssize_t ihigh) -{ - CHECK_VALID(NULL); - if (ilow < 0) - ilow = 0; - else if ((size_t)ilow > self->size) - ilow = self->size; - if (ihigh < 0) - ihigh = 0; - if (ihigh < ilow) - ihigh = ilow; - else if ((size_t)ihigh > self->size) - ihigh = self->size; - - return PyString_FromStringAndSize(self->data + ilow, ihigh-ilow); -} - -static PyObject * mmap_subscript(mmap_object *self, PyObject *item) { CHECK_VALID(NULL); @@ -753,45 +735,6 @@ } static int -mmap_ass_slice(mmap_object *self, Py_ssize_t ilow, Py_ssize_t ihigh, PyObject *v) -{ - const char *buf; - - CHECK_VALID(-1); - if (ilow < 0) - ilow = 0; - else if ((size_t)ilow > self->size) - ilow = self->size; - if (ihigh < 0) - ihigh = 0; - if (ihigh < ilow) - ihigh = ilow; - else if ((size_t)ihigh > self->size) - ihigh = self->size; - - if (v == NULL) { - PyErr_SetString(PyExc_TypeError, - "mmap object doesn't support slice deletion"); - return -1; - } - if (! (PyString_Check(v)) ) { - PyErr_SetString(PyExc_IndexError, - "mmap slice assignment must be a string"); - return -1; - } - if (PyString_Size(v) != (ihigh - ilow)) { - PyErr_SetString(PyExc_IndexError, - "mmap slice assignment is wrong size"); - return -1; - } - if (!is_writeable(self)) - return -1; - buf = PyString_AsString(v); - memcpy(self->data + ilow, buf, ihigh-ilow); - return 0; -} - -static int mmap_ass_item(mmap_object *self, Py_ssize_t i, PyObject *v) { const char *buf; Modified: python/branches/p3yk-noslice/Objects/bufferobject.c ============================================================================== --- python/branches/p3yk-noslice/Objects/bufferobject.c (original) +++ python/branches/p3yk-noslice/Objects/bufferobject.c Fri Dec 15 05:37:10 2006 @@ -490,25 +490,6 @@ } static PyObject * -buffer_slice(PyBufferObject *self, Py_ssize_t left, Py_ssize_t right) -{ - void *ptr; - Py_ssize_t size; - if (!get_buf(self, &ptr, &size, ANY_BUFFER)) - return NULL; - if ( left < 0 ) - left = 0; - if ( right < 0 ) - right = 0; - if ( right > size ) - right = size; - if ( right < left ) - right = left; - return PyString_FromStringAndSize((char *)ptr + left, - right - left); -} - -static PyObject * buffer_subscript(PyBufferObject *self, PyObject *item) { void *p; @@ -616,64 +597,6 @@ } static int -buffer_ass_slice(PyBufferObject *self, Py_ssize_t left, Py_ssize_t right, PyObject *other) -{ - PyBufferProcs *pb; - void *ptr1, *ptr2; - Py_ssize_t size; - Py_ssize_t slice_len; - Py_ssize_t count; - - if ( self->b_readonly ) { - PyErr_SetString(PyExc_TypeError, - "buffer is read-only"); - return -1; - } - - pb = other ? other->ob_type->tp_as_buffer : NULL; - if ( pb == NULL || - pb->bf_getreadbuffer == NULL || - pb->bf_getsegcount == NULL ) - { - PyErr_BadArgument(); - return -1; - } - if ( (*pb->bf_getsegcount)(other, NULL) != 1 ) - { - /* ### use a different exception type/message? */ - PyErr_SetString(PyExc_TypeError, - "single-segment buffer object expected"); - return -1; - } - if (!get_buf(self, &ptr1, &size, ANY_BUFFER)) - return -1; - if ( (count = (*pb->bf_getreadbuffer)(other, 0, &ptr2)) < 0 ) - return -1; - - if ( left < 0 ) - left = 0; - else if ( left > size ) - left = size; - if ( right < left ) - right = left; - else if ( right > size ) - right = size; - slice_len = right - left; - - if ( count != slice_len ) { - PyErr_SetString( - PyExc_TypeError, - "right operand length must match slice length"); - return -1; - } - - if ( slice_len ) - memcpy((char *)ptr1 + left, ptr2, slice_len); - - return 0; -} - -static int buffer_ass_subscript(PyBufferObject *self, PyObject *item, PyObject *value) { PyBufferProcs *pb; Modified: python/branches/p3yk-noslice/Objects/bytesobject.c ============================================================================== --- python/branches/p3yk-noslice/Objects/bytesobject.c (original) +++ python/branches/p3yk-noslice/Objects/bytesobject.c Fri Dec 15 05:37:10 2006 @@ -269,18 +269,6 @@ } static PyObject * -bytes_getslice(PyBytesObject *self, Py_ssize_t lo, Py_ssize_t hi) -{ - if (lo < 0) - lo = 0; - if (hi > self->ob_size) - hi = self->ob_size; - if (lo >= hi) - lo = hi = 0; - return PyBytes_FromStringAndSize(self->ob_bytes + lo, hi - lo); -} - -static PyObject * bytes_subscript(PyBytesObject *self, PyObject *item) { if (PyIndex_Check(item)) { Modified: python/branches/p3yk-noslice/Objects/stringobject.c ============================================================================== --- python/branches/p3yk-noslice/Objects/stringobject.c (original) +++ python/branches/p3yk-noslice/Objects/stringobject.c Fri Dec 15 05:37:10 2006 @@ -1039,29 +1039,6 @@ return (PyObject *) op; } -/* String slice a[i:j] consists of characters a[i] ... a[j-1] */ - -static PyObject * -string_slice(register PyStringObject *a, register Py_ssize_t i, - register Py_ssize_t j) - /* j -- may be negative! */ -{ - if (i < 0) - i = 0; - if (j < 0) - j = 0; /* Avoid signed/unsigned bug in next line */ - if (j > a->ob_size) - j = a->ob_size; - if (i == 0 && j == a->ob_size && PyString_CheckExact(a)) { - /* It's the same as a */ - Py_INCREF(a); - return (PyObject *)a; - } - if (j < i) - j = i; - return PyString_FromStringAndSize(a->ob_sval + i, j-i); -} - static int string_contains(PyObject *str_obj, PyObject *sub_obj) { Modified: python/branches/p3yk-noslice/Objects/typeobject.c ============================================================================== --- python/branches/p3yk-noslice/Objects/typeobject.c (original) +++ python/branches/p3yk-noslice/Objects/typeobject.c Fri Dec 15 05:37:10 2006 @@ -3471,17 +3471,6 @@ } static PyObject * -wrap_ssizessizeargfunc(PyObject *self, PyObject *args, void *wrapped) -{ - ssizessizeargfunc func = (ssizessizeargfunc)wrapped; - Py_ssize_t i, j; - - if (!PyArg_ParseTuple(args, "nn", &i, &j)) - return NULL; - return (*func)(self, i, j); -} - -static PyObject * wrap_sq_setitem(PyObject *self, PyObject *args, void *wrapped) { ssizeobjargproc func = (ssizeobjargproc)wrapped; @@ -3522,23 +3511,6 @@ return Py_None; } -static PyObject * -wrap_ssizessizeobjargproc(PyObject *self, PyObject *args, void *wrapped) -{ - ssizessizeobjargproc func = (ssizessizeobjargproc)wrapped; - Py_ssize_t i, j; - int res; - PyObject *value; - - if (!PyArg_ParseTuple(args, "nnO", &i, &j, &value)) - return NULL; - res = (*func)(self, i, j, value); - if (res == -1 && PyErr_Occurred()) - return NULL; - Py_INCREF(Py_None); - return Py_None; -} - /* XXX objobjproc is a misnomer; should be objargpred */ static PyObject * wrap_objobjproc(PyObject *self, PyObject *args, void *wrapped) Modified: python/branches/p3yk-noslice/Objects/unicodeobject.c ============================================================================== --- python/branches/p3yk-noslice/Objects/unicodeobject.c (original) +++ python/branches/p3yk-noslice/Objects/unicodeobject.c Fri Dec 15 05:37:10 2006 @@ -6574,28 +6574,6 @@ return (PyObject*) pad(self, width - self->length, 0, fillchar); } -static PyObject* -unicode_slice(PyUnicodeObject *self, Py_ssize_t start, Py_ssize_t end) -{ - /* standard clamping */ - if (start < 0) - start = 0; - if (end < 0) - end = 0; - if (end > self->length) - end = self->length; - if (start == 0 && end == self->length && PyUnicode_CheckExact(self)) { - /* full slice, return original string */ - Py_INCREF(self); - return (PyObject*) self; - } - if (start > end) - start = end; - /* copy slice */ - return (PyObject*) PyUnicode_FromUnicode(self->str + start, - end - start); -} - PyObject *PyUnicode_Split(PyObject *s, PyObject *sep, Py_ssize_t maxsplit) Modified: python/branches/p3yk-noslice/Objects/weakrefobject.c ============================================================================== --- python/branches/p3yk-noslice/Objects/weakrefobject.c (original) +++ python/branches/p3yk-noslice/Objects/weakrefobject.c Fri Dec 15 05:37:10 2006 @@ -518,14 +518,6 @@ /* sequence slots */ -static PyObject * -proxy_slice(PyWeakReference *proxy, Py_ssize_t i, Py_ssize_t j) -{ - if (!proxy_checkref(proxy)) - return NULL; - return PySequence_GetSlice(PyWeakref_GET_OBJECT(proxy), i, j); -} - static int proxy_contains(PyWeakReference *proxy, PyObject *value) { Modified: python/branches/p3yk-noslice/Python/Python-ast.c ============================================================================== --- python/branches/p3yk-noslice/Python/Python-ast.c (original) +++ python/branches/p3yk-noslice/Python/Python-ast.c Fri Dec 15 05:37:10 2006 @@ -3008,7 +3008,7 @@ if (PyDict_SetItemString(d, "AST", (PyObject*)AST_type) < 0) return; if (PyModule_AddIntConstant(m, "PyCF_ONLY_AST", PyCF_ONLY_AST) < 0) return; - if (PyModule_AddStringConstant(m, "__version__", "45597") < 0) + if (PyModule_AddStringConstant(m, "__version__", "53040") < 0) return; if (PyDict_SetItemString(d, "mod", (PyObject*)mod_type) < 0) return; if (PyDict_SetItemString(d, "Module", (PyObject*)Module_type) < 0) From python-checkins at python.org Fri Dec 15 06:13:16 2006 From: python-checkins at python.org (kurt.kaiser) Date: Fri, 15 Dec 2006 06:13:16 +0100 (CET) Subject: [Python-checkins] r53042 - python/trunk/Lib/idlelib/AutoCompleteWindow.py python/trunk/Lib/idlelib/NEWS.txt Message-ID: <20061215051316.AF6011E4006@bag.python.org> Author: kurt.kaiser Date: Fri Dec 15 06:13:11 2006 New Revision: 53042 Modified: python/trunk/Lib/idlelib/AutoCompleteWindow.py python/trunk/Lib/idlelib/NEWS.txt Log: 1. Avoid hang when encountering a duplicate in a completion list. Bug 1571112. 2. Duplicate some old entries from Python's NEWS to IDLE's NEWS.txt M AutoCompleteWindow.py M NEWS.txt Modified: python/trunk/Lib/idlelib/AutoCompleteWindow.py ============================================================================== --- python/trunk/Lib/idlelib/AutoCompleteWindow.py (original) +++ python/trunk/Lib/idlelib/AutoCompleteWindow.py Fri Dec 15 06:13:11 2006 @@ -118,8 +118,11 @@ i = 0 while i < len(lts) and i < len(selstart) and lts[i] == selstart[i]: i += 1 - while cursel > 0 and selstart[:i] <= self.completions[cursel-1]: + previous_completion = self.completions[cursel - 1] + while cursel > 0 and selstart[:i] <= previous_completion: i += 1 + if selstart == previous_completion: + break # maybe we have a duplicate? newstart = selstart[:i] self._change_start(newstart) Modified: python/trunk/Lib/idlelib/NEWS.txt ============================================================================== --- python/trunk/Lib/idlelib/NEWS.txt (original) +++ python/trunk/Lib/idlelib/NEWS.txt Fri Dec 15 06:13:11 2006 @@ -3,9 +3,14 @@ *Release date: XX-XXX-200X* +- Avoid hang when encountering a duplicate in a completion list. Bug 1571112. + - Patch #1362975: Rework CodeContext indentation algorithm to avoid hard-coding pixel widths. +- Bug #813342: Start the IDLE subprocess with -Qnew if the parent + is started with that option. + - Some syntax errors were being caught by tokenize during the tabnanny check, resulting in obscure error messages. Do the syntax check first. Bug 1562716, 1562719 @@ -14,6 +19,12 @@ the Python release of which it's a part. +What's New in IDLE 1.2? +======================= + +*Release date: 19-SEP-2006* + + What's New in IDLE 1.2c1? ========================= @@ -44,6 +55,13 @@ *Release date: 03-AUG-2006* +- Bug #1525817: Don't truncate short lines in IDLE's tool tips. + +- Bug #1517990: IDLE keybindings on MacOS X now work correctly + +- Bug #1517996: IDLE now longer shows the default Tk menu when a + path browser, class browser or debugger is the frontmost window on MacOS X + - EditorWindow.test() was failing. Bug 1417598 - EditorWindow failed when used stand-alone if sys.ps1 not set. @@ -80,6 +98,8 @@ *Release date: 05-APR-2006* +- Patch #1162825: Support non-ASCII characters in IDLE window titles. + - Source file f.flush() after writing; trying to avoid lossage if user kills GUI. From python-checkins at python.org Fri Dec 15 19:27:05 2006 From: python-checkins at python.org (guido.van.rossum) Date: Fri, 15 Dec 2006 19:27:05 +0100 (CET) Subject: [Python-checkins] r53043 - in sandbox/trunk/2to3: example.py fixes/fix_has_key.py Message-ID: <20061215182705.7AD791E4006@bag.python.org> Author: guido.van.rossum Date: Fri Dec 15 19:27:05 2006 New Revision: 53043 Modified: sandbox/trunk/2to3/example.py sandbox/trunk/2to3/fixes/fix_has_key.py Log: Do a better job of transforming 'not x.has_key(y)' into 'y not in x'. Modified: sandbox/trunk/2to3/example.py ============================================================================== --- sandbox/trunk/2to3/example.py (original) +++ sandbox/trunk/2to3/example.py Fri Dec 15 19:27:05 2006 @@ -20,6 +20,12 @@ x = a.has_key(lambda: 12) # x = a.has_key(a for a in b) + # + if not a.has_key(b): pass + # + if not a.has_key(b).__repr__(): pass + # + if not a.has_key(b) ** 2: pass def foo(): pass # body indented by tab Modified: sandbox/trunk/2to3/fixes/fix_has_key.py ============================================================================== --- sandbox/trunk/2to3/fixes/fix_has_key.py (original) +++ sandbox/trunk/2to3/fixes/fix_has_key.py Fri Dec 15 19:27:05 2006 @@ -15,7 +15,7 @@ pat_compile = patcomp.PatternCompiler().compile_pattern PATTERN = """ -power< +anchor=power< before=any+ trailer< '.' 'has_key' > trailer< @@ -27,6 +27,21 @@ > after=any* > +| +negation=not_test< + 'not' + anchor=power< + before=any+ + trailer< '.' 'has_key' > + trailer< + '(' + ( not(arglist | argument) arg=any ','> + ) + ')' + > + > +> """ @@ -43,10 +58,17 @@ def transform(self, node): results = self.match(node) assert results + if (node.parent.type == syms.not_test and + self.pattern.match(node.parent)): + # Don't transform a node matching the first alternative of the + # pattern when its parent matches the second alternative + return None + negation = results.get("negation") + anchor = results["anchor"] prefix = node.get_prefix() before = [n.clone() for n in results["before"]] arg = results["arg"].clone() - after = results["after"] + after = results.get("after") if after: after = [n.clone() for n in after] if arg.type in (syms.comparison, syms.not_test, syms.and_test, @@ -57,15 +79,20 @@ else: before = pytree.Node(syms.power, before) before.set_prefix(" ") - n_in = pytree.Leaf(token.NAME, "in") - n_in.set_prefix(" ") - new = pytree.Node(syms.comparison, (arg, n_in, before)) + n_op = pytree.Leaf(token.NAME, "in") + n_op.set_prefix(" ") + if negation: + n_not = pytree.Leaf(token.NAME, "not") + n_not.set_prefix(" ") + n_op = pytree.Node(syms.comp_op, (n_not, n_op)) + new = pytree.Node(syms.comparison, (arg, n_op, before)) if after: new = pygram.parenthesize(new) new = pytree.Node(syms.power, (new,) + tuple(after)) if node.parent.type in (syms.comparison, syms.expr, syms.xor_expr, - syms.and_expr, syms.shift_expr, syms.arith_expr, - syms.term, syms.factor, syms.power): + syms.and_expr, syms.shift_expr, + syms.arith_expr, syms.term, + syms.factor, syms.power): new = pygram.parenthesize(new) new.set_prefix(prefix) return new From python-checkins at python.org Sat Dec 16 10:01:35 2006 From: python-checkins at python.org (thomas.wouters) Date: Sat, 16 Dec 2006 10:01:35 +0100 (CET) Subject: [Python-checkins] r53044 - in python/branches/p3yk-noslice: Lib/UserString.py Lib/test/string_tests.py Lib/test/test_array.py Lib/test/test_buffer.py Lib/test/test_bytes.py Lib/test/test_mmap.py Lib/test/test_structseq.py Lib/test/test_userstring.py TODO Message-ID: <20061216090135.A1E311E4009@bag.python.org> Author: thomas.wouters Date: Sat Dec 16 10:01:33 2006 New Revision: 53044 Modified: python/branches/p3yk-noslice/Lib/UserString.py python/branches/p3yk-noslice/Lib/test/string_tests.py python/branches/p3yk-noslice/Lib/test/test_array.py python/branches/p3yk-noslice/Lib/test/test_buffer.py python/branches/p3yk-noslice/Lib/test/test_bytes.py python/branches/p3yk-noslice/Lib/test/test_mmap.py python/branches/p3yk-noslice/Lib/test/test_structseq.py python/branches/p3yk-noslice/Lib/test/test_userstring.py python/branches/p3yk-noslice/TODO Log: - Add/expand tests for extended slicing in stringtypes, array, buffer, structseq, mmap - Clean up test for extended slicing of bytes - Fix bug in slice assignment/deletion of UserString.MutableString - Add support for step=-1 to UserString.MutableString slicing - Update TODO Modified: python/branches/p3yk-noslice/Lib/UserString.py ============================================================================== --- python/branches/p3yk-noslice/Lib/UserString.py (original) +++ python/branches/p3yk-noslice/Lib/UserString.py Sat Dec 16 10:01:33 2006 @@ -178,8 +178,14 @@ elif not isinstance(sub, basestring): sub = str(sub) start, stop, step = index.indices(len(self.data)) - if step != 1: + if step == -1: + start, stop = stop+1, start+1 + sub = sub[::-1] + elif step != 1: + # XXX(twouters): I guess we should be reimplementing + # the extended slice assignment/deletion algorithm here... raise TypeError, "invalid step in slicing assignment" + start = min(start, stop) self.data = self.data[:start] + sub + self.data[stop:] else: if index < 0: @@ -189,8 +195,12 @@ def __delitem__(self, index): if isinstance(index, slice): start, stop, step = index.indices(len(self.data)) - if step != 1: - raise TypeError, "invalid step in slicing assignment" + if step == -1: + start, stop = stop+1, start+1 + elif step != 1: + # XXX(twouters): see same block in __setitem__ + raise TypeError, "invalid step in slicing deletion" + start = min(start, stop) self.data = self.data[:start] + self.data[stop:] else: if index < 0: Modified: python/branches/p3yk-noslice/Lib/test/string_tests.py ============================================================================== --- python/branches/p3yk-noslice/Lib/test/string_tests.py (original) +++ python/branches/p3yk-noslice/Lib/test/string_tests.py Sat Dec 16 10:01:33 2006 @@ -907,10 +907,21 @@ self.checkequal(u'abc', 'abc', '__getitem__', slice(0, 1000)) self.checkequal(u'a', 'abc', '__getitem__', slice(0, 1)) self.checkequal(u'', 'abc', '__getitem__', slice(0, 0)) - # FIXME What about negative indices? This is handled differently by [] and __getitem__(slice) self.checkraises(TypeError, 'abc', '__getitem__', 'def') + def test_extended_getslice(self): + # Test extended slicing by comparing with list slicing. + s = string.ascii_letters + string.digits + indices = (0, None, 1, 3, 41, -1, -2, -37) + for start in indices: + for stop in indices: + # Skip step 0 (invalid) + for step in indices[1:]: + L = list(s)[start:stop:step] + self.checkequal(u"".join(L), s, '__getitem__', + slice(start, stop, step)) + def test_mul(self): self.checkequal('', 'abc', '__mul__', -1) self.checkequal('', 'abc', '__mul__', 0) Modified: python/branches/p3yk-noslice/Lib/test/test_array.py ============================================================================== --- python/branches/p3yk-noslice/Lib/test/test_array.py (original) +++ python/branches/p3yk-noslice/Lib/test/test_array.py Sat Dec 16 10:01:33 2006 @@ -455,6 +455,18 @@ array.array(self.typecode) ) + def test_extended_getslice(self): + # Test extended slicing by comparing with list slicing + # (Assumes list conversion works correctly, too) + a = array.array(self.typecode, self.example) + indices = (0, None, 1, 3, 19, 100, -1, -2, -31, -100) + for start in indices: + for stop in indices: + # Everything except the initial 0 (invalid step) + for step in indices[1:]: + self.assertEqual(list(a[start:stop:step]), + list(a)[start:stop:step]) + def test_setslice(self): a = array.array(self.typecode, self.example) a[:1] = a @@ -544,6 +556,26 @@ self.assertRaises(TypeError, a.__setitem__, slice(0, 0), b) self.assertRaises(TypeError, a.__setitem__, slice(0, 1), b) + def test_extended_set_del_slice(self): + indices = (0, None, 1, 3, 19, 100, -1, -2, -31, -100) + for start in indices: + for stop in indices: + # Everything except the initial 0 (invalid step) + for step in indices[1:]: + a = array.array(self.typecode, self.example) + L = list(a) + # Make sure we have a slice of exactly the right length, + # but with (hopefully) different data. + data = L[start:stop:step] + data.reverse() + L[start:stop:step] = data + a[start:stop:step] = array.array(self.typecode, data) + self.assertEquals(a, array.array(self.typecode, L)) + + del L[start:stop:step] + del a[start:stop:step] + self.assertEquals(a, array.array(self.typecode, L)) + def test_index(self): example = 2*self.example a = array.array(self.typecode, example) Modified: python/branches/p3yk-noslice/Lib/test/test_buffer.py ============================================================================== --- python/branches/p3yk-noslice/Lib/test/test_buffer.py (original) +++ python/branches/p3yk-noslice/Lib/test/test_buffer.py Sat Dec 16 10:01:33 2006 @@ -37,6 +37,20 @@ self.failIf(a == b) self.assertRaises(TypeError, lambda: a < b) + def test_extended_getslice(self): + # Test extended slicing by comparing with list slicing. + s = "".join(chr(c) for c in list(range(255, -1, -1))) + b = bytes(s) + indices = (0, None, 1, 3, 19, 300, -1, -2, -31, -300) + for start in indices: + for stop in indices: + # Skip step 0 (invalid) + for step in indices[1:]: + self.assertEqual(b[start:stop:step], + buffer(s[start:stop:step])) + + + def test_main(): test_support.run_unittest(BufferTests) Modified: python/branches/p3yk-noslice/Lib/test/test_bytes.py ============================================================================== --- python/branches/p3yk-noslice/Lib/test/test_bytes.py (original) +++ python/branches/p3yk-noslice/Lib/test/test_bytes.py Sat Dec 16 10:01:33 2006 @@ -164,14 +164,15 @@ self.assertEqual(b[-100:5], by("Hello")) def test_extended_getslice(self): - L = range(20) + # Test extended slicing by comparing with list slicing. + L = list(range(255)) b = bytes(L) - indices = (None, 1, 5, 11, 19, 100, -1, -2, -5, -11, -19, -100) + indices = (0, None, 1, 3, 19, 100, -1, -2, -31, -100) for start in indices: for stop in indices: - for step in indices: - idx = slice(start, stop, step) - self.assertEqual(b[idx], bytes(L[idx])) + # Skip step 0 (invalid) + for step in indices[1:]: + self.assertEqual(b[start:stop:step], bytes(L[start:stop:step])) def test_regexps(self): def by(s): @@ -250,32 +251,23 @@ self.assertEqual(b, bytes([0, 1, 2, 42, 42, 42, 3, 4, 5, 6, 7, 8, 9])) def test_extended_set_del_slice(self): - indices = (None, 1, 5, 11, 19, 100, -1, -2, -5, -11, -19, -100) + indices = (0, None, 1, 3, 19, 300, -1, -2, -31, -300) for start in indices: - for step in indices: - for stop in indices: - L = list(range(20)) + for stop in indices: + # Skip invalid step 0 + for step in indices[1:]: + L = list(range(255)) b = bytes(L) - - idx = slice(start, stop, step) - start, stop, step = idx.indices(len(L)) - # This is taken from Pyslice_GetIndicesEx(), - # and should probably be exposed to Python - if ((step < 0 and start <= stop) or - (step > 0 and start >= stop)): - slicelen = 0 - elif step < 0: - slicelen = (stop - start + 1) // step + 1 - else: - slicelen = (stop - start - 1) // step + 1 - - data = list(range(100, 100 + slicelen)) - L[idx] = data - b[idx] = data + # Make sure we have a slice of exactly the right length, + # but with different data. + data = L[start:stop:step] + data.reverse() + L[start:stop:step] = data + b[start:stop:step] = data self.assertEquals(b, bytes(L)) - del L[idx] - del b[idx] + del L[start:stop:step] + del b[start:stop:step] self.assertEquals(b, bytes(L)) def test_setslice_trap(self): Modified: python/branches/p3yk-noslice/Lib/test/test_mmap.py ============================================================================== --- python/branches/p3yk-noslice/Lib/test/test_mmap.py (original) +++ python/branches/p3yk-noslice/Lib/test/test_mmap.py Sat Dec 16 10:01:33 2006 @@ -306,6 +306,40 @@ m[x] = ch = chr(x & 255) self.assertEqual(m[x], ch) + def test_extended_getslice(self): + # Test extended slicing by comparing with list slicing. + s = "".join(chr(c) for c in list(range(255, -1, -1))) + m = mmap.mmap(-1, len(s)) + m[:] = s + self.assertEqual(m[:], s) + indices = (0, None, 1, 3, 19, 300, -1, -2, -31, -300) + for start in indices: + for stop in indices: + # Skip step 0 (invalid) + for step in indices[1:]: + self.assertEqual(m[start:stop:step], + s[start:stop:step]) + + def test_extended_set_del_slice(self): + # Test extended slicing by comparing with list slicing. + s = "".join(chr(c) for c in list(range(255, -1, -1))) + m = mmap.mmap(-1, len(s)) + indices = (0, None, 1, 3, 19, 300, -1, -2, -31, -300) + for start in indices: + for stop in indices: + # Skip invalid step 0 + for step in indices[1:]: + m[:] = s + self.assertEqual(m[:], s) + L = list(s) + # Make sure we have a slice of exactly the right length, + # but with different data. + data = L[start:stop:step] + data = "".join(reversed(data)) + L[start:stop:step] = data + m[start:stop:step] = data + self.assertEquals(m[:], "".join(L)) + def test_main(): run_unittest(MmapTests) Modified: python/branches/p3yk-noslice/Lib/test/test_structseq.py ============================================================================== --- python/branches/p3yk-noslice/Lib/test/test_structseq.py (original) +++ python/branches/p3yk-noslice/Lib/test/test_structseq.py Sat Dec 16 10:01:33 2006 @@ -97,6 +97,18 @@ t = time.gmtime() x = t.__reduce__() + def test_extended_getslice(self): + # Test extended slicing by comparing with list slicing. + t = time.gmtime() + L = list(t) + indices = (0, None, 1, 3, 19, 300, -1, -2, -31, -300) + for start in indices: + for stop in indices: + # Skip step 0 (invalid) + for step in indices[1:]: + self.assertEqual(list(t[start:stop:step]), + L[start:stop:step]) + def test_main(): test_support.run_unittest(StructSeqTest) Modified: python/branches/p3yk-noslice/Lib/test/test_userstring.py ============================================================================== --- python/branches/p3yk-noslice/Lib/test/test_userstring.py (original) +++ python/branches/p3yk-noslice/Lib/test/test_userstring.py Sat Dec 16 10:01:33 2006 @@ -3,6 +3,7 @@ # UserString instances should behave similar to builtin string objects. import unittest +import string from test import test_support, string_tests from UserString import UserString, MutableString @@ -88,6 +89,28 @@ del s[-1:10] self.assertEqual(s, "fo") + def test_extended_set_del_slice(self): + indices = (0, None, 1, 3, 19, 100, -1, -2, -31, -100) + orig = string.ascii_letters + string.digits + for start in indices: + for stop in indices: + # Use indices[1:] when MutableString can handle real + # extended slices + for step in (None, 1, -1): + s = self.type2test(orig) + L = list(orig) + # Make sure we have a slice of exactly the right length, + # but with (hopefully) different data. + data = L[start:stop:step] + data.reverse() + L[start:stop:step] = data + s[start:stop:step] = "".join(data) + self.assertEquals(s, "".join(L)) + + del L[start:stop:step] + del s[start:stop:step] + self.assertEquals(s, "".join(L)) + def test_immutable(self): s = self.type2test("foobar") s2 = s.immutable() Modified: python/branches/p3yk-noslice/TODO ============================================================================== --- python/branches/p3yk-noslice/TODO (original) +++ python/branches/p3yk-noslice/TODO Sat Dec 16 10:01:33 2006 @@ -2,15 +2,14 @@ TODO in slice removal: - Clean up compilerpackage's code now that SLICE opcodes are gone - - Add tests for the extended slicing abilities of: - buffer - mmap.mmap - structseq - - Add actual *extended* slicing to ctypes objects + - Add non-step-1 slicing to ctypes objects + - Add non-step-1 slice assignment to UserString.MutableString - Make list's mp_[ass_]subscr not depend on list_[ass]slice - Remove slice API (or emulate it ontop of sliceobject API) - Further remove slice/ass_slice PySequenceMethod hooks - Figure out what to do with PyMapping_Check (it uses the presence of the classic slicing hook to tell sequences-with-extended-slicing from mappings.) - + - Refactor slice handling logic from all the sequency types into a single + location? Might need some funky macros to make work... + - Submit type enhancements to trunk, rest to p3yk From onlinecustomer at halifax.co.uk Sat Dec 16 01:25:45 2006 From: onlinecustomer at halifax.co.uk (Halifax Internet Banking) Date: Sat, 16 Dec 2006 01:25:45 +0100 Subject: [Python-checkins] Account Update Message-ID: An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-checkins/attachments/20061216/4ef99ed1/attachment.html From python-checkins at python.org Sat Dec 16 10:34:56 2006 From: python-checkins at python.org (thomas.wouters) Date: Sat, 16 Dec 2006 10:34:56 +0100 (CET) Subject: [Python-checkins] r53045 - python/branches/p3yk-noslice/Lib/test/test_mmap.py Message-ID: <20061216093456.21F951E4008@bag.python.org> Author: thomas.wouters Date: Sat Dec 16 10:34:55 2006 New Revision: 53045 Modified: python/branches/p3yk-noslice/Lib/test/test_mmap.py Log: Clean up test code a bit. Modified: python/branches/p3yk-noslice/Lib/test/test_mmap.py ============================================================================== --- python/branches/p3yk-noslice/Lib/test/test_mmap.py (original) +++ python/branches/p3yk-noslice/Lib/test/test_mmap.py Sat Dec 16 10:34:55 2006 @@ -308,7 +308,7 @@ def test_extended_getslice(self): # Test extended slicing by comparing with list slicing. - s = "".join(chr(c) for c in list(range(255, -1, -1))) + s = "".join(chr(c) for c in reversed(range(256))) m = mmap.mmap(-1, len(s)) m[:] = s self.assertEqual(m[:], s) @@ -322,7 +322,7 @@ def test_extended_set_del_slice(self): # Test extended slicing by comparing with list slicing. - s = "".join(chr(c) for c in list(range(255, -1, -1))) + s = "".join(chr(c) for c in reversed(range(256))) m = mmap.mmap(-1, len(s)) indices = (0, None, 1, 3, 19, 300, -1, -2, -31, -300) for start in indices: From python-checkins at python.org Sun Dec 17 05:41:28 2006 From: python-checkins at python.org (guido.van.rossum) Date: Sun, 17 Dec 2006 05:41:28 +0100 (CET) Subject: [Python-checkins] r53046 - in sandbox/trunk/2to3: example.py fixes/fix_exec.py Message-ID: <20061217044128.7DEB71E4004@bag.python.org> Author: guido.van.rossum Date: Sun Dec 17 05:41:28 2006 New Revision: 53046 Added: sandbox/trunk/2to3/fixes/fix_exec.py (contents, props changed) Modified: sandbox/trunk/2to3/example.py Log: Add a fixer for 'exec'. Modified: sandbox/trunk/2to3/example.py ============================================================================== --- sandbox/trunk/2to3/example.py (original) +++ sandbox/trunk/2to3/example.py Sun Dec 17 05:41:28 2006 @@ -93,4 +93,26 @@ # print >> sys.stderr # spaces before sys.stderr +def exec_examples(): + # + exec code + # + exec code in ns + # + exec code in ns1, ns2 + # + exec (a.b()) in ns + # + exec a.b() + c in ns + # + # These should not be touched: + # + exec(code) + # + exec (code) + # + exec(code, ns) + # + exec(code, ns1, ns2) + # This is the last line. Added: sandbox/trunk/2to3/fixes/fix_exec.py ============================================================================== --- (empty file) +++ sandbox/trunk/2to3/fixes/fix_exec.py Sun Dec 17 05:41:28 2006 @@ -0,0 +1,54 @@ +# Copyright 2006 Google, Inc. All Rights Reserved. +# Licensed to PSF under a Contributor Agreement. + +"""Fixer for exec.""" + +# Python imports +import token + +# Local imports +import pytree +import patcomp +import pygram + +syms = pygram.python_symbols +pat_compile = patcomp.PatternCompiler().compile_pattern + +PATTERN = """ +exec_stmt< 'exec' a=any 'in' b=any [',' c=any] > +| +exec_stmt< 'exec' (not atom<'(' [any] ')'>) a=any > +""" + + +class FixExec(object): + + def __init__(self, options): + self.options = options + self.pattern = pat_compile(PATTERN) + + def match(self, node): + results = {} + return self.pattern.match(node, results) and results + + def transform(self, node): + results = self.match(node) + assert results + a = results["a"] + b = results.get("b") + c = results.get("c") + args = [a.clone()] + args[0].set_prefix("") + if b is not None: + args.extend([pytree.Leaf(token.COMMA, ","), b.clone()]) + if c is not None: + args.extend([pytree.Leaf(token.COMMA, ","), c.clone()]) + new = pytree.Node(syms.factor, + [pytree.Leaf(token.NAME, "exec"), + pytree.Node(syms.trailer, + [pytree.Leaf(token.LPAR, "("), + pytree.Node(syms.arglist, args), + pytree.Leaf(token.RPAR, ")")])]) + new.set_prefix(node.get_prefix()) + return new + From python-checkins at python.org Sun Dec 17 05:46:33 2006 From: python-checkins at python.org (guido.van.rossum) Date: Sun, 17 Dec 2006 05:46:33 +0100 (CET) Subject: [Python-checkins] r53047 - sandbox/trunk/2to3/refactor.py Message-ID: <20061217044633.6DB041E4004@bag.python.org> Author: guido.van.rossum Date: Sun Dec 17 05:46:33 2006 New Revision: 53047 Modified: sandbox/trunk/2to3/refactor.py Log: Sort directory listings, for more reproducible results. Modified: sandbox/trunk/2to3/refactor.py ============================================================================== --- sandbox/trunk/2to3/refactor.py (original) +++ sandbox/trunk/2to3/refactor.py Sun Dec 17 05:46:33 2006 @@ -72,7 +72,9 @@ def get_all_fix_names(): """Return a sorted list of all available fix names.""" fix_names = [] - for name in os.listdir(os.path.dirname(fixes.__file__)): + names = os.listdir(os.path.dirname(fixes.__file__)) + names.sort() + for name in names: if name.startswith("fix_") and name.endswith(".py"): fix_names.append(name[4:-3]) fix_names.sort() @@ -153,6 +155,8 @@ for dirpath, dirnames, filenames in os.walk(arg): if self.options.verbose: self.log_message("Descending into %s", dirpath) + dirnames.sort() + filenames.sort() for name in filenames: if not name.startswith(".") and name.endswith("py"): fullname = os.path.join(dirpath, name) From python-checkins at python.org Mon Dec 18 18:12:32 2006 From: python-checkins at python.org (andrew.kuchling) Date: Mon, 18 Dec 2006 18:12:32 +0100 (CET) Subject: [Python-checkins] r53048 - python/trunk/Doc/lib/libsqlite3.tex Message-ID: <20061218171232.0D9C91E4006@bag.python.org> Author: andrew.kuchling Date: Mon Dec 18 18:12:31 2006 New Revision: 53048 Modified: python/trunk/Doc/lib/libsqlite3.tex Log: [Bug #1618083] Add missing word; make a few grammar fixes Modified: python/trunk/Doc/lib/libsqlite3.tex ============================================================================== --- python/trunk/Doc/lib/libsqlite3.tex (original) +++ python/trunk/Doc/lib/libsqlite3.tex Mon Dec 18 18:12:31 2006 @@ -187,12 +187,12 @@ \end{funcdesc} \begin{funcdesc}{complete_statement}{sql} -Returns \constant{True} if the string \var{sql} one or more complete SQL -statements terminated by semicolons. It does not verify if the SQL is -syntactically correct, only if there are no unclosed string literals and if the +Returns \constant{True} if the string \var{sql} contains one or more complete SQL +statements terminated by semicolons. It does not verify that the SQL is +syntactically correct, only that there are no unclosed string literals and the statement is terminated by a semicolon. -This can be used to build a shell for SQLite, like in the following example: +This can be used to build a shell for SQLite, as in the following example: \verbatiminput{sqlite3/complete_statement.py} \end{funcdesc} From python-checkins at python.org Mon Dec 18 18:13:10 2006 From: python-checkins at python.org (andrew.kuchling) Date: Mon, 18 Dec 2006 18:13:10 +0100 (CET) Subject: [Python-checkins] r53049 - python/branches/release25-maint/Doc/lib/libsqlite3.tex Message-ID: <20061218171310.9A23A1E4006@bag.python.org> Author: andrew.kuchling Date: Mon Dec 18 18:13:10 2006 New Revision: 53049 Modified: python/branches/release25-maint/Doc/lib/libsqlite3.tex Log: [Bug #1618083] Add missing word; make a few grammar fixes Modified: python/branches/release25-maint/Doc/lib/libsqlite3.tex ============================================================================== --- python/branches/release25-maint/Doc/lib/libsqlite3.tex (original) +++ python/branches/release25-maint/Doc/lib/libsqlite3.tex Mon Dec 18 18:13:10 2006 @@ -187,12 +187,12 @@ \end{funcdesc} \begin{funcdesc}{complete_statement}{sql} -Returns \constant{True} if the string \var{sql} one or more complete SQL -statements terminated by semicolons. It does not verify if the SQL is -syntactically correct, only if there are no unclosed string literals and if the +Returns \constant{True} if the string \var{sql} contains one or more complete SQL +statements terminated by semicolons. It does not verify that the SQL is +syntactically correct, only that there are no unclosed string literals and the statement is terminated by a semicolon. -This can be used to build a shell for SQLite, like in the following example: +This can be used to build a shell for SQLite, as in the following example: \verbatiminput{sqlite3/complete_statement.py} \end{funcdesc} From python-checkins at python.org Mon Dec 18 18:16:06 2006 From: python-checkins at python.org (andrew.kuchling) Date: Mon, 18 Dec 2006 18:16:06 +0100 (CET) Subject: [Python-checkins] r53050 - python/trunk/Doc/whatsnew/whatsnew25.tex Message-ID: <20061218171606.3CD8F1E4006@bag.python.org> Author: andrew.kuchling Date: Mon Dec 18 18:16:05 2006 New Revision: 53050 Modified: python/trunk/Doc/whatsnew/whatsnew25.tex Log: Bump version Modified: python/trunk/Doc/whatsnew/whatsnew25.tex ============================================================================== --- python/trunk/Doc/whatsnew/whatsnew25.tex (original) +++ python/trunk/Doc/whatsnew/whatsnew25.tex Mon Dec 18 18:16:05 2006 @@ -5,7 +5,7 @@ % Fix XXX comments \title{What's New in Python 2.5} -\release{1.0} +\release{1.01} \author{A.M. Kuchling} \authoraddress{\email{amk at amk.ca}} From python-checkins at python.org Mon Dec 18 18:22:07 2006 From: python-checkins at python.org (andrew.kuchling) Date: Mon, 18 Dec 2006 18:22:07 +0100 (CET) Subject: [Python-checkins] r53051 - python/trunk/Doc/whatsnew/whatsnew25.tex Message-ID: <20061218172207.BA08D1E4006@bag.python.org> Author: andrew.kuchling Date: Mon Dec 18 18:22:07 2006 New Revision: 53051 Modified: python/trunk/Doc/whatsnew/whatsnew25.tex Log: [Bug #1616726] Fix description of generator.close(); if you raise some random exception, the exception is raised and doesn't trigger a RuntimeError Modified: python/trunk/Doc/whatsnew/whatsnew25.tex ============================================================================== --- python/trunk/Doc/whatsnew/whatsnew25.tex (original) +++ python/trunk/Doc/whatsnew/whatsnew25.tex Mon Dec 18 18:22:07 2006 @@ -556,13 +556,14 @@ where the generator's execution is paused. \item \method{close()} raises a new \exception{GeneratorExit} - exception inside the generator to terminate the iteration. - On receiving this - exception, the generator's code must either raise - \exception{GeneratorExit} or \exception{StopIteration}; catching the - exception and doing anything else is illegal and will trigger - a \exception{RuntimeError}. \method{close()} will also be called by - Python's garbage collector when the generator is garbage-collected. + exception inside the generator to terminate the iteration. On + receiving this exception, the generator's code must either raise + \exception{GeneratorExit} or \exception{StopIteration}. Catching + the \exception{GeneratorExit} exception and returning a value is + illegal and will trigger a \exception{RuntimeError}; if the function + raises some other exception, that exception is propagated to the + caller. \method{close()} will also be called by Python's garbage + collector when the generator is garbage-collected. If you need to run cleanup code when a \exception{GeneratorExit} occurs, I suggest using a \code{try: ... finally:} suite instead of From python-checkins at python.org Mon Dec 18 18:38:15 2006 From: python-checkins at python.org (andrew.kuchling) Date: Mon, 18 Dec 2006 18:38:15 +0100 (CET) Subject: [Python-checkins] r53052 - python/trunk/Doc/whatsnew/whatsnew25.tex Message-ID: <20061218173815.0F37B1E4006@bag.python.org> Author: andrew.kuchling Date: Mon Dec 18 18:38:14 2006 New Revision: 53052 Modified: python/trunk/Doc/whatsnew/whatsnew25.tex Log: Describe new methods in Queue module Modified: python/trunk/Doc/whatsnew/whatsnew25.tex ============================================================================== --- python/trunk/Doc/whatsnew/whatsnew25.tex (original) +++ python/trunk/Doc/whatsnew/whatsnew25.tex Mon Dec 18 18:38:14 2006 @@ -1664,6 +1664,13 @@ \item The \module{pyexpat} module now uses version 2.0 of the Expat parser. (Contributed by Trent Mick.) +\item The \class{Queue} class provided by the \module{Queue} module +gained two new methods. \method{join()} blocks until all items in +the queue have been retrieved and all processing work on the items +have been completed. Worker threads call the other new method, +\method{task_done()}, to signal that processing for an item has been +completed. (Contributed by Raymond Hettinger.) + \item The old \module{regex} and \module{regsub} modules, which have been deprecated ever since Python 2.0, have finally been deleted. Other deleted modules: \module{statcache}, \module{tzparse}, From python-checkins at python.org Mon Dec 18 20:22:25 2006 From: python-checkins at python.org (andrew.kuchling) Date: Mon, 18 Dec 2006 20:22:25 +0100 (CET) Subject: [Python-checkins] r53053 - python/trunk/Modules/bz2module.c Message-ID: <20061218192225.6EA371E4006@bag.python.org> Author: andrew.kuchling Date: Mon Dec 18 20:22:24 2006 New Revision: 53053 Modified: python/trunk/Modules/bz2module.c Log: [Patch #1615868 by Lars Gustaebel] Use Py_off_t to fix BZ2File.seek() for offsets > 2Gb Modified: python/trunk/Modules/bz2module.c ============================================================================== --- python/trunk/Modules/bz2module.c (original) +++ python/trunk/Modules/bz2module.c Mon Dec 18 20:22:24 2006 @@ -996,7 +996,7 @@ char small_buffer[SMALLCHUNK]; char *buffer = small_buffer; size_t buffersize = SMALLCHUNK; - int bytesread = 0; + Py_off_t bytesread = 0; size_t readsize; int chunksize; int bzerror; From python-checkins at python.org Mon Dec 18 20:26:14 2006 From: python-checkins at python.org (andrew.kuchling) Date: Mon, 18 Dec 2006 20:26:14 +0100 (CET) Subject: [Python-checkins] r53054 - python/branches/release25-maint/Modules/bz2module.c Message-ID: <20061218192614.18A501E4006@bag.python.org> Author: andrew.kuchling Date: Mon Dec 18 20:26:13 2006 New Revision: 53054 Modified: python/branches/release25-maint/Modules/bz2module.c Log: [Patch #1615868 by Lars Gustaebel] Use Py_off_t to fix BZ2File.seek() for offsets > 2Gb Modified: python/branches/release25-maint/Modules/bz2module.c ============================================================================== --- python/branches/release25-maint/Modules/bz2module.c (original) +++ python/branches/release25-maint/Modules/bz2module.c Mon Dec 18 20:26:13 2006 @@ -996,7 +996,7 @@ char small_buffer[SMALLCHUNK]; char *buffer = small_buffer; size_t buffersize = SMALLCHUNK; - int bytesread = 0; + Py_off_t bytesread = 0; size_t readsize; int chunksize; int bzerror; From python-checkins at python.org Mon Dec 18 20:41:53 2006 From: python-checkins at python.org (brett.cannon) Date: Mon, 18 Dec 2006 20:41:53 +0100 (CET) Subject: [Python-checkins] r53055 - sandbox/trunk/import_in_py/importbench.py Message-ID: <20061218194153.913121E4010@bag.python.org> Author: brett.cannon Date: Mon Dec 18 20:41:53 2006 New Revision: 53055 Added: sandbox/trunk/import_in_py/importbench.py Log: Start a benchmarking script. Added: sandbox/trunk/import_in_py/importbench.py ============================================================================== --- (empty file) +++ sandbox/trunk/import_in_py/importbench.py Mon Dec 18 20:41:53 2006 @@ -0,0 +1,18 @@ +from timeit import Timer + +def bench_sys_modules(times=100000, repeat=1): + """Benchmark returning a modules from sys.modules.""" + # We can safely assume timeit has already been imported. + timer = Timer("__import__('timeit', {}, {}, [], 0)") + return timer.repeat(repeat, times) + + +def main(): + for name, item in globals().iteritems(): + if name.startswith('bench_'): + timings = item() + print "%s: %s" % (item.__name__, timings) + + +if __name__ == '__main__': + main() From buildbot at python.org Mon Dec 18 21:27:24 2006 From: buildbot at python.org (buildbot at python.org) Date: Mon, 18 Dec 2006 20:27:24 +0000 Subject: [Python-checkins] buildbot warnings in ia64 Ubuntu trunk trunk Message-ID: <20061218202724.A17351E400B@bag.python.org> The Buildbot has detected a new failure of ia64 Ubuntu trunk trunk. Full details are available at: http://www.python.org/dev/buildbot/all/ia64%2520Ubuntu%2520trunk%2520trunk/builds/266 Buildbot URL: http://www.python.org/dev/buildbot/all/ Build Reason: Build Source Stamp: [branch trunk] HEAD Blamelist: andrew.kuchling Build had warnings: warnings test Excerpt from the test logfile: 1 test failed: test_urllibnet ====================================================================== ERROR: test_info (test.test_urllibnet.urlopenNetworkTests) ---------------------------------------------------------------------- Traceback (most recent call last): File "/home/pybot/buildarea/trunk.klose-debian-ia64/build/Lib/test/test_urllibnet.py", line 66, in test_info open_url = urllib.urlopen("http://www.python.org/") File "/home/pybot/buildarea/trunk.klose-debian-ia64/build/Lib/urllib.py", line 82, in urlopen return opener.open(url) File "/home/pybot/buildarea/trunk.klose-debian-ia64/build/Lib/urllib.py", line 190, in open return getattr(self, name)(url) File "/home/pybot/buildarea/trunk.klose-debian-ia64/build/Lib/urllib.py", line 325, in open_http h.endheaders() File "/home/pybot/buildarea/trunk.klose-debian-ia64/build/Lib/httplib.py", line 864, in endheaders self._send_output() File "/home/pybot/buildarea/trunk.klose-debian-ia64/build/Lib/httplib.py", line 736, in _send_output self.send(msg) File "/home/pybot/buildarea/trunk.klose-debian-ia64/build/Lib/httplib.py", line 695, in send self.connect() File "/home/pybot/buildarea/trunk.klose-debian-ia64/build/Lib/httplib.py", line 679, in connect raise socket.error, msg IOError: [Errno socket error] (110, 'Connection timed out') ====================================================================== ERROR: test_readlines (test.test_urllibnet.urlopenNetworkTests) ---------------------------------------------------------------------- Traceback (most recent call last): File "/home/pybot/buildarea/trunk.klose-debian-ia64/build/Lib/test/test_urllibnet.py", line 55, in test_readlines open_url = urllib.urlopen("http://www.python.org/") File "/home/pybot/buildarea/trunk.klose-debian-ia64/build/Lib/urllib.py", line 82, in urlopen return opener.open(url) File "/home/pybot/buildarea/trunk.klose-debian-ia64/build/Lib/urllib.py", line 190, in open return getattr(self, name)(url) File "/home/pybot/buildarea/trunk.klose-debian-ia64/build/Lib/urllib.py", line 325, in open_http h.endheaders() File "/home/pybot/buildarea/trunk.klose-debian-ia64/build/Lib/httplib.py", line 864, in endheaders self._send_output() File "/home/pybot/buildarea/trunk.klose-debian-ia64/build/Lib/httplib.py", line 736, in _send_output self.send(msg) File "/home/pybot/buildarea/trunk.klose-debian-ia64/build/Lib/httplib.py", line 695, in send self.connect() File "/home/pybot/buildarea/trunk.klose-debian-ia64/build/Lib/httplib.py", line 679, in connect raise socket.error, msg IOError: [Errno socket error] (110, 'Connection timed out') ====================================================================== ERROR: test_basic (test.test_urllibnet.urlretrieveNetworkTests) ---------------------------------------------------------------------- Traceback (most recent call last): File "/home/pybot/buildarea/trunk.klose-debian-ia64/build/Lib/test/test_urllibnet.py", line 120, in test_basic file_location,info = urllib.urlretrieve("http://www.python.org/") File "/home/pybot/buildarea/trunk.klose-debian-ia64/build/Lib/urllib.py", line 89, in urlretrieve return _urlopener.retrieve(url, filename, reporthook, data) File "/home/pybot/buildarea/trunk.klose-debian-ia64/build/Lib/urllib.py", line 222, in retrieve fp = self.open(url, data) File "/home/pybot/buildarea/trunk.klose-debian-ia64/build/Lib/urllib.py", line 190, in open return getattr(self, name)(url) File "/home/pybot/buildarea/trunk.klose-debian-ia64/build/Lib/urllib.py", line 325, in open_http h.endheaders() File "/home/pybot/buildarea/trunk.klose-debian-ia64/build/Lib/httplib.py", line 864, in endheaders self._send_output() File "/home/pybot/buildarea/trunk.klose-debian-ia64/build/Lib/httplib.py", line 736, in _send_output self.send(msg) File "/home/pybot/buildarea/trunk.klose-debian-ia64/build/Lib/httplib.py", line 695, in send self.connect() File "/home/pybot/buildarea/trunk.klose-debian-ia64/build/Lib/httplib.py", line 679, in connect raise socket.error, msg IOError: [Errno socket error] (110, 'Connection timed out') sincerely, -The Buildbot From python-checkins at python.org Mon Dec 18 21:27:31 2006 From: python-checkins at python.org (andrew.kuchling) Date: Mon, 18 Dec 2006 21:27:31 +0100 (CET) Subject: [Python-checkins] r53056 - python/branches/release25-maint/Misc/NEWS Message-ID: <20061218202731.6B1B81E400F@bag.python.org> Author: andrew.kuchling Date: Mon Dec 18 21:27:30 2006 New Revision: 53056 Modified: python/branches/release25-maint/Misc/NEWS Log: Add forgotten NEWS item for previous commit Modified: python/branches/release25-maint/Misc/NEWS ============================================================================== --- python/branches/release25-maint/Misc/NEWS (original) +++ python/branches/release25-maint/Misc/NEWS Mon Dec 18 21:27:30 2006 @@ -81,6 +81,8 @@ - Patch #1544279: Improve thread-safety of the socket module by moving the sock_addr_t storage out of the socket object. +- Patch #1615868: make bz2.BZFile.seek() work for offsets >2GiB. + - Bug #1563807: _ctypes built on AIX fails with ld ffi error. - Bug #1598620: A ctypes Structure cannot contain itself. From buildbot at python.org Mon Dec 18 21:38:06 2006 From: buildbot at python.org (buildbot at python.org) Date: Mon, 18 Dec 2006 20:38:06 +0000 Subject: [Python-checkins] buildbot warnings in x86 XP 2.5 Message-ID: <20061218203806.5ACDF1E4008@bag.python.org> The Buildbot has detected a new failure of x86 XP 2.5. Full details are available at: http://www.python.org/dev/buildbot/all/x86%2520XP%25202.5/builds/59 Buildbot URL: http://www.python.org/dev/buildbot/all/ Build Reason: Build Source Stamp: [branch branches/release25-maint] HEAD Blamelist: andrew.kuchling Build had warnings: warnings test Excerpt from the test logfile: 1 test failed: test_timeout sincerely, -The Buildbot From buildbot at python.org Mon Dec 18 21:40:46 2006 From: buildbot at python.org (buildbot at python.org) Date: Mon, 18 Dec 2006 20:40:46 +0000 Subject: [Python-checkins] buildbot warnings in hppa Ubuntu dapper trunk Message-ID: <20061218204046.C34351E403A@bag.python.org> The Buildbot has detected a new failure of hppa Ubuntu dapper trunk. Full details are available at: http://www.python.org/dev/buildbot/all/hppa%2520Ubuntu%2520dapper%2520trunk/builds/257 Buildbot URL: http://www.python.org/dev/buildbot/all/ Build Reason: Build Source Stamp: [branch trunk] HEAD Blamelist: andrew.kuchling Build had warnings: warnings test Excerpt from the test logfile: sincerely, -The Buildbot From buildbot at python.org Mon Dec 18 22:21:16 2006 From: buildbot at python.org (buildbot at python.org) Date: Mon, 18 Dec 2006 21:21:16 +0000 Subject: [Python-checkins] buildbot warnings in alpha Tru64 5.1 2.5 Message-ID: <20061218212116.301DF1E4006@bag.python.org> The Buildbot has detected a new failure of alpha Tru64 5.1 2.5. Full details are available at: http://www.python.org/dev/buildbot/all/alpha%2520Tru64%25205.1%25202.5/builds/130 Buildbot URL: http://www.python.org/dev/buildbot/all/ Build Reason: Build Source Stamp: [branch branches/release25-maint] HEAD Blamelist: andrew.kuchling Build had warnings: warnings test Excerpt from the test logfile: 1 test failed: test_socket ====================================================================== FAIL: testInterruptedTimeout (test.test_socket.TCPTimeoutTest) ---------------------------------------------------------------------- Traceback (most recent call last): File "/net/ringneck/scratch1/nnorwitz/buildbot/2.5.norwitz-tru64/build/Lib/test/test_socket.py", line 847, in testInterruptedTimeout self.fail("got Alarm in wrong place") AssertionError: got Alarm in wrong place sincerely, -The Buildbot From python-checkins at python.org Mon Dec 18 22:29:08 2006 From: python-checkins at python.org (andrew.kuchling) Date: Mon, 18 Dec 2006 22:29:08 +0100 (CET) Subject: [Python-checkins] r53057 - python/trunk/Doc/howto/functional.rst Message-ID: <20061218212908.56C6D1E4006@bag.python.org> Author: andrew.kuchling Date: Mon Dec 18 22:29:07 2006 New Revision: 53057 Modified: python/trunk/Doc/howto/functional.rst Log: Fix markup Modified: python/trunk/Doc/howto/functional.rst ============================================================================== --- python/trunk/Doc/howto/functional.rst (original) +++ python/trunk/Doc/howto/functional.rst Mon Dec 18 22:29:07 2006 @@ -1398,10 +1398,10 @@ ''''''''''''''''''''''''''' http://docs.python.org/lib/module-itertools.html: -Documentation ``for the itertools`` module. +Documentation for the ``itertools`` module. http://docs.python.org/lib/module-operator.html: -Documentation ``for the operator`` module. +Documentation for the ``operator`` module. http://www.python.org/dev/peps/pep-0289/: PEP 289: "Generator Expressions" From python-checkins at python.org Mon Dec 18 22:29:28 2006 From: python-checkins at python.org (brett.cannon) Date: Mon, 18 Dec 2006 22:29:28 +0100 (CET) Subject: [Python-checkins] r53058 - sandbox/trunk/import_in_py/importbench.py Message-ID: <20061218212928.D5C321E4006@bag.python.org> Author: brett.cannon Date: Mon Dec 18 22:29:28 2006 New Revision: 53058 Modified: sandbox/trunk/import_in_py/importbench.py Log: Add a test for a guaranteed import failure. Also add some infrastructure code for preserving import state between benchmarks and for creating temporary .py/.pyc files. Modified: sandbox/trunk/import_in_py/importbench.py ============================================================================== --- sandbox/trunk/import_in_py/importbench.py (original) +++ sandbox/trunk/import_in_py/importbench.py Mon Dec 18 22:29:28 2006 @@ -1,16 +1,101 @@ +from py_compile import compile as compile_to_pyc +import os +import sys +import tempfile from timeit import Timer -def bench_sys_modules(times=100000, repeat=1): + +def save_import_state(fxn): + """Backup and restore the import state.""" + def inner(*args, **kwargs): + modules = sys.modules.copy() + path = sys.path[:] + meta_path = sys.meta_path[:] + path_importer_cache = sys.path_importer_cache.copy() + path_hooks = sys.path_hooks[:] + try: + return fxn(*args, **kwargs) + finally: + sys.modules.clear() + sys.modules.update(modules) + sys.path = path + sys.meta_path = meta_path + sys.path_importer_cache.clear() + sys.path_importer_cache.update(path_importer_cache) + sys.path_hooks = path_hooks + + inner.__name__ = fxn.__name__ + return inner + +class PyPycFiles(object): + + """Create .py and .pyc files for importing.""" + + def __init__(self, py=True, pyc=True, module_name="tempmod"): + """Specify what type of files to create.""" + self.py = py + self.pyc = pyc + self.module_name = module_name + + def __enter__(self): + """Create requested files.""" + self.directory = tempfile.gettempdir() + self.py_path = os.path.join(self.directory, self.module_name + '.py') + with open(self.py_path, 'w') as py_file: + py_file.write("# Temporary file for benchmarking import.") + if self.pyc: + compile_to_pyc(self.py_path, doraise=True) + self.pyc_path = self.py_path + ('c' if __debug__ else 'o') + if not self.py: + os.remove(self.py_path) + sys.path.append(self.directory) + return self + + def __exit__(self, *args): + """Clean up created state.""" + if self.py: + os.remove(self.py_path) + if self.pyc: + os.remove(self.pyc_path) + + + at save_import_state +def bench_sys_modules(times, repeat): """Benchmark returning a modules from sys.modules.""" - # We can safely assume timeit has already been imported. - timer = Timer("__import__('timeit', {}, {}, [], 0)") - return timer.repeat(repeat, times) + sys.path = [] + sys.meta_path = [] + sys.path_importer_cache.clear() + with PyPycFiles() as py_pyc_state: + # Force the module into sys.modules . + __import__(py_pyc_state.module_name, {}) + timer = Timer("__import__(%r, {}, {}, [], 0)" % py_pyc_state.module_name) + return timer.repeat(repeat, times) + + at save_import_state +def bench_nonexistent_module(times, repeat): + """How expensive is an import failure (with a single entry on sys.path)?""" + # Verify that the module does not exist. + sys.path = [] + sys.meta_path = [] + bad_name = 'sadfflkjsdf' + # Have at least one entry on sys.path. + with PyPycFiles(): + # Make sure the fake module name is not actually real. + try: + __import__(bad_name) + except ImportError: + pass + else: + raise Exception("supposed non-existent module actually exists") + timer = Timer("try:__import__(%r, {}, {}, [], 0)\nexcept ImportError:pass" % + bad_name) + return timer.repeat(repeat, times) def main(): for name, item in globals().iteritems(): if name.startswith('bench_'): - timings = item() + timings = item(10000, 1) print "%s: %s" % (item.__name__, timings) From python-checkins at python.org Mon Dec 18 23:07:09 2006 From: python-checkins at python.org (brett.cannon) Date: Mon, 18 Dec 2006 23:07:09 +0100 (CET) Subject: [Python-checkins] r53059 - sandbox/trunk/import_in_py/importbench.py Message-ID: <20061218220709.1F4251E4006@bag.python.org> Author: brett.cannon Date: Mon Dec 18 23:07:08 2006 New Revision: 53059 Modified: sandbox/trunk/import_in_py/importbench.py Log: Add tests for importing Python modules. Also clean up output. Modified: sandbox/trunk/import_in_py/importbench.py ============================================================================== --- sandbox/trunk/import_in_py/importbench.py (original) +++ sandbox/trunk/import_in_py/importbench.py Mon Dec 18 23:07:08 2006 @@ -41,11 +41,11 @@ """Create requested files.""" self.directory = tempfile.gettempdir() self.py_path = os.path.join(self.directory, self.module_name + '.py') + self.pyc_path = self.py_path + ('c' if __debug__ else 'o') with open(self.py_path, 'w') as py_file: py_file.write("# Temporary file for benchmarking import.") if self.pyc: compile_to_pyc(self.py_path, doraise=True) - self.pyc_path = self.py_path + ('c' if __debug__ else 'o') if not self.py: os.remove(self.py_path) sys.path.append(self.directory) @@ -53,9 +53,9 @@ def __exit__(self, *args): """Clean up created state.""" - if self.py: + if os.path.exists(self.py_path): os.remove(self.py_path) - if self.pyc: + if os.path.exists(self.pyc_path): os.remove(self.pyc_path) @@ -65,10 +65,10 @@ sys.path = [] sys.meta_path = [] sys.path_importer_cache.clear() - with PyPycFiles() as py_pyc_state: + with PyPycFiles() as file_state: # Force the module into sys.modules . - __import__(py_pyc_state.module_name, {}) - timer = Timer("__import__(%r, {}, {}, [], 0)" % py_pyc_state.module_name) + __import__(file_state.module_name, {}) + timer = Timer("__import__(%r, {}, {}, [], 0)" % file_state.module_name) return timer.repeat(repeat, times) @save_import_state @@ -90,14 +90,43 @@ timer = Timer("try:__import__(%r, {}, {}, [], 0)\nexcept ImportError:pass" % bad_name) return timer.repeat(repeat, times) - - + +def py_pyc_module_benchmark(py, pyc): + @save_import_state + def inner(times, repeat): + sys.path = [] + sys.meta_path = [] + with PyPycFiles(py, pyc) as file_state: + import_stmt = ("__import__(%(module)r, {}, {}, [], 0);" + "del sys.modules[%(module)r]") + import_stmt = import_stmt % {'module':file_state.module_name} + # Warm up path_importer_cache. + exec import_stmt in globals(), {} + # Benchmark. + timer = Timer(import_stmt, "import sys") + return timer.repeat(repeat, times) + return inner + +bench_pyc_with_py = py_pyc_module_benchmark(py=True, pyc=True) +bench_pyc_without_py = py_pyc_module_benchmark(py=False, pyc=True) +bench_py_without_pyc = py_pyc_module_benchmark(py=True, pyc=False) + + def main(): + max_name_len = max(len(name) for name in globals().keys()) + repetitions = 2 + iterations = 10000 + print ("Repeating tests %s times with %s iterations ..." % + (repetitions, iterations)) + print + print "%s time per repetition (in ms)" % "benchmark".ljust(max_name_len) + print '-' * 50 for name, item in globals().iteritems(): if name.startswith('bench_'): - timings = item(10000, 1) - print "%s: %s" % (item.__name__, timings) - + timings = item(iterations, repetitions) + print "%s %s" % (name.ljust(max_name_len), + [int(result*1000) for result in timings]) + if __name__ == '__main__': main() From python-checkins at python.org Mon Dec 18 23:29:28 2006 From: python-checkins at python.org (brett.cannon) Date: Mon, 18 Dec 2006 23:29:28 +0100 (CET) Subject: [Python-checkins] r53060 - sandbox/trunk/import_in_py/importbench.py Message-ID: <20061218222928.98E7E1E4006@bag.python.org> Author: brett.cannon Date: Mon Dec 18 23:29:28 2006 New Revision: 53060 Modified: sandbox/trunk/import_in_py/importbench.py Log: Benchmark importing built-ins and frozen modules. Modified: sandbox/trunk/import_in_py/importbench.py ============================================================================== --- sandbox/trunk/import_in_py/importbench.py (original) +++ sandbox/trunk/import_in_py/importbench.py Mon Dec 18 23:29:28 2006 @@ -1,9 +1,19 @@ from py_compile import compile as compile_to_pyc import os +import StringIO import sys import tempfile from timeit import Timer +def import_and_clear_timer(module_name, globals_={}, locals_={}, fromlist=[], + level=0): + import_stmt = ('__import__(%r, %r, %r, %r, %s)' % + (module_name, globals_, locals_, fromlist, level)) + del_stmt = 'del sys.modules[%r]' % module_name + stmt = import_stmt + '; ' + del_stmt + # Warm up path_importer_cache and make sure module is not in sys.modules. + exec stmt in globals(), {} + return Timer(import_stmt + '; ' + del_stmt, 'import sys') def save_import_state(fxn): """Backup and restore the import state.""" @@ -97,13 +107,7 @@ sys.path = [] sys.meta_path = [] with PyPycFiles(py, pyc) as file_state: - import_stmt = ("__import__(%(module)r, {}, {}, [], 0);" - "del sys.modules[%(module)r]") - import_stmt = import_stmt % {'module':file_state.module_name} - # Warm up path_importer_cache. - exec import_stmt in globals(), {} - # Benchmark. - timer = Timer(import_stmt, "import sys") + timer = import_and_clear_timer(file_state.module_name) return timer.repeat(repeat, times) return inner @@ -111,10 +115,30 @@ bench_pyc_without_py = py_pyc_module_benchmark(py=False, pyc=True) bench_py_without_pyc = py_pyc_module_benchmark(py=True, pyc=False) + at save_import_state +def bench_builtins(times, repeat): + """Benchmark the importation of a built-in module.""" + sys.meta_path = [] + sys.path = [] + timer = import_and_clear_timer('xxsubtype') + return timer.repeat(repeat, times) + +def bench_frozen(times, repeat): + """Benchmark the importing of frozen modules.""" + sys.path = [] + sys.meta_path = [] + # Must suppress output from importing __hello__. + sys.stdout = StringIO.StringIO() + try: + timer = import_and_clear_timer('__hello__') + return timer.repeat(repeat, times) + finally: + sys.stdout = sys.__stdout__ + def main(): max_name_len = max(len(name) for name in globals().keys()) - repetitions = 2 + repetitions = 3 iterations = 10000 print ("Repeating tests %s times with %s iterations ..." % (repetitions, iterations)) From python-checkins at python.org Tue Dec 19 02:23:28 2006 From: python-checkins at python.org (brett.cannon) Date: Tue, 19 Dec 2006 02:23:28 +0100 (CET) Subject: [Python-checkins] r53061 - sandbox/trunk/import_in_py/importbench.py Message-ID: <20061219012328.383071E4006@bag.python.org> Author: brett.cannon Date: Tue Dec 19 02:23:27 2006 New Revision: 53061 Modified: sandbox/trunk/import_in_py/importbench.py Log: Add benchmark for extension modules. This also found a bug where bench_frozen was not cleaning up import state properly. Modified: sandbox/trunk/import_in_py/importbench.py ============================================================================== --- sandbox/trunk/import_in_py/importbench.py (original) +++ sandbox/trunk/import_in_py/importbench.py Tue Dec 19 02:23:27 2006 @@ -122,7 +122,8 @@ sys.path = [] timer = import_and_clear_timer('xxsubtype') return timer.repeat(repeat, times) - + + at save_import_state def bench_frozen(times, repeat): """Benchmark the importing of frozen modules.""" sys.path = [] @@ -135,8 +136,26 @@ finally: sys.stdout = sys.__stdout__ + at save_import_state +def bench_extension(times, repeat): + """Benchmark the importing of an extension module.""" + # Choose an extension module that is always included with Python. + module = 'datetime' + # Import the object to find out which entry in sys.path contains the module. + module_object = __import__(module, {}, {}, [], 0) + directory = os.path.split(module_object.__file__)[0] + sys.meta_path = [] + sys.path = [directory] + timer = import_and_clear_timer(module) + return timer.repeat(repeat, times) + -def main(): +def display_results(fxn, name, spacing, repeat, times): + timings = fxn(times, repeat) + print "%s %s" % (name.ljust(spacing), + [int(result*1000) for result in timings]) + +def main(tests=None): max_name_len = max(len(name) for name in globals().keys()) repetitions = 3 iterations = 10000 @@ -145,12 +164,14 @@ print print "%s time per repetition (in ms)" % "benchmark".ljust(max_name_len) print '-' * 50 - for name, item in globals().iteritems(): - if name.startswith('bench_'): - timings = item(iterations, repetitions) - print "%s %s" % (name.ljust(max_name_len), - [int(result*1000) for result in timings]) + if tests is None: + tests = (item for item in globals().iterkeys() + if item.startswith('bench_')) + globals_ = globals() + for name in tests: + item = globals_[name] + display_results(item, name, max_name_len, repetitions, iterations) if __name__ == '__main__': - main() + main(sys.argv[1:] if len(sys.argv) > 1 else None) From python-checkins at python.org Tue Dec 19 03:11:05 2006 From: python-checkins at python.org (brett.cannon) Date: Tue, 19 Dec 2006 03:11:05 +0100 (CET) Subject: [Python-checkins] r53062 - sandbox/trunk/import_in_py/importbench.py Message-ID: <20061219021105.5B4BC1E4006@bag.python.org> Author: brett.cannon Date: Tue Dec 19 03:11:04 2006 New Revision: 53062 Modified: sandbox/trunk/import_in_py/importbench.py Log: Add docstring for the module. Modified: sandbox/trunk/import_in_py/importbench.py ============================================================================== --- sandbox/trunk/import_in_py/importbench.py (original) +++ sandbox/trunk/import_in_py/importbench.py Tue Dec 19 03:11:04 2006 @@ -1,3 +1,24 @@ +"""Benchmark importing. + +There are two aspects to importing that these benchmarks should cover. One is +the importing of various types of modules (such as extension modules, frozen +modules, etc.). The other aspect is the general mechanism of importing (such as +walking sys.path, using path_hooks, etc.). + +In general, though, one encompasses the other. By minimizing the entries in +sys.path and sys.meta_path when benchmarking the import of different types of +files you also inadvertently benchmark the fundamental import machinery as well. +This means that only extreme cases of the import machinery need to be explicitly +tested. + +Another thing to keep in mind is expected changed in Py3K in terms of the +'level' argument. Since Py3K is a definite target for this code the 'level' +value should be set properly and not be allowed to default to -1. While +benchmarking the classic relative import style would be helpful it should be +its own benchmark. + +""" +#XXX make sure all code goes repetitions, iterations (and probably with those names). from py_compile import compile as compile_to_pyc import os import StringIO @@ -71,7 +92,7 @@ @save_import_state def bench_sys_modules(times, repeat): - """Benchmark returning a modules from sys.modules.""" + """Benchmark returning a module from sys.modules.""" sys.path = [] sys.meta_path = [] sys.path_importer_cache.clear() @@ -174,4 +195,5 @@ if __name__ == '__main__': +# XXX support specifying number of repetitions and iterations from the command-line. main(sys.argv[1:] if len(sys.argv) > 1 else None) From python-checkins at python.org Tue Dec 19 09:17:51 2006 From: python-checkins at python.org (thomas.wouters) Date: Tue, 19 Dec 2006 09:17:51 +0100 (CET) Subject: [Python-checkins] r53063 - python/trunk/Lib/sre_parse.py Message-ID: <20061219081751.3E0DD1E4008@bag.python.org> Author: thomas.wouters Date: Tue Dec 19 09:17:50 2006 New Revision: 53063 Modified: python/trunk/Lib/sre_parse.py Log: Make sre's SubPattern objects accept slice objects like it already accepts simple slices. Modified: python/trunk/Lib/sre_parse.py ============================================================================== --- python/trunk/Lib/sre_parse.py (original) +++ python/trunk/Lib/sre_parse.py Tue Dec 19 09:17:50 2006 @@ -134,6 +134,8 @@ def __delitem__(self, index): del self.data[index] def __getitem__(self, index): + if isinstance(index, slice): + return SubPattern(self.pattern, self.data[index]) return self.data[index] def __setitem__(self, index, code): self.data[index] = code From python-checkins at python.org Tue Dec 19 15:13:06 2006 From: python-checkins at python.org (andrew.kuchling) Date: Tue, 19 Dec 2006 15:13:06 +0100 (CET) Subject: [Python-checkins] r53065 - python/trunk/Lib/hmac.py Message-ID: <20061219141306.746341E4006@bag.python.org> Author: andrew.kuchling Date: Tue Dec 19 15:13:05 2006 New Revision: 53065 Modified: python/trunk/Lib/hmac.py Log: [Patch #1618455 by Ben Maurer] Improve speed of HMAC by using str.translate() instead of a more general XOR that has to construct a list. Slightly modified from Maurer's patch: the _strxor() function is no longer necessary at all. Modified: python/trunk/Lib/hmac.py ============================================================================== --- python/trunk/Lib/hmac.py (original) +++ python/trunk/Lib/hmac.py Tue Dec 19 15:13:05 2006 @@ -3,10 +3,8 @@ Implements the HMAC algorithm as described by RFC 2104. """ -def _strxor(s1, s2): - """Utility method. XOR the two strings s1 and s2 (must have same length). - """ - return "".join(map(lambda x, y: chr(ord(x) ^ ord(y)), s1, s2)) +trans_5C = "".join ([chr (x ^ 0x5C) for x in xrange(256)]) +trans_36 = "".join ([chr (x ^ 0x36) for x in xrange(256)]) # The size of the digests returned by HMAC depends on the underlying # hashing module used. @@ -50,15 +48,12 @@ self.digest_size = self.inner.digest_size blocksize = 64 - ipad = "\x36" * blocksize - opad = "\x5C" * blocksize - if len(key) > blocksize: key = self.digest_cons(key).digest() key = key + chr(0) * (blocksize - len(key)) - self.outer.update(_strxor(key, opad)) - self.inner.update(_strxor(key, ipad)) + self.outer.update(key.translate(trans_5C)) + self.inner.update(key.translate(trans_36)) if msg is not None: self.update(msg) From python-checkins at python.org Tue Dec 19 15:28:23 2006 From: python-checkins at python.org (andrew.kuchling) Date: Tue, 19 Dec 2006 15:28:23 +0100 (CET) Subject: [Python-checkins] r53066 - python/trunk/Doc/lib/libsocket.tex Message-ID: <20061219142823.9FE531E4006@bag.python.org> Author: andrew.kuchling Date: Tue Dec 19 15:28:23 2006 New Revision: 53066 Modified: python/trunk/Doc/lib/libsocket.tex Log: [Bug #1613651] Document socket.recv_into, socket.recvfrom_into Also, the text for recvfrom told you to read recv() for an explanation of the 'flags' argument, but recv() just pointed you at the man page. Copied the man-page text to recvfrom(), recvfrom_into, recv_into to avoid the pointless redirection. I don't have LaTeX on this machine; hope my markup is OK. Modified: python/trunk/Doc/lib/libsocket.tex ============================================================================== --- python/trunk/Doc/lib/libsocket.tex (original) +++ python/trunk/Doc/lib/libsocket.tex Tue Dec 19 15:28:23 2006 @@ -569,11 +569,32 @@ Receive data from the socket. The return value is a pair \code{(\var{string}, \var{address})} where \var{string} is a string representing the data received and \var{address} is the address of the -socket sending the data. The optional \var{flags} argument has the -same meaning as for \method{recv()} above. +socket sending the data. See the \UNIX{} manual page +\manpage{recv}{2} for the meaning of the optional argument +\var{flags}; it defaults to zero. (The format of \var{address} depends on the address family --- see above.) \end{methoddesc} +\begin{methoddesc}[socket]{recvfrom_into}{buffer\optional{, nbytes\optional{, flags}}} +Receive data from the socket, writing it into \var{buffer} instead of +creating a new string. The return value is a pair +\code{(\var{nbytes}, \var{address})} where \var{nbytes} is the number +of bytes received and \var{address} is the address of the socket +sending the data. See the \UNIX{} manual page +\manpage{recv}{2} for the meaning of the optional argument +\var{flags}; it defaults to zero. (The format of \var{address} +depends on the address family --- see above.) +\end{methoddesc} + +\begin{methoddesc}[socket]{recv_into}{buffer\optional{, nbytes\optional{, flags}}} +Receive up to \var{nbytes} bytes from the socket, +storing the data into a buffer rather than creating a new string. +If \var{nbytes} is not specified (or 0), +receive up to the size available in the given buffer. +See the \UNIX{} manual page \manpage{recv}{2} for the meaning of the +optional argument \var{flags}; it defaults to zero. +\end{methoddesc} + \begin{methoddesc}[socket]{send}{string\optional{, flags}} Send data to the socket. The socket must be connected to a remote socket. The optional \var{flags} argument has the same meaning as for From python-checkins at python.org Tue Dec 19 15:29:04 2006 From: python-checkins at python.org (andrew.kuchling) Date: Tue, 19 Dec 2006 15:29:04 +0100 (CET) Subject: [Python-checkins] r53067 - python/trunk/Modules/socketmodule.c Message-ID: <20061219142904.8E6181E4008@bag.python.org> Author: andrew.kuchling Date: Tue Dec 19 15:29:04 2006 New Revision: 53067 Modified: python/trunk/Modules/socketmodule.c Log: Comment typo Modified: python/trunk/Modules/socketmodule.c ============================================================================== --- python/trunk/Modules/socketmodule.c (original) +++ python/trunk/Modules/socketmodule.c Tue Dec 19 15:29:04 2006 @@ -2210,7 +2210,7 @@ /* * This is the guts of the recv() and recv_into() methods, which reads into a - * char buffer. If you have any inc/def ref to do to the objects that contain + * char buffer. If you have any inc/dec ref to do to the objects that contain * the buffer, do it in the caller. This function returns the number of bytes * succesfully read. If there was an error, it returns -1. Note that it is * also possible that we return a number of bytes smaller than the request From python-checkins at python.org Tue Dec 19 16:11:41 2006 From: python-checkins at python.org (andrew.kuchling) Date: Tue, 19 Dec 2006 16:11:41 +0100 (CET) Subject: [Python-checkins] r53068 - python/trunk/Lib/urllib.py Message-ID: <20061219151141.CDF101E4008@bag.python.org> Author: andrew.kuchling Date: Tue Dec 19 16:11:41 2006 New Revision: 53068 Modified: python/trunk/Lib/urllib.py Log: [Patch #1617413 from Dug Song] Fix HTTP Basic authentication via HTTPS Modified: python/trunk/Lib/urllib.py ============================================================================== --- python/trunk/Lib/urllib.py (original) +++ python/trunk/Lib/urllib.py Tue Dec 19 16:11:41 2006 @@ -405,8 +405,8 @@ h.putheader('Content-Length', '%d' % len(data)) else: h.putrequest('GET', selector) - if proxy_auth: h.putheader('Proxy-Authorization: Basic %s' % proxy_auth) - if auth: h.putheader('Authorization: Basic %s' % auth) + if proxy_auth: h.putheader('Proxy-Authorization', 'Basic %s' % proxy_auth) + if auth: h.putheader('Authorization', 'Basic %s' % auth) if realhost: h.putheader('Host', realhost) for args in self.addheaders: h.putheader(*args) h.endheaders() From python-checkins at python.org Tue Dec 19 16:12:23 2006 From: python-checkins at python.org (andrew.kuchling) Date: Tue, 19 Dec 2006 16:12:23 +0100 (CET) Subject: [Python-checkins] r53069 - python/branches/release25-maint/Lib/urllib.py Message-ID: <20061219151223.D2AB01E4006@bag.python.org> Author: andrew.kuchling Date: Tue Dec 19 16:12:23 2006 New Revision: 53069 Modified: python/branches/release25-maint/Lib/urllib.py Log: [Patch #1617413 from Dug Song] Fix HTTP Basic authentication via HTTPS Modified: python/branches/release25-maint/Lib/urllib.py ============================================================================== --- python/branches/release25-maint/Lib/urllib.py (original) +++ python/branches/release25-maint/Lib/urllib.py Tue Dec 19 16:12:23 2006 @@ -405,8 +405,8 @@ h.putheader('Content-Length', '%d' % len(data)) else: h.putrequest('GET', selector) - if proxy_auth: h.putheader('Proxy-Authorization: Basic %s' % proxy_auth) - if auth: h.putheader('Authorization: Basic %s' % auth) + if proxy_auth: h.putheader('Proxy-Authorization', 'Basic %s' % proxy_auth) + if auth: h.putheader('Authorization', 'Basic %s' % auth) if realhost: h.putheader('Host', realhost) for args in self.addheaders: h.putheader(*args) h.endheaders() From python-checkins at python.org Tue Dec 19 16:13:45 2006 From: python-checkins at python.org (andrew.kuchling) Date: Tue, 19 Dec 2006 16:13:45 +0100 (CET) Subject: [Python-checkins] r53070 - python/branches/release25-maint/Misc/NEWS Message-ID: <20061219151345.5E0E41E4006@bag.python.org> Author: andrew.kuchling Date: Tue Dec 19 16:13:44 2006 New Revision: 53070 Modified: python/branches/release25-maint/Misc/NEWS Log: Add NEWS item Modified: python/branches/release25-maint/Misc/NEWS ============================================================================== --- python/branches/release25-maint/Misc/NEWS (original) +++ python/branches/release25-maint/Misc/NEWS Tue Dec 19 16:13:44 2006 @@ -197,6 +197,9 @@ - Patch #1574068: fix urllib/urllib2 to not insert line breaks when HTTP authentication data was very long. +- Patch #1617413: fix urllib's support for HTTP Basic authentication via HTTPS + (patch by Dug Song). + - Fix a bug in traceback.format_exception_only() that led to an error being raised when print_exc() was called without an exception set. In version 2.4, this printed "None", restored that behavior. From buildbot at python.org Tue Dec 19 16:14:43 2006 From: buildbot at python.org (buildbot at python.org) Date: Tue, 19 Dec 2006 15:14:43 +0000 Subject: [Python-checkins] buildbot warnings in alpha Tru64 5.1 trunk Message-ID: <20061219151443.2A99B1E4006@bag.python.org> The Buildbot has detected a new failure of alpha Tru64 5.1 trunk. Full details are available at: http://www.python.org/dev/buildbot/all/alpha%2520Tru64%25205.1%2520trunk/builds/1328 Buildbot URL: http://www.python.org/dev/buildbot/all/ Build Reason: Build Source Stamp: [branch trunk] HEAD Blamelist: andrew.kuchling Build had warnings: warnings test Excerpt from the test logfile: 1 test failed: test_socket ====================================================================== FAIL: testInterruptedTimeout (test.test_socket.TCPTimeoutTest) ---------------------------------------------------------------------- Traceback (most recent call last): File "/net/ringneck/scratch1/nnorwitz/buildbot/trunk.norwitz-tru64/build/Lib/test/test_socket.py", line 847, in testInterruptedTimeout self.fail("got Alarm in wrong place") AssertionError: got Alarm in wrong place sincerely, -The Buildbot From buildbot at python.org Tue Dec 19 16:17:34 2006 From: buildbot at python.org (buildbot at python.org) Date: Tue, 19 Dec 2006 15:17:34 +0000 Subject: [Python-checkins] buildbot warnings in hppa Ubuntu dapper trunk Message-ID: <20061219151734.584F21E4006@bag.python.org> The Buildbot has detected a new failure of hppa Ubuntu dapper trunk. Full details are available at: http://www.python.org/dev/buildbot/all/hppa%2520Ubuntu%2520dapper%2520trunk/builds/259 Buildbot URL: http://www.python.org/dev/buildbot/all/ Build Reason: Build Source Stamp: [branch trunk] HEAD Blamelist: andrew.kuchling Build had warnings: warnings failed slave lost sincerely, -The Buildbot From python-checkins at python.org Tue Dec 19 16:18:14 2006 From: python-checkins at python.org (andrew.kuchling) Date: Tue, 19 Dec 2006 16:18:14 +0100 (CET) Subject: [Python-checkins] r53071 - python/trunk/Lib/pydoc.py Message-ID: <20061219151814.76DF51E4006@bag.python.org> Author: andrew.kuchling Date: Tue Dec 19 16:18:12 2006 New Revision: 53071 Modified: python/trunk/Lib/pydoc.py Log: [Patch #1600491 from Jim Jewett] Describe how to build help files on Windows Modified: python/trunk/Lib/pydoc.py ============================================================================== --- python/trunk/Lib/pydoc.py (original) +++ python/trunk/Lib/pydoc.py Tue Dec 19 16:18:12 2006 @@ -1737,6 +1737,9 @@ Sorry, topic and keyword documentation is not available because the Python HTML documentation files could not be found. If you have installed them, please set the environment variable PYTHONDOCS to indicate their location. + +On the Microsoft Windows operating system, the files can be built by +running "hh -decompile . PythonNN.chm" in the C:\PythonNN\Doc> directory. ''') return target = self.topics.get(topic, self.keywords.get(topic)) From python-checkins at python.org Tue Dec 19 16:19:15 2006 From: python-checkins at python.org (andrew.kuchling) Date: Tue, 19 Dec 2006 16:19:15 +0100 (CET) Subject: [Python-checkins] r53072 - python/branches/release25-maint/Lib/pydoc.py Message-ID: <20061219151915.4BA3B1E4006@bag.python.org> Author: andrew.kuchling Date: Tue Dec 19 16:19:14 2006 New Revision: 53072 Modified: python/branches/release25-maint/Lib/pydoc.py Log: [Patch #1600491 from Jim Jewett] Describe how to build help files on Windows Modified: python/branches/release25-maint/Lib/pydoc.py ============================================================================== --- python/branches/release25-maint/Lib/pydoc.py (original) +++ python/branches/release25-maint/Lib/pydoc.py Tue Dec 19 16:19:14 2006 @@ -1737,6 +1737,9 @@ Sorry, topic and keyword documentation is not available because the Python HTML documentation files could not be found. If you have installed them, please set the environment variable PYTHONDOCS to indicate their location. + +On the Microsoft Windows operating system, the files can be built by +running "hh -decompile . PythonNN.chm" in the C:\PythonNN\Doc> directory. ''') return target = self.topics.get(topic, self.keywords.get(topic)) From buildbot at python.org Tue Dec 19 16:35:42 2006 From: buildbot at python.org (buildbot at python.org) Date: Tue, 19 Dec 2006 15:35:42 +0000 Subject: [Python-checkins] buildbot warnings in x86 mvlgcc trunk Message-ID: <20061219153543.292E91E4010@bag.python.org> The Buildbot has detected a new failure of x86 mvlgcc trunk. Full details are available at: http://www.python.org/dev/buildbot/all/x86%2520mvlgcc%2520trunk/builds/115 Buildbot URL: http://www.python.org/dev/buildbot/all/ Build Reason: Build Source Stamp: [branch trunk] HEAD Blamelist: andrew.kuchling Build had warnings: warnings test Excerpt from the test logfile: 1 test failed: test_socket_ssl sincerely, -The Buildbot From python-checkins at python.org Tue Dec 19 16:43:10 2006 From: python-checkins at python.org (andrew.kuchling) Date: Tue, 19 Dec 2006 16:43:10 +0100 (CET) Subject: [Python-checkins] r53073 - python/trunk/Lib/cookielib.py Message-ID: <20061219154310.DA7DA1E4010@bag.python.org> Author: andrew.kuchling Date: Tue Dec 19 16:43:10 2006 New Revision: 53073 Modified: python/trunk/Lib/cookielib.py Log: [Patch #1587139 by kxroberto] Protect lock acquisition/release with try...finally to ensure the lock is always released. This could use the 'with' statement, but the patch uses 'finally'. 2.5 backport candidate. Modified: python/trunk/Lib/cookielib.py ============================================================================== --- python/trunk/Lib/cookielib.py (original) +++ python/trunk/Lib/cookielib.py Tue Dec 19 16:43:10 2006 @@ -1316,26 +1316,28 @@ """ _debug("add_cookie_header") self._cookies_lock.acquire() + try: - self._policy._now = self._now = int(time.time()) - - cookies = self._cookies_for_request(request) + self._policy._now = self._now = int(time.time()) - attrs = self._cookie_attrs(cookies) - if attrs: - if not request.has_header("Cookie"): - request.add_unredirected_header( - "Cookie", "; ".join(attrs)) - - # if necessary, advertise that we know RFC 2965 - if (self._policy.rfc2965 and not self._policy.hide_cookie2 and - not request.has_header("Cookie2")): - for cookie in cookies: - if cookie.version != 1: - request.add_unredirected_header("Cookie2", '$Version="1"') - break + cookies = self._cookies_for_request(request) - self._cookies_lock.release() + attrs = self._cookie_attrs(cookies) + if attrs: + if not request.has_header("Cookie"): + request.add_unredirected_header( + "Cookie", "; ".join(attrs)) + + # if necessary, advertise that we know RFC 2965 + if (self._policy.rfc2965 and not self._policy.hide_cookie2 and + not request.has_header("Cookie2")): + for cookie in cookies: + if cookie.version != 1: + request.add_unredirected_header("Cookie2", '$Version="1"') + break + + finally: + self._cookies_lock.release() self.clear_expired_cookies() @@ -1602,12 +1604,15 @@ def set_cookie_if_ok(self, cookie, request): """Set a cookie if policy says it's OK to do so.""" self._cookies_lock.acquire() - self._policy._now = self._now = int(time.time()) + try: + self._policy._now = self._now = int(time.time()) - if self._policy.set_ok(cookie, request): - self.set_cookie(cookie) + if self._policy.set_ok(cookie, request): + self.set_cookie(cookie) + - self._cookies_lock.release() + finally: + self._cookies_lock.release() def set_cookie(self, cookie): """Set a cookie, without checking whether or not it should be set.""" @@ -1626,13 +1631,15 @@ """Extract cookies from response, where allowable given the request.""" _debug("extract_cookies: %s", response.info()) self._cookies_lock.acquire() - self._policy._now = self._now = int(time.time()) + try: + self._policy._now = self._now = int(time.time()) - for cookie in self.make_cookies(response, request): - if self._policy.set_ok(cookie, request): - _debug(" setting cookie: %s", cookie) - self.set_cookie(cookie) - self._cookies_lock.release() + for cookie in self.make_cookies(response, request): + if self._policy.set_ok(cookie, request): + _debug(" setting cookie: %s", cookie) + self.set_cookie(cookie) + finally: + self._cookies_lock.release() def clear(self, domain=None, path=None, name=None): """Clear some cookies. @@ -1669,10 +1676,12 @@ """ self._cookies_lock.acquire() - for cookie in self: - if cookie.discard: - self.clear(cookie.domain, cookie.path, cookie.name) - self._cookies_lock.release() + try: + for cookie in self: + if cookie.discard: + self.clear(cookie.domain, cookie.path, cookie.name) + finally: + self._cookies_lock.release() def clear_expired_cookies(self): """Discard all expired cookies. @@ -1685,11 +1694,13 @@ """ self._cookies_lock.acquire() - now = time.time() - for cookie in self: - if cookie.is_expired(now): - self.clear(cookie.domain, cookie.path, cookie.name) - self._cookies_lock.release() + try: + now = time.time() + for cookie in self: + if cookie.is_expired(now): + self.clear(cookie.domain, cookie.path, cookie.name) + finally: + self._cookies_lock.release() def __iter__(self): return deepvalues(self._cookies) @@ -1761,16 +1772,18 @@ else: raise ValueError(MISSING_FILENAME_TEXT) self._cookies_lock.acquire() - - old_state = copy.deepcopy(self._cookies) - self._cookies = {} try: - self.load(filename, ignore_discard, ignore_expires) - except (LoadError, IOError): - self._cookies = old_state - raise - self._cookies_lock.release() + old_state = copy.deepcopy(self._cookies) + self._cookies = {} + try: + self.load(filename, ignore_discard, ignore_expires) + except (LoadError, IOError): + self._cookies = old_state + raise + + finally: + self._cookies_lock.release() from _LWPCookieJar import LWPCookieJar, lwp_cookie_str from _MozillaCookieJar import MozillaCookieJar From buildbot at python.org Tue Dec 19 17:20:05 2006 From: buildbot at python.org (buildbot at python.org) Date: Tue, 19 Dec 2006 16:20:05 +0000 Subject: [Python-checkins] buildbot warnings in x86 OpenBSD 2.5 Message-ID: <20061219162005.A9A501E4009@bag.python.org> The Buildbot has detected a new failure of x86 OpenBSD 2.5. Full details are available at: http://www.python.org/dev/buildbot/all/x86%2520OpenBSD%25202.5/builds/129 Buildbot URL: http://www.python.org/dev/buildbot/all/ Build Reason: Build Source Stamp: [branch branches/release25-maint] HEAD Blamelist: andrew.kuchling Build had warnings: warnings test Excerpt from the test logfile: sincerely, -The Buildbot From buildbot at python.org Tue Dec 19 17:30:00 2006 From: buildbot at python.org (buildbot at python.org) Date: Tue, 19 Dec 2006 16:30:00 +0000 Subject: [Python-checkins] buildbot warnings in x86 gentoo 2.5 Message-ID: <20061219163000.3AF1D1E4002@bag.python.org> The Buildbot has detected a new failure of x86 gentoo 2.5. Full details are available at: http://www.python.org/dev/buildbot/all/x86%2520gentoo%25202.5/builds/149 Buildbot URL: http://www.python.org/dev/buildbot/all/ Build Reason: Build Source Stamp: [branch branches/release25-maint] HEAD Blamelist: andrew.kuchling Build had warnings: warnings test Excerpt from the test logfile: Traceback (most recent call last): File "/home/buildslave/python-trunk/2.5.norwitz-x86/build/Lib/threading.py", line 460, in __bootstrap self.run() File "/home/buildslave/python-trunk/2.5.norwitz-x86/build/Lib/threading.py", line 440, in run self.__target(*self.__args, **self.__kwargs) File "/home/buildslave/python-trunk/2.5.norwitz-x86/build/Lib/bsddb/test/test_thread.py", line 281, in readerThread rec = dbutils.DeadlockWrap(c.next, max_retries=10) File "/home/buildslave/python-trunk/2.5.norwitz-x86/build/Lib/bsddb/dbutils.py", line 62, in DeadlockWrap return function(*_args, **_kwargs) DBLockDeadlockError: (-30996, 'DB_LOCK_DEADLOCK: Locker killed to resolve a deadlock') Traceback (most recent call last): File "/home/buildslave/python-trunk/2.5.norwitz-x86/build/Lib/threading.py", line 460, in __bootstrap self.run() File "/home/buildslave/python-trunk/2.5.norwitz-x86/build/Lib/threading.py", line 440, in run self.__target(*self.__args, **self.__kwargs) File "/home/buildslave/python-trunk/2.5.norwitz-x86/build/Lib/bsddb/test/test_thread.py", line 281, in readerThread rec = dbutils.DeadlockWrap(c.next, max_retries=10) File "/home/buildslave/python-trunk/2.5.norwitz-x86/build/Lib/bsddb/dbutils.py", line 62, in DeadlockWrap return function(*_args, **_kwargs) DBLockDeadlockError: (-30996, 'DB_LOCK_DEADLOCK: Locker killed to resolve a deadlock') 1 test failed: test_socket_ssl sincerely, -The Buildbot From buildbot at python.org Tue Dec 19 18:01:42 2006 From: buildbot at python.org (buildbot at python.org) Date: Tue, 19 Dec 2006 17:01:42 +0000 Subject: [Python-checkins] buildbot warnings in hppa Ubuntu dapper 2.5 Message-ID: <20061219170143.033D01E4012@bag.python.org> The Buildbot has detected a new failure of hppa Ubuntu dapper 2.5. Full details are available at: http://www.python.org/dev/buildbot/all/hppa%2520Ubuntu%2520dapper%25202.5/builds/128 Buildbot URL: http://www.python.org/dev/buildbot/all/ Build Reason: Build Source Stamp: [branch branches/release25-maint] HEAD Blamelist: andrew.kuchling Build had warnings: warnings test Excerpt from the test logfile: sincerely, -The Buildbot From python-checkins at python.org Tue Dec 19 19:29:11 2006 From: python-checkins at python.org (vinay.sajip) Date: Tue, 19 Dec 2006 19:29:11 +0100 (CET) Subject: [Python-checkins] r53074 - python/trunk/Doc/lib/liblogging.tex Message-ID: <20061219182911.C40A71E4016@bag.python.org> Author: vinay.sajip Date: Tue Dec 19 19:29:11 2006 New Revision: 53074 Modified: python/trunk/Doc/lib/liblogging.tex Log: Updated documentation for findCaller() to indicate that a 3-tuple is now returned, rather than a 2-tuple. Modified: python/trunk/Doc/lib/liblogging.tex ============================================================================== --- python/trunk/Doc/lib/liblogging.tex (original) +++ python/trunk/Doc/lib/liblogging.tex Tue Dec 19 19:29:11 2006 @@ -516,8 +516,10 @@ \end{methoddesc} \begin{methoddesc}{findCaller}{} -Finds the caller's source filename and line number. Returns the filename -and line number as a 2-element tuple. +Finds the caller's source filename and line number. Returns the filename, +line number and function name as a 3-element tuple. +\versionchanged[The function name was added. In earlier versions, the +filename and line number were returned as a 2-element tuple.]{2.5} \end{methoddesc} \begin{methoddesc}{handle}{record} From python-checkins at python.org Tue Dec 19 19:31:23 2006 From: python-checkins at python.org (vinay.sajip) Date: Tue, 19 Dec 2006 19:31:23 +0100 (CET) Subject: [Python-checkins] r53075 - python/branches/release25-maint/Doc/lib/liblogging.tex Message-ID: <20061219183123.316EC1E400A@bag.python.org> Author: vinay.sajip Date: Tue Dec 19 19:31:22 2006 New Revision: 53075 Modified: python/branches/release25-maint/Doc/lib/liblogging.tex Log: Updated documentation for findCaller() to indicate that a 3-tuple is now returned, rather than a 2-tuple. Modified: python/branches/release25-maint/Doc/lib/liblogging.tex ============================================================================== --- python/branches/release25-maint/Doc/lib/liblogging.tex (original) +++ python/branches/release25-maint/Doc/lib/liblogging.tex Tue Dec 19 19:31:22 2006 @@ -516,8 +516,10 @@ \end{methoddesc} \begin{methoddesc}{findCaller}{} -Finds the caller's source filename and line number. Returns the filename -and line number as a 2-element tuple. +Finds the caller's source filename and line number. Returns the filename, +line number and function name as a 3-element tuple. +\versionchanged[The function name was added. In earlier versions, the +filename and line number were returned as a 2-element tuple.]{2.5} \end{methoddesc} \begin{methoddesc}{handle}{record} From python-checkins at python.org Tue Dec 19 20:01:11 2006 From: python-checkins at python.org (georg.brandl) Date: Tue, 19 Dec 2006 20:01:11 +0100 (CET) Subject: [Python-checkins] r53076 - peps/trunk/pep-3100.txt Message-ID: <20061219190111.9455F1E4011@bag.python.org> Author: georg.brandl Date: Tue Dec 19 20:01:10 2006 New Revision: 53076 Modified: peps/trunk/pep-3100.txt Log: Repair footnote jumble. Modified: peps/trunk/pep-3100.txt ============================================================================== --- peps/trunk/pep-3100.txt (original) +++ peps/trunk/pep-3100.txt Tue Dec 19 20:01:10 2006 @@ -65,19 +65,19 @@ * True division becomes default behavior [#pep238]_ [done] * ``exec`` as a statement is not worth it -- make it a function [done] -* (Maybe) add optional declarations for static typing [11]_ +* (Maybe) add optional declarations for static typing [10]_ * Support only new-style classes; classic classes will be gone [1]_ [done] -* Replace ``print`` by a function [16]_ +* Replace ``print`` by a function [14]_ * Use ``except E1, E2, E3 as err:`` if you want the error variable. [3]_ * ``None`` becomes a keyword [4]_ (What about ``True``, ``False``?) -* ``...`` to become a general expression element [24]_ [done] +* ``...`` to become a general expression element [16]_ [done] * ``as`` becomes a keyword [5]_ (starting in 2.6 already) [done] * Have list comprehensions be syntactic sugar for passing an equivalent generator expression to ``list()``; as a consequence the - loop variable will no longer be exposed [12]_ + loop variable will no longer be exposed [#pep289]_ * Comparisons other than ``==`` and ``!=`` between disparate types will raise an exception unless explicitly supported by the type [6]_ [done] -* Exceptions might grow an attribute to store the traceback [13]_ +* Exceptions might grow an attribute to store the traceback [11]_ * floats will not be acceptable as arguments in place of ints for operations where floats are inadvertantly accepted (PyArg_ParseTuple() i & l formats) * Imports will be absolute by default. [done] @@ -91,7 +91,7 @@ - List comprehensions will require parentheses around the iterables. This will make list comprehensions more similar to generator comprehensions. [x for x in 1, 2] will need to be: [x for x in (1, 2)] - - Lambdas may have to be parenthesized [23]_ + - Lambdas may have to be parenthesized [#pep308]_ * Builtin module init function names (PyMODINIT_FUNC) will be prefixed with _Py (or Py). Currently they aren't namespace safe since the names @@ -100,29 +100,29 @@ with __builtin__. Keeping both with confusingly similar spellings and semantics is evil. * Attributes on functions of the form ``func_whatever`` will be renamed - ``__whatever__`` [25]_ -* Set literals and comprehensions [27]_ [28]_ [done] + ``__whatever__`` [17]_ +* Set literals and comprehensions [19]_ [20]_ [done] {x} means set([x]); {x, y} means set([x, y]). {F(x) for x in S if P(x)} means set(F(x) for x in S if P(x)). NB. {range(x)} means set([range(x)]), NOT set(range(x)). There's no literal for an empty set; use set() (or {1}&{2} :-). There's no frozenset literal; they are too rarely needed. -* Might reconsider PEP 299 [30]_: special __main__() function in modules. +* Might reconsider PEP 299 [#pep299]_: special __main__() function in modules. * The ``__nonzero__`` special method will be renamed to ``__bool__`` and have to return a bool. The typeobject slot will be called - ``tp_bool`` [32]_ [done] + ``tp_bool`` [23]_ [done] To be removed: * String exceptions: use instances of an Exception class [2]_ [done] -* ``raise Exception, "message"``: use ``raise Exception("message")`` [14]_ +* ``raise Exception, "message"``: use ``raise Exception("message")`` [12]_ * ```x```: use ``repr(x)`` [2]_ [done] * The ``<>`` operator: use ``!=`` instead [3]_ [done] -* The __mod__ and __divmod__ special methods on float. [29]_ +* The __mod__ and __divmod__ special methods on float. [21]_ * Might drop unbound methods? [7]_ * METH_OLDARGS * WITH_CYCLE_GC [done] -* __getslice__, __setslice__, __delslice__ [17]_; +* __getslice__, __setslice__, __delslice__ [#sequence-types]_; remove slice opcodes and use slice objects. [Thomas Wouters is working on this in a branch] * C APIs (see code): @@ -145,15 +145,15 @@ (e.g. ``dict.keys()``, ``dict.values()``, ``dict.items()``, etc.); iter* methods will be removed. Better: make keys(), etc. return views ala Java collections??? -* Make ``string.join()`` stringify its arguments? [26]_ +* Make ``string.join()`` stringify its arguments? [18]_ To be removed: * ``basestring.find()`` and ``basestring.rfind()``; use ``basestring.index()`` or ``basestring.[r]partition()`` or - or ``basestring.rindex()`` in a try/except block??? [15]_ + or ``basestring.rindex()`` in a try/except block??? [13]_ * ``file.xreadlines()`` method [#file-object]_ [done] -* ``dict.setdefault()``? [22]_ +* ``dict.setdefault()``? [15]_ * ``dict.has_key()`` method [done] @@ -178,7 +178,7 @@ * ``coerce()``: no longer needed [2]_ * ``execfile()``, ``reload()``: use ``exec()`` [2]_ * ``input()``: use ``eval(sys.stdin.readline())`` [2]_ [done] -* ``intern()``, ``id()``: put in ``sys`` (?) [2]_, [31]_ +* ``intern()``, ``id()``: put in ``sys`` (?) [2]_, [22]_ * ``map()``, ``filter()``: use list comprehensions instead??? [1]_, [9]_ (Actually these can stay.) * ``reduce()``: write a loop instead [2]_, [9]_ [done] @@ -201,11 +201,11 @@ + see docstrings and comments in the source - ``macfs``, ``new``, ``reconvert``, ``stringold``, ``xmllib``, ``pcre``, ``pypcre``, ``strop`` - + see PEP 4 [18]_ + + see PEP 4 [#pep4]_ - ``posixfile``, ``pre``, ``regsub``, ``rfc822``, ``statcache``, ``string``, ``TERMIOS`` ``mimetools``, ``MimeWriter``, ``mimify``, ``mpz``, ``rgbimage`` - + Everything in lib-old [18]_ + + Everything in lib-old [#pep4]_ - ``Para``, ``addpack``, ``cmp``, ``cmpcache``, ``codehack``, ``dircmp``, ``dump``, ``find``, ``fmt``, ``grep``, ``lockfile``, ``newdir``, ``ni``, ``packmail``, ``poly``, @@ -214,7 +214,7 @@ * ``sys.exitfunc``: use atexit module instead [#sys-module]_ * ``sys.exc_type``, ``sys.exc_values``, ``sys.exc_traceback``: not thread-safe; use ``sys.exc_info()`` or an attribute - of the exception [2]_ [13]_ [#sys-module]_ + of the exception [2]_ [11]_ [#sys-module]_ * ``array.read``, ``array.write`` [#array-module]_ * ``operator.isCallable`` : ``callable()`` built-in is being removed [#operator-module]_ @@ -246,12 +246,6 @@ .. [2] Python Regrets: http://www.python.org/doc/essays/ppt/regrets/PythonRegrets.pdf -.. [9] Guido's blog ("The fate of reduce() in Python 3000") - http://www.artima.com/weblogs/viewpost.jsp?thread=98196 - -.. [11] Guido's blog ("Python Optional Typechecking Redux") - http://www.artima.com/weblogs/viewpost.jsp?thread=89161 - .. [3] Python Wiki: http://www.python.org/moin/Python3.0 @@ -271,44 +265,50 @@ objects can be used") http://mail.python.org/pipermail/python-dev/2005-February/051674.html -.. [13] python-dev email ("anonymous blocks") +.. [9] Guido's blog ("The fate of reduce() in Python 3000") + http://www.artima.com/weblogs/viewpost.jsp?thread=98196 + +.. [10] Guido's blog ("Python Optional Typechecking Redux") + http://www.artima.com/weblogs/viewpost.jsp?thread=89161 + +.. [11] python-dev email ("anonymous blocks") http://mail.python.org/pipermail/python-dev/2005-April/053060.html -.. [14] python-dev email ("PEP 8: exception style") +.. [12] python-dev email ("PEP 8: exception style") http://mail.python.org/pipermail/python-dev/2005-August/055190.html -.. [15] python-dev email (Remove str.find in 3.0?) +.. [13] python-dev email (Remove str.find in 3.0?) http://mail.python.org/pipermail/python-dev/2005-August/055705.html -.. [16] python-dev email (Replacement for print in Python 3.0) +.. [14] python-dev email (Replacement for print in Python 3.0) http://mail.python.org/pipermail/python-dev/2005-September/056154.html -.. [21] python-dev email - http://mail.python.org/pipermail/python-dev/2006-February/061169.html - -.. [22] python-dev email ("defaultdict") +.. [15] python-dev email ("defaultdict") http://mail.python.org/pipermail/python-dev/2006-February/061261.html -.. [24] python-3000 email +.. [16] python-3000 email http://mail.python.org/pipermail/python-3000/2006-April/000996.html -.. [25] python-3000 email ("Pronouncement on parameter lists") +.. [17] python-3000 email ("Pronouncement on parameter lists") http://mail.python.org/pipermail/python-3000/2006-April/001175.html -.. [26] python-3000 email ("More wishful thinking") +.. [18] python-3000 email ("More wishful thinking") http://mail.python.org/pipermail/python-3000/2006-April/000810.html -.. [27] python-3000 email ("sets in P3K?") +.. [19] python-3000 email ("sets in P3K?") http://mail.python.org/pipermail/python-3000/2006-April/001286.html -.. [28] python-3000 email ("sets in P3K?") +.. [20] python-3000 email ("sets in P3K?") http://mail.python.org/pipermail/python-3000/2006-May/001666.html -.. [29] python-3000 email ("bug in modulus?") +.. [21] python-3000 email ("bug in modulus?") http://mail.python.org/pipermail/python-3000/2006-May/001735.html -.. [17] Python docs (Additional methods for emulation of sequence types) - http://docs.python.org/ref/sequence-methods.html +.. [22] SF patch "sys.id() and sys.intern()" + http://www.python.org/sf/1601678 + +.. [23] python-3000 email ("__nonzero__ vs. __bool__") + http://mail.python.org/pipermail/python-3000/2006-November/004524.html .. [#sys-module] Python docs (sys -- System-specific parameters and functions) http://docs.python.org/lib/module-sys.html @@ -322,27 +322,24 @@ .. [#file-object] Python docs (File objects) http://docs.python.org/lib/bltin-file-objects.html -.. [18] PEP 4 ("Deprecation of Standard Modules") +.. [#sequence-types] Python docs (Additional methods for emulation of sequence types) + http://docs.python.org/ref/sequence-methods.html + +.. [#pep4] PEP 4 ("Deprecation of Standard Modules") http://www.python.org/dev/peps/pep-0004 .. [#pep238] PEP 238 (Changing the Division Operator) http://www.python.org/dev/peps/pep-0238 -.. [12] PEP 289 ("Generator Expressions") +.. [#pep289] PEP 289 ("Generator Expressions") http://www.python.org/dev/peps/pep-0289 -.. [30] PEP 299 ("Special __main__() function in modules") +.. [#pep299] PEP 299 ("Special __main__() function in modules") http://www.python.org/dev/peps/pep-0299 -.. [23] PEP 308 ("Conditional Expressions") +.. [#pep308] PEP 308 ("Conditional Expressions") http://www.python.org/dev/peps/pep-0308 -.. [31] SF patch "sys.id() and sys.intern()" - http://www.python.org/sf/1601678 - -.. [32] python-3000 email ("__nonzero__ vs. __bool__") - http://mail.python.org/pipermail/python-3000/2006-November/004524.html - .. [#pep328] PEP 328 (Imports: Multi-Line and Absolute/Relative) http://www.python.org/dev/peps/pep-0328 From python-checkins at python.org Tue Dec 19 21:09:00 2006 From: python-checkins at python.org (erik.forsberg) Date: Tue, 19 Dec 2006 21:09:00 +0100 (CET) Subject: [Python-checkins] r53077 - in tracker/instances/python-dev: html/issue.index.html html/issue.item.html html/issue.search.html html/keyword.index.html html/keyword.item.html html/page.html schema.py Message-ID: <20061219200900.336FB1E4006@bag.python.org> Author: erik.forsberg Date: Tue Dec 19 21:08:59 2006 New Revision: 53077 Added: tracker/instances/python-dev/html/keyword.index.html Modified: tracker/instances/python-dev/html/issue.index.html tracker/instances/python-dev/html/issue.item.html tracker/instances/python-dev/html/issue.search.html tracker/instances/python-dev/html/keyword.item.html tracker/instances/python-dev/html/page.html tracker/instances/python-dev/schema.py Log: Added keyword to schema and templates. Modified: tracker/instances/python-dev/html/issue.index.html ============================================================================== --- tracker/instances/python-dev/html/issue.index.html (original) +++ tracker/instances/python-dev/html/issue.index.html Tue Dec 19 21:08:59 2006 @@ -35,6 +35,7 @@
    +   + Modified: tracker/instances/python-dev/html/issue.item.html ============================================================================== --- tracker/instances/python-dev/html/issue.item.html (original) +++ tracker/instances/python-dev/html/issue.item.html Tue Dec 19 21:08:59 2006 @@ -140,7 +140,10 @@ : - + + + + Modified: tracker/instances/python-dev/html/issue.search.html ============================================================================== --- tracker/instances/python-dev/html/issue.search.html (original) +++ tracker/instances/python-dev/html/issue.search.html Tue Dec 19 21:08:59 2006 @@ -182,6 +182,19 @@ + + + + + + + + Added: tracker/instances/python-dev/html/keyword.index.html ============================================================================== --- (empty file) +++ tracker/instances/python-dev/html/keyword.index.html Tue Dec 19 21:08:59 2006 @@ -0,0 +1,46 @@ + + + <span tal:omit-tag="true" i18n:translate="" >List of keywords</span> + <span tal:condition="request/dispname" + tal:replace="python:' - %s '%request.dispname" + /> - <span tal:replace="config/TRACKER_NAME" /> + + + List of keywords + + + + +

    + You are not allowed to view this page.

    + +

    + Please login with your username and password.

    + +
    %s
    STATUS NumberChange
    Resolution Creator Assigned ToKeywords
      
    priorityKeywords:keywords
    Change Note:
    Keyword: + +
    + + + + + + + + + + + + + + + +
    KeywordDescription
    + keyword name +  
    New Keyword
    + + + \ No newline at end of file Modified: tracker/instances/python-dev/html/keyword.item.html ============================================================================== --- tracker/instances/python-dev/html/keyword.item.html (original) +++ tracker/instances/python-dev/html/keyword.item.html Tue Dec 19 21:08:59 2006 @@ -1,54 +1,78 @@ - -Keyword editing - <span - i18n:name="tracker" tal:replace="config/TRACKER_NAME" /> -Keyword editing + + +<tal:if condition="context/id" i18n:translate="" + >Keyword <span tal:replace="context/id" i18n:name="id" + />: <span tal:replace="context/name" i18n:name="title" + /> - <span tal:replace="config/TRACKER_NAME" i18n:name="tracker" +/></tal:if> +<tal:if condition="not:context/id" i18n:translate="" + >New Keyword - <span tal:replace="config/TRACKER_NAME" i18n:name="tracker" +/></tal:if> + + + + + + New Keyword + New Keyword Editing + Keyword + Keyword Editing + + - - - - - - - - -
    Existing Keywords
    - keyword here -
    - To edit an existing keyword (for spelling or typing errors), - click on its entry above. -
    +

    + You are not allowed to view this page.

    + +

    + Please login with your username and password.

    -

    - To create a new keyword, enter it below and click "Submit New Entry". -

    +
    -
    + tal:attributes="action context/designator;"> + + -
    - - - - - - - - - -
    Keywordname
    -   - - - - submit button will go here -
    + + Keyword: + title + + + + Description: + description + + + + + +   + + + + + + + + +
    +
    - - + Modified: tracker/instances/python-dev/html/page.html ============================================================================== --- tracker/instances/python-dev/html/page.html (original) +++ tracker/instances/python-dev/html/page.html Tue Dec 19 21:08:59 2006 @@ -160,6 +160,9 @@
  • Add User
  • +
  • Edit Keywords +
  • Modified: tracker/instances/python-dev/schema.py ============================================================================== --- tracker/instances/python-dev/schema.py (original) +++ tracker/instances/python-dev/schema.py Tue Dec 19 21:08:59 2006 @@ -58,6 +58,13 @@ order=Number()) resolution.setkey('name') +# Keyword +keyword = Class(db, "keyword", + name=String(), + description=String()) +keyword.setkey("name") + + # User-defined saved searches query = Class(db, "query", klass=String(), @@ -111,7 +118,8 @@ assignee=Link('user'), status=Link('status'), resolution=Link('resolution'), - superseder=Link('issue')) + superseder=Link('issue'), + keywords=Multilink("keyword")) # # TRACKER SECURITY SETTINGS @@ -134,7 +142,8 @@ # User permissions ########################## for cl in ('issue_type', 'severity', 'component', - 'version', 'priority', 'status', 'resolution', 'issue', 'file', 'msg'): + 'version', 'priority', 'status', 'resolution', + 'issue', 'file', 'msg', 'keyword'): db.security.addPermissionToRole('User', 'View', cl) for cl in 'file', 'msg': @@ -161,10 +170,11 @@ # Developer permissions ########################## for cl in ('issue_type', 'severity', 'component', - 'version', 'priority', 'status', 'resolution', 'issue', 'file', 'msg'): + 'version', 'priority', 'status', 'resolution', + 'issue', 'file', 'msg', 'keyword'): db.security.addPermissionToRole('Developer', 'View', cl) -for cl in ('issue', 'file', 'msg'): +for cl in ('issue', 'file', 'msg', 'keyword'): db.security.addPermissionToRole('Developer', 'Edit', cl) db.security.addPermissionToRole('Developer', 'Create', cl) From python-checkins at python.org Tue Dec 19 21:09:19 2006 From: python-checkins at python.org (erik.forsberg) Date: Tue, 19 Dec 2006 21:09:19 +0100 (CET) Subject: [Python-checkins] r53078 - tracker/instances/python-dev/html/user.item.html Message-ID: <20061219200919.DF5E01E4006@bag.python.org> Author: erik.forsberg Date: Tue Dec 19 21:09:19 2006 New Revision: 53078 Modified: tracker/instances/python-dev/html/user.item.html Log: Minor html fix. Modified: tracker/instances/python-dev/html/user.item.html ============================================================================== --- tracker/instances/python-dev/html/user.item.html (original) +++ tracker/instances/python-dev/html/user.item.html Tue Dec 19 21:09:19 2006 @@ -142,7 +142,7 @@ tal:attributes="value python:','.join(required)"> - + From python-checkins at python.org Tue Dec 19 21:48:11 2006 From: python-checkins at python.org (erik.forsberg) Date: Tue, 19 Dec 2006 21:48:11 +0100 (CET) Subject: [Python-checkins] r53079 - tracker/instances/python-dev/schema.py Message-ID: <20061219204811.1386F1E4006@bag.python.org> Author: erik.forsberg Date: Tue Dec 19 21:48:10 2006 New Revision: 53079 Modified: tracker/instances/python-dev/schema.py Log: Allow Anonymous to view all classes. Probably closes http://psf.upfronthosting.co.za/roundup/meta/issue64. Modified: tracker/instances/python-dev/schema.py ============================================================================== --- tracker/instances/python-dev/schema.py (original) +++ tracker/instances/python-dev/schema.py Tue Dec 19 21:48:10 2006 @@ -145,6 +145,7 @@ 'version', 'priority', 'status', 'resolution', 'issue', 'file', 'msg', 'keyword'): db.security.addPermissionToRole('User', 'View', cl) + db.security.addPermissionToRole('Anonymous', 'View', cl) for cl in 'file', 'msg': db.security.addPermissionToRole('User', 'Create', cl) From python-checkins at python.org Tue Dec 19 21:51:07 2006 From: python-checkins at python.org (erik.forsberg) Date: Tue, 19 Dec 2006 21:51:07 +0100 (CET) Subject: [Python-checkins] r53081 - in tracker: importer/sfxml2roundup.py importer/sfxmlhandlers.py instances/python-dev/initial_data.py Message-ID: <20061219205107.57C0B1E4006@bag.python.org> Author: erik.forsberg Date: Tue Dec 19 21:51:06 2006 New Revision: 53081 Modified: tracker/importer/sfxml2roundup.py tracker/importer/sfxmlhandlers.py tracker/instances/python-dev/initial_data.py Log: Add py3k as keyword during initialization. Set keyword = [py3k] on issues that have Group = 'Python 3000'. Modified: tracker/importer/sfxml2roundup.py ============================================================================== --- tracker/importer/sfxml2roundup.py (original) +++ tracker/importer/sfxml2roundup.py Tue Dec 19 21:51:06 2006 @@ -49,7 +49,7 @@ sfxmlhandlers.GroupHandler(db, "artifact_group_id", "versions"), ] - roundupdata = {'files':[]} + roundupdata = {'files':[], 'keywords':[]} fields = {} for field in artifact.findall("field"): Modified: tracker/importer/sfxmlhandlers.py ============================================================================== --- tracker/importer/sfxmlhandlers.py (original) +++ tracker/importer/sfxmlhandlers.py Tue Dec 19 21:51:06 2006 @@ -413,6 +413,8 @@ elif "Feature Request" == group: roundupdata['type'] = self.db.issue_type.lookup("rfe") return + elif "Python 3000" == group: + roundupdata['keywords'] = [self.db.keyword.lookup('py3k')] try: version = self.db.version.lookup(group) roundupdata[self.target] = version Modified: tracker/instances/python-dev/initial_data.py ============================================================================== --- tracker/instances/python-dev/initial_data.py (original) +++ tracker/instances/python-dev/initial_data.py Tue Dec 19 21:51:06 2006 @@ -76,6 +76,9 @@ resolution.create(name='wont fix', order='10') resolution.create(name='works for me', order='11') +keyword = db.getclass("keyword") +keyword.create(name="py3k", description="Python 3000 bugs") + # # create the two default users user = db.getclass('user') From python-checkins at python.org Tue Dec 19 21:51:36 2006 From: python-checkins at python.org (georg.brandl) Date: Tue, 19 Dec 2006 21:51:36 +0100 (CET) Subject: [Python-checkins] r53082 - peps/trunk/pep-3100.txt Message-ID: <20061219205136.1F1811E4016@bag.python.org> Author: georg.brandl Date: Tue Dec 19 21:51:35 2006 New Revision: 53082 Modified: peps/trunk/pep-3100.txt Log: Mark intern() move as done. Modified: peps/trunk/pep-3100.txt ============================================================================== --- peps/trunk/pep-3100.txt (original) +++ peps/trunk/pep-3100.txt Tue Dec 19 21:51:35 2006 @@ -178,7 +178,7 @@ * ``coerce()``: no longer needed [2]_ * ``execfile()``, ``reload()``: use ``exec()`` [2]_ * ``input()``: use ``eval(sys.stdin.readline())`` [2]_ [done] -* ``intern()``, ``id()``: put in ``sys`` (?) [2]_, [22]_ +* ``intern()``: put in ``sys`` [2]_, [22]_ [done] * ``map()``, ``filter()``: use list comprehensions instead??? [1]_, [9]_ (Actually these can stay.) * ``reduce()``: write a loop instead [2]_, [9]_ [done] From python-checkins at python.org Tue Dec 19 22:03:16 2006 From: python-checkins at python.org (guido.van.rossum) Date: Tue, 19 Dec 2006 22:03:16 +0100 (CET) Subject: [Python-checkins] r53083 - in sandbox/trunk/2to3: example.py fixes/fix_ne.py Message-ID: <20061219210316.B8A061E4006@bag.python.org> Author: guido.van.rossum Date: Tue Dec 19 22:03:16 2006 New Revision: 53083 Added: sandbox/trunk/2to3/fixes/fix_ne.py (contents, props changed) Modified: sandbox/trunk/2to3/example.py Log: Add a fixer that turns <> into !=. Sorry, Barry! Modified: sandbox/trunk/2to3/example.py ============================================================================== --- sandbox/trunk/2to3/example.py (original) +++ sandbox/trunk/2to3/example.py Tue Dec 19 22:03:16 2006 @@ -3,6 +3,14 @@ """Docstring.""" import sys +def ne_examples(): + if x <> y: + pass + if x<>y: + pass + if x<>y<>z: + pass + def has_key_examples(): # x = d.has_key("x") or d.has_key("y") Added: sandbox/trunk/2to3/fixes/fix_ne.py ============================================================================== --- (empty file) +++ sandbox/trunk/2to3/fixes/fix_ne.py Tue Dec 19 22:03:16 2006 @@ -0,0 +1,30 @@ +# Copyright 2006 Google, Inc. All Rights Reserved. +# Licensed to PSF under a Contributor Agreement. + +"""Fixer that turns <> into !=. + +This is so simple that we don't need the pattern compiler. +""" + +# Python imports +import token + +# Local imports +import pytree +import pygram + +syms = pygram.python_symbols + + +class FixNe(object): + + def __init__(self, options): + self.options = options + + def match(self, node): + return node.type == token.NOTEQUAL and node.value == "<>" + + def transform(self, node): + new = pytree.Leaf(token.NOTEQUAL, "!=") + new.set_prefix(node.get_prefix()) + return new From python-checkins at python.org Tue Dec 19 22:04:02 2006 From: python-checkins at python.org (georg.brandl) Date: Tue, 19 Dec 2006 22:04:02 +0100 (CET) Subject: [Python-checkins] r53084 - peps/trunk/pep-0263.txt Message-ID: <20061219210402.3AC581E400A@bag.python.org> Author: georg.brandl Date: Tue Dec 19 22:04:01 2006 New Revision: 53084 Modified: peps/trunk/pep-0263.txt Log: Clarify encoding cookie format. Modified: peps/trunk/pep-0263.txt ============================================================================== --- peps/trunk/pep-0263.txt (original) +++ peps/trunk/pep-0263.txt Tue Dec 19 22:04:01 2006 @@ -47,17 +47,26 @@ To define a source code encoding, a magic comment must be placed into the source files either as first or second - line in the file: + line in the file, such as: + + # coding= + + or (using formats recognized by popular editors) #!/usr/bin/python # -*- coding: -*- + or + + #!/usr/bin/python + # vim: set fileencoding= : + More precisely, the first or second line must match the regular expression "coding[:=]\s*([-\w.]+)". The first group of this expression is then interpreted as encoding name. If the encoding is unknown to Python, an error is raised during compilation. There must not be any Python statement on the line that contains the - encoding declartation. + encoding declaration. To aid with platforms such as Windows, which add Unicode BOM marks to the beginning of Unicode files, the UTF-8 signature From python-checkins at python.org Tue Dec 19 22:17:07 2006 From: python-checkins at python.org (guido.van.rossum) Date: Tue, 19 Dec 2006 22:17:07 +0100 (CET) Subject: [Python-checkins] r53085 - peps/trunk/pep-3000.txt Message-ID: <20061219211707.762ED1E4006@bag.python.org> Author: guido.van.rossum Date: Tue Dec 19 22:17:06 2006 New Revision: 53085 Modified: peps/trunk/pep-3000.txt Log: Updated timeline. Modified: peps/trunk/pep-3000.txt ============================================================================== --- peps/trunk/pep-3000.txt (original) +++ peps/trunk/pep-3000.txt Tue Dec 19 22:17:06 2006 @@ -48,10 +48,13 @@ Timeline ======== -We need a meta-PEP for the Python 3000 timeline. At this moment, I -hope to have a first alpha release out sometime in 2007; it may take -another year after that (or more) before the first proper release, -named Python 3.0. +I no longer think we need a meta-PEP for the Python 3000 timeline; +instead, here's my current proposal. I hope to have a first alpha +release (3.0a1) out in the first half of 2007; it should take no more +than a year from then before the first proper release, named Python +3.0. I would like all PEPs for features going into Python 3000 to be +submitted by the end of April 2007 (allowing time for discussion and +implementation after the initial submission). I expect that there will be parallel Python 2.x and 3.x releases for some time; the Python 2.x releases will continue for a longer time @@ -63,9 +66,9 @@ continued 2.x support, acceptance and stability of 3.0, and volunteer stamina. -It's quite possible that Python 3.1 and 3.2 will be released much -sooner after 3.0 than has been customary for the 2.x series. The 3.x -release pattern will stabilize once the community is happy with 3.x. +I expect that Python 3.1 and 3.2 will be released much sooner after +3.0 than has been customary for the 2.x series. The 3.x release +pattern will stabilize once the community is happy with 3.x. Compatibility and Transition From python-checkins at python.org Tue Dec 19 22:20:00 2006 From: python-checkins at python.org (guido.van.rossum) Date: Tue, 19 Dec 2006 22:20:00 +0100 (CET) Subject: [Python-checkins] r53086 - peps/trunk/pep-3100.txt Message-ID: <20061219212000.AB63E1E4006@bag.python.org> Author: guido.van.rossum Date: Tue Dec 19 22:20:00 2006 New Revision: 53086 Modified: peps/trunk/pep-3100.txt Log: add a link to PEP 3105 for print function call. Modified: peps/trunk/pep-3100.txt ============================================================================== --- peps/trunk/pep-3100.txt (original) +++ peps/trunk/pep-3100.txt Tue Dec 19 22:20:00 2006 @@ -67,7 +67,7 @@ * ``exec`` as a statement is not worth it -- make it a function [done] * (Maybe) add optional declarations for static typing [10]_ * Support only new-style classes; classic classes will be gone [1]_ [done] -* Replace ``print`` by a function [14]_ +* Replace ``print`` by a function [14]_ [#pep3105]_ * Use ``except E1, E2, E3 as err:`` if you want the error variable. [3]_ * ``None`` becomes a keyword [4]_ (What about ``True``, ``False``?) * ``...`` to become a general expression element [16]_ [done] @@ -355,6 +355,8 @@ .. [#pep3099] PEP 3099 (Things that will Not Change in Python 3000) http://www.python.org/dev/peps/pep-3099 +.. [#pep3105] PEP 3105 (Make print a function) + http://www.python.org/dev/peps/pep-3105 Copyright From python-checkins at python.org Tue Dec 19 22:43:54 2006 From: python-checkins at python.org (georg.brandl) Date: Tue, 19 Dec 2006 22:43:54 +0100 (CET) Subject: [Python-checkins] r53088 - in sandbox/trunk/2to3: example.py fixes/fix_intern.py Message-ID: <20061219214354.A44961E4006@bag.python.org> Author: georg.brandl Date: Tue Dec 19 22:43:54 2006 New Revision: 53088 Added: sandbox/trunk/2to3/fixes/fix_intern.py Modified: sandbox/trunk/2to3/example.py Log: Add intern() fixer (patch #1619049). Modified: sandbox/trunk/2to3/example.py ============================================================================== --- sandbox/trunk/2to3/example.py (original) +++ sandbox/trunk/2to3/example.py Tue Dec 19 22:43:54 2006 @@ -73,6 +73,29 @@ apply(f, args=args, kwds=kwds) apply(f, args, kwds=kwds) +def intern_examples(): + # + # These should be refactored: + # + x = intern(a) + # + y = intern("b" # test + ) + # + z = intern(a+b+c.d,) + # + intern("y%s" % 5).replace("y", "") + # + # These not: + # + intern(a=1) + # + intern(f, g) + # + intern(*h) + # + intern(**i) + def print_examples(): # plain vanilla print 1, 1+1, 1+1+1 Added: sandbox/trunk/2to3/fixes/fix_intern.py ============================================================================== --- (empty file) +++ sandbox/trunk/2to3/fixes/fix_intern.py Tue Dec 19 22:43:54 2006 @@ -0,0 +1,61 @@ +# Copyright 2006 Georg Brandl. +# Licensed to PSF under a Contributor Agreement. + +"""Fixer for intern().""" + +# Python imports +import token + +# Local imports +import pytree +import patcomp +import pygram + +syms = pygram.python_symbols +pat_compile = patcomp.PatternCompiler().compile_pattern + +PATTERN = """ +power< 'intern' + trailer< lpar='(' + ( not(arglist | argument) any ','> ) + rpar=')' > + after=any* +> +""" + + +class FixIntern(object): + + def __init__(self, options): + self.options = options + self.pattern = pat_compile(PATTERN) + + def match(self, node): + results = {} + return self.pattern.match(node, results) and results + + def transform(self, node): + results = self.match(node) + assert results + obj = results["obj"].clone() + if obj.type == syms.arglist: + newarglist = obj.clone() + else: + newarglist = pytree.Node(syms.arglist, [obj.clone()]) + after = results["after"] + if after: + after = tuple(n.clone() for n in after) + new = pytree.Node(syms.power, + (pytree.Leaf(token.NAME, "sys"), + pytree.Node(syms.trailer, + [pytree.Leaf(token.DOT, "."), + pytree.Leaf(token.NAME, "intern")]), + pytree.Node(syms.trailer, + [results["lpar"].clone(), + newarglist, + results["rpar"].clone()])) + + after) + new.set_prefix(node.get_prefix()) + return new + From python-checkins at python.org Tue Dec 19 23:06:47 2006 From: python-checkins at python.org (georg.brandl) Date: Tue, 19 Dec 2006 23:06:47 +0100 (CET) Subject: [Python-checkins] r53090 - in python/trunk: Doc/lib/libtarfile.tex Lib/tarfile.py Misc/NEWS Message-ID: <20061219220647.67EC41E4010@bag.python.org> Author: georg.brandl Date: Tue Dec 19 23:06:46 2006 New Revision: 53090 Modified: python/trunk/Doc/lib/libtarfile.tex python/trunk/Lib/tarfile.py python/trunk/Misc/NEWS Log: Patch #1484695: The tarfile module now raises a HeaderError exception if a buffer given to frombuf() is invalid. Modified: python/trunk/Doc/lib/libtarfile.tex ============================================================================== --- python/trunk/Doc/lib/libtarfile.tex (original) +++ python/trunk/Doc/lib/libtarfile.tex Tue Dec 19 23:06:46 2006 @@ -124,6 +124,11 @@ only if \member{TarFile.errorlevel}\code{ == 2}. \end{excdesc} +\begin{excdesc}{HeaderError} + Is raised by \method{frombuf()} if the buffer it gets is invalid. + \versionadded{2.6} +\end{excdesc} + \begin{seealso} \seemodule{zipfile}{Documentation of the \refmodule{zipfile} standard module.} @@ -332,6 +337,8 @@ \begin{methoddesc}{frombuf}{} Create and return a \class{TarInfo} object from a string buffer. + \versionadded[Raises \exception{HeaderError} if the buffer is + invalid.]{2.6} \end{methoddesc} \begin{methoddesc}{tobuf}{posix} Modified: python/trunk/Lib/tarfile.py ============================================================================== --- python/trunk/Lib/tarfile.py (original) +++ python/trunk/Lib/tarfile.py Tue Dec 19 23:06:46 2006 @@ -280,6 +280,9 @@ class StreamError(TarError): """Exception for unsupported operations on stream-like TarFiles.""" pass +class HeaderError(TarError): + """Exception for invalid headers.""" + pass #--------------------------- # internal stream interface @@ -819,9 +822,17 @@ """Construct a TarInfo object from a 512 byte string buffer. """ if len(buf) != BLOCKSIZE: - raise ValueError("truncated header") + raise HeaderError("truncated header") if buf.count(NUL) == BLOCKSIZE: - raise ValueError("empty header") + raise HeaderError("empty header") + + try: + chksum = nti(buf[148:156]) + except ValueError: + raise HeaderError("invalid header") + + if chksum not in calc_chksums(buf): + raise HeaderError("bad checksum") tarinfo = cls() tarinfo.buf = buf @@ -831,7 +842,7 @@ tarinfo.gid = nti(buf[116:124]) tarinfo.size = nti(buf[124:136]) tarinfo.mtime = nti(buf[136:148]) - tarinfo.chksum = nti(buf[148:156]) + tarinfo.chksum = chksum tarinfo.type = buf[156:157] tarinfo.linkname = buf[157:257].rstrip(NUL) tarinfo.uname = buf[265:297].rstrip(NUL) @@ -843,8 +854,6 @@ if prefix and not tarinfo.issparse(): tarinfo.name = prefix + "/" + tarinfo.name - if tarinfo.chksum not in calc_chksums(buf): - raise ValueError("invalid header") return tarinfo def tobuf(self, posix=False): @@ -1793,16 +1802,14 @@ tarinfo = self.proc_member(tarinfo) - except ValueError, e: + except HeaderError, e: if self.ignore_zeros: - self._dbg(2, "0x%X: empty or invalid block: %s" % - (self.offset, e)) + self._dbg(2, "0x%X: %s" % (self.offset, e)) self.offset += BLOCKSIZE continue else: if self.offset == 0: - raise ReadError("empty, unreadable or compressed " - "file: %s" % e) + raise ReadError(str(e)) return None break Modified: python/trunk/Misc/NEWS ============================================================================== --- python/trunk/Misc/NEWS (original) +++ python/trunk/Misc/NEWS Tue Dec 19 23:06:46 2006 @@ -101,6 +101,9 @@ Library ------- +- Patch #1484695: The tarfile module now raises a HeaderError exception + if a buffer given to frombuf() is invalid. + - Bug #1503765: Fix a problem in logging.config with spaces in comma- separated lists read from logging config files. From python-checkins at python.org Wed Dec 20 02:18:47 2006 From: python-checkins at python.org (brett.cannon) Date: Wed, 20 Dec 2006 02:18:47 +0100 (CET) Subject: [Python-checkins] r53091 - sandbox/trunk/import_in_py/importbench.py Message-ID: <20061220011847.3F3C31E4006@bag.python.org> Author: brett.cannon Date: Wed Dec 20 02:18:46 2006 New Revision: 53091 Modified: sandbox/trunk/import_in_py/importbench.py Log: Change argument order for repetitions and iterations so that it matches timeit.Timer.repeat . Modified: sandbox/trunk/import_in_py/importbench.py ============================================================================== --- sandbox/trunk/import_in_py/importbench.py (original) +++ sandbox/trunk/import_in_py/importbench.py Wed Dec 20 02:18:46 2006 @@ -18,7 +18,6 @@ its own benchmark. """ -#XXX make sure all code goes repetitions, iterations (and probably with those names). from py_compile import compile as compile_to_pyc import os import StringIO @@ -91,7 +90,7 @@ @save_import_state -def bench_sys_modules(times, repeat): +def bench_sys_modules(repetitions, iterations): """Benchmark returning a module from sys.modules.""" sys.path = [] sys.meta_path = [] @@ -100,10 +99,10 @@ # Force the module into sys.modules . __import__(file_state.module_name, {}) timer = Timer("__import__(%r, {}, {}, [], 0)" % file_state.module_name) - return timer.repeat(repeat, times) + return timer.repeat(repetitions, iterations) @save_import_state -def bench_nonexistent_module(times, repeat): +def bench_nonexistent_module(repetitions, iterations): """How expensive is an import failure (with a single entry on sys.path)?""" # Verify that the module does not exist. sys.path = [] @@ -120,16 +119,16 @@ raise Exception("supposed non-existent module actually exists") timer = Timer("try:__import__(%r, {}, {}, [], 0)\nexcept ImportError:pass" % bad_name) - return timer.repeat(repeat, times) + return timer.repeat(repetitions, iterations) def py_pyc_module_benchmark(py, pyc): @save_import_state - def inner(times, repeat): + def inner(repetitions, iterations): sys.path = [] sys.meta_path = [] with PyPycFiles(py, pyc) as file_state: timer = import_and_clear_timer(file_state.module_name) - return timer.repeat(repeat, times) + return timer.repeat(repetitions, iterations) return inner bench_pyc_with_py = py_pyc_module_benchmark(py=True, pyc=True) @@ -137,15 +136,15 @@ bench_py_without_pyc = py_pyc_module_benchmark(py=True, pyc=False) @save_import_state -def bench_builtins(times, repeat): +def bench_builtins(repetitions, iterations): """Benchmark the importation of a built-in module.""" sys.meta_path = [] sys.path = [] timer = import_and_clear_timer('xxsubtype') - return timer.repeat(repeat, times) + return timer.repeat(repetitions, iterations) @save_import_state -def bench_frozen(times, repeat): +def bench_frozen(repetitions, iterations): """Benchmark the importing of frozen modules.""" sys.path = [] sys.meta_path = [] @@ -153,12 +152,12 @@ sys.stdout = StringIO.StringIO() try: timer = import_and_clear_timer('__hello__') - return timer.repeat(repeat, times) + return timer.repeat(repetitions, iterations) finally: sys.stdout = sys.__stdout__ @save_import_state -def bench_extension(times, repeat): +def bench_extension(repetitions, iterations): """Benchmark the importing of an extension module.""" # Choose an extension module that is always included with Python. module = 'datetime' @@ -168,11 +167,11 @@ sys.meta_path = [] sys.path = [directory] timer = import_and_clear_timer(module) - return timer.repeat(repeat, times) + return timer.repeat(repetitions, iterations) -def display_results(fxn, name, spacing, repeat, times): - timings = fxn(times, repeat) +def display_results(fxn, name, spacing, repetitions, iterations): + timings = fxn(repetitions, iterations) print "%s %s" % (name.ljust(spacing), [int(result*1000) for result in timings]) From python-checkins at python.org Wed Dec 20 02:32:15 2006 From: python-checkins at python.org (brett.cannon) Date: Wed, 20 Dec 2006 02:32:15 +0100 (CET) Subject: [Python-checkins] r53092 - sandbox/trunk/import_in_py/importbench.py Message-ID: <20061220013215.A70CE1E4006@bag.python.org> Author: brett.cannon Date: Wed Dec 20 02:32:14 2006 New Revision: 53092 Modified: sandbox/trunk/import_in_py/importbench.py Log: Benchmark cost of having a large number of entries in sys.path that do not have the requested module. Modified: sandbox/trunk/import_in_py/importbench.py ============================================================================== --- sandbox/trunk/import_in_py/importbench.py (original) +++ sandbox/trunk/import_in_py/importbench.py Wed Dec 20 02:32:14 2006 @@ -168,6 +168,22 @@ sys.path = [directory] timer = import_and_clear_timer(module) return timer.repeat(repetitions, iterations) + + at save_import_state +def bench_long_sys_path(repetitions, iterations, extra_path_entries=20): + """See the impact of having a large number of entries on sys.path.""" + def succeed_hook(path): + class FailImporter(object): + def find_module(name, path=None): + raise ImportError + return FailImporter() + sys.path = [] + sys.meta_path = [] + with PyPycFiles() as file_state: + for entry in xrange(extra_path_entries): + sys.path.insert(0, str(entry)+'dummy_entry') + timer = import_and_clear_timer(file_state.module_name) + return timer.repeat(repetitions, iterations) def display_results(fxn, name, spacing, repetitions, iterations): From python-checkins at python.org Wed Dec 20 02:46:51 2006 From: python-checkins at python.org (brett.cannon) Date: Wed, 20 Dec 2006 02:46:51 +0100 (CET) Subject: [Python-checkins] r53093 - sandbox/trunk/import_in_py/importbench.py Message-ID: <20061220014651.506241E4008@bag.python.org> Author: brett.cannon Date: Wed Dec 20 02:46:50 2006 New Revision: 53093 Modified: sandbox/trunk/import_in_py/importbench.py Log: Test the importation of a package. Modified: sandbox/trunk/import_in_py/importbench.py ============================================================================== --- sandbox/trunk/import_in_py/importbench.py (original) +++ sandbox/trunk/import_in_py/importbench.py Wed Dec 20 02:46:50 2006 @@ -20,6 +20,7 @@ """ from py_compile import compile as compile_to_pyc import os +from shutil import rmtree import StringIO import sys import tempfile @@ -72,14 +73,18 @@ self.directory = tempfile.gettempdir() self.py_path = os.path.join(self.directory, self.module_name + '.py') self.pyc_path = self.py_path + ('c' if __debug__ else 'o') - with open(self.py_path, 'w') as py_file: - py_file.write("# Temporary file for benchmarking import.") - if self.pyc: - compile_to_pyc(self.py_path, doraise=True) - if not self.py: - os.remove(self.py_path) - sys.path.append(self.directory) - return self + try: + with open(self.py_path, 'w') as py_file: + py_file.write("# Temporary file for benchmarking import.") + if self.pyc: + compile_to_pyc(self.py_path, doraise=True) + if not self.py: + os.remove(self.py_path) + sys.path.append(self.directory) + return self + except Exception: + self.__exit__() + raise def __exit__(self, *args): """Clean up created state.""" @@ -87,6 +92,40 @@ os.remove(self.py_path) if os.path.exists(self.pyc_path): os.remove(self.pyc_path) + +class PyPycPackage(object): + + """Create .py files for testing the importing of packages.""" + + def __init__(self, pkg_name="testpkg", module_name="testmod"): + """Specify the names for the package and module within the package.""" + self.pkg_name = pkg_name + self.module_name = module_name + + def __enter__(self): + """Create the package and module.""" + self.directory = tempfile.gettempdir() + self.pkg_path = os.path.join(self.directory, self.pkg_name) + os.mkdir(self.pkg_path) + try: + self.pkg_init_path = os.path.join(self.pkg_path, '__init__.py') + with open(self.pkg_init_path, 'w') as init_file: + init_file.write('# This file is used for benchmarking package ' + 'imports') + self.full_module_name = self.pkg_name + '.' + self.module_name + self.module_path = os.path.join(self.pkg_path, self.module_name+'.py') + with open(self.module_path, 'w') as module_file: + module_file.write('# This file is used to benchmark importing ' + 'modules in a package.') + sys.path.append(self.directory) + return self + except Exception: + self.__exit__() + raise + + def __exit__(self, *args): + """Cleanup our mess.""" + rmtree(self.pkg_path) @save_import_state @@ -171,7 +210,8 @@ @save_import_state def bench_long_sys_path(repetitions, iterations, extra_path_entries=20): - """See the impact of having a large number of entries on sys.path.""" + """See the impact of having a large number of entries on sys.path that do + not have the module.""" def succeed_hook(path): class FailImporter(object): def find_module(name, path=None): @@ -184,6 +224,16 @@ sys.path.insert(0, str(entry)+'dummy_entry') timer = import_and_clear_timer(file_state.module_name) return timer.repeat(repetitions, iterations) + + at save_import_state +def bench_package(repetitions, iterations): + """Benchmark the importing of a package.""" + sys.path = [] + sys.meta_path = [] + with PyPycPackage() as pkg_details: + timer = import_and_clear_timer(pkg_details.pkg_name) + return timer.repeat(repetitions, iterations) + def display_results(fxn, name, spacing, repetitions, iterations): From python-checkins at python.org Wed Dec 20 04:03:44 2006 From: python-checkins at python.org (guido.van.rossum) Date: Wed, 20 Dec 2006 04:03:44 +0100 (CET) Subject: [Python-checkins] r53094 - peps/trunk/pep-3106.txt Message-ID: <20061220030344.8D2E91E4006@bag.python.org> Author: guido.van.rossum Date: Wed Dec 20 04:03:44 2006 New Revision: 53094 Added: peps/trunk/pep-3106.txt (contents, props changed) Log: Not really creating the PEP, just a stub to reserve the PEP number. Added: peps/trunk/pep-3106.txt ============================================================================== --- (empty file) +++ peps/trunk/pep-3106.txt Wed Dec 20 04:03:44 2006 @@ -0,0 +1,15 @@ +PEP: 3106 +Title: Revamping dict.keys(), .values() and .items() +Version: $Revision$ +Last-Modified: $Date$ +Author: Guido van Rossum +Status: Draft +Type: Standards +Content-Type: text/x-rst +Created: 19-Dec-2006 +Post-History: + + +Abstract + + Stub to reserve the PEP number. From python-checkins at python.org Wed Dec 20 05:33:54 2006 From: python-checkins at python.org (guido.van.rossum) Date: Wed, 20 Dec 2006 05:33:54 +0100 (CET) Subject: [Python-checkins] r53095 - sandbox/trunk/2to3/refactor.py Message-ID: <20061220043354.0F3051E4006@bag.python.org> Author: guido.van.rossum Date: Wed Dec 20 05:33:53 2006 New Revision: 53095 Modified: sandbox/trunk/2to3/refactor.py Log: Fix typo reported by Neal. Modified: sandbox/trunk/2to3/refactor.py ============================================================================== --- sandbox/trunk/2to3/refactor.py (original) +++ sandbox/trunk/2to3/refactor.py Wed Dec 20 05:33:53 2006 @@ -4,7 +4,7 @@ """Refactoring framework. -Used as a main program, this can refactory any number of files and/or +Used as a main program, this can refactor any number of files and/or recursively descend down directories. Imported as a module, this provides infrastructure to write your own refactoring tool. """ From python-checkins at python.org Wed Dec 20 06:44:20 2006 From: python-checkins at python.org (guido.van.rossum) Date: Wed, 20 Dec 2006 06:44:20 +0100 (CET) Subject: [Python-checkins] r53096 - peps/trunk/pep-3106.txt Message-ID: <20061220054420.CB24D1E4006@bag.python.org> Author: guido.van.rossum Date: Wed Dec 20 06:44:20 2006 New Revision: 53096 Modified: peps/trunk/pep-3106.txt Log: Wrote the real PEP (mostly). Modified: peps/trunk/pep-3106.txt ============================================================================== --- peps/trunk/pep-3106.txt (original) +++ peps/trunk/pep-3106.txt Wed Dec 20 06:44:20 2006 @@ -11,5 +11,241 @@ Abstract +======== - Stub to reserve the PEP number. +This PEP proposes to change the .keys(), .values() and .items() +methods of the built-in dict type to return a set-like or +multiset-like object whose contents are derived of the underlying +dictionary rather than a list which is a copy of the keys, etc.; and +to remove the .iterkeys(), .itervalues() and .iteritems() methods. + +The approach is inspired by that taken in the Java Collections +Framework [1]_. + +Introduction +============ + +It has long been the plan to change the .keys(), .values() and +.items() methods of the built-in dict type to return a more +lightweight object than a list, and to get rid of .iterkeys(), +.itervalues() and .iteritems(). The idea is that code that currently +(in 2.x) reads:: + + for x in d.iterkeys(): ... + +should be rewritten as:: + + for x in d.keys(): ... + +and code that currently reads:: + + a = d.keys() # assume we really want a list here + +should be rewritten as + + a = list(d.keys()) + +There are (at least) two ways to accomplish this. The original plan +was to simply let .keys(), .values() and .items() return an iterator, +i.e. exactly what iterkeys(), itervalues() and iteritems() return +in Python 2.x. However, the Java Collections Framework [1]_ suggests +that a better solution is possible: the methods return objects with +set behavior (for .keys() and .items()) or multiset behavior (for +.values()) that do not contain copies of the keys, values or items, +but rather reference the underlying dict and pull their values out of +the dict as needed. + +The advantage of this approach is that one can still write code like +this:: + + a = d.keys() + for x in a: ... + for x in a: ... + +Effectively, iter(d.keys()) in Python 3.0 does what d.iterkeys() does +in Python 2.x; but in most contexts we don't have to write the iter() +call because it is implied by a for-loop. + +The objects returned by the .keys() and .items() methods behave like +sets with limited mutability; the allow removing elements, but not +adding them. Removing an item from these sets removes it from the +underlying dict. The object returned by the values() method behaves +like a multiset (Java calls this a Collection). It does not allow +removing elements, because a value might occur multiple times and the +implementation wouldn't know which key to remove from the underlying +dict. (The Java Collections Framework has a way around this by +removing from an iterator, but I see no practical use case for that +functionality.) + +Because of the set behavior, it will be possible to check whether two +dicts have the same keys by simply testing:: + + if a.keys() == b.keys(): ... + +and similarly for values. (Two multisets are deemed equal if they +have the same elements with the same cardinalities, +e.g. the multiset {1, 2, 2} is equal to the multiset {2, 1, 2} but +differs from the multiset {1, 2}.) + +These operations are thread-safe only to the extent that using them in +a thread-unsafe way may cause an exception but will not cause +corruption of the internal representation. + +As in Python 2.x, mutating a dict while iterating over it using an +iterator has an undefined effect and will in most cases raise a +RuntimeError exception. (This is similar to the guarantees made by +the Java Collections Framework.) + +The objects returned by .keys() and .items() are fully interoperable +with instances of the built-in set and frozenset types; for example:: + + set(d.keys()) == d.keys() + +is guaranteed to be True (except when d is being modified +simultaneously by another thread). + + +Specification +============= + +I'll try pseudo-code to specify the semantics:: + + class dict: + + # Omitting all other dict methods for brevity + + def keys(self): + return d_keys(self) + + def items(self): + return d_items(self) + + def values(self): + return d_values(self) + + class d_keys: + + def __init__(self, d): + self.__d = d + + def __len__(self): + return len(self.__d) + + def __contains__(self, key): + return key in self.__d + + def __iter__(self): + for key in self.__d: + yield key + + def remove(self, key): + del self.__d[key] + + def discard(self, key): + if key in self: + self.remove(key) + + def pop(self): + return self.__d.popitem()[0] + + def clear(self): + self.__d.clear() + + def copy(self): + return set(self) + + # The following operations should be implemented to be + # compatible with sets; this can be done by exploiting + # the above primitive operations: + # + # <, <=, ==, !=, >=, > (returning a bool) + # &, |, ^, - (returning a new, real set object) + # &=, -= (updating in place and returning self; but not |=, ^=) + # + # as well as their method counterparts (.union(), etc.). + + class d_items: + + def __init__(self, d): + self.__d = d + + def __len__(self): + return len(self.__d) + + def __contains__(self, (key, value)): + return key in self.__d and self.__d[key] == value + + def __iter__(self): + for key in self.__d: + yield key, self.__d[key] + + def remove(self, (key, value)): + del self.__d[key] + + def discard(self, item): + if item in self: + self.remove(item) + + def pop(self): + return self.__d.popitem() + + def clear(self): + self.__d.clear() + + def copy(self): + return set(self) + + # As well as the same set operations as mentioned for d_keys above. + + class d_values: + + def __init__(self, d): + self.__d = d + + def __len__(self): + return len(self.__d) + + def __contains__(self, value): + # Slow! Do we even want to implement this? + for v in self: + if v == value: + return True + return False + + def __iter__(self): + for key in self.__d: + yield self.__d[key] + + # Do we care about the following? + + def pop(self): + return self.__d.popitem()[1] + + def clear(self): + return self.__d.clear() + + def copy(self): + # XXX What should this return? + + # Should we bother implementing set-like operations on + # multisets? If so, how about mixed operations on sets and + # multisets? I'm not sure that these are worth the effort. + +I'm soliciting better names than d_keys, d_values and d_items; these +classes will be public so that their implementations may be reused by +the .keys(), .values() and .items() methods of other mappings. (Or +should they?) + + +Open Issues +=========== + +Should the d_keys, d_values and d_items classes be reusable? Should +they be subclassable? + + +References +========== + +.. [1] Java Collections Framework + http://java.sun.com/docs/books/tutorial/collections/index.html From python-checkins at python.org Wed Dec 20 07:36:16 2006 From: python-checkins at python.org (neal.norwitz) Date: Wed, 20 Dec 2006 07:36:16 +0100 (CET) Subject: [Python-checkins] r53097 - peps/trunk/pep-3106.txt Message-ID: <20061220063616.E51C21E4006@bag.python.org> Author: neal.norwitz Date: Wed Dec 20 07:36:16 2006 New Revision: 53097 Modified: peps/trunk/pep-3106.txt Log: Fix typo Modified: peps/trunk/pep-3106.txt ============================================================================== --- peps/trunk/pep-3106.txt (original) +++ peps/trunk/pep-3106.txt Wed Dec 20 07:36:16 2006 @@ -67,7 +67,7 @@ call because it is implied by a for-loop. The objects returned by the .keys() and .items() methods behave like -sets with limited mutability; the allow removing elements, but not +sets with limited mutability; they allow removing elements, but not adding them. Removing an item from these sets removes it from the underlying dict. The object returned by the values() method behaves like a multiset (Java calls this a Collection). It does not allow From python-checkins at python.org Wed Dec 20 07:40:44 2006 From: python-checkins at python.org (neal.norwitz) Date: Wed, 20 Dec 2006 07:40:44 +0100 (CET) Subject: [Python-checkins] r53098 - peps/trunk/pep-0000.txt Message-ID: <20061220064044.AAC031E4006@bag.python.org> Author: neal.norwitz Date: Wed Dec 20 07:40:44 2006 New Revision: 53098 Modified: peps/trunk/pep-0000.txt Log: Add 3106 to the index Modified: peps/trunk/pep-0000.txt ============================================================================== --- peps/trunk/pep-0000.txt (original) +++ peps/trunk/pep-0000.txt Wed Dec 20 07:40:44 2006 @@ -104,6 +104,7 @@ S 3103 A Switch/Case Statement GvR S 3104 Access to Names in Outer Scopes Yee S 3105 Make print a function Brandl + S 3106 Revamping dict.keys(), .values() and .items() GvR Finished PEPs (done, implemented in Subversion) @@ -441,6 +442,7 @@ S 3103 A Switch/Case Statement GvR S 3104 Access to Names in Outer Scopes Yee S 3105 Make print a function Brandl + S 3106 Revamping dict.keys(), .values() and .items() GvR Key From python-checkins at python.org Wed Dec 20 07:42:07 2006 From: python-checkins at python.org (raymond.hettinger) Date: Wed, 20 Dec 2006 07:42:07 +0100 (CET) Subject: [Python-checkins] r53099 - in python/trunk: Lib/random.py Lib/test/test_random.py Misc/NEWS Message-ID: <20061220064207.8D4241E4009@bag.python.org> Author: raymond.hettinger Date: Wed Dec 20 07:42:06 2006 New Revision: 53099 Modified: python/trunk/Lib/random.py python/trunk/Lib/test/test_random.py python/trunk/Misc/NEWS Log: Bug #1590891: random.randrange don't return correct value for big number Needs to be backported. Modified: python/trunk/Lib/random.py ============================================================================== --- python/trunk/Lib/random.py (original) +++ python/trunk/Lib/random.py Wed Dec 20 07:42:06 2006 @@ -205,7 +205,7 @@ raise ValueError, "empty range for randrange()" if n >= maxwidth: - return istart + self._randbelow(n) + return istart + istep*self._randbelow(n) return istart + istep*int(self.random() * n) def randint(self, a, b): Modified: python/trunk/Lib/test/test_random.py ============================================================================== --- python/trunk/Lib/test/test_random.py (original) +++ python/trunk/Lib/test/test_random.py Wed Dec 20 07:42:06 2006 @@ -438,6 +438,14 @@ self.assertEqual(k, numbits) # note the stronger assertion self.assert_(2**k > n > 2**(k-1)) # note the stronger assertion + def test_randrange_bug_1590891(self): + start = 1000000000000 + stop = -100000000000000000000 + step = -200 + x = self.gen.randrange(start, stop, step) + self.assert_(stop < x <= start) + self.assertEqual((x+stop)%step, 0) + _gammacoeff = (0.9999999999995183, 676.5203681218835, -1259.139216722289, 771.3234287757674, -176.6150291498386, 12.50734324009056, -0.1385710331296526, 0.9934937113930748e-05, 0.1659470187408462e-06) Modified: python/trunk/Misc/NEWS ============================================================================== --- python/trunk/Misc/NEWS (original) +++ python/trunk/Misc/NEWS Wed Dec 20 07:42:06 2006 @@ -12,6 +12,8 @@ Core and builtins ----------------- +- Bug #1590891: random.randrange don't return correct value for big number + - Patch #1586791: Better exception messages for some operations on strings, tuples and lists. From python-checkins at python.org Wed Dec 20 08:44:00 2006 From: python-checkins at python.org (raymond.hettinger) Date: Wed, 20 Dec 2006 08:44:00 +0100 (CET) Subject: [Python-checkins] r53100 - in python/branches/release25-maint: Lib/random.py Lib/test/test_random.py Misc/NEWS Message-ID: <20061220074400.A499E1E4006@bag.python.org> Author: raymond.hettinger Date: Wed Dec 20 08:43:59 2006 New Revision: 53100 Modified: python/branches/release25-maint/Lib/random.py python/branches/release25-maint/Lib/test/test_random.py python/branches/release25-maint/Misc/NEWS Log: Bug #1590891: random.randrange don't return correct value for big number Modified: python/branches/release25-maint/Lib/random.py ============================================================================== --- python/branches/release25-maint/Lib/random.py (original) +++ python/branches/release25-maint/Lib/random.py Wed Dec 20 08:43:59 2006 @@ -205,7 +205,7 @@ raise ValueError, "empty range for randrange()" if n >= maxwidth: - return istart + self._randbelow(n) + return istart + istep*self._randbelow(n) return istart + istep*int(self.random() * n) def randint(self, a, b): Modified: python/branches/release25-maint/Lib/test/test_random.py ============================================================================== --- python/branches/release25-maint/Lib/test/test_random.py (original) +++ python/branches/release25-maint/Lib/test/test_random.py Wed Dec 20 08:43:59 2006 @@ -439,6 +439,14 @@ self.assertEqual(k, numbits) # note the stronger assertion self.assert_(2**k > n > 2**(k-1)) # note the stronger assertion + def test_randrange_bug_1590891(self): + start = 1000000000000 + stop = -100000000000000000000 + step = -200 + x = self.gen.randrange(start, stop, step) + self.assert_(stop < x <= start) + self.assertEqual((x+stop)%step, 0) + _gammacoeff = (0.9999999999995183, 676.5203681218835, -1259.139216722289, 771.3234287757674, -176.6150291498386, 12.50734324009056, -0.1385710331296526, 0.9934937113930748e-05, 0.1659470187408462e-06) Modified: python/branches/release25-maint/Misc/NEWS ============================================================================== --- python/branches/release25-maint/Misc/NEWS (original) +++ python/branches/release25-maint/Misc/NEWS Wed Dec 20 08:43:59 2006 @@ -12,6 +12,8 @@ Core and builtins ----------------- +- Bug #1590891: random.randrange don't return correct value for big number + - Bug #1456209: In some obscure cases it was possible for a class with a custom ``__eq__()`` method to confuse set internals when class instances were used as a set's elements and the ``__eq__()`` method mutated the set. From python-checkins at python.org Wed Dec 20 09:23:40 2006 From: python-checkins at python.org (raymond.hettinger) Date: Wed, 20 Dec 2006 09:23:40 +0100 (CET) Subject: [Python-checkins] r53101 - in python/branches/release24-maint: Lib/random.py Misc/NEWS Message-ID: <20061220082340.485B91E4012@bag.python.org> Author: raymond.hettinger Date: Wed Dec 20 09:23:39 2006 New Revision: 53101 Modified: python/branches/release24-maint/Lib/random.py python/branches/release24-maint/Misc/NEWS Log: Bug #1590891: random.randrange don't return correct value for big number Modified: python/branches/release24-maint/Lib/random.py ============================================================================== --- python/branches/release24-maint/Lib/random.py (original) +++ python/branches/release24-maint/Lib/random.py Wed Dec 20 09:23:39 2006 @@ -205,7 +205,7 @@ raise ValueError, "empty range for randrange()" if n >= maxwidth: - return istart + self._randbelow(n) + return istart + istep*self._randbelow(n) return istart + istep*int(self.random() * n) def randint(self, a, b): Modified: python/branches/release24-maint/Misc/NEWS ============================================================================== --- python/branches/release24-maint/Misc/NEWS (original) +++ python/branches/release24-maint/Misc/NEWS Wed Dec 20 09:23:39 2006 @@ -13,6 +13,8 @@ Core and builtins ----------------- +- Bug #1590891: random.randrange don't return correct value for big number + - Bug #1542016: make sys.callstats() match its docstring and return an 11-tuple (only relevant when Python is compiled with -DCALL_PROFILE). From python-checkins at python.org Wed Dec 20 12:55:17 2006 From: python-checkins at python.org (georg.brandl) Date: Wed, 20 Dec 2006 12:55:17 +0100 (CET) Subject: [Python-checkins] r53106 - in python/trunk/Lib: tarfile.py test/test_tarfile.py Message-ID: <20061220115517.9F42A1E400A@bag.python.org> Author: georg.brandl Date: Wed Dec 20 12:55:16 2006 New Revision: 53106 Modified: python/trunk/Lib/tarfile.py python/trunk/Lib/test/test_tarfile.py Log: Testcase for patch #1484695. Modified: python/trunk/Lib/tarfile.py ============================================================================== --- python/trunk/Lib/tarfile.py (original) +++ python/trunk/Lib/tarfile.py Wed Dec 20 12:55:16 2006 @@ -145,7 +145,10 @@ # There are two possible encodings for a number field, see # itn() below. if s[0] != chr(0200): - n = int(s.rstrip(NUL + " ") or "0", 8) + try: + n = int(s.rstrip(NUL + " ") or "0", 8) + except ValueError: + raise HeaderError("invalid header") else: n = 0L for i in xrange(len(s) - 1): @@ -826,11 +829,7 @@ if buf.count(NUL) == BLOCKSIZE: raise HeaderError("empty header") - try: - chksum = nti(buf[148:156]) - except ValueError: - raise HeaderError("invalid header") - + chksum = nti(buf[148:156]) if chksum not in calc_chksums(buf): raise HeaderError("bad checksum") Modified: python/trunk/Lib/test/test_tarfile.py ============================================================================== --- python/trunk/Lib/test/test_tarfile.py (original) +++ python/trunk/Lib/test/test_tarfile.py Wed Dec 20 12:55:16 2006 @@ -601,6 +601,28 @@ self.assertEqual(tarfile.filemode(0755), '-rwxr-xr-x') self.assertEqual(tarfile.filemode(07111), '---s--s--t') +class HeaderErrorTest(unittest.TestCase): + + def test_truncated_header(self): + self.assertRaises(tarfile.HeaderError, tarfile.TarInfo.frombuf, "") + self.assertRaises(tarfile.HeaderError, tarfile.TarInfo.frombuf, "filename\0") + self.assertRaises(tarfile.HeaderError, tarfile.TarInfo.frombuf, "\0" * 511) + self.assertRaises(tarfile.HeaderError, tarfile.TarInfo.frombuf, "\0" * 513) + + def test_empty_header(self): + self.assertRaises(tarfile.HeaderError, tarfile.TarInfo.frombuf, "\0" * 512) + + def test_invalid_header(self): + buf = tarfile.TarInfo("filename").tobuf() + buf = buf[:148] + "foo\0\0\0\0\0" + buf[156:] # invalid number field. + self.assertRaises(tarfile.HeaderError, tarfile.TarInfo.frombuf, buf) + + def test_bad_checksum(self): + buf = tarfile.TarInfo("filename").tobuf() + b = buf[:148] + " " + buf[156:] # clear the checksum field. + self.assertRaises(tarfile.HeaderError, tarfile.TarInfo.frombuf, b) + b = "a" + buf[1:] # manipulate the buffer, so checksum won't match. + self.assertRaises(tarfile.HeaderError, tarfile.TarInfo.frombuf, b) if bz2: # Bzip2 TestCases @@ -646,6 +668,7 @@ tests = [ FileModeTest, + HeaderErrorTest, ReadTest, ReadStreamTest, ReadDetectTest, From buildbot at python.org Wed Dec 20 14:09:07 2006 From: buildbot at python.org (buildbot at python.org) Date: Wed, 20 Dec 2006 13:09:07 +0000 Subject: [Python-checkins] buildbot warnings in x86 Ubuntu edgy (icc) trunk Message-ID: <20061220130907.67AA71E4008@bag.python.org> The Buildbot has detected a new failure of x86 Ubuntu edgy (icc) trunk. Full details are available at: http://www.python.org/dev/buildbot/all/x86%2520Ubuntu%2520edgy%2520%2528icc%2529%2520trunk/builds/1122 Buildbot URL: http://www.python.org/dev/buildbot/all/ Build Reason: Build Source Stamp: [branch trunk] HEAD Blamelist: georg.brandl Build had warnings: warnings test Excerpt from the test logfile: 1 test failed: test_urllibnet sincerely, -The Buildbot From python-checkins at python.org Wed Dec 20 19:49:38 2006 From: python-checkins at python.org (brett.cannon) Date: Wed, 20 Dec 2006 19:49:38 +0100 (CET) Subject: [Python-checkins] r53109 - sandbox/trunk/import_in_py/importbench.py Message-ID: <20061220184938.095ED1E400E@bag.python.org> Author: brett.cannon Date: Wed Dec 20 19:49:37 2006 New Revision: 53109 Modified: sandbox/trunk/import_in_py/importbench.py Log: Add a benchmark for importing a module in a package. Modified: sandbox/trunk/import_in_py/importbench.py ============================================================================== --- sandbox/trunk/import_in_py/importbench.py (original) +++ sandbox/trunk/import_in_py/importbench.py Wed Dec 20 19:49:37 2006 @@ -234,6 +234,18 @@ timer = import_and_clear_timer(pkg_details.pkg_name) return timer.repeat(repetitions, iterations) + at save_import_state +def bench_module_in_package(repetitions, iterations): + """Benchmark importing a module that is contained within a package.""" + sys.path = [] + sys.meta_path = [] + with PyPycPackage() as pkg_details: + # Import the package first to prime sys.modules. + __import__(pkg_details.pkg_name, {}, {}, [], 0) + # Shouldn't have to worry about attribute pre-existing on the package + # for the module. It should get reset by the import. + timer = import_and_clear_timer(pkg_details.full_module_name) + return timer.repeat(repetitions, iterations) def display_results(fxn, name, spacing, repetitions, iterations): From python-checkins at python.org Wed Dec 20 20:48:20 2006 From: python-checkins at python.org (andrew.kuchling) Date: Wed, 20 Dec 2006 20:48:20 +0100 (CET) Subject: [Python-checkins] r53110 - python/trunk/Lib/mailbox.py Message-ID: <20061220194820.ED8DD1E4008@bag.python.org> Author: andrew.kuchling Date: Wed Dec 20 20:48:20 2006 New Revision: 53110 Modified: python/trunk/Lib/mailbox.py Log: [Apply length-checking.diff from bug #1599254] Add length checking to single-file mailbox formats: before doing a flush() on a mailbox, seek to the end and verify its length is unchanged, raising ExternalClashError if the file's length has changed. This fix avoids potential data loss if some other process appends to the mailbox file after the table of contents has been generated; instead of overwriting the modified file, you'll get the exception. I also noticed that the self._lookup() call in self.flush() wasn't necessary (everything that sets self._pending to True also calls self.lookup()), and replaced it by an assertion. 2.5 backport candidate. Modified: python/trunk/Lib/mailbox.py ============================================================================== --- python/trunk/Lib/mailbox.py (original) +++ python/trunk/Lib/mailbox.py Wed Dec 20 20:48:20 2006 @@ -513,6 +513,7 @@ self._next_key = 0 self._pending = False # No changes require rewriting the file. self._locked = False + self._file_length = None # Used to record mailbox size def add(self, message): """Add message and return assigned key.""" @@ -566,7 +567,21 @@ """Write any pending changes to disk.""" if not self._pending: return - self._lookup() + + # In order to be writing anything out at all, self._toc must + # already have been generated (and presumably has been modified + # by adding or deleting an item). + assert self._toc is not None + + # Check length of self._file; if it's changed, some other process + # has modified the mailbox since we scanned it. + self._file.seek(0, 2) + cur_len = self._file.tell() + if cur_len != self._file_length: + raise ExternalClashError('Size of mailbox file changed ' + '(expected %i, found %i)' % + (self._file_length, cur_len)) + new_file = _create_temporary(self._path) try: new_toc = {} @@ -642,6 +657,7 @@ offsets = self._install_message(message) self._post_message_hook(self._file) self._file.flush() + self._file_length = self._file.tell() # Record current length of mailbox return offsets @@ -733,6 +749,7 @@ break self._toc = dict(enumerate(zip(starts, stops))) self._next_key = len(self._toc) + self._file_length = self._file.tell() class MMDF(_mboxMMDF): @@ -776,6 +793,8 @@ break self._toc = dict(enumerate(zip(starts, stops))) self._next_key = len(self._toc) + self._file.seek(0, 2) + self._file_length = self._file.tell() class MH(Mailbox): @@ -1201,7 +1220,9 @@ self._toc = dict(enumerate(zip(starts, stops))) self._labels = dict(enumerate(label_lists)) self._next_key = len(self._toc) - + self._file.seek(0, 2) + self._file_length = self._file.tell() + def _pre_mailbox_hook(self, f): """Called before writing the mailbox to file f.""" f.write('BABYL OPTIONS:%sVersion: 5%sLabels:%s%s\037' % From python-checkins at python.org Wed Dec 20 20:57:10 2006 From: python-checkins at python.org (andrew.kuchling) Date: Wed, 20 Dec 2006 20:57:10 +0100 (CET) Subject: [Python-checkins] r53112 - python/trunk/Doc/lib/libfuncs.tex Message-ID: <20061220195710.F3D6E1E4010@bag.python.org> Author: andrew.kuchling Date: Wed Dec 20 20:57:10 2006 New Revision: 53112 Modified: python/trunk/Doc/lib/libfuncs.tex Log: [Bug #1619674] Make sum() use the term iterable, not sequence Modified: python/trunk/Doc/lib/libfuncs.tex ============================================================================== --- python/trunk/Doc/lib/libfuncs.tex (original) +++ python/trunk/Doc/lib/libfuncs.tex Wed Dec 20 20:57:10 2006 @@ -1087,11 +1087,11 @@ string, \code{''}. \end{funcdesc} -\begin{funcdesc}{sum}{sequence\optional{, start}} - Sums \var{start} and the items of a \var{sequence}, from left to - right, and returns the total. \var{start} defaults to \code{0}. - The \var{sequence}'s items are normally numbers, and are not allowed - to be strings. The fast, correct way to concatenate sequence of +\begin{funcdesc}{sum}{iterable\optional{, start}} + Sums \var{start} and the items of an \var{iterable} from left to + right and returns the total. \var{start} defaults to \code{0}. + The \var{iterable}'s items are normally numbers, and are not allowed + to be strings. The fast, correct way to concatenate a sequence of strings is by calling \code{''.join(\var{sequence})}. Note that \code{sum(range(\var{n}), \var{m})} is equivalent to \code{reduce(operator.add, range(\var{n}), \var{m})} From python-checkins at python.org Wed Dec 20 20:58:11 2006 From: python-checkins at python.org (andrew.kuchling) Date: Wed, 20 Dec 2006 20:58:11 +0100 (CET) Subject: [Python-checkins] r53113 - python/trunk/Doc/lib/liburlparse.tex Message-ID: <20061220195811.D38D31E4008@bag.python.org> Author: andrew.kuchling Date: Wed Dec 20 20:58:11 2006 New Revision: 53113 Modified: python/trunk/Doc/lib/liburlparse.tex Log: Two grammar fixes Modified: python/trunk/Doc/lib/liburlparse.tex ============================================================================== --- python/trunk/Doc/lib/liburlparse.tex (original) +++ python/trunk/Doc/lib/liburlparse.tex Wed Dec 20 20:58:11 2006 @@ -89,7 +89,7 @@ \begin{funcdesc}{urlunparse}{parts} Construct a URL from a tuple as returned by \code{urlparse()}. -The \var{parts} argument be any six-item iterable. +The \var{parts} argument can be any six-item iterable. This may result in a slightly different, but equivalent URL, if the URL that was parsed originally had unnecessary delimiters (for example, a ? with an empty query; the RFC states that these are equivalent). @@ -133,7 +133,7 @@ \begin{funcdesc}{urlunsplit}{parts} Combine the elements of a tuple as returned by \function{urlsplit()} into a complete URL as a string. -The \var{parts} argument be any five-item iterable. +The \var{parts} argument can be any five-item iterable. This may result in a slightly different, but equivalent URL, if the URL that was parsed originally had unnecessary delimiters (for example, a ? with an empty query; the RFC states that these are equivalent). From python-checkins at python.org Wed Dec 20 20:58:18 2006 From: python-checkins at python.org (andrew.kuchling) Date: Wed, 20 Dec 2006 20:58:18 +0100 (CET) Subject: [Python-checkins] r53114 - python/branches/release25-maint/Doc/lib/liburlparse.tex Message-ID: <20061220195818.00B6F1E4009@bag.python.org> Author: andrew.kuchling Date: Wed Dec 20 20:58:18 2006 New Revision: 53114 Modified: python/branches/release25-maint/Doc/lib/liburlparse.tex Log: Two grammar fixes Modified: python/branches/release25-maint/Doc/lib/liburlparse.tex ============================================================================== --- python/branches/release25-maint/Doc/lib/liburlparse.tex (original) +++ python/branches/release25-maint/Doc/lib/liburlparse.tex Wed Dec 20 20:58:18 2006 @@ -89,7 +89,7 @@ \begin{funcdesc}{urlunparse}{parts} Construct a URL from a tuple as returned by \code{urlparse()}. -The \var{parts} argument be any six-item iterable. +The \var{parts} argument can be any six-item iterable. This may result in a slightly different, but equivalent URL, if the URL that was parsed originally had unnecessary delimiters (for example, a ? with an empty query; the RFC states that these are equivalent). @@ -133,7 +133,7 @@ \begin{funcdesc}{urlunsplit}{parts} Combine the elements of a tuple as returned by \function{urlsplit()} into a complete URL as a string. -The \var{parts} argument be any five-item iterable. +The \var{parts} argument can be any five-item iterable. This may result in a slightly different, but equivalent URL, if the URL that was parsed originally had unnecessary delimiters (for example, a ? with an empty query; the RFC states that these are equivalent). From python-checkins at python.org Wed Dec 20 21:11:13 2006 From: python-checkins at python.org (andrew.kuchling) Date: Wed, 20 Dec 2006 21:11:13 +0100 (CET) Subject: [Python-checkins] r53115 - python/trunk/Doc/lib/libfuncs.tex Message-ID: <20061220201113.786E11E4008@bag.python.org> Author: andrew.kuchling Date: Wed Dec 20 21:11:12 2006 New Revision: 53115 Modified: python/trunk/Doc/lib/libfuncs.tex Log: Some other built-in functions are described with 'sequence' arguments that should really be 'iterable'; this commit changes them. Did I miss any? Did I introduce any errors? Modified: python/trunk/Doc/lib/libfuncs.tex ============================================================================== --- python/trunk/Doc/lib/libfuncs.tex (original) +++ python/trunk/Doc/lib/libfuncs.tex Wed Dec 20 21:11:12 2006 @@ -237,11 +237,11 @@ \code{del \var{x}.\var{foobar}}. \end{funcdesc} -\begin{funcdesc}{dict}{\optional{mapping-or-sequence}} +\begin{funcdesc}{dict}{\optional{arg}} Return a new dictionary initialized from an optional positional argument or from a set of keyword arguments. If no arguments are given, return a new empty dictionary. - If the positional argument is a mapping object, return a dictionary + If the positional argument \var{arg} is a mapping object, return a dictionary mapping the same keys to the same values as does the mapping object. Otherwise the positional argument must be a sequence, a container that supports iteration, or an iterator object. The elements of the argument @@ -414,18 +414,18 @@ \versionadded{2.2} \end{funcdesc} -\begin{funcdesc}{filter}{function, list} - Construct a list from those elements of \var{list} for which - \var{function} returns true. \var{list} may be either a sequence, a - container which supports iteration, or an iterator, If \var{list} +\begin{funcdesc}{filter}{function, iterable} + Construct a list from those elements of \var{iterable} for which + \var{function} returns true. \var{iterable} may be either a sequence, a + container which supports iteration, or an iterator, If \var{iterable} is a string or a tuple, the result also has that type; otherwise it is always a list. If \var{function} is \code{None}, the identity function is assumed, that is, all elements of - \var{list} that are false are removed. + \var{iterable} that are false are removed. - Note that \code{filter(function, \var{list})} is equivalent to - \code{[item for item in \var{list} if function(item)]} if function is - not \code{None} and \code{[item for item in \var{list} if item]} if + Note that \code{filter(function, \var{iterable})} is equivalent to + \code{[item for item in \var{iterable} if function(item)]} if function is + not \code{None} and \code{[item for item in \var{iterable} if item]} if function is \code{None}. \end{funcdesc} @@ -591,12 +591,12 @@ may be a sequence (string, tuple or list) or a mapping (dictionary). \end{funcdesc} -\begin{funcdesc}{list}{\optional{sequence}} +\begin{funcdesc}{list}{\optional{iterable}} Return a list whose items are the same and in the same order as - \var{sequence}'s items. \var{sequence} may be either a sequence, a + \var{iterable}'s items. \var{iterable} may be either a sequence, a container that supports iteration, or an iterator object. If - \var{sequence} is already a list, a copy is made and returned, - similar to \code{\var{sequence}[:]}. For instance, + \var{iterable} is already a list, a copy is made and returned, + similar to \code{\var{iterable}[:]}. For instance, \code{list('abc')} returns \code{['a', 'b', 'c']} and \code{list( (1, 2, 3) )} returns \code{[1, 2, 3]}. If no argument is given, returns a new empty list, \code{[]}. @@ -622,22 +622,22 @@ are given, returns \code{0L}. \end{funcdesc} -\begin{funcdesc}{map}{function, list, ...} - Apply \var{function} to every item of \var{list} and return a list - of the results. If additional \var{list} arguments are passed, +\begin{funcdesc}{map}{function, iterable, ...} + Apply \var{function} to every item of \var{iterable} and return a list + of the results. If additional \var{iterable} arguments are passed, \var{function} must take that many arguments and is applied to the - items of all lists in parallel; if a list is shorter than another it + items from all iterables in parallel. If one iterable is shorter than another it is assumed to be extended with \code{None} items. If \var{function} is \code{None}, the identity function is assumed; if there are - multiple list arguments, \function{map()} returns a list consisting - of tuples containing the corresponding items from all lists (a kind - of transpose operation). The \var{list} arguments may be any kind - of sequence; the result is always a list. + multiple arguments, \function{map()} returns a list consisting + of tuples containing the corresponding items from all iterables (a kind + of transpose operation). The \var{iterable} arguments may be a sequence + or any iterable object; the result is always a list. \end{funcdesc} -\begin{funcdesc}{max}{s\optional{, args...}\optional{key}} - With a single argument \var{s}, return the largest item of a - non-empty sequence (such as a string, tuple or list). With more +\begin{funcdesc}{max}{iterable\optional{, args...}\optional{key}} + With a single argument \var{iterable}, return the largest item of a + non-empty iterable (such as a string, tuple or list). With more than one argument, return the largest of the arguments. The optional \var{key} argument specifies a one-argument ordering @@ -647,16 +647,16 @@ \versionchanged[Added support for the optional \var{key} argument]{2.5} \end{funcdesc} -\begin{funcdesc}{min}{s\optional{, args...}\optional{key}} - With a single argument \var{s}, return the smallest item of a - non-empty sequence (such as a string, tuple or list). With more +\begin{funcdesc}{min}{iterable\optional{, args...}\optional{key}} + With a single argument \var{iterable}, return the smallest item of a + non-empty iterable (such as a string, tuple or list). With more than one argument, return the smallest of the arguments. The optional \var{key} argument specifies a one-argument ordering function like that used for \method{list.sort()}. The \var{key} argument, if supplied, must be in keyword form (for example, \samp{min(a,b,c,key=func)}). - \versionchanged[Added support for the optional \var{key} argument]{2.5} + \versionchanged[Added support for the optional \var{key} argument]{2.5} \end{funcdesc} \begin{funcdesc}{object}{} @@ -871,17 +871,17 @@ line editing and history features. \end{funcdesc} -\begin{funcdesc}{reduce}{function, sequence\optional{, initializer}} +\begin{funcdesc}{reduce}{function, iterable\optional{, initializer}} Apply \var{function} of two arguments cumulatively to the items of - \var{sequence}, from left to right, so as to reduce the sequence to + \var{iterable}, from left to right, so as to reduce the iterable to a single value. For example, \code{reduce(lambda x, y: x+y, [1, 2, 3, 4, 5])} calculates \code{((((1+2)+3)+4)+5)}. The left argument, \var{x}, is the accumulated value and the right argument, \var{y}, - is the update value from the \var{sequence}. If the optional + is the update value from the \var{iterable}. If the optional \var{initializer} is present, it is placed before the items of the - sequence in the calculation, and serves as a default when the - sequence is empty. If \var{initializer} is not given and - \var{sequence} contains only one item, the first item is returned. + iterable in the calculation, and serves as a default when the + iterable is empty. If \var{initializer} is not given and + \var{iterable} contains only one item, the first item is returned. \end{funcdesc} \begin{funcdesc}{reload}{module} @@ -1121,11 +1121,11 @@ \versionadded{2.2} \end{funcdesc} -\begin{funcdesc}{tuple}{\optional{sequence}} +\begin{funcdesc}{tuple}{\optional{iterable}} Return a tuple whose items are the same and in the same order as - \var{sequence}'s items. \var{sequence} may be a sequence, a + \var{iterable}'s items. \var{iterable} may be a sequence, a container that supports iteration, or an iterator object. - If \var{sequence} is already a tuple, it + If \var{iterable} is already a tuple, it is returned unchanged. For instance, \code{tuple('abc')} returns \code{('a', 'b', 'c')} and \code{tuple([1, 2, 3])} returns \code{(1, 2, 3)}. If no argument is given, returns a new empty From python-checkins at python.org Wed Dec 20 21:15:09 2006 From: python-checkins at python.org (andrew.kuchling) Date: Wed, 20 Dec 2006 21:15:09 +0100 (CET) Subject: [Python-checkins] r53116 - python/branches/release25-maint/Doc/lib/libfuncs.tex Message-ID: <20061220201509.7D75A1E4008@bag.python.org> Author: andrew.kuchling Date: Wed Dec 20 21:15:08 2006 New Revision: 53116 Modified: python/branches/release25-maint/Doc/lib/libfuncs.tex Log: Backport doc changes from rev. 53112, 53115: use 'iterable' in various places instead of 'sequence'. Modified: python/branches/release25-maint/Doc/lib/libfuncs.tex ============================================================================== --- python/branches/release25-maint/Doc/lib/libfuncs.tex (original) +++ python/branches/release25-maint/Doc/lib/libfuncs.tex Wed Dec 20 21:15:08 2006 @@ -237,11 +237,11 @@ \code{del \var{x}.\var{foobar}}. \end{funcdesc} -\begin{funcdesc}{dict}{\optional{mapping-or-sequence}} +\begin{funcdesc}{dict}{\optional{arg}} Return a new dictionary initialized from an optional positional argument or from a set of keyword arguments. If no arguments are given, return a new empty dictionary. - If the positional argument is a mapping object, return a dictionary + If the positional argument \var{arg} is a mapping object, return a dictionary mapping the same keys to the same values as does the mapping object. Otherwise the positional argument must be a sequence, a container that supports iteration, or an iterator object. The elements of the argument @@ -414,18 +414,18 @@ \versionadded{2.2} \end{funcdesc} -\begin{funcdesc}{filter}{function, list} - Construct a list from those elements of \var{list} for which - \var{function} returns true. \var{list} may be either a sequence, a - container which supports iteration, or an iterator, If \var{list} +\begin{funcdesc}{filter}{function, iterable} + Construct a list from those elements of \var{iterable} for which + \var{function} returns true. \var{iterable} may be either a sequence, a + container which supports iteration, or an iterator, If \var{iterable} is a string or a tuple, the result also has that type; otherwise it is always a list. If \var{function} is \code{None}, the identity function is assumed, that is, all elements of - \var{list} that are false are removed. + \var{iterable} that are false are removed. - Note that \code{filter(function, \var{list})} is equivalent to - \code{[item for item in \var{list} if function(item)]} if function is - not \code{None} and \code{[item for item in \var{list} if item]} if + Note that \code{filter(function, \var{iterable})} is equivalent to + \code{[item for item in \var{iterable} if function(item)]} if function is + not \code{None} and \code{[item for item in \var{iterable} if item]} if function is \code{None}. \end{funcdesc} @@ -591,12 +591,12 @@ may be a sequence (string, tuple or list) or a mapping (dictionary). \end{funcdesc} -\begin{funcdesc}{list}{\optional{sequence}} +\begin{funcdesc}{list}{\optional{iterable}} Return a list whose items are the same and in the same order as - \var{sequence}'s items. \var{sequence} may be either a sequence, a + \var{iterable}'s items. \var{iterable} may be either a sequence, a container that supports iteration, or an iterator object. If - \var{sequence} is already a list, a copy is made and returned, - similar to \code{\var{sequence}[:]}. For instance, + \var{iterable} is already a list, a copy is made and returned, + similar to \code{\var{iterable}[:]}. For instance, \code{list('abc')} returns \code{['a', 'b', 'c']} and \code{list( (1, 2, 3) )} returns \code{[1, 2, 3]}. If no argument is given, returns a new empty list, \code{[]}. @@ -622,22 +622,22 @@ are given, returns \code{0L}. \end{funcdesc} -\begin{funcdesc}{map}{function, list, ...} - Apply \var{function} to every item of \var{list} and return a list - of the results. If additional \var{list} arguments are passed, +\begin{funcdesc}{map}{function, iterable, ...} + Apply \var{function} to every item of \var{iterable} and return a list + of the results. If additional \var{iterable} arguments are passed, \var{function} must take that many arguments and is applied to the - items of all lists in parallel; if a list is shorter than another it + items from all iterables in parallel. If one iterable is shorter than another it is assumed to be extended with \code{None} items. If \var{function} is \code{None}, the identity function is assumed; if there are - multiple list arguments, \function{map()} returns a list consisting - of tuples containing the corresponding items from all lists (a kind - of transpose operation). The \var{list} arguments may be any kind - of sequence; the result is always a list. + multiple arguments, \function{map()} returns a list consisting + of tuples containing the corresponding items from all iterables (a kind + of transpose operation). The \var{iterable} arguments may be a sequence + or any iterable object; the result is always a list. \end{funcdesc} -\begin{funcdesc}{max}{s\optional{, args...}\optional{key}} - With a single argument \var{s}, return the largest item of a - non-empty sequence (such as a string, tuple or list). With more +\begin{funcdesc}{max}{iterable\optional{, args...}\optional{key}} + With a single argument \var{iterable}, return the largest item of a + non-empty iterable (such as a string, tuple or list). With more than one argument, return the largest of the arguments. The optional \var{key} argument specifies a one-argument ordering @@ -647,16 +647,16 @@ \versionchanged[Added support for the optional \var{key} argument]{2.5} \end{funcdesc} -\begin{funcdesc}{min}{s\optional{, args...}\optional{key}} - With a single argument \var{s}, return the smallest item of a - non-empty sequence (such as a string, tuple or list). With more +\begin{funcdesc}{min}{iterable\optional{, args...}\optional{key}} + With a single argument \var{iterable}, return the smallest item of a + non-empty iterable (such as a string, tuple or list). With more than one argument, return the smallest of the arguments. The optional \var{key} argument specifies a one-argument ordering function like that used for \method{list.sort()}. The \var{key} argument, if supplied, must be in keyword form (for example, \samp{min(a,b,c,key=func)}). - \versionchanged[Added support for the optional \var{key} argument]{2.5} + \versionchanged[Added support for the optional \var{key} argument]{2.5} \end{funcdesc} \begin{funcdesc}{object}{} @@ -871,17 +871,17 @@ line editing and history features. \end{funcdesc} -\begin{funcdesc}{reduce}{function, sequence\optional{, initializer}} +\begin{funcdesc}{reduce}{function, iterable\optional{, initializer}} Apply \var{function} of two arguments cumulatively to the items of - \var{sequence}, from left to right, so as to reduce the sequence to + \var{iterable}, from left to right, so as to reduce the iterable to a single value. For example, \code{reduce(lambda x, y: x+y, [1, 2, 3, 4, 5])} calculates \code{((((1+2)+3)+4)+5)}. The left argument, \var{x}, is the accumulated value and the right argument, \var{y}, - is the update value from the \var{sequence}. If the optional + is the update value from the \var{iterable}. If the optional \var{initializer} is present, it is placed before the items of the - sequence in the calculation, and serves as a default when the - sequence is empty. If \var{initializer} is not given and - \var{sequence} contains only one item, the first item is returned. + iterable in the calculation, and serves as a default when the + iterable is empty. If \var{initializer} is not given and + \var{iterable} contains only one item, the first item is returned. \end{funcdesc} \begin{funcdesc}{reload}{module} @@ -1087,11 +1087,11 @@ string, \code{''}. \end{funcdesc} -\begin{funcdesc}{sum}{sequence\optional{, start}} - Sums \var{start} and the items of a \var{sequence}, from left to - right, and returns the total. \var{start} defaults to \code{0}. - The \var{sequence}'s items are normally numbers, and are not allowed - to be strings. The fast, correct way to concatenate sequence of +\begin{funcdesc}{sum}{iterable\optional{, start}} + Sums \var{start} and the items of an \var{iterable} from left to + right and returns the total. \var{start} defaults to \code{0}. + The \var{iterable}'s items are normally numbers, and are not allowed + to be strings. The fast, correct way to concatenate a sequence of strings is by calling \code{''.join(\var{sequence})}. Note that \code{sum(range(\var{n}), \var{m})} is equivalent to \code{reduce(operator.add, range(\var{n}), \var{m})} @@ -1121,11 +1121,11 @@ \versionadded{2.2} \end{funcdesc} -\begin{funcdesc}{tuple}{\optional{sequence}} +\begin{funcdesc}{tuple}{\optional{iterable}} Return a tuple whose items are the same and in the same order as - \var{sequence}'s items. \var{sequence} may be a sequence, a + \var{iterable}'s items. \var{iterable} may be a sequence, a container that supports iteration, or an iterator object. - If \var{sequence} is already a tuple, it + If \var{iterable} is already a tuple, it is returned unchanged. For instance, \code{tuple('abc')} returns \code{('a', 'b', 'c')} and \code{tuple([1, 2, 3])} returns \code{(1, 2, 3)}. If no argument is given, returns a new empty From python-checkins at python.org Wed Dec 20 21:20:43 2006 From: python-checkins at python.org (andrew.kuchling) Date: Wed, 20 Dec 2006 21:20:43 +0100 (CET) Subject: [Python-checkins] r53117 - python/trunk/Doc/lib/libctypes.tex Message-ID: <20061220202043.A85D21E4008@bag.python.org> Author: andrew.kuchling Date: Wed Dec 20 21:20:42 2006 New Revision: 53117 Modified: python/trunk/Doc/lib/libctypes.tex Log: [Bug #1619680] in_dll() arguments are documented in the wrong order Modified: python/trunk/Doc/lib/libctypes.tex ============================================================================== --- python/trunk/Doc/lib/libctypes.tex (original) +++ python/trunk/Doc/lib/libctypes.tex Wed Dec 20 21:20:42 2006 @@ -2085,7 +2085,7 @@ the type. Some types accept other objects as well. \end{methoddesc} -\begin{methoddesc}{in_dll}{name, library} +\begin{methoddesc}{in_dll}{library, name} This method returns a ctypes type instance exported by a shared library. \var{name} is the name of the symbol that exports the data, \code{library} is the loaded shared library. From python-checkins at python.org Wed Dec 20 21:20:57 2006 From: python-checkins at python.org (andrew.kuchling) Date: Wed, 20 Dec 2006 21:20:57 +0100 (CET) Subject: [Python-checkins] r53118 - python/branches/release25-maint/Doc/lib/libctypes.tex Message-ID: <20061220202057.6971F1E4008@bag.python.org> Author: andrew.kuchling Date: Wed Dec 20 21:20:56 2006 New Revision: 53118 Modified: python/branches/release25-maint/Doc/lib/libctypes.tex Log: [Bug #1619680] in_dll() arguments are documented in the wrong order Modified: python/branches/release25-maint/Doc/lib/libctypes.tex ============================================================================== --- python/branches/release25-maint/Doc/lib/libctypes.tex (original) +++ python/branches/release25-maint/Doc/lib/libctypes.tex Wed Dec 20 21:20:56 2006 @@ -2085,7 +2085,7 @@ the type. Some types accept other objects as well. \end{methoddesc} -\begin{methoddesc}{in_dll}{name, library} +\begin{methoddesc}{in_dll}{library, name} This method returns a ctypes type instance exported by a shared library. \var{name} is the name of the symbol that exports the data, \code{library} is the loaded shared library. From python-checkins at python.org Wed Dec 20 23:26:07 2006 From: python-checkins at python.org (brett.cannon) Date: Wed, 20 Dec 2006 23:26:07 +0100 (CET) Subject: [Python-checkins] r53119 - sandbox/trunk/import_in_py/importbench.py Message-ID: <20061220222607.464691E400B@bag.python.org> Author: brett.cannon Date: Wed Dec 20 23:26:06 2006 New Revision: 53119 Modified: sandbox/trunk/import_in_py/importbench.py Log: Add a benchmark for a relative import in a package. Modified: sandbox/trunk/import_in_py/importbench.py ============================================================================== --- sandbox/trunk/import_in_py/importbench.py (original) +++ sandbox/trunk/import_in_py/importbench.py Wed Dec 20 23:26:06 2006 @@ -27,14 +27,23 @@ from timeit import Timer def import_and_clear_timer(module_name, globals_={}, locals_={}, fromlist=[], - level=0): + level=0, absolute_name=None): import_stmt = ('__import__(%r, %r, %r, %r, %s)' % (module_name, globals_, locals_, fromlist, level)) - del_stmt = 'del sys.modules[%r]' % module_name + # Need to get absolute module name in case benchmark is doing a relative + # import. + module = eval(import_stmt) + del_format = 'del sys.modules[%r]' + if not absolute_name: + absolute_name = module.__name__ + else: + del_format += '; delattr(sys.modules[%r], %r)' % (module.__name__, + fromlist[0]) + assert absolute_name in sys.modules + del_stmt = del_format % absolute_name + exec del_stmt in globals(), {} stmt = import_stmt + '; ' + del_stmt - # Warm up path_importer_cache and make sure module is not in sys.modules. - exec stmt in globals(), {} - return Timer(import_stmt + '; ' + del_stmt, 'import sys') + return Timer(stmt, 'import sys') def save_import_state(fxn): """Backup and restore the import state.""" @@ -246,6 +255,19 @@ # for the module. It should get reset by the import. timer = import_and_clear_timer(pkg_details.full_module_name) return timer.repeat(repetitions, iterations) + + at save_import_state +def bench_relative_import_in_package(repetitions, iterations): + """Benchmark importing a module within a package using a relative path.""" + sys.path = [] + sys.meta_path = [] + with PyPycPackage() as pkg_details: + pkg = __import__(pkg_details.pkg_name, {}, {}, [], 0) + globals_ = {'__name__': pkg.__name__, '__path__':pkg.__path__} + timer = import_and_clear_timer('', globals_, {}, + [pkg_details.module_name], 1, + pkg_details.full_module_name) + return timer.repeat(repetitions, iterations) def display_results(fxn, name, spacing, repetitions, iterations): From python-checkins at python.org Thu Dec 21 05:38:00 2006 From: python-checkins at python.org (neal.norwitz) Date: Thu, 21 Dec 2006 05:38:00 +0100 (CET) Subject: [Python-checkins] r53120 - python/trunk/Misc/developers.txt Message-ID: <20061221043800.990D71E4007@bag.python.org> Author: neal.norwitz Date: Thu Dec 21 05:38:00 2006 New Revision: 53120 Modified: python/trunk/Misc/developers.txt Log: Lars asked for permission on on python-dev for work on tarfile.py Modified: python/trunk/Misc/developers.txt ============================================================================== --- python/trunk/Misc/developers.txt (original) +++ python/trunk/Misc/developers.txt Thu Dec 21 05:38:00 2006 @@ -17,6 +17,9 @@ Permissions History ------------------- +- Lars Gustaebel was given SVN access on 20 Dec 2006 by NCN, for tarfile.py + related work. + - 2006 Summer of Code entries: SoC developers are expected to work primarily in nondist/sandbox or on a branch of their own, and will have their work reviewed before changes are accepted into the trunk. From nnorwitz at gmail.com Thu Dec 21 05:54:21 2006 From: nnorwitz at gmail.com (Neal Norwitz) Date: Wed, 20 Dec 2006 20:54:21 -0800 Subject: [Python-checkins] r53110 - python/trunk/Lib/mailbox.py In-Reply-To: <20061220194820.ED8DD1E4008@bag.python.org> References: <20061220194820.ED8DD1E4008@bag.python.org> Message-ID: Is there any reason to use 2 rather than os.SEEK_END in this code? > + self._file.seek(0, 2) n -- On 12/20/06, andrew.kuchling wrote: > Author: andrew.kuchling > Date: Wed Dec 20 20:48:20 2006 > New Revision: 53110 > > Modified: > python/trunk/Lib/mailbox.py > Log: > [Apply length-checking.diff from bug #1599254] > > Add length checking to single-file mailbox formats: before doing a > flush() on a mailbox, seek to the end and verify its length is > unchanged, raising ExternalClashError if the file's length has > changed. > > This fix avoids potential data loss if some other process appends to > the mailbox file after the table of contents has been generated; > instead of overwriting the modified file, you'll get the exception. > > I also noticed that the self._lookup() call in self.flush() wasn't > necessary (everything that sets self._pending to True also calls > self.lookup()), and replaced it by an assertion. > > 2.5 backport candidate. > > > Modified: python/trunk/Lib/mailbox.py > ============================================================================== > --- python/trunk/Lib/mailbox.py (original) > +++ python/trunk/Lib/mailbox.py Wed Dec 20 20:48:20 2006 > @@ -513,6 +513,7 @@ > self._next_key = 0 > self._pending = False # No changes require rewriting the file. > self._locked = False > + self._file_length = None # Used to record mailbox size > > def add(self, message): > """Add message and return assigned key.""" > @@ -566,7 +567,21 @@ > """Write any pending changes to disk.""" > if not self._pending: > return > - self._lookup() > + > + # In order to be writing anything out at all, self._toc must > + # already have been generated (and presumably has been modified > + # by adding or deleting an item). > + assert self._toc is not None > + > + # Check length of self._file; if it's changed, some other process > + # has modified the mailbox since we scanned it. > + self._file.seek(0, 2) > + cur_len = self._file.tell() > + if cur_len != self._file_length: > + raise ExternalClashError('Size of mailbox file changed ' > + '(expected %i, found %i)' % > + (self._file_length, cur_len)) > + > new_file = _create_temporary(self._path) > try: > new_toc = {} > @@ -642,6 +657,7 @@ > offsets = self._install_message(message) > self._post_message_hook(self._file) > self._file.flush() > + self._file_length = self._file.tell() # Record current length of mailbox > return offsets > > > @@ -733,6 +749,7 @@ > break > self._toc = dict(enumerate(zip(starts, stops))) > self._next_key = len(self._toc) > + self._file_length = self._file.tell() > > > class MMDF(_mboxMMDF): > @@ -776,6 +793,8 @@ > break > self._toc = dict(enumerate(zip(starts, stops))) > self._next_key = len(self._toc) > + self._file.seek(0, 2) > + self._file_length = self._file.tell() > > > class MH(Mailbox): > @@ -1201,7 +1220,9 @@ > self._toc = dict(enumerate(zip(starts, stops))) > self._labels = dict(enumerate(label_lists)) > self._next_key = len(self._toc) > - > + self._file.seek(0, 2) > + self._file_length = self._file.tell() > + > def _pre_mailbox_hook(self, f): > """Called before writing the mailbox to file f.""" > f.write('BABYL OPTIONS:%sVersion: 5%sLabels:%s%s\037' % > _______________________________________________ > Python-checkins mailing list > Python-checkins at python.org > http://mail.python.org/mailman/listinfo/python-checkins > From fdrake at acm.org Thu Dec 21 08:14:55 2006 From: fdrake at acm.org (Fred L. Drake, Jr.) Date: Thu, 21 Dec 2006 02:14:55 -0500 Subject: [Python-checkins] r53110 - python/trunk/Lib/mailbox.py In-Reply-To: References: <20061220194820.ED8DD1E4008@bag.python.org> Message-ID: <200612210214.55585.fdrake@acm.org> On Wednesday 20 December 2006 23:54, Neal Norwitz wrote: > Is there any reason to use 2 rather than os.SEEK_END in this code? I remember that for years, there were no SEEK_* constants in Python, certainly not in reasonable places. The .seek() method was documented to use specific values... oh, wait, it still is documented to take specific numeric values! I (only vaguely) recall Guido telling people that that's how it's documented, and that's what they should use. Don't know if he still feels that way; if he's recanted the obscure path, we can fix both the calls and the documentation. I'd lend a hand! -Fred -- Fred L. Drake, Jr. From python-checkins at python.org Thu Dec 21 14:40:29 2006 From: python-checkins at python.org (andrew.kuchling) Date: Thu, 21 Dec 2006 14:40:29 +0100 (CET) Subject: [Python-checkins] r53125 - python/trunk/Doc/lib/libbz2.tex python/trunk/Doc/lib/libmmap.tex python/trunk/Doc/lib/libstdtypes.tex Message-ID: <20061221134029.E11011E4003@bag.python.org> Author: andrew.kuchling Date: Thu Dec 21 14:40:29 2006 New Revision: 53125 Modified: python/trunk/Doc/lib/libbz2.tex python/trunk/Doc/lib/libmmap.tex python/trunk/Doc/lib/libstdtypes.tex Log: Mention the os.SEEK_* constants Modified: python/trunk/Doc/lib/libbz2.tex ============================================================================== --- python/trunk/Doc/lib/libbz2.tex (original) +++ python/trunk/Doc/lib/libbz2.tex Thu Dec 21 14:40:29 2006 @@ -90,10 +90,10 @@ \begin{methoddesc}[BZ2File]{seek}{offset\optional{, whence}} Move to new file position. Argument \var{offset} is a byte count. Optional -argument \var{whence} defaults to \code{0} (offset from start of file, -offset should be \code{>= 0}); other values are \code{1} (move relative to -current position, positive or negative), and \code{2} (move relative to end -of file, usually negative, although many platforms allow seeking beyond +argument \var{whence} defaults to \code{os.SEEK_SET} or \code{0} (offset from start of file; +offset should be \code{>= 0}); other values are \code{os.SEEK_CUR} or \code{1} (move relative to +current position; offset can be positive or negative), and \code{os.SEEK_END} or \code{2} (move relative to end +of file; offset is usually negative, although many platforms allow seeking beyond the end of a file). Note that seeking of bz2 files is emulated, and depending on the parameters Modified: python/trunk/Doc/lib/libmmap.tex ============================================================================== --- python/trunk/Doc/lib/libmmap.tex (original) +++ python/trunk/Doc/lib/libmmap.tex Thu Dec 21 14:40:29 2006 @@ -140,8 +140,9 @@ \begin{methoddesc}{seek}{pos\optional{, whence}} Set the file's current position. \var{whence} argument is optional - and defaults to \code{0} (absolute file positioning); other values - are \code{1} (seek relative to the current position) and \code{2} + and defaults to \code{os.SEEK_SET} or \code{0} (absolute file + positioning); other values are \code{os.SEEK_CUR} or \code{1} (seek + relative to the current position) and \code{os.SEEK_END} or \code{2} (seek relative to the file's end). \end{methoddesc} Modified: python/trunk/Doc/lib/libstdtypes.tex ============================================================================== --- python/trunk/Doc/lib/libstdtypes.tex (original) +++ python/trunk/Doc/lib/libstdtypes.tex Thu Dec 21 14:40:29 2006 @@ -1678,9 +1678,12 @@ \begin{methoddesc}[file]{seek}{offset\optional{, whence}} Set the file's current position, like \code{stdio}'s \cfunction{fseek()}. - The \var{whence} argument is optional and defaults to \code{0} - (absolute file positioning); other values are \code{1} (seek - relative to the current position) and \code{2} (seek relative to the + The \var{whence} argument is optional and defaults to + \code{os.SEEK_SET} or \code{0} + (absolute file positioning); other values are \code{os.SEEK_CUR} or \code{1} + (seek + relative to the current position) and \code{os.SEEK_END} or \code{2} + (seek relative to the file's end). There is no return value. Note that if the file is opened for appending (mode \code{'a'} or \code{'a+'}), any \method{seek()} operations will be undone at the next write. If the From python-checkins at python.org Thu Dec 21 14:41:47 2006 From: python-checkins at python.org (andrew.kuchling) Date: Thu, 21 Dec 2006 14:41:47 +0100 (CET) Subject: [Python-checkins] r53126 - python/branches/release25-maint/Doc/lib/libbz2.tex python/branches/release25-maint/Doc/lib/libmmap.tex python/branches/release25-maint/Doc/lib/libstdtypes.tex Message-ID: <20061221134147.2F4C21E4003@bag.python.org> Author: andrew.kuchling Date: Thu Dec 21 14:41:46 2006 New Revision: 53126 Modified: python/branches/release25-maint/Doc/lib/libbz2.tex python/branches/release25-maint/Doc/lib/libmmap.tex python/branches/release25-maint/Doc/lib/libstdtypes.tex Log: Mention the os.SEEK_* constants Modified: python/branches/release25-maint/Doc/lib/libbz2.tex ============================================================================== --- python/branches/release25-maint/Doc/lib/libbz2.tex (original) +++ python/branches/release25-maint/Doc/lib/libbz2.tex Thu Dec 21 14:41:46 2006 @@ -90,10 +90,10 @@ \begin{methoddesc}[BZ2File]{seek}{offset\optional{, whence}} Move to new file position. Argument \var{offset} is a byte count. Optional -argument \var{whence} defaults to \code{0} (offset from start of file, -offset should be \code{>= 0}); other values are \code{1} (move relative to -current position, positive or negative), and \code{2} (move relative to end -of file, usually negative, although many platforms allow seeking beyond +argument \var{whence} defaults to \code{os.SEEK_SET} or \code{0} (offset from start of file; +offset should be \code{>= 0}); other values are \code{os.SEEK_CUR} or \code{1} (move relative to +current position; offset can be positive or negative), and \code{os.SEEK_END} or \code{2} (move relative to end +of file; offset is usually negative, although many platforms allow seeking beyond the end of a file). Note that seeking of bz2 files is emulated, and depending on the parameters Modified: python/branches/release25-maint/Doc/lib/libmmap.tex ============================================================================== --- python/branches/release25-maint/Doc/lib/libmmap.tex (original) +++ python/branches/release25-maint/Doc/lib/libmmap.tex Thu Dec 21 14:41:46 2006 @@ -140,8 +140,9 @@ \begin{methoddesc}{seek}{pos\optional{, whence}} Set the file's current position. \var{whence} argument is optional - and defaults to \code{0} (absolute file positioning); other values - are \code{1} (seek relative to the current position) and \code{2} + and defaults to \code{os.SEEK_SET} or \code{0} (absolute file + positioning); other values are \code{os.SEEK_CUR} or \code{1} (seek + relative to the current position) and \code{os.SEEK_END} or \code{2} (seek relative to the file's end). \end{methoddesc} Modified: python/branches/release25-maint/Doc/lib/libstdtypes.tex ============================================================================== --- python/branches/release25-maint/Doc/lib/libstdtypes.tex (original) +++ python/branches/release25-maint/Doc/lib/libstdtypes.tex Thu Dec 21 14:41:46 2006 @@ -1678,9 +1678,12 @@ \begin{methoddesc}[file]{seek}{offset\optional{, whence}} Set the file's current position, like \code{stdio}'s \cfunction{fseek()}. - The \var{whence} argument is optional and defaults to \code{0} - (absolute file positioning); other values are \code{1} (seek - relative to the current position) and \code{2} (seek relative to the + The \var{whence} argument is optional and defaults to + \code{os.SEEK_SET} or \code{0} + (absolute file positioning); other values are \code{os.SEEK_CUR} or \code{1} + (seek + relative to the current position) and \code{os.SEEK_END} or \code{2} + (seek relative to the file's end). There is no return value. Note that if the file is opened for appending (mode \code{'a'} or \code{'a+'}), any \method{seek()} operations will be undone at the next write. If the From amk at amk.ca Thu Dec 21 14:53:43 2006 From: amk at amk.ca (A.M. Kuchling) Date: Thu, 21 Dec 2006 08:53:43 -0500 Subject: [Python-checkins] r53110 - python/trunk/Lib/mailbox.py In-Reply-To: <200612210214.55585.fdrake@acm.org> References: <20061220194820.ED8DD1E4008@bag.python.org> <200612210214.55585.fdrake@acm.org> Message-ID: <20061221135343.GA5855@localhost.localdomain> On Thu, Dec 21, 2006 at 02:14:55AM -0500, Fred L. Drake, Jr. wrote: > I (only vaguely) recall Guido telling people that that's how it's documented, > and that's what they should use. Don't know if he still feels that way; if > he's recanted the obscure path, we can fix both the calls and the > documentation. I'd lend a hand! The constants were added in 2.5. I've gone ahead and made the documentation change to trunk and 25-maint, because why were the constants added if they weren't intended to be used? While looking at the code, I noticed a minor potential bug. Python defines SEEK_SET and friends to be 0,1,2 and then os.lseek() maps them to SEEK_SET, SEEK_CUR, SEEK_END. file.seek() does *not* do this; it just passes the 0,1,2 through to the stdio fseek(), and therefore would be broken if there's some weird platform where 0,1,2 aren't the correct values. This doesn't seem worth fixing, given that no one has ever run into it, and might be an argument for removing the conversion from os.lseek(); clearly it isn't needed. --amk From jimjjewett at gmail.com Thu Dec 21 17:39:45 2006 From: jimjjewett at gmail.com (Jim Jewett) Date: Thu, 21 Dec 2006 11:39:45 -0500 Subject: [Python-checkins] r53118 - python/branches/release25-maint/Doc/lib/libctypes.tex In-Reply-To: <20061220202057.6971F1E4008@bag.python.org> References: <20061220202057.6971F1E4008@bag.python.org> Message-ID: Is there a reason for "\var{name}" but "\code{library}"? On 12/20/06, andrew.kuchling wrote: > Author: andrew.kuchling > Date: Wed Dec 20 21:20:56 2006 > New Revision: 53118 > > Modified: > python/branches/release25-maint/Doc/lib/libctypes.tex > Log: > [Bug #1619680] in_dll() arguments are documented in the wrong order > > Modified: python/branches/release25-maint/Doc/lib/libctypes.tex > ============================================================================== > --- python/branches/release25-maint/Doc/lib/libctypes.tex (original) > +++ python/branches/release25-maint/Doc/lib/libctypes.tex Wed Dec 20 21:20:56 2006 > @@ -2085,7 +2085,7 @@ > the type. Some types accept other objects as well. > \end{methoddesc} > > -\begin{methoddesc}{in_dll}{name, library} > +\begin{methoddesc}{in_dll}{library, name} > This method returns a ctypes type instance exported by a shared > library. \var{name} is the name of the symbol that exports the data, > \code{library} is the loaded shared library. > _______________________________________________ > Python-checkins mailing list > Python-checkins at python.org > http://mail.python.org/mailman/listinfo/python-checkins > From fdrake at acm.org Thu Dec 21 17:53:34 2006 From: fdrake at acm.org (Fred L. Drake, Jr.) Date: Thu, 21 Dec 2006 11:53:34 -0500 Subject: [Python-checkins] r53118 - python/branches/release25-maint/Doc/lib/libctypes.tex In-Reply-To: References: <20061220202057.6971F1E4008@bag.python.org> Message-ID: <200612211153.34989.fdrake@acm.org> On Thursday 21 December 2006 11:39, Jim Jewett wrote: > Is there a reason for "\var{name}" but "\code{library}"? Both should be \var in this case. -Fred -- Fred L. Drake, Jr. From python-checkins at python.org Thu Dec 21 19:06:31 2006 From: python-checkins at python.org (walter.doerwald) Date: Thu, 21 Dec 2006 19:06:31 +0100 (CET) Subject: [Python-checkins] r53129 - python/trunk/Modules/timemodule.c Message-ID: <20061221180631.0CB6A1E4007@bag.python.org> Author: walter.doerwald Date: Thu Dec 21 19:06:30 2006 New Revision: 53129 Modified: python/trunk/Modules/timemodule.c Log: Fix typo. Modified: python/trunk/Modules/timemodule.c ============================================================================== --- python/trunk/Modules/timemodule.c (original) +++ python/trunk/Modules/timemodule.c Thu Dec 21 19:06:30 2006 @@ -659,7 +659,7 @@ time_tzset. In the future, some parts of it can be moved back (for platforms that don't HAVE_WORKING_TZSET, when we know what they are), and the extranious calls to tzset(3) should be removed. - I havn't done this yet, as I don't want to change this code as + I haven't done this yet, as I don't want to change this code as little as possible when introducing the time.tzset and time.tzsetwall methods. This should simply be a method of doing the following once, at the top of this function and removing the call to tzset() from From theller at ctypes.org Thu Dec 21 19:23:14 2006 From: theller at ctypes.org (Thomas Heller) Date: Thu, 21 Dec 2006 19:23:14 +0100 Subject: [Python-checkins] r53118 - python/branches/release25-maint/Doc/lib/libctypes.tex In-Reply-To: <200612211153.34989.fdrake@acm.org> References: <20061220202057.6971F1E4008@bag.python.org> <200612211153.34989.fdrake@acm.org> Message-ID: Fred L. Drake, Jr. schrieb: > On Thursday 21 December 2006 11:39, Jim Jewett wrote: > > Is there a reason for "\var{name}" but "\code{library}"? > > Both should be \var in this case. > > > -Fred > I'll correct that in the toolchain that generates libctypes.tex (it is generated from rst). Thomas From python-checkins at python.org Thu Dec 21 19:30:56 2006 From: python-checkins at python.org (thomas.heller) Date: Thu, 21 Dec 2006 19:30:56 +0100 (CET) Subject: [Python-checkins] r53131 - python/trunk/Doc/lib/libctypes.tex Message-ID: <20061221183056.A00E81E4007@bag.python.org> Author: thomas.heller Date: Thu Dec 21 19:30:56 2006 New Revision: 53131 Modified: python/trunk/Doc/lib/libctypes.tex Log: Fix wrong markup of an argument in a method signature. Will backport. Modified: python/trunk/Doc/lib/libctypes.tex ============================================================================== --- python/trunk/Doc/lib/libctypes.tex (original) +++ python/trunk/Doc/lib/libctypes.tex Thu Dec 21 19:30:56 2006 @@ -2088,7 +2088,7 @@ \begin{methoddesc}{in_dll}{library, name} This method returns a ctypes type instance exported by a shared library. \var{name} is the name of the symbol that exports the data, -\code{library} is the loaded shared library. +\var{library} is the loaded shared library. \end{methoddesc} Common instance variables of ctypes data types: From python-checkins at python.org Thu Dec 21 19:31:36 2006 From: python-checkins at python.org (thomas.heller) Date: Thu, 21 Dec 2006 19:31:36 +0100 (CET) Subject: [Python-checkins] r53132 - python/branches/release25-maint/Doc/lib/libctypes.tex Message-ID: <20061221183136.C3C781E4007@bag.python.org> Author: thomas.heller Date: Thu Dec 21 19:31:36 2006 New Revision: 53132 Modified: python/branches/release25-maint/Doc/lib/libctypes.tex Log: Fix wrong markup of an argument in a method signature. Backported from trunk. Modified: python/branches/release25-maint/Doc/lib/libctypes.tex ============================================================================== --- python/branches/release25-maint/Doc/lib/libctypes.tex (original) +++ python/branches/release25-maint/Doc/lib/libctypes.tex Thu Dec 21 19:31:36 2006 @@ -2088,7 +2088,7 @@ \begin{methoddesc}{in_dll}{library, name} This method returns a ctypes type instance exported by a shared library. \var{name} is the name of the symbol that exports the data, -\code{library} is the loaded shared library. +\var{library} is the loaded shared library. \end{methoddesc} Common instance variables of ctypes data types: From buildbot at python.org Thu Dec 21 20:00:17 2006 From: buildbot at python.org (buildbot at python.org) Date: Thu, 21 Dec 2006 19:00:17 +0000 Subject: [Python-checkins] buildbot warnings in alpha Tru64 5.1 trunk Message-ID: <20061221190017.D1C201E4007@bag.python.org> The Buildbot has detected a new failure of alpha Tru64 5.1 trunk. Full details are available at: http://www.python.org/dev/buildbot/all/alpha%2520Tru64%25205.1%2520trunk/builds/1335 Buildbot URL: http://www.python.org/dev/buildbot/all/ Build Reason: Build Source Stamp: [branch trunk] HEAD Blamelist: andrew.kuchling,neal.norwitz,walter.doerwald Build had warnings: warnings test Excerpt from the test logfile: 2 tests failed: test_signal test_socket Traceback (most recent call last): File "./Lib/test/regrtest.py", line 546, in runtest_inner the_package = __import__(abstest, globals(), locals(), []) File "/net/ringneck/scratch1/nnorwitz/buildbot/trunk.norwitz-tru64/build/Lib/test/test_signal.py", line 134, in signal.pause() File "/net/ringneck/scratch1/nnorwitz/buildbot/trunk.norwitz-tru64/build/Lib/test/test_signal.py", line 49, in handlerB raise HandlerBCalled, args HandlerBCalled: (30, ) sincerely, -The Buildbot From martin at v.loewis.de Thu Dec 21 21:23:10 2006 From: martin at v.loewis.de (=?ISO-8859-1?Q?=22Martin_v=2E_L=F6wis=22?=) Date: Thu, 21 Dec 2006 21:23:10 +0100 Subject: [Python-checkins] [Python-Dev] r53110 - python/trunk/Lib/mailbox.py In-Reply-To: <20061221135343.GA5855@localhost.localdomain> References: <20061220194820.ED8DD1E4008@bag.python.org> <200612210214.55585.fdrake@acm.org> <20061221135343.GA5855@localhost.localdomain> Message-ID: <458AED2E.5080709@v.loewis.de> A.M. Kuchling schrieb: > The constants were added in 2.5. I've gone ahead and made the > documentation change to trunk and 25-maint, because why were the > constants added if they weren't intended to be used? See #711830. They were added for compatibility (with earlier Python releases) primarily. Some people believe in these constants, so just let them have them. Python (the API) doesn't really rely on them, but instead guarantees that the numeric values are always the same across platforms. Now it seem that introducing them has the unfortunate side effect that people think they *have* to use them, and that doing so gives better code... Regards, Martin From python-checkins at python.org Fri Dec 22 01:50:57 2006 From: python-checkins at python.org (andrew.kuchling) Date: Fri, 22 Dec 2006 01:50:57 +0100 (CET) Subject: [Python-checkins] r53137 - python/trunk/Objects/dictnotes.txt Message-ID: <20061222005057.2703D1E400D@bag.python.org> Author: andrew.kuchling Date: Fri Dec 22 01:50:56 2006 New Revision: 53137 Modified: python/trunk/Objects/dictnotes.txt Log: Typo fix Modified: python/trunk/Objects/dictnotes.txt ============================================================================== --- python/trunk/Objects/dictnotes.txt (original) +++ python/trunk/Objects/dictnotes.txt Fri Dec 22 01:50:56 2006 @@ -44,7 +44,7 @@ d.setdefault(word, []).append(pagenumber) Note, the second example is a use case characterized by a get and set - to the same key. There are similar used cases with a __contains__ + to the same key. There are similar use cases with a __contains__ followed by a get, set, or del to the same key. Part of the justification for d.setdefault is combining the two lookups into one. From femharrods1 at myway.com Mon Dec 18 15:31:42 2006 From: femharrods1 at myway.com (Pure Six Inc.) Date: Mon, 18 Dec 2006 15:31:42 +0100 Subject: [Python-checkins] Work with Pure Six and earn more Message-ID: An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-checkins/attachments/20061218/855c5a8a/attachment.htm From python-checkins at python.org Fri Dec 22 14:25:03 2006 From: python-checkins at python.org (andrew.kuchling) Date: Fri, 22 Dec 2006 14:25:03 +0100 (CET) Subject: [Python-checkins] r53139 - python/trunk/Lib/CGIHTTPServer.py Message-ID: <20061222132503.51EFD1E400C@bag.python.org> Author: andrew.kuchling Date: Fri Dec 22 14:25:02 2006 New Revision: 53139 Modified: python/trunk/Lib/CGIHTTPServer.py Log: [Bug #737202; fix from Titus Brown] Make CGIHTTPServer work for scripts in sub-directories Modified: python/trunk/Lib/CGIHTTPServer.py ============================================================================== --- python/trunk/Lib/CGIHTTPServer.py (original) +++ python/trunk/Lib/CGIHTTPServer.py Fri Dec 22 14:25:02 2006 @@ -105,17 +105,36 @@ def run_cgi(self): """Execute a CGI script.""" + path = self.path dir, rest = self.cgi_info + + i = path.find('/', len(dir) + 1) + while i >= 0: + nextdir = path[:i] + nextrest = path[i+1:] + + scriptdir = self.translate_path(nextdir) + if os.path.isdir(scriptdir): + dir, rest = nextdir, nextrest + i = path.find('/', len(dir) + 1) + else: + break + + # find an explicit query string, if present. i = rest.rfind('?') if i >= 0: rest, query = rest[:i], rest[i+1:] else: query = '' + + # dissect the part after the directory name into a script name & + # a possible additional path, to be stored in PATH_INFO. i = rest.find('/') if i >= 0: script, rest = rest[:i], rest[i:] else: script, rest = rest, '' + scriptname = dir + '/' + script scriptfile = self.translate_path(scriptname) if not os.path.exists(scriptfile): From python-checkins at python.org Fri Dec 22 14:28:44 2006 From: python-checkins at python.org (andrew.kuchling) Date: Fri, 22 Dec 2006 14:28:44 +0100 (CET) Subject: [Python-checkins] r53140 - in python/branches/release25-maint: Lib/CGIHTTPServer.py Misc/NEWS Message-ID: <20061222132844.3EB561E400C@bag.python.org> Author: andrew.kuchling Date: Fri Dec 22 14:28:43 2006 New Revision: 53140 Modified: python/branches/release25-maint/Lib/CGIHTTPServer.py python/branches/release25-maint/Misc/NEWS Log: [Bug #737202; fix from Titus Brown] Make CGIHTTPServer work for scripts in sub-directories Modified: python/branches/release25-maint/Lib/CGIHTTPServer.py ============================================================================== --- python/branches/release25-maint/Lib/CGIHTTPServer.py (original) +++ python/branches/release25-maint/Lib/CGIHTTPServer.py Fri Dec 22 14:28:43 2006 @@ -105,17 +105,36 @@ def run_cgi(self): """Execute a CGI script.""" + path = self.path dir, rest = self.cgi_info + + i = path.find('/', len(dir) + 1) + while i >= 0: + nextdir = path[:i] + nextrest = path[i+1:] + + scriptdir = self.translate_path(nextdir) + if os.path.isdir(scriptdir): + dir, rest = nextdir, nextrest + i = path.find('/', len(dir) + 1) + else: + break + + # find an explicit query string, if present. i = rest.rfind('?') if i >= 0: rest, query = rest[:i], rest[i+1:] else: query = '' + + # dissect the part after the directory name into a script name & + # a possible additional path, to be stored in PATH_INFO. i = rest.find('/') if i >= 0: script, rest = rest[:i], rest[i:] else: script, rest = rest, '' + scriptname = dir + '/' + script scriptfile = self.translate_path(scriptname) if not os.path.exists(scriptfile): Modified: python/branches/release25-maint/Misc/NEWS ============================================================================== --- python/branches/release25-maint/Misc/NEWS (original) +++ python/branches/release25-maint/Misc/NEWS Fri Dec 22 14:28:43 2006 @@ -122,6 +122,9 @@ Library ------- +- Bug #737202: Make CGIHTTPServer work for scripts in subdirectories. + Fix by Titus Brown. + - Patch #1608267: fix a race condition in os.makedirs() is the directory to be created is already there. From python-checkins at python.org Fri Dec 22 16:04:46 2006 From: python-checkins at python.org (andrew.kuchling) Date: Fri, 22 Dec 2006 16:04:46 +0100 (CET) Subject: [Python-checkins] r53141 - in python/trunk/Lib: dumbdbm.py test/test_dumbdbm.py Message-ID: <20061222150446.47A7F1E400D@bag.python.org> Author: andrew.kuchling Date: Fri Dec 22 16:04:45 2006 New Revision: 53141 Modified: python/trunk/Lib/dumbdbm.py python/trunk/Lib/test/test_dumbdbm.py Log: [Bug #802128] Make the mode argument of dumbdbm actually work the way it's described, and add a test for it. 2.5 bugfix candidate, maybe; arguably this patch changes the API of dumbdbm and shouldn't be added in a point-release. Modified: python/trunk/Lib/dumbdbm.py ============================================================================== --- python/trunk/Lib/dumbdbm.py (original) +++ python/trunk/Lib/dumbdbm.py Fri Dec 22 16:04:45 2006 @@ -68,7 +68,8 @@ try: f = _open(self._datfile, 'r') except IOError: - f = _open(self._datfile, 'w', self._mode) + f = _open(self._datfile, 'w') + self._chmod(self._datfile) f.close() self._update() @@ -106,7 +107,8 @@ except self._os.error: pass - f = self._open(self._dirfile, 'w', self._mode) + f = self._open(self._dirfile, 'w') + self._chmod(self._dirfile) for key, pos_and_siz_pair in self._index.iteritems(): f.write("%r, %r\n" % (key, pos_and_siz_pair)) f.close() @@ -152,7 +154,8 @@ # the in-memory index dict, and append one to the directory file. def _addkey(self, key, pos_and_siz_pair): self._index[key] = pos_and_siz_pair - f = _open(self._dirfile, 'a', self._mode) + f = _open(self._dirfile, 'a') + self._chmod(self._dirfile) f.write("%r, %r\n" % (key, pos_and_siz_pair)) f.close() @@ -214,6 +217,9 @@ __del__ = close + def _chmod (self, file): + if hasattr(self._os, 'chmod'): + self._os.chmod(file, self._mode) def open(file, flag=None, mode=0666): Modified: python/trunk/Lib/test/test_dumbdbm.py ============================================================================== --- python/trunk/Lib/test/test_dumbdbm.py (original) +++ python/trunk/Lib/test/test_dumbdbm.py Fri Dec 22 16:04:45 2006 @@ -38,6 +38,20 @@ self.read_helper(f) f.close() + def test_dumbdbm_creation_mode(self): + # On platforms without chmod, don't do anything. + if not hasattr(os, 'chmod'): + return + + f = dumbdbm.open(_fname, 'c', 0632) + f.close() + + import stat + st = os.stat(_fname + '.dat') + self.assertEqual(stat.S_IMODE(st.st_mode), 0632) + st = os.stat(_fname + '.dir') + self.assertEqual(stat.S_IMODE(st.st_mode), 0632) + def test_close_twice(self): f = dumbdbm.open(_fname) f['a'] = 'b' From python-checkins at python.org Fri Dec 22 16:16:58 2006 From: python-checkins at python.org (andrew.kuchling) Date: Fri, 22 Dec 2006 16:16:58 +0100 (CET) Subject: [Python-checkins] r53142 - in python/trunk/Lib: dumbdbm.py test/test_dumbdbm.py Message-ID: <20061222151658.9FAD61E400D@bag.python.org> Author: andrew.kuchling Date: Fri Dec 22 16:16:58 2006 New Revision: 53142 Modified: python/trunk/Lib/dumbdbm.py python/trunk/Lib/test/test_dumbdbm.py Log: [Bug #802128 continued] Modify mode depending on the process umask. Is there really no other way to read the umask than to set it? Hope this works on Windows... Modified: python/trunk/Lib/dumbdbm.py ============================================================================== --- python/trunk/Lib/dumbdbm.py (original) +++ python/trunk/Lib/dumbdbm.py Fri Dec 22 16:16:58 2006 @@ -236,4 +236,15 @@ """ # flag argument is currently ignored + + # Modify mode depending on the umask + try: + um = _os.umask(0) + _os.umask(um) + except AttributeError: + pass + else: + # Turn off any bits that are set in the umask + mode = mode & (~um) + return _Database(file, mode) Modified: python/trunk/Lib/test/test_dumbdbm.py ============================================================================== --- python/trunk/Lib/test/test_dumbdbm.py (original) +++ python/trunk/Lib/test/test_dumbdbm.py Fri Dec 22 16:16:58 2006 @@ -40,17 +40,21 @@ def test_dumbdbm_creation_mode(self): # On platforms without chmod, don't do anything. - if not hasattr(os, 'chmod'): + if not (hasattr(os, 'chmod') and hasattr(os, 'umask')): return - f = dumbdbm.open(_fname, 'c', 0632) - f.close() - + try: + old_umask = os.umask(0002) + f = dumbdbm.open(_fname, 'c', 0637) + f.close() + finally: + os.umask(old_umask) + import stat st = os.stat(_fname + '.dat') - self.assertEqual(stat.S_IMODE(st.st_mode), 0632) + self.assertEqual(stat.S_IMODE(st.st_mode), 0635) st = os.stat(_fname + '.dir') - self.assertEqual(stat.S_IMODE(st.st_mode), 0632) + self.assertEqual(stat.S_IMODE(st.st_mode), 0635) def test_close_twice(self): f = dumbdbm.open(_fname) From fdrake at acm.org Fri Dec 22 16:19:49 2006 From: fdrake at acm.org (Fred L. Drake, Jr.) Date: Fri, 22 Dec 2006 10:19:49 -0500 Subject: [Python-checkins] r53142 - in python/trunk/Lib: dumbdbm.py test/test_dumbdbm.py In-Reply-To: <20061222151658.9FAD61E400D@bag.python.org> References: <20061222151658.9FAD61E400D@bag.python.org> Message-ID: <200612221019.49312.fdrake@acm.org> On Friday 22 December 2006 10:16, andrew.kuchling wrote: > Is there really no other way to read the umask than to set it? Indeed. :-( -Fred -- Fred L. Drake, Jr. From python-checkins at python.org Fri Dec 22 16:46:01 2006 From: python-checkins at python.org (david.goodger) Date: Fri, 22 Dec 2006 16:46:01 +0100 (CET) Subject: [Python-checkins] r53144 - peps/trunk/pep-0000.txt peps/trunk/pep-3107.txt Message-ID: <20061222154601.D79601E400D@bag.python.org> Author: david.goodger Date: Fri Dec 22 16:46:01 2006 New Revision: 53144 Added: peps/trunk/pep-3107.txt (contents, props changed) Modified: peps/trunk/pep-0000.txt Log: added PEP 3107, Function Annotations, by Winter & Lownds Modified: peps/trunk/pep-0000.txt ============================================================================== --- peps/trunk/pep-0000.txt (original) +++ peps/trunk/pep-0000.txt Fri Dec 22 16:46:01 2006 @@ -105,6 +105,7 @@ S 3104 Access to Names in Outer Scopes Yee S 3105 Make print a function Brandl S 3106 Revamping dict.keys(), .values() and .items() GvR + S 3107 Function Annotations Winter, Lownds Finished PEPs (done, implemented in Subversion) @@ -442,7 +443,8 @@ S 3103 A Switch/Case Statement GvR S 3104 Access to Names in Outer Scopes Yee S 3105 Make print a function Brandl - S 3106 Revamping dict.keys(), .values() and .items() GvR + S 3106 Revamping dict.keys(), .values() and .items() GvR + S 3107 Function Annotations Winter, Lownds Key @@ -513,6 +515,7 @@ Lielens, Gregory gregory.lielens at fft.be Lindqvist, Bj?rn bjourne at gmail.com von Loewis, Martin loewis at informatik.hu-berlin.de + Lownds, Tony tony at pagedna.com Martelli, Alex aleax at aleax.it McClelland, Andrew eternalsquire at comcast.net McMillan, Gordon gmcm at hypernet.com @@ -549,6 +552,7 @@ Way, Terence terry at wayforward.net Wells, Cliff LogiplexSoftware at earthlink.net Wilson, Greg gvwilson at ddj.com + Winter, Collin collinw at gmail.com Wouters, Thomas thomas at xs4all.net Yee, Ka-Ping ping at zesty.ca Zadka, Moshe moshez at zadka.site.co.il Added: peps/trunk/pep-3107.txt ============================================================================== --- (empty file) +++ peps/trunk/pep-3107.txt Fri Dec 22 16:46:01 2006 @@ -0,0 +1,294 @@ +PEP: 3107 +Title: Function Annotations +Version: $Revision$ +Last-Modified: $Date$ +Author: Collin Winter , + Tony Lownds +Status: Draft +Type: Standards Track +Requires: 362 +Content-Type: text/x-rst +Created: 2-Dec-2006 +Python-Version: 3.0 +Post-History: + + +Abstract +======== + +This PEP introduces a syntax for adding arbitrary metadata annotations +to Python functions [#functerm]_. + + +Rationale +========= + +Because Python's 2.x series lacks a standard way of annotating a +function's parameters and return values (e.g., with information about +a what type a function's return value should be), a variety of tools +and libraries have appeared to fill this gap [#tailexamp]_. Some +utilise the decorators introduced in "PEP 318", while others parse a +function's docstring, looking for annotations there. + +This PEP aims to provide a single, standard way of specifying this +information, reducing the confusion caused by the wide variation in +mechanism and syntax that has existed until this point. + + +Fundamentals of Function Annotations +==================================== + +Before launching into a discussion of the precise ins and outs of +Python 3.0's function annotations, let's first talk broadly about +what annotations are and are not: + +1. Function annotations, both for parameters and return values, are + completely optional. + +2. Function annotations are nothing more than a way of associating + arbitrary Python expressions with various parts of a function at + compile-time. + + By itself, Python does not attach any particular meaning or + significance to annotations. Left to its own, Python simply makes + these expressions available as the values in the + ``__signature__.annotations`` mapping described in `Accessing + Function Annotations`_ below. + + The only way that annotations take on meaning is when they are + interpreted by third-party libraries. These annotation consumers + can do anything they want with a function's annotations. For + example, one library might use string-based annotations to provide + improved help messages, like so:: + + def compile(source: "something compilable", + filename: "where the compilable thing comes from", + mode: "is this a single statement or a suite?"): + ... + + Another library might be used to provide typechecking for Python + functions and methods. This library could use annotations to + indicate the function's expected input and return types, possibly + something like :: + + def haul(item: Haulable, *vargs: PackAnimal) -> Distance: + ... + + However, neither the strings in the first example nor the + type information in the second example have any meaning on their + own; meaning comes from third-party libraries alone. + +3. Following from point 2, this PEP makes no attempt to introduce + any kind of standard semantics, even for the built-in types. + This work will be left to third-party libraries. + + There is no worry that these libraries will assign semantics at + random, or that a variety of libraries will appear, each with + varying semantics and interpretations of what, say, a tuple of + strings means. The difficulty inherent in writing annotation + interpreting libraries will keep their number low and their + authorship in the hands of people who, frankly, know what they're + doing. + + +Syntax +====== + +Parameters +---------- + +Annotations for parameters take the form of optional expressions that +follow the parameter name. This example indicates that parameters 'a' +and 'c' should both be a ``Number``, while parameter 'b' should both +be a ``Mapping``:: + + def foo(a: Number, b: Mapping, c: Number = 5): + ... + +(Number, Mapping and Sequence are used thoughout this PEP and +represent the standard `numeric`_, `mapping`_ and `sequence +protocols`_.) + +In pseudo-grammar, parameters now look like ``identifier [: +expression] [= expression]``. That is, type annotations always +precede a parameter's default value and both type annotations and +default values are optional. Just like how equal signs are used to +indicate a default value, colons are used to mark annotations. All +annotation expressions are evaluated when the function definition is +executed. + +Annotations for excess parameters (i.e., ``*args`` and ``**kwargs``) +are indicated similarly. In the following function definition, +``*args`` is flagged as a list of ``Number``, and ``**kwargs`` is +marked as a dict whose keys are strings and whose values are of type +``Sequence``. :: + + def foo(*args: Number, **kwargs: Sequence): + ... + +Note that, depending on what annotation-interpreting library you're +using, the following might also be a valid spelling of the above:: + + def foo(*args: [Number], **kwargs: {str: Sequence}): + ... + +Only the first, however, has the BDFL's blessing [#blessedexcess]_ as +the One Obvious Way. + + +Return Values +------------- + +The examples thus far have omitted examples of how to annotate the +type of a function's return value. This is done like so:: + + def sum(*args: Number) -> Number: + ... + +The parameter list can now be followed by a literal ``->`` and a +Python expression. Like the annotations for parameters, this +expression will be evaluated when the function definition is executed. + +The grammar for function definitions [#grammar]_ is now something like +:: + + funcdef ::= [decorators] "def" funcname "(" + [parameter_list] ")" ["->" expression] ":" suite + decorators ::= decorator+ + decorator ::= "@" dotted_name ["(" [argument_list + [","]] ")"] NEWLINE + dotted_name ::= identifier ("." identifier)* + parameter_list ::= (defparameter ",")* + ( "*" identifier [":" expression] + [, "**" identifier [":" expression] ] + | "**" identifier [":" expression] + | defparameter [","] ) + defparameter ::= parameter [":" expression] ["=" expression] + sublist ::= parameter ("," parameter)* [","] + parameter ::= identifier | "(" sublist ")" + funcname ::= identifier + + +Accessing Function Annotations +============================== + +Once compiled, a function's annotations are available via the +function's ``__signature__`` attribute, introduced by PEP 362. +Signature objects include an attribute just for annotations, +appropriately called ``annotations``. This attribute is a dictionary, +mapping parameter names to an object representing the evaluated +annotation expression. + +There is a special key in the ``annotations`` mapping, ``"return"``. +This key is present only if an annotation was supplied for the +function's return value. + +For example, the following annotation:: + + def foo(a: Number, b: 5 + 6, c: list) -> String: + ... + +would result in a ``__signature__.annotations`` mapping of :: + + {'a': Number, + 'b': 11, + 'c': list, + 'return': String} + +The ``return`` key was chosen because it cannot conflict with the name +of a parameter; any attempt to use ``return`` as a parameter name +would result in a ``SyntaxError``. + + +Implementation +============== + +A sample implementation has been provided [#implementation]_ by Tony +Lownds. + + +Rejected Proposals +================== + ++ The BDFL rejected the author's idea for a special syntax for adding + annotations to generators as being "too ugly" [#rejectgensyn]_. + ++ Though discussed early on ([#threadgen]_, [#threadhof]_), including + special objects in the stdlib for annotating generator functions and + higher-order functions was ultimately rejected as being more + appropriate for third-party libraries; including them in the + standard library raised too many thorny issues. + ++ Despite considerable discussion about a standard type + parameterisation syntax, it was decided that this should also be + left to third-party libraries. ([#threadimmlist]_, [#threadmixing]_, + [#emphasistpls]_) + + +References and Footnotes +======================== + +.. [#functerm] Unless specifically stated, "function" is generally + used as a synonym for "callable" throughout this document. + +.. [#tailexamp] The author's typecheck_ library makes use of + decorators, while `Maxime Bourget's own typechecker`_ utilises + parsed docstrings. + +.. [#blessedexcess] + http://mail.python.org/pipermail/python-3000/2006-May/002173.html + +.. [#rejectgensyn] + http://mail.python.org/pipermail/python-3000/2006-May/002103.html + +.. _typecheck: + http://oakwinter.com/code/typecheck/ + +.. _Maxime Bourget's own typechecker: + http://maxrepo.info/taxonomy/term/3,6/all + +.. [#threadgen] + http://mail.python.org/pipermail/python-3000/2006-May/002091.html + +.. [#threadhof] + http://mail.python.org/pipermail/python-3000/2006-May/001972.html + +.. [#threadimmlist] + http://mail.python.org/pipermail/python-3000/2006-May/002105.html + +.. [#threadmixing] + http://mail.python.org/pipermail/python-3000/2006-May/002209.html + +.. [#emphasistpls] + http://mail.python.org/pipermail/python-3000/2006-June/002438.html + +.. [#implementation] + http://python.org/sf/1607548 + +.. _numeric: + http://docs.python.org/lib/typesnumeric.html + +.. _mapping: + http://docs.python.org/lib/typesmapping.html + +.. _sequence protocols: + http://docs.python.org/lib/typesseq.html + +.. [#grammar] + http://www.python.org/doc/current/ref/function.html + + +Copyright +========= + +This document has been placed in the public domain. + + +.. + Local Variables: + mode: indented-text + indent-tabs-mode: nil + sentence-end-double-space: t + fill-column: 70 + coding: utf-8 + End: From buildbot at python.org Fri Dec 22 16:47:32 2006 From: buildbot at python.org (buildbot at python.org) Date: Fri, 22 Dec 2006 15:47:32 +0000 Subject: [Python-checkins] buildbot warnings in x86 XP trunk Message-ID: <20061222154732.2ADBF1E400D@bag.python.org> The Buildbot has detected a new failure of x86 XP trunk. Full details are available at: http://www.python.org/dev/buildbot/all/x86%2520XP%2520trunk/builds/111 Buildbot URL: http://www.python.org/dev/buildbot/all/ Build Reason: Build Source Stamp: [branch trunk] HEAD Blamelist: andrew.kuchling Build had warnings: warnings test Excerpt from the test logfile: 1 test failed: test_dumbdbm ====================================================================== FAIL: test_dumbdbm_creation_mode (test.test_dumbdbm.DumbDBMTestCase) ---------------------------------------------------------------------- Traceback (most recent call last): File "C:\buildbot_py25\trunk.mcintyre-windows\build\lib\test\test_dumbdbm.py", line 51, in test_dumbdbm_creation_mode self.assertEqual(stat.S_IMODE(st.st_mode), 0632) AssertionError: 438 != 410 sincerely, -The Buildbot From buildbot at python.org Fri Dec 22 17:28:34 2006 From: buildbot at python.org (buildbot at python.org) Date: Fri, 22 Dec 2006 16:28:34 +0000 Subject: [Python-checkins] buildbot warnings in alpha Tru64 5.1 trunk Message-ID: <20061222162834.D57191E400D@bag.python.org> The Buildbot has detected a new failure of alpha Tru64 5.1 trunk. Full details are available at: http://www.python.org/dev/buildbot/all/alpha%2520Tru64%25205.1%2520trunk/builds/1338 Buildbot URL: http://www.python.org/dev/buildbot/all/ Build Reason: Build Source Stamp: [branch trunk] HEAD Blamelist: andrew.kuchling Build had warnings: warnings test Excerpt from the test logfile: 1 test failed: test_socket ====================================================================== FAIL: testInterruptedTimeout (test.test_socket.TCPTimeoutTest) ---------------------------------------------------------------------- Traceback (most recent call last): File "/net/ringneck/scratch1/nnorwitz/buildbot/trunk.norwitz-tru64/build/Lib/test/test_socket.py", line 847, in testInterruptedTimeout self.fail("got Alarm in wrong place") AssertionError: got Alarm in wrong place sincerely, -The Buildbot From python-checkins at python.org Fri Dec 22 17:43:27 2006 From: python-checkins at python.org (andrew.kuchling) Date: Fri, 22 Dec 2006 17:43:27 +0100 (CET) Subject: [Python-checkins] r53145 - python/trunk/Lib/test/test_uu.py Message-ID: <20061222164327.109141E400D@bag.python.org> Author: andrew.kuchling Date: Fri Dec 22 17:43:26 2006 New Revision: 53145 Modified: python/trunk/Lib/test/test_uu.py Log: [Bug #776202] Apply Walter Doerwald's patch to use text mode for encoded files Modified: python/trunk/Lib/test/test_uu.py ============================================================================== --- python/trunk/Lib/test/test_uu.py (original) +++ python/trunk/Lib/test/test_uu.py Fri Dec 22 17:43:26 2006 @@ -114,11 +114,11 @@ def test_encode(self): try: - fin = open(self.tmpin, 'wb') + fin = open(self.tmpin, 'w') fin.write(plaintext) fin.close() - fin = open(self.tmpin, 'rb') + fin = open(self.tmpin, 'r') fout = open(self.tmpout, 'w') uu.encode(fin, fout, self.tmpin, mode=0644) fin.close() @@ -130,7 +130,7 @@ self.assertEqual(s, encodedtextwrapped % (0644, self.tmpin)) # in_file and out_file as filenames - uu.encode(self.tmpin, self.tmpout, mode=0644) + uu.encode(self.tmpin, self.tmpout, self.tmpin, mode=0644) fout = open(self.tmpout, 'r') s = fout.read() fout.close() @@ -142,11 +142,11 @@ def test_decode(self): try: - f = open(self.tmpin, 'wb') + f = open(self.tmpin, 'w') f.write(encodedtextwrapped % (0644, self.tmpout)) f.close() - f = open(self.tmpin, 'rb') + f = open(self.tmpin, 'r') uu.decode(f) f.close() @@ -163,11 +163,11 @@ try: f = cStringIO.StringIO(encodedtextwrapped % (0644, self.tmpout)) - f = open(self.tmpin, 'rb') + f = open(self.tmpin, 'r') uu.decode(f) f.close() - f = open(self.tmpin, 'rb') + f = open(self.tmpin, 'r') self.assertRaises(uu.Error, uu.decode, f) f.close() finally: From amk at amk.ca Fri Dec 22 17:53:55 2006 From: amk at amk.ca (A.M. Kuchling) Date: Fri, 22 Dec 2006 11:53:55 -0500 Subject: [Python-checkins] buildbot warnings in x86 XP trunk In-Reply-To: <20061222154732.2ADBF1E400D@bag.python.org> References: <20061222154732.2ADBF1E400D@bag.python.org> Message-ID: <20061222165355.GA21623@localhost.localdomain> On Fri, Dec 22, 2006 at 03:47:32PM +0000, buildbot at python.org wrote: > Traceback (most recent call last): > File "C:\buildbot_py25\trunk.mcintyre-windows\build\lib\test\test_dumbdbm.py", line 51, in test_dumbdbm_creation_mode > self.assertEqual(stat.S_IMODE(st.st_mode), 0632) > AssertionError: 438 != 410 Waaaah. 438 = 0666, 410 = 0632, so it looks like the umask value returned is zero even though the test case is setting it to 002. By Googling, it looks like Cygwin supports umask. Anyone got a clue? --amk From python-checkins at python.org Fri Dec 22 19:41:42 2006 From: python-checkins at python.org (andrew.kuchling) Date: Fri, 22 Dec 2006 19:41:42 +0100 (CET) Subject: [Python-checkins] r53146 - in python/trunk/Lib: pty.py test/test_pty.py Message-ID: <20061222184142.939901E400D@bag.python.org> Author: andrew.kuchling Date: Fri Dec 22 19:41:42 2006 New Revision: 53146 Modified: python/trunk/Lib/pty.py python/trunk/Lib/test/test_pty.py Log: [Patch #783050 from Patrick Lynch] The emulation of forkpty() is incorrect; the master should close the slave fd. Added a test to test_pty.py that reads from the master_fd after doing a pty.fork(); without the fix it hangs forever instead of raising an exception. () 2.5 backport candidate. Modified: python/trunk/Lib/pty.py ============================================================================== --- python/trunk/Lib/pty.py (original) +++ python/trunk/Lib/pty.py Fri Dec 22 19:41:42 2006 @@ -121,7 +121,9 @@ # Explicitly open the tty to make it become a controlling tty. tmp_fd = os.open(os.ttyname(STDOUT_FILENO), os.O_RDWR) os.close(tmp_fd) - + else: + os.close(slave_fd) + # Parent and child process. return pid, master_fd Modified: python/trunk/Lib/test/test_pty.py ============================================================================== --- python/trunk/Lib/test/test_pty.py (original) +++ python/trunk/Lib/test/test_pty.py Fri Dec 22 19:41:42 2006 @@ -115,6 +115,12 @@ os._exit(4) else: debug("Waiting for child (%d) to finish."%pid) + line = os.read(master_fd, 80) + lines = line.replace('\r\n', '\n').split('\n') + if lines != ['In child, calling os.setsid()', + 'Good: OSError was raised.', '']: + raise TestFailed("Unexpected output from child: %r" % line) + (pid, status) = os.waitpid(pid, 0) res = status >> 8 debug("Child (%d) exited with status %d (%d)."%(pid, res, status)) @@ -127,6 +133,15 @@ elif res != 4: raise TestFailed, "pty.fork() failed for unknown reasons." + debug("Reading from master_fd now that the child has exited") + try: + s1 = os.read(master_fd, 1024) + except os.error: + pass + else: + raise TestFailed("Read from master_fd did not raise exception") + + os.close(master_fd) # pty.fork() passed. From buildbot at python.org Fri Dec 22 20:04:24 2006 From: buildbot at python.org (buildbot at python.org) Date: Fri, 22 Dec 2006 19:04:24 +0000 Subject: [Python-checkins] buildbot warnings in x86 gentoo trunk Message-ID: <20061222190424.E37F11E400D@bag.python.org> The Buildbot has detected a new failure of x86 gentoo trunk. Full details are available at: http://www.python.org/dev/buildbot/all/x86%2520gentoo%2520trunk/builds/1804 Buildbot URL: http://www.python.org/dev/buildbot/all/ Build Reason: Build Source Stamp: [branch trunk] HEAD Blamelist: andrew.kuchling Build had warnings: warnings test Excerpt from the test logfile: 1 test failed: test_pty sincerely, -The Buildbot From buildbot at python.org Fri Dec 22 20:04:55 2006 From: buildbot at python.org (buildbot at python.org) Date: Fri, 22 Dec 2006 19:04:55 +0000 Subject: [Python-checkins] buildbot warnings in amd64 gentoo trunk Message-ID: <20061222190455.E3E091E400D@bag.python.org> The Buildbot has detected a new failure of amd64 gentoo trunk. Full details are available at: http://www.python.org/dev/buildbot/all/amd64%2520gentoo%2520trunk/builds/1722 Buildbot URL: http://www.python.org/dev/buildbot/all/ Build Reason: Build Source Stamp: [branch trunk] HEAD Blamelist: andrew.kuchling Build had warnings: warnings test Excerpt from the test logfile: 1 test failed: test_pty sincerely, -The Buildbot From python-checkins at python.org Fri Dec 22 20:06:17 2006 From: python-checkins at python.org (andrew.kuchling) Date: Fri, 22 Dec 2006 20:06:17 +0100 (CET) Subject: [Python-checkins] r53147 - python/trunk/Lib/SimpleHTTPServer.py Message-ID: <20061222190617.57C231E400E@bag.python.org> Author: andrew.kuchling Date: Fri Dec 22 20:06:16 2006 New Revision: 53147 Modified: python/trunk/Lib/SimpleHTTPServer.py Log: [Patch #827559 from Chris Gonnerman] Make SimpleHTTPServer redirect when a directory URL is missing the trailing slash; this lets relative links work. Modified: python/trunk/Lib/SimpleHTTPServer.py ============================================================================== --- python/trunk/Lib/SimpleHTTPServer.py (original) +++ python/trunk/Lib/SimpleHTTPServer.py Fri Dec 22 20:06:16 2006 @@ -66,6 +66,12 @@ path = self.translate_path(self.path) f = None if os.path.isdir(path): + if not self.path.endswith('/'): + # redirect browser - doing basically what apache does + self.send_response(301) + self.send_header("Location", self.path + "/") + self.end_headers() + return None for index in "index.html", "index.htm": index = os.path.join(path, index) if os.path.exists(index): From buildbot at python.org Fri Dec 22 20:08:41 2006 From: buildbot at python.org (buildbot at python.org) Date: Fri, 22 Dec 2006 19:08:41 +0000 Subject: [Python-checkins] buildbot warnings in x86 mvlgcc trunk Message-ID: <20061222190841.E508E1E400D@bag.python.org> The Buildbot has detected a new failure of x86 mvlgcc trunk. Full details are available at: http://www.python.org/dev/buildbot/all/x86%2520mvlgcc%2520trunk/builds/128 Buildbot URL: http://www.python.org/dev/buildbot/all/ Build Reason: Build Source Stamp: [branch trunk] HEAD Blamelist: andrew.kuchling Build had warnings: warnings test Excerpt from the test logfile: 1 test failed: test_pty Traceback (most recent call last): File "./Lib/test/regrtest.py", line 546, in runtest_inner the_package = __import__(abstest, globals(), locals(), []) File "/home2/buildbot/slave/trunk.loewis-linux/build/Lib/test/test_pty.py", line 118, in line = os.read(master_fd, 80) OSError: [Errno 5] Input/output error sincerely, -The Buildbot From python-checkins at python.org Fri Dec 22 20:08:42 2006 From: python-checkins at python.org (andrew.kuchling) Date: Fri, 22 Dec 2006 20:08:42 +0100 (CET) Subject: [Python-checkins] r53148 - in python/branches/release25-maint: Lib/SimpleHTTPServer.py Misc/NEWS Message-ID: <20061222190842.43C0B1E400D@bag.python.org> Author: andrew.kuchling Date: Fri Dec 22 20:08:41 2006 New Revision: 53148 Modified: python/branches/release25-maint/Lib/SimpleHTTPServer.py python/branches/release25-maint/Misc/NEWS Log: [Patch #827559 from Chris Gonnerman] Make SimpleHTTPServer redirect when a directory URL is missing the trailing slash; this lets relative links work. Modified: python/branches/release25-maint/Lib/SimpleHTTPServer.py ============================================================================== --- python/branches/release25-maint/Lib/SimpleHTTPServer.py (original) +++ python/branches/release25-maint/Lib/SimpleHTTPServer.py Fri Dec 22 20:08:41 2006 @@ -66,6 +66,12 @@ path = self.translate_path(self.path) f = None if os.path.isdir(path): + if not self.path.endswith('/'): + # redirect browser - doing basically what apache does + self.send_response(301) + self.send_header("Location", self.path + "/") + self.end_headers() + return None for index in "index.html", "index.htm": index = os.path.join(path, index) if os.path.exists(index): Modified: python/branches/release25-maint/Misc/NEWS ============================================================================== --- python/branches/release25-maint/Misc/NEWS (original) +++ python/branches/release25-maint/Misc/NEWS Fri Dec 22 20:08:41 2006 @@ -125,6 +125,10 @@ - Bug #737202: Make CGIHTTPServer work for scripts in subdirectories. Fix by Titus Brown. +- Patch #827559: Make SimpleHTTPServer redirect when a directory URL + is missing the trailing slash, so that relative links work correctly. + Patch by Chris Gonnerman. + - Patch #1608267: fix a race condition in os.makedirs() is the directory to be created is already there. From python-checkins at python.org Fri Dec 22 20:21:27 2006 From: python-checkins at python.org (andrew.kuchling) Date: Fri, 22 Dec 2006 20:21:27 +0100 (CET) Subject: [Python-checkins] r53149 - python/trunk/Lib/test/test_pty.py Message-ID: <20061222192127.94EDD1E400D@bag.python.org> Author: andrew.kuchling Date: Fri Dec 22 20:21:27 2006 New Revision: 53149 Modified: python/trunk/Lib/test/test_pty.py Log: Darn; this test works when you run test_pty.py directly, but fails when regrtest runs it (the os.read() raises os.error). I can't figure out the cause, so am commenting out the test. Modified: python/trunk/Lib/test/test_pty.py ============================================================================== --- python/trunk/Lib/test/test_pty.py (original) +++ python/trunk/Lib/test/test_pty.py Fri Dec 22 20:21:27 2006 @@ -115,11 +115,11 @@ os._exit(4) else: debug("Waiting for child (%d) to finish."%pid) - line = os.read(master_fd, 80) - lines = line.replace('\r\n', '\n').split('\n') - if lines != ['In child, calling os.setsid()', - 'Good: OSError was raised.', '']: - raise TestFailed("Unexpected output from child: %r" % line) + ##line = os.read(master_fd, 80) + ##lines = line.replace('\r\n', '\n').split('\n') + ##if False and lines != ['In child, calling os.setsid()', + ## 'Good: OSError was raised.', '']: + ## raise TestFailed("Unexpected output from child: %r" % line) (pid, status) = os.waitpid(pid, 0) res = status >> 8 From buildbot at python.org Fri Dec 22 20:24:26 2006 From: buildbot at python.org (buildbot at python.org) Date: Fri, 22 Dec 2006 19:24:26 +0000 Subject: [Python-checkins] buildbot warnings in sparc solaris10 gcc trunk Message-ID: <20061222192426.33B001E400D@bag.python.org> The Buildbot has detected a new failure of sparc solaris10 gcc trunk. Full details are available at: http://www.python.org/dev/buildbot/all/sparc%2520solaris10%2520gcc%2520trunk/builds/1645 Buildbot URL: http://www.python.org/dev/buildbot/all/ Build Reason: Build Source Stamp: [branch trunk] HEAD Blamelist: andrew.kuchling Build had warnings: warnings test Excerpt from the test logfile: 1 test failed: test_pty sincerely, -The Buildbot From buildbot at python.org Fri Dec 22 20:25:33 2006 From: buildbot at python.org (buildbot at python.org) Date: Fri, 22 Dec 2006 19:25:33 +0000 Subject: [Python-checkins] buildbot warnings in g4 osx.4 trunk Message-ID: <20061222192533.77A4A1E400D@bag.python.org> The Buildbot has detected a new failure of g4 osx.4 trunk. Full details are available at: http://www.python.org/dev/buildbot/all/g4%2520osx.4%2520trunk/builds/1628 Buildbot URL: http://www.python.org/dev/buildbot/all/ Build Reason: Build Source Stamp: [branch trunk] HEAD Blamelist: andrew.kuchling Build had warnings: warnings test Excerpt from the test logfile: 1 test failed: test_pty sincerely, -The Buildbot From buildbot at python.org Fri Dec 22 20:34:09 2006 From: buildbot at python.org (buildbot at python.org) Date: Fri, 22 Dec 2006 19:34:09 +0000 Subject: [Python-checkins] buildbot warnings in ia64 Ubuntu trunk trunk Message-ID: <20061222193409.4151D1E400D@bag.python.org> The Buildbot has detected a new failure of ia64 Ubuntu trunk trunk. Full details are available at: http://www.python.org/dev/buildbot/all/ia64%2520Ubuntu%2520trunk%2520trunk/builds/281 Buildbot URL: http://www.python.org/dev/buildbot/all/ Build Reason: Build Source Stamp: [branch trunk] HEAD Blamelist: andrew.kuchling Build had warnings: warnings test Excerpt from the test logfile: 1 test failed: test_pty Traceback (most recent call last): File "./Lib/test/regrtest.py", line 546, in runtest_inner the_package = __import__(abstest, globals(), locals(), []) File "/home/pybot/buildarea/trunk.klose-debian-ia64/build/Lib/test/test_pty.py", line 118, in line = os.read(master_fd, 80) OSError: [Errno 5] Input/output error sincerely, -The Buildbot From buildbot at python.org Fri Dec 22 20:38:52 2006 From: buildbot at python.org (buildbot at python.org) Date: Fri, 22 Dec 2006 19:38:52 +0000 Subject: [Python-checkins] buildbot warnings in S-390 Debian trunk Message-ID: <20061222193852.37F901E400D@bag.python.org> The Buildbot has detected a new failure of S-390 Debian trunk. Full details are available at: http://www.python.org/dev/buildbot/all/S-390%2520Debian%2520trunk/builds/562 Buildbot URL: http://www.python.org/dev/buildbot/all/ Build Reason: Build Source Stamp: [branch trunk] HEAD Blamelist: andrew.kuchling Build had warnings: warnings test Excerpt from the test logfile: 1 test failed: test_pty sincerely, -The Buildbot From buildbot at python.org Fri Dec 22 20:52:34 2006 From: buildbot at python.org (buildbot at python.org) Date: Fri, 22 Dec 2006 19:52:34 +0000 Subject: [Python-checkins] buildbot warnings in x86 Ubuntu edgy (icc) trunk Message-ID: <20061222195234.EEC0A1E400D@bag.python.org> The Buildbot has detected a new failure of x86 Ubuntu edgy (icc) trunk. Full details are available at: http://www.python.org/dev/buildbot/all/x86%2520Ubuntu%2520edgy%2520%2528icc%2529%2520trunk/builds/1130 Buildbot URL: http://www.python.org/dev/buildbot/all/ Build Reason: Build Source Stamp: [branch trunk] HEAD Blamelist: andrew.kuchling Build had warnings: warnings test Excerpt from the test logfile: 1 test failed: test_pty Traceback (most recent call last): File "./Lib/test/regrtest.py", line 546, in runtest_inner the_package = __import__(abstest, globals(), locals(), []) File "/home/buildbot/Buildbot/trunk.baxter-ubuntu/build/Lib/test/test_pty.py", line 118, in line = os.read(master_fd, 80) OSError: [Errno 5] Input/output error sincerely, -The Buildbot From buildbot at python.org Fri Dec 22 22:38:03 2006 From: buildbot at python.org (buildbot at python.org) Date: Fri, 22 Dec 2006 21:38:03 +0000 Subject: [Python-checkins] buildbot warnings in x86 OpenBSD trunk Message-ID: <20061222213803.76FA31E400D@bag.python.org> The Buildbot has detected a new failure of x86 OpenBSD trunk. Full details are available at: http://www.python.org/dev/buildbot/all/x86%2520OpenBSD%2520trunk/builds/1452 Buildbot URL: http://www.python.org/dev/buildbot/all/ Build Reason: Build Source Stamp: [branch trunk] HEAD Blamelist: andrew.kuchling Build had warnings: warnings test Excerpt from the test logfile: 1 test failed: test_pty sincerely, -The Buildbot From python-checkins at python.org Fri Dec 22 22:48:20 2006 From: python-checkins at python.org (andrew.kuchling) Date: Fri, 22 Dec 2006 22:48:20 +0100 (CET) Subject: [Python-checkins] r53150 - python/trunk/Lib/test/test_pty.py Message-ID: <20061222214820.022351E400D@bag.python.org> Author: andrew.kuchling Date: Fri Dec 22 22:48:19 2006 New Revision: 53150 Modified: python/trunk/Lib/test/test_pty.py Log: Frak; this test also fails Modified: python/trunk/Lib/test/test_pty.py ============================================================================== --- python/trunk/Lib/test/test_pty.py (original) +++ python/trunk/Lib/test/test_pty.py Fri Dec 22 22:48:19 2006 @@ -133,13 +133,13 @@ elif res != 4: raise TestFailed, "pty.fork() failed for unknown reasons." - debug("Reading from master_fd now that the child has exited") - try: - s1 = os.read(master_fd, 1024) - except os.error: - pass - else: - raise TestFailed("Read from master_fd did not raise exception") + ##debug("Reading from master_fd now that the child has exited") + ##try: + ## s1 = os.read(master_fd, 1024) + ##except os.error: + ## pass + ##else: + ## raise TestFailed("Read from master_fd did not raise exception") os.close(master_fd) From buildbot at python.org Fri Dec 22 22:50:03 2006 From: buildbot at python.org (buildbot at python.org) Date: Fri, 22 Dec 2006 21:50:03 +0000 Subject: [Python-checkins] buildbot warnings in x86 OpenBSD 2.5 Message-ID: <20061222215003.5B3441E400D@bag.python.org> The Buildbot has detected a new failure of x86 OpenBSD 2.5. Full details are available at: http://www.python.org/dev/buildbot/all/x86%2520OpenBSD%25202.5/builds/133 Buildbot URL: http://www.python.org/dev/buildbot/all/ Build Reason: Build Source Stamp: [branch branches/release25-maint] HEAD Blamelist: andrew.kuchling Build had warnings: warnings test clean Excerpt from the test logfile: 1 test failed: test_subprocess sincerely, -The Buildbot From buildbot at python.org Fri Dec 22 22:53:22 2006 From: buildbot at python.org (buildbot at python.org) Date: Fri, 22 Dec 2006 21:53:22 +0000 Subject: [Python-checkins] buildbot failure in x86 OpenBSD trunk Message-ID: <20061222215322.B9A751E400D@bag.python.org> The Buildbot has detected a new failure of x86 OpenBSD trunk. Full details are available at: http://www.python.org/dev/buildbot/all/x86%2520OpenBSD%2520trunk/builds/1453 Buildbot URL: http://www.python.org/dev/buildbot/all/ Build Reason: Build Source Stamp: [branch trunk] HEAD Blamelist: andrew.kuchling BUILD FAILED: failed svn sincerely, -The Buildbot From python-checkins at python.org Sat Dec 23 06:22:30 2006 From: python-checkins at python.org (guido.van.rossum) Date: Sat, 23 Dec 2006 06:22:30 +0100 (CET) Subject: [Python-checkins] r53151 - peps/trunk/pep-3106.txt Message-ID: <20061223052230.D6EEC1E400E@bag.python.org> Author: guido.van.rossum Date: Sat Dec 23 06:22:30 2006 New Revision: 53151 Modified: peps/trunk/pep-3106.txt Log: Clarified lots of issues, added more open issues. Modified: peps/trunk/pep-3106.txt ============================================================================== --- peps/trunk/pep-3106.txt (original) +++ peps/trunk/pep-3106.txt Sat Dec 23 06:22:30 2006 @@ -15,9 +15,10 @@ This PEP proposes to change the .keys(), .values() and .items() methods of the built-in dict type to return a set-like or -multiset-like object whose contents are derived of the underlying -dictionary rather than a list which is a copy of the keys, etc.; and -to remove the .iterkeys(), .itervalues() and .iteritems() methods. +multiset-like (== bag-like) object whose contents are derived of the +underlying dictionary rather than a list which is a copy of the keys, +etc.; and to remove the .iterkeys(), .itervalues() and .iteritems() +methods. The approach is inspired by that taken in the Java Collections Framework [1]_. @@ -31,40 +32,43 @@ .itervalues() and .iteritems(). The idea is that code that currently (in 2.x) reads:: - for x in d.iterkeys(): ... + for k, v in d.iteritems(): ... should be rewritten as:: - for x in d.keys(): ... + for k, v in d.items(): ... -and code that currently reads:: +(and similar for .itervalues() and .iterkeys(), except the latter is +redundant since we can write that loop as ``for k in d``.) + +Code that currently reads:: a = d.keys() # assume we really want a list here -should be rewritten as +(etc.) should be rewritten as a = list(d.keys()) There are (at least) two ways to accomplish this. The original plan was to simply let .keys(), .values() and .items() return an iterator, -i.e. exactly what iterkeys(), itervalues() and iteritems() return -in Python 2.x. However, the Java Collections Framework [1]_ suggests +i.e. exactly what iterkeys(), itervalues() and iteritems() return in +Python 2.x. However, the Java Collections Framework [1]_ suggests that a better solution is possible: the methods return objects with -set behavior (for .keys() and .items()) or multiset behavior (for -.values()) that do not contain copies of the keys, values or items, -but rather reference the underlying dict and pull their values out of -the dict as needed. +set behavior (for .keys() and .items()) or multiset (== bag) behavior +(for .values()) that do not contain copies of the keys, values or +items, but rather reference the underlying dict and pull their values +out of the dict as needed. The advantage of this approach is that one can still write code like this:: - a = d.keys() - for x in a: ... - for x in a: ... - -Effectively, iter(d.keys()) in Python 3.0 does what d.iterkeys() does -in Python 2.x; but in most contexts we don't have to write the iter() -call because it is implied by a for-loop. + a = d.items() + for k, v in a: ... + for k, v in a: ... + +Effectively, iter(d.keys()) (etc.) in Python 3.0 will do what +d.iterkeys() (etc.) does in Python 2.x; but in most contexts we don't +have to write the iter() call because it is implied by a for-loop. The objects returned by the .keys() and .items() methods behave like sets with limited mutability; they allow removing elements, but not @@ -83,9 +87,9 @@ if a.keys() == b.keys(): ... and similarly for values. (Two multisets are deemed equal if they -have the same elements with the same cardinalities, -e.g. the multiset {1, 2, 2} is equal to the multiset {2, 1, 2} but -differs from the multiset {1, 2}.) +have the same elements with the same cardinalities, e.g. the multiset +{1, 2, 2} is equal to the multiset {2, 1, 2} but differs from the +multiset {1, 2}.) These operations are thread-safe only to the extent that using them in a thread-unsafe way may cause an exception but will not cause @@ -108,11 +112,13 @@ Specification ============= -I'll try pseudo-code to specify the semantics:: +I'm using pseudo-code to specify the semantics:: class dict: - # Omitting all other dict methods for brevity + # Omitting all other dict methods for brevity. + # The .iterkeys(), .itervalues() and .iteritems() methods + # will be removed. def keys(self): return d_keys(self) @@ -151,18 +157,23 @@ def clear(self): self.__d.clear() - def copy(self): - return set(self) - # The following operations should be implemented to be # compatible with sets; this can be done by exploiting - # the above primitive operations: + # the above primitive operations: # # <, <=, ==, !=, >=, > (returning a bool) # &, |, ^, - (returning a new, real set object) # &=, -= (updating in place and returning self; but not |=, ^=) # # as well as their method counterparts (.union(), etc.). + # + # To specify the semantics, we can specify x == y as: + # + # set(x) == set(y) if both x and y are d_keys instances + # set(x) == y if x is a d_keys instance + # x == set(y) if y is a d_keys instance + # + # and so on for all other operations. class d_items: @@ -180,9 +191,13 @@ yield key, self.__d[key] def remove(self, (key, value)): + if (key, value) not in self: + raise KeyError((key, value)) del self.__d[key] def discard(self, item): + # Defined in terms of 'in' and .remove() so overriding + # those will update discard appropriately. if item in self: self.remove(item) @@ -192,10 +207,55 @@ def clear(self): self.__d.clear() - def copy(self): - return set(self) - - # As well as the same set operations as mentioned for d_keys above. + # As well as the set operations mentioned for d_keys above. + # However the specifications suggested there will not work if + # the values aren't hashable. Fortunately, the operations can + # still be implemented efficiently. For example, this is how + # intersection can be specified: + + def __and__(self, other): + if isinstance(other, (set, frozenset, d_keys)): + result = set() + for item in other: + if item in self: + result.add(item) + return result + if not isinstance(other, d_items): + return NotImplemented + d = {} + if len(other) < len(self): + self, other = other, self + for item in self: + if item in other: + key, value = item + d[key] = value + return d.items() + + # And here is equality: + + def __eq__(self, other): + if isinstance(other, (set, frozenset, d_keys)): + if len(self) != len(other): + return False + for item in other: + if item not in self: + return False + return True + if not isinstance(other, d_items): + return NotImplemented + if len(self) != len(other): + return False + for item in self: + if item not in other: + return False + return True + + def __ne__(self, other): + # XXX Perhaps object.__ne__() should be defined this way. + result = self.__eq__(other) + if result is not NotImplemented: + result = not result + return result class d_values: @@ -206,7 +266,9 @@ return len(self.__d) def __contains__(self, value): - # Slow! Do we even want to implement this? + # This is slow, and it's what "x in y" uses as a fallback + # if __contains__ is not defined; but I'd rather make it + # explicit that it is supported. for v in self: if v == value: return True @@ -216,32 +278,71 @@ for key in self.__d: yield self.__d[key] - # Do we care about the following? + def __eq__(self, other): + if not isinstance(other, d_values): + return NotImplemented + if len(self) != len(other): + return False + # XXX Sometimes this could be optimized, but these are the + # semantics: we can't depend on the values to be hashable + # or comparable. + o = list(other) + for x in self: + try: + o.remove(x) + except ValueError: + return False + return True + + def __ne__(self, other): + result = self.__eq__(other) + if result is not NotImplemented: + result = not result + return result + +Note that we don't implement .copy() -- the presence of a .copy() +method suggests that the copy has the same type as the original, but +that's not feasible without copying the underlying dict. If you want +a copy of a specific type, like list or set, you can just pass one +of the above to the list() or set() constructor. - def pop(self): - return self.__d.popitem()[1] - def clear(self): - return self.__d.clear() +Open Issues +=========== - def copy(self): - # XXX What should this return? +I've left out the implementation of various set operations. These +could still present surprises. - # Should we bother implementing set-like operations on - # multisets? If so, how about mixed operations on sets and - # multisets? I'm not sure that these are worth the effort. - -I'm soliciting better names than d_keys, d_values and d_items; these -classes will be public so that their implementations may be reused by -the .keys(), .values() and .items() methods of other mappings. (Or -should they?) +Should d_values have mutating methods (pop(), clear())? Strawman: no. +Should d_values implement set operations (as defined for multisets). +Strawman: no. -Open Issues -=========== +Should d_keys, d_values and d_items have a public instance variable or +method through which one can retrieve the underlying dict? Strawman: +yes (but what should it be called?). + +I'm soliciting better names than d_keys, d_values and d_items. These +classes could be public so that their implementations could be reused +by the .keys(), .values() and .items() methods of other mappings. Or +should they? + +Should the d_keys, d_values and d_items classes be reusable? +Strawman: yes. + +Should they be subclassable? Strawman: yes (but see below). + +A particularly nasty issue is whether operations that are specified in +terms of other operations (e.g. .discard()) must really be implemented +in terms of those other operations; this may appear irrelevant but it +becomes relevant if these classes are ever subclassed. Historically, +Python has a really poor track record of specifying the semantics of +highly optimized built-in types clearly in such cases; my strawman is +to continue that trend. Subclassing may still be useful to *add* new +methods, for example. -Should the d_keys, d_values and d_items classes be reusable? Should -they be subclassable? +I'll leave the decisions (especially about naming) up to whoever +submits a working implementation. References From python-checkins at python.org Sat Dec 23 07:10:02 2006 From: python-checkins at python.org (neal.norwitz) Date: Sat, 23 Dec 2006 07:10:02 +0100 (CET) Subject: [Python-checkins] r53152 - peps/trunk/pep-3107.txt Message-ID: <20061223061002.595721E4004@bag.python.org> Author: neal.norwitz Date: Sat Dec 23 07:10:01 2006 New Revision: 53152 Modified: peps/trunk/pep-3107.txt Log: Fix some minor typos/formatting Modified: peps/trunk/pep-3107.txt ============================================================================== --- peps/trunk/pep-3107.txt (original) +++ peps/trunk/pep-3107.txt Sat Dec 23 07:10:01 2006 @@ -25,7 +25,7 @@ Because Python's 2.x series lacks a standard way of annotating a function's parameters and return values (e.g., with information about -a what type a function's return value should be), a variety of tools +what type a function's return value should be), a variety of tools and libraries have appeared to fill this gap [#tailexamp]_. Some utilise the decorators introduced in "PEP 318", while others parse a function's docstring, looking for annotations there. @@ -69,14 +69,14 @@ Another library might be used to provide typechecking for Python functions and methods. This library could use annotations to indicate the function's expected input and return types, possibly - something like :: + something like:: def haul(item: Haulable, *vargs: PackAnimal) -> Distance: ... However, neither the strings in the first example nor the type information in the second example have any meaning on their - own; meaning comes from third-party libraries alone. + own; meaning comes from third-party libraries alone. 3. Following from point 2, this PEP makes no attempt to introduce any kind of standard semantics, even for the built-in types. @@ -99,7 +99,7 @@ Annotations for parameters take the form of optional expressions that follow the parameter name. This example indicates that parameters 'a' -and 'c' should both be a ``Number``, while parameter 'b' should both +and 'c' should both be a ``Number``, while parameter 'b' should be a ``Mapping``:: def foo(a: Number, b: Mapping, c: Number = 5): @@ -149,8 +149,7 @@ Python expression. Like the annotations for parameters, this expression will be evaluated when the function definition is executed. -The grammar for function definitions [#grammar]_ is now something like -:: +The grammar for function definitions [#grammar]_ is now something like:: funcdef ::= [decorators] "def" funcname "(" [parameter_list] ")" ["->" expression] ":" suite From fdrake at acm.org Sat Dec 23 07:59:08 2006 From: fdrake at acm.org (Fred L. Drake, Jr.) Date: Sat, 23 Dec 2006 01:59:08 -0500 Subject: [Python-checkins] =?iso-8859-1?q?=5BPython-Dev=5D_r53110_-=09pyth?= =?iso-8859-1?q?on/trunk/Lib/mailbox=2Epy?= In-Reply-To: <458AED2E.5080709@v.loewis.de> References: <20061220194820.ED8DD1E4008@bag.python.org> <20061221135343.GA5855@localhost.localdomain> <458AED2E.5080709@v.loewis.de> Message-ID: <200612230159.08151.fdrake@acm.org> On Thursday 21 December 2006 15:23, Martin v. L?wis wrote: > Now it seem that introducing them has the unfortunate side effect > that people think they *have* to use them, and that doing so gives > better code... Speaking strictly for myself: I don't think I *have* to use them, but I do prefer to use them because I don't like magic constants that affect what a function does in code; I'd rather have a named constant for readability's sake. Maybe I just can't keep enough in my head, but I don't find I actually use seek() enough to remember what the numeric values mean with checking the reference documentation. -Fred -- Fred L. Drake, Jr. From python-checkins at python.org Sat Dec 23 17:40:14 2006 From: python-checkins at python.org (lars.gustaebel) Date: Sat, 23 Dec 2006 17:40:14 +0100 (CET) Subject: [Python-checkins] r53153 - in python/trunk: Lib/tarfile.py Lib/test/test_tarfile.py Misc/NEWS Message-ID: <20061223164014.613E21E4005@bag.python.org> Author: lars.gustaebel Date: Sat Dec 23 17:40:13 2006 New Revision: 53153 Modified: python/trunk/Lib/tarfile.py python/trunk/Lib/test/test_tarfile.py python/trunk/Misc/NEWS Log: Patch #1230446: tarfile.py: fix ExFileObject so that read() and tell() work correctly together with readline(). Will backport to 2.5. Modified: python/trunk/Lib/tarfile.py ============================================================================== --- python/trunk/Lib/tarfile.py (original) +++ python/trunk/Lib/tarfile.py Sat Dec 23 17:40:13 2006 @@ -628,140 +628,194 @@ #------------------------ # Extraction file object #------------------------ -class ExFileObject(object): - """File-like object for reading an archive member. - Is returned by TarFile.extractfile(). Support for - sparse files included. +class _FileInFile(object): + """A thin wrapper around an existing file object that + provides a part of its data as an individual file + object. """ - def __init__(self, tarfile, tarinfo): - self.fileobj = tarfile.fileobj - self.name = tarinfo.name - self.mode = "r" - self.closed = False - self.offset = tarinfo.offset_data - self.size = tarinfo.size - self.pos = 0L - self.linebuffer = "" - if tarinfo.issparse(): - self.sparse = tarinfo.sparse - self.read = self._readsparse - else: - self.read = self._readnormal + def __init__(self, fileobj, offset, size, sparse=None): + self.fileobj = fileobj + self.offset = offset + self.size = size + self.sparse = sparse + self.position = 0 - def __read(self, size): - """Overloadable read method. + def tell(self): + """Return the current file position. """ - return self.fileobj.read(size) - - def readline(self, size=-1): - """Read a line with approx. size. If size is negative, - read a whole line. readline() and read() must not - be mixed up (!). - """ - if size < 0: - size = sys.maxint - - nl = self.linebuffer.find("\n") - if nl >= 0: - nl = min(nl, size) - else: - size -= len(self.linebuffer) - while (nl < 0 and size > 0): - buf = self.read(min(size, 100)) - if not buf: - break - self.linebuffer += buf - size -= len(buf) - nl = self.linebuffer.find("\n") - if nl == -1: - s = self.linebuffer - self.linebuffer = "" - return s - buf = self.linebuffer[:nl] - self.linebuffer = self.linebuffer[nl + 1:] - while buf[-1:] == "\r": - buf = buf[:-1] - return buf + "\n" + return self.position - def readlines(self): - """Return a list with all (following) lines. + def seek(self, position): + """Seek to a position in the file. """ - result = [] - while True: - line = self.readline() - if not line: break - result.append(line) - return result + self.position = position - def _readnormal(self, size=None): - """Read operation for regular files. + def read(self, size=None): + """Read data from the file. """ - if self.closed: - raise ValueError("file is closed") - self.fileobj.seek(self.offset + self.pos) - bytesleft = self.size - self.pos if size is None: - bytestoread = bytesleft + size = self.size - self.position else: - bytestoread = min(size, bytesleft) - self.pos += bytestoread - return self.__read(bytestoread) + size = min(size, self.size - self.position) - def _readsparse(self, size=None): - """Read operation for sparse files. - """ - if self.closed: - raise ValueError("file is closed") + if self.sparse is None: + return self.readnormal(size) + else: + return self.readsparse(size) - if size is None: - size = self.size - self.pos + def readnormal(self, size): + """Read operation for regular files. + """ + self.fileobj.seek(self.offset + self.position) + self.position += size + return self.fileobj.read(size) + def readsparse(self, size): + """Read operation for sparse files. + """ data = [] while size > 0: - buf = self._readsparsesection(size) + buf = self.readsparsesection(size) if not buf: break size -= len(buf) data.append(buf) return "".join(data) - def _readsparsesection(self, size): + def readsparsesection(self, size): """Read a single section of a sparse file. """ - section = self.sparse.find(self.pos) + section = self.sparse.find(self.position) if section is None: return "" - toread = min(size, section.offset + section.size - self.pos) + size = min(size, section.offset + section.size - self.position) + if isinstance(section, _data): - realpos = section.realpos + self.pos - section.offset - self.pos += toread + realpos = section.realpos + self.position - section.offset self.fileobj.seek(self.offset + realpos) - return self.__read(toread) + self.position += size + return self.fileobj.read(size) else: - self.pos += toread - return NUL * toread + self.position += size + return NUL * size +#class _FileInFile + + +class ExFileObject(object): + """File-like object for reading an archive member. + Is returned by TarFile.extractfile(). + """ + blocksize = 1024 + + def __init__(self, tarfile, tarinfo): + self.fileobj = _FileInFile(tarfile.fileobj, + tarinfo.offset_data, + tarinfo.size, + getattr(tarinfo, "sparse", None)) + self.name = tarinfo.name + self.mode = "r" + self.closed = False + self.size = tarinfo.size + + self.position = 0 + self.buffer = "" + + def read(self, size=None): + """Read at most size bytes from the file. If size is not + present or None, read all data until EOF is reached. + """ + if self.closed: + raise ValueError("I/O operation on closed file") + + buf = "" + if self.buffer: + if size is None: + buf = self.buffer + self.buffer = "" + else: + buf = self.buffer[:size] + self.buffer = self.buffer[size:] + + if size is None: + buf += self.fileobj.read() + else: + buf += self.fileobj.read(size - len(buf)) + + self.position += len(buf) + return buf + + def readline(self, size=-1): + """Read one entire line from the file. If size is present + and non-negative, return a string with at most that + size, which may be an incomplete line. + """ + if self.closed: + raise ValueError("I/O operation on closed file") + + if "\n" in self.buffer: + pos = self.buffer.find("\n") + 1 + else: + buffers = [self.buffer] + while True: + buf = self.fileobj.read(self.blocksize) + buffers.append(buf) + if not buf or "\n" in buf: + self.buffer = "".join(buffers) + pos = self.buffer.find("\n") + 1 + if pos == 0: + # no newline found. + pos = len(self.buffer) + break + + if size != -1: + pos = min(size, pos) + + buf = self.buffer[:pos] + self.buffer = self.buffer[pos:] + self.position += len(buf) + return buf + + def readlines(self): + """Return a list with all remaining lines. + """ + result = [] + while True: + line = self.readline() + if not line: break + result.append(line) + return result def tell(self): """Return the current file position. """ - return self.pos + if self.closed: + raise ValueError("I/O operation on closed file") - def seek(self, pos, whence=0): + return self.position + + def seek(self, pos, whence=os.SEEK_SET): """Seek to a position in the file. """ - self.linebuffer = "" - if whence == 0: - self.pos = min(max(pos, 0), self.size) - if whence == 1: + if self.closed: + raise ValueError("I/O operation on closed file") + + if whence == os.SEEK_SET: + self.position = min(max(pos, 0), self.size) + elif whence == os.SEEK_CUR: if pos < 0: - self.pos = max(self.pos + pos, 0) + self.position = max(self.position + pos, 0) else: - self.pos = min(self.pos + pos, self.size) - if whence == 2: - self.pos = max(min(self.size + pos, self.size), 0) + self.position = min(self.position + pos, self.size) + elif whence == os.SEEK_END: + self.position = max(min(self.size + pos, self.size), 0) + else: + raise ValueError("Invalid argument") + + self.buffer = "" + self.fileobj.seek(self.position) def close(self): """Close the file object. @@ -769,20 +823,13 @@ self.closed = True def __iter__(self): - """Get an iterator over the file object. + """Get an iterator over the file's lines. """ - if self.closed: - raise ValueError("I/O operation on closed file") - return self - - def next(self): - """Get the next item from the file iterator. - """ - result = self.readline() - if not result: - raise StopIteration - return result - + while True: + line = self.readline() + if not line: + break + yield line #class ExFileObject #------------------ Modified: python/trunk/Lib/test/test_tarfile.py ============================================================================== --- python/trunk/Lib/test/test_tarfile.py (original) +++ python/trunk/Lib/test/test_tarfile.py Sat Dec 23 17:40:13 2006 @@ -110,7 +110,7 @@ """Test seek() method of _FileObject, incl. random reading. """ if self.sep != "|": - filename = "0-REGTYPE" + filename = "0-REGTYPE-TEXT" self.tar.extract(filename, dirname()) f = open(os.path.join(dirname(), filename), "rb") data = f.read() @@ -149,6 +149,16 @@ s2 = fobj.readlines() self.assert_(s1 == s2, "readlines() after seek failed") + fobj.seek(0) + self.assert_(len(fobj.readline()) == fobj.tell(), + "tell() after readline() failed") + fobj.seek(512) + self.assert_(len(fobj.readline()) + 512 == fobj.tell(), + "tell() after seek() and readline() failed") + fobj.seek(0) + line = fobj.readline() + self.assert_(fobj.read() == data[len(line):], + "read() after readline() failed") fobj.close() def test_old_dirtype(self): Modified: python/trunk/Misc/NEWS ============================================================================== --- python/trunk/Misc/NEWS (original) +++ python/trunk/Misc/NEWS Sat Dec 23 17:40:13 2006 @@ -103,6 +103,9 @@ Library ------- +- Patch #1230446: tarfile.py: fix ExFileObject so that read() and tell() + work correctly together with readline(). + - Patch #1484695: The tarfile module now raises a HeaderError exception if a buffer given to frombuf() is invalid. From python-checkins at python.org Sat Dec 23 17:51:48 2006 From: python-checkins at python.org (lars.gustaebel) Date: Sat, 23 Dec 2006 17:51:48 +0100 (CET) Subject: [Python-checkins] r53154 - in python/branches/release25-maint: Lib/tarfile.py Lib/test/test_tarfile.py Misc/NEWS Message-ID: <20061223165148.C8AFD1E4005@bag.python.org> Author: lars.gustaebel Date: Sat Dec 23 17:51:47 2006 New Revision: 53154 Modified: python/branches/release25-maint/Lib/tarfile.py python/branches/release25-maint/Lib/test/test_tarfile.py python/branches/release25-maint/Misc/NEWS Log: Patch #1230446: tarfile.py: fix ExFileObject so that read() and tell() work correctly together with readline(). (backport from rev. 53153) Modified: python/branches/release25-maint/Lib/tarfile.py ============================================================================== --- python/branches/release25-maint/Lib/tarfile.py (original) +++ python/branches/release25-maint/Lib/tarfile.py Sat Dec 23 17:51:47 2006 @@ -622,140 +622,194 @@ #------------------------ # Extraction file object #------------------------ -class ExFileObject(object): - """File-like object for reading an archive member. - Is returned by TarFile.extractfile(). Support for - sparse files included. +class _FileInFile(object): + """A thin wrapper around an existing file object that + provides a part of its data as an individual file + object. """ - def __init__(self, tarfile, tarinfo): - self.fileobj = tarfile.fileobj - self.name = tarinfo.name - self.mode = "r" - self.closed = False - self.offset = tarinfo.offset_data - self.size = tarinfo.size - self.pos = 0L - self.linebuffer = "" - if tarinfo.issparse(): - self.sparse = tarinfo.sparse - self.read = self._readsparse - else: - self.read = self._readnormal + def __init__(self, fileobj, offset, size, sparse=None): + self.fileobj = fileobj + self.offset = offset + self.size = size + self.sparse = sparse + self.position = 0 - def __read(self, size): - """Overloadable read method. + def tell(self): + """Return the current file position. """ - return self.fileobj.read(size) - - def readline(self, size=-1): - """Read a line with approx. size. If size is negative, - read a whole line. readline() and read() must not - be mixed up (!). - """ - if size < 0: - size = sys.maxint - - nl = self.linebuffer.find("\n") - if nl >= 0: - nl = min(nl, size) - else: - size -= len(self.linebuffer) - while (nl < 0 and size > 0): - buf = self.read(min(size, 100)) - if not buf: - break - self.linebuffer += buf - size -= len(buf) - nl = self.linebuffer.find("\n") - if nl == -1: - s = self.linebuffer - self.linebuffer = "" - return s - buf = self.linebuffer[:nl] - self.linebuffer = self.linebuffer[nl + 1:] - while buf[-1:] == "\r": - buf = buf[:-1] - return buf + "\n" + return self.position - def readlines(self): - """Return a list with all (following) lines. + def seek(self, position): + """Seek to a position in the file. """ - result = [] - while True: - line = self.readline() - if not line: break - result.append(line) - return result + self.position = position - def _readnormal(self, size=None): - """Read operation for regular files. + def read(self, size=None): + """Read data from the file. """ - if self.closed: - raise ValueError("file is closed") - self.fileobj.seek(self.offset + self.pos) - bytesleft = self.size - self.pos if size is None: - bytestoread = bytesleft + size = self.size - self.position else: - bytestoread = min(size, bytesleft) - self.pos += bytestoread - return self.__read(bytestoread) + size = min(size, self.size - self.position) - def _readsparse(self, size=None): - """Read operation for sparse files. - """ - if self.closed: - raise ValueError("file is closed") + if self.sparse is None: + return self.readnormal(size) + else: + return self.readsparse(size) - if size is None: - size = self.size - self.pos + def readnormal(self, size): + """Read operation for regular files. + """ + self.fileobj.seek(self.offset + self.position) + self.position += size + return self.fileobj.read(size) + def readsparse(self, size): + """Read operation for sparse files. + """ data = [] while size > 0: - buf = self._readsparsesection(size) + buf = self.readsparsesection(size) if not buf: break size -= len(buf) data.append(buf) return "".join(data) - def _readsparsesection(self, size): + def readsparsesection(self, size): """Read a single section of a sparse file. """ - section = self.sparse.find(self.pos) + section = self.sparse.find(self.position) if section is None: return "" - toread = min(size, section.offset + section.size - self.pos) + size = min(size, section.offset + section.size - self.position) + if isinstance(section, _data): - realpos = section.realpos + self.pos - section.offset - self.pos += toread + realpos = section.realpos + self.position - section.offset self.fileobj.seek(self.offset + realpos) - return self.__read(toread) + self.position += size + return self.fileobj.read(size) else: - self.pos += toread - return NUL * toread + self.position += size + return NUL * size +#class _FileInFile + + +class ExFileObject(object): + """File-like object for reading an archive member. + Is returned by TarFile.extractfile(). + """ + blocksize = 1024 + + def __init__(self, tarfile, tarinfo): + self.fileobj = _FileInFile(tarfile.fileobj, + tarinfo.offset_data, + tarinfo.size, + getattr(tarinfo, "sparse", None)) + self.name = tarinfo.name + self.mode = "r" + self.closed = False + self.size = tarinfo.size + + self.position = 0 + self.buffer = "" + + def read(self, size=None): + """Read at most size bytes from the file. If size is not + present or None, read all data until EOF is reached. + """ + if self.closed: + raise ValueError("I/O operation on closed file") + + buf = "" + if self.buffer: + if size is None: + buf = self.buffer + self.buffer = "" + else: + buf = self.buffer[:size] + self.buffer = self.buffer[size:] + + if size is None: + buf += self.fileobj.read() + else: + buf += self.fileobj.read(size - len(buf)) + + self.position += len(buf) + return buf + + def readline(self, size=-1): + """Read one entire line from the file. If size is present + and non-negative, return a string with at most that + size, which may be an incomplete line. + """ + if self.closed: + raise ValueError("I/O operation on closed file") + + if "\n" in self.buffer: + pos = self.buffer.find("\n") + 1 + else: + buffers = [self.buffer] + while True: + buf = self.fileobj.read(self.blocksize) + buffers.append(buf) + if not buf or "\n" in buf: + self.buffer = "".join(buffers) + pos = self.buffer.find("\n") + 1 + if pos == 0: + # no newline found. + pos = len(self.buffer) + break + + if size != -1: + pos = min(size, pos) + + buf = self.buffer[:pos] + self.buffer = self.buffer[pos:] + self.position += len(buf) + return buf + + def readlines(self): + """Return a list with all remaining lines. + """ + result = [] + while True: + line = self.readline() + if not line: break + result.append(line) + return result def tell(self): """Return the current file position. """ - return self.pos + if self.closed: + raise ValueError("I/O operation on closed file") - def seek(self, pos, whence=0): + return self.position + + def seek(self, pos, whence=os.SEEK_SET): """Seek to a position in the file. """ - self.linebuffer = "" - if whence == 0: - self.pos = min(max(pos, 0), self.size) - if whence == 1: + if self.closed: + raise ValueError("I/O operation on closed file") + + if whence == os.SEEK_SET: + self.position = min(max(pos, 0), self.size) + elif whence == os.SEEK_CUR: if pos < 0: - self.pos = max(self.pos + pos, 0) + self.position = max(self.position + pos, 0) else: - self.pos = min(self.pos + pos, self.size) - if whence == 2: - self.pos = max(min(self.size + pos, self.size), 0) + self.position = min(self.position + pos, self.size) + elif whence == os.SEEK_END: + self.position = max(min(self.size + pos, self.size), 0) + else: + raise ValueError("Invalid argument") + + self.buffer = "" + self.fileobj.seek(self.position) def close(self): """Close the file object. @@ -763,20 +817,13 @@ self.closed = True def __iter__(self): - """Get an iterator over the file object. + """Get an iterator over the file's lines. """ - if self.closed: - raise ValueError("I/O operation on closed file") - return self - - def next(self): - """Get the next item from the file iterator. - """ - result = self.readline() - if not result: - raise StopIteration - return result - + while True: + line = self.readline() + if not line: + break + yield line #class ExFileObject #------------------ Modified: python/branches/release25-maint/Lib/test/test_tarfile.py ============================================================================== --- python/branches/release25-maint/Lib/test/test_tarfile.py (original) +++ python/branches/release25-maint/Lib/test/test_tarfile.py Sat Dec 23 17:51:47 2006 @@ -110,7 +110,7 @@ """Test seek() method of _FileObject, incl. random reading. """ if self.sep != "|": - filename = "0-REGTYPE" + filename = "0-REGTYPE-TEXT" self.tar.extract(filename, dirname()) f = open(os.path.join(dirname(), filename), "rb") data = f.read() @@ -149,6 +149,16 @@ s2 = fobj.readlines() self.assert_(s1 == s2, "readlines() after seek failed") + fobj.seek(0) + self.assert_(len(fobj.readline()) == fobj.tell(), + "tell() after readline() failed") + fobj.seek(512) + self.assert_(len(fobj.readline()) + 512 == fobj.tell(), + "tell() after seek() and readline() failed") + fobj.seek(0) + line = fobj.readline() + self.assert_(fobj.read() == data[len(line):], + "read() after readline() failed") fobj.close() def test_old_dirtype(self): Modified: python/branches/release25-maint/Misc/NEWS ============================================================================== --- python/branches/release25-maint/Misc/NEWS (original) +++ python/branches/release25-maint/Misc/NEWS Sat Dec 23 17:51:47 2006 @@ -620,6 +620,9 @@ Library ------- +- Patch #1230446: tarfile.py: fix ExFileObject so that read() and tell() + work correctly together with readline(). + - Correction of patch #1455898: In the mbcs decoder, set final=False for stream decoder, but final=True for the decode function. From python-checkins at python.org Sat Dec 23 18:57:24 2006 From: python-checkins at python.org (lars.gustaebel) Date: Sat, 23 Dec 2006 18:57:24 +0100 (CET) Subject: [Python-checkins] r53155 - in python/trunk: Lib/tarfile.py Lib/test/test_tarfile.py Misc/NEWS Message-ID: <20061223175724.7E9491E400E@bag.python.org> Author: lars.gustaebel Date: Sat Dec 23 18:57:23 2006 New Revision: 53155 Modified: python/trunk/Lib/tarfile.py python/trunk/Lib/test/test_tarfile.py python/trunk/Misc/NEWS Log: Patch #1262036: Prevent TarFiles from being added to themselves under certain conditions. Will backport to 2.5. Modified: python/trunk/Lib/tarfile.py ============================================================================== --- python/trunk/Lib/tarfile.py (original) +++ python/trunk/Lib/tarfile.py Sat Dec 23 18:57:23 2006 @@ -1052,7 +1052,7 @@ can be determined, `mode' is overridden by `fileobj's mode. `fileobj' is not closed, when TarFile is closed. """ - self.name = name + self.name = os.path.abspath(name) if len(mode) > 1 or mode not in "raw": raise ValueError("mode must be 'r', 'a' or 'w'") @@ -1064,7 +1064,7 @@ self._extfileobj = False else: if self.name is None and hasattr(fileobj, "name"): - self.name = fileobj.name + self.name = os.path.abspath(fileobj.name) if hasattr(fileobj, "mode"): self.mode = fileobj.mode self._extfileobj = True @@ -1200,24 +1200,12 @@ except (ImportError, AttributeError): raise CompressionError("gzip module is not available") - pre, ext = os.path.splitext(name) - pre = os.path.basename(pre) - if ext == ".tgz": - ext = ".tar" - if ext == ".gz": - ext = "" - tarname = pre + ext - if fileobj is None: fileobj = file(name, mode + "b") - if mode != "r": - name = tarname - try: - t = cls.taropen(tarname, mode, - gzip.GzipFile(name, mode, compresslevel, fileobj) - ) + t = cls.taropen(name, mode, + gzip.GzipFile(name, mode, compresslevel, fileobj)) except IOError: raise ReadError("not a gzip file") t._extfileobj = False @@ -1236,21 +1224,13 @@ except ImportError: raise CompressionError("bz2 module is not available") - pre, ext = os.path.splitext(name) - pre = os.path.basename(pre) - if ext == ".tbz2": - ext = ".tar" - if ext == ".bz2": - ext = "" - tarname = pre + ext - if fileobj is not None: fileobj = _BZ2Proxy(fileobj, mode) else: fileobj = bz2.BZ2File(name, mode, compresslevel=compresslevel) try: - t = cls.taropen(tarname, mode, fileobj) + t = cls.taropen(name, mode, fileobj) except IOError: raise ReadError("not a bzip2 file") t._extfileobj = False @@ -1455,8 +1435,7 @@ arcname = name # Skip if somebody tries to archive the archive... - if self.name is not None \ - and os.path.abspath(name) == os.path.abspath(self.name): + if self.name is not None and os.path.abspath(name) == self.name: self._dbg(2, "tarfile: Skipped %r" % name) return Modified: python/trunk/Lib/test/test_tarfile.py ============================================================================== --- python/trunk/Lib/test/test_tarfile.py (original) +++ python/trunk/Lib/test/test_tarfile.py Sat Dec 23 18:57:23 2006 @@ -290,6 +290,20 @@ else: self.dst.addfile(tarinfo, f) + def test_add_self(self): + dstname = os.path.abspath(self.dstname) + + self.assertEqual(self.dst.name, dstname, "archive name must be absolute") + + self.dst.add(dstname) + self.assertEqual(self.dst.getnames(), [], "added the archive to itself") + + cwd = os.getcwd() + os.chdir(dirname()) + self.dst.add(dstname) + os.chdir(cwd) + self.assertEqual(self.dst.getnames(), [], "added the archive to itself") + class Write100Test(BaseTest): # The name field in a tar header stores strings of at most 100 chars. Modified: python/trunk/Misc/NEWS ============================================================================== --- python/trunk/Misc/NEWS (original) +++ python/trunk/Misc/NEWS Sat Dec 23 18:57:23 2006 @@ -103,6 +103,9 @@ Library ------- +- Patch #1262036: Prevent TarFiles from being added to themselves under + certain conditions. + - Patch #1230446: tarfile.py: fix ExFileObject so that read() and tell() work correctly together with readline(). From python-checkins at python.org Sat Dec 23 19:13:59 2006 From: python-checkins at python.org (lars.gustaebel) Date: Sat, 23 Dec 2006 19:13:59 +0100 (CET) Subject: [Python-checkins] r53156 - in python/branches/release25-maint: Lib/tarfile.py Lib/test/test_tarfile.py Misc/NEWS Message-ID: <20061223181359.454CB1E400E@bag.python.org> Author: lars.gustaebel Date: Sat Dec 23 19:13:57 2006 New Revision: 53156 Modified: python/branches/release25-maint/Lib/tarfile.py python/branches/release25-maint/Lib/test/test_tarfile.py python/branches/release25-maint/Misc/NEWS Log: Patch #1262036: Prevent TarFiles from being added to themselves under certain conditions. (backport from rev. 53155) Moved message from my previous change to the right place in Misc/NEWS. Modified: python/branches/release25-maint/Lib/tarfile.py ============================================================================== --- python/branches/release25-maint/Lib/tarfile.py (original) +++ python/branches/release25-maint/Lib/tarfile.py Sat Dec 23 19:13:57 2006 @@ -1044,7 +1044,7 @@ can be determined, `mode' is overridden by `fileobj's mode. `fileobj' is not closed, when TarFile is closed. """ - self.name = name + self.name = os.path.abspath(name) if len(mode) > 1 or mode not in "raw": raise ValueError("mode must be 'r', 'a' or 'w'") @@ -1056,7 +1056,7 @@ self._extfileobj = False else: if self.name is None and hasattr(fileobj, "name"): - self.name = fileobj.name + self.name = os.path.abspath(fileobj.name) if hasattr(fileobj, "mode"): self.mode = fileobj.mode self._extfileobj = True @@ -1192,24 +1192,12 @@ except (ImportError, AttributeError): raise CompressionError("gzip module is not available") - pre, ext = os.path.splitext(name) - pre = os.path.basename(pre) - if ext == ".tgz": - ext = ".tar" - if ext == ".gz": - ext = "" - tarname = pre + ext - if fileobj is None: fileobj = file(name, mode + "b") - if mode != "r": - name = tarname - try: - t = cls.taropen(tarname, mode, - gzip.GzipFile(name, mode, compresslevel, fileobj) - ) + t = cls.taropen(name, mode, + gzip.GzipFile(name, mode, compresslevel, fileobj)) except IOError: raise ReadError("not a gzip file") t._extfileobj = False @@ -1228,21 +1216,13 @@ except ImportError: raise CompressionError("bz2 module is not available") - pre, ext = os.path.splitext(name) - pre = os.path.basename(pre) - if ext == ".tbz2": - ext = ".tar" - if ext == ".bz2": - ext = "" - tarname = pre + ext - if fileobj is not None: fileobj = _BZ2Proxy(fileobj, mode) else: fileobj = bz2.BZ2File(name, mode, compresslevel=compresslevel) try: - t = cls.taropen(tarname, mode, fileobj) + t = cls.taropen(name, mode, fileobj) except IOError: raise ReadError("not a bzip2 file") t._extfileobj = False @@ -1447,8 +1427,7 @@ arcname = name # Skip if somebody tries to archive the archive... - if self.name is not None \ - and os.path.abspath(name) == os.path.abspath(self.name): + if self.name is not None and os.path.abspath(name) == self.name: self._dbg(2, "tarfile: Skipped %r" % name) return Modified: python/branches/release25-maint/Lib/test/test_tarfile.py ============================================================================== --- python/branches/release25-maint/Lib/test/test_tarfile.py (original) +++ python/branches/release25-maint/Lib/test/test_tarfile.py Sat Dec 23 19:13:57 2006 @@ -290,6 +290,20 @@ else: self.dst.addfile(tarinfo, f) + def test_add_self(self): + dstname = os.path.abspath(self.dstname) + + self.assertEqual(self.dst.name, dstname, "archive name must be absolute") + + self.dst.add(dstname) + self.assertEqual(self.dst.getnames(), [], "added the archive to itself") + + cwd = os.getcwd() + os.chdir(dirname()) + self.dst.add(dstname) + os.chdir(cwd) + self.assertEqual(self.dst.getnames(), [], "added the archive to itself") + class Write100Test(BaseTest): # The name field in a tar header stores strings of at most 100 chars. Modified: python/branches/release25-maint/Misc/NEWS ============================================================================== --- python/branches/release25-maint/Misc/NEWS (original) +++ python/branches/release25-maint/Misc/NEWS Sat Dec 23 19:13:57 2006 @@ -122,6 +122,12 @@ Library ------- +- Patch #1262036: Prevent TarFiles from being added to themselves under + certain conditions. + +- Patch #1230446: tarfile.py: fix ExFileObject so that read() and tell() + work correctly together with readline(). + - Bug #737202: Make CGIHTTPServer work for scripts in subdirectories. Fix by Titus Brown. @@ -620,9 +626,6 @@ Library ------- -- Patch #1230446: tarfile.py: fix ExFileObject so that read() and tell() - work correctly together with readline(). - - Correction of patch #1455898: In the mbcs decoder, set final=False for stream decoder, but final=True for the decode function. From python-checkins at python.org Sun Dec 24 02:33:17 2006 From: python-checkins at python.org (guido.van.rossum) Date: Sun, 24 Dec 2006 02:33:17 +0100 (CET) Subject: [Python-checkins] r53157 - peps/trunk/pep-3106.txt Message-ID: <20061224013317.101B61E400F@bag.python.org> Author: guido.van.rossum Date: Sun Dec 24 02:33:16 2006 New Revision: 53157 Modified: peps/trunk/pep-3106.txt Log: - Clarify that the ordering of keys, values and items is compatible. - Note that comparing two d_items instances could compare the underlying dicts. - Ask whether we need more of a motivation. - Observe that we could cache+reuse the keys/values/items objects. Modified: peps/trunk/pep-3106.txt ============================================================================== --- peps/trunk/pep-3106.txt (original) +++ peps/trunk/pep-3106.txt Sun Dec 24 02:33:16 2006 @@ -23,6 +23,7 @@ The approach is inspired by that taken in the Java Collections Framework [1]_. + Introduction ============ @@ -243,6 +244,7 @@ return True if not isinstance(other, d_items): return NotImplemented + # XXX We could also just compare the underlying dicts... if len(self) != len(other): return False for item in self: @@ -306,13 +308,32 @@ a copy of a specific type, like list or set, you can just pass one of the above to the list() or set() constructor. +Also note that the specification implies that the order in which items +are returned by .keys(), .values() and .items() is the same (just as +it was in Python 2.x), because the order is all derived from the dict +iterator (which is presumably arbitrary but stable as long as a dict +isn't modified). This can be expressed by the following invariant:: + + list(d.items()) == list(zip(d.keys(), d.values())) + Open Issues =========== +Do we need more of a motivation? I would think that being able to do +set operations on keys and items without having to copy them should +speak for itself. + I've left out the implementation of various set operations. These could still present surprises. +It would be okay if multiple calls to d.keys() (etc.) returned the +same object, since the object's only state is the dict to which it +refers. Is this worth having extra slots in the dict object for? +Should that be a weak reference or should the d_keys (etc.) object +live forever once created? Strawman: probably not worth the extra +slots in every dict. + Should d_values have mutating methods (pop(), clear())? Strawman: no. Should d_values implement set operations (as defined for multisets). From python-checkins at python.org Tue Dec 26 07:08:29 2006 From: python-checkins at python.org (neal.norwitz) Date: Tue, 26 Dec 2006 07:08:29 +0100 (CET) Subject: [Python-checkins] r53158 - peps/trunk/pep-3100.txt Message-ID: <20061226060829.CF5AF1E4008@bag.python.org> Author: neal.norwitz Date: Tue Dec 26 07:08:28 2006 New Revision: 53158 Modified: peps/trunk/pep-3100.txt Log: * Add pep reference for annotations. * Remove support for from ... import * at function scope. It will continue to be supported at class and module scope. This is the last dependency on the distinction between optimized and unoptimized byte codes within functions (LOAD_FAST vs LOAD_NAME), so remove that support as well. exec is already a function which also required specialization. Modified: peps/trunk/pep-3100.txt ============================================================================== --- peps/trunk/pep-3100.txt (original) +++ peps/trunk/pep-3100.txt Tue Dec 26 07:08:28 2006 @@ -65,7 +65,7 @@ * True division becomes default behavior [#pep238]_ [done] * ``exec`` as a statement is not worth it -- make it a function [done] -* (Maybe) add optional declarations for static typing [10]_ +* (Maybe) add optional declarations for static typing [#pep3107] [10]_ * Support only new-style classes; classic classes will be gone [1]_ [done] * Replace ``print`` by a function [14]_ [#pep3105]_ * Use ``except E1, E2, E3 as err:`` if you want the error variable. [3]_ @@ -80,6 +80,8 @@ * Exceptions might grow an attribute to store the traceback [11]_ * floats will not be acceptable as arguments in place of ints for operations where floats are inadvertantly accepted (PyArg_ParseTuple() i & l formats) +* Remove from ... import * at function scope. This means that functions + can always be optimized and support for unoptimized functions can go away. * Imports will be absolute by default. [done] Relative imports must be explicitly specified [#pep328]_ [done] * __init__.py might become optional in sub-packages. __init__.py will still @@ -358,6 +360,9 @@ .. [#pep3105] PEP 3105 (Make print a function) http://www.python.org/dev/peps/pep-3105 +.. [#pep3107] PEP 3107 (Function Annotations) + http://www.python.org/dev/peps/pep-3107 + Copyright ========= From uyuatq at cerebralitch.com Tue Dec 26 12:28:21 2006 From: uyuatq at cerebralitch.com (Chris Hendricks) Date: Tue, 26 Dec 2006 13:28:21 +0200 Subject: [Python-checkins] finesse Message-ID: <000701c728e2$142e5850$7b83c2be@uuxfa> How many of us have enough time to do everything that needs to be done? Find out all about the revolution of audio books. The key is doing that which needs to be done RIGHT NOW and setting the right priorities. Are you ready to begin racking up freebies accepting great book offers? -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-checkins/attachments/20061226/c9790c3f/attachment.html -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: image/gif Size: 11334 bytes Desc: not available Url : http://mail.python.org/pipermail/python-checkins/attachments/20061226/c9790c3f/attachment.gif From python-checkins at python.org Wed Dec 27 04:25:32 2006 From: python-checkins at python.org (andrew.kuchling) Date: Wed, 27 Dec 2006 04:25:32 +0100 (CET) Subject: [Python-checkins] r53159 - python/trunk/Lib/hmac.py Message-ID: <20061227032532.5E9881E4008@bag.python.org> Author: andrew.kuchling Date: Wed Dec 27 04:25:31 2006 New Revision: 53159 Modified: python/trunk/Lib/hmac.py Log: [Part of patch #1182394] Move the HMAC blocksize to be a class-level constant; this allows changing it in a subclass. To accommodate this, copy() now uses __class__. Also add some text to a comment. Modified: python/trunk/Lib/hmac.py ============================================================================== --- python/trunk/Lib/hmac.py (original) +++ python/trunk/Lib/hmac.py Wed Dec 27 04:25:31 2006 @@ -7,7 +7,7 @@ trans_36 = "".join ([chr (x ^ 0x36) for x in xrange(256)]) # The size of the digests returned by HMAC depends on the underlying -# hashing module used. +# hashing module used. Use digest_size from the instance of HMAC instead. digest_size = None # A unique object passed by HMAC.copy() to the HMAC constructor, in order @@ -20,6 +20,7 @@ This supports the API for Cryptographic Hash Functions (PEP 247). """ + blocksize = 64 # 512-bit HMAC; can be changed in subclasses. def __init__(self, key, msg = None, digestmod = None): """Create a new HMAC object. @@ -47,7 +48,7 @@ self.inner = self.digest_cons() self.digest_size = self.inner.digest_size - blocksize = 64 + blocksize = self.blocksize if len(key) > blocksize: key = self.digest_cons(key).digest() @@ -70,7 +71,7 @@ An update to this copy won't affect the original object. """ - other = HMAC(_secret_backdoor_key) + other = self.__class__(_secret_backdoor_key) other.digest_cons = self.digest_cons other.digest_size = self.digest_size other.inner = self.inner.copy() From buildbot at python.org Wed Dec 27 04:30:35 2006 From: buildbot at python.org (buildbot at python.org) Date: Wed, 27 Dec 2006 03:30:35 +0000 Subject: [Python-checkins] buildbot failure in alpha Tru64 5.1 trunk Message-ID: <20061227033035.2939C1E4008@bag.python.org> The Buildbot has detected a new failure of alpha Tru64 5.1 trunk. Full details are available at: http://www.python.org/dev/buildbot/all/alpha%2520Tru64%25205.1%2520trunk/builds/1346 Buildbot URL: http://www.python.org/dev/buildbot/all/ Build Reason: Build Source Stamp: [branch trunk] HEAD Blamelist: andrew.kuchling BUILD FAILED: failed svn sincerely, -The Buildbot From python-checkins at python.org Wed Dec 27 04:31:29 2006 From: python-checkins at python.org (andrew.kuchling) Date: Wed, 27 Dec 2006 04:31:29 +0100 (CET) Subject: [Python-checkins] r53160 - in python/trunk: Lib/hmac.py Misc/ACKS Misc/NEWS Message-ID: <20061227033129.5830A1E4008@bag.python.org> Author: andrew.kuchling Date: Wed Dec 27 04:31:24 2006 New Revision: 53160 Modified: python/trunk/Lib/hmac.py python/trunk/Misc/ACKS python/trunk/Misc/NEWS Log: [Rest of patch #1182394] Add ._current() method so that we can use the written-in-C .hexdigest() method Modified: python/trunk/Lib/hmac.py ============================================================================== --- python/trunk/Lib/hmac.py (original) +++ python/trunk/Lib/hmac.py Wed Dec 27 04:31:24 2006 @@ -78,6 +78,15 @@ other.outer = self.outer.copy() return other + def _current(self): + """Return a hash object for the current state. + + To be used only internally with digest() and hexdigest(). + """ + h = self.outer.copy() + h.update(self.inner.digest()) + return h + def digest(self): """Return the hash value of this hashing object. @@ -85,15 +94,14 @@ not altered in any way by this function; you can continue updating the object after calling this function. """ - h = self.outer.copy() - h.update(self.inner.digest()) + h = self._current() return h.digest() def hexdigest(self): """Like digest(), but returns a string of hexadecimal digits instead. """ - return "".join([hex(ord(x))[2:].zfill(2) - for x in tuple(self.digest())]) + h = self._current() + return h.hexdigest() def new(key, msg = None, digestmod = None): """Create a new hashing object and return it. Modified: python/trunk/Misc/ACKS ============================================================================== --- python/trunk/Misc/ACKS (original) +++ python/trunk/Misc/ACKS Wed Dec 27 04:31:24 2006 @@ -285,6 +285,7 @@ Albert Hofkamp Jonathan Hogg Gerrit Holl +Shane Holloway Rune Holm Philip Homburg Naofumi Honda Modified: python/trunk/Misc/NEWS ============================================================================== --- python/trunk/Misc/NEWS (original) +++ python/trunk/Misc/NEWS Wed Dec 27 04:31:24 2006 @@ -103,6 +103,8 @@ Library ------- +- Patch #1182394 from Shane Holloway: speed up HMAC.hexdigest. + - Patch #1262036: Prevent TarFiles from being added to themselves under certain conditions. From buildbot at python.org Wed Dec 27 05:11:11 2006 From: buildbot at python.org (buildbot at python.org) Date: Wed, 27 Dec 2006 04:11:11 +0000 Subject: [Python-checkins] buildbot failure in x86 XP trunk Message-ID: <20061227041111.6BA5B1E4008@bag.python.org> The Buildbot has detected a new failure of x86 XP trunk. Full details are available at: http://www.python.org/dev/buildbot/all/x86%2520XP%2520trunk/builds/121 Buildbot URL: http://www.python.org/dev/buildbot/all/ Build Reason: Build Source Stamp: [branch trunk] HEAD Blamelist: andrew.kuchling BUILD FAILED: failed failed slave lost sincerely, -The Buildbot From buildbot at python.org Wed Dec 27 07:44:04 2006 From: buildbot at python.org (buildbot at python.org) Date: Wed, 27 Dec 2006 06:44:04 +0000 Subject: [Python-checkins] buildbot warnings in x86 OpenBSD trunk Message-ID: <20061227064404.ED46A1E4008@bag.python.org> The Buildbot has detected a new failure of x86 OpenBSD trunk. Full details are available at: http://www.python.org/dev/buildbot/all/x86%2520OpenBSD%2520trunk/builds/1457 Buildbot URL: http://www.python.org/dev/buildbot/all/ Build Reason: Build Source Stamp: [branch trunk] HEAD Blamelist: andrew.kuchling Build had warnings: warnings failed slave lost sincerely, -The Buildbot From python-checkins at python.org Wed Dec 27 11:30:47 2006 From: python-checkins at python.org (lars.gustaebel) Date: Wed, 27 Dec 2006 11:30:47 +0100 (CET) Subject: [Python-checkins] r53161 - in python/trunk: Lib/tarfile.py Lib/test/test_tarfile.py Misc/NEWS Message-ID: <20061227103047.E34651E4008@bag.python.org> Author: lars.gustaebel Date: Wed Dec 27 11:30:46 2006 New Revision: 53161 Modified: python/trunk/Lib/tarfile.py python/trunk/Lib/test/test_tarfile.py python/trunk/Misc/NEWS Log: Patch #1504073: Fix tarfile.open() for mode "r" with a fileobj argument. Will backport to 2.5. Modified: python/trunk/Lib/tarfile.py ============================================================================== --- python/trunk/Lib/tarfile.py (original) +++ python/trunk/Lib/tarfile.py Wed Dec 27 11:30:46 2006 @@ -1141,9 +1141,13 @@ # Find out which *open() is appropriate for opening the file. for comptype in cls.OPEN_METH: func = getattr(cls, cls.OPEN_METH[comptype]) + if fileobj is not None: + saved_pos = fileobj.tell() try: return func(name, "r", fileobj) except (ReadError, CompressionError): + if fileobj is not None: + fileobj.seek(saved_pos) continue raise ReadError("file could not be opened successfully") Modified: python/trunk/Lib/test/test_tarfile.py ============================================================================== --- python/trunk/Lib/test/test_tarfile.py (original) +++ python/trunk/Lib/test/test_tarfile.py Wed Dec 27 11:30:46 2006 @@ -648,6 +648,16 @@ b = "a" + buf[1:] # manipulate the buffer, so checksum won't match. self.assertRaises(tarfile.HeaderError, tarfile.TarInfo.frombuf, b) +class OpenFileobjTest(BaseTest): + # Test for SF bug #1496501. + + def test_opener(self): + fobj = StringIO.StringIO("foo\n") + try: + tarfile.open("", "r", fileobj=fobj) + except tarfile.ReadError: + self.assertEqual(fobj.tell(), 0, "fileobj's position has moved") + if bz2: # Bzip2 TestCases class ReadTestBzip2(ReadTestGzip): @@ -693,6 +703,7 @@ tests = [ FileModeTest, HeaderErrorTest, + OpenFileobjTest, ReadTest, ReadStreamTest, ReadDetectTest, Modified: python/trunk/Misc/NEWS ============================================================================== --- python/trunk/Misc/NEWS (original) +++ python/trunk/Misc/NEWS Wed Dec 27 11:30:46 2006 @@ -103,6 +103,8 @@ Library ------- +- Patch #1504073: Fix tarfile.open() for mode "r" with a fileobj argument. + - Patch #1182394 from Shane Holloway: speed up HMAC.hexdigest. - Patch #1262036: Prevent TarFiles from being added to themselves under From python-checkins at python.org Wed Dec 27 11:36:59 2006 From: python-checkins at python.org (lars.gustaebel) Date: Wed, 27 Dec 2006 11:36:59 +0100 (CET) Subject: [Python-checkins] r53162 - in python/branches/release25-maint: Lib/tarfile.py Lib/test/test_tarfile.py Misc/NEWS Message-ID: <20061227103659.CC3391E4008@bag.python.org> Author: lars.gustaebel Date: Wed Dec 27 11:36:58 2006 New Revision: 53162 Modified: python/branches/release25-maint/Lib/tarfile.py python/branches/release25-maint/Lib/test/test_tarfile.py python/branches/release25-maint/Misc/NEWS Log: Patch #1504073: Fix tarfile.open() for mode "r" with a fileobj argument. Backport from rev. 53161. Modified: python/branches/release25-maint/Lib/tarfile.py ============================================================================== --- python/branches/release25-maint/Lib/tarfile.py (original) +++ python/branches/release25-maint/Lib/tarfile.py Wed Dec 27 11:36:58 2006 @@ -1133,9 +1133,13 @@ # Find out which *open() is appropriate for opening the file. for comptype in cls.OPEN_METH: func = getattr(cls, cls.OPEN_METH[comptype]) + if fileobj is not None: + saved_pos = fileobj.tell() try: return func(name, "r", fileobj) except (ReadError, CompressionError): + if fileobj is not None: + fileobj.seek(saved_pos) continue raise ReadError("file could not be opened successfully") Modified: python/branches/release25-maint/Lib/test/test_tarfile.py ============================================================================== --- python/branches/release25-maint/Lib/test/test_tarfile.py (original) +++ python/branches/release25-maint/Lib/test/test_tarfile.py Wed Dec 27 11:36:58 2006 @@ -625,6 +625,15 @@ self.assertEqual(tarfile.filemode(0755), '-rwxr-xr-x') self.assertEqual(tarfile.filemode(07111), '---s--s--t') +class OpenFileobjTest(BaseTest): + # Test for SF bug #1496501. + + def test_opener(self): + fobj = StringIO.StringIO("foo\n") + try: + tarfile.open("", "r", fileobj=fobj) + except tarfile.ReadError: + self.assertEqual(fobj.tell(), 0, "fileobj's position has moved") if bz2: # Bzip2 TestCases @@ -670,6 +679,7 @@ tests = [ FileModeTest, + OpenFileobjTest, ReadTest, ReadStreamTest, ReadDetectTest, Modified: python/branches/release25-maint/Misc/NEWS ============================================================================== --- python/branches/release25-maint/Misc/NEWS (original) +++ python/branches/release25-maint/Misc/NEWS Wed Dec 27 11:36:58 2006 @@ -122,6 +122,8 @@ Library ------- +- Patch #1504073: Fix tarfile.open() for mode "r" with a fileobj argument. + - Patch #1262036: Prevent TarFiles from being added to themselves under certain conditions. From buildbot at python.org Wed Dec 27 11:42:01 2006 From: buildbot at python.org (buildbot at python.org) Date: Wed, 27 Dec 2006 10:42:01 +0000 Subject: [Python-checkins] buildbot failure in alpha Tru64 5.1 2.5 Message-ID: <20061227104201.428641E4008@bag.python.org> The Buildbot has detected a new failure of alpha Tru64 5.1 2.5. Full details are available at: http://www.python.org/dev/buildbot/all/alpha%2520Tru64%25205.1%25202.5/builds/138 Buildbot URL: http://www.python.org/dev/buildbot/all/ Build Reason: Build Source Stamp: [branch branches/release25-maint] HEAD Blamelist: lars.gustaebel BUILD FAILED: failed svn sincerely, -The Buildbot From buildbot at python.org Wed Dec 27 12:12:04 2006 From: buildbot at python.org (buildbot at python.org) Date: Wed, 27 Dec 2006 11:12:04 +0000 Subject: [Python-checkins] buildbot warnings in x86 XP trunk Message-ID: <20061227111204.C93821E4009@bag.python.org> The Buildbot has detected a new failure of x86 XP trunk. Full details are available at: http://www.python.org/dev/buildbot/all/x86%2520XP%2520trunk/builds/122 Buildbot URL: http://www.python.org/dev/buildbot/all/ Build Reason: Build Source Stamp: [branch trunk] HEAD Blamelist: lars.gustaebel Build had warnings: warnings test Excerpt from the test logfile: 2 tests failed: test_dumbdbm test_uu ====================================================================== FAIL: test_dumbdbm_creation_mode (test.test_dumbdbm.DumbDBMTestCase) ---------------------------------------------------------------------- Traceback (most recent call last): File "C:\buildbot_py25\trunk.mcintyre-windows\build\lib\test\test_dumbdbm.py", line 55, in test_dumbdbm_creation_mode self.assertEqual(stat.S_IMODE(st.st_mode), 0635) AssertionError: 438 != 413 ====================================================================== FAIL: test_encode (test.test_uu.UUFileTest) ---------------------------------------------------------------------- Traceback (most recent call last): File "C:\buildbot_py25\trunk.mcintyre-windows\build\lib\test\test_uu.py", line 137, in test_encode self.assertEqual(s, encodedtextwrapped % (0644, self.tmpin)) AssertionError: 'begin 644 @testi\nM5&AE(\'-M;V]T:"US8V%L960@<\'ET:&]N(&-R97!T(&]V97(@=&AE(\'-L965P\n):6YG(&1O9PT*\n \nend\n' != 'begin 644 @testi\nM5&AE(\'-M;V]T:"US8V%L960@<\'ET:&]N(&-R97!T(&]V97(@=&AE(\'-L965P\n(:6YG(&1O9PH \n \nend\n' sincerely, -The Buildbot From buildbot at python.org Wed Dec 27 13:18:37 2006 From: buildbot at python.org (buildbot at python.org) Date: Wed, 27 Dec 2006 12:18:37 +0000 Subject: [Python-checkins] buildbot warnings in x86 OpenBSD 2.5 Message-ID: <20061227121837.62AEC1E4009@bag.python.org> The Buildbot has detected a new failure of x86 OpenBSD 2.5. Full details are available at: http://www.python.org/dev/buildbot/all/x86%2520OpenBSD%25202.5/builds/136 Buildbot URL: http://www.python.org/dev/buildbot/all/ Build Reason: Build Source Stamp: [branch branches/release25-maint] HEAD Blamelist: lars.gustaebel Build had warnings: warnings failed slave lost sincerely, -The Buildbot From python-checkins at python.org Wed Dec 27 18:57:25 2006 From: python-checkins at python.org (guido.van.rossum) Date: Wed, 27 Dec 2006 18:57:25 +0100 (CET) Subject: [Python-checkins] r53163 - sandbox/trunk/overload Message-ID: <20061227175725.229FE1E4009@bag.python.org> Author: guido.van.rossum Date: Wed Dec 27 18:57:24 2006 New Revision: 53163 Modified: sandbox/trunk/overload/ (props changed) Log: Add basic svn:ignore property. From python-checkins at python.org Wed Dec 27 18:59:08 2006 From: python-checkins at python.org (paul.dubois) Date: Wed, 27 Dec 2006 18:59:08 +0100 (CET) Subject: [Python-checkins] r53164 - tracker/instances/python-dev/scripts/roundup-summary Message-ID: <20061227175908.7491A1E4009@bag.python.org> Author: paul.dubois Date: Wed Dec 27 18:59:07 2006 New Revision: 53164 Modified: tracker/instances/python-dev/scripts/roundup-summary Log: Put in kludge for local execution. Got it out of dos format. Tested on tracker, ok. Ready to go. Modified: tracker/instances/python-dev/scripts/roundup-summary ============================================================================== --- tracker/instances/python-dev/scripts/roundup-summary (original) +++ tracker/instances/python-dev/scripts/roundup-summary Wed Dec 27 18:59:07 2006 @@ -1,876 +1,879 @@ -#!/usr/bin/env python -# Make sure you are using the python that has the roundup runtime used by the -# tracker. Requires Python 2.3 or later. -# -# Script to create a tracker summary by Richard Jones and Paul Dubois -import sys, math -import roundup -import roundup.date, roundup.instance -import optparse , datetime -import cStringIO, MimeWriter, smtplib -from roundup.mailer import SMTPConnection - -### CONFIGURATION -# List of statuses to treat as closed -- these don't have to all exist. -resolvedStatusDefault = 'resolved,done,done-cbb,closed,faq' - -# Period of time for report. Uses roundup syntax for ranges. -defaultDates = '-1w;' - -# Email address of recipient of report, if any. -defaultMailTo = '' - -# Comma-delimited list of statuses not to include in report. -ignoredStatusesDefault = '' - -# Number of most-discussed messages to display -discussionMax = 10 - -# Smallest number of messages to be eligible for 'most discussed'. -discussionThreshold = 3 - -# Date format per time.strftime -dateFormat="%x" #locale-appropriate - -##### END CONFIGURATION; ALSO SEE CUSTOMIZATION BELOW - -usage = """%prog trackerHome [--mail mailTo] - [--dates 'date1;date2'] - [--brief] - # less likely - [--resolved 'status1,status2'] - [--status 'status1,status2'] - [--output filename] - [--errors filename] - # for maintainers - [--DEBUG] - [--AUDIT recent|all] - dates is a roundup date range such as: - '-1w;' -- the last week (the default) - '-3m;' -- the last 3 months - 'from 2006-10-25 to 2006-12-25' -- Thanksgiving to Christmas, 2006 - - mailTo is one or more email addresses, comma delimited. - resolved is a list of statuses to treat as 'closed'. - statuses are names of statuses to ignore. - - Be sure to protect commas and semicolons from the shell with quotes! - Execute %prog --help for detailed help -""" -#### Options -parser = optparse.OptionParser(usage=usage) -parser.add_option('-b','--brief', dest='brief', action='store_true', - default=False, - help='Show summary only, no tables.') -parser.add_option('-a','--audit', dest='audit', - default='', metavar = 'all|recent', - help='Print journal for "all" or "recent" transactions, then halt.') -parser.add_option('-D','--DEBUG', dest='debug', action='store_true', - default=False, - help='Just print the result; if mailTo set, print email but do not send it.') -parser.add_option('-d','--dates', dest='dates', - default=defaultDates, metavar="'from;to'", - help="""Specification for range of dates, such as: \ -'-1w;' -- previous week; -'-1y;' -- previous year; -'from 2006-11-1 to 2006-12-1' -- exact period""") -parser.add_option('-m','--mail', dest='mailTo', - default=defaultMailTo, - help='Mail the report to the address(es) mailTo; if not given, print report.') -parser.add_option('-s','--status', dest='ignore', metavar="STATUSES_TO_IGNORE", - default=ignoredStatusesDefault, - help="Comma-delimited list of statuses to ignore in report.") -parser.add_option('-r','--resolved', dest='resolved', - default=resolvedStatusDefault, - help="Comma-delimited list of statuses that corresponds to being 'closed'.") -parser.add_option('-o','--output', dest='output', - default='', metavar='FILENAME', - help='File name for output; default is stdout.') -parser.add_option('-e','--errors', dest='errors', - default='', metavar='FILENAME', - help='File name for error output; default is stderr.') - -#### Get the command line args: -(options, args) = parser.parse_args() -if options.output: - sys.stdout = open(options.output, 'w') -if options.errors: - sys.stderr = open(options.errors, 'w') - -if len(args) != 1: - parser.error("""Incorrect number of arguments; - you must supply a tracker home.""") -instanceHome = args[0] -# Open the instance -instance = roundup.instance.open(instanceHome) -db = instance.open('admin') - -# CUSTOMIZATION -dateWidth = len(roundup.date.Date('2006-09-30').pretty(format=dateFormat)) -titleWidth = 72 #zero means no limit -durationWidth = len('9999 days') -tableStyle = 'border="1" cellspacing="0" cellpadding="3"' - -def formatDuration(duration): - "Change a duration into text." - return "%4.0f days" % (duration.as_seconds()/(3600.*24),) - -def closedOrBlank(statusID): - "CLOSED or a blank" - if statusID in resolvedStatusIDS: - return "CLOSED" - else: - return "" - -# Additional filter(s) to use in picking out issues. -# Depends on the schema. -notThese = ('notices', 'faq', 'todo', 'feature', 'wish') -try: - priorityIDS = db.priority.getnodeids(None, retired=None) - priorityNames = [db.priority.get(p, 'name') for p in priorityIDS] - acceptablePriorities = [priorityIDS[i] for i in range(len(priorityIDS)) if \ - priorityNames[i] not in notThese] -except: #for example, priority is not in the schema - acceptablePriorities = [] - -def F(**args): - "args is the dictionary to return, with additions if desired." - if acceptablePriorities: - args['priority'] = acceptablePriorities - return args - - -# Set what fields show up in the different tables. -# May need to modify getIssueAttribute to match your schema or add things -# you want to compute. -# Each field has a title and a field width. -# In text mode: -# a title of '
    , indent' means a new line is started for each -# record, and the integer indent indicates an indentation for the next line. -# If used, titles are omitted. -# In html mode,
    is ignored. - -### Text Tables -# The 'Created or Repopened' table, text mode. -createdTable = """ - titles: - 'Title', titleWidth - dateWidth - 'Date', dateWidth - '
    ', 0 - 'Status', len('CLOSED') - 'Link', linkWidth - 'Action', actionWidth - 'By', userNameWidth - records: - title - (reopenedDate or creation).pretty(format=dateFormat) - closedOrBlank(statusID) - link(issueNumber) - reopened or 'created' - reopener or creator -""" -# The table of closed issues, text mode. -closedTable = """ - titles: - 'Title', titleWidth - durationWidth - 'Duration', durationWidth - '
    ', len('CLOSED') - 'Link', linkWidth - 'By', userNameWidth - records: - title - formatDuration(duration) - link(issueNumber) - actor -""" -# The table of most discussed issues, text mode. -discussedTable = """ - titles: - 'N', -3 - 'Title', titleWidth - durationWidth - 'Duration', durationWidth - '
    ', 0 - 'Status', statusWidth - 'Link', linkWidth - records: - numberOfMessages - title - formatDuration(duration) - status - link(issueNumber) -""" - -### HTML Tables -# The 'Created or Repopened' table, html mode. -# Titles are links, use zero on width; limit is applied in hlink -htmlCreatedTable = """ - titles: - 'Title', 0 - 'Status', len('CLOSED') - 'Date', dateWidth - 'Action', actionWidth - 'By', userNameWidth - records: - hlink(issueNumber, title) - closedOrBlank(statusID) - (reopenedDate or creation).pretty(format=dateFormat) - reopened or 'created' - reopener or creator -""" -# The table of closed issues, html mode. -htmlClosedTable = """ - titles: - 'Title', 0 - 'By', userNameWidth - 'Duration', durationWidth - records: - hlink(issueNumber, title) - actor - formatDuration(duration) -""" -# The table of most discussed issues, text mode. -htmlDiscussedTable = """ - titles: - 'N', -3 - 'Title', 0 - 'Status', statusWidth - 'Duration', durationWidth - records: - numberOfMessages - hlink(issueNumber, title) - status - formatDuration(duration) -""" -### END CUSTOMIZATION -# well, except you might want to add to this...locals in this -# routine are usable in the 'records' section of tables. - -def getIssueAttributes (issueID): - """Return dictionaries with the issue's title, etc. - Assumes issue was created no later than to_value - """ - issueNumber = issueID - reopened = '' - reopener = '' - reopenedDate = '' - numberOfMessages = 0 - status2 = db.issue.get(issueID, 'status') - status1 = status2 - actor2 = db.issue.get(issueID, 'actor') - activity2 = db.issue.get(issueID, 'activity') - statusID = None - actorID = None - activity = None - -# programming note: -# the journal records the OLD value of the status in the data field -# So we know the end value (status2) and can walk backwards through it -# Want to set statusID = status in effect at to_value -# Also discover any activity that changed a resolved to non-resolved. - journal = db.issue.history(issueID) - journal.reverse() -# this trick catches the first time we are in the interval of interest - if activity2 < to_value: - statusID = statusID or status2 - actorID = actorID or actor2 - activity = activity or activity2 - - for x,ts,userid,act,data in journal: - inPeriod = ts >= from_value and ts < to_value - if inPeriod: - statusID = statusID or status2 - actorID = actorID or actor2 - activity = activity or activity2 - if act == 'set': - if data.has_key('messages'): - if inPeriod: - numberOfMessages += 1 - if data.has_key('status'): - status1 = data['status'] - if ts < to_value: - if (status1 in resolvedStatusIDS) and \ - (status2 not in resolvedStatusIDS): - if not reopened: # want the latest reopener only - if inPeriod and issueID not in recentlyCreatedIssueIDS: - reopenedIssueIDS.append(issueID) - reopened = 'reopened' - reopener = userMap[userid] - reopenedDate = ts - actor2 = userid - activity2 = ts - status2 = status1 - - messages.append((numberOfMessages, issueID)) -# get these set if not done before - statusID = statusID or status2 - activity = activity or activity2 - actorID = actorID or actor2 -# calculate the fields for the reports - status = statusMap[statusID] - actor = userMap[actorID] - title = db.issue.get(issueID, 'title') - creation = db.issue.get(issueID, 'creation') - creatorID = db.issue.get(issueID, 'creator') - creator = userMap[creatorID] - if statusID in resolvedStatusIDS: - duration = activity - (reopenedDate or creation) - else: - duration = to_value - (reopenedDate or creation) - if options.debug: - print >>bugfile, issueID, status, creator, actor, "%4.0f" %(duration.as_seconds()/(3600.24)), \ - activity.pretty(dateFormat), reopenedDate or 'created', creation.pretty(dateFormat) -# out of a sense of neatness - del status1, status2, actor2, activity2 - del x, ts, userid, act, data, journal -# return the dictionary of local values for use in evals of table values. - return locals() - -### Utility -def link (issueID): - "url of issue whose ID is issueID" - return "%sissue%s" % (db.config.TRACKER_WEB, issueID) - -def hlink (issueID, title): - "html link to url/title of issue whose ID is issueID" - return '''%s''' %(link(issueID), title[:titleWidth]) - -def statusCompare (x, y): - """Compare two statusIDs by order.""" - xs = db.status.get(x, 'order') - ys = db.status.get(y, 'order') - c = float(xs) - float(ys) - if c >= 0.0: - return int(c) - else: - return -int(abs(c)) - -def issueIdCompare (x, y): - """Compare two issue ids numerically.""" - return int(x) - int(y) - -def issueStatus(issueID): - """Get the status name from an issueID.""" - sid = db.issue.get(issueID, 'status') - return db.status.get(sid, 'name') - -def statusUsable (statusID): - """Is this status is one we want to deal with?""" - if db.status.is_retired(statusID): - return False - if db.status.get(statusID, 'name') in ignoredStatuses: - return False - return True - -#Table writers - -class Table (object): - def __init__ (self, caption, issueIDS, tableSpec): - self.caption = caption + ' (%d)' % len(issueIDS) - self.issueIDS = issueIDS - self.breaks = [] - self.spec = self.parse(tableSpec) - - def parse(self, tableSpec): - """Sample: - titles: - 'ID', -6 - 'Title', 25 - 'Status', 30 - records: - id - title - status - """ - titles = [] - fields = [] - fws = [] - for line in tableSpec.split('\n'): - line = line.strip() - if not line: continue - if line.startswith("titles"): - inTitles = True - elif line.startswith("records"): - inTitles = False - elif inTitles: - title, fw = eval(line) - if title == '
    ': - self.breaks.append((len(titles), fw)) - else: - titles.append(title) - if fw > 0: - fw = max(fw, len(title)) - elif fw < 0: - fw = min(fw, -len(title)) - fws.append(fw) - else: - fields.append(line) - self.titles = titles - self.fields = fields - self.fws = fws - if len(titles) != len(fields): - raise ValueError, 'Number of titles and fields do not match.' - if len(titles) == 0: - raise ValueError, 'No titles or fields given' - - def write(self, device): - if not self.issueIDS: - return - fields = self.fields - fws = self.fws - self.prologue(device) - self.writeFields(device, fields, fws) - self.epilogue(device) - - def writeTitles(self, device, titles, fws): - self.startTitles(device, titles, fws) - for i in range(len(titles)): - t = titles[i] - fw = fws[i] - self.startTitle(device, t, fw) - self.writeTitle(device, t, fw) - self.endTitle(device, t, fw) - self.endTitles(device, titles, fws) - - def writeFields(self, device, fields, fws): - for issueID in self.issueIDS: - d = issueAttributes[issueID] - self.startFields(d, device, fields, fws) - for i in range(len(fields)): - f = fields[i] - fw = fws[i] - self.startField(d, device, f, fw) - self.writeField(d, device, f, fw) - self.endField(d, device, f, fw) - for count, indent in self.breaks: - if i+1 == count: - print >>device - if indent: - print >>device, ' '.ljust(indent), - self.endFields(d, device, fields, fws) - - def prologue(self, device): - print >>device - print >>device, self.caption - print >>device, '_'*len(self.caption) - print >>device - if not self.breaks: - self.writeTitles(device, self.titles, self.fws) - - def epilogue(self, device): - print >>device - - def startTitles(self, device, titles, fws): - pass - - def endTitles(self, device, titles, fws): - print >>device - - def startTitle(self, device, title, fw): - pass - - def writeTitle(self, device, title, fw): - fwa = abs(fw) - if fwa > 0: - print >>device, title[0:fwa].ljust(fwa), - elif fwa < 0: - print >>device, title[0:fwa].rjust(fwa), - else: - print >>device, title, - - def endTitle(self, device, title, fw): - pass - - def startFields(self, d, device, fields, fws): - pass - - def endFields(self, d, device, fields, fws): - print >>device - if self.breaks: print >>device - - def startField(self, d, device, field, fw): - pass - - def writeField(self, d, device, field, fw): - fwa = abs(fw) - value = str(eval(field, d, globals())) - if fw > 0: - print >>device, value[0:fwa].ljust(fwa), - elif fw < 0: - print >>device, value[0:fwa].rjust(fwa), - else: - print >>device, value, - - def endField(self, d, device, field, fw): - pass - -class htmlTable (Table): - def __init__ (self, caption, issueIDS, tableSpec): - super(htmlTable, self).__init__(caption, issueIDS, tableSpec) - - def prologue(self, device): - print >>device, """
    -""" % (tableStyle, self.caption) - self.writeTitles(device, self.titles, self.fws) - - def epilogue(self, device): - print >>device, '
    %s
    ' - - def startTitles(self, device, titles, fws): - print >>device, ' ' - - def endTitles(self, device, titles, fws): - print >>device, ' ' - - def startTitle(self, device, title, fw): - print >>device, ' ', - - def writeTitle(self, device, title, fw): - if not title: - title = ' ' - fwa = abs(fw) - if fw != 0: - print >>device, title[0:fwa], - else: - print >>device, title, - - def endTitle(self, device, title, fw): - print >>device, '' - - def startFields(self, d, device, fields, fws): - print >>device, ' ' - - def endFields(self, d, device, fields, fws): - print >>device, ' ' - - def startField(self, d, device, field, fw): - print >>device, ' ', - - def writeField(self, d, device, field, fw): - if field == 'issueRef': - field = 'issueHRef' - fw = 0 - value = str(eval(field, d, globals())) - fwa = abs(fw) - if not value: - value = ' ' - fwa = 0 - if fwa != 0: - print >>device, value[0:fwa], - else: - print >>device, value, - - def endField(self, d, device, field, fw): - print >>device, '' - -# Summary writers -def htmlSummary(body, caption): - "Print html summary" - print >>body, '

    ACTIVITY SUMMARY ('+ from_value.pretty(format=dateFormat) + \ - ' - ' + to_value.pretty(format=dateFormat) + ')

    ' - print >>body, '

    %s at %s

    ' % (db.config.TRACKER_NAME, - db.config.TRACKER_WEB) - print >>body, '

    ' - print >>body, '''To view or respond to any of the issues listed - below, simply click on the issue ID. Do not respond to - this message.''' - print >>body, '

    ' - print >>body, '

    ' - fmt = "%5d open (%+3d) / %5d closed (%+3d) / %5d total (%+3d)" - print >>body, '

    ' - print >>body, '

    ' - print >>body, fmt % \ - (nOpen, nOpen-nOpenOld, nClosed, nClosed-nClosedOld, (nOpen+nClosed), - (nOpen+nClosed)-(nOpenOld+nClosedOld)) - print >>body, '

    ' - print >>body, "

    " - print >>body, '

    ' - print >>body, "Average duration of open issues:", "%3.0f" % averageDuration, "days." - print >>body, '

    ' - print >>body, "

    " - print >>body, "Median duration of open issues:", "%3.0f" % medianDuration, "days." - print >>body, '

    ' - print >>body, '

    ' - print >>body, ''' - - -''' % (tableStyle, caption) - for sid in statusIDS: - if sid in resolvedStatusIDS: - continue - (ntot, nold) = statusReport[sid] - name = statusMap[sid] - print >>body, ''''''% \ - (name, ntot, ntot-nold) - print >>body, '
    %s
    STATUS NumberChange
    %s%6d%+6d
    ' - print >>body, '

    ' - - -def textSummary(body, caption): - "Print text summary" - print >>body - print >>body, 'ACTIVITY SUMMARY ('+ from_value.pretty(format=dateFormat) + \ - ' - ' + to_value.pretty(format=dateFormat) + ')' - print >>body, '%s at %s' % (db.config.TRACKER_NAME, db.config.TRACKER_WEB) - print >>body, ''' -To view or respond to any of the issues listed below, click on the issue -number. Do NOT respond to this message. -''' - print >>body - fmt = "%5d open (%+3d) / %5d closed (%+3d) / %5d total (%+3d)" - print >>body, fmt % \ - (nOpen, nOpen-nOpenOld, nClosed, nClosed-nClosedOld, (nOpen+nClosed), - (nOpen+nClosed)-(nOpenOld+nClosedOld)) - print >>body - print >>body, "Average duration of open issues:", "%3.0f" % averageDuration, "days." - print >>body, "Median duration of open issues:", "%3.0f" % medianDuration, "days." - print >>body - print >>body, caption - for sid in statusIDS: - if sid in resolvedStatusIDS: - continue - (ntot, nold) = statusReport[sid] - name = statusMap[sid] - fmt = "%" + str(statusWidth) + "s %5d (%+3d)" - print >>body, (fmt % (name, ntot, ntot-nold)) - - -def writeTextReport(device): - "Write the report in text mode to device." - textSummary(device, "Open Issues Breakdown") - - if not options.brief: - messages.sort() - messages.reverse() - t = Table('Issues Created Or Reopened', createdOrReopenedIDS, - createdTable) - t.write(device) - - t = Table('Issues Now Closed', recentlyClosedIssueIDS, closedTable) - t.write(device) - - t = Table('Top Issues Most Discussed', discussedIDS, discussedTable) - t.write(device) - -def writeHtmlReport(device): - "Write the report in html mode to device." - htmlSummary(device, 'Open Issues Breakdown') - if not options.brief: - t = htmlTable('Issues Created Or Reopened', createdOrReopenedIDS, - htmlCreatedTable) - t.write(device) - - t = htmlTable('Issues Now Closed', recentlyClosedIssueIDS, - htmlClosedTable) - t.write(device) - - t = htmlTable('Top Issues Most Discussed', discussedIDS, - htmlDiscussedTable) - t.write(device) - -def writeAudit(device, issueIDS): - "Write audit of given issues to device." - for issueID in issueIDS: - journal = db.issue.history(issueID) - for x,ts,userid,act,data in journal: - user = db.user.get(userid, 'username') - print >>device, x, ts, '%s (%s)'%(userid, user), act - if act == 'set': - for d, v in data.items(): - print >>device, ' ', d, ': ', v - -# Options processing -if options.debug: - bugfile = open('bugfile', 'w') - print >>bugfile, options -# ...dates -dates = roundup.date.Range(options.dates, roundup.date.Date) -from_value = dates.from_value -to_value = dates.to_value -if to_value is None: - to_value = roundup.date.Date('.') -if from_value is None: - from_value = roundup.date.Date('1980-1-1') -early_period = ';%s'%from_value -whole_period = ';%s'%to_value -# ... statuses -ignoredStatuses = [s.strip() for s in options.ignore.split(',')] -if options.debug: - print >>bugfile, "from,to", from_value, to_value - print >>bugfile, 'acceptablePriorities', acceptablePriorities - print >>bugfile, 'ignoredStatuses', ignoredStatuses - -# ...audit -if options.audit: -# Name of audit file (not usually used by normal users) - auditFilename = 'audit.txt' - if options.audit not in ['all', 'recent']: - raise ValueError, "AUDIT option must be 'recent' or 'all'." - - audit = open(auditFilename, 'w') - if options.audit == 'recent': - IDS = db.issue.filter(None, F(activity=options.dates)) - elif options.audit == 'full': - IDS = db.issue.filter(None, F(activity=whole_period)) - IDS.sort(issueIdCompare) - writeAudit(audit, IDS) - audit.close() - sys.exit(0) - - -# MAIN -# Make lists and maps of things -# Users -adminUserID = db.user.lookup('admin') -userIDS_ALL = db.user.getnodeids(retired=None) -userMap = {None: adminUserID} -userLookup = {} -for userid in userIDS_ALL: - name = db.user.get(userid, 'username') - userLookup[name] = userid - userMap[userid] = name -userNames = userLookup.keys() -userNameWidth = max([len(uname) for uname in userNames]) - -# Make map of statuses / names, including retired ones. -# Just doing lookup on names will miss retired ones. -statusIDS_ALL = db.status.getnodeids(retired=None) -statusLookup = {'None': None} -statusMap = {None: 'None'} -for sid in statusIDS_ALL: - name = db.status.get(sid, 'name') - statusLookup[name] = sid - statusMap[sid] = name - -# Make a list of statuses considered closed (including retired ones) -resolvedStatusOptions = options.resolved.split(',') -resolvedStatusIDS = [] -for r in resolvedStatusOptions: - try: - sid = statusLookup[r] - resolvedStatusIDS.append(sid) - except KeyError: - pass - -if options.debug: - print >>bugfile, 'statusLookup', statusLookup - print >>bugfile, 'resolvedStatusIDS', resolvedStatusIDS - -statusIDS = [sid for sid in statusIDS_ALL if statusUsable(sid)] -statusIDS.sort(statusCompare) -statusNames = [statusMap[sid] for sid in statusIDS] -statusWidth = max([len(s) for s in statusLookup.keys()]) -actionWidth = len('reopened') - -# Important note: for 'all', get only issues created before to_value -# Not just efficient, simplifies logic in getIssueAttribue - -# All issues -allIssueIDS = db.issue.filter(None, F(creation=whole_period)) -allIssueIDS.sort(issueIdCompare) -earlyIssueIDS = db.issue.filter(None, F(creation=early_period)) - -# Closed issues -oldClosedIssueIDS = db.issue.filter(None, F(creation=early_period, - status= resolvedStatusIDS)) -closedIssueIDS = db.issue.filter(None,F(creation=whole_period, - status=resolvedStatusIDS)) -recentlyClosedIssueIDS=db.issue.filter(None, F(activity=options.dates, - status=resolvedStatusIDS)) -recentlyClosedIssueIDS.sort(issueIdCompare) - -# Created and reopened issues -recentlyCreatedIssueIDS=db.issue.filter(None, F(creation=options.dates)) -reopenedIssueIDS = [] # gets accumulated in getIssueAttributes - -# Create more data needed for reports -if allIssueIDS: - maxIssueID = allIssueIDS[-1] -else: - maxIssueID = 1000 -linkWidth = len(link(maxIssueID)) -messages = [] -statusReport = {} -issueAttributes = {} - -for issueID in allIssueIDS: - issueAttributes[issueID] = getIssueAttributes(issueID) - -createdOrReopenedIDS = reopenedIssueIDS + recentlyCreatedIssueIDS -createdOrReopenedIDS.sort(issueIdCompare) - -durations = [issueAttributes[id]['duration'].as_seconds()/(3600*24.) for id in allIssueIDS if \ - id not in closedIssueIDS] -if durations: - if options.debug: - print >>bugfile, 'Min duration:', durations[-1], '; max', durations[0] - averageDuration = sum(durations)/len(durations) - medianDuration = durations[len(durations)/2] -else: - averageDuration = "N/A" - medianDuration = "N/A" - -messages.sort() -messages.reverse() -discussedIDS = [id for (num, id) in messages[:discussionMax] \ - if num >= discussionThreshold] - -nTotal = len(allIssueIDS) -nTotalOld = len(earlyIssueIDS) -nClosed = len(closedIssueIDS) -nClosedOld = len(oldClosedIssueIDS) -nOpen = nTotal - nClosed -nOpenOld = nTotalOld - nClosedOld - -for sid in statusIDS: - IDS = db.issue.filter(None, F(creation=whole_period, status=sid)) - IDSOld = db.issue.filter(None, F(creation=early_period, status=sid)) - nNow, nThen = (len(IDS), len(IDSOld)) - statusReport[sid] = (nNow, nThen) - - -# Now make the reports -textReport = cStringIO.StringIO() -writeTextReport(textReport) - -htmlReport = cStringIO.StringIO() -writeHtmlReport(htmlReport) - -def sendReport (recipient): - "Send the email message." - message = cStringIO.StringIO() - writer = MimeWriter.MimeWriter(message) - writer.addheader('Subject', 'Summary of %s Issues'%db.config.TRACKER_NAME) - writer.addheader('To', recipient) - writer.addheader('From', '%s <%s>'%(db.config.TRACKER_NAME, db.config.ADMIN_EMAIL)) - writer.addheader('Reply-To', '%s <%s>'%(db.config.TRACKER_NAME, 'DONOTREPLY at NOWHERE.ORG')) - writer.addheader('MIME-Version', '1.0') - writer.addheader('X-Roundup-Name', db.config.TRACKER_NAME) - - # start the multipart - part = writer.startmultipartbody('alternative') - part = writer.nextpart() - body = part.startbody('text/plain') - - # do the plain text bit - print >>body, textReport.getvalue() - - # now the HTML one - part = writer.nextpart() - body = part.startbody('text/html') - print >>body, htmlReport.getvalue() - # finish off the multipart - writer.lastpart() - # all done, send! - if options.debug: - print message.getvalue() - else: - smtp = SMTPConnection(db.config) - smtp.sendmail(db.config.ADMIN_EMAIL, options.mailTo, message.getvalue()) - -# Email? Or just print it. -if not options.mailTo: - print textReport.getvalue() -else: - for recipient in options.mailTo.split(','): - sendReport(recipient) - +#!/usr/bin/python +# Make sure you are using the python that has the roundup runtime used by the +# tracker. Requires Python 2.3 or later. +# +# Script to create a tracker summary by Richard Jones and Paul Dubois +import sys, math +# kludge +sys.path.insert(1,'/home/roundup/roundup/lib/python2.4/site-packages') +# +import roundup +import roundup.date, roundup.instance +import optparse , datetime +import cStringIO, MimeWriter, smtplib +from roundup.mailer import SMTPConnection + +### CONFIGURATION +# List of statuses to treat as closed -- these don't have to all exist. +resolvedStatusDefault = 'resolved,done,done-cbb,closed,faq' + +# Period of time for report. Uses roundup syntax for ranges. +defaultDates = '-1w;' + +# Email address of recipient of report, if any. +defaultMailTo = '' + +# Comma-delimited list of statuses not to include in report. +ignoredStatusesDefault = '' + +# Number of most-discussed messages to display +discussionMax = 10 + +# Smallest number of messages to be eligible for 'most discussed'. +discussionThreshold = 3 + +# Date format per time.strftime +dateFormat="%x" #locale-appropriate + +##### END CONFIGURATION; ALSO SEE CUSTOMIZATION BELOW + +usage = """%prog trackerHome [--mail mailTo] + [--dates 'date1;date2'] + [--brief] + # less likely + [--resolved 'status1,status2'] + [--status 'status1,status2'] + [--output filename] + [--errors filename] + # for maintainers + [--DEBUG] + [--AUDIT recent|all] + dates is a roundup date range such as: + '-1w;' -- the last week (the default) + '-3m;' -- the last 3 months + 'from 2006-10-25 to 2006-12-25' -- Thanksgiving to Christmas, 2006 + + mailTo is one or more email addresses, comma delimited. + resolved is a list of statuses to treat as 'closed'. + statuses are names of statuses to ignore. + + Be sure to protect commas and semicolons from the shell with quotes! + Execute %prog --help for detailed help +""" +#### Options +parser = optparse.OptionParser(usage=usage) +parser.add_option('-b','--brief', dest='brief', action='store_true', + default=False, + help='Show summary only, no tables.') +parser.add_option('-a','--audit', dest='audit', + default='', metavar = 'all|recent', + help='Print journal for "all" or "recent" transactions, then halt.') +parser.add_option('-D','--DEBUG', dest='debug', action='store_true', + default=False, + help='Just print the result; if mailTo set, print email but do not send it.') +parser.add_option('-d','--dates', dest='dates', + default=defaultDates, metavar="'from;to'", + help="""Specification for range of dates, such as: \ +'-1w;' -- previous week; +'-1y;' -- previous year; +'from 2006-11-1 to 2006-12-1' -- exact period""") +parser.add_option('-m','--mail', dest='mailTo', + default=defaultMailTo, + help='Mail the report to the address(es) mailTo; if not given, print report.') +parser.add_option('-s','--status', dest='ignore', metavar="STATUSES_TO_IGNORE", + default=ignoredStatusesDefault, + help="Comma-delimited list of statuses to ignore in report.") +parser.add_option('-r','--resolved', dest='resolved', + default=resolvedStatusDefault, + help="Comma-delimited list of statuses that corresponds to being 'closed'.") +parser.add_option('-o','--output', dest='output', + default='', metavar='FILENAME', + help='File name for output; default is stdout.') +parser.add_option('-e','--errors', dest='errors', + default='', metavar='FILENAME', + help='File name for error output; default is stderr.') + +#### Get the command line args: +(options, args) = parser.parse_args() +if options.output: + sys.stdout = open(options.output, 'w') +if options.errors: + sys.stderr = open(options.errors, 'w') + +if len(args) != 1: + parser.error("""Incorrect number of arguments; + you must supply a tracker home.""") +instanceHome = args[0] +# Open the instance +instance = roundup.instance.open(instanceHome) +db = instance.open('admin') + +# CUSTOMIZATION +dateWidth = len(roundup.date.Date('2006-09-30').pretty(format=dateFormat)) +titleWidth = 72 #zero means no limit +durationWidth = len('9999 days') +tableStyle = 'border="1" cellspacing="0" cellpadding="3"' + +def formatDuration(duration): + "Change a duration into text." + return "%4.0f days" % (duration.as_seconds()/(3600.*24),) + +def closedOrBlank(statusID): + "CLOSED or a blank" + if statusID in resolvedStatusIDS: + return "CLOSED" + else: + return "" + +# Additional filter(s) to use in picking out issues. +# Depends on the schema. +notThese = ('notices', 'faq', 'todo', 'feature', 'wish') +try: + priorityIDS = db.priority.getnodeids(None, retired=None) + priorityNames = [db.priority.get(p, 'name') for p in priorityIDS] + acceptablePriorities = [priorityIDS[i] for i in range(len(priorityIDS)) if \ + priorityNames[i] not in notThese] +except: #for example, priority is not in the schema + acceptablePriorities = [] + +def F(**args): + "args is the dictionary to return, with additions if desired." + if acceptablePriorities: + args['priority'] = acceptablePriorities + return args + + +# Set what fields show up in the different tables. +# May need to modify getIssueAttribute to match your schema or add things +# you want to compute. +# Each field has a title and a field width. +# In text mode: +# a title of '
    , indent' means a new line is started for each +# record, and the integer indent indicates an indentation for the next line. +# If used, titles are omitted. +# In html mode,
    is ignored. + +### Text Tables +# The 'Created or Repopened' table, text mode. +createdTable = """ + titles: + 'Title', titleWidth - dateWidth + 'Date', dateWidth + '
    ', 0 + 'Status', len('CLOSED') + 'Link', linkWidth + 'Action', actionWidth + 'By', userNameWidth + records: + title + (reopenedDate or creation).pretty(format=dateFormat) + closedOrBlank(statusID) + link(issueNumber) + reopened or 'created' + reopener or creator +""" +# The table of closed issues, text mode. +closedTable = """ + titles: + 'Title', titleWidth - durationWidth + 'Duration', durationWidth + '
    ', len('CLOSED') + 'Link', linkWidth + 'By', userNameWidth + records: + title + formatDuration(duration) + link(issueNumber) + actor +""" +# The table of most discussed issues, text mode. +discussedTable = """ + titles: + 'N', -3 + 'Title', titleWidth - durationWidth + 'Duration', durationWidth + '
    ', 0 + 'Status', statusWidth + 'Link', linkWidth + records: + numberOfMessages + title + formatDuration(duration) + status + link(issueNumber) +""" + +### HTML Tables +# The 'Created or Repopened' table, html mode. +# Titles are links, use zero on width; limit is applied in hlink +htmlCreatedTable = """ + titles: + 'Title', 0 + 'Status', len('CLOSED') + 'Date', dateWidth + 'Action', actionWidth + 'By', userNameWidth + records: + hlink(issueNumber, title) + closedOrBlank(statusID) + (reopenedDate or creation).pretty(format=dateFormat) + reopened or 'created' + reopener or creator +""" +# The table of closed issues, html mode. +htmlClosedTable = """ + titles: + 'Title', 0 + 'By', userNameWidth + 'Duration', durationWidth + records: + hlink(issueNumber, title) + actor + formatDuration(duration) +""" +# The table of most discussed issues, text mode. +htmlDiscussedTable = """ + titles: + 'N', -3 + 'Title', 0 + 'Status', statusWidth + 'Duration', durationWidth + records: + numberOfMessages + hlink(issueNumber, title) + status + formatDuration(duration) +""" +### END CUSTOMIZATION +# well, except you might want to add to this...locals in this +# routine are usable in the 'records' section of tables. + +def getIssueAttributes (issueID): + """Return dictionaries with the issue's title, etc. + Assumes issue was created no later than to_value + """ + issueNumber = issueID + reopened = '' + reopener = '' + reopenedDate = '' + numberOfMessages = 0 + status2 = db.issue.get(issueID, 'status') + status1 = status2 + actor2 = db.issue.get(issueID, 'actor') + activity2 = db.issue.get(issueID, 'activity') + statusID = None + actorID = None + activity = None + +# programming note: +# the journal records the OLD value of the status in the data field +# So we know the end value (status2) and can walk backwards through it +# Want to set statusID = status in effect at to_value +# Also discover any activity that changed a resolved to non-resolved. + journal = db.issue.history(issueID) + journal.reverse() +# this trick catches the first time we are in the interval of interest + if activity2 < to_value: + statusID = statusID or status2 + actorID = actorID or actor2 + activity = activity or activity2 + + for x,ts,userid,act,data in journal: + inPeriod = ts >= from_value and ts < to_value + if inPeriod: + statusID = statusID or status2 + actorID = actorID or actor2 + activity = activity or activity2 + if act == 'set': + if data.has_key('messages'): + if inPeriod: + numberOfMessages += 1 + if data.has_key('status'): + status1 = data['status'] + if ts < to_value: + if (status1 in resolvedStatusIDS) and \ + (status2 not in resolvedStatusIDS): + if not reopened: # want the latest reopener only + if inPeriod and issueID not in recentlyCreatedIssueIDS: + reopenedIssueIDS.append(issueID) + reopened = 'reopened' + reopener = userMap[userid] + reopenedDate = ts + actor2 = userid + activity2 = ts + status2 = status1 + + messages.append((numberOfMessages, issueID)) +# get these set if not done before + statusID = statusID or status2 + activity = activity or activity2 + actorID = actorID or actor2 +# calculate the fields for the reports + status = statusMap[statusID] + actor = userMap[actorID] + title = db.issue.get(issueID, 'title') + creation = db.issue.get(issueID, 'creation') + creatorID = db.issue.get(issueID, 'creator') + creator = userMap[creatorID] + if statusID in resolvedStatusIDS: + duration = activity - (reopenedDate or creation) + else: + duration = to_value - (reopenedDate or creation) + if options.debug: + print >>bugfile, issueID, status, creator, actor, "%4.0f" %(duration.as_seconds()/(3600.24)), \ + activity.pretty(dateFormat), reopenedDate or 'created', creation.pretty(dateFormat) +# out of a sense of neatness + del status1, status2, actor2, activity2 + del x, ts, userid, act, data, journal +# return the dictionary of local values for use in evals of table values. + return locals() + +### Utility +def link (issueID): + "url of issue whose ID is issueID" + return "%sissue%s" % (db.config.TRACKER_WEB, issueID) + +def hlink (issueID, title): + "html link to url/title of issue whose ID is issueID" + return '''%s''' %(link(issueID), title[:titleWidth]) + +def statusCompare (x, y): + """Compare two statusIDs by order.""" + xs = db.status.get(x, 'order') + ys = db.status.get(y, 'order') + c = float(xs) - float(ys) + if c >= 0.0: + return int(c) + else: + return -int(abs(c)) + +def issueIdCompare (x, y): + """Compare two issue ids numerically.""" + return int(x) - int(y) + +def issueStatus(issueID): + """Get the status name from an issueID.""" + sid = db.issue.get(issueID, 'status') + return db.status.get(sid, 'name') + +def statusUsable (statusID): + """Is this status is one we want to deal with?""" + if db.status.is_retired(statusID): + return False + if db.status.get(statusID, 'name') in ignoredStatuses: + return False + return True + +#Table writers + +class Table (object): + def __init__ (self, caption, issueIDS, tableSpec): + self.caption = caption + ' (%d)' % len(issueIDS) + self.issueIDS = issueIDS + self.breaks = [] + self.spec = self.parse(tableSpec) + + def parse(self, tableSpec): + """Sample: + titles: + 'ID', -6 + 'Title', 25 + 'Status', 30 + records: + id + title + status + """ + titles = [] + fields = [] + fws = [] + for line in tableSpec.split('\n'): + line = line.strip() + if not line: continue + if line.startswith("titles"): + inTitles = True + elif line.startswith("records"): + inTitles = False + elif inTitles: + title, fw = eval(line) + if title == '
    ': + self.breaks.append((len(titles), fw)) + else: + titles.append(title) + if fw > 0: + fw = max(fw, len(title)) + elif fw < 0: + fw = min(fw, -len(title)) + fws.append(fw) + else: + fields.append(line) + self.titles = titles + self.fields = fields + self.fws = fws + if len(titles) != len(fields): + raise ValueError, 'Number of titles and fields do not match.' + if len(titles) == 0: + raise ValueError, 'No titles or fields given' + + def write(self, device): + if not self.issueIDS: + return + fields = self.fields + fws = self.fws + self.prologue(device) + self.writeFields(device, fields, fws) + self.epilogue(device) + + def writeTitles(self, device, titles, fws): + self.startTitles(device, titles, fws) + for i in range(len(titles)): + t = titles[i] + fw = fws[i] + self.startTitle(device, t, fw) + self.writeTitle(device, t, fw) + self.endTitle(device, t, fw) + self.endTitles(device, titles, fws) + + def writeFields(self, device, fields, fws): + for issueID in self.issueIDS: + d = issueAttributes[issueID] + self.startFields(d, device, fields, fws) + for i in range(len(fields)): + f = fields[i] + fw = fws[i] + self.startField(d, device, f, fw) + self.writeField(d, device, f, fw) + self.endField(d, device, f, fw) + for count, indent in self.breaks: + if i+1 == count: + print >>device + if indent: + print >>device, ' '.ljust(indent), + self.endFields(d, device, fields, fws) + + def prologue(self, device): + print >>device + print >>device, self.caption + print >>device, '_'*len(self.caption) + print >>device + if not self.breaks: + self.writeTitles(device, self.titles, self.fws) + + def epilogue(self, device): + print >>device + + def startTitles(self, device, titles, fws): + pass + + def endTitles(self, device, titles, fws): + print >>device + + def startTitle(self, device, title, fw): + pass + + def writeTitle(self, device, title, fw): + fwa = abs(fw) + if fwa > 0: + print >>device, title[0:fwa].ljust(fwa), + elif fwa < 0: + print >>device, title[0:fwa].rjust(fwa), + else: + print >>device, title, + + def endTitle(self, device, title, fw): + pass + + def startFields(self, d, device, fields, fws): + pass + + def endFields(self, d, device, fields, fws): + print >>device + if self.breaks: print >>device + + def startField(self, d, device, field, fw): + pass + + def writeField(self, d, device, field, fw): + fwa = abs(fw) + value = str(eval(field, d, globals())) + if fw > 0: + print >>device, value[0:fwa].ljust(fwa), + elif fw < 0: + print >>device, value[0:fwa].rjust(fwa), + else: + print >>device, value, + + def endField(self, d, device, field, fw): + pass + +class htmlTable (Table): + def __init__ (self, caption, issueIDS, tableSpec): + super(htmlTable, self).__init__(caption, issueIDS, tableSpec) + + def prologue(self, device): + print >>device, """
    +""" % (tableStyle, self.caption) + self.writeTitles(device, self.titles, self.fws) + + def epilogue(self, device): + print >>device, '
    %s
    ' + + def startTitles(self, device, titles, fws): + print >>device, ' ' + + def endTitles(self, device, titles, fws): + print >>device, ' ' + + def startTitle(self, device, title, fw): + print >>device, ' ', + + def writeTitle(self, device, title, fw): + if not title: + title = ' ' + fwa = abs(fw) + if fw != 0: + print >>device, title[0:fwa], + else: + print >>device, title, + + def endTitle(self, device, title, fw): + print >>device, '' + + def startFields(self, d, device, fields, fws): + print >>device, ' ' + + def endFields(self, d, device, fields, fws): + print >>device, ' ' + + def startField(self, d, device, field, fw): + print >>device, ' ', + + def writeField(self, d, device, field, fw): + if field == 'issueRef': + field = 'issueHRef' + fw = 0 + value = str(eval(field, d, globals())) + fwa = abs(fw) + if not value: + value = ' ' + fwa = 0 + if fwa != 0: + print >>device, value[0:fwa], + else: + print >>device, value, + + def endField(self, d, device, field, fw): + print >>device, '' + +# Summary writers +def htmlSummary(body, caption): + "Print html summary" + print >>body, '

    ACTIVITY SUMMARY ('+ from_value.pretty(format=dateFormat) + \ + ' - ' + to_value.pretty(format=dateFormat) + ')

    ' + print >>body, '

    %s at %s

    ' % (db.config.TRACKER_NAME, + db.config.TRACKER_WEB) + print >>body, '

    ' + print >>body, '''To view or respond to any of the issues listed + below, simply click on the issue ID. Do not respond to + this message.''' + print >>body, '

    ' + print >>body, '

    ' + fmt = "%5d open (%+3d) / %5d closed (%+3d) / %5d total (%+3d)" + print >>body, '

    ' + print >>body, '

    ' + print >>body, fmt % \ + (nOpen, nOpen-nOpenOld, nClosed, nClosed-nClosedOld, (nOpen+nClosed), + (nOpen+nClosed)-(nOpenOld+nClosedOld)) + print >>body, '

    ' + print >>body, "

    " + print >>body, '

    ' + print >>body, "Average duration of open issues:", "%3.0f" % averageDuration, "days." + print >>body, '

    ' + print >>body, "

    " + print >>body, "Median duration of open issues:", "%3.0f" % medianDuration, "days." + print >>body, '

    ' + print >>body, '

    ' + print >>body, ''' + + +''' % (tableStyle, caption) + for sid in statusIDS: + if sid in resolvedStatusIDS: + continue + (ntot, nold) = statusReport[sid] + name = statusMap[sid] + print >>body, ''''''% \ + (name, ntot, ntot-nold) + print >>body, '
    %s
    STATUS NumberChange
    %s%6d%+6d
    ' + print >>body, '

    ' + + +def textSummary(body, caption): + "Print text summary" + print >>body + print >>body, 'ACTIVITY SUMMARY ('+ from_value.pretty(format=dateFormat) + \ + ' - ' + to_value.pretty(format=dateFormat) + ')' + print >>body, '%s at %s' % (db.config.TRACKER_NAME, db.config.TRACKER_WEB) + print >>body, ''' +To view or respond to any of the issues listed below, click on the issue +number. Do NOT respond to this message. +''' + print >>body + fmt = "%5d open (%+3d) / %5d closed (%+3d) / %5d total (%+3d)" + print >>body, fmt % \ + (nOpen, nOpen-nOpenOld, nClosed, nClosed-nClosedOld, (nOpen+nClosed), + (nOpen+nClosed)-(nOpenOld+nClosedOld)) + print >>body + print >>body, "Average duration of open issues:", "%3.0f" % averageDuration, "days." + print >>body, "Median duration of open issues:", "%3.0f" % medianDuration, "days." + print >>body + print >>body, caption + for sid in statusIDS: + if sid in resolvedStatusIDS: + continue + (ntot, nold) = statusReport[sid] + name = statusMap[sid] + fmt = "%" + str(statusWidth) + "s %5d (%+3d)" + print >>body, (fmt % (name, ntot, ntot-nold)) + + +def writeTextReport(device): + "Write the report in text mode to device." + textSummary(device, "Open Issues Breakdown") + + if not options.brief: + messages.sort() + messages.reverse() + t = Table('Issues Created Or Reopened', createdOrReopenedIDS, + createdTable) + t.write(device) + + t = Table('Issues Now Closed', recentlyClosedIssueIDS, closedTable) + t.write(device) + + t = Table('Top Issues Most Discussed', discussedIDS, discussedTable) + t.write(device) + +def writeHtmlReport(device): + "Write the report in html mode to device." + htmlSummary(device, 'Open Issues Breakdown') + if not options.brief: + t = htmlTable('Issues Created Or Reopened', createdOrReopenedIDS, + htmlCreatedTable) + t.write(device) + + t = htmlTable('Issues Now Closed', recentlyClosedIssueIDS, + htmlClosedTable) + t.write(device) + + t = htmlTable('Top Issues Most Discussed', discussedIDS, + htmlDiscussedTable) + t.write(device) + +def writeAudit(device, issueIDS): + "Write audit of given issues to device." + for issueID in issueIDS: + journal = db.issue.history(issueID) + for x,ts,userid,act,data in journal: + user = db.user.get(userid, 'username') + print >>device, x, ts, '%s (%s)'%(userid, user), act + if act == 'set': + for d, v in data.items(): + print >>device, ' ', d, ': ', v + +# Options processing +if options.debug: + bugfile = open('bugfile', 'w') + print >>bugfile, options +# ...dates +dates = roundup.date.Range(options.dates, roundup.date.Date) +from_value = dates.from_value +to_value = dates.to_value +if to_value is None: + to_value = roundup.date.Date('.') +if from_value is None: + from_value = roundup.date.Date('1980-1-1') +early_period = ';%s'%from_value +whole_period = ';%s'%to_value +# ... statuses +ignoredStatuses = [s.strip() for s in options.ignore.split(',')] +if options.debug: + print >>bugfile, "from,to", from_value, to_value + print >>bugfile, 'acceptablePriorities', acceptablePriorities + print >>bugfile, 'ignoredStatuses', ignoredStatuses + +# ...audit +if options.audit: +# Name of audit file (not usually used by normal users) + auditFilename = 'audit.txt' + if options.audit not in ['all', 'recent']: + raise ValueError, "AUDIT option must be 'recent' or 'all'." + + audit = open(auditFilename, 'w') + if options.audit == 'recent': + IDS = db.issue.filter(None, F(activity=options.dates)) + elif options.audit == 'full': + IDS = db.issue.filter(None, F(activity=whole_period)) + IDS.sort(issueIdCompare) + writeAudit(audit, IDS) + audit.close() + sys.exit(0) + + +# MAIN +# Make lists and maps of things +# Users +adminUserID = db.user.lookup('admin') +userIDS_ALL = db.user.getnodeids(retired=None) +userMap = {None: adminUserID} +userLookup = {} +for userid in userIDS_ALL: + name = db.user.get(userid, 'username') + userLookup[name] = userid + userMap[userid] = name +userNames = userLookup.keys() +userNameWidth = max([len(uname) for uname in userNames]) + +# Make map of statuses / names, including retired ones. +# Just doing lookup on names will miss retired ones. +statusIDS_ALL = db.status.getnodeids(retired=None) +statusLookup = {'None': None} +statusMap = {None: 'None'} +for sid in statusIDS_ALL: + name = db.status.get(sid, 'name') + statusLookup[name] = sid + statusMap[sid] = name + +# Make a list of statuses considered closed (including retired ones) +resolvedStatusOptions = options.resolved.split(',') +resolvedStatusIDS = [] +for r in resolvedStatusOptions: + try: + sid = statusLookup[r] + resolvedStatusIDS.append(sid) + except KeyError: + pass + +if options.debug: + print >>bugfile, 'statusLookup', statusLookup + print >>bugfile, 'resolvedStatusIDS', resolvedStatusIDS + +statusIDS = [sid for sid in statusIDS_ALL if statusUsable(sid)] +statusIDS.sort(statusCompare) +statusNames = [statusMap[sid] for sid in statusIDS] +statusWidth = max([len(s) for s in statusLookup.keys()]) +actionWidth = len('reopened') + +# Important note: for 'all', get only issues created before to_value +# Not just efficient, simplifies logic in getIssueAttribue + +# All issues +allIssueIDS = db.issue.filter(None, F(creation=whole_period)) +allIssueIDS.sort(issueIdCompare) +earlyIssueIDS = db.issue.filter(None, F(creation=early_period)) + +# Closed issues +oldClosedIssueIDS = db.issue.filter(None, F(creation=early_period, + status= resolvedStatusIDS)) +closedIssueIDS = db.issue.filter(None,F(creation=whole_period, + status=resolvedStatusIDS)) +recentlyClosedIssueIDS=db.issue.filter(None, F(activity=options.dates, + status=resolvedStatusIDS)) +recentlyClosedIssueIDS.sort(issueIdCompare) + +# Created and reopened issues +recentlyCreatedIssueIDS=db.issue.filter(None, F(creation=options.dates)) +reopenedIssueIDS = [] # gets accumulated in getIssueAttributes + +# Create more data needed for reports +if allIssueIDS: + maxIssueID = allIssueIDS[-1] +else: + maxIssueID = 1000 +linkWidth = len(link(maxIssueID)) +messages = [] +statusReport = {} +issueAttributes = {} + +for issueID in allIssueIDS: + issueAttributes[issueID] = getIssueAttributes(issueID) + +createdOrReopenedIDS = reopenedIssueIDS + recentlyCreatedIssueIDS +createdOrReopenedIDS.sort(issueIdCompare) + +durations = [issueAttributes[id]['duration'].as_seconds()/(3600*24.) for id in allIssueIDS if \ + id not in closedIssueIDS] +if durations: + if options.debug: + print >>bugfile, 'Min duration:', durations[-1], '; max', durations[0] + averageDuration = sum(durations)/len(durations) + medianDuration = durations[len(durations)/2] +else: + averageDuration = "N/A" + medianDuration = "N/A" + +messages.sort() +messages.reverse() +discussedIDS = [id for (num, id) in messages[:discussionMax] \ + if num >= discussionThreshold] + +nTotal = len(allIssueIDS) +nTotalOld = len(earlyIssueIDS) +nClosed = len(closedIssueIDS) +nClosedOld = len(oldClosedIssueIDS) +nOpen = nTotal - nClosed +nOpenOld = nTotalOld - nClosedOld + +for sid in statusIDS: + IDS = db.issue.filter(None, F(creation=whole_period, status=sid)) + IDSOld = db.issue.filter(None, F(creation=early_period, status=sid)) + nNow, nThen = (len(IDS), len(IDSOld)) + statusReport[sid] = (nNow, nThen) + + +# Now make the reports +textReport = cStringIO.StringIO() +writeTextReport(textReport) + +htmlReport = cStringIO.StringIO() +writeHtmlReport(htmlReport) + +def sendReport (recipient): + "Send the email message." + message = cStringIO.StringIO() + writer = MimeWriter.MimeWriter(message) + writer.addheader('Subject', 'Summary of %s Issues'%db.config.TRACKER_NAME) + writer.addheader('To', recipient) + writer.addheader('From', '%s <%s>'%(db.config.TRACKER_NAME, db.config.ADMIN_EMAIL)) + writer.addheader('Reply-To', '%s <%s>'%(db.config.TRACKER_NAME, 'DONOTREPLY at NOWHERE.ORG')) + writer.addheader('MIME-Version', '1.0') + writer.addheader('X-Roundup-Name', db.config.TRACKER_NAME) + + # start the multipart + part = writer.startmultipartbody('alternative') + part = writer.nextpart() + body = part.startbody('text/plain') + + # do the plain text bit + print >>body, textReport.getvalue() + + # now the HTML one + part = writer.nextpart() + body = part.startbody('text/html') + print >>body, htmlReport.getvalue() + # finish off the multipart + writer.lastpart() + # all done, send! + if options.debug: + print message.getvalue() + else: + smtp = SMTPConnection(db.config) + smtp.sendmail(db.config.ADMIN_EMAIL, options.mailTo, message.getvalue()) + +# Email? Or just print it. +if not options.mailTo: + print textReport.getvalue() +else: + for recipient in options.mailTo.split(','): + sendReport(recipient) + From python-checkins at python.org Thu Dec 28 05:39:21 2006 From: python-checkins at python.org (neal.norwitz) Date: Thu, 28 Dec 2006 05:39:21 +0100 (CET) Subject: [Python-checkins] r53165 - python/trunk/Doc/api/newtypes.tex Message-ID: <20061228043921.474411E400A@bag.python.org> Author: neal.norwitz Date: Thu Dec 28 05:39:20 2006 New Revision: 53165 Modified: python/trunk/Doc/api/newtypes.tex Log: Remove a stray (old) macro name left around (I guess) Modified: python/trunk/Doc/api/newtypes.tex ============================================================================== --- python/trunk/Doc/api/newtypes.tex (original) +++ python/trunk/Doc/api/newtypes.tex Thu Dec 28 05:39:20 2006 @@ -103,8 +103,6 @@ the value for the \var{methods} argument]{2.3} \end{cfuncdesc} -DL_IMPORT - \begin{cvardesc}{PyObject}{_Py_NoneStruct} Object which is visible in Python as \code{None}. This should only be accessed using the \code{Py_None} macro, which evaluates to a From python-checkins at python.org Thu Dec 28 05:39:54 2006 From: python-checkins at python.org (neal.norwitz) Date: Thu, 28 Dec 2006 05:39:54 +0100 (CET) Subject: [Python-checkins] r53166 - python/branches/release25-maint/Doc/api/newtypes.tex Message-ID: <20061228043954.8D5B21E400A@bag.python.org> Author: neal.norwitz Date: Thu Dec 28 05:39:54 2006 New Revision: 53166 Modified: python/branches/release25-maint/Doc/api/newtypes.tex Log: Remove a stray (old) macro name left around (I guess) Modified: python/branches/release25-maint/Doc/api/newtypes.tex ============================================================================== --- python/branches/release25-maint/Doc/api/newtypes.tex (original) +++ python/branches/release25-maint/Doc/api/newtypes.tex Thu Dec 28 05:39:54 2006 @@ -103,8 +103,6 @@ the value for the \var{methods} argument]{2.3} \end{cfuncdesc} -DL_IMPORT - \begin{cvardesc}{PyObject}{_Py_NoneStruct} Object which is visible in Python as \code{None}. This should only be accessed using the \code{Py_None} macro, which evaluates to a From python-checkins at python.org Thu Dec 28 05:59:17 2006 From: python-checkins at python.org (neal.norwitz) Date: Thu, 28 Dec 2006 05:59:17 +0100 (CET) Subject: [Python-checkins] r53169 - peps/trunk/pep-3107.txt Message-ID: <20061228045917.318B91E400A@bag.python.org> Author: neal.norwitz Date: Thu Dec 28 05:59:16 2006 New Revision: 53169 Modified: peps/trunk/pep-3107.txt Log: Update from Tony Lownds sent in private mail and to python-3000 Modified: peps/trunk/pep-3107.txt ============================================================================== --- peps/trunk/pep-3107.txt (original) +++ peps/trunk/pep-3107.txt Thu Dec 28 05:59:16 2006 @@ -3,7 +3,7 @@ Version: $Revision$ Last-Modified: $Date$ Author: Collin Winter , - Tony Lownds + Tony Lownds Status: Draft Type: Standards Track Requires: 362 @@ -51,9 +51,8 @@ By itself, Python does not attach any particular meaning or significance to annotations. Left to its own, Python simply makes - these expressions available as the values in the - ``__signature__.annotations`` mapping described in `Accessing - Function Annotations`_ below. + these expressions available as described in `Accessing Function + Annotations`_ below. The only way that annotations take on meaning is when they are interpreted by third-party libraries. These annotation consumers @@ -98,38 +97,33 @@ ---------- Annotations for parameters take the form of optional expressions that -follow the parameter name. This example indicates that parameters 'a' -and 'c' should both be a ``Number``, while parameter 'b' should -be a ``Mapping``:: +follow the parameter name. This example indicates that parameters +'a' and 'c' should both be an ``int``, while parameter 'b' should +be a ``dict``:: - def foo(a: Number, b: Mapping, c: Number = 5): + def foo(a: int, b: dict, c: int = 5): ... -(Number, Mapping and Sequence are used thoughout this PEP and -represent the standard `numeric`_, `mapping`_ and `sequence -protocols`_.) - In pseudo-grammar, parameters now look like ``identifier [: -expression] [= expression]``. That is, type annotations always -precede a parameter's default value and both type annotations and -default values are optional. Just like how equal signs are used to -indicate a default value, colons are used to mark annotations. All -annotation expressions are evaluated when the function definition is -executed. +expression] [= expression]``. That is, annotations always precede a +parameter's default value and both annotations and default values are +optional. Just like how equal signs are used to indicate a default +value, colons are used to mark annotations. All annotation +expressions are evaluated when the function definition is executed. Annotations for excess parameters (i.e., ``*args`` and ``**kwargs``) are indicated similarly. In the following function definition, -``*args`` is flagged as a list of ``Number``, and ``**kwargs`` is +``*args`` is flagged as a tuple of ``int``, and ``**kwargs`` is marked as a dict whose keys are strings and whose values are of type -``Sequence``. :: +``str``:: - def foo(*args: Number, **kwargs: Sequence): + def foo(*args: int, **kwargs: str): ... Note that, depending on what annotation-interpreting library you're using, the following might also be a valid spelling of the above:: - def foo(*args: [Number], **kwargs: {str: Sequence}): + def foo(*args: [int], **kwargs: {str: str}): ... Only the first, however, has the BDFL's blessing [#blessedexcess]_ as @@ -142,68 +136,99 @@ The examples thus far have omitted examples of how to annotate the type of a function's return value. This is done like so:: - def sum(*args: Number) -> Number: + def sum(*args: int) -> int: ... The parameter list can now be followed by a literal ``->`` and a Python expression. Like the annotations for parameters, this expression will be evaluated when the function definition is executed. -The grammar for function definitions [#grammar]_ is now something like:: +The grammar for function definitions [#grammar]_ is now:: - funcdef ::= [decorators] "def" funcname "(" - [parameter_list] ")" ["->" expression] ":" suite - decorators ::= decorator+ - decorator ::= "@" dotted_name ["(" [argument_list - [","]] ")"] NEWLINE - dotted_name ::= identifier ("." identifier)* - parameter_list ::= (defparameter ",")* - ( "*" identifier [":" expression] - [, "**" identifier [":" expression] ] - | "**" identifier [":" expression] - | defparameter [","] ) - defparameter ::= parameter [":" expression] ["=" expression] - sublist ::= parameter ("," parameter)* [","] - parameter ::= identifier | "(" sublist ")" - funcname ::= identifier + decorator: '@' dotted_name [ '(' [arglist] ')' ] NEWLINE + decorators: decorator+ + funcdef: [decorators] 'def' NAME parameters ['->' test] ':' suite + parameters: '(' [typedargslist] ')' + typedargslist: ((tfpdef ['=' test] ',')* + ('*' [tname] (',' tname ['=' test])* [',' '**' tname] + | '**' tname) + | tfpdef ['=' test] (',' tfpdef ['=' test])* [',']) + tname: NAME [':' test] + tfpdef: tname | '(' tfplist ')' + tfplist: tfpdef (',' tfpdef)* [','] + +Lambda +------ + +``lambda``'s syntax does not support annotations. The syntax of +``lambda`` could be changed to support annotations, by requiring +parentheses around the parameter list. However it was decided +[#lambda]_ not to make this change because: + +1. It would be an incompatible change. +2. Lambda's are neutered anyway. +3. The lambda can always be changed to a function. Accessing Function Annotations ============================== Once compiled, a function's annotations are available via the -function's ``__signature__`` attribute, introduced by PEP 362. -Signature objects include an attribute just for annotations, -appropriately called ``annotations``. This attribute is a dictionary, -mapping parameter names to an object representing the evaluated -annotation expression. - -There is a special key in the ``annotations`` mapping, ``"return"``. -This key is present only if an annotation was supplied for the -function's return value. +function's ``func_annotations`` attribute. This attribute is +a dictionary, mapping parameter names to an object representing +the evaluated annotation expression + +There is a special key in the ``func_annotations`` mapping, +``"return"``. This key is present only if an annotation was supplied +for the function's return value. For example, the following annotation:: - def foo(a: Number, b: 5 + 6, c: list) -> String: + def foo(a: 'x', b: 5 + 6, c: list) -> str: ... -would result in a ``__signature__.annotations`` mapping of :: +would result in a ``func_annotation`` mapping of :: - {'a': Number, + {'a': 'x', 'b': 11, 'c': list, - 'return': String} + 'return': str} The ``return`` key was chosen because it cannot conflict with the name of a parameter; any attempt to use ``return`` as a parameter name would result in a ``SyntaxError``. +``func_annotations`` is an empty dictionary if no there are no +annotations on the function. ``func_annotations`` is always an empty +dictionary for functions created from ``lambda`` expressions. + + +Standard Library +================ + +pydoc and inspect +----------------- + +The ``pydoc`` module should display the function annotations when +displaying help for a function. The ``inspect`` module should change +to support annotations. + + +Relation to Other PEPs +====================== + +Function Signature Objects [#pep-362]_ +-------------------------------------- + +Function Signature Objects should expose the function's annotations. +The ``Parameter`` object may change or other changes may be warranted. + Implementation ============== -A sample implementation has been provided [#implementation]_ by Tony -Lownds. +A sample implementation for the syntax changes has been provided +[#implementation]_ by Tony Lownds. Rejected Proposals @@ -220,8 +245,8 @@ + Despite considerable discussion about a standard type parameterisation syntax, it was decided that this should also be - left to third-party libraries. ([#threadimmlist]_, [#threadmixing]_, - [#emphasistpls]_) + left to third-party libraries. ([#threadimmlist]_, + [#threadmixing]_, [#emphasistpls]_) References and Footnotes @@ -276,6 +301,13 @@ .. [#grammar] http://www.python.org/doc/current/ref/function.html +.. [#lambda] + http://mail.python.org/pipermail/python-3000/2006-May/001613.html + +.. [#pep-362] + http://www.python.org/dev/peps/pep-0362/ + + Copyright ========= @@ -291,3 +323,4 @@ fill-column: 70 coding: utf-8 End: + From python-checkins at python.org Thu Dec 28 22:19:41 2006 From: python-checkins at python.org (guido.van.rossum) Date: Thu, 28 Dec 2006 22:19:41 +0100 (CET) Subject: [Python-checkins] r53172 - sandbox/trunk/2to3/fixes/basefix.py sandbox/trunk/2to3/fixes/fix_apply.py Message-ID: <20061228211941.CD47D1E4004@bag.python.org> Author: guido.van.rossum Date: Thu Dec 28 22:19:41 2006 New Revision: 53172 Added: sandbox/trunk/2to3/fixes/basefix.py (contents, props changed) Modified: sandbox/trunk/2to3/fixes/fix_apply.py Log: Add a fixer base class that provides most of the boiler plate code. Use in in one example fix (the rest will come later). Added: sandbox/trunk/2to3/fixes/basefix.py ============================================================================== --- (empty file) +++ sandbox/trunk/2to3/fixes/basefix.py Thu Dec 28 22:19:41 2006 @@ -0,0 +1,52 @@ +# Copyright 2006 Google, Inc. All Rights Reserved. +# Licensed to PSF under a Contributor Agreement. + +"""Base class for fixers (optional, but recommended).""" + +# Local imports +import patcomp +import pygram + + +class BaseFix(object): + + """Optional base class for fixers.""" + + PATTERN = None # Subclass *must* override with a string literal + pattern = None # Compiled pattern, set by compile_pattern() + options = None # Options object passed to initializer + + # Shortcut for access to Python grammar symbols + syms = pygram.python_symbols + + def __init__(self, options): + """Initializer. Subclass may override.""" + self.options = options + self.compile_pattern() + + def compile_pattern(self): + """Compiles self.PATTERN into self.pattern. + + Subclass may override if it doesn't want to use + self.{pattern,PATTERN} in .match(). + """ + self.pattern = patcomp.PatternCompiler().compile_pattern(self.PATTERN) + + def match(self, node): + """Returns match for a given parse tree node. + + Subclass may override. + """ + results = {} + return self.pattern.match(node, results) and results + + def transform(self, node): + """Returns the transformation for a given parse tree node. + + Subclass must override. + """ + return None + + def parenthesize(self, node): + """Wrapper around pygram.parenthesize().""" + return pygram.parenthesize(node) Modified: sandbox/trunk/2to3/fixes/fix_apply.py ============================================================================== --- sandbox/trunk/2to3/fixes/fix_apply.py (original) +++ sandbox/trunk/2to3/fixes/fix_apply.py Thu Dec 28 22:19:41 2006 @@ -8,38 +8,27 @@ # Local imports import pytree -import patcomp -import pygram +from fixes import basefix -syms = pygram.python_symbols -pat_compile = patcomp.PatternCompiler().compile_pattern -PATTERN = """ -power< 'apply' - trailer< - '(' - arglist< - (not argument + ')' > - ')' > -> -""" - - -class FixApply(object): - - def __init__(self, options): - self.options = options - self.pattern = pat_compile(PATTERN) - - def match(self, node): - results = {} - return self.pattern.match(node, results) and results + """ def transform(self, node): + syms = self.syms results = self.match(node) assert results func = results["func"] @@ -51,7 +40,7 @@ (func.type != syms.power or func.children[-2].type == token.DOUBLESTAR)): # Need to parenthesize - func = pygram.parenthesize(func) + func = self.parenthesize(func) func.set_prefix("") args = args.clone() args.set_prefix("") From python-checkins at python.org Thu Dec 28 22:31:19 2006 From: python-checkins at python.org (guido.van.rossum) Date: Thu, 28 Dec 2006 22:31:19 +0100 (CET) Subject: [Python-checkins] r53173 - in sandbox/trunk/2to3: example.py fixes/fix_repr.py Message-ID: <20061228213119.EAFE81E4004@bag.python.org> Author: guido.van.rossum Date: Thu Dec 28 22:31:18 2006 New Revision: 53173 Added: sandbox/trunk/2to3/fixes/fix_repr.py (contents, props changed) Modified: sandbox/trunk/2to3/example.py Log: Add a fix for `x` -> repr(x). Modified: sandbox/trunk/2to3/example.py ============================================================================== --- sandbox/trunk/2to3/example.py (original) +++ sandbox/trunk/2to3/example.py Thu Dec 28 22:31:18 2006 @@ -146,4 +146,17 @@ # exec(code, ns1, ns2) +def repr_examples(): + x = `1 + 2` + # + y = `x` + # + z = `y`.__repr__() + # + x = `1, 2, 3` + # + x = `1 + `2`` + # + x = `1, 2 + `3, 4`` + # This is the last line. Added: sandbox/trunk/2to3/fixes/fix_repr.py ============================================================================== --- (empty file) +++ sandbox/trunk/2to3/fixes/fix_repr.py Thu Dec 28 22:31:18 2006 @@ -0,0 +1,33 @@ +# Copyright 2006 Google, Inc. All Rights Reserved. +# Licensed to PSF under a Contributor Agreement. + +"""Fixer that transforms `xyzzy` into repr(xyzzy).""" + +# Python imports +import token + +# Local imports +import pytree +from fixes import basefix + + +class FixRepr(basefix.BaseFix): + + PATTERN = """ + atom < '`' expr=any '`' > + """ + + def transform(self, node): + results = self.match(node) + assert results + expr = results["expr"].clone() + if expr.type == self.syms.testlist1: + expr = self.parenthesize(expr) + new = pytree.Node(self.syms.power, + (pytree.Leaf(token.NAME, "repr"), + pytree.Node(self.syms.trailer, + (pytree.Leaf(token.LPAR, "("), + expr, + pytree.Leaf(token.RPAR, ")"))))) + new.set_prefix(node.get_prefix()) + return new From python-checkins at python.org Thu Dec 28 22:50:14 2006 From: python-checkins at python.org (guido.van.rossum) Date: Thu, 28 Dec 2006 22:50:14 +0100 (CET) Subject: [Python-checkins] r53174 - sandbox/trunk/2to3/fixes/basefix.py sandbox/trunk/2to3/fixes/fix_exec.py sandbox/trunk/2to3/fixes/fix_has_key.py sandbox/trunk/2to3/fixes/fix_intern.py sandbox/trunk/2to3/fixes/fix_ne.py sandbox/trunk/2to3/fixes/fix_null.py sandbox/trunk/2to3/fixes/fix_print.py Message-ID: <20061228215014.0BB311E4012@bag.python.org> Author: guido.van.rossum Date: Thu Dec 28 22:50:13 2006 New Revision: 53174 Removed: sandbox/trunk/2to3/fixes/fix_null.py Modified: sandbox/trunk/2to3/fixes/basefix.py sandbox/trunk/2to3/fixes/fix_exec.py sandbox/trunk/2to3/fixes/fix_has_key.py sandbox/trunk/2to3/fixes/fix_intern.py sandbox/trunk/2to3/fixes/fix_ne.py sandbox/trunk/2to3/fixes/fix_print.py Log: Finish refactoring the remaining fixes. The null fix is no longer needed; the class docs are in basefix.py. Modified: sandbox/trunk/2to3/fixes/basefix.py ============================================================================== --- sandbox/trunk/2to3/fixes/basefix.py (original) +++ sandbox/trunk/2to3/fixes/basefix.py Thu Dec 28 22:50:13 2006 @@ -10,7 +10,13 @@ class BaseFix(object): - """Optional base class for fixers.""" + """Optional base class for fixers. + + The subclass name must be FixFooBar where FooBar is the result of + removing underscores and capitalizing the words of the fix name. + For example, the class name for a fixer named 'has_key' should be + FixHasKey. + """ PATTERN = None # Subclass *must* override with a string literal pattern = None # Compiled pattern, set by compile_pattern() @@ -20,7 +26,11 @@ syms = pygram.python_symbols def __init__(self, options): - """Initializer. Subclass may override.""" + """Initializer. Subclass may override. +o + The argument is an optparse.Values instance which can be used + to inspect the command line options. + """ self.options = options self.compile_pattern() @@ -35,6 +45,10 @@ def match(self, node): """Returns match for a given parse tree node. + Should return a true or false object (not necessarily a bool). + It may return a non-empty dict of matching sub-nodes as + returned by a matching pattern. + Subclass may override. """ results = {} @@ -43,7 +57,10 @@ def transform(self, node): """Returns the transformation for a given parse tree node. - Subclass must override. + Should return None, or a node that is a modified copy of the + argument node. The argument should not be modified in place. + + Subclass *must* override. """ return None Modified: sandbox/trunk/2to3/fixes/fix_exec.py ============================================================================== --- sandbox/trunk/2to3/fixes/fix_exec.py (original) +++ sandbox/trunk/2to3/fixes/fix_exec.py Thu Dec 28 22:50:13 2006 @@ -8,30 +8,19 @@ # Local imports import pytree -import patcomp -import pygram +from fixes import basefix -syms = pygram.python_symbols -pat_compile = patcomp.PatternCompiler().compile_pattern -PATTERN = """ -exec_stmt< 'exec' a=any 'in' b=any [',' c=any] > -| -exec_stmt< 'exec' (not atom<'(' [any] ')'>) a=any > -""" +class FixExec(basefix.BaseFix): - -class FixExec(object): - - def __init__(self, options): - self.options = options - self.pattern = pat_compile(PATTERN) - - def match(self, node): - results = {} - return self.pattern.match(node, results) and results + PATTERN = """ + exec_stmt< 'exec' a=any 'in' b=any [',' c=any] > + | + exec_stmt< 'exec' (not atom<'(' [any] ')'>) a=any > + """ def transform(self, node): + syms = self.syms results = self.match(node) assert results a = results["a"] @@ -51,4 +40,3 @@ pytree.Leaf(token.RPAR, ")")])]) new.set_prefix(node.get_prefix()) return new - Modified: sandbox/trunk/2to3/fixes/fix_has_key.py ============================================================================== --- sandbox/trunk/2to3/fixes/fix_has_key.py (original) +++ sandbox/trunk/2to3/fixes/fix_has_key.py Thu Dec 28 22:50:13 2006 @@ -8,28 +8,12 @@ # Local imports import pytree -import patcomp -import pygram +from fixes import basefix -syms = pygram.python_symbols -pat_compile = patcomp.PatternCompiler().compile_pattern -PATTERN = """ -anchor=power< - before=any+ - trailer< '.' 'has_key' > - trailer< - '(' - ( not(arglist | argument) arg=any ','> - ) - ')' - > - after=any* -> -| -negation=not_test< - 'not' +class FixHasKey(basefix.BaseFix): + + PATTERN = """ anchor=power< before=any+ trailer< '.' 'has_key' > @@ -40,22 +24,27 @@ ) ')' > + after=any* > -> -""" - - -class FixHasKey(object): - - def __init__(self, options): - self.options = options - self.pattern = pat_compile(PATTERN) - - def match(self, node): - results = {} - return self.pattern.match(node, results) and results + | + negation=not_test< + 'not' + anchor=power< + before=any+ + trailer< '.' 'has_key' > + trailer< + '(' + ( not(arglist | argument) arg=any ','> + ) + ')' + > + > + > + """ def transform(self, node): + syms = self.syms results = self.match(node) assert results if (node.parent.type == syms.not_test and @@ -73,7 +62,7 @@ after = [n.clone() for n in after] if arg.type in (syms.comparison, syms.not_test, syms.and_test, syms.or_test, syms.test, syms.lambdef, syms.argument): - arg = pygram.parenthesize(arg) + arg = self.parenthesize(arg) if len(before) == 1: before = before[0] else: @@ -87,12 +76,12 @@ n_op = pytree.Node(syms.comp_op, (n_not, n_op)) new = pytree.Node(syms.comparison, (arg, n_op, before)) if after: - new = pygram.parenthesize(new) + new = self.parenthesize(new) new = pytree.Node(syms.power, (new,) + tuple(after)) if node.parent.type in (syms.comparison, syms.expr, syms.xor_expr, syms.and_expr, syms.shift_expr, syms.arith_expr, syms.term, syms.factor, syms.power): - new = pygram.parenthesize(new) + new = self.parenthesize(new) new.set_prefix(prefix) return new Modified: sandbox/trunk/2to3/fixes/fix_intern.py ============================================================================== --- sandbox/trunk/2to3/fixes/fix_intern.py (original) +++ sandbox/trunk/2to3/fixes/fix_intern.py Thu Dec 28 22:50:13 2006 @@ -8,34 +8,23 @@ # Local imports import pytree -import patcomp -import pygram +from fixes import basefix -syms = pygram.python_symbols -pat_compile = patcomp.PatternCompiler().compile_pattern -PATTERN = """ -power< 'intern' - trailer< lpar='(' - ( not(arglist | argument) any ','> ) - rpar=')' > - after=any* -> -""" +class FixIntern(basefix.BaseFix): - -class FixIntern(object): - - def __init__(self, options): - self.options = options - self.pattern = pat_compile(PATTERN) - - def match(self, node): - results = {} - return self.pattern.match(node, results) and results + PATTERN = """ + power< 'intern' + trailer< lpar='(' + ( not(arglist | argument) any ','> ) + rpar=')' > + after=any* + > + """ def transform(self, node): + syms = self.syms results = self.match(node) assert results obj = results["obj"].clone() @@ -58,4 +47,3 @@ + after) new.set_prefix(node.get_prefix()) return new - Modified: sandbox/trunk/2to3/fixes/fix_ne.py ============================================================================== --- sandbox/trunk/2to3/fixes/fix_ne.py (original) +++ sandbox/trunk/2to3/fixes/fix_ne.py Thu Dec 28 22:50:13 2006 @@ -11,17 +11,17 @@ # Local imports import pytree -import pygram +from fixes import basefix -syms = pygram.python_symbols +class FixNe(basefix.BaseFix): -class FixNe(object): - - def __init__(self, options): - self.options = options + def compile_pattern(self): + # Override + pass def match(self, node): + # Override return node.type == token.NOTEQUAL and node.value == "<>" def transform(self, node): Deleted: /sandbox/trunk/2to3/fixes/fix_null.py ============================================================================== --- /sandbox/trunk/2to3/fixes/fix_null.py Thu Dec 28 22:50:13 2006 +++ (empty file) @@ -1,40 +0,0 @@ -# Copyright 2006 Google, Inc. All Rights Reserved. -# Licensed to PSF under a Contributor Agreement. - -"""Null fixer. Use as a template.""" - - -class FixNull(object): - - """Fixer class. - - The class name must be FixFooBar where FooBar is the result of - removing underscores and capitalizing the words of the fix name. - For example, the class name for a fixer named 'has_key' should be - FixHasKey. - """ - - def __init__(self, options): - """Initializer. - - The argument is an optparse.Values instance which can be used - to inspect the command line options. - """ - self.options = options - - def match(self, node): - """Matcher. - - Should return a true or false object (not necessarily a bool). - It may return a non-empty dict of matching sub-nodes as - returned by a matching pattern. - """ - return None - - def transform(self, node): - """Transformer. - - Should return None, or a node that is a modified copy of the - argument node. The argument should not be modified in place. - """ - return None Modified: sandbox/trunk/2to3/fixes/fix_print.py ============================================================================== --- sandbox/trunk/2to3/fixes/fix_print.py (original) +++ sandbox/trunk/2to3/fixes/fix_print.py Thu Dec 28 22:50:13 2006 @@ -15,30 +15,24 @@ # Local imports import pytree -import patcomp -import pygram +from fixes import basefix -syms = pygram.python_symbols -pat_compile = patcomp.PatternCompiler().compile_pattern -PATTERN = """ -'print' | print_stmt -""" +class FixPrint(basefix.BaseFix): - -class FixPrint(object): - - def __init__(self, options): - self.options = options - self.pattern = pat_compile(PATTERN) + PATTERN = """ + 'print' | print_stmt + """ def match(self, node): - if node.parent is not None and node.parent.type == syms.print_stmt: + # Override + if node.parent is not None and node.parent.type == self.syms.print_stmt: # Avoid matching 'print' as part of a print_stmt return None return self.pattern.match(node) def transform(self, node): + syms = self.syms results = self.match(node) assert results @@ -68,13 +62,13 @@ l_args[0].set_prefix("") if sep is not None or end is not None or file is not None: if sep is not None: - add_kwarg(l_args, "sep", - pytree.Leaf(token.STRING, repr(sep))) + self.add_kwarg(l_args, "sep", + pytree.Leaf(token.STRING, repr(sep))) if end is not None: - add_kwarg(l_args, "end", - pytree.Leaf(token.STRING, repr(end))) + self.add_kwarg(l_args, "end", + pytree.Leaf(token.STRING, repr(end))) if file is not None: - add_kwarg(l_args, "file", file) + self.add_kwarg(l_args, "file", file) if l_args: n_arglist = pytree.Node(syms.arglist, l_args) else: @@ -87,14 +81,14 @@ n_stmt.set_prefix(node.get_prefix()) return n_stmt -def add_kwarg(l_nodes, s_kwd, n_expr): - # XXX All this prefix-setting may lose comments (though rarely) - n_expr.set_prefix("") - n_argument = pytree.Node(syms.argument, - (pytree.Leaf(token.NAME, s_kwd), - pytree.Leaf(token.EQUAL, "="), - n_expr)) - if l_nodes: - l_nodes.append(pytree.Leaf(token.COMMA, ",")) - n_argument.set_prefix(" ") - l_nodes.append(n_argument) + def add_kwarg(self, l_nodes, s_kwd, n_expr): + # XXX All this prefix-setting may lose comments (though rarely) + n_expr.set_prefix("") + n_argument = pytree.Node(self.syms.argument, + (pytree.Leaf(token.NAME, s_kwd), + pytree.Leaf(token.EQUAL, "="), + n_expr)) + if l_nodes: + l_nodes.append(pytree.Leaf(token.COMMA, ",")) + n_argument.set_prefix(" ") + l_nodes.append(n_argument) From python-checkins at python.org Fri Dec 29 01:06:23 2006 From: python-checkins at python.org (phillip.eby) Date: Fri, 29 Dec 2006 01:06:23 +0100 (CET) Subject: [Python-checkins] r53175 - sandbox/trunk/setuptools/README.txt sandbox/trunk/setuptools/setup.py Message-ID: <20061229000623.E75D31E4004@bag.python.org> Author: phillip.eby Date: Fri Dec 29 01:06:23 2006 New Revision: 53175 Added: sandbox/trunk/setuptools/README.txt (contents, props changed) Modified: sandbox/trunk/setuptools/setup.py Log: New installation instructions and credits Added: sandbox/trunk/setuptools/README.txt ============================================================================== --- (empty file) +++ sandbox/trunk/setuptools/README.txt Fri Dec 29 01:06:23 2006 @@ -0,0 +1,149 @@ +=============================== +Installing and Using Setuptools +=============================== + +.. contents:: **Table of Contents** + + +------------------------- +Installation Instructions +------------------------- + +Windows +======= + +Install setuptools using the provided ``.exe`` installer. If you've previously +installed older versions of setuptools, please delete all ``setuptools*.egg`` +files from your system FIRST. + +If you are upgrading a previous version of setuptools that was installed using +an ``.exe`` installer, please be sure to also *uninstall that older version* +via your system's "Add/Remove Programs" feature, BEFORE installing the newer +version. + +Once installation is complete, you will find an ``easy_install.exe`` program in +your Python ``Scripts`` subdirectory. Be sure to add this directory to your +``PATH`` environment variable, if you haven't already done so. + + +RPM-Based Systems +================= + +Install setuptools using the provided source RPM. The included ``.spec`` file +assumes you are installing using the default ``python`` executable, and is not +specific to a particular Python version. The ``easy_install`` executable will +be installed to a system ``bin`` directory such as ``/usr/bin``. + +If you wish to install to a location other than the default Python +installation's default ``site-packages`` directory (and ``$prefix/bin`` for +scripts), please use the ``.egg``-based installation approach described in the +following section. + + +Cygwin, Mac OS X, Linux, Other +============================== + +1. Download the appropriate egg for your version of Python (e.g. + ``setuptools-0.6c4-py2.4.egg``). Do NOT rename it. + +2. Run it as if it were a shell script, e.g. ``sh setuptools-0.6c4-py2.4.egg``. + Setuptools will install itself using the matching version of Python (e.g. + ``python2.4``), and will place the ``easy_install`` executable in the + default location for installing Python scripts (as determined by the + standard distutils configuration files, or by the Python installation). + +If you want to install setuptools to somewhere other than ``site-packages`` or +your default distutils installation locations for libraries and scripts, you +may include EasyInstall command-line options such as ``--prefix``, +``--install-dir``, and so on, following the ``.egg`` filename on the same +command line. For example:: + + sh setuptools-0.6c4-py2.4.egg --prefix=~ + +You can use ``--help`` to get a full options list, but we recommend consulting +the `EasyInstall manual`_ for detailed instructions, especially `the section +on custom installation locations`_. + +.. _The EasyInstall user's guide and reference manual: http://peak.telecommunity.com/DevCenter/EasyInstall +.. _the section on custom installation locations: http://peak.telecommunity.com/DevCenter/EasyInstall#custom-installation-locations + + +Cygwin Note +----------- + +If you are trying to install setuptools for the *Windows* version of Python (as +opposed to the Cygwin version that lives in ``/usr/bin``), you must make sure +that an appropriate executable (``python2.3``, ``python2.4``, or ``python2.5``) +is on your **Cygwin** ``PATH`` when invoking the egg. For example, doing the +following at a Cygwin bash prompt will install setuptools for the *Windows* +Python found at ``C:\\Python24``:: + + ln -s /cygdrive/c/Python24/python.exe python2.4 + PATH=.:$PATH sh setuptools-0.6c4-py2.4.egg + rm python2.4 + + +Downloads +========= + +All setuptools downloads can be found at `the project's home page in the Python +Cheese Shop`_. Scroll to the very bottom of the page to find the links. + +.. _the project's home page in the Python Cheese Shop: http://cheeseshop.python.org/pypi/setuptools + +-------------------------------- +Using Setuptools and EasyInstall +-------------------------------- + +Here are some of the available manuals, tutorials, and other resources for +learning about Setuptools, Python Eggs, and EasyInstall: + +* `The EasyInstall user's guide and reference manual`_ +* `The setuptools Developer's Guide`_ +* `The pkg_resources API reference`_ +* `Package Compatibility Notes`_ (user-maintained) +* `The Internal Structure of Python Eggs`_ + +Questions, comments, and bug reports should be directed to the `distutils-sig +mailing list`_. If you have written (or know of) any tutorials, documentation, +plug-ins, or other resources for setuptools users, please let us know about +them there, so this reference list can be updated. + +.. _Package Compatibility Notes: http://peak.telecommunity.com/DevCenter/PackageNotes +.. _The Internal Structure of Python Eggs: http://peak.telecommunity.com/DevCenter/EggFormats +.. _The setuptools Developer's Guide: http://peak.telecommunity.com/DevCenter/setuptools +.. _The pkg_resources API reference: http://peak.telecommunity.com/DevCenter/PkgResources +.. _The EasyInstall user's guide and reference manual: http://peak.telecommunity.com/DevCenter/EasyInstall +.. _distutils-sig mailing list: http://mail.python.org/pipermail/distutils-sig/ + + +------- +Credits +------- + +* The original design for the ``.egg`` format and the ``pkg_resources`` API was + co-created by Phillip Eby and Bob Ippolito. Bob also implemented the first + version of ``pkg_resources``, and supplied the OS X operating system version + compatibility algorithm. + +* Ian Bicking implemented many early "creature comfort" features of + easy_install, including support for downloading via Sourceforge and + Subversion repositories. Ian's comments on the Web-SIG about WSGI + application deployment also inspired the concept of "entry points" in eggs, + and he has given talks at PyCon and elsewhere to inform and educate the + community about eggs and setuptools. + +* Jim Fulton contributed time and effort to build automated tests of various + aspects of ``easy_install``, and supplied the doctests for the command-line + ``.exe`` wrappers on Windows. + +* Phillip J. Eby is the principal author and maintainer of setuptools, and + first proposed the idea of an importable binary distribution format for + Python application plug-ins. + +* Significant parts of the implementation of setuptools were funded by the Open + Source Applications Foundation, to provide a plug-in infrastructure for the + Chandler PIM application. In addition, many OSAF staffers (such as Mike + "Code Bear" Taylor) contributed their time and stress as guinea pigs for the + use of eggs and setuptools, even before eggs were "cool". (Thanks, guys!) + Modified: sandbox/trunk/setuptools/setup.py ============================================================================== --- sandbox/trunk/setuptools/setup.py (original) +++ sandbox/trunk/setuptools/setup.py Fri Dec 29 01:06:23 2006 @@ -1,38 +1,31 @@ #!/usr/bin/env python """Distutils setup file, used to install or test 'setuptools'""" -def get_description(): - # Get our long description from the documentation - f = file('setuptools.txt') - lines = [] - for line in f: - if not line.strip(): - break # skip to first blank line - for line in f: - if line.startswith('.. contents::'): - break # read to table of contents - lines.append(line) - f.close() - return ''.join(lines) - from distutils.util import convert_path -d = {}; execfile(convert_path('setuptools/command/__init__.py'), d) + +d = {} +execfile(convert_path('setuptools/command/__init__.py'), d) + SETUP_COMMANDS = d['__all__'] VERSION = "0.7a1" + from setuptools import setup, find_packages import sys + modules = ['pkg_resources','easy_install'] + if sys.version<"2.5": modules += ['_pkgutil', 'doctest', 'pydoc'] # fixups for older Pythons + setup( name="setuptools", version=VERSION, description="Download, build, install, upgrade, and uninstall Python " "packages -- easily!", author="Phillip J. Eby", - author_email="peak at eby-sarna.com", + author_email="distutils-sig at python.org", license="PSF or ZPL", - long_description = get_description(), + long_description = open('README.txt').read(), keywords = "CPAN PyPI distutils eggs package management", url = "http://peak.telecommunity.com/DevCenter/setuptools", test_suite = 'setuptools.tests', @@ -84,6 +77,9 @@ ['eggsecutable = setuptools.command.easy_install:bootstrap'], }, + + + classifiers = [f.strip() for f in """ Development Status :: 3 - Alpha Intended Audience :: Developers @@ -121,3 +117,7 @@ + + + + From python-checkins at python.org Fri Dec 29 01:09:57 2006 From: python-checkins at python.org (phillip.eby) Date: Fri, 29 Dec 2006 01:09:57 +0100 (CET) Subject: [Python-checkins] r53176 - sandbox/branches/setuptools-0.6/README.txt sandbox/branches/setuptools-0.6/setup.py Message-ID: <20061229000957.8C19D1E4004@bag.python.org> Author: phillip.eby Date: Fri Dec 29 01:09:57 2006 New Revision: 53176 Added: sandbox/branches/setuptools-0.6/README.txt - copied unchanged from r53175, sandbox/trunk/setuptools/README.txt Modified: sandbox/branches/setuptools-0.6/setup.py Log: New installation instructions & credits (backport from trunk) Modified: sandbox/branches/setuptools-0.6/setup.py ============================================================================== --- sandbox/branches/setuptools-0.6/setup.py (original) +++ sandbox/branches/setuptools-0.6/setup.py Fri Dec 29 01:09:57 2006 @@ -1,25 +1,14 @@ #!/usr/bin/env python """Distutils setup file, used to install or test 'setuptools'""" -def get_description(): - # Get our long description from the documentation - f = file('setuptools.txt') - lines = [] - for line in f: - if not line.strip(): - break # skip to first blank line - for line in f: - if line.startswith('.. contents::'): - break # read to table of contents - lines.append(line) - f.close() - return ''.join(lines) - from distutils.util import convert_path -d = {}; execfile(convert_path('setuptools/command/__init__.py'), d) -SETUP_COMMANDS = d['__all__'] +d = {} +execfile(convert_path('setuptools/command/__init__.py'), d) + +SETUP_COMMANDS = d['__all__'] VERSION = "0.6c4" + from setuptools import setup, find_packages import sys scripts = [] @@ -30,9 +19,9 @@ description="Download, build, install, upgrade, and uninstall Python " "packages -- easily!", author="Phillip J. Eby", - author_email="peak at eby-sarna.com", + author_email="distutils-sig at python.org", license="PSF or ZPL", - long_description = get_description(), + long_description = open('README.txt').read(), keywords = "CPAN PyPI distutils eggs package management", url = "http://peak.telecommunity.com/DevCenter/setuptools", test_suite = 'setuptools.tests', @@ -77,9 +66,6 @@ "dependency_links.txt = setuptools.command.egg_info:overwrite_arg", ], - - - "console_scripts": [ "easy_install = setuptools.command.easy_install:main", "easy_install-%s = setuptools.command.easy_install:main" @@ -93,6 +79,7 @@ ['eggsecutable = setuptools.command.easy_install:bootstrap'], }, + classifiers = [f.strip() for f in """ Development Status :: 3 - Alpha Intended Audience :: Developers @@ -121,3 +108,16 @@ + + + + + + + + + + + + + From python-checkins at python.org Fri Dec 29 01:31:05 2006 From: python-checkins at python.org (phillip.eby) Date: Fri, 29 Dec 2006 01:31:05 +0100 (CET) Subject: [Python-checkins] r53177 - in sandbox/trunk/setuptools: EasyInstall.txt setuptools/command/easy_install.py setuptools/package_index.py Message-ID: <20061229003105.722041E4004@bag.python.org> Author: phillip.eby Date: Fri Dec 29 01:31:04 2006 New Revision: 53177 Modified: sandbox/trunk/setuptools/EasyInstall.txt sandbox/trunk/setuptools/setuptools/command/easy_install.py sandbox/trunk/setuptools/setuptools/package_index.py Log: Removed all special support for Sourceforge mirrors, since SF finally replaced their crazy mirror system with something sane. Modified: sandbox/trunk/setuptools/EasyInstall.txt ============================================================================== --- sandbox/trunk/setuptools/EasyInstall.txt (original) +++ sandbox/trunk/setuptools/EasyInstall.txt Fri Dec 29 01:31:04 2006 @@ -355,40 +355,6 @@ ``python.org`` and ``myintranet.example.com`` domains, unless overridden on the command line. -Note that if you want to allow downloads from Sourceforge, you need to enable -the ``dl.sourceforge.net`` host. All Sourceforge mirror downloads are treated -as if they had this hostname, regardless of which mirror is actually used to -do the downloading. If you want to restrict downloading to specific -Sourceforge hosts, you must use the ``--sf-mirrors`` option to set what hosts -will be substituted for ``dl.sourceforge.net``. See the next section for more -details. - - -Selecting Your Preferred Sourceforge Mirror(s) -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - -You can use the ``--sf-mirrors`` option on the command line, or via the -standard `configuration files`_, to select what Sourceforge mirrors you want -downloads to take place from. For example, putting this in your -configuration:: - - [easy_install] - sf_mirrors = superb-east, superb-west, easynews - -Would cause ``easy_install`` to always perform Sourceforge downloads using -``superb-east.dl.sourceforge.net``, ``superb-west.dl.sourceforge.net``, or -``easynews.dl.sourceforge.net``. You can also specify IP addresses or full -domain names. - -The actual mirror used will be selected at runtime. If the selected mirror -fails, another mirror will be selected, after eliminating the failed mirror as -a possible choice. - -If you don't specify any mirrors, ``easy_install`` will randomly select mirrors -from the list of IP addresses for ``sf-mirrors.telecommunity.com``. And if -the DNS lookup fails, it will simply make a single download attempt to -``dl.sourceforge.net``, without using any mirrors at all. - Installing on Un-networked Machines ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -909,32 +875,6 @@ setting for this option in their `configuration files`_, and then manually override the setting on the command line as needed. - Note that if you wish to allow Sourceforge downloads, you must allow access - to ``dl.sourceforge.net``. You do not have to list individual Sourceforge - mirror addresses, as mirror selection is controlled by the ``--sf-mirrors`` - option. - -``--sf-mirrors=NAMES`` (New in 0.6c4) - Set the list of Sourceforge mirror sites to use for downloads published by - Sourceforge. EasyInstall will randomly select one for each Sourceforge - download attempt. - - Mirror sites can be given by name (e.g. ``easynews``, ``superb-east``, - etc.) or by full hostname/IP address (e.g. ``easynews.dl.sf.net``). Use a - comma to separate mirrors. - - If you do not provide any names, EasyInstall will use the list of IP - addresses provided by the ``sf-mirrors.telecommunity.com`` subdomain, which - is automatically updated daily from Sourceforge's UI pages and DNS. - - If, due to firewall protections or server failure, it isn't possible to get - the mirror list from ``sf-mirrors.telecommunity.com``, EasyInstall will - attempt to perform all downloads directly from ``dl.sourceforge.net`` - without selecting a mirror. (Note, however, that this is extremely - unreliable due to Sourceforge not keeping the ``dl.sourceforge.net`` IP - addresses up to date with their UI! This is why the backup system at - ``sf-mirrors.telecommunity.com`` exists.) - ``--prefix=DIR`` (New in 0.6a10) Use the specified directory as a base for computing the default installation and script directories. On Windows, the resulting default @@ -1257,11 +1197,6 @@ 0.7a1 * You can now use "python -m easy_install" with Python 2.4 and above. - * Added automatic retry for Sourceforge mirrors. The new download process is - to first just try dl.sourceforge.net, then randomly select mirror IPs and - remove ones that fail, until something works. The removed IPs stay removed - for the remainder of the run. - * Better ambiguity management: accept ``#egg`` name/version even if processing what appears to be a correctly-named distutils file, and ignore ``.egg`` files with no ``-``, since valid Python ``.egg`` files always have a version Modified: sandbox/trunk/setuptools/setuptools/command/easy_install.py ============================================================================== --- sandbox/trunk/setuptools/setuptools/command/easy_install.py (original) +++ sandbox/trunk/setuptools/setuptools/command/easy_install.py Fri Dec 29 01:31:04 2006 @@ -70,7 +70,6 @@ ('editable', 'e', "Install specified packages in editable form"), ('no-deps', 'N', "don't install dependencies"), ('allow-hosts=', 'H', "pattern(s) that hostnames must match"), - ('sf-mirrors=', None, "Sourceforge mirror(s) to use"), ] boolean_options = [ 'zip-ok', 'multi-version', 'exclude-scripts', 'upgrade', 'always-copy', @@ -80,6 +79,7 @@ negative_opt = {'always-unzip': 'zip-ok'} create_index = PackageIndex + def initialize_options(self): self.zip_ok = None self.install_dir = self.script_dir = self.exclude_scripts = None @@ -90,7 +90,7 @@ self.optimize = self.record = None self.upgrade = self.always_copy = self.multi_version = None self.editable = self.no_deps = self.allow_hosts = None - self.root = self.prefix = self.no_report = self.sf_mirrors = None + self.root = self.prefix = self.no_report = None # Options not specifiable via command line self.package_index = None @@ -169,7 +169,6 @@ if self.package_index is None: self.package_index = self.create_index( self.index_url, search_path = self.shadow_path, hosts=hosts, - sf_mirrors = self.sf_mirrors ) self.local_index = Environment(self.shadow_path+sys.path) @@ -203,6 +202,7 @@ self.outputs = [] + def run(self): if self.verbose<>self.distribution.verbose: log.set_verbosity(self.verbose) Modified: sandbox/trunk/setuptools/setuptools/package_index.py ============================================================================== --- sandbox/trunk/setuptools/setuptools/package_index.py (original) +++ sandbox/trunk/setuptools/setuptools/package_index.py Fri Dec 29 01:31:04 2006 @@ -14,7 +14,7 @@ '([^<]+)\n\s+\\(md5\\)' ) -SF_DOWNLOAD = 'dl.sourceforge.net' + URL_SCHEME = re.compile('([-+.a-z0-9]{2,}):',re.I).match EXTENSIONS = ".tar.gz .tar.bz2 .tar .zip .tgz".split() @@ -146,27 +146,11 @@ ) - - - - - - - - - - - - - - - - class PackageIndex(Environment): """A distribution index that scans web pages for download URLs""" def __init__(self, index_url="http://www.python.org/pypi", hosts=('*',), - sf_mirrors=None, *args, **kw + *args, **kw ): Environment.__init__(self,*args,**kw) self.index_url = index_url + "/"[:not index_url.endswith('/')] @@ -175,39 +159,14 @@ self.package_pages = {} self.allows = re.compile('|'.join(map(translate,hosts))).match self.to_scan = [] - if sf_mirrors: - if isinstance(sf_mirrors,str): - self.sf_mirrors = map(str.strip, sf_mirrors.split(',')) - else: - self.sf_mirrors = map(str.strip, sf_mirrors) - else: - self.sf_mirrors = () - - def _get_mirrors(self): - mirrors = [] - for mirror in self.sf_mirrors: - if mirror: - if '.' not in mirror: - mirror += '.dl.sourceforge.net' - mirrors.append(mirror) - - if not mirrors: - try: - mirrors.extend( - socket.gethostbyname_ex('sf-mirrors.telecommunity.com')[-1] - ) - except socket.error: - # DNS-bl0ck1n9 f1r3w4llz sUx0rs! - mirrors[:] = [SF_DOWNLOAD] - return mirrors def process_url(self, url, retrieve=False): """Evaluate a URL as a possible download, and maybe retrieve it""" - url = fix_sf_url(url) if url in self.scanned_urls and not retrieve: return + self.scanned_urls[url] = True if not URL_SCHEME(url): self.process_filename(url) @@ -613,47 +572,6 @@ pass # no-op - def _attempt_download(self, url, filename): - headers = self._download_to(url, filename) - if 'html' in headers['content-type'].lower(): - return self._download_html(url, headers, filename) - else: - return filename - - def _retry_sf_download(self, url, filename): - self.url_ok(url, True) # raises error if not allowed - scheme, server, path, param, query, frag = urlparse.urlparse(url) - - if server == SF_DOWNLOAD: - mirrors = self._get_mirrors() - query = '' - else: - mirrors = [server] - - while mirrors or server != SF_DOWNLOAD: - mirror = random.choice(mirrors) - url = urlparse.urlunparse((scheme,mirror,path,param,query,frag)) - - try: - return self._attempt_download(url, filename) - except (KeyboardInterrupt,SystemExit): - raise - except: - if server != SF_DOWNLOAD: - raise - self.warn("Download failed: %s", sys.exc_info()[1]) - mirrors.remove(mirror) - - raise # fail if no mirror works - - - - - - - - - def open_url(self, url): if url.startswith('file:'): return local_open(url) @@ -689,15 +607,19 @@ elif scheme=='file': return urllib2.url2pathname(urlparse.urlparse(url)[2]) else: - return self._retry_sf_download(url, filename) - - - - + self.url_ok(url, True) # raises error if not allowed + return self._attempt_download(url, filename) def scan_url(self, url): self.process_url(url, True) + def _attempt_download(self, url, filename): + headers = self._download_to(url, filename) + if 'html' in headers['content-type'].lower(): + return self._download_html(url, headers, filename) + else: + return filename + def _download_html(self, url, headers, filename): file = open(filename) for line in file: @@ -728,13 +650,12 @@ def warn(self, msg, *args): log.warn(msg, *args) + + + + def fix_sf_url(url): - scheme, server, path, param, query, frag = urlparse.urlparse(url) - if server!='prdownloads.sourceforge.net': - return url - return urlparse.urlunparse( - (scheme, SF_DOWNLOAD, 'sourceforge'+path, param, '', frag) - ) + return url # backward compatibility def local_open(url): """Read a local path, with special support for directories""" @@ -773,7 +694,4 @@ - - - # this line is a kludge to keep the trailing blank lines for pje's editor From python-checkins at python.org Fri Dec 29 01:34:27 2006 From: python-checkins at python.org (phillip.eby) Date: Fri, 29 Dec 2006 01:34:27 +0100 (CET) Subject: [Python-checkins] r53178 - in sandbox/branches/setuptools-0.6: EasyInstall.txt setuptools/command/easy_install.py setuptools/package_index.py Message-ID: <20061229003427.220051E4004@bag.python.org> Author: phillip.eby Date: Fri Dec 29 01:34:24 2006 New Revision: 53178 Modified: sandbox/branches/setuptools-0.6/EasyInstall.txt sandbox/branches/setuptools-0.6/setuptools/command/easy_install.py sandbox/branches/setuptools-0.6/setuptools/package_index.py Log: Removed all special support for Sourceforge mirrors, as Sourceforge's mirror system now works well for non-browser downloads. (backport from trunk) Modified: sandbox/branches/setuptools-0.6/EasyInstall.txt ============================================================================== --- sandbox/branches/setuptools-0.6/EasyInstall.txt (original) +++ sandbox/branches/setuptools-0.6/EasyInstall.txt Fri Dec 29 01:34:24 2006 @@ -355,40 +355,6 @@ ``python.org`` and ``myintranet.example.com`` domains, unless overridden on the command line. -Note that if you want to allow downloads from Sourceforge, you need to enable -the ``dl.sourceforge.net`` host. All Sourceforge mirror downloads are treated -as if they had this hostname, regardless of which mirror is actually used to -do the downloading. If you want to restrict downloading to specific -Sourceforge hosts, you must use the ``--sf-mirrors`` option to set what hosts -will be substituted for ``dl.sourceforge.net``. See the next section for more -details. - - -Selecting Your Preferred Sourceforge Mirror(s) -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - -You can use the ``--sf-mirrors`` option on the command line, or via the -standard `configuration files`_, to select what Sourceforge mirrors you want -downloads to take place from. For example, putting this in your -configuration:: - - [easy_install] - sf_mirrors = superb-east, superb-west, easynews - -Would cause ``easy_install`` to always perform Sourceforge downloads using -``superb-east.dl.sourceforge.net``, ``superb-west.dl.sourceforge.net``, or -``easynews.dl.sourceforge.net``. You can also specify IP addresses or full -domain names. - -The actual mirror used will be selected at runtime. If the selected mirror -fails, another mirror will be selected, after eliminating the failed mirror as -a possible choice. - -If you don't specify any mirrors, ``easy_install`` will randomly select mirrors -from the list of IP addresses for ``sf-mirrors.telecommunity.com``. And if -the DNS lookup fails, it will simply make a single download attempt to -``dl.sourceforge.net``, without using any mirrors at all. - Installing on Un-networked Machines ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -909,32 +875,6 @@ setting for this option in their `configuration files`_, and then manually override the setting on the command line as needed. - Note that if you wish to allow Sourceforge downloads, you must allow access - to ``dl.sourceforge.net``. You do not have to list individual Sourceforge - mirror addresses, as mirror selection is controlled by the ``--sf-mirrors`` - option. - -``--sf-mirrors=NAMES`` (New in 0.6c4) - Set the list of Sourceforge mirror sites to use for downloads published by - Sourceforge. EasyInstall will randomly select one for each Sourceforge - download attempt. - - Mirror sites can be given by name (e.g. ``easynews``, ``superb-east``, - etc.) or by full hostname/IP address (e.g. ``easynews.dl.sf.net``). Use a - comma to separate mirrors. - - If you do not provide any names, EasyInstall will use the list of IP - addresses provided by the ``sf-mirrors.telecommunity.com`` subdomain, which - is automatically updated daily from Sourceforge's UI pages and DNS. - - If, due to firewall protections or server failure, it isn't possible to get - the mirror list from ``sf-mirrors.telecommunity.com``, EasyInstall will - attempt to perform all downloads directly from ``dl.sourceforge.net`` - without selecting a mirror. (Note, however, that this is extremely - unreliable due to Sourceforge not keeping the ``dl.sourceforge.net`` IP - addresses up to date with their UI! This is why the backup system at - ``sf-mirrors.telecommunity.com`` exists.) - ``--prefix=DIR`` (New in 0.6a10) Use the specified directory as a base for computing the default installation and script directories. On Windows, the resulting default @@ -1255,16 +1195,12 @@ ============================ 0.6c4 + * Removed all special support for Sourceforge mirrors, as Sourceforge's + mirror system now works well for non-browser downloads. + * Fixed not recogninzing ``win32.exe`` installers that included a custom bitmap. - * Fixed SF downloads aborting when a SF mirror returns an HTML page when it - should've returned a 404. Fall back to ``sf-mirrors.telecommunity.com`` - round-robin address for SF mirrors if ``dl.sourceforge.net`` doesn't work. - - * Allow explicit selection of Sourceforge mirror(s) with ``--sf-mirror``, and - further refine download/retry algorithm. - * Fixed not allowing ``os.open()`` of paths outside the sandbox, even if they are opened read-only (e.g. reading ``/dev/urandom`` for random numbers, as is done by ``os.urandom()`` on some platforms). Modified: sandbox/branches/setuptools-0.6/setuptools/command/easy_install.py ============================================================================== --- sandbox/branches/setuptools-0.6/setuptools/command/easy_install.py (original) +++ sandbox/branches/setuptools-0.6/setuptools/command/easy_install.py Fri Dec 29 01:34:24 2006 @@ -70,7 +70,6 @@ ('editable', 'e', "Install specified packages in editable form"), ('no-deps', 'N', "don't install dependencies"), ('allow-hosts=', 'H', "pattern(s) that hostnames must match"), - ('sf-mirrors=', None, "Sourceforge mirror(s) to use"), ] boolean_options = [ 'zip-ok', 'multi-version', 'exclude-scripts', 'upgrade', 'always-copy', @@ -80,6 +79,7 @@ negative_opt = {'always-unzip': 'zip-ok'} create_index = PackageIndex + def initialize_options(self): self.zip_ok = None self.install_dir = self.script_dir = self.exclude_scripts = None @@ -90,7 +90,7 @@ self.optimize = self.record = None self.upgrade = self.always_copy = self.multi_version = None self.editable = self.no_deps = self.allow_hosts = None - self.root = self.prefix = self.no_report = self.sf_mirrors = None + self.root = self.prefix = self.no_report = None # Options not specifiable via command line self.package_index = None @@ -169,7 +169,6 @@ if self.package_index is None: self.package_index = self.create_index( self.index_url, search_path = self.shadow_path, hosts=hosts, - sf_mirrors = self.sf_mirrors ) self.local_index = Environment(self.shadow_path+sys.path) @@ -203,6 +202,7 @@ self.outputs = [] + def run(self): if self.verbose<>self.distribution.verbose: log.set_verbosity(self.verbose) Modified: sandbox/branches/setuptools-0.6/setuptools/package_index.py ============================================================================== --- sandbox/branches/setuptools-0.6/setuptools/package_index.py (original) +++ sandbox/branches/setuptools-0.6/setuptools/package_index.py Fri Dec 29 01:34:24 2006 @@ -14,7 +14,7 @@ '([^<]+)\n\s+\\(md5\\)' ) -SF_DOWNLOAD = 'dl.sourceforge.net' + URL_SCHEME = re.compile('([-+.a-z0-9]{2,}):',re.I).match EXTENSIONS = ".tar.gz .tar.bz2 .tar .zip .tgz".split() @@ -146,27 +146,11 @@ ) - - - - - - - - - - - - - - - - class PackageIndex(Environment): """A distribution index that scans web pages for download URLs""" def __init__(self, index_url="http://www.python.org/pypi", hosts=('*',), - sf_mirrors=None, *args, **kw + *args, **kw ): Environment.__init__(self,*args,**kw) self.index_url = index_url + "/"[:not index_url.endswith('/')] @@ -175,39 +159,14 @@ self.package_pages = {} self.allows = re.compile('|'.join(map(translate,hosts))).match self.to_scan = [] - if sf_mirrors: - if isinstance(sf_mirrors,str): - self.sf_mirrors = map(str.strip, sf_mirrors.split(',')) - else: - self.sf_mirrors = map(str.strip, sf_mirrors) - else: - self.sf_mirrors = () - - def _get_mirrors(self): - mirrors = [] - for mirror in self.sf_mirrors: - if mirror: - if '.' not in mirror: - mirror += '.dl.sourceforge.net' - mirrors.append(mirror) - - if not mirrors: - try: - mirrors.extend( - socket.gethostbyname_ex('sf-mirrors.telecommunity.com')[-1] - ) - except socket.error: - # DNS-bl0ck1n9 f1r3w4llz sUx0rs! - mirrors[:] = [SF_DOWNLOAD] - return mirrors def process_url(self, url, retrieve=False): """Evaluate a URL as a possible download, and maybe retrieve it""" - url = fix_sf_url(url) if url in self.scanned_urls and not retrieve: return + self.scanned_urls[url] = True if not URL_SCHEME(url): self.process_filename(url) @@ -613,47 +572,6 @@ pass # no-op - def _attempt_download(self, url, filename): - headers = self._download_to(url, filename) - if 'html' in headers['content-type'].lower(): - return self._download_html(url, headers, filename) - else: - return filename - - def _retry_sf_download(self, url, filename): - self.url_ok(url, True) # raises error if not allowed - scheme, server, path, param, query, frag = urlparse.urlparse(url) - - if server == SF_DOWNLOAD: - mirrors = self._get_mirrors() - query = '' - else: - mirrors = [server] - - while mirrors or server != SF_DOWNLOAD: - mirror = random.choice(mirrors) - url = urlparse.urlunparse((scheme,mirror,path,param,query,frag)) - - try: - return self._attempt_download(url, filename) - except (KeyboardInterrupt,SystemExit): - raise - except: - if server != SF_DOWNLOAD: - raise - self.warn("Download failed: %s", sys.exc_info()[1]) - mirrors.remove(mirror) - - raise # fail if no mirror works - - - - - - - - - def open_url(self, url): if url.startswith('file:'): return local_open(url) @@ -689,15 +607,19 @@ elif scheme=='file': return urllib2.url2pathname(urlparse.urlparse(url)[2]) else: - return self._retry_sf_download(url, filename) - - - - + self.url_ok(url, True) # raises error if not allowed + return self._attempt_download(url, filename) def scan_url(self, url): self.process_url(url, True) + def _attempt_download(self, url, filename): + headers = self._download_to(url, filename) + if 'html' in headers['content-type'].lower(): + return self._download_html(url, headers, filename) + else: + return filename + def _download_html(self, url, headers, filename): file = open(filename) for line in file: @@ -728,13 +650,12 @@ def warn(self, msg, *args): log.warn(msg, *args) + + + + def fix_sf_url(url): - scheme, server, path, param, query, frag = urlparse.urlparse(url) - if server!='prdownloads.sourceforge.net': - return url - return urlparse.urlunparse( - (scheme, SF_DOWNLOAD, 'sourceforge'+path, param, '', frag) - ) + return url # backward compatibility def local_open(url): """Read a local path, with special support for directories""" @@ -773,7 +694,4 @@ - - - # this line is a kludge to keep the trailing blank lines for pje's editor From python-checkins at python.org Fri Dec 29 01:34:49 2006 From: python-checkins at python.org (phillip.eby) Date: Fri, 29 Dec 2006 01:34:49 +0100 (CET) Subject: [Python-checkins] r53179 - sandbox/branches/setuptools-0.6/EasyInstall.txt Message-ID: <20061229003449.A668B1E4004@bag.python.org> Author: phillip.eby Date: Fri Dec 29 01:34:49 2006 New Revision: 53179 Modified: sandbox/branches/setuptools-0.6/EasyInstall.txt Log: Fix typo in release notes Modified: sandbox/branches/setuptools-0.6/EasyInstall.txt ============================================================================== --- sandbox/branches/setuptools-0.6/EasyInstall.txt (original) +++ sandbox/branches/setuptools-0.6/EasyInstall.txt Fri Dec 29 01:34:49 2006 @@ -1198,7 +1198,7 @@ * Removed all special support for Sourceforge mirrors, as Sourceforge's mirror system now works well for non-browser downloads. - * Fixed not recogninzing ``win32.exe`` installers that included a custom + * Fixed not recognizing ``win32.exe`` installers that included a custom bitmap. * Fixed not allowing ``os.open()`` of paths outside the sandbox, even if they From python-checkins at python.org Fri Dec 29 01:35:23 2006 From: python-checkins at python.org (phillip.eby) Date: Fri, 29 Dec 2006 01:35:23 +0100 (CET) Subject: [Python-checkins] r53180 - sandbox/branches/setuptools-0.6/EasyInstall.txt Message-ID: <20061229003523.849D71E4004@bag.python.org> Author: phillip.eby Date: Fri Dec 29 01:35:22 2006 New Revision: 53180 Modified: sandbox/branches/setuptools-0.6/EasyInstall.txt Log: And another typo... Modified: sandbox/branches/setuptools-0.6/EasyInstall.txt ============================================================================== --- sandbox/branches/setuptools-0.6/EasyInstall.txt (original) +++ sandbox/branches/setuptools-0.6/EasyInstall.txt Fri Dec 29 01:35:22 2006 @@ -1210,7 +1210,7 @@ directory). 0.6c3 - * You once again use "python -m easy_install" with Python 2.4 and above. + * You can once again use "python -m easy_install" with Python 2.4 and above. * Python 2.5 compatibility fixes added. From python-checkins at python.org Fri Dec 29 01:40:33 2006 From: python-checkins at python.org (phillip.eby) Date: Fri, 29 Dec 2006 01:40:33 +0100 (CET) Subject: [Python-checkins] r53181 - sandbox/trunk/setuptools/setuptools/command/bdist_rpm.py Message-ID: <20061229004033.64E611E4005@bag.python.org> Author: phillip.eby Date: Fri Dec 29 01:40:32 2006 New Revision: 53181 Modified: sandbox/trunk/setuptools/setuptools/command/bdist_rpm.py Log: Fix import problem for bdist_rpm w/Python<2.5 Modified: sandbox/trunk/setuptools/setuptools/command/bdist_rpm.py ============================================================================== --- sandbox/trunk/setuptools/setuptools/command/bdist_rpm.py (original) +++ sandbox/trunk/setuptools/setuptools/command/bdist_rpm.py Fri Dec 29 01:40:32 2006 @@ -4,7 +4,7 @@ # finally, a kludge to track .rpm files for uploading when run on Python <2.5. from distutils.command.bdist_rpm import bdist_rpm as _bdist_rpm -import sys +import sys, os class bdist_rpm(_bdist_rpm): From python-checkins at python.org Fri Dec 29 01:41:11 2006 From: python-checkins at python.org (phillip.eby) Date: Fri, 29 Dec 2006 01:41:11 +0100 (CET) Subject: [Python-checkins] r53182 - sandbox/branches/setuptools-0.6/setuptools/command/bdist_rpm.py Message-ID: <20061229004111.A22291E4004@bag.python.org> Author: phillip.eby Date: Fri Dec 29 01:41:11 2006 New Revision: 53182 Modified: sandbox/branches/setuptools-0.6/setuptools/command/bdist_rpm.py Log: Fix import problem for bdist_rpm w/Python<2.5 Modified: sandbox/branches/setuptools-0.6/setuptools/command/bdist_rpm.py ============================================================================== --- sandbox/branches/setuptools-0.6/setuptools/command/bdist_rpm.py (original) +++ sandbox/branches/setuptools-0.6/setuptools/command/bdist_rpm.py Fri Dec 29 01:41:11 2006 @@ -4,7 +4,7 @@ # finally, a kludge to track .rpm files for uploading when run on Python <2.5. from distutils.command.bdist_rpm import bdist_rpm as _bdist_rpm -import sys +import sys, os class bdist_rpm(_bdist_rpm): From python-checkins at python.org Fri Dec 29 01:58:35 2006 From: python-checkins at python.org (phillip.eby) Date: Fri, 29 Dec 2006 01:58:35 +0100 (CET) Subject: [Python-checkins] r53183 - sandbox/trunk/setuptools/setuptools/command/__init__.py sandbox/trunk/setuptools/setuptools/command/bdist_wininst.py Message-ID: <20061229005835.5401B1E4004@bag.python.org> Author: phillip.eby Date: Fri Dec 29 01:58:34 2006 New Revision: 53183 Modified: sandbox/trunk/setuptools/setuptools/command/__init__.py sandbox/trunk/setuptools/setuptools/command/bdist_wininst.py Log: Work around a distutils bdist_wininst bug: if the user has specified an --install-lib via a configuration file, the path is hardcoded into the .exe file in place of PLATLIB/ or PURELIB/. (This bug should also be fixed in distutils' bdist_wininst!) Modified: sandbox/trunk/setuptools/setuptools/command/__init__.py ============================================================================== --- sandbox/trunk/setuptools/setuptools/command/__init__.py (original) +++ sandbox/trunk/setuptools/setuptools/command/__init__.py Fri Dec 29 01:58:34 2006 @@ -9,7 +9,6 @@ if sys.version>='2.5': # In Python 2.5 and above, distutils includes its own upload command __all__.remove('upload') - __all__.remove('bdist_wininst') # this is only for 'upload' support from distutils.command.bdist import bdist Modified: sandbox/trunk/setuptools/setuptools/command/bdist_wininst.py ============================================================================== --- sandbox/trunk/setuptools/setuptools/command/bdist_wininst.py (original) +++ sandbox/trunk/setuptools/setuptools/command/bdist_wininst.py Fri Dec 29 01:58:34 2006 @@ -20,3 +20,11 @@ getattr(self.distribution,'dist_files',[]).append( ('bdist_wininst', pyversion, installer_name) ) + + def reinitialize_command (self, command, reinit_subcommands=0): + cmd = self.distribution.reinitialize_command( + command, reinit_subcommands) + if command in ('install', 'install_lib'): + cmd.install_lib = None # work around distutils bug + return cmd + From python-checkins at python.org Fri Dec 29 01:59:38 2006 From: python-checkins at python.org (phillip.eby) Date: Fri, 29 Dec 2006 01:59:38 +0100 (CET) Subject: [Python-checkins] r53184 - sandbox/branches/setuptools-0.6/setuptools/command/__init__.py sandbox/branches/setuptools-0.6/setuptools/command/bdist_wininst.py Message-ID: <20061229005938.1CF871E4004@bag.python.org> Author: phillip.eby Date: Fri Dec 29 01:59:37 2006 New Revision: 53184 Modified: sandbox/branches/setuptools-0.6/setuptools/command/__init__.py sandbox/branches/setuptools-0.6/setuptools/command/bdist_wininst.py Log: Work around a distutils bdist_wininst bug: if the user has specified an --install-lib via a configuration file, the path is hardcoded into the .exe file in place of PLATLIB/ or PURELIB/. (Backport from trunk.) Modified: sandbox/branches/setuptools-0.6/setuptools/command/__init__.py ============================================================================== --- sandbox/branches/setuptools-0.6/setuptools/command/__init__.py (original) +++ sandbox/branches/setuptools-0.6/setuptools/command/__init__.py Fri Dec 29 01:59:37 2006 @@ -9,7 +9,6 @@ if sys.version>='2.5': # In Python 2.5 and above, distutils includes its own upload command __all__.remove('upload') - __all__.remove('bdist_wininst') # this is only for 'upload' support from distutils.command.bdist import bdist Modified: sandbox/branches/setuptools-0.6/setuptools/command/bdist_wininst.py ============================================================================== --- sandbox/branches/setuptools-0.6/setuptools/command/bdist_wininst.py (original) +++ sandbox/branches/setuptools-0.6/setuptools/command/bdist_wininst.py Fri Dec 29 01:59:37 2006 @@ -20,3 +20,11 @@ getattr(self.distribution,'dist_files',[]).append( ('bdist_wininst', pyversion, installer_name) ) + + def reinitialize_command (self, command, reinit_subcommands=0): + cmd = self.distribution.reinitialize_command( + command, reinit_subcommands) + if command in ('install', 'install_lib'): + cmd.install_lib = None # work around distutils bug + return cmd + From python-checkins at python.org Fri Dec 29 02:29:51 2006 From: python-checkins at python.org (phillip.eby) Date: Fri, 29 Dec 2006 02:29:51 +0100 (CET) Subject: [Python-checkins] r53185 - in sandbox/trunk/setuptools: README.txt setuptools.egg-info/entry_points.txt setuptools/command/bdist_wininst.py setuptools/command/easy_install.py setuptools/command/install_scripts.py Message-ID: <20061229012951.8E91B1E4004@bag.python.org> Author: phillip.eby Date: Fri Dec 29 02:29:49 2006 New Revision: 53185 Modified: sandbox/trunk/setuptools/README.txt sandbox/trunk/setuptools/setuptools.egg-info/entry_points.txt sandbox/trunk/setuptools/setuptools/command/bdist_wininst.py sandbox/trunk/setuptools/setuptools/command/easy_install.py sandbox/trunk/setuptools/setuptools/command/install_scripts.py Log: Partial support for cross-platform generation of bdist_wininst .exe's. Unfortunately, bdist_wininst doesn't fix up #! lines, so python.exe or pythonw.exe have to be on PATH for generated scripts to work. This could probably be fixed up with a post-install script, but that's a job for another day. Modified: sandbox/trunk/setuptools/README.txt ============================================================================== --- sandbox/trunk/setuptools/README.txt (original) +++ sandbox/trunk/setuptools/README.txt Fri Dec 29 02:29:49 2006 @@ -23,7 +23,9 @@ Once installation is complete, you will find an ``easy_install.exe`` program in your Python ``Scripts`` subdirectory. Be sure to add this directory to your -``PATH`` environment variable, if you haven't already done so. +``PATH`` environment variable, if you haven't already done so. You must also +have your Python installation directory (e.g. ``C:\\Python23``) on the +``PATH``. RPM-Based Systems Modified: sandbox/trunk/setuptools/setuptools.egg-info/entry_points.txt ============================================================================== --- sandbox/trunk/setuptools/setuptools.egg-info/entry_points.txt (original) +++ sandbox/trunk/setuptools/setuptools.egg-info/entry_points.txt Fri Dec 29 02:29:49 2006 @@ -1,38 +1,3 @@ -[distutils.setup_keywords] -dependency_links = setuptools.dist:assert_string_list -entry_points = setuptools.dist:check_entry_points -extras_require = setuptools.dist:check_extras -package_data = setuptools.dist:check_package_data -install_requires = setuptools.dist:check_requirements -include_package_data = setuptools.dist:assert_bool -exclude_package_data = setuptools.dist:check_package_data -namespace_packages = setuptools.dist:check_nsp -test_suite = setuptools.dist:check_test_suite -eager_resources = setuptools.dist:assert_string_list -zip_safe = setuptools.dist:assert_bool -test_loader = setuptools.dist:check_importable -tests_require = setuptools.dist:check_requirements - -[setuptools.file_finders] -svn_cvs = setuptools.command.sdist:_default_revctrl - -[egg_info.writers] -dependency_links.txt = setuptools.command.egg_info:overwrite_arg -requires.txt = setuptools.command.egg_info:write_requirements -PKG-INFO = setuptools.command.egg_info:write_pkg_info -eager_resources.txt = setuptools.command.egg_info:overwrite_arg -top_level.txt = setuptools.command.egg_info:write_toplevel_names -namespace_packages.txt = setuptools.command.egg_info:overwrite_arg -entry_points.txt = setuptools.command.egg_info:write_entries -depends.txt = setuptools.command.egg_info:warn_depends_obsolete - -[console_scripts] -easy_install = setuptools.command.easy_install:main -easy_install-2.3 = setuptools.command.easy_install:main - -[setuptools.installation] -eggsecutable = setuptools.command.easy_install:bootstrap - [distutils.commands] bdist_rpm = setuptools.command.bdist_rpm:bdist_rpm rotate = setuptools.command.rotate:rotate @@ -54,3 +19,39 @@ install_lib = setuptools.command.install_lib:install_lib build_ext = setuptools.command.build_ext:build_ext sdist = setuptools.command.sdist:sdist + +[egg_info.writers] +dependency_links.txt = setuptools.command.egg_info:overwrite_arg +requires.txt = setuptools.command.egg_info:write_requirements +PKG-INFO = setuptools.command.egg_info:write_pkg_info +eager_resources.txt = setuptools.command.egg_info:overwrite_arg +top_level.txt = setuptools.command.egg_info:write_toplevel_names +namespace_packages.txt = setuptools.command.egg_info:overwrite_arg +entry_points.txt = setuptools.command.egg_info:write_entries +depends.txt = setuptools.command.egg_info:warn_depends_obsolete + +[console_scripts] +easy_install = setuptools.command.easy_install:main +easy_install-2.3 = setuptools.command.easy_install:main + +[setuptools.file_finders] +svn_cvs = setuptools.command.sdist:_default_revctrl + +[distutils.setup_keywords] +dependency_links = setuptools.dist:assert_string_list +entry_points = setuptools.dist:check_entry_points +extras_require = setuptools.dist:check_extras +package_data = setuptools.dist:check_package_data +install_requires = setuptools.dist:check_requirements +include_package_data = setuptools.dist:assert_bool +exclude_package_data = setuptools.dist:check_package_data +namespace_packages = setuptools.dist:check_nsp +test_suite = setuptools.dist:check_test_suite +eager_resources = setuptools.dist:assert_string_list +zip_safe = setuptools.dist:assert_bool +test_loader = setuptools.dist:check_importable +tests_require = setuptools.dist:check_requirements + +[setuptools.installation] +eggsecutable = setuptools.command.easy_install:bootstrap + Modified: sandbox/trunk/setuptools/setuptools/command/bdist_wininst.py ============================================================================== --- sandbox/trunk/setuptools/setuptools/command/bdist_wininst.py (original) +++ sandbox/trunk/setuptools/setuptools/command/bdist_wininst.py Fri Dec 29 02:29:49 2006 @@ -28,3 +28,10 @@ cmd.install_lib = None # work around distutils bug return cmd + def run(self): + self._is_running = True + try: + _bdist_wininst.run(self) + finally: + self._is_running = False + Modified: sandbox/trunk/setuptools/setuptools/command/easy_install.py ============================================================================== --- sandbox/trunk/setuptools/setuptools/command/easy_install.py (original) +++ sandbox/trunk/setuptools/setuptools/command/easy_install.py Fri Dec 29 02:29:49 2006 @@ -1408,7 +1408,7 @@ return path -def get_script_header(script_text, executable=sys_executable): +def get_script_header(script_text, executable=sys_executable, wininst=False): """Create a #! line, getting options (if any) from script_text""" from distutils.command.build_scripts import first_line_re first = (script_text+'\n').splitlines()[0] @@ -1418,6 +1418,8 @@ options = match.group(1) or '' if options: options = ' '+options + if wininst and sys.platform!='win32': + executable = "python.exe" hdr = "#!%(executable)s%(options)s\n" % locals() if unicode(hdr,'ascii','ignore').encode('ascii') != hdr: # Non-ascii path to sys.executable, use -x to prevent warnings @@ -1431,8 +1433,6 @@ return hdr - - def auto_chmod(func, arg, exc): if func is os.remove and os.name=='nt': os.chmod(arg, stat.S_IWRITE) @@ -1515,10 +1515,10 @@ -def get_script_args(dist, executable=sys_executable): +def get_script_args(dist, executable=sys_executable, wininst=False): """Yield write_script() argument tuples for a distribution's entrypoints""" spec = str(dist.as_requirement()) - header = get_script_header("", executable) + header = get_script_header("", executable, wininst) for group in 'console_scripts', 'gui_scripts': for name,ep in dist.get_entry_map(group).items(): script_text = ( @@ -1531,7 +1531,7 @@ " load_entry_point(%(spec)r, %(group)r, %(name)r)()\n" ")\n" ) % locals() - if sys.platform=='win32': + if sys.platform=='win32' or wininst: # On Windows, add a .py extension and an .exe launcher if group=='gui_scripts': ext, launcher = '-script.pyw', 'gui.exe' Modified: sandbox/trunk/setuptools/setuptools/command/install_scripts.py ============================================================================== --- sandbox/trunk/setuptools/setuptools/command/install_scripts.py (original) +++ sandbox/trunk/setuptools/setuptools/command/install_scripts.py Fri Dec 29 02:29:49 2006 @@ -29,16 +29,16 @@ ) bs_cmd = self.get_finalized_command('build_scripts') executable = getattr(bs_cmd,'executable',sys_executable) - - for args in get_script_args(dist, executable): + is_wininst = getattr( + self.get_finalized_command("bdist_wininst"), '_is_running', False + ) + for args in get_script_args(dist, executable, is_wininst): self.write_script(*args) - - def write_script(self, script_name, contents, mode="t", *ignored): """Write an executable file to the scripts directory""" log.info("Installing %s script to %s", script_name, self.install_dir) @@ -54,3 +54,29 @@ os.chmod(target,0755) except (AttributeError, os.error): pass + + + + + + + + + + + + + + + + + + + + + + + + + + From python-checkins at python.org Fri Dec 29 02:32:48 2006 From: python-checkins at python.org (phillip.eby) Date: Fri, 29 Dec 2006 02:32:48 +0100 (CET) Subject: [Python-checkins] r53186 - in sandbox/branches/setuptools-0.6: README.txt setuptools/command/bdist_wininst.py setuptools/command/easy_install.py setuptools/command/install_scripts.py Message-ID: <20061229013248.7B68F1E4004@bag.python.org> Author: phillip.eby Date: Fri Dec 29 02:32:46 2006 New Revision: 53186 Modified: sandbox/branches/setuptools-0.6/README.txt sandbox/branches/setuptools-0.6/setuptools/command/bdist_wininst.py sandbox/branches/setuptools-0.6/setuptools/command/easy_install.py sandbox/branches/setuptools-0.6/setuptools/command/install_scripts.py Log: Partial support for cross-platform generation of bdist_wininst .exe's. Unfortunately, bdist_wininst doesn't fix up #! lines, so python.exe or pythonw.exe have to be on PATH for generated scripts to work. This could probably be fixed up with a post-install script, but that's a job for another day. (backport from trunk) Modified: sandbox/branches/setuptools-0.6/README.txt ============================================================================== --- sandbox/branches/setuptools-0.6/README.txt (original) +++ sandbox/branches/setuptools-0.6/README.txt Fri Dec 29 02:32:46 2006 @@ -23,7 +23,9 @@ Once installation is complete, you will find an ``easy_install.exe`` program in your Python ``Scripts`` subdirectory. Be sure to add this directory to your -``PATH`` environment variable, if you haven't already done so. +``PATH`` environment variable, if you haven't already done so. You must also +have your Python installation directory (e.g. ``C:\\Python23``) on the +``PATH``. RPM-Based Systems Modified: sandbox/branches/setuptools-0.6/setuptools/command/bdist_wininst.py ============================================================================== --- sandbox/branches/setuptools-0.6/setuptools/command/bdist_wininst.py (original) +++ sandbox/branches/setuptools-0.6/setuptools/command/bdist_wininst.py Fri Dec 29 02:32:46 2006 @@ -28,3 +28,10 @@ cmd.install_lib = None # work around distutils bug return cmd + def run(self): + self._is_running = True + try: + _bdist_wininst.run(self) + finally: + self._is_running = False + Modified: sandbox/branches/setuptools-0.6/setuptools/command/easy_install.py ============================================================================== --- sandbox/branches/setuptools-0.6/setuptools/command/easy_install.py (original) +++ sandbox/branches/setuptools-0.6/setuptools/command/easy_install.py Fri Dec 29 02:32:46 2006 @@ -1408,7 +1408,7 @@ return path -def get_script_header(script_text, executable=sys_executable): +def get_script_header(script_text, executable=sys_executable, wininst=False): """Create a #! line, getting options (if any) from script_text""" from distutils.command.build_scripts import first_line_re first = (script_text+'\n').splitlines()[0] @@ -1418,6 +1418,8 @@ options = match.group(1) or '' if options: options = ' '+options + if wininst and sys.platform!='win32': + executable = "python.exe" hdr = "#!%(executable)s%(options)s\n" % locals() if unicode(hdr,'ascii','ignore').encode('ascii') != hdr: # Non-ascii path to sys.executable, use -x to prevent warnings @@ -1431,8 +1433,6 @@ return hdr - - def auto_chmod(func, arg, exc): if func is os.remove and os.name=='nt': os.chmod(arg, stat.S_IWRITE) @@ -1515,10 +1515,10 @@ -def get_script_args(dist, executable=sys_executable): +def get_script_args(dist, executable=sys_executable, wininst=False): """Yield write_script() argument tuples for a distribution's entrypoints""" spec = str(dist.as_requirement()) - header = get_script_header("", executable) + header = get_script_header("", executable, wininst) for group in 'console_scripts', 'gui_scripts': for name,ep in dist.get_entry_map(group).items(): script_text = ( @@ -1531,7 +1531,7 @@ " load_entry_point(%(spec)r, %(group)r, %(name)r)()\n" ")\n" ) % locals() - if sys.platform=='win32': + if sys.platform=='win32' or wininst: # On Windows, add a .py extension and an .exe launcher if group=='gui_scripts': ext, launcher = '-script.pyw', 'gui.exe' Modified: sandbox/branches/setuptools-0.6/setuptools/command/install_scripts.py ============================================================================== --- sandbox/branches/setuptools-0.6/setuptools/command/install_scripts.py (original) +++ sandbox/branches/setuptools-0.6/setuptools/command/install_scripts.py Fri Dec 29 02:32:46 2006 @@ -29,16 +29,16 @@ ) bs_cmd = self.get_finalized_command('build_scripts') executable = getattr(bs_cmd,'executable',sys_executable) - - for args in get_script_args(dist, executable): + is_wininst = getattr( + self.get_finalized_command("bdist_wininst"), '_is_running', False + ) + for args in get_script_args(dist, executable, is_wininst): self.write_script(*args) - - def write_script(self, script_name, contents, mode="t", *ignored): """Write an executable file to the scripts directory""" log.info("Installing %s script to %s", script_name, self.install_dir) From python-checkins at python.org Fri Dec 29 04:01:06 2006 From: python-checkins at python.org (neal.norwitz) Date: Fri, 29 Dec 2006 04:01:06 +0100 (CET) Subject: [Python-checkins] r53187 - python/branches/release25-maint/Lib/subprocess.py Message-ID: <20061229030106.D38C61E4004@bag.python.org> Author: neal.norwitz Date: Fri Dec 29 04:01:06 2006 New Revision: 53187 Modified: python/branches/release25-maint/Lib/subprocess.py Log: SF bug #1623890, fix argument name in docstring Modified: python/branches/release25-maint/Lib/subprocess.py ============================================================================== --- python/branches/release25-maint/Lib/subprocess.py (original) +++ python/branches/release25-maint/Lib/subprocess.py Fri Dec 29 04:01:06 2006 @@ -166,7 +166,7 @@ communicate(input=None) Interact with process: Send data to stdin. Read data from stdout and stderr, until end-of-file is reached. Wait for process to - terminate. The optional stdin argument should be a string to be + terminate. The optional input argument should be a string to be sent to the child process, or None, if no data should be sent to the child. From python-checkins at python.org Fri Dec 29 04:01:53 2006 From: python-checkins at python.org (neal.norwitz) Date: Fri, 29 Dec 2006 04:01:53 +0100 (CET) Subject: [Python-checkins] r53188 - python/trunk/Lib/subprocess.py Message-ID: <20061229030153.BE43C1E4004@bag.python.org> Author: neal.norwitz Date: Fri Dec 29 04:01:53 2006 New Revision: 53188 Modified: python/trunk/Lib/subprocess.py Log: SF bug #1623890, fix argument name in docstring Modified: python/trunk/Lib/subprocess.py ============================================================================== --- python/trunk/Lib/subprocess.py (original) +++ python/trunk/Lib/subprocess.py Fri Dec 29 04:01:53 2006 @@ -166,7 +166,7 @@ communicate(input=None) Interact with process: Send data to stdin. Read data from stdout and stderr, until end-of-file is reached. Wait for process to - terminate. The optional stdin argument should be a string to be + terminate. The optional input argument should be a string to be sent to the child process, or None, if no data should be sent to the child. From python-checkins at python.org Fri Dec 29 15:42:17 2006 From: python-checkins at python.org (thomas.wouters) Date: Fri, 29 Dec 2006 15:42:17 +0100 (CET) Subject: [Python-checkins] r53190 - in python/branches/release25-maint: Lib/test/test_array.py Misc/ACKS Modules/arraymodule.c Message-ID: <20061229144217.DFCAE1E4005@bag.python.org> Author: thomas.wouters Date: Fri Dec 29 15:42:17 2006 New Revision: 53190 Modified: python/branches/release25-maint/Lib/test/test_array.py python/branches/release25-maint/Misc/ACKS python/branches/release25-maint/Modules/arraymodule.c Log: Backport trunk checkin r51565: Fix SF bug #1545837: array.array borks on deepcopy. array.__deepcopy__() needs to take an argument, even if it doesn't actually use it. Modified: python/branches/release25-maint/Lib/test/test_array.py ============================================================================== --- python/branches/release25-maint/Lib/test/test_array.py (original) +++ python/branches/release25-maint/Lib/test/test_array.py Fri Dec 29 15:42:17 2006 @@ -85,6 +85,13 @@ self.assertNotEqual(id(a), id(b)) self.assertEqual(a, b) + def test_deepcopy(self): + import copy + a = array.array(self.typecode, self.example) + b = copy.deepcopy(a) + self.assertNotEqual(id(a), id(b)) + self.assertEqual(a, b) + def test_pickle(self): for protocol in (0, 1, 2): a = array.array(self.typecode, self.example) Modified: python/branches/release25-maint/Misc/ACKS ============================================================================== --- python/branches/release25-maint/Misc/ACKS (original) +++ python/branches/release25-maint/Misc/ACKS Fri Dec 29 15:42:17 2006 @@ -242,6 +242,7 @@ Michael Guravage Lars Gust?bel Barry Haddow +V?clav Haisman Paul ten Hagen Rasmus Hahn Peter Haight Modified: python/branches/release25-maint/Modules/arraymodule.c ============================================================================== --- python/branches/release25-maint/Modules/arraymodule.c (original) +++ python/branches/release25-maint/Modules/arraymodule.c Fri Dec 29 15:42:17 2006 @@ -1495,7 +1495,7 @@ copy_doc}, {"count", (PyCFunction)array_count, METH_O, count_doc}, - {"__deepcopy__",(PyCFunction)array_copy, METH_NOARGS, + {"__deepcopy__",(PyCFunction)array_copy, METH_O, copy_doc}, {"extend", (PyCFunction)array_extend, METH_O, extend_doc}, From python-checkins at python.org Fri Dec 29 18:33:16 2006 From: python-checkins at python.org (phillip.eby) Date: Fri, 29 Dec 2006 18:33:16 +0100 (CET) Subject: [Python-checkins] r53191 - in sandbox/trunk/setuptools: README.txt launcher.c setuptools/cli.exe setuptools/command/easy_install.py setuptools/gui.exe Message-ID: <20061229173316.8681D1E4005@bag.python.org> Author: phillip.eby Date: Fri Dec 29 18:33:14 2006 New Revision: 53191 Modified: sandbox/trunk/setuptools/README.txt sandbox/trunk/setuptools/launcher.c sandbox/trunk/setuptools/setuptools/cli.exe sandbox/trunk/setuptools/setuptools/command/easy_install.py sandbox/trunk/setuptools/setuptools/gui.exe Log: Overhaul Windows script wrappers to support bdist_wininst better. Scripts installed with bdist_wininst will always use #!python.exe or #!pythonw.exe as the executable name, and the wrappers will look for the executable in the script's parent directory. Since bdist_wininst scripts are installed to Python2X/Scripts, this will look for Python2X/python.exe. Scripts installed by easy_install, however, will still use an absolute executable path. Also fixed: some egg<->exe roundtripping issues, and script #! lines on Windows can now have an arbitrary number of arguments following the Python exe name, and the exe name is quoted if necessary, following the MS command line parsing rules. Modified: sandbox/trunk/setuptools/README.txt ============================================================================== --- sandbox/trunk/setuptools/README.txt (original) +++ sandbox/trunk/setuptools/README.txt Fri Dec 29 18:33:14 2006 @@ -14,7 +14,8 @@ Install setuptools using the provided ``.exe`` installer. If you've previously installed older versions of setuptools, please delete all ``setuptools*.egg`` -files from your system FIRST. +and ``setuptools.pth`` files from your system's ``site-packages`` directory +(and any other ``sys.path`` directories) FIRST. If you are upgrading a previous version of setuptools that was installed using an ``.exe`` installer, please be sure to also *uninstall that older version* @@ -23,9 +24,7 @@ Once installation is complete, you will find an ``easy_install.exe`` program in your Python ``Scripts`` subdirectory. Be sure to add this directory to your -``PATH`` environment variable, if you haven't already done so. You must also -have your Python installation directory (e.g. ``C:\\Python23``) on the -``PATH``. +``PATH`` environment variable, if you haven't already done so. RPM-Based Systems Modified: sandbox/trunk/setuptools/launcher.c ============================================================================== --- sandbox/trunk/setuptools/launcher.c (original) +++ sandbox/trunk/setuptools/launcher.c Fri Dec 29 18:33:14 2006 @@ -22,6 +22,7 @@ starting. So, we have to use spawnv() and wait for Python to exit before continuing. :( */ + #include #include #include @@ -29,20 +30,25 @@ #include "windows.h" int fail(char *format, char *data) { - /* Print error message to stderr and return 1 */ + /* Print error message to stderr and return 2 */ fprintf(stderr, format, data); return 2; } + + + + char *quoted(char *data) { - int i, l = strlen(data), nb; + int i, ln = strlen(data), nb; + /* We allocate twice as much space as needed to deal with worse-case of having to escape everything. */ - char *result = calloc(l*2+3, sizeof(char)); + char *result = calloc(ln*2+3, sizeof(char)); char *presult = result; *presult++ = '"'; - for (nb=0, i=0; i < l; i++) + for (nb=0, i=0; i < ln; i++) { if (data[i] == '\\') nb += 1; @@ -56,6 +62,7 @@ nb = 0; *presult++ = data[i]; } + for (; nb > 0; nb--) /* Deal w trailing slashes */ *presult++ = '\\'; @@ -64,49 +71,108 @@ return result; } -char *getpyopt(char *python) + + + + + + + + + +char *loadable_exe(char *exename) { + HINSTANCE hPython; /* DLL handle for python executable */ + char *result; + + hPython = LoadLibraryEx(exename, NULL, LOAD_WITH_ALTERED_SEARCH_PATH); + if (!hPython) return NULL; + + /* Return the absolute filename for spawnv */ + result = calloc(MAX_PATH, sizeof(char)); + if (result) GetModuleFileName(hPython, result, MAX_PATH); + + FreeLibrary(hPython); + return result; +} + + +char *find_exe(char *exename, char *script) { + char drive[_MAX_DRIVE], dir[_MAX_DIR], fname[_MAX_FNAME], ext[_MAX_EXT]; + char path[_MAX_PATH], c, *result; + + /* convert slashes to backslashes for uniform search below */ + result = exename; + while (c = *result++) if (c=='/') result[-1] = '\\'; + + _splitpath(exename, drive, dir, fname, ext); + if (drive[0] || dir[0]=='\\') { + return loadable_exe(exename); /* absolute path, use directly */ + } + /* Use the script's parent directory, which should be the Python home + (This should only be used for bdist_wininst-installed scripts, because + easy_install-ed scripts use the absolute path to python[w].exe + */ + _splitpath(script, drive, dir, fname, ext); + result = dir + strlen(dir) -1; + if (*result == '\\') result--; + while (*result != '\\' && result>=dir) *result-- = 0; + _makepath(path, drive, dir, exename, NULL); + return loadable_exe(path); +} + + +char **parse_argv(char *cmdline, int *argc) { - /* Search a Python command string, read from a #! line for an - option. An option must be separated from an executable name by - one or more spaces. An option consistes of a hyphen followed by - one or more letters. - */ - static char *letters = - "abcdefghijklmnopqrstuvwxyz" - "ABCDEFGHIJKLMNOPQRSTUVWXYZ" - ; - char *p = python + strlen(python) - 1; - if (strchr(letters, *p) == NULL) - return NULL; /* Path doen't end with a letter. Odd. */ - while (p > python && strchr(letters, *p) != NULL) - p--; - if (p == python || *p != '-') - return NULL; /* Can't be an option */ - p--; - if (p > python && isspace(*p)) - { /* BINGO, we have an option */ - char *pyopt = p+1; - /* strip trailing spaces from remainder of python command */ - while (p > python && isspace(*p)) - *p-- = '\0'; - return pyopt; - } - else - return NULL; + /* Parse a command line in-place using MS C rules */ + + char **result = calloc(strlen(cmdline), sizeof(char *)); + char *output = cmdline; + char c; + int nb = 0; + *argc = 0; + + result[0] = output; + while (isspace(*cmdline)) cmdline++; /* skip leading spaces */ + + do { + c = *cmdline++; + if (!c || isspace(c)) { + while (nb) {*output++ = '\\'; nb--; } + *output++ = 0; + result[++*argc] = output; + if (!c) return result; + while (isspace(*cmdline)) cmdline++; /* skip leading spaces */ + continue; + } + if (c == '\\') + ++nb; /* count \'s */ + else { + if (c == '"') { + if (!(nb & 1)) c = 0; /* skip " unless odd # of \ */ + nb = nb >> 1; /* cut \'s in half */ + } + while (nb) {*output++ = '\\'; nb--; } + if (c) *output++ = c; + } + } while (1); } + + + + + int run(int argc, char **argv, int is_gui) { char python[256]; /* python executable's filename*/ char *pyopt; /* Python option */ char script[256]; /* the script's filename */ - HINSTANCE hPython; /* DLL handle for python executable */ int scriptf; /* file descriptor for script file */ - char **newargs, **newargsp; /* argument array for exec */ + char **newargs, **newargsp, **parsedargs; /* argument array for exec */ char *ptr, *end; /* working pointers for string manipulation */ - int i; /* loop counter */ + int i, parsedargc; /* loop counter */ /* compute script name from our .exe name*/ GetModuleFileName(NULL, script, sizeof(script)); @@ -126,57 +192,51 @@ close(scriptf); ptr = python-1; - while(++ptr < end && *ptr && *ptr!='\n' && *ptr!='\r') { - if (*ptr=='/') - *ptr='\\'; /* convert slashes to avoid LoadLibrary crashes... */ - } + while(++ptr < end && *ptr && *ptr!='\n' && *ptr!='\r') {;} *ptr-- = '\0'; - while (ptr>python && isspace(*ptr)) *ptr-- = '\0'; /* strip trailing sp */ + if (strncmp(python, "#!", 2)) { /* default to python.exe if no #! header */ strcpy(python, "#!python.exe"); } - /* Check for Python options */ - pyopt = getpyopt(python); - - /* At this point, the python buffer contains "#!pythonfilename" */ + parsedargs = parse_argv(python+2, &parsedargc); /* Using spawnv() can fail strangely if you e.g. find the Cygwin Python, so we'll make sure Windows can find and load it */ - hPython = LoadLibraryEx(python+2, NULL, LOAD_WITH_ALTERED_SEARCH_PATH); - if (!hPython) { - return fail("Cannot find Python executable %s\n", python+2); + + ptr = find_exe(parsedargs[0], script); + if (!ptr) { + return fail("Cannot find Python executable %s\n", parsedargs[0]); } - /* And we'll use the absolute filename for spawnv */ - GetModuleFileName(hPython, python, sizeof(python)); + /* printf("Python executable: %s\n", ptr); */ - /* printf("Python executable: %s\n", python); */ + /* Argument array needs to be + parsedargc + argc, plus 1 for null sentinel */ - /* Argument array needs to be - argc+1 for python executable, - plus 1 for possible python opts, - plus 1 for null sentinel */ - newargs = (char **)calloc(argc+3, sizeof(char *)); + newargs = (char **)calloc(parsedargc + argc + 1, sizeof(char *)); newargsp = newargs; - *newargsp++ = quoted(python); - if (pyopt) - *newargsp++ = pyopt; + + *newargsp++ = quoted(ptr); + for (i = 1; iegg roundtripping self.install_wrapper_scripts(dist) - if self.exclude_scripts or not dist.metadata_isdir('scripts'): - return - - for script_name in dist.metadata_listdir('scripts'): - self.install_script( - dist, script_name, - dist.get_metadata('scripts/'+script_name).replace('\r','\n') - ) def add_output(self, path): if os.path.isdir(path): @@ -408,6 +407,7 @@ + def easy_install(self, spec, deps=False): tmpdir = tempfile.mkdtemp(prefix="easy_install-") download = None @@ -1407,7 +1407,6 @@ else: return path - def get_script_header(script_text, executable=sys_executable, wininst=False): """Create a #! line, getting options (if any) from script_text""" from distutils.command.build_scripts import first_line_re @@ -1418,8 +1417,10 @@ options = match.group(1) or '' if options: options = ' '+options - if wininst and sys.platform!='win32': + if wininst: executable = "python.exe" + else: + executable = nt_quote_arg(executable) hdr = "#!%(executable)s%(options)s\n" % locals() if unicode(hdr,'ascii','ignore').encode('ascii') != hdr: # Non-ascii path to sys.executable, use -x to prevent warnings @@ -1432,7 +1433,6 @@ hdr = "#!%(executable)s%(options)s\n" % locals() return hdr - def auto_chmod(func, arg, exc): if func is os.remove and os.name=='nt': os.chmod(arg, stat.S_IWRITE) @@ -1474,6 +1474,47 @@ +def nt_quote_arg(arg): + """Quote a command line argument according to Windows parsing rules""" + + result = [] + needquote = False + nb = 0 + + needquote = (" " in arg) or ("\t" in arg) + if needquote: + result.append('"') + + for c in arg: + if c == '\\': + nb += 1 + elif c == '"': + # double preceding backslashes, then add a \" + result.append('\\' * (nb*2) + '\\"') + nb = 0 + else: + if nb: + result.append('\\' * nb) + nb = 0 + result.append(c) + + if nb: + result.append('\\' * nb) + + if needquote: + result.append('\\' * nb) # double the trailing backslashes + result.append('"') + + return ''.join(result) + + + + + + + + + def is_python_script(script_text, filename): """Is this text, as a whole, a Python script? (as opposed to shell/bat/etc. """ @@ -1532,7 +1573,7 @@ ")\n" ) % locals() if sys.platform=='win32' or wininst: - # On Windows, add a .py extension and an .exe launcher + # On Windows/wininst, add a .py extension and an .exe launcher if group=='gui_scripts': ext, launcher = '-script.pyw', 'gui.exe' old = ['.pyw'] @@ -1540,9 +1581,9 @@ else: ext, launcher = '-script.py', 'cli.exe' old = ['.py','.pyc','.pyo'] - new_header = re.sub('(?i)pythonw.exe','pythonw.exe',header) + new_header = re.sub('(?i)pythonw.exe','python.exe',header) - if os.path.exists(new_header[2:-1]): + if os.path.exists(new_header[2:-1]) or sys.platform!='win32': hdr = new_header else: hdr = header Modified: sandbox/trunk/setuptools/setuptools/gui.exe ============================================================================== Binary files. No diff available. From python-checkins at python.org Fri Dec 29 18:33:33 2006 From: python-checkins at python.org (paul.dubois) Date: Fri, 29 Dec 2006 18:33:33 +0100 (CET) Subject: [Python-checkins] r53192 - tracker/instances/python-dev/detectors/busybody.py tracker/instances/python-dev/detectors/config.ini Message-ID: <20061229173333.5D3611E4005@bag.python.org> Author: paul.dubois Date: Fri Dec 29 18:33:32 2006 New Revision: 53192 Added: tracker/instances/python-dev/detectors/busybody.py Modified: tracker/instances/python-dev/detectors/config.ini Log: Add script to send email on EVERY change to an email list set in detectors/config.ini. Currently set to send mail to Dubois; change at deployment. Added: tracker/instances/python-dev/detectors/busybody.py ============================================================================== --- (empty file) +++ tracker/instances/python-dev/detectors/busybody.py Fri Dec 29 18:33:32 2006 @@ -0,0 +1,75 @@ +# +# Copyright (c) 2001 Bizar Software Pty Ltd (http://www.bizarsoftware.com.au/) +# This module is free software, and you may redistribute it and/or modify +# under the same terms as Python, so long as this copyright message and +# disclaimer are retained in their original form. +# +# IN NO EVENT SHALL BIZAR SOFTWARE PTY LTD BE LIABLE TO ANY PARTY FOR +# DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING +# OUT OF THE USE OF THIS CODE, EVEN IF THE AUTHOR HAS BEEN ADVISED OF THE +# POSSIBILITY OF SUCH DAMAGE. +# +# BIZAR SOFTWARE PTY LTD SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, +# BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS +# FOR A PARTICULAR PURPOSE. THE CODE PROVIDED HEREUNDER IS ON AN "AS IS" +# BASIS, AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE, +# SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. +# +# Modified from nosyreaction by P. Dubois to send mail to a busybody list +# that wants to know about EVERY change. + +import sets + +from roundup import roundupdb, hyperdb + +def busyreaction(db, cl, nodeid, oldvalues): + ''' busybody mail + ''' + try: + sendto = db.config.detectors['BUSYBODY_EMAIL'].split() + except KeyError: + return + + msgIDS = determineNewMessages(cl, nodeid, oldvalues) + if oldvalues is None: # a create + note = cl.generateCreateNote(nodeid) + else: + note = cl.generateChangeNote(nodeid, oldvalues) + + for msgid in msgIDS: + try: + cl.send_message(nodeid, msgid, note, sendto) + except roundupdb.MessageSendError, message: + raise roundupdb.DetectorError, message + if not msgIDS: + try: + cl.send_message(nodeid, None, note, sendto) + except roundupdb.MessageSendError, message: + raise roundupdb.DetectorError, message + + +def determineNewMessages(cl, nodeid, oldvalues): + ''' Figure a list of the messages that are being added to the given + node in this transaction. + ''' + messages = [] + if oldvalues is None: + # the action was a create, so use all the messages in the create + messages = cl.get(nodeid, 'messages') + elif oldvalues.has_key('messages'): + # the action was a set (so adding new messages to an existing issue) + m = {} + for msgid in oldvalues['messages']: + m[msgid] = 1 + messages = [] + # figure which of the messages now on the issue weren't there before + for msgid in cl.get(nodeid, 'messages'): + if not m.has_key(msgid): + messages.append(msgid) + return messages + +def init(db): + db.issue.react('create', busyreaction) + db.issue.react('set', busyreaction) + +# vim: set filetype=python ts=4 sw=4 et si Modified: tracker/instances/python-dev/detectors/config.ini ============================================================================== --- tracker/instances/python-dev/detectors/config.ini (original) +++ tracker/instances/python-dev/detectors/config.ini Fri Dec 29 18:33:32 2006 @@ -1,3 +1,5 @@ [main] triage_email = pfdubois at gmail.com +busybody_email=pfdubois at gmail.com + From python-checkins at python.org Fri Dec 29 18:41:03 2006 From: python-checkins at python.org (phillip.eby) Date: Fri, 29 Dec 2006 18:41:03 +0100 (CET) Subject: [Python-checkins] r53193 - sandbox/trunk/setuptools/setuptools/command/easy_install.py Message-ID: <20061229174103.66A901E4005@bag.python.org> Author: phillip.eby Date: Fri Dec 29 18:41:03 2006 New Revision: 53193 Modified: sandbox/trunk/setuptools/setuptools/command/easy_install.py Log: Whoops; dupes were already taken care of elsewhere. Modified: sandbox/trunk/setuptools/setuptools/command/easy_install.py ============================================================================== --- sandbox/trunk/setuptools/setuptools/command/easy_install.py (original) +++ sandbox/trunk/setuptools/setuptools/command/easy_install.py Fri Dec 29 18:41:03 2006 @@ -375,8 +375,6 @@ dist, script_name, dist.get_metadata('scripts/'+script_name).replace('\r','\n') ) - # we install wrapper scripts second, so they'll overwrite any dupes - # created as a result of exe<->egg roundtripping self.install_wrapper_scripts(dist) def add_output(self, path): @@ -408,6 +406,8 @@ + + def easy_install(self, spec, deps=False): tmpdir = tempfile.mkdtemp(prefix="easy_install-") download = None From python-checkins at python.org Fri Dec 29 18:43:40 2006 From: python-checkins at python.org (phillip.eby) Date: Fri, 29 Dec 2006 18:43:40 +0100 (CET) Subject: [Python-checkins] r53194 - in sandbox/branches/setuptools-0.6: README.txt launcher.c setuptools.txt setuptools/cli.exe setuptools/command/easy_install.py setuptools/gui.exe Message-ID: <20061229174340.C21C31E4005@bag.python.org> Author: phillip.eby Date: Fri Dec 29 18:43:39 2006 New Revision: 53194 Modified: sandbox/branches/setuptools-0.6/README.txt sandbox/branches/setuptools-0.6/launcher.c sandbox/branches/setuptools-0.6/setuptools.txt sandbox/branches/setuptools-0.6/setuptools/cli.exe sandbox/branches/setuptools-0.6/setuptools/command/easy_install.py sandbox/branches/setuptools-0.6/setuptools/gui.exe Log: Overhauled Windows script wrapping to support ``bdist_wininst`` better. Scripts installed with ``bdist_wininst`` will always use ``#!python.exe`` or ``#!pythonw.exe`` as the executable name (even when built on non-Windows platforms!), and the wrappers will look for the executable in the script's parent directory (which should find the right version of Python). (backport from trunk) Modified: sandbox/branches/setuptools-0.6/README.txt ============================================================================== --- sandbox/branches/setuptools-0.6/README.txt (original) +++ sandbox/branches/setuptools-0.6/README.txt Fri Dec 29 18:43:39 2006 @@ -14,7 +14,8 @@ Install setuptools using the provided ``.exe`` installer. If you've previously installed older versions of setuptools, please delete all ``setuptools*.egg`` -files from your system FIRST. +and ``setuptools.pth`` files from your system's ``site-packages`` directory +(and any other ``sys.path`` directories) FIRST. If you are upgrading a previous version of setuptools that was installed using an ``.exe`` installer, please be sure to also *uninstall that older version* @@ -23,9 +24,7 @@ Once installation is complete, you will find an ``easy_install.exe`` program in your Python ``Scripts`` subdirectory. Be sure to add this directory to your -``PATH`` environment variable, if you haven't already done so. You must also -have your Python installation directory (e.g. ``C:\\Python23``) on the -``PATH``. +``PATH`` environment variable, if you haven't already done so. RPM-Based Systems Modified: sandbox/branches/setuptools-0.6/launcher.c ============================================================================== --- sandbox/branches/setuptools-0.6/launcher.c (original) +++ sandbox/branches/setuptools-0.6/launcher.c Fri Dec 29 18:43:39 2006 @@ -22,6 +22,7 @@ starting. So, we have to use spawnv() and wait for Python to exit before continuing. :( */ + #include #include #include @@ -29,20 +30,25 @@ #include "windows.h" int fail(char *format, char *data) { - /* Print error message to stderr and return 1 */ + /* Print error message to stderr and return 2 */ fprintf(stderr, format, data); return 2; } + + + + char *quoted(char *data) { - int i, l = strlen(data), nb; + int i, ln = strlen(data), nb; + /* We allocate twice as much space as needed to deal with worse-case of having to escape everything. */ - char *result = calloc(l*2+3, sizeof(char)); + char *result = calloc(ln*2+3, sizeof(char)); char *presult = result; *presult++ = '"'; - for (nb=0, i=0; i < l; i++) + for (nb=0, i=0; i < ln; i++) { if (data[i] == '\\') nb += 1; @@ -56,6 +62,7 @@ nb = 0; *presult++ = data[i]; } + for (; nb > 0; nb--) /* Deal w trailing slashes */ *presult++ = '\\'; @@ -64,49 +71,108 @@ return result; } -char *getpyopt(char *python) + + + + + + + + + +char *loadable_exe(char *exename) { + HINSTANCE hPython; /* DLL handle for python executable */ + char *result; + + hPython = LoadLibraryEx(exename, NULL, LOAD_WITH_ALTERED_SEARCH_PATH); + if (!hPython) return NULL; + + /* Return the absolute filename for spawnv */ + result = calloc(MAX_PATH, sizeof(char)); + if (result) GetModuleFileName(hPython, result, MAX_PATH); + + FreeLibrary(hPython); + return result; +} + + +char *find_exe(char *exename, char *script) { + char drive[_MAX_DRIVE], dir[_MAX_DIR], fname[_MAX_FNAME], ext[_MAX_EXT]; + char path[_MAX_PATH], c, *result; + + /* convert slashes to backslashes for uniform search below */ + result = exename; + while (c = *result++) if (c=='/') result[-1] = '\\'; + + _splitpath(exename, drive, dir, fname, ext); + if (drive[0] || dir[0]=='\\') { + return loadable_exe(exename); /* absolute path, use directly */ + } + /* Use the script's parent directory, which should be the Python home + (This should only be used for bdist_wininst-installed scripts, because + easy_install-ed scripts use the absolute path to python[w].exe + */ + _splitpath(script, drive, dir, fname, ext); + result = dir + strlen(dir) -1; + if (*result == '\\') result--; + while (*result != '\\' && result>=dir) *result-- = 0; + _makepath(path, drive, dir, exename, NULL); + return loadable_exe(path); +} + + +char **parse_argv(char *cmdline, int *argc) { - /* Search a Python command string, read from a #! line for an - option. An option must be separated from an executable name by - one or more spaces. An option consistes of a hyphen followed by - one or more letters. - */ - static char *letters = - "abcdefghijklmnopqrstuvwxyz" - "ABCDEFGHIJKLMNOPQRSTUVWXYZ" - ; - char *p = python + strlen(python) - 1; - if (strchr(letters, *p) == NULL) - return NULL; /* Path doen't end with a letter. Odd. */ - while (p > python && strchr(letters, *p) != NULL) - p--; - if (p == python || *p != '-') - return NULL; /* Can't be an option */ - p--; - if (p > python && isspace(*p)) - { /* BINGO, we have an option */ - char *pyopt = p+1; - /* strip trailing spaces from remainder of python command */ - while (p > python && isspace(*p)) - *p-- = '\0'; - return pyopt; - } - else - return NULL; + /* Parse a command line in-place using MS C rules */ + + char **result = calloc(strlen(cmdline), sizeof(char *)); + char *output = cmdline; + char c; + int nb = 0; + *argc = 0; + + result[0] = output; + while (isspace(*cmdline)) cmdline++; /* skip leading spaces */ + + do { + c = *cmdline++; + if (!c || isspace(c)) { + while (nb) {*output++ = '\\'; nb--; } + *output++ = 0; + result[++*argc] = output; + if (!c) return result; + while (isspace(*cmdline)) cmdline++; /* skip leading spaces */ + continue; + } + if (c == '\\') + ++nb; /* count \'s */ + else { + if (c == '"') { + if (!(nb & 1)) c = 0; /* skip " unless odd # of \ */ + nb = nb >> 1; /* cut \'s in half */ + } + while (nb) {*output++ = '\\'; nb--; } + if (c) *output++ = c; + } + } while (1); } + + + + + int run(int argc, char **argv, int is_gui) { char python[256]; /* python executable's filename*/ char *pyopt; /* Python option */ char script[256]; /* the script's filename */ - HINSTANCE hPython; /* DLL handle for python executable */ int scriptf; /* file descriptor for script file */ - char **newargs, **newargsp; /* argument array for exec */ + char **newargs, **newargsp, **parsedargs; /* argument array for exec */ char *ptr, *end; /* working pointers for string manipulation */ - int i; /* loop counter */ + int i, parsedargc; /* loop counter */ /* compute script name from our .exe name*/ GetModuleFileName(NULL, script, sizeof(script)); @@ -126,57 +192,51 @@ close(scriptf); ptr = python-1; - while(++ptr < end && *ptr && *ptr!='\n' && *ptr!='\r') { - if (*ptr=='/') - *ptr='\\'; /* convert slashes to avoid LoadLibrary crashes... */ - } + while(++ptr < end && *ptr && *ptr!='\n' && *ptr!='\r') {;} *ptr-- = '\0'; - while (ptr>python && isspace(*ptr)) *ptr-- = '\0'; /* strip trailing sp */ + if (strncmp(python, "#!", 2)) { /* default to python.exe if no #! header */ strcpy(python, "#!python.exe"); } - /* Check for Python options */ - pyopt = getpyopt(python); - - /* At this point, the python buffer contains "#!pythonfilename" */ + parsedargs = parse_argv(python+2, &parsedargc); /* Using spawnv() can fail strangely if you e.g. find the Cygwin Python, so we'll make sure Windows can find and load it */ - hPython = LoadLibraryEx(python+2, NULL, LOAD_WITH_ALTERED_SEARCH_PATH); - if (!hPython) { - return fail("Cannot find Python executable %s\n", python+2); + + ptr = find_exe(parsedargs[0], script); + if (!ptr) { + return fail("Cannot find Python executable %s\n", parsedargs[0]); } - /* And we'll use the absolute filename for spawnv */ - GetModuleFileName(hPython, python, sizeof(python)); + /* printf("Python executable: %s\n", ptr); */ - /* printf("Python executable: %s\n", python); */ + /* Argument array needs to be + parsedargc + argc, plus 1 for null sentinel */ - /* Argument array needs to be - argc+1 for python executable, - plus 1 for possible python opts, - plus 1 for null sentinel */ - newargs = (char **)calloc(argc+3, sizeof(char *)); + newargs = (char **)calloc(parsedargc + argc + 1, sizeof(char *)); newargsp = newargs; - *newargsp++ = quoted(python); - if (pyopt) - *newargsp++ = pyopt; + + *newargsp++ = quoted(ptr); + for (i = 1; i Author: phillip.eby Date: Fri Dec 29 18:50:25 2006 New Revision: 53195 Modified: sandbox/trunk/setuptools/setup.py sandbox/trunk/setuptools/setuptools/command/easy_install.py Log: Switch default package-index to cheeseshop.python.org, and make setuptools' home page its cheeseshop page. Modified: sandbox/trunk/setuptools/setup.py ============================================================================== --- sandbox/trunk/setuptools/setup.py (original) +++ sandbox/trunk/setuptools/setup.py Fri Dec 29 18:50:25 2006 @@ -27,7 +27,7 @@ license="PSF or ZPL", long_description = open('README.txt').read(), keywords = "CPAN PyPI distutils eggs package management", - url = "http://peak.telecommunity.com/DevCenter/setuptools", + url = "http://cheeseshop.python.org/pypi/setuptools", test_suite = 'setuptools.tests', packages = find_packages(), package_data = {'setuptools':['*.exe','site-patch.py']}, Modified: sandbox/trunk/setuptools/setuptools/command/easy_install.py ============================================================================== --- sandbox/trunk/setuptools/setuptools/command/easy_install.py (original) +++ sandbox/trunk/setuptools/setuptools/command/easy_install.py Fri Dec 29 18:50:25 2006 @@ -156,7 +156,7 @@ else: self.all_site_dirs.append(normalize_path(d)) if not self.editable: self.check_site_dir() - self.index_url = self.index_url or "http://www.python.org/pypi" + self.index_url = self.index_url or "http://cheeseshop.python.org/pypi" self.shadow_path = self.all_site_dirs[:] for path_item in self.install_dir, normalize_path(self.script_dir): if path_item not in self.shadow_path: From python-checkins at python.org Fri Dec 29 18:51:28 2006 From: python-checkins at python.org (phillip.eby) Date: Fri, 29 Dec 2006 18:51:28 +0100 (CET) Subject: [Python-checkins] r53196 - in sandbox/branches/setuptools-0.6: setup.py setuptools/command/easy_install.py Message-ID: <20061229175128.5E4771E400D@bag.python.org> Author: phillip.eby Date: Fri Dec 29 18:51:27 2006 New Revision: 53196 Modified: sandbox/branches/setuptools-0.6/setup.py sandbox/branches/setuptools-0.6/setuptools/command/easy_install.py Log: Switch default package-index to cheeseshop.python.org, and make setuptools' home page its cheeseshop page. (backport from trunk) Modified: sandbox/branches/setuptools-0.6/setup.py ============================================================================== --- sandbox/branches/setuptools-0.6/setup.py (original) +++ sandbox/branches/setuptools-0.6/setup.py Fri Dec 29 18:51:27 2006 @@ -23,7 +23,7 @@ license="PSF or ZPL", long_description = open('README.txt').read(), keywords = "CPAN PyPI distutils eggs package management", - url = "http://peak.telecommunity.com/DevCenter/setuptools", + url = "http://cheeseshop.python.org/pypi/setuptools", test_suite = 'setuptools.tests', packages = find_packages(), package_data = {'setuptools':['*.exe']}, Modified: sandbox/branches/setuptools-0.6/setuptools/command/easy_install.py ============================================================================== --- sandbox/branches/setuptools-0.6/setuptools/command/easy_install.py (original) +++ sandbox/branches/setuptools-0.6/setuptools/command/easy_install.py Fri Dec 29 18:51:27 2006 @@ -156,7 +156,7 @@ else: self.all_site_dirs.append(normalize_path(d)) if not self.editable: self.check_site_dir() - self.index_url = self.index_url or "http://www.python.org/pypi" + self.index_url = self.index_url or "http://cheeseshop.python.org/pypi" self.shadow_path = self.all_site_dirs[:] for path_item in self.install_dir, normalize_path(self.script_dir): if path_item not in self.shadow_path: From python-checkins at python.org Fri Dec 29 19:49:14 2006 From: python-checkins at python.org (raymond.hettinger) Date: Fri, 29 Dec 2006 19:49:14 +0100 (CET) Subject: [Python-checkins] r53197 - in python/branches/release25-maint: Lib/test/test_set.py Misc/NEWS Objects/setobject.c Message-ID: <20061229184914.2EF911E4005@bag.python.org> Author: raymond.hettinger Date: Fri Dec 29 19:49:13 2006 New Revision: 53197 Modified: python/branches/release25-maint/Lib/test/test_set.py python/branches/release25-maint/Misc/NEWS python/branches/release25-maint/Objects/setobject.c Log: For sets with cyclical reprs, emit '...' instead of recursing. Modified: python/branches/release25-maint/Lib/test/test_set.py ============================================================================== --- python/branches/release25-maint/Lib/test/test_set.py (original) +++ python/branches/release25-maint/Lib/test/test_set.py Fri Dec 29 19:49:13 2006 @@ -21,6 +21,11 @@ def __cmp__(self, other): raise RuntimeError +class ReprWrapper: + 'Used to test self-referential repr() calls' + def __repr__(self): + return repr(self.value) + class TestJointOps(unittest.TestCase): # Tests common to both set and frozenset @@ -244,6 +249,27 @@ self.assertRaises(RuntimeError, s.discard, BadCmp()) self.assertRaises(RuntimeError, s.remove, BadCmp()) + def test_cyclical_repr(self): + w = ReprWrapper() + s = self.thetype([w]) + w.value = s + name = repr(s).partition('(')[0] # strip class name from repr string + self.assertEqual(repr(s), '%s([%s(...)])' % (name, name)) + + def test_cyclical_print(self): + w = ReprWrapper() + s = self.thetype([w]) + w.value = s + try: + fo = open(test_support.TESTFN, "wb") + print >> fo, s, + fo.close() + fo = open(test_support.TESTFN, "rb") + self.assertEqual(fo.read(), repr(s)) + finally: + fo.close() + os.remove(test_support.TESTFN) + class TestSet(TestJointOps): thetype = set Modified: python/branches/release25-maint/Misc/NEWS ============================================================================== --- python/branches/release25-maint/Misc/NEWS (original) +++ python/branches/release25-maint/Misc/NEWS Fri Dec 29 19:49:13 2006 @@ -18,6 +18,9 @@ custom ``__eq__()`` method to confuse set internals when class instances were used as a set's elements and the ``__eq__()`` method mutated the set. +- The repr for self-referential sets and fronzensets now shows "..." instead + of falling into infinite recursion. + - Eliminated unnecessary repeated calls to hash() by set.intersection() and set.symmetric_difference_update(). Modified: python/branches/release25-maint/Objects/setobject.c ============================================================================== --- python/branches/release25-maint/Objects/setobject.c (original) +++ python/branches/release25-maint/Objects/setobject.c Fri Dec 29 19:49:13 2006 @@ -572,34 +572,54 @@ Py_ssize_t pos=0; char *emit = ""; /* No separator emitted on first pass */ char *separator = ", "; + int status = Py_ReprEnter((PyObject*)so); + + if (status != 0) { + if (status < 0) + return status; + fprintf(fp, "%s(...)", so->ob_type->tp_name); + return 0; + } fprintf(fp, "%s([", so->ob_type->tp_name); while (set_next(so, &pos, &entry)) { fputs(emit, fp); emit = separator; - if (PyObject_Print(entry->key, fp, 0) != 0) + if (PyObject_Print(entry->key, fp, 0) != 0) { + Py_ReprLeave((PyObject*)so); return -1; + } } fputs("])", fp); + Py_ReprLeave((PyObject*)so); return 0; } static PyObject * set_repr(PySetObject *so) { - PyObject *keys, *result, *listrepr; + PyObject *keys, *result=NULL, *listrepr; + int status = Py_ReprEnter((PyObject*)so); + + if (status != 0) { + if (status < 0) + return NULL; + return PyString_FromFormat("%s(...)", so->ob_type->tp_name); + } keys = PySequence_List((PyObject *)so); if (keys == NULL) - return NULL; + goto done; listrepr = PyObject_Repr(keys); Py_DECREF(keys); if (listrepr == NULL) - return NULL; + goto done; result = PyString_FromFormat("%s(%s)", so->ob_type->tp_name, PyString_AS_STRING(listrepr)); Py_DECREF(listrepr); +done: + Py_ReprLeave((PyObject*)so); return result; } From jackdied at jackdied.com Fri Dec 29 21:01:56 2006 From: jackdied at jackdied.com (Jack Diederich) Date: Fri, 29 Dec 2006 15:01:56 -0500 Subject: [Python-checkins] r53190 - in python/branches/release25-maint: Lib/test/test_array.py Misc/ACKS Modules/arraymodule.c In-Reply-To: <20061229144217.DFCAE1E4005@bag.python.org> References: <20061229144217.DFCAE1E4005@bag.python.org> Message-ID: <20061229200156.GC5359@performancedrivers.com> Is there a policy for ACKS? I rarely see people touch it so I've just left it alone. On Fri, Dec 29, 2006 at 03:42:17PM +0100, thomas.wouters wrote: > Author: thomas.wouters > Date: Fri Dec 29 15:42:17 2006 > New Revision: 53190 > > Modified: > python/branches/release25-maint/Lib/test/test_array.py > python/branches/release25-maint/Misc/ACKS > python/branches/release25-maint/Modules/arraymodule.c > Log: > > Backport trunk checkin r51565: > > Fix SF bug #1545837: array.array borks on deepcopy. array.__deepcopy__() > needs to take an argument, even if it doesn't actually use it. > [snip] > Modified: python/branches/release25-maint/Misc/ACKS > ============================================================================== > --- python/branches/release25-maint/Misc/ACKS (original) > +++ python/branches/release25-maint/Misc/ACKS Fri Dec 29 15:42:17 2006 > @@ -242,6 +242,7 @@ > Michael Guravage > Lars Gust?bel > Barry Haddow > +V?clav Haisman > Paul ten Hagen > Rasmus Hahn > Peter Haight > From nnorwitz at gmail.com Fri Dec 29 22:27:41 2006 From: nnorwitz at gmail.com (Neal Norwitz) Date: Fri, 29 Dec 2006 13:27:41 -0800 Subject: [Python-checkins] r53190 - in python/branches/release25-maint: Lib/test/test_array.py Misc/ACKS Modules/arraymodule.c In-Reply-To: <20061229200156.GC5359@performancedrivers.com> References: <20061229144217.DFCAE1E4005@bag.python.org> <20061229200156.GC5359@performancedrivers.com> Message-ID: On 12/29/06, Jack Diederich wrote: > Is there a policy for ACKS? I rarely see people touch it so I've just > left it alone. Not exactly. I try to check the name if I don't recognize it and the OP provides a moderate size patch or equivalent. Moderate to me is generally at least 20 lines or so. 'Equivalent' could be if they suggest wording for doc, but not an actual patch. We should try to keep ACKs up to date. n From martin at v.loewis.de Fri Dec 29 22:41:24 2006 From: martin at v.loewis.de (=?ISO-8859-1?Q?=22Martin_v=2E_L=F6wis=22?=) Date: Fri, 29 Dec 2006 22:41:24 +0100 Subject: [Python-checkins] [Python-Dev] r53110 - python/trunk/Lib/mailbox.py In-Reply-To: <200612230159.08151.fdrake@acm.org> References: <20061220194820.ED8DD1E4008@bag.python.org> <20061221135343.GA5855@localhost.localdomain> <458AED2E.5080709@v.loewis.de> <200612230159.08151.fdrake@acm.org> Message-ID: <45958B84.60501@v.loewis.de> Fred L. Drake, Jr. schrieb: > Speaking strictly for myself: I don't think I *have* to use them, but I do > prefer to use them because I don't like magic constants that affect what a > function does in code; I'd rather have a named constant for readability's > sake. Maybe I just can't keep enough in my head, but I don't find I actually > use seek() enough to remember what the numeric values mean with checking the > reference documentation. But you *can* remember the symbolic names (plus you can remember what module they are in, in what Python version)? I'd have to consult the documentation for either; help(file.seek) gives the numeric values. Regards, Martin From guido at python.org Fri Dec 29 22:55:43 2006 From: guido at python.org (Guido van Rossum) Date: Fri, 29 Dec 2006 13:55:43 -0800 Subject: [Python-checkins] [Python-Dev] r53110 - python/trunk/Lib/mailbox.py In-Reply-To: <45958B84.60501@v.loewis.de> References: <20061220194820.ED8DD1E4008@bag.python.org> <20061221135343.GA5855@localhost.localdomain> <458AED2E.5080709@v.loewis.de> <200612230159.08151.fdrake@acm.org> <45958B84.60501@v.loewis.de> Message-ID: On 12/29/06, "Martin v. L?wis" wrote: > Fred L. Drake, Jr. schrieb: > > Speaking strictly for myself: I don't think I *have* to use them, but I do > > prefer to use them because I don't like magic constants that affect what a > > function does in code; I'd rather have a named constant for readability's > > sake. Maybe I just can't keep enough in my head, but I don't find I actually > > use seek() enough to remember what the numeric values mean with checking the > > reference documentation. > > But you *can* remember the symbolic names (plus you can remember what > module they are in, in what Python version)? I'd have to consult the > documentation for either; help(file.seek) gives the numeric values. I'm with Martin here. But my main objection to suggesting that these constants ought to be used is that open() is a built-in but you would have to import os to be able to call the seek method on the object it returns. If we want to make the seek API more 21st century, why not use keyword arguments? -- --Guido van Rossum (home page: http://www.python.org/~guido/) From fdrake at acm.org Fri Dec 29 23:03:22 2006 From: fdrake at acm.org (Fred L. Drake, Jr.) Date: Fri, 29 Dec 2006 17:03:22 -0500 Subject: [Python-checkins] [Python-Dev] r53110 - python/trunk/Lib/mailbox.py In-Reply-To: References: <20061220194820.ED8DD1E4008@bag.python.org> <45958B84.60501@v.loewis.de> Message-ID: <200612291703.22535.fdrake@acm.org> On Friday 29 December 2006 16:55, Guido van Rossum wrote: > If we want to make the seek API more 21st century, why not use keyword > arguments? I'd prefer that myself. I'm not advocating the constants as a way to go forward, but was simply expressing a preference for the named constant over a magic number in code. -Fred -- Fred L. Drake, Jr. From barry at python.org Fri Dec 29 23:05:34 2006 From: barry at python.org (Barry Warsaw) Date: Fri, 29 Dec 2006 17:05:34 -0500 Subject: [Python-checkins] [Python-Dev] r53110 - python/trunk/Lib/mailbox.py In-Reply-To: References: <20061220194820.ED8DD1E4008@bag.python.org> <20061221135343.GA5855@localhost.localdomain> <458AED2E.5080709@v.loewis.de> <200612230159.08151.fdrake@acm.org> <45958B84.60501@v.loewis.de> Message-ID: -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 On Dec 29, 2006, at 4:55 PM, Guido van Rossum wrote: > But my main objection to suggesting that these constants ought to be > used is that open() is a built-in but you would have to import os to > be able to call the seek method on the object it returns. > > If we want to make the seek API more 21st century, why not use keyword > arguments? Or put the constants on class attributes. - -Barry -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.5 (Darwin) iQCVAwUBRZWRM3EjvBPtnXfVAQLWdwQAmrt5ncAhFIxCK2Tm72g90P9qckVrkdAt odvZ+fw8RFrKs3MUpsP2HtfHWHrouC6SHQCXoU63msfgy52vO4M9rG3NLN5Hi0KK tU4J9pkSqqi+Jfu4LvCs+ouURqxTbGicyMBUuw54hQWqg0bxvYvjEyuC1NFltcV6 HJ2qElSTOw0= =LAq1 -----END PGP SIGNATURE----- From martin at v.loewis.de Fri Dec 29 23:38:53 2006 From: martin at v.loewis.de (=?ISO-8859-1?Q?=22Martin_v=2E_L=F6wis=22?=) Date: Fri, 29 Dec 2006 23:38:53 +0100 Subject: [Python-checkins] r53190 - in python/branches/release25-maint: Lib/test/test_array.py Misc/ACKS Modules/arraymodule.c In-Reply-To: <20061229200156.GC5359@performancedrivers.com> References: <20061229144217.DFCAE1E4005@bag.python.org> <20061229200156.GC5359@performancedrivers.com> Message-ID: <459598FD.4060902@v.loewis.de> Jack Diederich schrieb: > Is there a policy for ACKS? I rarely see people touch it so I've just > left it alone. I think the agreement is that "significant" contributions should be acknowledged; obvious fixes for bugs, typos etc. don't need to. What a significant contributions is determines the committer; I usually add people with their second contribution (unless I find the first one already deserves listing in ACKS - the contribution can be traced, of course, to the SF tracker to find out who the submitter was). Regards, Martin From python-checkins at python.org Sat Dec 30 04:06:09 2006 From: python-checkins at python.org (phillip.eby) Date: Sat, 30 Dec 2006 04:06:09 +0100 (CET) Subject: [Python-checkins] r53198 - sandbox/trunk/setuptools/setuptools/sandbox.py Message-ID: <20061230030609.8F8F91E4005@bag.python.org> Author: phillip.eby Date: Sat Dec 30 04:06:09 2006 New Revision: 53198 Modified: sandbox/trunk/setuptools/setuptools/sandbox.py Log: Fix os.open() sandboxing code that refused anything but read-only access. Modified: sandbox/trunk/setuptools/setuptools/sandbox.py ============================================================================== --- sandbox/trunk/setuptools/setuptools/sandbox.py (original) +++ sandbox/trunk/setuptools/setuptools/sandbox.py Sat Dec 30 04:06:09 2006 @@ -189,8 +189,8 @@ def open(self, file, flags, mode=0777): """Called for low-level os.open()""" - if flags & WRITE_FLAGS: - self._violation("open", file, flags, mode) + if flags & WRITE_FLAGS and not self._ok(file): + self._violation("os.open", file, flags, mode) return _os.open(file,flags,mode) From python-checkins at python.org Sat Dec 30 04:06:57 2006 From: python-checkins at python.org (phillip.eby) Date: Sat, 30 Dec 2006 04:06:57 +0100 (CET) Subject: [Python-checkins] r53199 - sandbox/branches/setuptools-0.6/setuptools/sandbox.py Message-ID: <20061230030657.EEB281E4005@bag.python.org> Author: phillip.eby Date: Sat Dec 30 04:06:57 2006 New Revision: 53199 Modified: sandbox/branches/setuptools-0.6/setuptools/sandbox.py Log: Fix os.open() sandboxing code that refused anything but read-only access. (backport from trunk) Modified: sandbox/branches/setuptools-0.6/setuptools/sandbox.py ============================================================================== --- sandbox/branches/setuptools-0.6/setuptools/sandbox.py (original) +++ sandbox/branches/setuptools-0.6/setuptools/sandbox.py Sat Dec 30 04:06:57 2006 @@ -189,8 +189,8 @@ def open(self, file, flags, mode=0777): """Called for low-level os.open()""" - if flags & WRITE_FLAGS: - self._violation("open", file, flags, mode) + if flags & WRITE_FLAGS and not self._ok(file): + self._violation("os.open", file, flags, mode) return _os.open(file,flags,mode) From python-checkins at python.org Sat Dec 30 05:01:18 2006 From: python-checkins at python.org (raymond.hettinger) Date: Sat, 30 Dec 2006 05:01:18 +0100 (CET) Subject: [Python-checkins] r53200 - in python/trunk: Lib/test/test_set.py Objects/setobject.c Message-ID: <20061230040118.33CFB1E4005@bag.python.org> Author: raymond.hettinger Date: Sat Dec 30 05:01:17 2006 New Revision: 53200 Modified: python/trunk/Lib/test/test_set.py python/trunk/Objects/setobject.c Log: For sets with cyclical reprs, emit an ellipsis instead of infinitely recursing. Modified: python/trunk/Lib/test/test_set.py ============================================================================== --- python/trunk/Lib/test/test_set.py (original) +++ python/trunk/Lib/test/test_set.py Sat Dec 30 05:01:17 2006 @@ -21,6 +21,11 @@ def __cmp__(self, other): raise RuntimeError +class ReprWrapper: + 'Used to test self-referential repr() calls' + def __repr__(self): + return repr(self.value) + class TestJointOps(unittest.TestCase): # Tests common to both set and frozenset @@ -244,6 +249,27 @@ self.assertRaises(RuntimeError, s.discard, BadCmp()) self.assertRaises(RuntimeError, s.remove, BadCmp()) + def test_cyclical_repr(self): + w = ReprWrapper() + s = self.thetype([w]) + w.value = s + name = repr(s).partition('(')[0] # strip class name from repr string + self.assertEqual(repr(s), '%s([%s(...)])' % (name, name)) + + def test_cyclical_print(self): + w = ReprWrapper() + s = self.thetype([w]) + w.value = s + try: + fo = open(test_support.TESTFN, "wb") + print >> fo, s, + fo.close() + fo = open(test_support.TESTFN, "rb") + self.assertEqual(fo.read(), repr(s)) + finally: + fo.close() + os.remove(test_support.TESTFN) + class TestSet(TestJointOps): thetype = set Modified: python/trunk/Objects/setobject.c ============================================================================== --- python/trunk/Objects/setobject.c (original) +++ python/trunk/Objects/setobject.c Sat Dec 30 05:01:17 2006 @@ -572,34 +572,54 @@ Py_ssize_t pos=0; char *emit = ""; /* No separator emitted on first pass */ char *separator = ", "; + int status = Py_ReprEnter((PyObject*)so); + + if (status != 0) { + if (status < 0) + return status; + fprintf(fp, "%s(...)", so->ob_type->tp_name); + return 0; + } fprintf(fp, "%s([", so->ob_type->tp_name); while (set_next(so, &pos, &entry)) { fputs(emit, fp); emit = separator; - if (PyObject_Print(entry->key, fp, 0) != 0) + if (PyObject_Print(entry->key, fp, 0) != 0) { + Py_ReprLeave((PyObject*)so); return -1; + } } fputs("])", fp); + Py_ReprLeave((PyObject*)so); return 0; } static PyObject * set_repr(PySetObject *so) { - PyObject *keys, *result, *listrepr; + PyObject *keys, *result=NULL, *listrepr; + int status = Py_ReprEnter((PyObject*)so); + + if (status != 0) { + if (status < 0) + return NULL; + return PyString_FromFormat("%s(...)", so->ob_type->tp_name); + } keys = PySequence_List((PyObject *)so); if (keys == NULL) - return NULL; + goto done; listrepr = PyObject_Repr(keys); Py_DECREF(keys); if (listrepr == NULL) - return NULL; + goto done; result = PyString_FromFormat("%s(%s)", so->ob_type->tp_name, PyString_AS_STRING(listrepr)); Py_DECREF(listrepr); +done: + Py_ReprLeave((PyObject*)so); return result; } From python-checkins at python.org Sat Dec 30 07:17:06 2006 From: python-checkins at python.org (brett.cannon) Date: Sat, 30 Dec 2006 07:17:06 +0100 (CET) Subject: [Python-checkins] r53201 - peps/trunk/pep-0362.txt Message-ID: <20061230061706.1C19D1E4005@bag.python.org> Author: brett.cannon Date: Sat Dec 30 07:17:05 2006 New Revision: 53201 Modified: peps/trunk/pep-0362.txt Log: Add mention of PEP 3107. Also clean up grammar and typos. Finally, add some open issues to work out. Modified: peps/trunk/pep-0362.txt ============================================================================== --- peps/trunk/pep-0362.txt (original) +++ peps/trunk/pep-0362.txt Sat Dec 30 07:17:05 2006 @@ -17,10 +17,10 @@ Python has always supported powerful introspection capabilities, including that for functions and methods (for the rest of this PEP the word "function" refers to both functions and methods). Taking a -function object, you can fully reconstruct the function signature +function object, you can fully reconstruct the function's signature using ``func_defaults``, ``func_code.co_argcount``, ``func_code.co_flags``, and ``func_code.co_varnames``. Unfortunately -this is a little unruly having to look at four different attributes +it is a little unruly having to look at four different attributes to pull together complete information for a function's signature. This PEP proposes an object representation for function signatures. @@ -34,9 +34,9 @@ ================ The overall signature of an object is represented by the Signature -object. This object is to store Parameter objects (discussed later) -along with any information about the function itself and any -parameters that are highly unique (.e.g, ``*args``). +object. This object is to store a `Parameter Object`_ for each +parameter in the signature. It is also to store any information +about the function itself that is pertinent to the signature. A Signature object has the following structure attributes: @@ -46,26 +46,24 @@ contained within. This makes functions and methods indistinguishable from one another when passed to decorators, preventing proper creation of a fully qualified name. - indistinguishable from * var_args:str - Name of the ``*args`` parameter, if present, else the empty + Name of the ``*args`` parameter, if present, or the empty string. * var_kw_args:str - Name of the ``**kwargs`` parameter, if present, else the empty + Name of the ``**kwargs`` parameter, if present, or the empty string. * parameters:list(Parameter) - List of the parameters of the function are represented by - Parameter objects (see `Parameter Object`_ for their - description). + List of the parameters of the function as represented by + Parameter objects (see `Parameter Object`_). * __str__() -> str Return the string representation of the signature as it might appear in source code. * bind(\*args, \*\*kwargs) -> dict - Create a mapping from parameter to argument for the signature (see - `Open Issues`_ for question of how to handle tuples). + Create a mapping from parameter to argument for the signature. The Signature object is stored in the ``__signature__`` attribute of -the function. When it is to be created is an `Open Issues`_. +the function. When it is to be created is discussed in +`Open Issues`_. Parameter Object @@ -122,10 +120,10 @@ way if the argument can be unpacked. -Relation With Other PEPs -======================== +Relation To Other PEPs +====================== -"Keyword-Only Arguments [#pep-3102]_ +Keyword-Only Arguments [#pep-3102]_ ------------------------------------ If keyword-only parameters come into existence, the Parameter object @@ -139,7 +137,26 @@ attribute that are in no way compatible. It also removes the ability to know the position number within the signature from the Paramter object itself. Plus Guido preferred the original approach over this -alternative. +alternative. This does mean, though, that how to set the position of +an argument when ``*args`` is not at the end of the parameter list. + + +Function Annotations [#pep-3107]_ +---------------------------------- + +Support needs to be added for function annotations. One option is to +have two new attributes for each Parameter object: ``has_annotation`` +and ``annotation``. This would remove any possible ambiguity in +terms of what an annotation could be. + +But one could argue that the chances of someone setting an annotation +to ``None`` is very low and thus allows it to be used as a value +for a single ``annotation`` attribute to signify that no annotation +was set. But there is the slight issue of breaking from consistency +compared to ``has_default``/``default_value``. + +Regardless of which approach is taken, Signature objects will also +need to gain support for annotations for ``*args`` and ``**kwargs``. Open Issues @@ -177,6 +194,28 @@ that the binding could not be calculated with full confidence. +How should ``Signature.bind`` handle ``*args`` and ``**kwargs``? +------------------------------------------------------------------ + +There are two possible approaches to how ``*args`` and ``**kwargs`` +should be returned by ``Signature.bind``. One is to have their +names as keys in the dictionary and their values be the list and +dictionary that would be created. Another is to have ``bind`` +return a three-item tuple of the parameters and their values, what +the ``*args`` value would be bound to, and a dict of what +``**kwargs`` would be set to. + + +Should ``Signature.bind`` return Parameter objects as keys? +----------------------------------------------------------- + +Instead of returning a dict with keys consisting of the name of the +parameters, would it be more useful to instead return Parameter +objects? The name of the argument can easily be retrieved. It also +removes any need of having to map parameter name to the Parameter +object if that is desired. + + References ========== @@ -189,6 +228,9 @@ .. [#impl] Implementation of PEP 362 (http://www.python.org/sf/1544909) +.. [#pep-3107] Function Annotations + (http://www.python.org/dev/peps/pep-3107/) + Copyright ========= From python-checkins at python.org Sat Dec 30 17:03:14 2006 From: python-checkins at python.org (phillip.eby) Date: Sat, 30 Dec 2006 17:03:14 +0100 (CET) Subject: [Python-checkins] r53202 - sandbox/trunk/setuptools/setuptools/package_index.py Message-ID: <20061230160314.B71E41E4002@bag.python.org> Author: phillip.eby Date: Sat Dec 30 17:03:14 2006 New Revision: 53202 Modified: sandbox/trunk/setuptools/setuptools/package_index.py Log: Add Basic Auth support for http URLs with embedded credentials. If an authenticated page contains links to the same protocol and host, those links should inherit the same credentials. Modified: sandbox/trunk/setuptools/setuptools/package_index.py ============================================================================== --- sandbox/trunk/setuptools/setuptools/package_index.py (original) +++ sandbox/trunk/setuptools/setuptools/package_index.py Sat Dec 30 17:03:14 2006 @@ -576,9 +576,7 @@ if url.startswith('file:'): return local_open(url) try: - request = urllib2.Request(url) - request.add_header('User-Agent', user_agent) - return urllib2.urlopen(request) + return open_with_auth(url) except urllib2.HTTPError, v: return v except urllib2.URLError, v: @@ -613,6 +611,8 @@ def scan_url(self, url): self.process_url(url, True) + + def _attempt_download(self, url, filename): headers = self._download_to(url, filename) if 'html' in headers['content-type'].lower(): @@ -654,6 +654,47 @@ +def open_with_auth(url): + """Open a urllib2 request, handling HTTP authentication""" + + scheme, netloc, path, params, query, frag = urlparse.urlparse(url) + + if scheme in ('http', 'https'): + auth, host = urllib2.splituser(netloc) + else: + auth = None + + if auth: + auth = "Basic " + urllib2.unquote(auth).encode('base64').strip() + new_url = urlparse.urlunparse((scheme,host,path,params,query,frag)) + request = urllib2.Request(new_url) + request.add_header("Authorization", auth) + else: + request = urllib2.Request(url) + + request.add_header('User-Agent', user_agent) + fp = urllib2.urlopen(request) + + if auth: + # Put authentication info back into request URL if same host, + # so that links found on the page will work + s2, h2, path2, param2, query2, frag2 = urlparse.urlparse(fp.url) + if s2==scheme and h2==host: + fp.url = urlparse.urlunparse((s2,netloc,path2,param2,query2,frag2)) + + return fp + + + + + + + + + + + + def fix_sf_url(url): return url # backward compatibility From python-checkins at python.org Sat Dec 30 17:05:41 2006 From: python-checkins at python.org (phillip.eby) Date: Sat, 30 Dec 2006 17:05:41 +0100 (CET) Subject: [Python-checkins] r53203 - in sandbox/branches/setuptools-0.6: EasyInstall.txt setuptools/package_index.py Message-ID: <20061230160541.A10781E4002@bag.python.org> Author: phillip.eby Date: Sat Dec 30 17:05:41 2006 New Revision: 53203 Modified: sandbox/branches/setuptools-0.6/EasyInstall.txt sandbox/branches/setuptools-0.6/setuptools/package_index.py Log: Add Basic Auth support for http URLs with embedded credentials. If an authenticated page contains links to the same protocol and host, those links should inherit the same credentials. (backport from trunk) Modified: sandbox/branches/setuptools-0.6/EasyInstall.txt ============================================================================== --- sandbox/branches/setuptools-0.6/EasyInstall.txt (original) +++ sandbox/branches/setuptools-0.6/EasyInstall.txt Sat Dec 30 17:05:41 2006 @@ -1195,6 +1195,11 @@ ============================ 0.6c4 + * Added support for HTTP "Basic" authentication using ``http://user:pass at host`` + URLs. If a password-protected page contains links to the same host (and + protocol), those links will inherit the credentials used to access the + original page. + * Removed all special support for Sourceforge mirrors, as Sourceforge's mirror system now works well for non-browser downloads. Modified: sandbox/branches/setuptools-0.6/setuptools/package_index.py ============================================================================== --- sandbox/branches/setuptools-0.6/setuptools/package_index.py (original) +++ sandbox/branches/setuptools-0.6/setuptools/package_index.py Sat Dec 30 17:05:41 2006 @@ -576,9 +576,7 @@ if url.startswith('file:'): return local_open(url) try: - request = urllib2.Request(url) - request.add_header('User-Agent', user_agent) - return urllib2.urlopen(request) + return open_with_auth(url) except urllib2.HTTPError, v: return v except urllib2.URLError, v: @@ -613,6 +611,8 @@ def scan_url(self, url): self.process_url(url, True) + + def _attempt_download(self, url, filename): headers = self._download_to(url, filename) if 'html' in headers['content-type'].lower(): @@ -654,6 +654,47 @@ +def open_with_auth(url): + """Open a urllib2 request, handling HTTP authentication""" + + scheme, netloc, path, params, query, frag = urlparse.urlparse(url) + + if scheme in ('http', 'https'): + auth, host = urllib2.splituser(netloc) + else: + auth = None + + if auth: + auth = "Basic " + urllib2.unquote(auth).encode('base64').strip() + new_url = urlparse.urlunparse((scheme,host,path,params,query,frag)) + request = urllib2.Request(new_url) + request.add_header("Authorization", auth) + else: + request = urllib2.Request(url) + + request.add_header('User-Agent', user_agent) + fp = urllib2.urlopen(request) + + if auth: + # Put authentication info back into request URL if same host, + # so that links found on the page will work + s2, h2, path2, param2, query2, frag2 = urlparse.urlparse(fp.url) + if s2==scheme and h2==host: + fp.url = urlparse.urlunparse((s2,netloc,path2,param2,query2,frag2)) + + return fp + + + + + + + + + + + + def fix_sf_url(url): return url # backward compatibility