]> granicus.if.org Git - python/commitdiff
Merged revisions 64623,64640,64665,64687,64689-64690,64719,64721,64735,64742,64744...
authorGeorg Brandl <georg@python.org>
Wed, 16 Jul 2008 03:43:04 +0000 (03:43 +0000)
committerGeorg Brandl <georg@python.org>
Wed, 16 Jul 2008 03:43:04 +0000 (03:43 +0000)
svn+ssh://pythondev@svn.python.org/python/trunk

........
  r64623 | benjamin.peterson | 2008-07-01 21:51:54 +0200 (Tue, 01 Jul 2008) | 1 line

  write a short little section for multiprocessing; it still needs help
........
  r64640 | georg.brandl | 2008-07-01 22:56:03 +0200 (Tue, 01 Jul 2008) | 2 lines

  Add a comment about incref'ing w.
........
  r64665 | jesse.noller | 2008-07-02 18:56:51 +0200 (Wed, 02 Jul 2008) | 1 line

  Add #!/usr/bin/env python for ben
........
  r64687 | andrew.kuchling | 2008-07-03 14:50:03 +0200 (Thu, 03 Jul 2008) | 1 line

  Tweak wording
........
  r64689 | benjamin.peterson | 2008-07-03 14:57:35 +0200 (Thu, 03 Jul 2008) | 1 line

  lowercase glossary term
........
  r64690 | benjamin.peterson | 2008-07-03 15:01:17 +0200 (Thu, 03 Jul 2008) | 1 line

  let the term be linked
........
  r64719 | raymond.hettinger | 2008-07-05 04:11:55 +0200 (Sat, 05 Jul 2008) | 1 line

  Update comment on prediction macros.
........
  r64721 | georg.brandl | 2008-07-05 12:07:18 +0200 (Sat, 05 Jul 2008) | 2 lines

  Fix tabs.
........
  r64735 | mark.dickinson | 2008-07-05 17:25:48 +0200 (Sat, 05 Jul 2008) | 3 lines

  Minor rewrite of cmath_log to work around a Sun compiler bug.  See issue
  #3168.
........
  r64742 | benjamin.peterson | 2008-07-05 18:29:38 +0200 (Sat, 05 Jul 2008) | 1 line

  make regrtest aware of the lib2to3 resource
........
  r64744 | georg.brandl | 2008-07-05 18:43:45 +0200 (Sat, 05 Jul 2008) | 2 lines

  Keep below 80 chars.
........
  r64745 | facundo.batista | 2008-07-05 21:19:50 +0200 (Sat, 05 Jul 2008) | 3 lines

  Issue 3289.  Removed two lines that ended doing nothing.
........
  r64746 | facundo.batista | 2008-07-05 22:39:59 +0200 (Sat, 05 Jul 2008) | 4 lines

  Issue #3239. Differentiate the ascii call from the curses one and
  the builtin one.
........
  r64756 | gregory.p.smith | 2008-07-06 09:16:40 +0200 (Sun, 06 Jul 2008) | 3 lines

  - Issue #2113: Fix error in subprocess.Popen if the select system call is
    interrupted by a signal.
........
  r64757 | benjamin.peterson | 2008-07-06 14:39:09 +0200 (Sun, 06 Jul 2008) | 1 line

  remove test_compact_freelists from test_sys
........
  r64758 | gregory.p.smith | 2008-07-06 19:06:29 +0200 (Sun, 06 Jul 2008) | 2 lines

  fix issue3304 - remove an incorrect PyMem_Free in fileio_init
........
  r64759 | georg.brandl | 2008-07-06 19:36:20 +0200 (Sun, 06 Jul 2008) | 2 lines

  Fix opensearch template.
........
  r64760 | andrew.kuchling | 2008-07-06 19:43:16 +0200 (Sun, 06 Jul 2008) | 1 line

  Wording fix
........
  r64761 | andrew.kuchling | 2008-07-06 19:44:17 +0200 (Sun, 06 Jul 2008) | 1 line

  Add two items; rewrap paragraph
........
  r64767 | gregory.p.smith | 2008-07-07 06:31:58 +0200 (Mon, 07 Jul 2008) | 4 lines

  - Issue #3309: Fix bz2.BZFile itererator to release its internal lock
    properly when raising an exception due to the bz2file being closed.
    Prevents a deadlock.
........
  r64768 | josiah.carlson | 2008-07-07 06:51:46 +0200 (Mon, 07 Jul 2008) | 2 lines

  Fixed bugs 760475, 953599, and 1519.
........
  r64769 | gregory.p.smith | 2008-07-07 06:54:31 +0200 (Mon, 07 Jul 2008) | 2 lines

  Add commented out #_sha256 and #_sha512 lines per issue 3183.
........
  r64771 | gregory.p.smith | 2008-07-07 07:09:12 +0200 (Mon, 07 Jul 2008) | 4 lines

  - Issue #3094: httplib.HTTPSConnection Host: headers no longer include the
    redundant ":443" port number designation when the connection is using the
    default https port (443).
........
  r64772 | skip.montanaro | 2008-07-07 13:16:14 +0200 (Mon, 07 Jul 2008) | 2 lines

  Correct grammar.
........
  r64774 | andrew.kuchling | 2008-07-07 18:51:09 +0200 (Mon, 07 Jul 2008) | 1 line

  Fix example to match text
........
  r64775 | facundo.batista | 2008-07-07 19:02:59 +0200 (Mon, 07 Jul 2008) | 3 lines

  Issue 3306. Better control for a lenght in findmax() function.
........
  r64788 | georg.brandl | 2008-07-08 09:05:23 +0200 (Tue, 08 Jul 2008) | 2 lines

  Add missing ABCs to list.
........
  r64793 | nick.coghlan | 2008-07-08 16:21:42 +0200 (Tue, 08 Jul 2008) | 1 line

  Add missing NEWS and ACK entries for r64791
........
  r64835 | raymond.hettinger | 2008-07-10 11:31:08 +0200 (Thu, 10 Jul 2008) | 1 line

  Issue 3287: Raise correct exception for float inputs.
........
  r64836 | raymond.hettinger | 2008-07-10 12:28:41 +0200 (Thu, 10 Jul 2008) | 1 line

  Use operator.index() instead of n.__index__().
........

27 files changed:
Doc/glossary.rst
Doc/library/abc.rst
Doc/library/collections.rst
Doc/library/shutil.rst
Doc/library/stdtypes.rst
Doc/tools/sphinxext/opensearch.xml
Doc/whatsnew/2.6.rst
Lib/curses/textpad.py
Lib/fractions.py
Lib/http/client.py
Lib/subprocess.py
Lib/test/regrtest.py
Lib/test/test_audioop.py
Lib/test/test_bz2.py
Lib/test/test_fractions.py
Lib/test/test_multiprocessing.py
Lib/test/test_sys.py
Misc/ACKS
Modules/Setup.dist
Modules/_fileio.c
Modules/audioop.c
Modules/bz2module.c
Modules/cmathmodule.c
Modules/timemodule.c
Objects/abstract.c
Python/ceval.c
Python/pythonrun.c

index f7a4b569b39f147ee95ae4345a925354734055e3..a2e9b0213e1405f7f05923145cb4461a22bb7832 100644 (file)
@@ -16,7 +16,7 @@ Glossary
       The typical Python prompt of the interactive shell when entering code for
       an indented code block.
 
-   Abstract Base Class
+   abstract base class
       Abstract Base Classes (abbreviated ABCs) complement :term:`duck-typing` by
       providing a way to define interfaces when other techniques like :func:`hasattr`
       would be clumsy. Python comes with many builtin ABCs for data structures
index 21d3018a737c4b650637dcdb001a7bf6de1d0aa2..b03fc83a70e03a85ba9c3f61600d5f05b7f3967c 100644 (file)
@@ -8,8 +8,8 @@
 .. sectionauthor:: Georg Brandl
 .. much of the content adapted from docstrings
 
-This module provides the infrastructure for defining :term:`abstract base
-classes` (ABCs) in Python, as outlined in :pep:`3119`; see the PEP for why this
+This module provides the infrastructure for defining an :term:`abstract base
+class` (ABCs) in Python, as outlined in :pep:`3119`; see the PEP for why this
 was added to Python. (See also :pep:`3141` and the :mod:`numbers` module
 regarding a type hierarchy for numbers based on ABCs.)
 
index 7718c5121d0abd7b97f4015454d098cf729c6b4d..d2d4f4750fcd5dfa72db81cb7d409ba31af60f85 100644 (file)
@@ -37,42 +37,50 @@ ABCs - abstract base classes
 
 The collections module offers the following ABCs:
 
-=========================  ====================  ======================  ====================================================
-ABC                        Inherits              Abstract Methods        Mixin Methods
-=========================  ====================  ======================  ====================================================
-:class:`Container`                               ``__contains__``
-:class:`Hashable`                                ``__hash__``
-:class:`Iterable`                                ``__iter__``
-:class:`Iterator`          :class:`Iterable`     ``__next__``            ``__iter__``
-:class:`Sized`                                  ``__len__``
-
-:class:`Mapping`           :class:`Sized`,       ``__getitem__``,        ``__contains__``, ``keys``, ``items``, ``values``,
-                           :class:`Iterable`,    ``__len__``. and        ``get``, ``__eq__``, and ``__ne__``
-                           :class:`Container`    ``__iter__``
-
-:class:`MutableMapping`    :class:`Mapping`      ``__getitem__``         Inherited Mapping methods and
-                                                 ``__setitem__``,        ``pop``, ``popitem``, ``clear``, ``update``,
-                                                 ``__delitem__``,        and ``setdefault``
-                                                ``__iter__``, and
-                                                 ``__len__``
-
-:class:`Sequence`          :class:`Sized`,       ``__getitem__``         ``__contains__``. ``__iter__``, ``__reversed__``.
-                           :class:`Iterable`,    and ``__len__``         ``index``, and ``count``
-                           :class:`Container`
-
-:class:`MutableSequnce`    :class:`Sequence`     ``__getitem__``         Inherited Sequence methods and
-                                                 ``__delitem__``,        ``append``, ``reverse``, ``extend``, ``pop``,
-                                                 ``insert``,             ``remove``, and ``__iadd__``
-                                                 and ``__len__``
-
-:class:`Set`               :class:`Sized`,       ``__len__``,            ``__le__``, ``__lt__``, ``__eq__``, ``__ne__``,
-                           :class:`Iterable`,    ``__iter__``, and       ``__gt__``, ``__ge__``, ``__and__``, ``__or__``
-                           :class:`Container`    ``__contains__``        ``__sub__``, ``__xor__``, and ``isdisjoint``
-
-:class:`MutableSet`        :class:`Set`          ``add`` and             Inherited Set methods and
-                                                 ``discard``             ``clear``, ``pop``, ``remove``, ``__ior__``,
-                                                                         ``__iand__``, ``__ixor__``, and ``__isub__``
-=========================  ====================  ======================  ====================================================
+=========================  =====================  ======================  ====================================================
+ABC                        Inherits               Abstract Methods        Mixin Methods
+=========================  =====================  ======================  ====================================================
+:class:`Container`                                ``__contains__``
+:class:`Hashable`                                 ``__hash__``
+:class:`Iterable`                                 ``__iter__``
+:class:`Iterator`          :class:`Iterable`      ``__next__``            ``__iter__``
+:class:`Sized`                                   ``__len__``
+:class:`Callable`                                 ``__call__``
+                                                  
+:class:`Sequence`          :class:`Sized`,        ``__getitem__``         ``__contains__``. ``__iter__``, ``__reversed__``.
+                           :class:`Iterable`,     and ``__len__``         ``index``, and ``count``
+                           :class:`Container`     
+                                                  
+:class:`MutableSequnce`    :class:`Sequence`      ``__getitem__``         Inherited Sequence methods and
+                                                  ``__delitem__``,        ``append``, ``reverse``, ``extend``, ``pop``,
+                                                  ``insert``,             ``remove``, and ``__iadd__``
+                                                  and ``__len__``
+                                                  
+:class:`Set`               :class:`Sized`,        ``__len__``,            ``__le__``, ``__lt__``, ``__eq__``, ``__ne__``,
+                           :class:`Iterable`,     ``__iter__``, and       ``__gt__``, ``__ge__``, ``__and__``, ``__or__``
+                           :class:`Container`     ``__contains__``        ``__sub__``, ``__xor__``, and ``isdisjoint``
+                                                  
+:class:`MutableSet`        :class:`Set`           ``add`` and             Inherited Set methods and
+                                                  ``discard``             ``clear``, ``pop``, ``remove``, ``__ior__``,
+                                                                          ``__iand__``, ``__ixor__``, and ``__isub__``
+                                                  
+:class:`Mapping`           :class:`Sized`,        ``__getitem__``,        ``__contains__``, ``keys``, ``items``, ``values``,
+                           :class:`Iterable`,     ``__len__``. and        ``get``, ``__eq__``, and ``__ne__``
+                           :class:`Container`     ``__iter__``
+                                                  
+:class:`MutableMapping`    :class:`Mapping`       ``__getitem__``         Inherited Mapping methods and
+                                                  ``__setitem__``,        ``pop``, ``popitem``, ``clear``, ``update``,
+                                                  ``__delitem__``,        and ``setdefault``
+                                                 ``__iter__``, and
+                                                  ``__len__``
+                                                  
+:class:`MappingView`       :class:`Sized`                                 ``__len__``
+:class:`KeysView`          :class:`MappingView`,                          ``__contains__``,
+                           :class:`Set`                                   ``__iter__``
+:class:`ItemsView`         :class:`MappingView`,                          ``__contains__``,
+                           :class:`Set`                                   ``__iter__``
+:class:`ValuesView`        :class:`MappingView`                           ``__contains__``, ``__iter__``
+=========================  =====================  ======================  ====================================================
 
 These ABCs allow us to ask classes or instances if they provide
 particular functionality, for example::
index 5ab2f29ef16a38ae482ca4490d9cd2850d088091..c295f290f5eb3c4aa92af4599aaf02f8e0bde069 100644 (file)
@@ -78,18 +78,39 @@ copying and removal. For operations on individual files, see also the
    Unix command :program:`cp -p`.
 
 
-.. function:: copytree(src, dst[, symlinks])
+.. function:: ignore_patterns(\*patterns)
+
+   This factory function creates a function that can be used as a callable for
+   :func:`copytree`\'s *ignore* argument, ignoring files and directories that
+   match one of the glob-style *patterns* provided.  See the example below.
+
+
+.. function:: copytree(src, dst[, symlinks=False[, ignore=None]])
 
    Recursively copy an entire directory tree rooted at *src*.  The destination
-   directory, named by *dst*, must not already exist; it will be created as well as
-   missing parent directories. Permissions and times of directories are copied with
-   :func:`copystat`, individual files are copied using :func:`copy2`.   If
-   *symlinks* is true, symbolic links in the source tree are represented as
-   symbolic links in the new tree; if false or omitted, the contents of the linked
-   files are copied to the new tree.  If exception(s) occur, an :exc:`Error` is
-   raised with a list of reasons.
-
-   The source code for this should be considered an example rather than a tool.
+   directory, named by *dst*, must not already exist; it will be created as well
+   as missing parent directories.  Permissions and times of directories are
+   copied with :func:`copystat`, individual files are copied using
+   :func:`copy2`.
+
+   If *symlinks* is true, symbolic links in the source tree are represented as
+   symbolic links in the new tree; if false or omitted, the contents of the
+   linked files are copied to the new tree.
+
+   If *ignore* is given, it must be a callable that will receive as its
+   arguments the directory being visited by :func:`copytree`, and a list of its
+   contents, as returned by :func:`os.listdir`.  Since :func:`copytree` is
+   called recursively, the *ignore* callable will be called once for each
+   directory that is copied.  The callable must return a sequence of directory
+   and file names relative to the current directory (i.e. a subset of the items
+   in its second argument); these names will then be ignored in the copy
+   process.  :func:`ignore_patterns` can be used to create such a callable that
+   ignores names based on glob-style patterns.
+
+   If exception(s) occur, an :exc:`Error` is raised with a list of reasons.
+
+   The source code for this should be considered an example rather than the
+   ultimate tool.
 
 
 .. function:: rmtree(path[, ignore_errors[, onerror]])
index 9107d0359d0deff57b251264d45ec95f0aa2e2a0..a97a5195fa824bffc0e68b064622cb1c18c10391 100644 (file)
@@ -2027,7 +2027,7 @@ Files have the following methods:
    files, like ttys, it makes sense to continue reading after an EOF is hit.)  Note
    that this method may call the underlying C function :cfunc:`fread` more than
    once in an effort to acquire as close to *size* bytes as possible. Also note
-   that when in non-blocking mode, less data than what was requested may be
+   that when in non-blocking mode, less data than was requested may be
    returned, even if no *size* parameter was given.
 
 
index d672c2e2b8c6c903b6eae09fad230779f4451a27..69cec804cd0e90b0fff6369534b806d4f6a2536f 100644 (file)
@@ -1,14 +1,4 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<OpenSearchDescription xmlns="http://a9.com/-/spec/opensearch/1.1/">
-  <ShortName>Python Docs</ShortName>
-  <LongName>Python Documentation</LongName>
-  <Description>Search the Python documentation</Description>
-  <InputEncoding>utf-8</InputEncoding>
-  <Url type="text/html" method="get" template="{{ pathto('search') }}?">
-    <Param name="q" value="{searchTerms}" />
-    <Param name="check_keywords" value="yes" />
-    <Param name="area" value="default" />
-  </Url>
-  <Image height="16" width="16" type="image/x-icon">http://www.python.org/images/favicon16x16.ico</Image>
-</OpenSearchDescription>
-
+{% extends "!opensearch.xml" %}
+{% block extra -%}
+<Image height="16" width="16" type="image/x-icon">http://www.python.org/images/favicon16x16.ico</Image>
+{%- endblock %}
index 21ccf9b891df3f30999b2a217db9d8c74195d211..df5ccb68b206e3000edad49f649ceb6626897f5d 100644 (file)
@@ -1681,6 +1681,11 @@ details.
   available, instead of restricting itself to protocol 1.
   (Contributed by W. Barnes; :issue:`1551443`.)
 
+* The :mod:`cgi` module will now read variables from the query string of an 
+  HTTP POST request.  This makes it possible to use form actions with 
+  URLs such as "/cgi-bin/add.py?category=1".  (Contributed by 
+  Alexandre Fiori and Nubis; :issue:`1817`.)
+
 * The :mod:`cmath` module underwent an extensive set of revisions,
   thanks to Mark Dickinson and Christian Heimes, that added some new
   features and greatly improved the accuracy of the computations.
@@ -2137,6 +2142,24 @@ details.
 * The :mod:`sets` module has been deprecated; it's better to
   use the built-in :class:`set` and :class:`frozenset` types.
 
+* The :func:`shutil.copytree` function now has an optional **ignore** argument
+  that takes a callable object.  This callable will receive each directory path
+  and a list of the directory's contents, and returns a list of names that
+  will be ignored, not copied.  
+
+  The :mod:`shutil` module also provides an :func:`ignore_patterns`
+  function for use with this new parameter.
+  :func:`ignore_patterns` takes an arbitrary number of glob-style patterns
+  and will ignore any files and directories that match this pattern.
+  The following example copies a directory tree, but skip both SVN's internal
+  :file:`.svn` directories and Emacs backup 
+  files, which have names ending with '~'::
+
+      shutil.copytree('Doc/library', '/tmp/library', 
+                      ignore=shutil.ignore_patterns('*~', '.svn'))
+
+  (Contributed by Tarek Ziadé; :issue:`2663`.)
+
 * Integrating signal handling with GUI handling event loops
   like those used by Tkinter or GTk+ has long been a problem; most
   software ends up polling, waking up every fraction of a second.
@@ -2500,9 +2523,10 @@ handle it safely::
       ...
     ValueError: malformed string
 
-The module also includes 
-:class:`NodeVisitor` and :class:`NodeTransformer` classes 
-for traversing and modifying an AST, and functions for common transformations such as changing line numbers.
+The module also includes :class:`NodeVisitor` and
+:class:`NodeTransformer` classes for traversing and modifying an AST,
+and functions for common transformations such as changing line
+numbers.
 
 .. ======================================================================
 
index a05b82bdb6ef1fc69da73846b79031efcdeff5ec..2b4b4cb669f53523b2db42bbb629e91c551ba3be 100644 (file)
@@ -1,6 +1,7 @@
 """Simple textbox editing widget with Emacs-like keybindings."""
 
-import curses, ascii
+import curses
+import curses.ascii
 
 def rectangle(win, uly, ulx, lry, lrx):
     """Draw a rectangle with corners at the provided upper-left
@@ -54,7 +55,7 @@ class Textbox:
         returning the index of the last non-blank character."""
         last = self.maxx
         while True:
-            if ascii.ascii(self.win.inch(y, last)) != ascii.SP:
+            if curses.ascii.ascii(self.win.inch(y, last)) != curses.ascii.SP:
                 last = min(self.maxx, last+1)
                 break
             elif last == 0:
@@ -76,7 +77,7 @@ class Textbox:
                 pass
             if self.insert_mode:
                 (backy, backx) = self.win.getyx()
-                if ascii.isprint(oldch):
+                if curses.ascii.isprint(oldch):
                     self._insert_printable_char(oldch)
                     self.win.move(backy, backx)
 
@@ -84,12 +85,12 @@ class Textbox:
         "Process a single editing command."
         (y, x) = self.win.getyx()
         self.lastcmd = ch
-        if ascii.isprint(ch):
+        if curses.ascii.isprint(ch):
             if y < self.maxy or x < self.maxx:
                 self._insert_printable_char(ch)
-        elif ch == ascii.SOH:                           # ^a
+        elif ch == curses.ascii.SOH:                           # ^a
             self.win.move(y, 0)
-        elif ch in (ascii.STX,curses.KEY_LEFT, ascii.BS,curses.KEY_BACKSPACE):
+        elif ch in (curses.ascii.STX,curses.KEY_LEFT, curses.ascii.BS,curses.KEY_BACKSPACE):
             if x > 0:
                 self.win.move(y, x-1)
             elif y == 0:
@@ -98,46 +99,46 @@ class Textbox:
                 self.win.move(y-1, self._end_of_line(y-1))
             else:
                 self.win.move(y-1, self.maxx)
-            if ch in (ascii.BS, curses.KEY_BACKSPACE):
+            if ch in (curses.ascii.BS, curses.KEY_BACKSPACE):
                 self.win.delch()
-        elif ch == ascii.EOT:                           # ^d
+        elif ch == curses.ascii.EOT:                           # ^d
             self.win.delch()
-        elif ch == ascii.ENQ:                           # ^e
+        elif ch == curses.ascii.ENQ:                           # ^e
             if self.stripspaces:
                 self.win.move(y, self._end_of_line(y))
             else:
                 self.win.move(y, self.maxx)
-        elif ch in (ascii.ACK, curses.KEY_RIGHT):       # ^f
+        elif ch in (curses.ascii.ACK, curses.KEY_RIGHT):       # ^f
             if x < self.maxx:
                 self.win.move(y, x+1)
             elif y == self.maxy:
                 pass
             else:
                 self.win.move(y+1, 0)
-        elif ch == ascii.BEL:                           # ^g
+        elif ch == curses.ascii.BEL:                           # ^g
             return 0
-        elif ch == ascii.NL:                            # ^j
+        elif ch == curses.ascii.NL:                            # ^j
             if self.maxy == 0:
                 return 0
             elif y < self.maxy:
                 self.win.move(y+1, 0)
-        elif ch == ascii.VT:                            # ^k
+        elif ch == curses.ascii.VT:                            # ^k
             if x == 0 and self._end_of_line(y) == 0:
                 self.win.deleteln()
             else:
                 # first undo the effect of self._end_of_line
                 self.win.move(y, x)
                 self.win.clrtoeol()
-        elif ch == ascii.FF:                            # ^l
+        elif ch == curses.ascii.FF:                            # ^l
             self.win.refresh()
-        elif ch in (ascii.SO, curses.KEY_DOWN):         # ^n
+        elif ch in (curses.ascii.SO, curses.KEY_DOWN):         # ^n
             if y < self.maxy:
                 self.win.move(y+1, x)
                 if x > self._end_of_line(y+1):
                     self.win.move(y+1, self._end_of_line(y+1))
-        elif ch == ascii.SI:                            # ^o
+        elif ch == curses.ascii.SI:                            # ^o
             self.win.insertln()
-        elif ch in (ascii.DLE, curses.KEY_UP):          # ^p
+        elif ch in (curses.ascii.DLE, curses.KEY_UP):          # ^p
             if y > 0:
                 self.win.move(y-1, x)
                 if x > self._end_of_line(y-1):
@@ -155,7 +156,7 @@ class Textbox:
             for x in range(self.maxx+1):
                 if self.stripspaces and x > stop:
                     break
-                result = result + chr(ascii.ascii(self.win.inch(y, x)))
+                result = result + chr(curses.ascii.ascii(self.win.inch(y, x)))
             if self.maxy > 0:
                 result = result + "\n"
         return result
index 329a16fa847f06dfca439bffa8e1bd0e4ad05826..3df628adc0b98fadcc3e7b2c899e644ea588ad12 100755 (executable)
@@ -94,9 +94,8 @@ class Fraction(numbers.Rational):
 
         if denominator == 0:
             raise ZeroDivisionError('Fraction(%s, 0)' % numerator)
-
-        numerator = numerator.__index__()
-        denominator = denominator.__index__()
+        numerator = operator.index(numerator)
+        denominator = operator.index(denominator)
         g = gcd(numerator, denominator)
         self._numerator = numerator // g
         self._denominator = denominator // g
index 96bcd72a9325a31372b6d078be7184d8b5f24944..4a078d388830ec2c668ec6335e325316e4b1499d 100644 (file)
@@ -783,7 +783,7 @@ class HTTPConnection:
                         host_enc = self.host.encode("ascii")
                     except UnicodeEncodeError:
                         host_enc = self.host.encode("idna")
-                    if self.port == HTTP_PORT:
+                    if self.port == self.default_port:
                         self.putheader('Host', host_enc)
                     else:
                         host_enc = host_enc.decode("ascii")
index 8df10344cbc9acaf7aee396e97e5bb769582a417..e94fc2c6fff203f6294947280e75bea1d7e1a0d5 100644 (file)
@@ -1149,7 +1149,12 @@ class Popen(object):
 
             input_offset = 0
             while read_set or write_set:
-                rlist, wlist, xlist = select.select(read_set, write_set, [])
+                try:
+                    rlist, wlist, xlist = select.select(read_set, write_set, [])
+                except select.error as e:
+                    if e.args[0] == errno.EINTR:
+                        continue
+                    raise
 
                 # XXX Rewrite these to use non-blocking I/O on the
                 # file objects; they are no longer using C stdio!
index d523d5b4e0420b80043f59f6636eb2446a588348..d47fde38e83f08485b8ce23d7aa53d6b7abe57f7 100755 (executable)
@@ -101,6 +101,8 @@ resources to test.  Currently only the following are defined:
     curses -    Tests that use curses and will modify the terminal's
                 state and output modes.
 
+    lib2to3 -   Run the tests for 2to3 (They take a while.)
+
     largefile - It is okay to run some test that may create huge
                 files.  These tests can take a long time and may
                 consume >2GB of disk space temporarily.
@@ -173,8 +175,8 @@ if sys.platform == 'darwin':
 
 from test import support
 
-RESOURCE_NAMES = ('audio', 'curses', 'largefile', 'network', 'bsddb',
-                  'decimal', 'compiler', 'subprocess', 'urlfetch')
+RESOURCE_NAMES = ('audio', 'curses', 'lib2to3', 'largefile', 'network',
+                  'bsddb', 'decimal', 'compiler', 'subprocess', 'urlfetch')
 
 
 def usage(msg):
index d43159a299b2c614665969645e59ffaec5cbac8b..689b0de7de71f9a8bfb17ab408fb754100ef3160 100644 (file)
@@ -163,6 +163,10 @@ class TestAudioop(unittest.TestCase):
             self.assertEqual(audioop.getsample(data[1], 2, i), i)
             self.assertEqual(audioop.getsample(data[2], 4, i), i)
 
+    def test_negavitelen(self):
+        # from issue 3306, previously it segfaulted
+        self.assertRaises(audioop.error,
+            audioop.findmax, ''.join(chr(x) for x in range(256)), -2392392)
 
 def test_main():
     run_unittest(TestAudioop)
index 4646f02ac1655e8c5268f5b09373eb6b00a02407..366ab7a16fe3f26e2f9f78836466f1b38485f57f 100644 (file)
@@ -120,6 +120,17 @@ class BZ2FileTest(BaseTest):
         self.assertEqual(list(iter(bz2f)), sio.readlines())
         bz2f.close()
 
+    def testClosedIteratorDeadlock(self):
+        # "Test that iteration on a closed bz2file releases the lock."
+        # http://bugs.python.org/issue3309
+        self.createTempFile()
+        bz2f = BZ2File(self.filename)
+        bz2f.close()
+        self.assertRaises(ValueError, bz2f.__next__)
+        # This call will deadlock of the above .__next__ call failed to
+        # release the lock.
+        self.assertRaises(ValueError, bz2f.readlines)
+
     def testWrite(self):
         # "Test BZ2File.write()"
         bz2f = BZ2File(self.filename, "w")
index 3c8da77ae8b0d1a511c44b2b5c5c5829c6f7d479..4f8defb81ae09a34ee4ef22a16f7f2baa838a390 100644 (file)
@@ -62,11 +62,11 @@ class FractionTest(unittest.TestCase):
 
         self.assertRaisesMessage(ZeroDivisionError, "Fraction(12, 0)",
                                  F, 12, 0)
-        self.assertRaises(AttributeError, F, 1.5)
-        self.assertRaises(AttributeError, F, 1.5 + 3j)
+        self.assertRaises(TypeError, F, 1.5)
+        self.assertRaises(TypeError, F, 1.5 + 3j)
 
-        self.assertRaises(AttributeError, F, F(1, 2), 3)
-        self.assertRaises(AttributeError, F, "3/2", 3)
+        self.assertRaises(TypeError, F, F(1, 2), 3)
+        self.assertRaises(TypeError, F, "3/2", 3)
 
     def testFromString(self):
         self.assertEquals((5, 1), _components(F("5")))
index 4c5f7a58a1b399eb5ed93ca443f27563c65ac2ba..5f5c58871f90d79cababf14f7c595b708b4d9dc0 100644 (file)
@@ -1,3 +1,5 @@
+#!/usr/bin/env python
+
 #
 # Unit tests for the multiprocessing package
 #
index cd8f56524de6c4d8d77279aedfd888f2ebbf9e97..f3c72e7c935bd9a2942fcc3f913cd67f0bcf2e23 100644 (file)
@@ -336,21 +336,6 @@ class SysModuleTest(unittest.TestCase):
     def test_clear_type_cache(self):
         sys._clear_type_cache()
 
-    def test_compact_freelists(self):
-        sys._compact_freelists()
-        r = sys._compact_freelists()
-        ## freed blocks shouldn't change
-        #self.assertEqual(r[0][2], 0)
-        ## fill freelists
-        #ints = list(range(10000))
-        #floats = [float(i) for i in ints]
-        #del ints
-        #del floats
-        ## should free more than 100 blocks
-        #r = sys._compact_freelists()
-        #self.assert_(r[0][1] > 100, r[0][1])
-        #self.assert_(r[0][2] > 100, r[0][2])
-
     def test_ioencoding(self):
         import subprocess,os
         env = dict(os.environ)
index dbb2035fac0177440245b150f6dec2dfe64d0c1d..7ce335ef50dd74ec5cde85beaba40d83c1168665 100644 (file)
--- a/Misc/ACKS
+++ b/Misc/ACKS
@@ -145,6 +145,7 @@ Alex Coventry
 Matthew Dixon Cowles
 Christopher A. Craig
 Laura Creighton
+Simon Cross
 Drew Csillag
 John Cugini
 Tom Culliton
index a790556aa0559c8dd6d3a8fbc638d4b5c5a12a5f..d2c89711a81acf71f2b56414464df895252e884c 100644 (file)
@@ -228,9 +228,11 @@ _symtable symtablemodule.c
 #_md5 md5module.c md5.c
 
 
-# The _sha module implements the SHA checksum algorithm.
-# (NIST's Secure Hash Algorithm.)
+# The _sha module implements the SHA checksum algorithms.
+# (NIST's Secure Hash Algorithms.)
 #_sha shamodule.c
+#_sha256 sha256module.c
+#_sha512 sha512module.c
 
 
 # The _tkinter module.
index 71553ba06df3c81582a1ac452fb3565832c6fc69..f520f0c701fc149ca1c0dc5f3f05c71eac35da27 100644 (file)
@@ -278,7 +278,6 @@ fileio_init(PyObject *oself, PyObject *args, PyObject *kwds)
        ret = -1;
 
  done:
-       PyMem_Free(name);
        return ret;
 }
 
index c660501ed8ed31add62af5667e4bbb87198b5656..c54e51255bd673c7ed90d606c059a0a753909a39 100644 (file)
@@ -575,7 +575,7 @@ audioop_findmax(PyObject *self, PyObject *args)
         }
         len1 >>= 1;
     
-        if ( len1 < len2 ) {
+        if ( len2 < 0 || len1 < len2 ) {
                 PyErr_SetString(AudioopError, "Input sample should be longer");
                 return 0;
         }
index db10f31a2ee8b73d25282bc135193c920e6ee492..562198be05b21129cce3024709e73be36fbcc76e 100644 (file)
@@ -1264,6 +1264,7 @@ BZ2File_iternext(BZ2FileObject *self)
        PyBytesObject* ret;
        ACQUIRE_LOCK(self);
        if (self->mode == MODE_CLOSED) {
+                RELEASE_LOCK(self);
                PyErr_SetString(PyExc_ValueError,
                                "I/O operation on closed file");
                return NULL;
index eec618ecfc3b33e063e90ee0d3d739464e163d6f..67df5c339bc3e834ea82c7d6014c1151de4ab391 100644 (file)
@@ -839,8 +839,10 @@ cmath_log(PyObject *self, PyObject *args)
        errno = 0;
        PyFPE_START_PROTECT("complex function", return 0)
        x = c_log(x);
-       if (PyTuple_GET_SIZE(args) == 2)
-               x = c_quot(x, c_log(y));
+       if (PyTuple_GET_SIZE(args) == 2) {
+               y = c_log(y);
+               x = c_quot(x, y);
+       }
        PyFPE_END_PROTECT(x)
        if (errno != 0)
                return math_error();
index 1954d0c75bfbf65a65922d84af6e952feb8885b8..d2817fb92ef53f141533c43a44464c4b90d35431 100644 (file)
@@ -641,8 +641,6 @@ time_mktime(PyObject *self, PyObject *tup)
 {
        struct tm buf;
        time_t tt;
-       tt = time(&tt);
-       buf = *localtime(&tt);
        if (!gettmarg(tup, &buf))
                return NULL;
        tt = mktime(&buf);
index 60a5e849cfddc8768af29a0d160520df45c7c255..f15883e668b48e83fce9b3a2ea03897e1b0f6a31 100644 (file)
@@ -1632,7 +1632,7 @@ PySequence_GetItem(PyObject *s, Py_ssize_t i)
                return m->sq_item(s, i);
        }
 
-       return type_error("'%.200s' object is unindexable", s);
+       return type_error("'%.200s' object does not support indexing", s);
 }
 
 PyObject *
index ec279bf339690a9ee668f355368b9d2bb605c869..c75caf68231a219b43710523654cfb30fa476f27 100644 (file)
@@ -617,18 +617,20 @@ PyEval_EvalFrameEx(PyFrameObject *f, int throwflag)
        COMPARE_OP is often followed by JUMP_IF_FALSE or JUMP_IF_TRUE.  And,
        those opcodes are often followed by a POP_TOP.
 
-       Verifying the prediction costs a single high-speed test of register
+       Verifying the prediction costs a single high-speed test of register
        variable against a constant.  If the pairing was good, then the
-       processor has a high likelihood of making its own successful branch
-       prediction which results in a nearly zero overhead transition to the
-       next opcode.
-
-       A successful prediction saves a trip through the eval-loop including
-       its two unpredictable branches, the HAS_ARG test and the switch-case.
-
-        If collecting opcode statistics, turn off prediction so that
-       statistics are accurately maintained (the predictions bypass
-       the opcode frequency counter updates).
+       processor's own internal branch predication has a high likelihood of
+       success, resulting in a nearly zero-overhead transition to the
+       next opcode.  A successful prediction saves a trip through the eval-loop
+       including its two unpredictable branches, the HAS_ARG test and the 
+       switch-case.  Combined with the processor's internal branch prediction,
+       a successful PREDICT has the effect of making the two opcodes run as if 
+       they were a single new opcode with the bodies combined.
+
+    If collecting opcode statistics, your choices are to either keep the
+       predictions turned-on and interpret the results as if some opcodes
+       had been combined or turn-off predictions so that the opcode frequency
+       counter updates for both opcodes.
 */
 
 #ifdef DYNAMIC_EXECUTION_PROFILE
index d13563ffb35064b8f0102062009ba196dce48bf4..3a6cc9120cb196e828b9aff58ff5a89c0f23c2de 100644 (file)
@@ -229,14 +229,14 @@ Py_InitializeEx(int install_sigs)
        if (install_sigs)
                initsigs(); /* Signal handling stuff, including initintr() */
                
-    /* Initialize warnings. */
-    _PyWarnings_Init();
-    if (PySys_HasWarnOptions()) {
-        PyObject *warnings_module = PyImport_ImportModule("warnings");
-        if (!warnings_module)
-            PyErr_Clear();
-        Py_XDECREF(warnings_module);
-    }
+       /* Initialize warnings. */
+       _PyWarnings_Init();
+       if (PySys_HasWarnOptions()) {
+               PyObject *warnings_module = PyImport_ImportModule("warnings");
+               if (!warnings_module)
+                       PyErr_Clear();
+               Py_XDECREF(warnings_module);
+       }
 
        initmain(); /* Module __main__ */
        if (!Py_NoSiteFlag)
@@ -1246,7 +1246,7 @@ PyErr_PrintEx(int set_sys_last_vars)
        PyException_SetTraceback(v, tb);
        if (exception == NULL)
                return;
-        /* Now we know v != NULL too */
+       /* Now we know v != NULL too */
        if (set_sys_last_vars) {
                PySys_SetObject("last_type", exception);
                PySys_SetObject("last_value", v);
@@ -2096,14 +2096,14 @@ PyRun_AnyFileFlags(FILE *fp, const char *name, PyCompilerFlags *flags)
 PyAPI_FUNC(PyObject *)
 PyRun_File(FILE *fp, const char *p, int s, PyObject *g, PyObject *l)
 {
-        return PyRun_FileExFlags(fp, p, s, g, l, 0, NULL);
+       return PyRun_FileExFlags(fp, p, s, g, l, 0, NULL);
 }
 
 #undef PyRun_FileEx
 PyAPI_FUNC(PyObject *)
 PyRun_FileEx(FILE *fp, const char *p, int s, PyObject *g, PyObject *l, int c)
 {
-        return PyRun_FileExFlags(fp, p, s, g, l, c, NULL);
+       return PyRun_FileExFlags(fp, p, s, g, l, c, NULL);
 }
 
 #undef PyRun_FileFlags
@@ -2111,7 +2111,7 @@ PyAPI_FUNC(PyObject *)
 PyRun_FileFlags(FILE *fp, const char *p, int s, PyObject *g, PyObject *l,
                PyCompilerFlags *flags)
 {
-        return PyRun_FileExFlags(fp, p, s, g, l, 0, flags);
+       return PyRun_FileExFlags(fp, p, s, g, l, 0, flags);
 }
 
 #undef PyRun_SimpleFile