[Python-3000-checkins] r64609 - in python/branches/py3k-urllib: Doc/conf.py Doc/howto/urllib2.rst Doc/library/contextlib.rst Doc/library/decimal.rst Doc/library/fractions.rst Doc/library/http.client.rst Doc/library/http.cookiejar.rst Doc/library/multiprocessing.rst Doc/library/operator.rst Doc/library/optparse.rst Doc/library/pickle.rst Doc/library/ssl.rst Doc/reference/compound_stmts.rst Doc/tutorial/stdlib.rst Doc/whatsnew/2.6.rst Include/bytesobject.h Include/patchlevel.h Include/pymem.h Include/pyport.h Include/unicodeobject.h Lib/distutils/__init__.py Lib/http/cookiejar.py Lib/http/server.py Lib/idlelib/idlever.py Lib/lib2to3/refactor.py Lib/logging/__init__.py Lib/logging/handlers.py Lib/multiprocessing Lib/multiprocessing/connection.py Lib/multiprocessing/dummy Lib/multiprocessing/managers.py Lib/multiprocessing/process.py Lib/multiprocessing/sharedctypes.py Lib/nturl2path.py Lib/platform.py Lib/pydoc.py Lib/ssl.py Lib/test/crashers/loosing_mro_ref.py Lib/test/ieee754.txt Lib/test/regrtest.py Lib/test/test_array.py Lib/test/test_binop.py Lib/test/test_compile.py Lib/test/test_grammar.py Lib/test/test_heapq.py Lib/test/test_int.py Lib/test/test_multiprocessing.py Lib/test/test_ssl.py Lib/test/test_struct.py Lib/test/test_sys.py Lib/test/test_threading_local.py Lib/test/test_types.py Lib/test/test_warnings.py Lib/urllib Lib/urllib/request.py Lib/warnings.py Mac/BuildScript/build-installer.py Mac/Makefile.in Makefile.pre.in Misc/ACKS Misc/NEWS Misc/RPM/python-3.0.spec Misc/cheatsheet Misc/developers.txt Modules/_csv.c Modules/_ctypes/callproc.c Modules/_heapqmodule.c Modules/_struct.c Modules/_threadmodule.c Modules/arraymodule.c Modules/audioop.c Modules/binascii.c Modules/cjkcodecs/multibytecodec.c Modules/datetimemodule.c Modules/mathmodule.c Objects/dictobject.c Objects/listobject.c Objects/longobject.c Objects/memoryobject.c Objects/obmalloc.c Objects/stringlib/formatter.h Objects/stringlib/localeutil.h Objects/tupleobject.c PC/_msi.c PCbuild/sqlite3.vcproj Parser/node.c Python/_warnings.c Python/asdl.c Python/ast.c Python/compile.c Python/marshal.c Python/pystrtod.c README RELNOTES Tools/buildbot/external-amd64.bat Tools/faqwiz/faqwiz.py Tools/msi/msi.py Tools/msi/msilib.py Tools/versioncheck/pyversioncheck.py Tools/webchecker/webchecker.py Tools/webchecker/websucker.py setup.py

senthil.kumaran python-3000-checkins at python.org
Tue Jul 1 06:02:33 CEST 2008


Author: senthil.kumaran
Date: Tue Jul  1 06:02:29 2008
New Revision: 64609

Log:
merging the files from trunk to py3k-urllib branch

Modified:
   python/branches/py3k-urllib/   (props changed)
   python/branches/py3k-urllib/Doc/conf.py
   python/branches/py3k-urllib/Doc/howto/urllib2.rst
   python/branches/py3k-urllib/Doc/library/contextlib.rst
   python/branches/py3k-urllib/Doc/library/decimal.rst
   python/branches/py3k-urllib/Doc/library/fractions.rst
   python/branches/py3k-urllib/Doc/library/http.client.rst
   python/branches/py3k-urllib/Doc/library/http.cookiejar.rst
   python/branches/py3k-urllib/Doc/library/multiprocessing.rst
   python/branches/py3k-urllib/Doc/library/operator.rst
   python/branches/py3k-urllib/Doc/library/optparse.rst
   python/branches/py3k-urllib/Doc/library/pickle.rst
   python/branches/py3k-urllib/Doc/library/ssl.rst
   python/branches/py3k-urllib/Doc/reference/compound_stmts.rst
   python/branches/py3k-urllib/Doc/tutorial/stdlib.rst
   python/branches/py3k-urllib/Doc/whatsnew/2.6.rst
   python/branches/py3k-urllib/Include/bytesobject.h
   python/branches/py3k-urllib/Include/patchlevel.h
   python/branches/py3k-urllib/Include/pymem.h
   python/branches/py3k-urllib/Include/pyport.h
   python/branches/py3k-urllib/Include/unicodeobject.h
   python/branches/py3k-urllib/Lib/distutils/__init__.py
   python/branches/py3k-urllib/Lib/http/cookiejar.py
   python/branches/py3k-urllib/Lib/http/server.py
   python/branches/py3k-urllib/Lib/idlelib/idlever.py
   python/branches/py3k-urllib/Lib/lib2to3/refactor.py
   python/branches/py3k-urllib/Lib/logging/__init__.py
   python/branches/py3k-urllib/Lib/logging/handlers.py
   python/branches/py3k-urllib/Lib/multiprocessing/   (props changed)
   python/branches/py3k-urllib/Lib/multiprocessing/connection.py
   python/branches/py3k-urllib/Lib/multiprocessing/dummy/   (props changed)
   python/branches/py3k-urllib/Lib/multiprocessing/managers.py
   python/branches/py3k-urllib/Lib/multiprocessing/process.py
   python/branches/py3k-urllib/Lib/multiprocessing/sharedctypes.py
   python/branches/py3k-urllib/Lib/nturl2path.py
   python/branches/py3k-urllib/Lib/platform.py
   python/branches/py3k-urllib/Lib/pydoc.py
   python/branches/py3k-urllib/Lib/ssl.py
   python/branches/py3k-urllib/Lib/test/crashers/loosing_mro_ref.py
   python/branches/py3k-urllib/Lib/test/ieee754.txt
   python/branches/py3k-urllib/Lib/test/regrtest.py
   python/branches/py3k-urllib/Lib/test/test_array.py
   python/branches/py3k-urllib/Lib/test/test_binop.py
   python/branches/py3k-urllib/Lib/test/test_compile.py
   python/branches/py3k-urllib/Lib/test/test_grammar.py
   python/branches/py3k-urllib/Lib/test/test_heapq.py
   python/branches/py3k-urllib/Lib/test/test_int.py
   python/branches/py3k-urllib/Lib/test/test_multiprocessing.py
   python/branches/py3k-urllib/Lib/test/test_ssl.py
   python/branches/py3k-urllib/Lib/test/test_struct.py
   python/branches/py3k-urllib/Lib/test/test_sys.py
   python/branches/py3k-urllib/Lib/test/test_threading_local.py
   python/branches/py3k-urllib/Lib/test/test_types.py
   python/branches/py3k-urllib/Lib/test/test_warnings.py
   python/branches/py3k-urllib/Lib/urllib/   (props changed)
   python/branches/py3k-urllib/Lib/urllib/request.py
   python/branches/py3k-urllib/Lib/warnings.py
   python/branches/py3k-urllib/Mac/BuildScript/build-installer.py
   python/branches/py3k-urllib/Mac/Makefile.in
   python/branches/py3k-urllib/Makefile.pre.in
   python/branches/py3k-urllib/Misc/ACKS
   python/branches/py3k-urllib/Misc/NEWS
   python/branches/py3k-urllib/Misc/RPM/python-3.0.spec
   python/branches/py3k-urllib/Misc/cheatsheet
   python/branches/py3k-urllib/Misc/developers.txt
   python/branches/py3k-urllib/Modules/_csv.c
   python/branches/py3k-urllib/Modules/_ctypes/callproc.c
   python/branches/py3k-urllib/Modules/_heapqmodule.c
   python/branches/py3k-urllib/Modules/_struct.c
   python/branches/py3k-urllib/Modules/_threadmodule.c
   python/branches/py3k-urllib/Modules/arraymodule.c
   python/branches/py3k-urllib/Modules/audioop.c
   python/branches/py3k-urllib/Modules/binascii.c
   python/branches/py3k-urllib/Modules/cjkcodecs/multibytecodec.c
   python/branches/py3k-urllib/Modules/datetimemodule.c
   python/branches/py3k-urllib/Modules/mathmodule.c
   python/branches/py3k-urllib/Objects/dictobject.c
   python/branches/py3k-urllib/Objects/listobject.c
   python/branches/py3k-urllib/Objects/longobject.c
   python/branches/py3k-urllib/Objects/memoryobject.c
   python/branches/py3k-urllib/Objects/obmalloc.c
   python/branches/py3k-urllib/Objects/stringlib/formatter.h
   python/branches/py3k-urllib/Objects/stringlib/localeutil.h
   python/branches/py3k-urllib/Objects/tupleobject.c
   python/branches/py3k-urllib/PC/_msi.c
   python/branches/py3k-urllib/PCbuild/sqlite3.vcproj
   python/branches/py3k-urllib/Parser/node.c
   python/branches/py3k-urllib/Python/_warnings.c
   python/branches/py3k-urllib/Python/asdl.c
   python/branches/py3k-urllib/Python/ast.c
   python/branches/py3k-urllib/Python/compile.c
   python/branches/py3k-urllib/Python/marshal.c
   python/branches/py3k-urllib/Python/pystrtod.c
   python/branches/py3k-urllib/README
   python/branches/py3k-urllib/RELNOTES
   python/branches/py3k-urllib/Tools/buildbot/external-amd64.bat
   python/branches/py3k-urllib/Tools/faqwiz/faqwiz.py
   python/branches/py3k-urllib/Tools/msi/msi.py
   python/branches/py3k-urllib/Tools/msi/msilib.py
   python/branches/py3k-urllib/Tools/versioncheck/pyversioncheck.py
   python/branches/py3k-urllib/Tools/webchecker/webchecker.py
   python/branches/py3k-urllib/Tools/webchecker/websucker.py
   python/branches/py3k-urllib/setup.py

Modified: python/branches/py3k-urllib/Doc/conf.py
==============================================================================
--- python/branches/py3k-urllib/Doc/conf.py	(original)
+++ python/branches/py3k-urllib/Doc/conf.py	Tue Jul  1 06:02:29 2008
@@ -95,6 +95,9 @@
 # Output file base name for HTML help builder.
 htmlhelp_basename = 'python' + release.replace('.', '')
 
+# Split the index
+html_split_index = True
+
 
 # Options for LaTeX output
 # ------------------------

Modified: python/branches/py3k-urllib/Doc/howto/urllib2.rst
==============================================================================
--- python/branches/py3k-urllib/Doc/howto/urllib2.rst	(original)
+++ python/branches/py3k-urllib/Doc/howto/urllib2.rst	Tue Jul  1 06:02:29 2008
@@ -1,12 +1,12 @@
-*****************************************************
-  HOWTO Fetch Internet Resources Using urllib package
-*****************************************************
+***********************************************************
+  HOWTO Fetch Internet Resources Using The urllib Package
+***********************************************************
 
 :Author: `Michael Foord <http://www.voidspace.org.uk/python/index.shtml>`_
 
 .. note::
 
-    There is an French translation of an earlier revision of this
+    There is a French translation of an earlier revision of this
     HOWTO, available at `urllib2 - Le Manuel manquant
     <http://www.voidspace.org.uk/python/articles/urllib2_francais.shtml>`_.
 
@@ -18,7 +18,7 @@
 .. sidebar:: Related Articles
 
     You may also find useful the following article on fetching web resources
-    with Python :
+    with Python:
     
     * `Basic Authentication <http://www.voidspace.org.uk/python/articles/authentication.shtml>`_
     
@@ -94,8 +94,8 @@
 all POSTs have to come from forms: you can use a POST to transmit arbitrary data
 to your own application. In the common case of HTML forms, the data needs to be
 encoded in a standard way, and then passed to the Request object as the ``data``
-argument. The encoding is done using a function from the ``urllib.parse`` library
-*not* from ``urllib.request``. ::
+argument. The encoding is done using a function from the :mod:`urllib.parse`
+library. ::
 
     import urllib.parse
     import urllib.request 
@@ -115,7 +115,7 @@
 <http://www.w3.org/TR/REC-html40/interact/forms.html#h-17.13>`_ for more
 details).
 
-If you do not pass the ``data`` argument, urllib.request uses a **GET** request. One
+If you do not pass the ``data`` argument, urllib uses a **GET** request. One
 way in which GET and POST requests differ is that POST requests often have
 "side-effects": they change the state of the system in some way (for example by
 placing an order with the website for a hundredweight of tinned spam to be
@@ -182,13 +182,15 @@
 Handling Exceptions
 ===================
 
-*urllib.error* raises ``URLError`` when it cannot handle a response (though as usual
+*urlopen* raises ``URLError`` when it cannot handle a response (though as usual
 with Python APIs, builtin exceptions such as ValueError, TypeError etc. may also
 be raised).
 
 ``HTTPError`` is the subclass of ``URLError`` raised in the specific case of
 HTTP URLs.
 
+The exception classes are exported from the :mod:`urllib.error` module.
+
 URLError
 --------
 
@@ -214,7 +216,7 @@
 the status code indicates that the server is unable to fulfil the request. The
 default handlers will handle some of these responses for you (for example, if
 the response is a "redirection" that requests the client fetch the document from
-a different URL, urllib.request will handle that for you). For those it can't handle,
+a different URL, urllib will handle that for you). For those it can't handle,
 urlopen will raise an ``HTTPError``. Typical errors include '404' (page not
 found), '403' (request forbidden), and '401' (authentication required).
 
@@ -380,7 +382,7 @@
 
 The response returned by urlopen (or the ``HTTPError`` instance) has two useful
 methods ``info`` and ``geturl`` and is defined in the module
-``urllib.response``.
+:mod:`urllib.response`.
 
 **geturl** - this returns the real URL of the page fetched. This is useful
 because ``urlopen`` (or the opener object used) may have followed a
@@ -388,7 +390,7 @@
 
 **info** - this returns a dictionary-like object that describes the page
 fetched, particularly the headers sent by the server. It is currently an
-``http.client.HTTPMessage`` instance.
+:class:`http.client.HTTPMessage` instance.
 
 Typical headers include 'Content-length', 'Content-type', and so on. See the
 `Quick Reference to HTTP Headers <http://www.cs.tut.fi/~jkorpela/http.html>`_
@@ -508,7 +510,7 @@
 Proxies
 =======
 
-**urllib.request** will auto-detect your proxy settings and use those. This is through
+**urllib** will auto-detect your proxy settings and use those. This is through
 the ``ProxyHandler`` which is part of the normal handler chain. Normally that's
 a good thing, but there are occasions when it may not be helpful [#]_. One way
 to do this is to setup our own ``ProxyHandler``, with no proxies defined. This
@@ -528,8 +530,8 @@
 Sockets and Layers
 ==================
 
-The Python support for fetching resources from the web is layered.
-urllib.request uses the http.client library, which in turn uses the socket library.
+The Python support for fetching resources from the web is layered.  urllib uses
+the :mod:`http.client` library, which in turn uses the socket library.
 
 As of Python 2.3 you can specify how long a socket should wait for a response
 before timing out. This can be useful in applications which have to fetch web
@@ -573,9 +575,9 @@
        `Quick Reference to HTTP Headers`_.
 .. [#] In my case I have to use a proxy to access the internet at work. If you
        attempt to fetch *localhost* URLs through this proxy it blocks them. IE
-       is set to use the proxy, which urllib2 picks up on. In order to test
-       scripts with a localhost server, I have to prevent urllib2 from using
+       is set to use the proxy, which urllib picks up on. In order to test
+       scripts with a localhost server, I have to prevent urllib from using
        the proxy.
-.. [#] urllib2 opener for SSL proxy (CONNECT method): `ASPN Cookbook Recipe 
+.. [#] urllib opener for SSL proxy (CONNECT method): `ASPN Cookbook Recipe 
        <http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/456195>`_.
  

Modified: python/branches/py3k-urllib/Doc/library/contextlib.rst
==============================================================================
--- python/branches/py3k-urllib/Doc/library/contextlib.rst	(original)
+++ python/branches/py3k-urllib/Doc/library/contextlib.rst	Tue Jul  1 06:02:29 2008
@@ -98,9 +98,9 @@
    And lets you write code like this::
 
       from contextlib import closing
-      import urllib.request
+      from urllib.request import urlopen
 
-      with closing(urllib.request.urlopen('http://www.python.org')) as page:
+      with closing(urlopen('http://www.python.org')) as page:
           for line in page:
               print(line)
 

Modified: python/branches/py3k-urllib/Doc/library/decimal.rst
==============================================================================
--- python/branches/py3k-urllib/Doc/library/decimal.rst	(original)
+++ python/branches/py3k-urllib/Doc/library/decimal.rst	Tue Jul  1 06:02:29 2008
@@ -135,6 +135,7 @@
 :const:`NaN` which stands for "Not a number", positive and negative
 :const:`Infinity`, and :const:`-0`.
 
+   >>> getcontext().prec = 28
    >>> Decimal(10)
    Decimal('10')
    >>> Decimal('3.14')
@@ -173,7 +174,7 @@
 .. doctest::
    :options: +NORMALIZE_WHITESPACE
 
-   >>> data = map(Decimal, '1.34 1.87 3.45 2.35 1.00 0.03 9.25'.split())
+   >>> data = list(map(Decimal, '1.34 1.87 3.45 2.35 1.00 0.03 9.25'.split()))
    >>> max(data)
    Decimal('9.25')
    >>> min(data)
@@ -201,6 +202,7 @@
 
 And some mathematical functions are also available to Decimal:
 
+   >>> getcontext().prec = 28
    >>> Decimal(2).sqrt()
    Decimal('1.414213562373095048801688724')
    >>> Decimal(1).exp()
@@ -267,7 +269,7 @@
    Decimal('3.14159292')
    >>> getcontext()
    Context(prec=9, rounding=ROUND_HALF_EVEN, Emin=-999999999, Emax=999999999,
-           capitals=1, flags=[Rounded, Inexact], traps=[])
+           capitals=1, flags=[Inexact, Rounded], traps=[])
 
 The *flags* entry shows that the rational approximation to :const:`Pi` was
 rounded (digits beyond the context precision were thrown away) and that the
@@ -414,6 +416,11 @@
       ``x.compare_total_mag(y)`` is equivalent to
       ``x.copy_abs().compare_total(y.copy_abs())``.
 
+   .. method:: conjugate()
+
+      Just returns itself, this method is only to comply with the Decimal
+      Specification.
+
    .. method:: copy_abs()
 
       Return the absolute value of the argument.  This operation is unaffected
@@ -722,13 +729,6 @@
       :const:`Rounded`.  If given, applies *rounding*; otherwise, uses the
       rounding method in either the supplied *context* or the current context.
 
-   .. method:: trim()
-
-      Return the decimal with *insignificant* trailing zeros removed.  Here, a
-      trailing zero is considered insignificant either if it follows the decimal
-      point, or if the exponent of the argument (that is, the last element of
-      the :meth:`as_tuple` representation) is positive.
-
 
 .. _logical_operands_label:
 
@@ -940,6 +940,46 @@
       Return the sum of *x* and *y*.
 
 
+   .. method:: canonical(x)
+
+      Returns the same Decimal object *x*.
+
+
+   .. method:: compare(x, y)
+
+      Compares *x* and *y* numerically.
+
+
+   .. method:: compare_signal(x, y)
+
+      Compares the values of the two operands numerically.
+
+
+   .. method:: compare_total(x, y)
+
+      Compares two operands using their abstract representation.
+
+
+   .. method:: compare_total_mag(x, y)
+
+      Compares two operands using their abstract representation, ignoring sign.
+
+
+   .. method:: copy_abs(x)
+
+      Returns a copy of *x* with the sign set to 0.
+
+
+   .. method:: copy_negate(x)
+
+      Returns a copy of *x* with the sign inverted.
+
+
+   .. method:: copy_sign(x, y)
+
+      Copies the sign from *y* to *x*.
+
+
    .. method:: divide(x, y)
 
       Return *x* divided by *y*.
@@ -955,6 +995,121 @@
       Divides two numbers and returns the integer part of the result.
 
 
+   .. method:: exp(x)
+
+      Returns `e ** x`.
+
+
+   .. method:: fma(x, y, z)
+
+      Returns *x* multiplied by *y*, plus *z*.
+
+
+   .. method:: is_canonical(x)
+
+      Returns True if *x* is canonical; otherwise returns False.
+
+
+   .. method:: is_finite(x)
+
+      Returns True if *x* is finite; otherwise returns False.
+
+
+   .. method:: is_infinite(x)
+
+      Returns True if *x* is infinite; otherwise returns False.
+
+
+   .. method:: is_nan(x)
+
+      Returns True if *x* is a qNaN or sNaN; otherwise returns False.
+
+
+   .. method:: is_normal(x)
+
+      Returns True if *x* is a normal number; otherwise returns False.
+
+
+   .. method:: is_qnan(x)
+
+      Returns True if *x* is a quiet NaN; otherwise returns False.
+
+
+   .. method:: is_signed(x)
+
+      Returns True if *x* is negative; otherwise returns False.
+
+
+   .. method:: is_snan(x)
+
+      Returns True if *x* is a signaling NaN; otherwise returns False.
+
+
+   .. method:: is_subnormal(x)
+
+      Returns True if *x* is subnormal; otherwise returns False.
+
+
+   .. method:: is_zero(x)
+
+      Returns True if *x* is a zero; otherwise returns False.
+
+
+   .. method:: ln(x)
+
+      Returns the natural (base e) logarithm of *x*.
+
+
+   .. method:: log10(x)
+
+      Returns the base 10 logarithm of *x*.
+
+
+   .. method:: logb(x)
+
+       Returns the exponent of the magnitude of the operand's MSD.
+
+
+   .. method:: logical_and(x, y)
+
+      Applies the logical operation `and` between each operand's digits.
+
+
+   .. method:: logical_invert(x)
+
+      Invert all the digits in *x*.
+
+
+   .. method:: logical_or(x, y)
+
+      Applies the logical operation `or` between each operand's digits.
+
+
+   .. method:: logical_xor(x, y)
+
+      Applies the logical operation `xor` between each operand's digits.
+
+
+   .. method:: max(x, y)
+
+      Compares two values numerically and returns the maximum.
+
+
+   .. method:: max_mag(x, y)
+
+      Compares the values numerically with their sign ignored.
+
+
+   .. method:: min(x, y)
+
+      Compares two values numerically and returns the minimum.
+
+
+   .. method:: min_mag(x, y)
+
+      Compares the values numerically with their sign ignored.
+
+
    .. method:: minus(x)
 
       Minus corresponds to the unary prefix minus operator in Python.
@@ -965,6 +1120,31 @@
       Return the product of *x* and *y*.
 
 
+   .. method:: next_minus(x)
+
+      Returns the largest representable number smaller than *x*.
+
+
+   .. method:: next_plus(x)
+
+      Returns the smallest representable number larger than *x*.
+
+
+   .. method:: next_toward(x, y)
+
+      Returns the number closest to *x*, in direction towards *y*.
+
+
+   .. method:: normalize(x)
+
+      Reduces *x* to its simplest form.
+
+
+   .. method:: number_class(x)
+
+      Returns an indication of the class of *x*.
+
+
    .. method:: plus(x)
 
       Plus corresponds to the unary prefix plus operator in Python.  This
@@ -994,6 +1174,17 @@
       that would be obtained by computing ``(x**y) % modulo`` with unbounded
       precision, but is computed more efficiently.  It is always exact.
 
+
+   .. method:: quantize(x, y)
+
+      Returns a value equal to *x* (rounded), having the exponent of *y*.
+
+
+   .. method:: radix()
+
+      Just returns 10, as this is Decimal, :)
+
+
    .. method:: remainder(x, y)
 
       Returns the remainder from integer division.
@@ -1001,10 +1192,52 @@
       The sign of the result, if non-zero, is the same as that of the original
       dividend.
 
+   .. method:: remainder_near(x, y)
+
+      Returns `x - y * n`, where *n* is the integer nearest the exact value 
+      of `x / y` (if the result is `0` then its sign will be the sign of *x*).
+
+
+   .. method:: rotate(x, y)
+
+      Returns a rotated copy of *x*, *y* times.
+
+
+   .. method:: same_quantum(x, y)
+
+      Returns True if the two operands have the same exponent.
+
+
+   .. method:: scaleb (x, y)
+
+      Returns the first operand after adding the second value its exp.
+
+
+   .. method:: shift(x, y)
+
+      Returns a shifted copy of *x*, *y* times.
+
+
+   .. method:: sqrt(x)
+
+      Square root of a non-negative number to context precision.
+
+
    .. method:: subtract(x, y)
 
       Return the difference between *x* and *y*.
 
+
+   .. method:: to_eng_string(x)
+
+      Converts a number to a string, using scientific notation.
+
+
+   .. method:: to_integral_exact(x)
+
+      Rounds to an integer.
+
+
    .. method:: to_sci_string(x)
 
       Converts a number to a string using scientific notation.
@@ -1323,7 +1556,7 @@
        q = Decimal(10) ** -places      # 2 places --> '0.01'
        sign, digits, exp = value.quantize(q).as_tuple()  
        result = []
-       digits = map(str, digits)
+       digits = list(map(str, digits))
        build, next = result.append, digits.pop
        if sign:
            build(trailneg)

Modified: python/branches/py3k-urllib/Doc/library/fractions.rst
==============================================================================
--- python/branches/py3k-urllib/Doc/library/fractions.rst	(original)
+++ python/branches/py3k-urllib/Doc/library/fractions.rst	Tue Jul  1 06:02:29 2008
@@ -8,39 +8,75 @@
 .. sectionauthor:: Jeffrey Yasskin <jyasskin at gmail.com>
 
 
-The :mod:`fractions` module defines an immutable, infinite-precision
-Rational number class.
+The :mod:`fractions` module provides support for rational number arithmetic.
 
 
+A Fraction instance can be constructed from a pair of integers, from
+another rational number, or from a string.
+
 .. class:: Fraction(numerator=0, denominator=1)
            Fraction(other_fraction)
            Fraction(string)
 
    The first version requires that *numerator* and *denominator* are
    instances of :class:`numbers.Integral` and returns a new
-   ``Fraction`` representing ``numerator/denominator``. If
-   *denominator* is :const:`0`, raises a :exc:`ZeroDivisionError`. The
-   second version requires that *other_fraction* is an instance of
-   :class:`numbers.Fraction` and returns an instance of
-   :class:`Rational` with the same value. The third version expects a
-   string of the form ``[-+]?[0-9]+(/[0-9]+)?``, optionally surrounded
-   by spaces.
-
-   Implements all of the methods and operations from
-   :class:`numbers.Rational` and is immutable and hashable.
+   :class:`Fraction` instance with value ``numerator/denominator``. If
+   *denominator* is :const:`0`, it raises a
+   :exc:`ZeroDivisionError`. The second version requires that
+   *other_fraction* is an instance of :class:`numbers.Rational` and
+   returns an :class:`Fraction` instance with the same value.  The
+   last version of the constructor expects a string or unicode
+   instance in one of two possible forms.  The first form is::
+
+      [sign] numerator ['/' denominator]
+
+   where the optional ``sign`` may be either '+' or '-' and
+   ``numerator`` and ``denominator`` (if present) are strings of
+   decimal digits.  The second permitted form is that of a number
+   containing a decimal point::
+
+      [sign] integer '.' [fraction] | [sign] '.' fraction
+
+   where ``integer`` and ``fraction`` are strings of digits.  In
+   either form the input string may also have leading and/or trailing
+   whitespace.  Here are some examples::
+
+      >>> from fractions import Fraction
+      >>> Fraction(16, -10)
+      Fraction(-8, 5)
+      >>> Fraction(123)
+      Fraction(123, 1)
+      >>> Fraction()
+      Fraction(0, 1)
+      >>> Fraction('3/7')
+      Fraction(3, 7)
+      [40794 refs]
+      >>> Fraction(' -3/7 ')
+      Fraction(-3, 7)
+      >>> Fraction('1.414213 \t\n')
+      Fraction(1414213, 1000000)
+      >>> Fraction('-.125')
+      Fraction(-1, 8)
+
+
+   The :class:`Fraction` class inherits from the abstract base class
+   :class:`numbers.Rational`, and implements all of the methods and
+   operations from that class.  :class:`Fraction` instances are hashable,
+   and should be treated as immutable.  In addition,
+   :class:`Fraction` has the following methods:
 
 
    .. method:: from_float(flt)
 
-      This classmethod constructs a :class:`Fraction` representing the exact
+      This class method constructs a :class:`Fraction` representing the exact
       value of *flt*, which must be a :class:`float`. Beware that
-      ``Fraction.from_float(0.3)`` is not the same value as ``Rational(3, 10)``
+      ``Fraction.from_float(0.3)`` is not the same value as ``Fraction(3, 10)``
 
 
    .. method:: from_decimal(dec)
 
-      This classmethod constructs a :class:`Fraction` representing the exact
-      value of *dec*, which must be a :class:`decimal.Decimal`.
+      This class method constructs a :class:`Fraction` representing the exact
+      value of *dec*, which must be a :class:`decimal.Decimal` instance.
 
 
    .. method:: limit_denominator(max_denominator=1000000)
@@ -51,37 +87,50 @@
 
          >>> from fractions import Fraction
          >>> Fraction('3.1415926535897932').limit_denominator(1000)
-         Fraction(355L, 113L)
+         Fraction(355, 113)
 
       or for recovering a rational number that's represented as a float:
 
          >>> from math import pi, cos
          >>> Fraction.from_float(cos(pi/3))
-         Fraction(4503599627370497L, 9007199254740992L)
+         Fraction(4503599627370497, 9007199254740992)
          >>> Fraction.from_float(cos(pi/3)).limit_denominator()
-         Fraction(1L, 2L)
+         Fraction(1, 2)
 
 
    .. method:: __floor__()
 
-      Returns the greatest :class:`int` ``<= self``. Will be accessible through
-      :func:`math.floor` in Py3k.
+      Returns the greatest :class:`int` ``<= self``.  This method can
+      also be accessed through the :func:`math.floor` function:
+
+        >>> from math import floor
+        >>> floor(Fraction(355, 113))
+        3
 
 
    .. method:: __ceil__()
 
-      Returns the least :class:`int` ``>= self``. Will be accessible through
-      :func:`math.ceil` in Py3k.
+      Returns the least :class:`int` ``>= self``.  This method can
+      also be accessed through the :func:`math.ceil` function.
 
 
    .. method:: __round__()
                __round__(ndigits)
 
-      The first version returns the nearest :class:`int` to ``self``, rounding
-      half to even. The second version rounds ``self`` to the nearest multiple
-      of ``Fraction(1, 10**ndigits)`` (logically, if ``ndigits`` is negative),
-      again rounding half toward even. Will be accessible through :func:`round`
-      in Py3k.
+      The first version returns the nearest :class:`int` to ``self``,
+      rounding half to even. The second version rounds ``self`` to the
+      nearest multiple of ``Fraction(1, 10**ndigits)`` (logically, if
+      ``ndigits`` is negative), again rounding half toward even.  This
+      method can also be accessed through the :func:`round` function.
+
+
+.. function:: gcd(a, b)
+
+   Return the greatest common divisor of the integers `a` and `b`.  If
+   either `a` or `b` is nonzero, then the absolute value of `gcd(a,
+   b)` is the largest integer that divides both `a` and `b`.  `gcd(a,b)`
+   has the same sign as `b` if `b` is nonzero; otherwise it takes the sign
+   of `a`.  `gcd(0, 0)` returns `0`.
 
 
 .. seealso::

Modified: python/branches/py3k-urllib/Doc/library/http.client.rst
==============================================================================
--- python/branches/py3k-urllib/Doc/library/http.client.rst	(original)
+++ python/branches/py3k-urllib/Doc/library/http.client.rst	Tue Jul  1 06:02:29 2008
@@ -13,8 +13,7 @@
 
 This module defines classes which implement the client side of the HTTP and
 HTTPS protocols.  It is normally not used directly --- the module
-:mod:`urllib.request`
-uses it to handle URLs that use HTTP and HTTPS.
+:mod:`urllib.request` uses it to handle URLs that use HTTP and HTTPS.
 
 .. note::
 

Modified: python/branches/py3k-urllib/Doc/library/http.cookiejar.rst
==============================================================================
--- python/branches/py3k-urllib/Doc/library/http.cookiejar.rst	(original)
+++ python/branches/py3k-urllib/Doc/library/http.cookiejar.rst	Tue Jul  1 06:02:29 2008
@@ -100,7 +100,7 @@
 
 .. seealso::
 
-   Module :mod:`urllib2`
+   Module :mod:`urllib.request`
       URL opening with automatic cookie handling.
 
    Module :mod:`http.cookies`
@@ -149,11 +149,11 @@
    the :class:`CookieJar`'s :class:`CookiePolicy` instance are true and false
    respectively), the :mailheader:`Cookie2` header is also added when appropriate.
 
-   The *request* object (usually a :class:`urllib2.Request` instance) must support
-   the methods :meth:`get_full_url`, :meth:`get_host`, :meth:`get_type`,
-   :meth:`unverifiable`, :meth:`get_origin_req_host`, :meth:`has_header`,
-   :meth:`get_header`, :meth:`header_items`, and :meth:`add_unredirected_header`,as
-   documented by :mod:`urllib2`.
+   The *request* object (usually a :class:`urllib.request..Request` instance)
+   must support the methods :meth:`get_full_url`, :meth:`get_host`,
+   :meth:`get_type`, :meth:`unverifiable`, :meth:`get_origin_req_host`,
+   :meth:`has_header`, :meth:`get_header`, :meth:`header_items`, and
+   :meth:`add_unredirected_header`, as documented by :mod:`urllib.request`.
 
 
 .. method:: CookieJar.extract_cookies(response, request)
@@ -166,14 +166,15 @@
    as appropriate (subject to the :meth:`CookiePolicy.set_ok` method's approval).
 
    The *response* object (usually the result of a call to
-   :meth:`urllib2.urlopen`, or similar) should support an :meth:`info` method,
-   which returns a :class:`email.message.Message` instance.
+   :meth:`urllib.request.urlopen`, or similar) should support an :meth:`info`
+   method, which returns a :class:`email.message.Message` instance.
 
-   The *request* object (usually a :class:`urllib2.Request` instance) must support
-   the methods :meth:`get_full_url`, :meth:`get_host`, :meth:`unverifiable`, and
-   :meth:`get_origin_req_host`, as documented by :mod:`urllib2`.  The request is
-   used to set default values for cookie-attributes as well as for checking that
-   the cookie is allowed to be set.
+   The *request* object (usually a :class:`urllib.request.Request` instance)
+   must support the methods :meth:`get_full_url`, :meth:`get_host`,
+   :meth:`unverifiable`, and :meth:`get_origin_req_host`, as documented by
+   :mod:`urllib.request`.  The request is used to set default values for
+   cookie-attributes as well as for checking that the cookie is allowed to be
+   set.
 
 
 .. method:: CookieJar.set_policy(policy)
@@ -715,18 +716,18 @@
 
 The first example shows the most common usage of :mod:`http.cookiejar`::
 
-   import http.cookiejar, urllib2
+   import http.cookiejar, urllib.request
    cj = http.cookiejar.CookieJar()
-   opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(cj))
+   opener = urllib.request.build_opener(urllib.request.HTTPCookieProcessor(cj))
    r = opener.open("http://example.com/")
 
 This example illustrates how to open a URL using your Netscape, Mozilla, or Lynx
 cookies (assumes Unix/Netscape convention for location of the cookies file)::
 
-   import os, http.cookiejar, urllib2
+   import os, http.cookiejar, urllib.request
    cj = http.cookiejar.MozillaCookieJar()
    cj.load(os.path.join(os.environ["HOME"], ".netscape/cookies.txt"))
-   opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(cj))
+   opener = urllib.request.build_opener(urllib.request.HTTPCookieProcessor(cj))
    r = opener.open("http://example.com/")
 
 The next example illustrates the use of :class:`DefaultCookiePolicy`. Turn on
@@ -734,12 +735,12 @@
 Netscape cookies, and block some domains from setting cookies or having them
 returned::
 
-   import urllib2
+   import urllib.request
    from http.cookiejar import CookieJar, DefaultCookiePolicy
    policy = DefaultCookiePolicy(
        rfc2965=True, strict_ns_domain=Policy.DomainStrict,
        blocked_domains=["ads.net", ".ads.net"])
    cj = CookieJar(policy)
-   opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(cj))
+   opener = urllib.request.build_opener(urllib.request.HTTPCookieProcessor(cj))
    r = opener.open("http://example.com/")
 

Modified: python/branches/py3k-urllib/Doc/library/multiprocessing.rst
==============================================================================
--- python/branches/py3k-urllib/Doc/library/multiprocessing.rst	(original)
+++ python/branches/py3k-urllib/Doc/library/multiprocessing.rst	Tue Jul  1 06:02:29 2008
@@ -4,81 +4,24 @@
 .. module:: multiprocessing
    :synopsis: Process-based "threading" interface.
 
-:mod:`multiprocessing` is a package for the Python language which supports the
-spawning of processes using a similar API of the :mod:`threading` module.  It
-runs on both Unix and Windows.
-
-The :mod:`multiprocessing` module offers the capability of both local and remote
-concurrency effectively side-stepping the Global Interpreter Lock by utilizing
-subprocesses for "threads".  Due to this, the :mod:`multiprocessing` module
-allows the programmer to fully leverage multiple processors on a given machine.
-
 
 Introduction
-------------
-
-
-Threads, processes and the GIL
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-
-To run more than one piece of code at the same time on the same computer one has
-the choice of either using multiple processes or multiple threads.
+----------------------
 
-Although a program can be made up of multiple processes, these processes are in
-effect completely independent of one another: different processes are not able
-to cooperate with one another unless one sets up some means of communication
-between them (such as by using sockets).  If a lot of data must be transferred
-between processes then this can be inefficient.
-
-On the other hand, multiple threads within a single process are intimately
-connected: they share their data but often can interfere badly with one another.
-It is often argued that the only way to make multithreaded programming "easy" is
-to avoid relying on any shared state and for the threads to only communicate by
-passing messages to each other.
-
-CPython has a *Global Interpreter Lock* (GIL) which in many ways makes threading
-easier than it is in most languages by making sure that only one thread can
-manipulate the interpreter's objects at a time.  As a result, it is often safe
-to let multiple threads access data without using any additional locking as one
-would need to in a language such as C.
-
-One downside of the GIL is that on multi-processor (or multi-core) systems a
-multithreaded Python program can only make use of one processor at a time unless
-your application makes heavy use of I/O which effectively side-steps this.  This
-is a problem that can be overcome by using multiple processes instead.
-
-This package allows one to write multi-process programs using much the same API
-that one uses for writing threaded programs.
-
-
-Forking and spawning
-~~~~~~~~~~~~~~~~~~~~
-
-There are two ways of creating a new process in Python:
-
-* The current process can *fork* a new child process by using the
-  :func:`os.fork` function.  This effectively creates an identical copy of the
-  current process which is now able to go off and perform some task set by the
-  parent process.  This means that the child process inherits *copies* of all
-  variables that the parent process had.  However, :func:`os.fork` is not
-  available on every platform: in particular Windows does not support it.
-
-* Alternatively, the current process can spawn a completely new Python
-  interpreter by using the :mod:`subprocess` module or one of the
-  :func:`os.spawn*` functions.  Getting this new interpreter in to a fit state
-  to perform the task set for it by its parent process is, however, a bit of a
-  challenge.
-
-The :mod:`multiprocessing` module uses :func:`os.fork` if it is available since
-it makes life a lot simpler.  Forking the process is also more efficient in
-terms of memory usage and the time needed to create the new process.
+:mod:`multiprocessing` is a package that supports spawning processes using an
+API similar to the :mod:`threading` module.  The :mod:`multiprocessing` package
+offers both local and remote concurrency, effectively side-stepping the
+:term:`Global Interpreter Lock` by using subprocesses instead of threads.  Due
+to this, the :mod:`multiprocessing` module allows the programmer to fully
+leverage multiple processors on a given machine.  It runs on both Unix and
+Windows.
 
 
 The :class:`Process` class
 ~~~~~~~~~~~~~~~~~~~~~~~~~~
 
 In :mod:`multiprocessing`, processes are spawned by creating a :class:`Process`
-object and then calling its :meth:`Process.start` method.  :class:`Process`
+object and then calling its :meth:`~Process.start` method.  :class:`Process`
 follows the API of :class:`threading.Thread`.  A trivial example of a
 multiprocess program is ::
 
@@ -107,7 +50,7 @@
 
 **Queues**
 
-   The :class:`Queue` class is a near clone of :class:`Queue.Queue`.  For
+   The :class:`Queue` class is a near clone of :class:`queue.Queue`.  For
    example::
 
       from multiprocessing import Process, Queue
@@ -143,11 +86,12 @@
           p.join()
 
    The two connection objects returned by :func:`Pipe` represent the two ends of
-   the pipe.  Each connection object has :meth:`send` and :meth:`recv` methods
-   (among others).  Note that data in a pipe may become corrupted if two
-   processes (or threads) try to read from or write to the *same* end of the
-   pipe at the same time.  Of course there is no risk of corruption from
-   processes using different ends of the pipe at the same time.
+   the pipe.  Each connection object has :meth:`~Connection.send` and
+   :meth:`~Connection.recv` methods (among others).  Note that data in a pipe
+   may become corrupted if two processes (or threads) try to read from or write
+   to the *same* end of the pipe at the same time.  Of course there is no risk
+   of corruption from processes using different ends of the pipe at the same
+   time.
 
 
 Synchronization between processes
@@ -268,7 +212,7 @@
 Using a pool of workers
 ~~~~~~~~~~~~~~~~~~~~~~~
 
-The :class:`multiprocessing.pool.Pool()` class represens a pool of worker
+The :class:`~multiprocessing.pool.Pool` class represents a pool of worker
 processes.  It has methods which allows tasks to be offloaded to the worker
 processes in a few different ways.
 
@@ -303,9 +247,9 @@
    :class:`threading.Thread`.
 
    The constructor should always be called with keyword arguments. *group*
-   should always be ``None``; it exists soley for compatibility with
-   :class:`threading.Thread`.  *target* is the callable object to be invoked by
-   the :meth:`run()` method.  It defaults to None, meaning nothing is
+   should always be ``None``; it exists solely for compatibility with
+   :class:`~threading.Thread`.  *target* is the callable object to be invoked by
+   the :meth:`run()` method.  It defaults to ``None``, meaning nothing is
    called. *name* is the process name.  By default, a unique name is constructed
    of the form 'Process-N\ :sub:`1`:N\ :sub:`2`:...:N\ :sub:`k`' where N\
    :sub:`1`,N\ :sub:`2`,...,N\ :sub:`k` is a sequence of integers whose length
@@ -413,11 +357,11 @@
 
       Set the process's authentication key which must be a byte string.
 
-   .. method:: terminate()`
+   .. method:: terminate()
 
-      Terminate the process.  On Unix this is done using the ``SIGTERM`` signal,
-      on Windows ``TerminateProcess()`` is used.  Note that exit handlers and
-      finally clauses etc will not be executed.
+      Terminate the process.  On Unix this is done using the ``SIGTERM`` signal;
+      on Windows :cfunc:`TerminateProcess` is used.  Note that exit handlers and
+      finally clauses, etc., will not be executed.
 
       Note that descendant processes of the process will *not* be terminated --
       they will simply become orphaned.
@@ -470,22 +414,25 @@
 processes) or a queue (which allows multiple producers and consumers).
 
 The :class:`Queue` and :class:`JoinableQueue` types are multi-producer,
-multi-consumer FIFO queues modelled on the :class:`Queue.Queue` class in the
+multi-consumer FIFO queues modelled on the :class:`queue.Queue` class in the
 standard library.  They differ in that :class:`Queue` lacks the
-:meth:`task_done` and :meth:`join` methods introduced into Python 2.5's
-:class:`Queue.Queue` class.
+:meth:`~queue.Queue.task_done` and :meth:`~queue.Queue.join` methods introduced
+into Python 2.5's :class:`queue.Queue` class.
 
 If you use :class:`JoinableQueue` then you **must** call
 :meth:`JoinableQueue.task_done` for each task removed from the queue or else the
 semaphore used to count the number of unfinished tasks may eventually overflow
 raising an exception.
 
+Note that one can also create a shared queue by using a manager object -- see
+:ref:`multiprocessing-managers`.
+
 .. note::
 
-   :mod:`multiprocessing` uses the usual :exc:`Queue.Empty` and
-   :exc:`Queue.Full` exceptions to signal a timeout.  They are not available in
+   :mod:`multiprocessing` uses the usual :exc:`queue.Empty` and
+   :exc:`queue.Full` exceptions to signal a timeout.  They are not available in
    the :mod:`multiprocessing` namespace so you need to import them from
-   :mod:`Queue`.
+   :mod:`queue`.
 
 
 .. warning::
@@ -509,9 +456,6 @@
    Note that a queue created using a manager does not have this issue.  See
    :ref:`multiprocessing-programming`.
 
-Note that one can also create a shared queue by using a manager object -- see
-:ref:`multiprocessing-managers`.
-
 For an example of the usage of queues for interprocess communication see
 :ref:`multiprocessing-examples`.
 
@@ -533,11 +477,11 @@
    locks/semaphores.  When a process first puts an item on the queue a feeder
    thread is started which transfers objects from a buffer into the pipe.
 
-   The usual :exc:`Queue.Empty` and :exc:`Queue.Full` exceptions from the
+   The usual :exc:`queue.Empty` and :exc:`queue.Full` exceptions from the
    standard library's :mod:`Queue` module are raised to signal timeouts.
 
-   :class:`Queue` implements all the methods of :class:`Queue.Queue` except for
-   :meth:`task_done` and :meth:`join`.
+   :class:`Queue` implements all the methods of :class:`queue.Queue` except for
+   :meth:`~queue.Queue.task_done` and :meth:`~queue.Queue.join`.
 
    .. method:: qsize()
 
@@ -557,15 +501,15 @@
       Return ``True`` if the queue is full, ``False`` otherwise.  Because of
       multithreading/multiprocessing semantics, this is not reliable.
 
-   .. method:: put(item[, block[, timeout]])`
+   .. method:: put(item[, block[, timeout]])
 
-      Put item into the queue.  If optional args *block* is ``True`` (the
-      default) and *timeout* is ``None`` (the default), block if necessary until
+      Put item into the queue.  If the optional argument *block* is ``True`` 
+      (the default) and *timeout* is ``None`` (the default), block if necessary until
       a free slot is available.  If *timeout* is a positive number, it blocks at
-      most *timeout* seconds and raises the :exc:`Queue.Full` exception if no
+      most *timeout* seconds and raises the :exc:`queue.Full` exception if no
       free slot was available within that time.  Otherwise (*block* is
       ``False``), put an item on the queue if a free slot is immediately
-      available, else raise the :exc:`Queue.Full` exception (*timeout* is
+      available, else raise the :exc:`queue.Full` exception (*timeout* is
       ignored in that case).
 
    .. method:: put_nowait(item)
@@ -577,10 +521,10 @@
       Remove and return an item from the queue.  If optional args *block* is
       ``True`` (the default) and *timeout* is ``None`` (the default), block if
       necessary until an item is available.  If *timeout* is a positive number,
-      it blocks at most *timeout* seconds and raises the :exc:`Queue.Empty`
+      it blocks at most *timeout* seconds and raises the :exc:`queue.Empty`
       exception if no item was available within that time.  Otherwise (block is
       ``False``), return an item if one is immediately available, else raise the
-      :exc:`Queue.Empty` exception (*timeout* is ignored in that case).
+      :exc:`queue.Empty` exception (*timeout* is ignored in that case).
 
    .. method:: get_nowait()
                get_no_wait()
@@ -588,7 +532,7 @@
       Equivalent to ``get(False)``.
 
    :class:`multiprocessing.Queue` has a few additional methods not found in
-   :class:`Queue.Queue` which are usually unnecessary:
+   :class:`queue.Queue` which are usually unnecessary:
 
    .. method:: close()
 
@@ -605,13 +549,13 @@
 
       By default if a process is not the creator of the queue then on exit it
       will attempt to join the queue's background thread.  The process can call
-      :meth:`cancel_join_thread()` to make :meth:`join_thread()` do nothing.
+      :meth:`cancel_join_thread` to make :meth:`join_thread` do nothing.
 
    .. method:: cancel_join_thread()
 
       Prevent :meth:`join_thread` from blocking.  In particular, this prevents
       the background thread from being joined automatically when the process
-      exits -- see :meth:`join_thread()`.
+      exits -- see :meth:`join_thread`.
 
 
 .. class:: JoinableQueue([maxsize])
@@ -622,13 +566,13 @@
    .. method:: task_done()
 
       Indicate that a formerly enqueued task is complete. Used by queue consumer
-      threads.  For each :meth:`get` used to fetch a task, a subsequent call to
-      :meth:`task_done` tells the queue that the processing on the task is
-      complete.
-
-      If a :meth:`join` is currently blocking, it will resume when all items
-      have been processed (meaning that a :meth:`task_done` call was received
-      for every item that had been :meth:`put` into the queue).
+      threads.  For each :meth:`~Queue.get` used to fetch a task, a subsequent
+      call to :meth:`task_done` tells the queue that the processing on the task
+      is complete.
+
+      If a :meth:`~Queue.join` is currently blocking, it will resume when all
+      items have been processed (meaning that a :meth:`task_done` call was
+      received for every item that had been :meth:`~Queue.put` into the queue).
 
       Raises a :exc:`ValueError` if called more times than there were items
       placed in the queue.
@@ -642,7 +586,7 @@
       queue.  The count goes down whenever a consumer thread calls
       :meth:`task_done` to indicate that the item was retrieved and all work on
       it is complete.  When the count of unfinished tasks drops to zero,
-      :meth:`join` unblocks.
+      :meth:`~Queue.join` unblocks.
 
 
 Miscellaneous
@@ -684,17 +628,17 @@
           freeze_support()
           Process(target=f).start()
 
-   If the :func:`freeze_support()` line is missed out then trying to run the
-   frozen executable will raise :exc:`RuntimeError`.
+   If the ``freeze_support()`` line is missed out then trying to run the frozen
+   executable will raise :exc:`RuntimeError`.
 
    If the module is being run normally by the Python interpreter then
-   :func:`freeze_support()` has no effect.
+   :func:`freeze_support` has no effect.
 
 .. function:: set_executable()
 
    Sets the path of the python interpreter to use when starting a child process.
-   (By default `sys.executable` is used).  Embedders will probably need to do
-   some thing like ::
+   (By default :data:`sys.executable` is used).  Embedders will probably need to
+   do some thing like ::
 
       setExecutable(os.path.join(sys.exec_prefix, 'pythonw.exe'))
 
@@ -715,7 +659,7 @@
 Connection objects allow the sending and receiving of picklable objects or
 strings.  They can be thought of as message oriented connected sockets.
 
-Connection objects usually created using :func:`Pipe()` -- see also
+Connection objects usually created using :func:`Pipe` -- see also
 :ref:`multiprocessing-listeners-clients`.
 
 .. class:: Connection
@@ -812,9 +756,10 @@
     receives, which can be a security risk unless you can trust the process
     which sent the message.
 
-    Therefore, unless the connection object was produced using :func:`Pipe()`
-    you should only use the `recv()` and `send()` methods after performing some
-    sort of authentication.  See :ref:`multiprocessing-auth-keys`.
+    Therefore, unless the connection object was produced using :func:`Pipe` you
+    should only use the :meth:`~Connection.recv` and :meth:`~Connection.send`
+    methods after performing some sort of authentication.  See
+    :ref:`multiprocessing-auth-keys`.
 
 .. warning::
 
@@ -827,8 +772,8 @@
 ~~~~~~~~~~~~~~~~~~~~~~~~~~
 
 Generally synchronization primitives are not as necessary in a multiprocess
-program as they are in a mulithreaded program.  See the documentation for the
-standard library's :mod:`threading` module.
+program as they are in a mulithreaded program.  See the documentation for
+:mod:`threading` module.
 
 Note that one can also create synchronization primitives by using a manager
 object -- see :ref:`multiprocessing-managers`.
@@ -842,7 +787,7 @@
 
 .. class:: Condition([lock])
 
-   A condition variable: a clone of `threading.Condition`.
+   A condition variable: a clone of :class:`threading.Condition`.
 
    If *lock* is specified then it should be a :class:`Lock` or :class:`RLock`
    object from :mod:`multiprocessing`.
@@ -865,7 +810,7 @@
 
 .. note::
 
-   The :meth:`acquire()` method of :class:`BoundedSemaphore`, :class:`Lock`,
+   The :meth:`acquire` method of :class:`BoundedSemaphore`, :class:`Lock`,
    :class:`RLock` and :class:`Semaphore` has a timeout parameter not supported
    by the equivalents in :mod:`threading`.  The signature is
    ``acquire(block=True, timeout=None)`` with keyword parameters being
@@ -891,7 +836,7 @@
 It is possible to create shared objects using shared memory which can be
 inherited by child processes.
 
-.. function:: Value(typecode_or_type[, lock[, *args]])
+.. function:: Value(typecode_or_type[, *args, lock]])
 
    Return a :mod:`ctypes` object allocated from shared memory.  By default the
    return value is actually a synchronized wrapper for the object.
@@ -983,7 +928,7 @@
    attributes which allow one to use it to store and retrieve strings -- see
    documentation for :mod:`ctypes`.
 
-.. function:: Array(typecode_or_type, size_or_initializer[, lock[, *args]])
+.. function:: Array(typecode_or_type, size_or_initializer[, *args[, lock]])
 
    The same as :func:`RawArray` except that depending on the value of *lock* a
    process-safe synchronization wrapper may be returned instead of a raw ctypes
@@ -1025,11 +970,11 @@
    :class:`multiprocessing.RLock` object is created automatically.
 
    A synchronized wrapper will have two methods in addition to those of the
-   object it wraps: :meth:`get_obj()` returns the wrapped object and
-   :meth:`get_lock()` returns the lock object used for synchronization.
+   object it wraps: :meth:`get_obj` returns the wrapped object and
+   :meth:`get_lock` returns the lock object used for synchronization.
 
    Note that accessing the ctypes object through the wrapper can be a lot slower
-   han accessing the raw ctypes object.
+   than accessing the raw ctypes object.
 
 
 The table below compares the syntax for creating shared ctypes objects from
@@ -1105,10 +1050,10 @@
 
 .. function:: multiprocessing.Manager()
 
-   Returns a started :class:`SyncManager` object which can be used for sharing
-   objects between processes.  The returned manager object corresponds to a
-   spawned child process and has methods which will create shared objects and
-   return corresponding proxies.
+   Returns a started :class:`~multiprocessing.managers.SyncManager` object which
+   can be used for sharing objects between processes.  The returned manager
+   object corresponds to a spawned child process and has methods which will
+   create shared objects and return corresponding proxies.
 
 .. module:: multiprocessing.managers
    :synopsis: Share data between process with shared objects.
@@ -1148,7 +1093,7 @@
    .. method:: shutdown()
 
       Stop the process used by the manager.  This is only available if
-      meth:`start` has been used to start the server process.
+      :meth:`start` has been used to start the server process.
 
       This can be called multiple times.
 
@@ -1162,12 +1107,12 @@
 
       *callable* is a callable used for creating objects for this type
       identifier.  If a manager instance will be created using the
-      :meth:`from_address()` classmethod or if the *create_method* argument is
+      :meth:`from_address` classmethod or if the *create_method* argument is
       ``False`` then this can be left as ``None``.
 
-      *proxytype* is a subclass of :class:`multiprocessing.managers.BaseProxy`
-      which is used to create proxies for shared objects with this *typeid*.  If
-      ``None`` then a proxy class is created automatically.
+      *proxytype* is a subclass of :class:`BaseProxy` which is used to create
+      proxies for shared objects with this *typeid*.  If ``None`` then a proxy
+      class is created automatically.
 
       *exposed* is used to specify a sequence of method names which proxies for
       this typeid should be allowed to access using
@@ -1175,7 +1120,7 @@
       :attr:`proxytype._exposed_` is used instead if it exists.)  In the case
       where no exposed list is specified, all "public methods" of the shared
       object will be accessible.  (Here a "public method" means any attribute
-      which has a ``__call__()`` method and whose name does not begin with
+      which has a :meth:`__call__` method and whose name does not begin with
       ``'_'``.)
 
       *method_to_typeid* is a mapping used to specify the return type of those
@@ -1200,7 +1145,7 @@
 
    A subclass of :class:`BaseManager` which can be used for the synchronization
    of processes.  Objects of this type are returned by
-   :func:`multiprocessing.Manager()`.
+   :func:`multiprocessing.Manager`.
 
    It also supports creation of shared lists and dictionaries.
 
@@ -1231,7 +1176,7 @@
 
    .. method:: Queue([maxsize])
 
-      Create a shared `Queue.Queue` object and return a proxy for it.
+      Create a shared :class:`queue.Queue` object and return a proxy for it.
 
    .. method:: RLock()
 
@@ -1244,7 +1189,7 @@
 
    .. method:: Array(typecode, sequence)
 
-      Create an array and return a proxy for it.  (*format* is ignored.)
+      Create an array and return a proxy for it.
 
    .. method:: Value(typecode, value)
 
@@ -1285,8 +1230,8 @@
 >>>>>>>>>>>>>>>>>>>
 
 To create one's own manager, one creates a subclass of :class:`BaseManager` and
-use the :meth:`resgister()` classmethod to register new types or callables with
-the manager class.  For example::
+use the :meth:`~BaseManager.resgister` classmethod to register new types or
+callables with the manager class.  For example::
 
    from multiprocessing.managers import BaseManager
 
@@ -1319,8 +1264,8 @@
 remote clients can access::
 
    >>> from multiprocessing.managers import BaseManager
-   >>> import Queue
-   >>> queue = Queue.Queue()
+   >>> import queue
+   >>> queue = queue.Queue()
    >>> class QueueManager(BaseManager): pass
    ...
    >>> QueueManager.register('getQueue', callable=lambda:queue)
@@ -1385,7 +1330,7 @@
 
    >>> a = manager.list()
    >>> b = manager.list()
-   >>> a.append(b)         # referent of `a` now contains referent of `b`
+   >>> a.append(b)         # referent of a now contains referent of b
    >>> print a, b
    [[]] []
    >>> b.append('hello')
@@ -1432,7 +1377,7 @@
       Note in particular that an exception will be raised if *methodname* has
       not been *exposed*
 
-      An example of the usage of :meth:`_call_method()`::
+      An example of the usage of :meth:`_call_method`::
 
          >>> l = manager.list(range(10))
          >>> l._call_method('__len__')
@@ -1476,7 +1421,7 @@
    :synopsis: Create pools of processes.
 
 One can create a pool of processes which will carry out tasks submitted to it
-with the :class:`Pool` class in :mod:`multiprocess.pool`.
+with the :class:`Pool` class.
 
 .. class:: multiprocessing.Pool([processes[, initializer[, initargs]]])
 
@@ -1514,7 +1459,7 @@
 
    .. method:: map_async(func, iterable[, chunksize[, callback]])
 
-      A variant of the :meth:`.map` method which returns a result object.
+      A variant of the :meth:`map` method which returns a result object.
 
       If *callback* is specified then it should be a callable which accepts a
       single argument.  When the result becomes ready *callback* is applied to
@@ -1622,7 +1567,7 @@
 However, the :mod:`multiprocessing.connection` module allows some extra
 flexibility.  It basically gives a high level message oriented API for dealing
 with sockets or Windows named pipes, and also has support for *digest
-authentication* using the :mod:`hmac` module from the standard library.
+authentication* using the :mod:`hmac` module.
 
 
 .. function:: deliver_challenge(connection, authkey)
@@ -1645,7 +1590,7 @@
 .. function:: Client(address[, family[, authenticate[, authkey]]])
 
    Attempt to set up a connection to the listener which is using address
-   *address*, returning a :class:`Connection`.
+   *address*, returning a :class:`~multiprocessing.Connection`.
 
    The type of the connection is determined by *family* argument, but this can
    generally be omitted since it can usually be inferred from the format of
@@ -1721,15 +1666,6 @@
 
    Exception raised when there is an authentication error.
 
-.. exception:: BufferTooShort
-
-   Exception raise by the :meth:`Connection.recv_bytes_into` method of a
-   connection object when the supplied buffer object is too small for the
-   message read.
-
-   If *e* is an instance of :exc:`BufferTooShort` then ``e.args[0]`` will give
-   the message as a byte string.
-
 
 **Examples**
 
@@ -1780,10 +1716,10 @@
 Address Formats
 >>>>>>>>>>>>>>>
 
-* An ``'AF_INET'`` address is a tuple of the form ``(hostname, port)``` where
+* An ``'AF_INET'`` address is a tuple of the form ``(hostname, port)`` where
   *hostname* is a string and *port* is an integer.
 
-* An ``'AF_UNIX'``` address is a string representing a filename on the
+* An ``'AF_UNIX'`` address is a string representing a filename on the
   filesystem.
 
 * An ``'AF_PIPE'`` address is a string of the form
@@ -1812,11 +1748,11 @@
 
 If authentication is requested but do authentication key is specified then the
 return value of ``current_process().get_auth_key`` is used (see
-:class:`Process`).  This value will automatically inherited by any
-:class:`Process` object that the current process creates.  This means that (by
-default) all processes of a multi-process program will share a single
-authentication key which can be used when setting up connections between the
-themselves.
+:class:`~multiprocessing.Process`).  This value will automatically inherited by
+any :class:`~multiprocessing.Process` object that the current process creates.
+This means that (by default) all processes of a multi-process program will share
+a single authentication key which can be used when setting up connections
+between the themselves.
 
 Suitable authentication keys can also be generated by using :func:`os.urandom`.
 
@@ -1866,7 +1802,7 @@
    :synopsis: Dumb wrapper around threading.
 
 :mod:`multiprocessing.dummy` replicates the API of :mod:`multiprocessing` but is
-no more than a wrapper around the `threading` module.
+no more than a wrapper around the :mod:`threading` module.
 
 
 .. _multiprocessing-programming:
@@ -1912,7 +1848,7 @@
 
 Better to inherit than pickle/unpickle
 
-    On Windows many of types from :mod:`multiprocessing` need to be picklable so
+    On Windows many types from :mod:`multiprocessing` need to be picklable so
     that child processes can use them.  However, one should generally avoid
     sending shared objects to other processes using pipes or queues.  Instead
     you should arrange the program so that a process which need access to a
@@ -1926,8 +1862,7 @@
     processes.
 
     Therefore it is probably best to only consider using
-    :meth:`Process.terminate()` on processes which never use any shared
-    resources.
+    :meth:`Process.terminate` on processes which never use any shared resources.
 
 Joining processes that use queues
 
@@ -1959,7 +1894,7 @@
     A fix here would be to swap the last two lines round (or simply remove the
     ``p.join()`` line).
 
-Explicity pass resources to child processes
+Explicitly pass resources to child processes
 
     On Unix a child process can make use of a shared resource created in a
     parent process using a global resource.  However, it is better to pass the
@@ -2050,7 +1985,7 @@
            p = Process(target=foo)
            p.start()
 
-    (The :func:`freeze_support()` line can be omitted if the program will be run
+    (The ``freeze_support()`` line can be omitted if the program will be run
     normally instead of frozen.)
 
     This allows the newly spawned Python interpreter to safely import the module

Modified: python/branches/py3k-urllib/Doc/library/operator.rst
==============================================================================
--- python/branches/py3k-urllib/Doc/library/operator.rst	(original)
+++ python/branches/py3k-urllib/Doc/library/operator.rst	Tue Jul  1 06:02:29 2008
@@ -210,24 +210,12 @@
    Remove the value of *a* at index *b*.
 
  
-.. function:: delslice(a, b, c)
-              __delslice__(a, b, c)
-
-   Delete the slice of *a* from index *b* to index *c-1*.
-
-
 .. function:: getitem(a, b)
               __getitem__(a, b)
 
    Return the value of *a* at index *b*.
 
 
-.. function:: getslice(a, b, c)
-              __getslice__(a, b, c)
-
-   Return the slice of *a* from index *b* to index *c-1*.
-
-
 .. function:: indexOf(a, b)
 
    Return the index of the first of occurrence of *b* in *a*.
@@ -245,12 +233,6 @@
    Set the value of *a* at index *b* to *c*.
 
 
-.. function:: setslice(a, b, c, v)
-              __setslice__(a, b, c, v)
-
-   Set the slice of *a* from index *b* to index *c-1* to the sequence *v*.
-
-
 Many operations have an "in-place" version.  The following functions provide a
 more primitive access to in-place operators than the usual syntax does; for
 example, the :term:`statement` ``x += y`` is equivalent to
@@ -533,12 +515,6 @@
 +-----------------------+-------------------------+---------------------------------+
 | Sequence Repitition   | ``seq * i``             | ``repeat(seq, i)``              |
 +-----------------------+-------------------------+---------------------------------+
-| Slice Assignment      | ``seq[i:j] = values``   | ``setslice(seq, i, j, values)`` |
-+-----------------------+-------------------------+---------------------------------+
-| Slice Deletion        | ``del seq[i:j]``        | ``delslice(seq, i, j)``         |
-+-----------------------+-------------------------+---------------------------------+
-| Slicing               | ``seq[i:j]``            | ``getslice(seq, i, j)``         |
-+-----------------------+-------------------------+---------------------------------+
 | String Formatting     | ``s % obj``             | ``mod(s, obj)``                 |
 +-----------------------+-------------------------+---------------------------------+
 | Subtraction           | ``a - b``               | ``sub(a, b)``                   |

Modified: python/branches/py3k-urllib/Doc/library/optparse.rst
==============================================================================
--- python/branches/py3k-urllib/Doc/library/optparse.rst	(original)
+++ python/branches/py3k-urllib/Doc/library/optparse.rst	Tue Jul  1 06:02:29 2008
@@ -636,9 +636,9 @@
 option involved in the error; be sure to do the same when calling
 ``parser.error()`` from your application code.
 
-If :mod:`optparse`'s default error-handling behaviour does not suite your needs,
-you'll need to subclass OptionParser and override ``exit()`` and/or
-:meth:`error`.
+If :mod:`optparse`'s default error-handling behaviour does not suit your needs,
+you'll need to subclass OptionParser and override its :meth:`exit` and/or
+:meth:`error` methods.
 
 
 .. _optparse-putting-it-all-together:

Modified: python/branches/py3k-urllib/Doc/library/pickle.rst
==============================================================================
--- python/branches/py3k-urllib/Doc/library/pickle.rst	(original)
+++ python/branches/py3k-urllib/Doc/library/pickle.rst	Tue Jul  1 06:02:29 2008
@@ -20,27 +20,15 @@
 "unpickling" is the inverse operation, whereby a byte stream is converted back
 into an object hierarchy.  Pickling (and unpickling) is alternatively known as
 "serialization", "marshalling," [#]_ or "flattening", however, to avoid
-confusion, the terms used here are "pickling" and "unpickling".
-
-This documentation describes both the :mod:`pickle` module and the
-:mod:`cPickle` module.
+confusion, the terms used here are "pickling" and "unpickling"..
 
 
 Relationship to other Python modules
 ------------------------------------
 
-The :mod:`pickle` module has an optimized cousin called the :mod:`cPickle`
-module.  As its name implies, :mod:`cPickle` is written in C, so it can be up to
-1000 times faster than :mod:`pickle`.  However it does not support subclassing
-of the :func:`Pickler` and :func:`Unpickler` classes, because in :mod:`cPickle`
-these are functions, not classes.  Most applications have no need for this
-functionality, and can benefit from the improved performance of :mod:`cPickle`.
-Other than that, the interfaces of the two modules are nearly identical; the
-common interface is described in this manual and differences are pointed out
-where necessary.  In the following discussions, we use the term "pickle" to
-collectively describe the :mod:`pickle` and :mod:`cPickle` modules.
-
-The data streams the two modules produce are guaranteed to be interchangeable.
+The :mod:`pickle` module has an transparent optimizer (:mod:`_pickle`) written
+in C. It is used whenever available. Otherwise the pure Python implementation is
+used.
 
 Python has a more primitive serialization module called :mod:`marshal`, but in
 general :mod:`pickle` should always be the preferred way to serialize Python
@@ -229,7 +217,7 @@
    necessarily limited to) :exc:`AttributeError`, :exc:`EOFError`,
    :exc:`ImportError`, and :exc:`IndexError`.
 
-The :mod:`pickle` module also exports two callables [#]_, :class:`Pickler` and
+The :mod:`pickle` module also exports two callables, :class:`Pickler` and
 :class:`Unpickler`:
 
 
@@ -305,11 +293,6 @@
       ids" that may be referenced in a pickle data stream.  See section
       :ref:`pickle-protocol` below for more details.
 
-      **Note:** the :meth:`noload` method is currently only available on
-      :class:`Unpickler` objects created with the :mod:`cPickle` module.
-      :mod:`pickle` module :class:`Unpickler`\ s do not have the :meth:`noload`
-      method.
-
 
 What can be pickled and unpickled?
 ----------------------------------
@@ -535,7 +518,7 @@
 objects are referenced by a "persistent id", which is just an arbitrary string
 of printable ASCII characters. The resolution of such names is not defined by
 the :mod:`pickle` module; it will delegate this resolution to user defined
-functions on the pickler and unpickler. [#]_
+functions on the pickler and unpickler.
 
 To define external persistent id resolution, you need to set the
 :attr:`persistent_id` attribute of the pickler object and the
@@ -600,15 +583,8 @@
    j = up.load()
    print(j)
 
-In the :mod:`cPickle` module, the unpickler's :attr:`persistent_load` attribute
-can also be set to a Python list, in which case, when the unpickler reaches a
-persistent id, the persistent id string will simply be appended to this list.
-This functionality exists so that a pickle data stream can be "sniffed" for
-object references without actually instantiating all the objects in a pickle.
-[#]_  Setting :attr:`persistent_load` to a list is usually used in conjunction
-with the :meth:`noload` method on the Unpickler.
 
-.. BAW: Both pickle and cPickle support something called inst_persistent_id()
+.. BAW: pickle supports something called inst_persistent_id()
    which appears to give unknown types a second shot at producing a persistent
    id.  Since Jim Fulton can't remember why it was added or what it's for, I'm
    leaving it undocumented.
@@ -625,32 +601,22 @@
 
 By default, unpickling will import any class that it finds in the pickle data.
 You can control exactly what gets unpickled and what gets called by customizing
-your unpickler.  Unfortunately, exactly how you do this is different depending
-on whether you're using :mod:`pickle` or :mod:`cPickle`. [#]_
+your unpickler.
 
-In the :mod:`pickle` module, you need to derive a subclass from
-:class:`Unpickler`, overriding the :meth:`load_global` method.
-:meth:`load_global` should read two lines from the pickle data stream where the
-first line will the name of the module containing the class and the second line
-will be the name of the instance's class.  It then looks up the class, possibly
-importing the module and digging out the attribute, then it appends what it
-finds to the unpickler's stack.  Later on, this class will be assigned to the
-:attr:`__class__` attribute of an empty class, as a way of magically creating an
-instance without calling its class's :meth:`__init__`. Your job (should you
-choose to accept it), would be to have :meth:`load_global` push onto the
-unpickler's stack, a known safe version of any class you deem safe to unpickle.
-It is up to you to produce such a class.  Or you could raise an error if you
-want to disallow all unpickling of instances.  If this sounds like a hack,
-you're right.  Refer to the source code to make this work.
-
-Things are a little cleaner with :mod:`cPickle`, but not by much. To control
-what gets unpickled, you can set the unpickler's :attr:`find_global` attribute
-to a function or ``None``.  If it is ``None`` then any attempts to unpickle
-instances will raise an :exc:`UnpicklingError`.  If it is a function, then it
-should accept a module name and a class name, and return the corresponding class
-object.  It is responsible for looking up the class and performing any necessary
-imports, and it may raise an error to prevent instances of the class from being
-unpickled.
+You need to derive a subclass from :class:`Unpickler`, overriding the
+:meth:`load_global` method.  :meth:`load_global` should read two lines from the
+pickle data stream where the first line will the name of the module containing
+the class and the second line will be the name of the instance's class.  It then
+looks up the class, possibly importing the module and digging out the attribute,
+then it appends what it finds to the unpickler's stack.  Later on, this class
+will be assigned to the :attr:`__class__` attribute of an empty class, as a way
+of magically creating an instance without calling its class's
+:meth:`__init__`. Your job (should you choose to accept it), would be to have
+:meth:`load_global` push onto the unpickler's stack, a known safe version of any
+class you deem safe to unpickle.  It is up to you to produce such a class.  Or
+you could raise an error if you want to disallow all unpickling of instances.
+If this sounds like a hack, you're right.  Refer to the source code to make this
+work.
 
 The moral of the story is that you should be really careful about the source of
 the strings your application unpickles.
@@ -777,48 +743,10 @@
       High-performance serialization of built-in types.
 
 
-:mod:`cPickle` --- A faster :mod:`pickle`
-=========================================
-
-.. module:: cPickle
-   :synopsis: Faster version of pickle, but not subclassable.
-.. moduleauthor:: Jim Fulton <jim at zope.com>
-.. sectionauthor:: Fred L. Drake, Jr. <fdrake at acm.org>
-
-
-.. index:: module: pickle
-
-The :mod:`cPickle` module supports serialization and de-serialization of Python
-objects, providing an interface and functionality nearly identical to the
-:mod:`pickle` module.  There are several differences, the most important being
-performance and subclassability.
-
-First, :mod:`cPickle` can be up to 1000 times faster than :mod:`pickle` because
-the former is implemented in C.  Second, in the :mod:`cPickle` module the
-callables :func:`Pickler` and :func:`Unpickler` are functions, not classes.
-This means that you cannot use them to derive custom pickling and unpickling
-subclasses.  Most applications have no need for this functionality and should
-benefit from the greatly improved performance of the :mod:`cPickle` module.
-
-The pickle data stream produced by :mod:`pickle` and :mod:`cPickle` are
-identical, so it is possible to use :mod:`pickle` and :mod:`cPickle`
-interchangeably with existing pickles. [#]_
-
-There are additional minor differences in API between :mod:`cPickle` and
-:mod:`pickle`, however for most applications, they are interchangeable.  More
-documentation is provided in the :mod:`pickle` module documentation, which
-includes a list of the documented differences.
-
 .. rubric:: Footnotes
 
 .. [#] Don't confuse this with the :mod:`marshal` module
 
-.. [#] In the :mod:`pickle` module these callables are classes, which you could
-   subclass to customize the behavior.  However, in the :mod:`cPickle` module these
-   callables are factory functions and so cannot be subclassed.  One common reason
-   to subclass is to control what objects can actually be unpickled.  See section
-   :ref:`pickle-sub` for more details.
-
 .. [#] *Warning*: this is intended for pickling multiple objects without intervening
    modifications to the objects or their parts.  If you modify an object and then
    pickle it again using the same :class:`Pickler` instance, the object is not
@@ -834,25 +762,3 @@
 
 .. [#] This protocol is also used by the shallow and deep copying operations defined in
    the :mod:`copy` module.
-
-.. [#] The actual mechanism for associating these user defined functions is slightly
-   different for :mod:`pickle` and :mod:`cPickle`.  The description given here
-   works the same for both implementations.  Users of the :mod:`pickle` module
-   could also use subclassing to effect the same results, overriding the
-   :meth:`persistent_id` and :meth:`persistent_load` methods in the derived
-   classes.
-
-.. [#] We'll leave you with the image of Guido and Jim sitting around sniffing pickles
-   in their living rooms.
-
-.. [#] A word of caution: the mechanisms described here use internal attributes and
-   methods, which are subject to change in future versions of Python.  We intend to
-   someday provide a common interface for controlling this behavior, which will
-   work in either :mod:`pickle` or :mod:`cPickle`.
-
-.. [#] Since the pickle data format is actually a tiny stack-oriented programming
-   language, and some freedom is taken in the encodings of certain objects, it is
-   possible that the two modules produce different data streams for the same input
-   objects.  However it is guaranteed that they will always be able to read each
-   other's data streams.
-

Modified: python/branches/py3k-urllib/Doc/library/ssl.rst
==============================================================================
--- python/branches/py3k-urllib/Doc/library/ssl.rst	(original)
+++ python/branches/py3k-urllib/Doc/library/ssl.rst	Tue Jul  1 06:02:29 2008
@@ -129,7 +129,7 @@
    method should signal unexpected EOF from the other end of the connection.  If specified
    as :const:`True` (the default), it returns a normal EOF in response to unexpected
    EOF errors raised from the underlying socket; if :const:`False`, it will raise
-   the exceptions back the caller.
+   the exceptions back to the caller.
 
 .. function:: RAND_status()
 

Modified: python/branches/py3k-urllib/Doc/reference/compound_stmts.rst
==============================================================================
--- python/branches/py3k-urllib/Doc/reference/compound_stmts.rst	(original)
+++ python/branches/py3k-urllib/Doc/reference/compound_stmts.rst	Tue Jul  1 06:02:29 2008
@@ -569,12 +569,13 @@
    Foo = f1(arg)(f2(Foo))
 
 **Programmer's note:** Variables defined in the class definition are class
-can be set in a method with ``self.name = value``.  Both class and instance
-variables are accessible through the notation "``self.name``", and an instance
-variable hides a class variable with the same name when accessed in this way.
-Class variables can be used as defaults for instance variables, but using
-mutable values there can lead to unexpected results.  Descriptors can be used
-to create instance variables with different implementation details.
+variables; they are shared by instances. Instance variables can be set in a
+method with ``self.name = value``.  Both class and instance variables are
+accessible through the notation "``self.name``", and an instance variable hides
+a class variable with the same name when accessed in this way.  Class variables
+can be used as defaults for instance variables, but using mutable values there
+can lead to unexpected results.  Descriptors can be used to create instance
+variables with different implementation details.
 
 .. XXX add link to descriptor docs above
 

Modified: python/branches/py3k-urllib/Doc/tutorial/stdlib.rst
==============================================================================
--- python/branches/py3k-urllib/Doc/tutorial/stdlib.rst	(original)
+++ python/branches/py3k-urllib/Doc/tutorial/stdlib.rst	Tue Jul  1 06:02:29 2008
@@ -147,11 +147,11 @@
 ===============
 
 There are a number of modules for accessing the internet and processing internet
-protocols. Two of the simplest are :mod:`urllib.request` for retrieving data from urls
-and :mod:`smtplib` for sending mail::
+protocols. Two of the simplest are :mod:`urllib.request` for retrieving data
+from urls and :mod:`smtplib` for sending mail::
 
-   >>> import urllib.request
-   >>> for line in urllib.request.urlopen('http://tycho.usno.navy.mil/cgi-bin/timer.pl'):
+   >>> from urllib.request import urlopen
+   >>> for line in urlopen('http://tycho.usno.navy.mil/cgi-bin/timer.pl'):
    ...     if 'EST' in line or 'EDT' in line:  # look for Eastern Time
    ...         print(line)
 

Modified: python/branches/py3k-urllib/Doc/whatsnew/2.6.rst
==============================================================================
--- python/branches/py3k-urllib/Doc/whatsnew/2.6.rst	(original)
+++ python/branches/py3k-urllib/Doc/whatsnew/2.6.rst	Tue Jul  1 06:02:29 2008
@@ -521,6 +521,21 @@
   
 .. ======================================================================
 
+.. _pep-0371:
+
+PEP 371: The ``multiprocessing`` Package
+=====================================================
+
+XXX write this.
+
+.. seealso::
+
+   :pep:`371` - Per-user ``site-packages`` Directory
+     PEP written by Jesse Noller and Richard Oudkerk; 
+     implemented by Jesse Noller.
+
+.. ======================================================================
+
 .. _pep-3101:
 
 PEP 3101: Advanced String Formatting

Modified: python/branches/py3k-urllib/Include/bytesobject.h
==============================================================================
--- python/branches/py3k-urllib/Include/bytesobject.h	(original)
+++ python/branches/py3k-urllib/Include/bytesobject.h	Tue Jul  1 06:02:29 2008
@@ -91,8 +91,8 @@
    see Objects/stringlib/localeutil.h */
 
 PyAPI_FUNC(int) _PyBytes_InsertThousandsGrouping(char *buffer,
-						  Py_ssize_t len,
-						  char *plast,
+						  Py_ssize_t n_buffer,
+						  Py_ssize_t n_digits,
 						  Py_ssize_t buf_size,
 						  Py_ssize_t *count,
 						  int append_zero_char);

Modified: python/branches/py3k-urllib/Include/patchlevel.h
==============================================================================
--- python/branches/py3k-urllib/Include/patchlevel.h	(original)
+++ python/branches/py3k-urllib/Include/patchlevel.h	Tue Jul  1 06:02:29 2008
@@ -19,11 +19,11 @@
 #define PY_MAJOR_VERSION	3
 #define PY_MINOR_VERSION	0
 #define PY_MICRO_VERSION	0
-#define PY_RELEASE_LEVEL	PY_RELEASE_LEVEL_ALPHA
-#define PY_RELEASE_SERIAL	5
+#define PY_RELEASE_LEVEL	PY_RELEASE_LEVEL_BETA
+#define PY_RELEASE_SERIAL	1
 
 /* Version as a string */
-#define PY_VERSION      	"3.0a5+"
+#define PY_VERSION      	"3.0b1+"
 /*--end constants--*/
 
 /* Subversion Revision number of this file (not of the repository) */

Modified: python/branches/py3k-urllib/Include/pymem.h
==============================================================================
--- python/branches/py3k-urllib/Include/pymem.h	(original)
+++ python/branches/py3k-urllib/Include/pymem.h	Tue Jul  1 06:02:29 2008
@@ -85,14 +85,18 @@
  */
 
 #define PyMem_New(type, n) \
-	( (type *) PyMem_Malloc((n) * sizeof(type)) )
+  ( assert((n) <= PY_SIZE_MAX / sizeof(type)) , \
+	( (type *) PyMem_Malloc((n) * sizeof(type)) ) )
 #define PyMem_NEW(type, n) \
-	( (type *) PyMem_MALLOC((n) * sizeof(type)) )
+  ( assert((n) <= PY_SIZE_MAX / sizeof(type)) , \
+	( (type *) PyMem_MALLOC((n) * sizeof(type)) ) )
 
 #define PyMem_Resize(p, type, n) \
-	( (p) = (type *) PyMem_Realloc((p), (n) * sizeof(type)) )
+  ( assert((n) <= PY_SIZE_MAX / sizeof(type)) , \
+	( (p) = (type *) PyMem_Realloc((p), (n) * sizeof(type)) ) )
 #define PyMem_RESIZE(p, type, n) \
-	( (p) = (type *) PyMem_REALLOC((p), (n) * sizeof(type)) )
+  ( assert((n) <= PY_SIZE_MAX / sizeof(type)) , \
+	( (p) = (type *) PyMem_REALLOC((p), (n) * sizeof(type)) ) )
 
 /* PyMem{Del,DEL} are left over from ancient days, and shouldn't be used
  * anymore.  They're just confusing aliases for PyMem_{Free,FREE} now.

Modified: python/branches/py3k-urllib/Include/pyport.h
==============================================================================
--- python/branches/py3k-urllib/Include/pyport.h	(original)
+++ python/branches/py3k-urllib/Include/pyport.h	Tue Jul  1 06:02:29 2008
@@ -106,6 +106,17 @@
 #   error "Python needs a typedef for Py_ssize_t in pyport.h."
 #endif
 
+/* Largest possible value of size_t.
+   SIZE_MAX is part of C99, so it might be defined on some
+   platforms. If it is not defined, (size_t)-1 is a portable
+   definition for C89, due to the way signed->unsigned 
+   conversion is defined. */
+#ifdef SIZE_MAX
+#define PY_SIZE_MAX SIZE_MAX
+#else
+#define PY_SIZE_MAX ((size_t)-1)
+#endif
+
 /* Largest positive value of type Py_ssize_t. */
 #define PY_SSIZE_T_MAX ((Py_ssize_t)(((size_t)-1)>>1))
 /* Smallest negative value of type Py_ssize_t. */

Modified: python/branches/py3k-urllib/Include/unicodeobject.h
==============================================================================
--- python/branches/py3k-urllib/Include/unicodeobject.h	(original)
+++ python/branches/py3k-urllib/Include/unicodeobject.h	Tue Jul  1 06:02:29 2008
@@ -1458,8 +1458,8 @@
    see Objects/stringlib/localeutil.h */
 
 PyAPI_FUNC(int) _PyUnicode_InsertThousandsGrouping(Py_UNICODE *buffer,
-						  Py_ssize_t len,
-						  Py_UNICODE *plast,
+						  Py_ssize_t n_buffer,
+						  Py_ssize_t n_digits,
 						  Py_ssize_t buf_size,
 						  Py_ssize_t *count,
 						  int append_zero_char);

Modified: python/branches/py3k-urllib/Lib/distutils/__init__.py
==============================================================================
--- python/branches/py3k-urllib/Lib/distutils/__init__.py	(original)
+++ python/branches/py3k-urllib/Lib/distutils/__init__.py	Tue Jul  1 06:02:29 2008
@@ -20,5 +20,5 @@
 #
 
 #--start constants--
-__version__ = "3.0a5"
+__version__ = "3.0b1"
 #--end constants--

Modified: python/branches/py3k-urllib/Lib/http/cookiejar.py
==============================================================================
--- python/branches/py3k-urllib/Lib/http/cookiejar.py	(original)
+++ python/branches/py3k-urllib/Lib/http/cookiejar.py	Tue Jul  1 06:02:29 2008
@@ -1305,7 +1305,7 @@
         return attrs
 
     def add_cookie_header(self, request):
-        """Add correct Cookie: header to request (urllib2.Request object).
+        """Add correct Cookie: header to request (urllib.request.Request object).
 
         The Cookie2 header is also added unless policy.hide_cookie2 is true.
 

Modified: python/branches/py3k-urllib/Lib/http/server.py
==============================================================================
--- python/branches/py3k-urllib/Lib/http/server.py	(original)
+++ python/branches/py3k-urllib/Lib/http/server.py	Tue Jul  1 06:02:29 2008
@@ -13,9 +13,7 @@
 This class implements GET and POST requests to cgi-bin scripts.
 
 If the os.fork() function is not present (e.g. on Windows),
-os.popen2() is used as a fallback, with slightly altered semantics; if
-that function is not present either (e.g. on Macintosh), only Python
-scripts are supported, and they are executed by the current process.
+subprocess.Popen() is used as a fallback, with slightly altered semantics.
 
 In all cases, the implementation is intentionally naive -- all
 requests are executed synchronously.
@@ -826,8 +824,6 @@
 
     # Determine platform specifics
     have_fork = hasattr(os, 'fork')
-    have_popen2 = hasattr(os, 'popen2')
-    have_popen3 = hasattr(os, 'popen3')
 
     # Make rfile unbuffered -- we need to read one line and then pass
     # the rest to a subprocess, so we can't use buffered input.
@@ -929,10 +925,6 @@
             return
         ispy = self.is_python(scriptname)
         if not ispy:
-            if not (self.have_fork or self.have_popen2 or self.have_popen3):
-                self.send_error(403, "CGI script is not a Python script (%r)" %
-                                scriptname)
-                return
             if not self.is_executable(scriptfile):
                 self.send_error(403, "CGI script is not executable (%r)" %
                                 scriptname)
@@ -1041,13 +1033,9 @@
                 self.server.handle_error(self.request, self.client_address)
                 os._exit(127)
 
-        elif self.have_popen2 or self.have_popen3:
-            # Windows -- use popen2 or popen3 to create a subprocess
-            import shutil
-            if self.have_popen3:
-                popenx = os.popen3
-            else:
-                popenx = os.popen2
+        else:
+            # Non-Unix -- use subprocess
+            import subprocess
             cmdline = scriptfile
             if self.is_python(scriptfile):
                 interp = sys.executable
@@ -1062,54 +1050,26 @@
                 nbytes = int(length)
             except (TypeError, ValueError):
                 nbytes = 0
-            files = popenx(cmdline, 'b')
-            fi = files[0]
-            fo = files[1]
-            if self.have_popen3:
-                fe = files[2]
+            p = subprocess.Popen(cmdline,
+                                 stdin=subprocess.PIPE,
+                                 stdout=subprocess.PIPE,
+                                 stderr=subprocess.PIPE,
+                                 )
             if self.command.lower() == "post" and nbytes > 0:
                 data = self.rfile.read(nbytes)
-                fi.write(data)
+            else:
+                data = None
             # throw away additional data [see bug #427345]
             while select.select([self.rfile._sock], [], [], 0)[0]:
                 if not self.rfile._sock.recv(1):
                     break
-            fi.close()
-            shutil.copyfileobj(fo, self.wfile)
-            if self.have_popen3:
-                errors = fe.read()
-                fe.close()
-                if errors:
-                    self.log_error('%s', errors)
-            sts = fo.close()
-            if sts:
-                self.log_error("CGI script exit status %#x", sts)
-            else:
-                self.log_message("CGI script exited OK")
-
-        else:
-            # Other O.S. -- execute script in this process
-            save_argv = sys.argv
-            save_stdin = sys.stdin
-            save_stdout = sys.stdout
-            save_stderr = sys.stderr
-            try:
-                save_cwd = os.getcwd()
-                try:
-                    sys.argv = [scriptfile]
-                    if '=' not in decoded_query:
-                        sys.argv.append(decoded_query)
-                    sys.stdout = self.wfile
-                    sys.stdin = self.rfile
-                    exec(open(scriptfile).read(), {"__name__": "__main__"})
-                finally:
-                    sys.argv = save_argv
-                    sys.stdin = save_stdin
-                    sys.stdout = save_stdout
-                    sys.stderr = save_stderr
-                    os.chdir(save_cwd)
-            except SystemExit as sts:
-                self.log_error("CGI script exit status %s", str(sts))
+            stdout, stderr = p.communicate(data)
+            self.wfile.write(stdout)
+            if stderr:
+                self.log_error('%s', stderr)
+            status = p.returncode
+            if status:
+                self.log_error("CGI script exit status %#x", status)
             else:
                 self.log_message("CGI script exited OK")
 

Modified: python/branches/py3k-urllib/Lib/idlelib/idlever.py
==============================================================================
--- python/branches/py3k-urllib/Lib/idlelib/idlever.py	(original)
+++ python/branches/py3k-urllib/Lib/idlelib/idlever.py	Tue Jul  1 06:02:29 2008
@@ -1 +1 @@
-IDLE_VERSION = "3.0a5"
+IDLE_VERSION = "3.0b1"

Modified: python/branches/py3k-urllib/Lib/lib2to3/refactor.py
==============================================================================
--- python/branches/py3k-urllib/Lib/lib2to3/refactor.py	(original)
+++ python/branches/py3k-urllib/Lib/lib2to3/refactor.py	Tue Jul  1 06:02:29 2008
@@ -172,7 +172,9 @@
           want a pre-order AST traversal, and post_order is the list that want
           post-order traversal.
         """
-        fixer_pkg = ".".join(self.fixer_dir.split(os.path.sep))
+        fixer_pkg = self.fixer_dir.replace(os.path.sep, ".")
+        if os.path.altsep:
+            fixer_pkg = fixer_pkg.replace(os.path.altsep, ".")
         pre_order_fixers = []
         post_order_fixers = []
         fix_names = self.options.fix

Modified: python/branches/py3k-urllib/Lib/logging/__init__.py
==============================================================================
--- python/branches/py3k-urllib/Lib/logging/__init__.py	(original)
+++ python/branches/py3k-urllib/Lib/logging/__init__.py	Tue Jul  1 06:02:29 2008
@@ -731,7 +731,7 @@
         """
         Flushes the stream.
         """
-        if self.stream:
+        if self.stream and hasattr(self.stream, "flush"):
             self.stream.flush()
 
     def emit(self, record):
@@ -787,7 +787,8 @@
         """
         if self.stream:
             self.flush()
-            self.stream.close()
+            if hasattr(self.stream, "close"):
+                self.stream.close()
             StreamHandler.close(self)
             self.stream = None
 

Modified: python/branches/py3k-urllib/Lib/logging/handlers.py
==============================================================================
--- python/branches/py3k-urllib/Lib/logging/handlers.py	(original)
+++ python/branches/py3k-urllib/Lib/logging/handlers.py	Tue Jul  1 06:02:29 2008
@@ -1002,11 +1002,11 @@
         Send the record to the Web server as an URL-encoded dictionary
         """
         try:
-            import http.client, urllib
+            import http.client, urllib.parse
             host = self.host
             h = http.client.HTTP(host)
             url = self.url
-            data = urllib.urlencode(self.mapLogRecord(record))
+            data = urllib.parse.urlencode(self.mapLogRecord(record))
             if self.method == "GET":
                 if (url.find('?') >= 0):
                     sep = '&'

Modified: python/branches/py3k-urllib/Lib/multiprocessing/connection.py
==============================================================================
--- python/branches/py3k-urllib/Lib/multiprocessing/connection.py	(original)
+++ python/branches/py3k-urllib/Lib/multiprocessing/connection.py	Tue Jul  1 06:02:29 2008
@@ -352,14 +352,9 @@
 
 MESSAGE_LENGTH = 20
 
-CHALLENGE = '#CHALLENGE#'
-WELCOME = '#WELCOME#'
-FAILURE = '#FAILURE#'
-
-if sys.version_info >= (3, 0):         # XXX can use bytes literals in 2.6/3.0
-    CHALLENGE = CHALLENGE.encode('ascii')
-    WELCOME = WELCOME.encode('ascii')
-    FAILURE = FAILURE.encode('ascii')
+CHALLENGE = b'#CHALLENGE#'
+WELCOME = b'#WELCOME#'
+FAILURE = b'#FAILURE#'
 
 def deliver_challenge(connection, authkey):
     import hmac

Modified: python/branches/py3k-urllib/Lib/multiprocessing/managers.py
==============================================================================
--- python/branches/py3k-urllib/Lib/multiprocessing/managers.py	(original)
+++ python/branches/py3k-urllib/Lib/multiprocessing/managers.py	Tue Jul  1 06:02:29 2008
@@ -33,15 +33,6 @@
     from pickle import PicklingError
 
 #
-#
-#
-
-try:
-    bytes
-except NameError:
-    bytes = str                  # XXX not needed in Py2.6 and Py3.0
-
-#
 # Register some things for pickling
 #
 
@@ -50,7 +41,7 @@
 copyreg.pickle(array.array, reduce_array)
 
 view_types = [type(getattr({}, name)()) for name in ('items','keys','values')]
-if view_types[0] is not list:       # XXX only needed in Py3.0
+if view_types[0] is not list:       # only needed in Py3.0
     def rebuild_as_list(obj):
         return list, (list(obj),)
     for view_type in view_types:
@@ -939,14 +930,11 @@
 #
 
 class IteratorProxy(BaseProxy):
-    # XXX remove methods for Py3.0 and Py2.6
-    _exposed_ = ('__next__', 'next', 'send', 'throw', 'close')
+    _exposed_ = ('__next__', 'send', 'throw', 'close')
     def __iter__(self):
         return self
     def __next__(self, *args):
         return self._callmethod('__next__', args)
-    def next(self, *args):
-        return self._callmethod('next', args)
     def send(self, *args):
         return self._callmethod('send', args)
     def throw(self, *args):

Modified: python/branches/py3k-urllib/Lib/multiprocessing/process.py
==============================================================================
--- python/branches/py3k-urllib/Lib/multiprocessing/process.py	(original)
+++ python/branches/py3k-urllib/Lib/multiprocessing/process.py	Tue Jul  1 06:02:29 2008
@@ -26,11 +26,6 @@
 except OSError:
     ORIGINAL_DIR = None
 
-try:
-    bytes
-except NameError:
-    bytes = str                  # XXX not needed in Py2.6 and Py3.0
-
 #
 # Public functions
 #

Modified: python/branches/py3k-urllib/Lib/multiprocessing/sharedctypes.py
==============================================================================
--- python/branches/py3k-urllib/Lib/multiprocessing/sharedctypes.py	(original)
+++ python/branches/py3k-urllib/Lib/multiprocessing/sharedctypes.py	Tue Jul  1 06:02:29 2008
@@ -62,13 +62,10 @@
         result.__init__(*size_or_initializer)
         return result
 
-def Value(typecode_or_type, *args, **kwds):
+def Value(typecode_or_type, *args, lock=None):
     '''
     Return a synchronization wrapper for a Value
     '''
-    lock = kwds.pop('lock', None)
-    if kwds:
-        raise ValueError('unrecognized keyword argument(s): %s' % list(kwds.keys()))
     obj = RawValue(typecode_or_type, *args)
     if lock is None:
         lock = RLock()

Modified: python/branches/py3k-urllib/Lib/nturl2path.py
==============================================================================
--- python/branches/py3k-urllib/Lib/nturl2path.py	(original)
+++ python/branches/py3k-urllib/Lib/nturl2path.py	Tue Jul  1 06:02:29 2008
@@ -7,7 +7,7 @@
     # ///C|/foo/bar/spam.foo
     # becomes
     # C:\foo\bar\spam.foo
-    import string, urllib
+    import string, urllib.parse
     # Windows itself uses ":" even in URLs.
     url = url.replace(':', '|')
     if not '|' in url:
@@ -19,7 +19,7 @@
             url = url[2:]
         components = url.split('/')
         # make sure not to convert quoted slashes :-)
-        return urllib.unquote('\\'.join(components))
+        return urllib.parse.unquote('\\'.join(components))
     comp = url.split('|')
     if len(comp) != 2 or comp[0][-1] not in string.ascii_letters:
         error = 'Bad URL: ' + url
@@ -29,7 +29,7 @@
     path = drive + ':'
     for  comp in components:
         if comp:
-            path = path + '\\' + urllib.unquote(comp)
+            path = path + '\\' + urllib.parse.unquote(comp)
     return path
 
 def pathname2url(p):
@@ -39,7 +39,7 @@
     # C:\foo\bar\spam.foo
     # becomes
     # ///C|/foo/bar/spam.foo
-    import urllib
+    import urllib.parse
     if not ':' in p:
         # No drive specifier, just convert slashes and quote the name
         if p[:2] == '\\\\':
@@ -48,16 +48,16 @@
         # (notice doubling of slashes at the start of the path)
             p = '\\\\' + p
         components = p.split('\\')
-        return urllib.quote('/'.join(components))
+        return urllib.parse.quote('/'.join(components))
     comp = p.split(':')
     if len(comp) != 2 or len(comp[0]) > 1:
         error = 'Bad path: ' + p
         raise IOError(error)
 
-    drive = urllib.quote(comp[0].upper())
+    drive = urllib.parse.quote(comp[0].upper())
     components = comp[1].split('\\')
     path = '///' + drive + '|'
     for comp in components:
         if comp:
-            path = path + '/' + urllib.quote(comp)
+            path = path + '/' + urllib.parse.quote(comp)
     return path

Modified: python/branches/py3k-urllib/Lib/platform.py
==============================================================================
--- python/branches/py3k-urllib/Lib/platform.py	(original)
+++ python/branches/py3k-urllib/Lib/platform.py	Tue Jul  1 06:02:29 2008
@@ -1066,22 +1066,29 @@
 
     """
     global _uname_cache
+    no_os_uname = 0
 
     if _uname_cache is not None:
         return _uname_cache
 
+    processor = ''
+
     # Get some infos from the builtin os.uname API...
     try:
         system,node,release,version,machine = os.uname()
-
     except AttributeError:
-        # Hmm, no uname... we'll have to poke around the system then.
-        system = sys.platform
-        release = ''
-        version = ''
-        node = _node()
-        machine = ''
-        processor = ''
+        no_os_uname = 1
+
+    if no_os_uname or not filter(None, (system, node, release, version, machine)):
+        # Hmm, no there is either no uname or uname has returned
+        #'unknowns'... we'll have to poke around the system then.
+        if no_os_uname:
+            system = sys.platform
+            release = ''
+            version = ''
+            node = _node()
+            machine = ''
+
         use_syscmd_ver = 1
 
         # Try win32_ver() on win32 platforms
@@ -1093,8 +1100,10 @@
             # available on Win XP and later; see
             # http://support.microsoft.com/kb/888731 and
             # http://www.geocities.com/rick_lively/MANUALS/ENV/MSWIN/PROCESSI.HTM
-            machine = os.environ.get('PROCESSOR_ARCHITECTURE', '')
-            processor = os.environ.get('PROCESSOR_IDENTIFIER', machine)
+            if not machine:
+                machine = os.environ.get('PROCESSOR_ARCHITECTURE', '')
+            if not processor:
+                processor = os.environ.get('PROCESSOR_IDENTIFIER', machine)
 
         # Try the 'ver' system command available on some
         # platforms
@@ -1136,30 +1145,28 @@
             release,(version,stage,nonrel),machine = mac_ver()
             system = 'MacOS'
 
-    else:
-        # System specific extensions
-        if system == 'OpenVMS':
-            # OpenVMS seems to have release and version mixed up
-            if not release or release == '0':
-                release = version
-                version = ''
-            # Get processor information
-            try:
-                import vms_lib
-            except ImportError:
-                pass
-            else:
-                csid, cpu_number = vms_lib.getsyi('SYI$_CPU',0)
-                if (cpu_number >= 128):
-                    processor = 'Alpha'
-                else:
-                    processor = 'VAX'
+    # System specific extensions
+    if system == 'OpenVMS':
+        # OpenVMS seems to have release and version mixed up
+        if not release or release == '0':
+            release = version
+            version = ''
+        # Get processor information
+        try:
+            import vms_lib
+        except ImportError:
+            pass
         else:
-            # Get processor information from the uname system command
-            processor = _syscmd_uname('-p','')
+            csid, cpu_number = vms_lib.getsyi('SYI$_CPU',0)
+            if (cpu_number >= 128):
+                processor = 'Alpha'
+            else:
+                processor = 'VAX'
+    if not processor:
+        # Get processor information from the uname system command
+        processor = _syscmd_uname('-p','')
 
-    # 'unknown' is not really any useful as information; we'll convert
-    # it to '' which is more portable
+    #If any unknowns still exist, replace them with ''s, which are more portable
     if system == 'unknown':
         system = ''
     if node == 'unknown':

Modified: python/branches/py3k-urllib/Lib/pydoc.py
==============================================================================
--- python/branches/py3k-urllib/Lib/pydoc.py	(original)
+++ python/branches/py3k-urllib/Lib/pydoc.py	Tue Jul  1 06:02:29 2008
@@ -1870,16 +1870,25 @@
             else:
                 loader = importer.find_module(modname)
                 if hasattr(loader,'get_source'):
+                    try:
+                        source = loader.get_source(modname)
+                    except UnicodeDecodeError:
+                        if onerror:
+                            onerror(modname)
+                        continue
                     import io
-                    desc = source_synopsis(
-                        io.StringIO(loader.get_source(modname))
-                    ) or ''
+                    desc = source_synopsis(io.StringIO(source)) or ''
                     if hasattr(loader,'get_filename'):
                         path = loader.get_filename(modname)
                     else:
                         path = None
                 else:
-                    module = loader.load_module(modname)
+                    try:
+                        module = loader.load_module(modname)
+                    except ImportError:
+                        if onerror:
+                            onerror(modname)
+                        continue
                     desc = (module.__doc__ or '').splitlines()[0]
                     path = getattr(module,'__file__',None)
                 name = modname + ' - ' + desc
@@ -1895,10 +1904,12 @@
         if modname[-9:] == '.__init__':
             modname = modname[:-9] + ' (package)'
         print(modname, desc and '- ' + desc)
+    def onerror(modname):
+        pass
     try: import warnings
     except ImportError: pass
     else: warnings.filterwarnings('ignore') # ignore problems during import
-    ModuleScanner().run(callback, key)
+    ModuleScanner().run(callback, key, onerror=onerror)
 
 # --------------------------------------------------- web browser interface
 

Modified: python/branches/py3k-urllib/Lib/ssl.py
==============================================================================
--- python/branches/py3k-urllib/Lib/ssl.py	(original)
+++ python/branches/py3k-urllib/Lib/ssl.py	Tue Jul  1 06:02:29 2008
@@ -215,13 +215,13 @@
         else:
             return socket.send(self, data, flags)
 
-    def send_to(self, data, addr, flags=0):
+    def sendto(self, data, addr, flags=0):
         self._checkClosed()
         if self._sslobj:
-            raise ValueError("send_to not allowed on instances of %s" %
+            raise ValueError("sendto not allowed on instances of %s" %
                              self.__class__)
         else:
-            return socket.send_to(self, data, addr, flags)
+            return socket.sendto(self, data, addr, flags)
 
     def sendall(self, data, flags=0):
         self._checkClosed()
@@ -276,13 +276,13 @@
         else:
             return socket.recv_into(self, buffer, nbytes, flags)
 
-    def recv_from(self, addr, buflen=1024, flags=0):
+    def recvfrom(self, addr, buflen=1024, flags=0):
         self._checkClosed()
         if self._sslobj:
-            raise ValueError("recv_from not allowed on instances of %s" %
+            raise ValueError("recvfrom not allowed on instances of %s" %
                              self.__class__)
         else:
-            return socket.recv_from(self, addr, buflen, flags)
+            return socket.recvfrom(self, addr, buflen, flags)
 
     def pending(self):
         self._checkClosed()

Modified: python/branches/py3k-urllib/Lib/test/crashers/loosing_mro_ref.py
==============================================================================
--- python/branches/py3k-urllib/Lib/test/crashers/loosing_mro_ref.py	(original)
+++ python/branches/py3k-urllib/Lib/test/crashers/loosing_mro_ref.py	Tue Jul  1 06:02:29 2008
@@ -27,10 +27,9 @@
 class Base2(object):
     mykey = 'from Base2'
 
-class X(Base):
-    # you can't add a non-string key to X.__dict__, but it can be
-    # there from the beginning :-)
-    locals()[MyKey()] = 5
+# you can't add a non-string key to X.__dict__, but it can be
+# there from the beginning :-)
+X = type('X', (Base,), {MyKey(): 5})
 
 print(X.mykey)
 # I get a segfault, or a slightly wrong assertion error in a debug build.

Modified: python/branches/py3k-urllib/Lib/test/ieee754.txt
==============================================================================
--- python/branches/py3k-urllib/Lib/test/ieee754.txt	(original)
+++ python/branches/py3k-urllib/Lib/test/ieee754.txt	Tue Jul  1 06:02:29 2008
@@ -127,31 +127,31 @@
 >>> sin(INF)
 Traceback (most recent call last):
 ...
-ValueError: math domain error (invalid argument)
+ValueError: math domain error
 >>> sin(NINF)
 Traceback (most recent call last):
 ...
-ValueError: math domain error (invalid argument)
+ValueError: math domain error
 >>> sin(NAN)
 nan
 >>> cos(INF)
 Traceback (most recent call last):
 ...
-ValueError: math domain error (invalid argument)
+ValueError: math domain error
 >>> cos(NINF)
 Traceback (most recent call last):
 ...
-ValueError: math domain error (invalid argument)
+ValueError: math domain error
 >>> cos(NAN)
 nan
 >>> tan(INF)
 Traceback (most recent call last):
 ...
-ValueError: math domain error (invalid argument)
+ValueError: math domain error
 >>> tan(NINF)
 Traceback (most recent call last):
 ...
-ValueError: math domain error (invalid argument)
+ValueError: math domain error
 >>> tan(NAN)
 nan
 
@@ -169,11 +169,11 @@
 >>> asin(INF), asin(NINF)
 Traceback (most recent call last):
 ...
-ValueError: math domain error (invalid argument)
+ValueError: math domain error
 >>> acos(INF), acos(NINF)
 Traceback (most recent call last):
 ...
-ValueError: math domain error (invalid argument)
+ValueError: math domain error
 >>> equal(atan(INF), PI/2), equal(atan(NINF), -PI/2)
 (True, True)
 

Modified: python/branches/py3k-urllib/Lib/test/regrtest.py
==============================================================================
--- python/branches/py3k-urllib/Lib/test/regrtest.py	(original)
+++ python/branches/py3k-urllib/Lib/test/regrtest.py	Tue Jul  1 06:02:29 2008
@@ -870,7 +870,6 @@
         test_crypt
         test_curses
         test_dbm
-        test_dl
         test_fcntl
         test_fork1
         test_epoll
@@ -879,7 +878,6 @@
         test_ioctl
         test_largefile
         test_kqueue
-        test_mhlib
         test_openpty
         test_ossaudiodev
         test_pipes
@@ -897,7 +895,6 @@
     'linux2':
         """
         test_curses
-        test_dl
         test_largefile
         test_kqueue
         test_ossaudiodev
@@ -911,7 +908,6 @@
         test_crypt
         test_curses
         test_dbm
-        test_dl
         test_fcntl
         test_fork1
         test_epoll
@@ -936,7 +932,6 @@
     'unixware7':
         """
         test_bsddb
-        test_dl
         test_epoll
         test_largefile
         test_kqueue
@@ -949,7 +944,6 @@
     'openunix8':
         """
         test_bsddb
-        test_dl
         test_epoll
         test_largefile
         test_kqueue
@@ -963,7 +957,6 @@
         """
         test_asynchat
         test_bsddb
-        test_dl
         test_fork1
         test_epoll
         test_gettext
@@ -1012,7 +1005,6 @@
         """
         test_bsddb
         test_curses
-        test_dl
         test_epoll
         test_dbm_gnu
         test_gzip
@@ -1029,7 +1021,6 @@
     'atheos':
         """
         test_curses
-        test_dl
         test_dbm_gnu
         test_epoll
         test_largefile
@@ -1058,11 +1049,9 @@
         test_audioop
         test_bsddb3
         test_curses
-        test_dl
         test_epoll
         test_kqueue
         test_largefile
-        test_mhlib
         test_mmap
         test_openpty
         test_ossaudiodev
@@ -1090,7 +1079,6 @@
         test_bsddb
         test_bsddb3
         test_bz2
-        test_dl
         test_epoll
         test_dbm_gnu
         test_gzip
@@ -1105,7 +1093,6 @@
         test_bsddb
         test_bsddb3
         test_ctypes
-        test_dl
         test_epoll
         test_dbm_gnu
         test_locale
@@ -1120,7 +1107,6 @@
         test_bsddb3
         test_ctypes
         test_curses
-        test_dl
         test_epoll
         test_dbm_gnu
         test_locale
@@ -1164,13 +1150,6 @@
             if test_timeout.skip_expected:
                 self.expected.add('test_timeout')
 
-            if not sys.platform in ("mac", "darwin"):
-                MAC_ONLY = ["test_macostools", "test_aepack",
-                            "test_plistlib", "test_scriptpackages",
-                            "test_applesingle"]
-                for skip in MAC_ONLY:
-                    self.expected.add(skip)
-
             if sys.platform != "win32":
                 # test_sqlite is only reliable on Windows where the library
                 # is distributed with Python

Modified: python/branches/py3k-urllib/Lib/test/test_array.py
==============================================================================
--- python/branches/py3k-urllib/Lib/test/test_array.py	(original)
+++ python/branches/py3k-urllib/Lib/test/test_array.py	Tue Jul  1 06:02:29 2008
@@ -962,6 +962,23 @@
 class DoubleTest(FPTest):
     typecode = 'd'
     minitemsize = 8
+
+    def test_alloc_overflow(self):
+        a = array.array('d', [-1]*65536)
+        try:
+            a *= 65536
+        except MemoryError:
+            pass
+        else:
+            self.fail("a *= 2**16 didn't raise MemoryError")
+        b = array.array('d', [ 2.71828183, 3.14159265, -1])
+        try:
+            b * 1431655766
+        except MemoryError:
+            pass
+        else:
+            self.fail("a * 1431655766 didn't raise MemoryError")
+
 tests.append(DoubleTest)
 
 def test_main(verbose=None):

Modified: python/branches/py3k-urllib/Lib/test/test_binop.py
==============================================================================
--- python/branches/py3k-urllib/Lib/test/test_binop.py	(original)
+++ python/branches/py3k-urllib/Lib/test/test_binop.py	Tue Jul  1 06:02:29 2008
@@ -301,21 +301,16 @@
         self.assertEqual(Rat(10), 10.0)
         self.assertEqual(10.0, Rat(10))
 
-    def test_future_div(self):
-        exec(future_test)
+    def test_true_div(self):
+        self.assertEqual(Rat(10, 3) / Rat(5, 7), Rat(14, 3))
+        self.assertEqual(Rat(10, 3) / 3, Rat(10, 9))
+        self.assertEqual(2 / Rat(5), Rat(2, 5))
+        self.assertEqual(3.0 * Rat(1, 2), 1.5)
+        self.assertEqual(Rat(1, 2) * 3.0, 1.5)
+        self.assertEqual(eval('1/2'), 0.5)
 
     # XXX Ran out of steam; TO DO: divmod, div, future division
 
-future_test = """
-from __future__ import division
-self.assertEqual(Rat(10, 3) / Rat(5, 7), Rat(14, 3))
-self.assertEqual(Rat(10, 3) / 3, Rat(10, 9))
-self.assertEqual(2 / Rat(5), Rat(2, 5))
-self.assertEqual(3.0 * Rat(1, 2), 1.5)
-self.assertEqual(Rat(1, 2) * 3.0, 1.5)
-self.assertEqual(eval('1/2'), 0.5)
-"""
-
 def test_main():
     support.run_unittest(RatTestCase)
 

Modified: python/branches/py3k-urllib/Lib/test/test_compile.py
==============================================================================
--- python/branches/py3k-urllib/Lib/test/test_compile.py	(original)
+++ python/branches/py3k-urllib/Lib/test/test_compile.py	Tue Jul  1 06:02:29 2008
@@ -18,21 +18,9 @@
         self.assertRaises(SyntaxError, eval, 'lambda a,a:0')
         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')
-            self.fail("duplicate arguments")
-        except SyntaxError:
-            pass
-        try:
-            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')
-            self.fail("variable is global and local")
-        except SyntaxError:
-            pass
+        self.assertRaises(SyntaxError, exec, 'def f(a, a): pass')
+        self.assertRaises(SyntaxError, exec, 'def f(a = 0, a = 1): pass')
+        self.assertRaises(SyntaxError, exec, 'def f(a): global a; a = 1')
 
     def test_syntax_error(self):
         self.assertRaises(SyntaxError, compile, "1+*3", "filename", "exec")
@@ -41,11 +29,7 @@
         self.assertRaises(SyntaxError, compile, "f(None=1)", "<string>", "exec")
 
     def test_duplicate_global_local(self):
-        try:
-            exec('def f(a): global a; a = 1')
-            self.fail("variable is global and local")
-        except SyntaxError:
-            pass
+        self.assertRaises(SyntaxError, exec, 'def f(a): global a; a = 1')
 
     def test_exec_with_general_mapping_for_locals(self):
 
@@ -76,23 +60,13 @@
         self.assertEqual(m.results, ('z', g))
         exec('z = locals()', g, m)
         self.assertEqual(m.results, ('z', m))
-        try:
-            exec('z = b', m)
-        except TypeError:
-            pass
-        else:
-            self.fail('Did not validate globals as a real dict')
+        self.assertRaises(TypeError, exec, 'z = b', m)
 
         class A:
             "Non-mapping"
             pass
         m = A()
-        try:
-            exec('z = a', g, m)
-        except TypeError:
-            pass
-        else:
-            self.fail('Did not validate locals as a mapping')
+        self.assertRaises(TypeError, exec, 'z = a', g, m)
 
         # Verify that dict subclasses work as well
         class D(dict):
@@ -129,11 +103,7 @@
         self.assertEqual(g['f'](5), 0)
 
     def test_argument_order(self):
-        try:
-            exec('def f(a=1, b): pass')
-            self.fail("non-default args after default")
-        except SyntaxError:
-            pass
+        self.assertRaises(SyntaxError, exec, 'def f(a=1, b): pass')
 
     def test_float_literals(self):
         # testing bad float literals

Modified: python/branches/py3k-urllib/Lib/test/test_grammar.py
==============================================================================
--- python/branches/py3k-urllib/Lib/test/test_grammar.py	(original)
+++ python/branches/py3k-urllib/Lib/test/test_grammar.py	Tue Jul  1 06:02:29 2008
@@ -335,6 +335,7 @@
         self.assertEquals(l5(1, 2), 5)
         self.assertEquals(l5(1, 2, 3), 6)
         check_syntax_error(self, "lambda x: x = 2")
+        check_syntax_error(self, "lambda (None,): None")
         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)

Modified: python/branches/py3k-urllib/Lib/test/test_heapq.py
==============================================================================
--- python/branches/py3k-urllib/Lib/test/test_heapq.py	(original)
+++ python/branches/py3k-urllib/Lib/test/test_heapq.py	Tue Jul  1 06:02:29 2008
@@ -198,7 +198,8 @@
     module = c_heapq
 
     def test_comparison_operator(self):
-        # Issue 3501: Make sure heapq works with both __lt__ and __le__
+        # Issue 3501: Make sure heapq works with both __lt__
+        # For python 3.0, __le__ alone is not enough
         def hsort(data, comp):
             data = [comp(x) for x in data]
             self.module.heapify(data)
@@ -211,12 +212,12 @@
         class LE:
             def __init__(self, x):
                 self.x = x
-            def __lt__(self, other):
+            def __le__(self, other):
                 return self.x >= other.x
         data = [random.random() for i in range(100)]
         target = sorted(data, reverse=True)
         self.assertEqual(hsort(data, LT), target)
-        self.assertEqual(hsort(data, LE), target)
+        self.assertRaises(TypeError, data, LE)
 
 
 #==============================================================================

Modified: python/branches/py3k-urllib/Lib/test/test_int.py
==============================================================================
--- python/branches/py3k-urllib/Lib/test/test_int.py	(original)
+++ python/branches/py3k-urllib/Lib/test/test_int.py	Tue Jul  1 06:02:29 2008
@@ -95,6 +95,9 @@
         self.assertRaises(ValueError, int, "0b", 2)
         self.assertRaises(ValueError, int, "0b", 0)
 
+        # Bug #3236: Return small longs from PyLong_FromString
+        self.assert_(int("10") is 10)
+        self.assert_(int("-1") is -1)
 
         # SF bug 1334662: int(string, base) wrong answers
         # Various representations of 2**32 evaluated to 0

Modified: python/branches/py3k-urllib/Lib/test/test_multiprocessing.py
==============================================================================
--- python/branches/py3k-urllib/Lib/test/test_multiprocessing.py	(original)
+++ python/branches/py3k-urllib/Lib/test/test_multiprocessing.py	Tue Jul  1 06:02:29 2008
@@ -1333,7 +1333,7 @@
 
         self.assertRaises(ValueError, a.send_bytes, msg, 4, -1)
 
-
+"""
 class _TestListenerClient(BaseTestCase):
 
     ALLOWED_TYPES = ('processes', 'threads')
@@ -1353,7 +1353,7 @@
             self.assertEqual(conn.recv(), 'hello')
             p.join()
             l.close()
-
+"""
 #
 # Test of sending connection and socket objects between processes
 #
@@ -1755,6 +1755,13 @@
 #
 
 def test_main(run=None):
+    if sys.platform.startswith("linux"):
+        try:
+            lock = multiprocessing.RLock()
+        except OSError:
+            from test.support import TestSkipped
+            raise TestSkipped("OSError raises on RLock creation, see issue 3111!")
+
     if run is None:
         from test.support import run_unittest as run
 

Modified: python/branches/py3k-urllib/Lib/test/test_ssl.py
==============================================================================
--- python/branches/py3k-urllib/Lib/test/test_ssl.py	(original)
+++ python/branches/py3k-urllib/Lib/test/test_ssl.py	Tue Jul  1 06:02:29 2008
@@ -529,6 +529,7 @@
                         self.send(str(data, 'ASCII', 'strict').lower().encode('ASCII', 'strict'))
 
                 def handle_close(self):
+                    self.close()
                     if support.verbose:
                         sys.stdout.write(" server:  closed connection %s\n" % self.socket)
 

Modified: python/branches/py3k-urllib/Lib/test/test_struct.py
==============================================================================
--- python/branches/py3k-urllib/Lib/test/test_struct.py	(original)
+++ python/branches/py3k-urllib/Lib/test/test_struct.py	Tue Jul  1 06:02:29 2008
@@ -8,6 +8,7 @@
 
 import sys
 ISBIGENDIAN = sys.byteorder == "big"
+IS32BIT = sys.maxsize == 0x7fffffff
 del sys
 
 try:
@@ -83,7 +84,7 @@
             self.fail("did not raise error for float coerce")
 
     def test_isbigendian(self):
-        self.assertEqual((struct.pack('=i', 1)[0] == chr(0)), ISBIGENDIAN)
+        self.assertEqual((struct.pack('=i', 1)[0] == 0), ISBIGENDIAN)
 
     def test_consistence(self):
         self.assertRaises(struct.error, struct.calcsize, 'Z')
@@ -580,6 +581,11 @@
             for c in [b'\x01', b'\x7f', b'\xff', b'\x0f', b'\xf0']:
                 self.assertTrue(struct.unpack('>?', c)[0])
 
+    if IS32BIT:
+        def test_crasher(self):
+            self.assertRaises(MemoryError, struct.pack, "357913941b", "a")
+
+
 def test_main():
     run_unittest(StructTest)
 

Modified: python/branches/py3k-urllib/Lib/test/test_sys.py
==============================================================================
--- python/branches/py3k-urllib/Lib/test/test_sys.py	(original)
+++ python/branches/py3k-urllib/Lib/test/test_sys.py	Tue Jul  1 06:02:29 2008
@@ -1,6 +1,7 @@
 # -*- coding: iso-8859-1 -*-
 import unittest, test.support
 import sys, io, os
+import struct
 
 class SysModuleTest(unittest.TestCase):
 
@@ -373,13 +374,16 @@
 class SizeofTest(unittest.TestCase):
 
     def setUp(self):
-        import struct
+        self.c = len(struct.pack('c', ' '))
+        self.H = len(struct.pack('H', 0))
         self.i = len(struct.pack('i', 0))
         self.l = len(struct.pack('l', 0))
-        self.p = len(struct.pack('P', 0))
-        self.headersize = self.l + self.p
+        self.P = len(struct.pack('P', 0))
+        # due to missing size_t information from struct, it is assumed that
+        # sizeof(Py_ssize_t) = sizeof(void*)
+        self.header = 'PP'
         if hasattr(sys, "gettotalrefcount"):
-            self.headersize += 2 * self.p
+            self.header += '2P'
         self.file = open(test.support.TESTFN, 'wb')
 
     def tearDown(self):
@@ -395,52 +399,38 @@
         else:
             self.assertEqual(result, size, msg + str(size))
 
-    def align(self, value):
-        mod = value % self.p
-        if mod != 0:
-            return value - mod + self.p
-        else:
-            return value
-
-    def test_align(self):
-        self.assertEqual(self.align(0) % self.p, 0)
-        self.assertEqual(self.align(1) % self.p, 0)
-        self.assertEqual(self.align(3) % self.p, 0)
-        self.assertEqual(self.align(4) % self.p, 0)
-        self.assertEqual(self.align(7) % self.p, 0)
-        self.assertEqual(self.align(8) % self.p, 0)
-        self.assertEqual(self.align(9) % self.p, 0)
+    def calcsize(self, fmt):
+        """Wrapper around struct.calcsize which enforces the alignment of the
+        end of a structure to the alignment requirement of pointer.
+
+        Note: This wrapper should only be used if a pointer member is included
+        and no member with a size larger than a pointer exists.
+        """
+        return struct.calcsize(fmt + '0P')
 
     def test_standardtypes(self):
-        i = self.i
-        l = self.l
-        p = self.p
-        h = self.headersize
-        # bool
-        self.check_sizeof(True, h + 2*l)
-        # bytearray
-        self.check_sizeof(bytes(), h + self.align(i) + l + p)
+        h = self.header
+        size = self.calcsize
         # cell
         def get_cell():
             x = 42
             def inner():
                 return x
             return inner
-        self.check_sizeof(get_cell().__closure__[0], h + p)
+        self.check_sizeof(get_cell().__closure__[0], size(h + 'P'))
         # code
-        self.check_sizeof(get_cell().__code__, h + self.align(5*i) + 8*p +\
-                           self.align(i) + 2*p)
+        self.check_sizeof(get_cell().__code__, size(h + '5i8Pi2P'))
         # complex
-        self.check_sizeof(complex(0,1), h + 2*8)
+        self.check_sizeof(complex(0,1), size(h + '2d'))
         # enumerate
-        self.check_sizeof(enumerate([]), h + l + 3*p)
+        self.check_sizeof(enumerate([]), size(h + 'l3P'))
         # reverse
-        self.check_sizeof(reversed(''), h + l + p )
+        self.check_sizeof(reversed(''), size(h + 'PP'))
         # float
-        self.check_sizeof(float(0), h + 8)
+        self.check_sizeof(float(0), size(h + 'd'))
         # function
         def func(): pass
-        self.check_sizeof(func, h + 11 * p)
+        self.check_sizeof(func, size(h + '11P'))
         class c():
             @staticmethod
             def foo():
@@ -449,58 +439,47 @@
             def bar(cls):
                 pass
             # staticmethod
-            self.check_sizeof(foo, h + l)
+            self.check_sizeof(foo, size(h + 'P'))
             # classmethod
-            self.check_sizeof(bar, h + l)
+            self.check_sizeof(bar, size(h + 'P'))
         # generator
         def get_gen(): yield 1
-        self.check_sizeof(get_gen(), h + p + self.align(i) + 2*p)
+        self.check_sizeof(get_gen(), size(h + 'Pi2P'))
         # builtin_function_or_method
-        self.check_sizeof(abs, h + 3*p)
+        self.check_sizeof(abs, size(h + '3P'))
         # module
-        self.check_sizeof(unittest, h + 3*p)
+        self.check_sizeof(unittest, size(h + '3P'))
         # range
-        self.check_sizeof(range(1), h + 3*p)
+        self.check_sizeof(range(1), size(h + '3P'))
         # slice
-        self.check_sizeof(slice(0), h + 3*p)
+        self.check_sizeof(slice(0), size(h + '3P'))
 
-        h += l
+        h += 'P'
+        # bool
+        self.check_sizeof(True, size(h + 'H'))
         # new-style class
         class class_newstyle(object):
             def method():
                 pass
         # type (PyTypeObject + PyNumberMethods + PyMappingMethods +
         #       PySequenceMethods + PyBufferProcs)
-        self.check_sizeof(class_newstyle, h +
-                          # PyTypeObject
-                          p + 2*l + 15*p + l + 4*p + l + 9*p + l + 11*p +
-                          self.align(4) +
-                          # PyNumberMethods
-                          16*p + self.align(i) + 17*p +
-                          3*p  + # PyMappingMethods
-                          10*p + # PySequenceMethods
-                          2*p  + # PyBufferProcs
-                          2*p)   # *ht_name and *ht_slots
+        self.check_sizeof(class_newstyle, size(h + 'P2P15Pl4PP9PP11PI') +\
+                                          size('16Pi17P 3P 10P 2P 2P'))
 
     def test_specialtypes(self):
-        i = self.i
-        l = self.l
-        p = self.p
-        h = self.headersize
+        h = self.header
+        size = self.calcsize
         # dict
-        self.check_sizeof({}, h + 3*l + 3*p + 8*(l + 2*p))
+        self.check_sizeof({}, size(h + '3P2P') + 8*size('P2P'))
         longdict = {1:1, 2:2, 3:3, 4:4, 5:5, 6:6, 7:7, 8:8}
-        self.check_sizeof(longdict, h + 3*l + 3*p + 8*(l + 2*p) + 16*(l + 2*p))
-        # list
-        self.check_sizeof([], h + l + p + l)
-        self.check_sizeof([1, 2, 3], h + l + p + l + 3*l)
+        self.check_sizeof(longdict, size(h + '3P2P') + (8+16)*size('P2P'))
         # unicode
         usize = len('\0'.encode('unicode-internal'))
         samples = ['', '1'*100]
         # we need to test for both sizes, because we don't know if the string
         # has been cached
         for s in samples:
-            basicsize =  h + l + p + l + l + p + usize * (len(s) + 1)
+            basicsize =  size(h + 'PPliP') + usize * (len(s) + 1)
             defenc = bytes(s, 'ascii')
             self.check_sizeof(s, basicsize,
                               size2=basicsize + sys.getsizeof(defenc))
@@ -512,14 +491,20 @@
             finally:
                 self.check_sizeof(s, basicsize + sys.getsizeof(defenc))
 
-        h += l
+        h += 'P'
+        # list
+        self.check_sizeof([], size(h + 'PP'))
+        self.check_sizeof([1, 2, 3], size(h + 'PP') + 3*self.P)
         # long
-        self.check_sizeof(0, h + self.align(2))
-        self.check_sizeof(1, h + self.align(2))
-        self.check_sizeof(-1, h + self.align(2))
-        self.check_sizeof(32768, h + self.align(2) + 2)
-        self.check_sizeof(32768*32768-1, h + self.align(2) + 2)
-        self.check_sizeof(32768*32768, h + self.align(2) + 4)
+        self.check_sizeof(0, size(h + 'H'))
+        self.check_sizeof(1, size(h + 'H'))
+        self.check_sizeof(-1, size(h + 'H'))
+        self.check_sizeof(32768, size(h + 'H') + self.H)
+        self.check_sizeof(32768*32768-1, size(h + 'H') + self.H)
+        self.check_sizeof(32768*32768, size(h + 'H') + 2*self.H)
+        # tuple
+        self.check_sizeof((), size(h))
+        self.check_sizeof((1,2,3), size(h) + 3*self.P)
 
 
 def test_main():

Modified: python/branches/py3k-urllib/Lib/test/test_threading_local.py
==============================================================================
--- python/branches/py3k-urllib/Lib/test/test_threading_local.py	(original)
+++ python/branches/py3k-urllib/Lib/test/test_threading_local.py	Tue Jul  1 06:02:29 2008
@@ -42,6 +42,32 @@
         deadlist = [weak for weak in weaklist if weak() is None]
         self.assert_(len(deadlist) in (n-1, n), (n, len(deadlist)))
 
+    def test_derived(self):
+        # Issue 3088: if there is a threads switch inside the __init__
+        # of a threading.local derived class, the per-thread dictionary
+        # is created but not correctly set on the object.
+        # The first member set may be bogus.
+        import time
+        class Local(threading.local):
+            def __init__(self):
+                time.sleep(0.01)
+        local = Local()
+
+        def f(i):
+            local.x = i
+            # Simply check that the variable is correctly set
+            self.assertEqual(local.x, i)
+
+        threads= []
+        for i in range(10):
+            t = threading.Thread(target=f, args=(i,))
+            t.start()
+            threads.append(t)
+
+        for t in threads:
+            t.join()
+
+
 def test_main():
     suite = unittest.TestSuite()
     suite.addTest(DocTestSuite('_threading_local'))

Modified: python/branches/py3k-urllib/Lib/test/test_types.py
==============================================================================
--- python/branches/py3k-urllib/Lib/test/test_types.py	(original)
+++ python/branches/py3k-urllib/Lib/test/test_types.py	Tue Jul  1 06:02:29 2008
@@ -428,6 +428,14 @@
             # move to the next integer to test
             x = x // 10
 
+        rfmt = ">20n"
+        lfmt = "<20n"
+        cfmt = "^20n"
+        for x in (1234, 12345, 123456, 1234567, 12345678, 123456789, 1234567890, 12345678900):
+            self.assertEqual(len(format(0, rfmt)), len(format(x, rfmt)))
+            self.assertEqual(len(format(0, lfmt)), len(format(x, lfmt)))
+            self.assertEqual(len(format(0, cfmt)), len(format(x, cfmt)))
+
     def test_float__format__(self):
         # these should be rewritten to use both format(x, spec) and
         # x.__format__(spec)

Modified: python/branches/py3k-urllib/Lib/test/test_warnings.py
==============================================================================
--- python/branches/py3k-urllib/Lib/test/test_warnings.py	(original)
+++ python/branches/py3k-urllib/Lib/test/test_warnings.py	Tue Jul  1 06:02:29 2008
@@ -301,6 +301,21 @@
             warning_tests.__name__ = module_name
             sys.argv = argv
 
+    def test_warn_explicit_type_errors(self):
+        # warn_explicit() shoud error out gracefully if it is given objects
+        # of the wrong types.
+        # lineno is expected to be an integer.
+        self.assertRaises(TypeError, self.module.warn_explicit,
+                            None, UserWarning, None, None)
+        # Either 'message' needs to be an instance of Warning or 'category'
+        # needs to be a subclass.
+        self.assertRaises(TypeError, self.module.warn_explicit,
+                            None, None, None, 1)
+        # 'registry' must be a dict or None.
+        self.assertRaises((TypeError, AttributeError),
+                            self.module.warn_explicit,
+                            None, Warning, None, 1, registry=42)
+
 
 
 class CWarnTests(BaseTest, WarnTests):

Modified: python/branches/py3k-urllib/Lib/urllib/request.py
==============================================================================
--- python/branches/py3k-urllib/Lib/urllib/request.py	(original)
+++ python/branches/py3k-urllib/Lib/urllib/request.py	Tue Jul  1 06:02:29 2008
@@ -47,24 +47,25 @@
 
 Example usage:
 
-import urllib2
+import urllib.request
 
 # set up authentication info
-authinfo = urllib2.HTTPBasicAuthHandler()
+authinfo = urllib.request.HTTPBasicAuthHandler()
 authinfo.add_password(realm='PDQ Application',
                       uri='https://mahler:8092/site-updates.py',
                       user='klem',
                       passwd='geheim$parole')
 
-proxy_support = urllib2.ProxyHandler({"http" : "http://ahad-haam:3128"})
+proxy_support = urllib.request.ProxyHandler({"http" : "http://ahad-haam:3128"})
 
 # build a new opener that adds authentication and caching FTP handlers
-opener = urllib2.build_opener(proxy_support, authinfo, urllib2.CacheFTPHandler)
+opener = urllib.request.build_opener(proxy_support, authinfo,
+                                     urllib.request.CacheFTPHandler)
 
 # install it
-urllib2.install_opener(opener)
+urllib.request.install_opener(opener)
 
-f = urllib2.urlopen('http://www.python.org/')
+f = urllib.request.urlopen('http://www.python.org/')
 """
 
 # XXX issues:
@@ -105,7 +106,6 @@
     _have_ssl = False
 else:
     _have_ssl = True
-assert _have_ssl
 
 # used in User-Agent header sent
 __version__ = sys.version[:3]
@@ -417,8 +417,6 @@
                        FTPHandler, FileHandler, HTTPErrorProcessor]
     if hasattr(http.client, "HTTPSConnection"):
         default_classes.append(HTTPSHandler)
-    else:
-        import pdb; pdb.set_trace()
     skip = set()
     for klass in default_classes:
         for check in handlers:
@@ -505,7 +503,7 @@
 
         # Strictly (according to RFC 2616), 301 or 302 in response to
         # a POST MUST NOT cause a redirection without confirmation
-        # from the user (of urllib2, in this case).  In practice,
+        # from the user (of urllib.request, in this case).  In practice,
         # essentially all clients do redirect in this case, so we do
         # the same.
         # be conciliant with URIs containing a space
@@ -658,7 +656,7 @@
         if proxy_type is None:
             proxy_type = orig_type
         if user and password:
-            user_pass = '%s:%s' % (unquote(user),
+            user_pass = '%s:%s' % (urllib.parse.unquote(user),
                                    urllib.parse.unquote(password))
             creds = base64.b64encode(user_pass.encode()).decode("ascii")
             req.add_header('Proxy-authorization', 'Basic ' + creds)
@@ -811,7 +809,7 @@
 
     def http_error_407(self, req, fp, code, msg, headers):
         # http_error_auth_reqed requires that there is no userinfo component in
-        # authority.  Assume there isn't one, since urllib2 does not (and
+        # authority.  Assume there isn't one, since urllib.request does not (and
         # should not, RFC 3986 s. 3.2.1) support requests for URLs containing
         # userinfo.
         authority = req.get_host()
@@ -1197,7 +1195,7 @@
                 return urllib.response.addinfourl(open(localfile, 'rb'),
                                                   headers, 'file:'+file)
         except OSError as msg:
-            # urllib2 users shouldn't expect OSErrors coming from urlopen()
+            # users shouldn't expect OSErrors coming from urlopen()
             raise urllib.error.URLError(msg)
         raise urllib.error.URLError('file not on local host')
 

Modified: python/branches/py3k-urllib/Lib/warnings.py
==============================================================================
--- python/branches/py3k-urllib/Lib/warnings.py	(original)
+++ python/branches/py3k-urllib/Lib/warnings.py	Tue Jul  1 06:02:29 2008
@@ -188,6 +188,7 @@
 
 def warn_explicit(message, category, filename, lineno,
                   module=None, registry=None, module_globals=None):
+    lineno = int(lineno)
     if module is None:
         module = filename or "<unknown>"
         if module[-3:].lower() == ".py":

Modified: python/branches/py3k-urllib/Mac/BuildScript/build-installer.py
==============================================================================
--- python/branches/py3k-urllib/Mac/BuildScript/build-installer.py	(original)
+++ python/branches/py3k-urllib/Mac/BuildScript/build-installer.py	Tue Jul  1 06:02:29 2008
@@ -9,7 +9,8 @@
 
 Usage: see USAGE variable in the script.
 """
-import platform, os, sys, getopt, textwrap, shutil, urllib2, stat, time, pwd
+import platform, os, sys, getopt, textwrap, shutil, stat, time, pwd
+import urllib.request
 import grp
 
 INCLUDE_TIMESTAMP = 1
@@ -442,7 +443,7 @@
         if KNOWNSIZES.get(url) == size:
             print("Using existing file for", url)
             return
-    fpIn = urllib2.urlopen(url)
+    fpIn = urllib.request.urlopen(url)
     fpOut = open(fname, 'wb')
     block = fpIn.read(10240)
     try:

Modified: python/branches/py3k-urllib/Mac/Makefile.in
==============================================================================
--- python/branches/py3k-urllib/Mac/Makefile.in	(original)
+++ python/branches/py3k-urllib/Mac/Makefile.in	Tue Jul  1 06:02:29 2008
@@ -43,7 +43,6 @@
 	Resources/English.lproj/Documentation/ide
 DOCDIR=$(srcdir)/Resources/app/Resources/English.lproj/Documentation
 DOCINDEX=$(DOCDIR)/"Documentation idx"
-CACHERSRC=$(srcdir)/scripts/cachersrc.py
 compileall=$(srcdir)/../Lib/compileall.py
 
 installapps: install_Python install_BuildApplet install_PythonLauncher \
@@ -225,7 +224,6 @@
 	done
 
 
-	$(RUNSHARED) $(BUILDPYTHON) $(CACHERSRC) -v $(DESTDIR)$(MACLIBDEST) $(DESTDIR)$(MACTOOLSDEST)
 	$(RUNSHARED) $(BUILDPYTHON) -Wi $(compileall) -d $(MACTOOLSDEST) -x badsyntax $(DESTDIR)$(MACTOOLSDEST)
 	$(RUNSHARED) $(BUILDPYTHON) -O -Wi $(compileall) -d $(MACTOOLSDEST) -x badsyntax $(DESTDIR)$(MACTOOLSDEST)
 

Modified: python/branches/py3k-urllib/Makefile.pre.in
==============================================================================
--- python/branches/py3k-urllib/Makefile.pre.in	(original)
+++ python/branches/py3k-urllib/Makefile.pre.in	Tue Jul  1 06:02:29 2008
@@ -814,6 +814,7 @@
 		ctypes ctypes/test ctypes/macholib idlelib idlelib/Icons \
 		distutils distutils/command distutils/tests $(XMLLIBSUBDIRS) \
 		setuptools setuptools/command setuptools/tests setuptools.egg-info \
+		multiprocessing multiprocessing/dummy \
 		curses $(MACHDEPS)
 libinstall:	build_all $(srcdir)/Lib/$(PLATDIR)
 	@for i in $(SCRIPTDIR) $(LIBDEST); \

Modified: python/branches/py3k-urllib/Misc/ACKS
==============================================================================
--- python/branches/py3k-urllib/Misc/ACKS	(original)
+++ python/branches/py3k-urllib/Misc/ACKS	Tue Jul  1 06:02:29 2008
@@ -486,6 +486,7 @@
 Gustavo Niemeyer
 Oscar Nierstrasz
 Hrvoje Niksic
+Jesse Noller
 Bill Noon
 Stefan Norberg
 Tim Northover
@@ -502,6 +503,7 @@
 Douglas Orr
 Denis S. Otkidach
 Michael Otteneder
+R. M. Oudkerk
 Russel Owen
 Ondrej Palkovsky
 Mike Pall
@@ -673,6 +675,7 @@
 Monty Taylor
 Amy Taylor
 Tobias Thelen
+James Thomas
 Robin Thomas
 Eric Tiedemann
 Tracy Tims

Modified: python/branches/py3k-urllib/Misc/NEWS
==============================================================================
--- python/branches/py3k-urllib/Misc/NEWS	(original)
+++ python/branches/py3k-urllib/Misc/NEWS	Tue Jul  1 06:02:29 2008
@@ -4,14 +4,36 @@
 
 (editors: check NEWS.help for information about editing NEWS using ReST.)
 
+What's new in Python 3.0b2?
+===========================
+
+*Release date: XX-XXX-2008*
+
+Core and Builtins
+-----------------
+
+- Issue #3236: Return small longs from PyLong_FromString.
+
+Library
+-------
+
+- Issue #3145: help("modules whatever") failed when trying to load the source
+  code of every single module of the standard library, including invalid files
+  used in the test suite.
+
 What's new in Python 3.0b1?
 ===========================
 
-*Release date: XX-June-2008*
+*Release date: 18-Jun-2008*
 
 Core and Builtins
 -----------------
 
+- Issue #3211: warnings.warn_explicit() did not guard against its 'registry'
+  argument being anything other than a dict or None. Also fixed a bug in error
+  handling when 'message' and 'category' were both set to None, triggering a
+  bus error.
+
 - Issue #3100: Corrected a crash on deallocation of a subclassed weakref which
   holds the last (strong) reference to its referent.
 
@@ -81,6 +103,17 @@
 Library
 -------
 
+- Patch #3133: http.server.CGIHTTPRequestHandler did not work on windows.
+
+- a new ``urllib`` package was created.  It consists of code from
+  ``urllib``, ``urllib2``, ``urlparse``, and ``robotparser``.  The old
+  modules have all been removed.  The new package has five submodules:
+  ``urllib.parse``, ``urllib.request``, ``urllib.response``,
+  ``urllib.error``, and ``urllib.robotparser``.  The
+  ``urllib.request.urlopen()`` function uses the url opener from
+  ``urllib2``.  (Note that the unittests have not been renamed for the
+  beta, but they will be renamed in the future.)
+
 - rfc822 has been removed in favor of the email package.
 
 - mimetools has been removed in favor of the email package.

Modified: python/branches/py3k-urllib/Misc/RPM/python-3.0.spec
==============================================================================
--- python/branches/py3k-urllib/Misc/RPM/python-3.0.spec	(original)
+++ python/branches/py3k-urllib/Misc/RPM/python-3.0.spec	Tue Jul  1 06:02:29 2008
@@ -34,7 +34,7 @@
 
 %define name python
 #--start constants--
-%define version 3.0a5
+%define version 3.0b1
 %define libver 3.0
 #--end constants--
 %define release 1pydotorg

Modified: python/branches/py3k-urllib/Misc/cheatsheet
==============================================================================
--- python/branches/py3k-urllib/Misc/cheatsheet	(original)
+++ python/branches/py3k-urllib/Misc/cheatsheet	Tue Jul  1 06:02:29 2008
@@ -1889,7 +1889,6 @@
 re               Regular Expressions.
 reprlib          Redo repr() but with limits on most sizes.
 rlcompleter      Word completion for GNU readline 2.0.
-robotparser      Parse robots.txt files, useful for web spiders.
 sched            A generally useful event scheduler class.
 shelve           Manage shelves of pickled objects.
 shlex            Lexical analyzer class for simple shell-like syntaxes.
@@ -1920,8 +1919,9 @@
 types            Define names for all type symbols in the std interpreter.
 tzparse          Parse a timezone specification.
 unicodedata      Interface to unicode properties.
-urllib           Open an arbitrary URL.
-urlparse         Parse URLs according to latest draft of standard.
+urllib.parse     Parse URLs according to latest draft of standard.
+urllib.request   Open an arbitrary URL.
+urllib.robotparser  Parse robots.txt files, useful for web spiders.
 user             Hook to allow user-specified customization code to run.
 uu               UUencode/UUdecode.
 unittest         Utilities for implementing unit testing.

Modified: python/branches/py3k-urllib/Misc/developers.txt
==============================================================================
--- python/branches/py3k-urllib/Misc/developers.txt	(original)
+++ python/branches/py3k-urllib/Misc/developers.txt	Tue Jul  1 06:02:29 2008
@@ -17,6 +17,9 @@
 Permissions History
 -------------------
 
+- Jesse Noller was given SVN access on 16 June 2008 by Georg Brandl,
+  for work on the multiprocessing module.
+
 - Gregor Lingl was given SVN access on 10 June 2008 by MvL,
   for work on the turtle module.
 

Modified: python/branches/py3k-urllib/Modules/_csv.c
==============================================================================
--- python/branches/py3k-urllib/Modules/_csv.c	(original)
+++ python/branches/py3k-urllib/Modules/_csv.c	Tue Jul  1 06:02:29 2008
@@ -533,6 +533,10 @@
 		self->field = PyMem_New(Py_UNICODE, self->field_size);
 	}
 	else {
+		if (self->field_size > INT_MAX / 2) {
+			PyErr_NoMemory();
+			return 0;
+		} 
 		self->field_size *= 2;
 		self->field = PyMem_Resize(self->field, Py_UNICODE,
 					   self->field_size);
@@ -1038,6 +1042,12 @@
 static int
 join_check_rec_size(WriterObj *self, int rec_len)
 {
+
+	if (rec_len < 0 || rec_len > INT_MAX - MEM_INCR) {
+		PyErr_NoMemory();
+		return 0;
+	}
+
 	if (rec_len > self->rec_size) {
 		if (self->rec_size == 0) {
 			self->rec_size = (rec_len / MEM_INCR + 1) * MEM_INCR;

Modified: python/branches/py3k-urllib/Modules/_ctypes/callproc.c
==============================================================================
--- python/branches/py3k-urllib/Modules/_ctypes/callproc.c	(original)
+++ python/branches/py3k-urllib/Modules/_ctypes/callproc.c	Tue Jul  1 06:02:29 2008
@@ -1815,6 +1815,8 @@
 		return NULL;
 	}
 	shape = PyTuple_New(dict->ndim);
+	if (shape == NULL)
+		return NULL;
 	for (i = 0; i < (int)dict->ndim; ++i)
 		PyTuple_SET_ITEM(shape, i, PyLong_FromSsize_t(dict->shape[i]));
 

Modified: python/branches/py3k-urllib/Modules/_heapqmodule.c
==============================================================================
--- python/branches/py3k-urllib/Modules/_heapqmodule.c	(original)
+++ python/branches/py3k-urllib/Modules/_heapqmodule.c	Tue Jul  1 06:02:29 2008
@@ -8,28 +8,10 @@
 
 #include "Python.h"
 
-/* Older implementations of heapq used Py_LE for comparisons.  Now, it uses
-   Py_LT so it will match min(), sorted(), and bisect().  Unfortunately, some
-   client code (Twisted for example) relied on Py_LE, so this little function
-   restores compatability by trying both.
-*/
 static int
 cmp_lt(PyObject *x, PyObject *y)
 {
-	int cmp;
-	static PyObject *lt = NULL;
-
-	if (lt == NULL) {
-		lt = PyUnicode_FromString("__lt__");
-		if (lt == NULL)
-			return -1;
-	}
-	if (PyObject_HasAttr(x, lt))
-		return PyObject_RichCompareBool(x, y, Py_LT);
-	cmp = PyObject_RichCompareBool(y, x, Py_LE);
-	if (cmp != -1)
-		cmp = 1 - cmp;
-	return cmp;
+	return PyObject_RichCompareBool(x, y, Py_LT);
 }
 
 static int

Modified: python/branches/py3k-urllib/Modules/_struct.c
==============================================================================
--- python/branches/py3k-urllib/Modules/_struct.c	(original)
+++ python/branches/py3k-urllib/Modules/_struct.c	Tue Jul  1 06:02:29 2008
@@ -1383,6 +1383,12 @@
 		}
 	}
 
+	/* check for overflow */
+	if ((len + 1) > (PY_SSIZE_T_MAX / sizeof(formatcode))) {
+		PyErr_NoMemory();
+		return -1;
+	}
+
 	self->s_size = size;
 	self->s_len = len;
 	codes = PyMem_MALLOC((len + 1) * sizeof(formatcode));

Modified: python/branches/py3k-urllib/Modules/_threadmodule.c
==============================================================================
--- python/branches/py3k-urllib/Modules/_threadmodule.c	(original)
+++ python/branches/py3k-urllib/Modules/_threadmodule.c	Tue Jul  1 06:02:29 2008
@@ -293,7 +293,10 @@
 		}
 		
 	}
-	else if (self->dict != ldict) {
+
+	/* The call to tp_init above may have caused another thread to run.
+	   Install our ldict again. */
+	if (self->dict != ldict) {
 		Py_CLEAR(self->dict);
 		Py_INCREF(ldict);
 		self->dict = ldict;

Modified: python/branches/py3k-urllib/Modules/arraymodule.c
==============================================================================
--- python/branches/py3k-urllib/Modules/arraymodule.c	(original)
+++ python/branches/py3k-urllib/Modules/arraymodule.c	Tue Jul  1 06:02:29 2008
@@ -421,6 +421,9 @@
 	if (op == NULL) {
 		return NULL;
 	}
+	op->ob_descr = descr;
+	op->allocated = size;
+	op->weakreflist = NULL;
 	Py_SIZE(op) = size;
 	if (size <= 0) {
 		op->ob_item = NULL;
@@ -428,13 +431,10 @@
 	else {
 		op->ob_item = PyMem_NEW(char, nbytes);
 		if (op->ob_item == NULL) {
-			PyObject_Del(op);
+			Py_DECREF(op);
 			return PyErr_NoMemory();
 		}
 	}
-	op->ob_descr = descr;
-	op->allocated = size;
-	op->weakreflist = NULL;
         op->ob_exports = 0;
 	return (PyObject *) op;
 }
@@ -642,6 +642,9 @@
 		PyErr_BadArgument();
 		return NULL;
 	}
+	if (Py_SIZE(a) > PY_SSIZE_T_MAX - Py_SIZE(b)) {
+		return PyErr_NoMemory();
+	}
 	size = Py_SIZE(a) + Py_SIZE(b);
 	np = (arrayobject *) newarrayobject(&Arraytype, size, a->ob_descr);
 	if (np == NULL) {
@@ -664,6 +667,9 @@
 	Py_ssize_t nbytes;
 	if (n < 0)
 		n = 0;
+	if ((Py_SIZE(a) != 0) && (n > PY_SSIZE_T_MAX / Py_SIZE(a))) {
+		return PyErr_NoMemory();
+	}
 	size = Py_SIZE(a) * n;
 	np = (arrayobject *) newarrayobject(&Arraytype, size, a->ob_descr);
 	if (np == NULL)
@@ -808,11 +814,15 @@
 			     "can only extend with array of same kind");
 		return -1;
 	}
+	if ((Py_SIZE(self) > PY_SSIZE_T_MAX - Py_SIZE(b)) ||
+		((Py_SIZE(self) + Py_SIZE(b)) > PY_SSIZE_T_MAX / self->ob_descr->itemsize)) {
+		PyErr_NoMemory();
+		return -1;
+	}
 	size = Py_SIZE(self) + Py_SIZE(b);
         PyMem_RESIZE(self->ob_item, char, size*self->ob_descr->itemsize);
         if (self->ob_item == NULL) {
-                PyObject_Del(self);
-                PyErr_NoMemory();
+		PyErr_NoMemory();
 		return -1;
         }
 	memcpy(self->ob_item + Py_SIZE(self)*self->ob_descr->itemsize,
@@ -849,6 +859,10 @@
 		if (n < 0)
 			n = 0;
 		items = self->ob_item;
+		if ((self->ob_descr->itemsize != 0) && 
+			(Py_SIZE(self) > PY_SSIZE_T_MAX / self->ob_descr->itemsize)) {
+			return PyErr_NoMemory();
+		}
 		size = Py_SIZE(self) * self->ob_descr->itemsize;
 		if (n == 0) {
 			PyMem_FREE(items);
@@ -857,6 +871,9 @@
 			self->allocated = 0;
 		}
 		else {
+			if (size > PY_SSIZE_T_MAX / n) {
+				return PyErr_NoMemory();
+			}
 			PyMem_Resize(items, char, n * size);
 			if (items == NULL)
 				return PyErr_NoMemory();
@@ -1138,6 +1155,10 @@
 		Py_INCREF(dict);
 	}
 	if (Py_SIZE(array) > 0) {
+		if (array->ob_descr->itemsize 
+				> PY_SSIZE_T_MAX / Py_SIZE(array)) {
+			return PyErr_NoMemory();
+		}
 		result = Py_BuildValue("O(cy#)O", 
 			Py_TYPE(array), 
 			array->ob_descr->typecode,
@@ -1311,6 +1332,9 @@
 			if ((*self->ob_descr->setitem)(self,
 					Py_SIZE(self) - n + i, v) != 0) {
 				Py_SIZE(self) -= n;
+				if (itemsize && (Py_SIZE(self) > PY_SSIZE_T_MAX / itemsize)) {
+					return PyErr_NoMemory();
+				}
 				PyMem_RESIZE(item, char,
 					          Py_SIZE(self) * itemsize);
 				self->ob_item = item;
@@ -1369,6 +1393,10 @@
 	n = n / itemsize;
 	if (n > 0) {
 		char *item = self->ob_item;
+		if ((n > PY_SSIZE_T_MAX - Py_SIZE(self)) ||
+			((Py_SIZE(self) + n) > PY_SSIZE_T_MAX / itemsize)) {
+				return PyErr_NoMemory();
+		}
 		PyMem_RESIZE(item, char, (Py_SIZE(self) + n) * itemsize);
 		if (item == NULL) {
 			PyErr_NoMemory();
@@ -1394,8 +1422,12 @@
 static PyObject *
 array_tostring(arrayobject *self, PyObject *unused)
 {
-	return PyBytes_FromStringAndSize(self->ob_item,
-                                         Py_SIZE(self) * self->ob_descr->itemsize);
+	if (Py_SIZE(self) <= PY_SSIZE_T_MAX / self->ob_descr->itemsize) {
+		return PyBytes_FromStringAndSize(self->ob_item,
+				    Py_SIZE(self) * self->ob_descr->itemsize);
+	} else {
+		return PyErr_NoMemory();
+	}
 }
 
 PyDoc_STRVAR(tostring_doc,
@@ -1424,6 +1456,9 @@
 	}
 	if (n > 0) {
 		Py_UNICODE *item = (Py_UNICODE *) self->ob_item;
+		if (Py_SIZE(self) > PY_SSIZE_T_MAX - n) {
+			return PyErr_NoMemory();
+		}
 		PyMem_RESIZE(item, Py_UNICODE, Py_SIZE(self) + n);
 		if (item == NULL) {
 			PyErr_NoMemory();

Modified: python/branches/py3k-urllib/Modules/audioop.c
==============================================================================
--- python/branches/py3k-urllib/Modules/audioop.c	(original)
+++ python/branches/py3k-urllib/Modules/audioop.c	Tue Jul  1 06:02:29 2008
@@ -829,7 +829,7 @@
 audioop_tostereo(PyObject *self, PyObject *args)
 {
         signed char *cp, *ncp;
-        int len, size, val1, val2, val = 0;
+        int len, new_len, size, val1, val2, val = 0;
         double fac1, fac2, fval, maxval;
         PyObject *rv;
         int i;
@@ -846,7 +846,14 @@
                 return 0;
         }
     
-        rv = PyBytes_FromStringAndSize(NULL, len*2);
+        new_len = len*2;
+        if (new_len < 0) {
+                PyErr_SetString(PyExc_MemoryError,
+                                "not enough memory for output buffer");
+                return 0;
+        }
+
+        rv = PyBytes_FromStringAndSize(NULL, new_len);
         if ( rv == 0 )
                 return 0;
         ncp = (signed char *)PyBytes_AsString(rv);
@@ -1009,7 +1016,7 @@
 {
         signed char *cp;
         unsigned char *ncp;
-        int len, size, size2, val = 0;
+        int len, new_len, size, size2, val = 0;
         PyObject *rv;
         int i, j;
 
@@ -1023,7 +1030,13 @@
                 return 0;
         }
     
-        rv = PyBytes_FromStringAndSize(NULL, (len/size)*size2);
+        new_len = (len/size)*size2;
+        if (new_len < 0) {
+                PyErr_SetString(PyExc_MemoryError,
+                                "not enough memory for output buffer");
+                return 0;
+        }
+        rv = PyBytes_FromStringAndSize(NULL, new_len);
         if ( rv == 0 )
                 return 0;
         ncp = (unsigned char *)PyBytes_AsString(rv);
@@ -1059,6 +1072,7 @@
         int chan, d, *prev_i, *cur_i, cur_o;
         PyObject *state, *samps, *str, *rv = NULL;
         int bytes_per_frame;
+        size_t alloc_size;
 
         weightA = 1;
         weightB = 0;
@@ -1101,8 +1115,14 @@
         inrate /= d;
         outrate /= d;
 
-        prev_i = (int *) malloc(nchannels * sizeof(int));
-        cur_i = (int *) malloc(nchannels * sizeof(int));
+        alloc_size = sizeof(int) * (unsigned)nchannels;
+        if (alloc_size < nchannels) {
+                PyErr_SetString(PyExc_MemoryError,
+                                "not enough memory for output buffer");
+                return 0;
+        }
+        prev_i = (int *) malloc(alloc_size);
+        cur_i = (int *) malloc(alloc_size);
         if (prev_i == NULL || cur_i == NULL) {
                 (void) PyErr_NoMemory();
                 goto exit;
@@ -1275,7 +1295,7 @@
         unsigned char *cp;
         unsigned char cval;
         signed char *ncp;
-        int len, size, val;
+        int len, new_len, size, val;
         PyObject *rv;
         int i;
 
@@ -1288,12 +1308,18 @@
                 return 0;
         }
     
-        rv = PyBytes_FromStringAndSize(NULL, len*size);
+        new_len = len*size;
+        if (new_len < 0) {
+                PyErr_SetString(PyExc_MemoryError,
+                                "not enough memory for output buffer");
+                return 0;
+        }
+        rv = PyBytes_FromStringAndSize(NULL, new_len);
         if ( rv == 0 )
                 return 0;
         ncp = (signed char *)PyBytes_AsString(rv);
     
-        for ( i=0; i < len*size; i += size ) {
+        for ( i=0; i < new_len; i += size ) {
                 cval = *cp++;
                 val = st_ulaw2linear16(cval);
         
@@ -1343,7 +1369,7 @@
         unsigned char *cp;
         unsigned char cval;
         signed char *ncp;
-        int len, size, val;
+        int len, new_len, size, val;
         PyObject *rv;
         int i;
 
@@ -1356,12 +1382,18 @@
                 return 0;
         }
     
-        rv = PyBytes_FromStringAndSize(NULL, len*size);
+        new_len = len*size;
+        if (new_len < 0) {
+                PyErr_SetString(PyExc_MemoryError,
+                                "not enough memory for output buffer");
+                return 0;
+        }
+        rv = PyBytes_FromStringAndSize(NULL, new_len);
         if ( rv == 0 )
                 return 0;
         ncp = (signed char *)PyBytes_AsString(rv);
     
-        for ( i=0; i < len*size; i += size ) {
+        for ( i=0; i < new_len; i += size ) {
                 cval = *cp++;
                 val = st_alaw2linear16(cval);
         
@@ -1486,7 +1518,7 @@
 {
         signed char *cp;
         signed char *ncp;
-        int len, size, valpred, step, delta, index, sign, vpdiff;
+        int len, new_len, size, valpred, step, delta, index, sign, vpdiff;
         PyObject *rv, *str, *state;
         int i, inputbuffer = 0, bufferstep;
 
@@ -1508,7 +1540,13 @@
         } else if ( !PyArg_ParseTuple(state, "ii", &valpred, &index) )
                 return 0;
     
-        str = PyBytes_FromStringAndSize(NULL, len*size*2);
+        new_len = len*size*2;
+        if (new_len < 0) {
+                PyErr_SetString(PyExc_MemoryError,
+                                "not enough memory for output buffer");
+                return 0;
+        }
+        str = PyBytes_FromStringAndSize(NULL, new_len);
         if ( str == 0 )
                 return 0;
         ncp = (signed char *)PyBytes_AsString(str);
@@ -1516,7 +1554,7 @@
         step = stepsizeTable[index];
         bufferstep = 0;
     
-        for ( i=0; i < len*size*2; i += size ) {
+        for ( i=0; i < new_len; i += size ) {
                 /* Step 1 - get the delta value and compute next index */
                 if ( bufferstep ) {
                         delta = inputbuffer & 0xf;

Modified: python/branches/py3k-urllib/Modules/binascii.c
==============================================================================
--- python/branches/py3k-urllib/Modules/binascii.c	(original)
+++ python/branches/py3k-urllib/Modules/binascii.c	Tue Jul  1 06:02:29 2008
@@ -198,6 +198,8 @@
 	if ( !PyArg_ParseTuple(args, "t#:a2b_uu", &ascii_data, &ascii_len) )
 		return NULL;
 
+	assert(ascii_len >= 0);
+
 	/* First byte: binary data length (in bytes) */
 	bin_len = (*ascii_data++ - ' ') & 077;
 	ascii_len--;
@@ -355,6 +357,11 @@
 	if ( !PyArg_ParseTuple(args, "t#:a2b_base64", &ascii_data, &ascii_len) )
 		return NULL;
 
+	assert(ascii_len >= 0);
+
+	if (ascii_len > PY_SSIZE_T_MAX - 3)
+		return PyErr_NoMemory();
+
 	bin_len = ((ascii_len+3)/4)*3; /* Upper bound, corrected later */
 
 	/* Allocate the buffer */
@@ -448,6 +455,9 @@
 
 	if ( !PyArg_ParseTuple(args, "s#:b2a_base64", &bin_data, &bin_len) )
 		return NULL;
+
+	assert(bin_len >= 0);
+
 	if ( bin_len > BASE64_MAXBIN ) {
 		PyErr_SetString(Error, "Too much data for base64 line");
 		return NULL;
@@ -507,6 +517,11 @@
 	if ( !PyArg_ParseTuple(args, "t#:a2b_hqx", &ascii_data, &len) )
 		return NULL;
 
+	assert(len >= 0);
+
+	if (len > PY_SSIZE_T_MAX - 2)
+		return PyErr_NoMemory();
+
 	/* Allocate a string that is too big (fixed later) 
 	   Add two to the initial length to prevent interning which
 	   would preclude subsequent resizing.  */
@@ -574,6 +589,11 @@
 	if ( !PyArg_ParseTuple(args, "s#:rlecode_hqx", &in_data, &len) )
 		return NULL;
 
+	assert(len >= 0);
+
+	if (len > PY_SSIZE_T_MAX / 2 - 2)
+		return PyErr_NoMemory();
+
 	/* Worst case: output is twice as big as input (fixed later) */
 	if ( (rv=PyBytes_FromStringAndSize(NULL, len*2+2)) == NULL )
 		return NULL;
@@ -627,6 +647,11 @@
 	if ( !PyArg_ParseTuple(args, "s#:b2a_hqx", &bin_data, &len) )
 		return NULL;
 
+	assert(len >= 0);
+
+	if (len > PY_SSIZE_T_MAX / 2 - 2)
+		return PyErr_NoMemory();
+
 	/* Allocate a buffer that is at least large enough */
 	if ( (rv=PyBytes_FromStringAndSize(NULL, len*2+2)) == NULL )
 		return NULL;
@@ -669,9 +694,13 @@
 	if ( !PyArg_ParseTuple(args, "s#:rledecode_hqx", &in_data, &in_len) )
 		return NULL;
 
+	assert(in_len >= 0);
+
 	/* Empty string is a special case */
 	if ( in_len == 0 )
 		return PyBytes_FromStringAndSize("", 0);
+	else if (in_len > PY_SSIZE_T_MAX / 2)
+		return PyErr_NoMemory();
 
 	/* Allocate a buffer of reasonable size. Resized when needed */
 	out_len = in_len*2;
@@ -697,6 +726,7 @@
 #define OUTBYTE(b) \
 	do { \
 		 if ( --out_len_left < 0 ) { \
+			  if ( out_len > PY_SSIZE_T_MAX / 2) return PyErr_NoMemory(); \
 			  if (_PyBytes_Resize(&rv, 2*out_len) < 0) \
 			    { Py_DECREF(rv); return NULL; } \
 			  out_data = (unsigned char *)PyBytes_AS_STRING(rv) \
@@ -769,7 +799,7 @@
 	if ( !PyArg_ParseTuple(args, "s#i:crc_hqx", &bin_data, &len, &crc) )
 		return NULL;
 
-	while(len--) {
+	while(len-- > 0) {
 		crc=((crc<<8)&0xff00)^crctab_hqx[((crc>>8)&0xff)^*bin_data++];
 	}
 
@@ -925,7 +955,7 @@
 		return NULL;
 
 	crc = ~ crc;
-	while (len--) {
+	while (len-- > 0) {
 		crc = crc_32_tab[(crc ^ *bin_data++) & 0xff] ^ (crc >> 8);
 		/* Note:  (crc >> 8) MUST zero fill on left */
 	}
@@ -948,6 +978,10 @@
 	if (!PyArg_ParseTuple(args, "s#:b2a_hex", &argbuf, &arglen))
 		return NULL;
 
+	assert(arglen >= 0);
+	if (arglen > PY_SSIZE_T_MAX / 2)
+		return PyErr_NoMemory();
+
 	retval = PyBytes_FromStringAndSize(NULL, arglen*2);
 	if (!retval)
 		return NULL;
@@ -999,6 +1033,8 @@
 	if (!PyArg_ParseTuple(args, "s#:a2b_hex", &argbuf, &arglen))
 		return NULL;
 
+	assert(arglen >= 0);
+
 	/* XXX What should we do about strings with an odd length?  Should
 	 * we add an implicit leading zero, or a trailing zero?  For now,
 	 * raise an exception.

Modified: python/branches/py3k-urllib/Modules/cjkcodecs/multibytecodec.c
==============================================================================
--- python/branches/py3k-urllib/Modules/cjkcodecs/multibytecodec.c	(original)
+++ python/branches/py3k-urllib/Modules/cjkcodecs/multibytecodec.c	Tue Jul  1 06:02:29 2008
@@ -172,13 +172,17 @@
 static int
 expand_encodebuffer(MultibyteEncodeBuffer *buf, Py_ssize_t esize)
 {
-	Py_ssize_t orgpos, orgsize;
+	Py_ssize_t orgpos, orgsize, incsize;
 
 	orgpos = (Py_ssize_t)((char *)buf->outbuf -
 				PyBytes_AS_STRING(buf->outobj));
 	orgsize = PyBytes_GET_SIZE(buf->outobj);
-	if (_PyBytes_Resize(&buf->outobj, orgsize + (
-	    esize < (orgsize >> 1) ? (orgsize >> 1) | 1 : esize)) == -1)
+	incsize = (esize < (orgsize >> 1) ? (orgsize >> 1) | 1 : esize);
+
+	if (orgsize > PY_SSIZE_T_MAX - incsize)
+		return -1;
+
+	if (_PyBytes_Resize(&buf->outobj, orgsize + incsize) == -1)
 		return -1;
 
 	buf->outbuf = (unsigned char *)PyBytes_AS_STRING(buf->outobj) +orgpos;
@@ -481,6 +485,12 @@
 	buf.excobj = NULL;
 	buf.inbuf = buf.inbuf_top = *data;
 	buf.inbuf_end = buf.inbuf_top + datalen;
+
+	if (datalen > (PY_SSIZE_T_MAX - 16) / 2) {
+		PyErr_NoMemory();
+		goto errorexit;
+	}
+
 	buf.outobj = PyBytes_FromStringAndSize(NULL, datalen * 2 + 16);
 	if (buf.outobj == NULL)
 		goto errorexit;
@@ -743,6 +753,11 @@
 	origpending = ctx->pendingsize;
 
 	if (origpending > 0) {
+		if (datalen > PY_SSIZE_T_MAX - ctx->pendingsize) {
+			PyErr_NoMemory();
+			/* inbuf_tmp == NULL */
+			goto errorexit;
+		}
 		inbuf_tmp = PyMem_New(Py_UNICODE, datalen + ctx->pendingsize);
 		if (inbuf_tmp == NULL)
 			goto errorexit;
@@ -805,9 +820,10 @@
 	Py_ssize_t npendings;
 
 	npendings = (Py_ssize_t)(buf->inbuf_end - buf->inbuf);
-	if (npendings + ctx->pendingsize > MAXDECPENDING) {
-		PyErr_SetString(PyExc_UnicodeError, "pending buffer overflow");
-		return -1;
+	if (npendings + ctx->pendingsize > MAXDECPENDING ||
+		npendings > PY_SSIZE_T_MAX - ctx->pendingsize) {
+			PyErr_SetString(PyExc_UnicodeError, "pending buffer overflow");
+			return -1;
 	}
 	memcpy(ctx->pending + ctx->pendingsize, buf->inbuf, npendings);
 	ctx->pendingsize += npendings;
@@ -1009,7 +1025,7 @@
 		  PyObject *args, PyObject *kwargs)
 {
 	MultibyteDecodeBuffer buf;
-	char *data, *wdata;
+	char *data, *wdata = NULL;
 	Py_ssize_t wsize, finalsize = 0, size, origpending;
 	int final = 0;
 
@@ -1025,6 +1041,10 @@
 		wdata = data;
 	}
 	else {
+		if (size > PY_SSIZE_T_MAX - self->pendingsize) {
+			PyErr_NoMemory();
+			goto errorexit;
+		}
 		wsize = size + self->pendingsize;
 		wdata = PyMem_Malloc(wsize);
 		if (wdata == NULL)
@@ -1244,6 +1264,10 @@
 			PyObject *ctr;
 			char *ctrdata;
 
+			if (PyBytes_GET_SIZE(cres) > PY_SSIZE_T_MAX - self->pendingsize) {
+				PyErr_NoMemory();
+				goto errorexit;
+            }
 			rsize = PyBytes_GET_SIZE(cres) + self->pendingsize;
 			ctr = PyBytes_FromStringAndSize(NULL, rsize);
 			if (ctr == NULL)

Modified: python/branches/py3k-urllib/Modules/datetimemodule.c
==============================================================================
--- python/branches/py3k-urllib/Modules/datetimemodule.c	(original)
+++ python/branches/py3k-urllib/Modules/datetimemodule.c	Tue Jul  1 06:02:29 2008
@@ -1111,6 +1111,8 @@
 	char sign;
 	int none;
 
+	assert(buflen >= 1);
+
 	offset = call_utcoffset(tzinfo, tzinfoarg, &none);
 	if (offset == -1 && PyErr_Occurred())
 		return -1;
@@ -1250,6 +1252,11 @@
 	 * a new format.  Since computing the replacements for those codes
 	 * is expensive, don't unless they're actually used.
 	 */
+	if (flen > INT_MAX - 1) {
+		PyErr_NoMemory();
+		goto Done;
+	}
+
 	totalnew = flen + 1;	/* realistic if no %z/%Z */
 	newfmt = PyBytes_FromStringAndSize(NULL, totalnew);
 	if (newfmt == NULL) goto Done;

Modified: python/branches/py3k-urllib/Modules/mathmodule.c
==============================================================================
--- python/branches/py3k-urllib/Modules/mathmodule.c	(original)
+++ python/branches/py3k-urllib/Modules/mathmodule.c	Tue Jul  1 06:02:29 2008
@@ -82,12 +82,17 @@
 		 * should return a zero on underflow, and +- HUGE_VAL on
 		 * overflow, so testing the result for zero suffices to
 		 * distinguish the cases).
+		 *
+		 * On some platforms (Ubuntu/ia64) it seems that errno can be
+		 * set to ERANGE for subnormal results that do *not* underflow
+		 * to zero.  So to be safe, we'll ignore ERANGE whenever the
+		 * function result is less than one in absolute value.
 		 */
-		if (x)
+		if (fabs(x) < 1.0)
+			result = 0;
+		else
 			PyErr_SetString(PyExc_OverflowError,
 					"math range error");
-		else
-			result = 0;
 	}
 	else
                 /* Unexpected math error */
@@ -176,16 +181,16 @@
 	PyFPE_END_PROTECT(r);
 	if (Py_IS_NAN(r) && !Py_IS_NAN(x)) {
 		PyErr_SetString(PyExc_ValueError,
-				"math domain error (invalid argument)");
+				"math domain error"); /* invalid arg */
 		return NULL;
 	}
 	if (Py_IS_INFINITY(r) && Py_IS_FINITE(x)) {
 			if (can_overflow)
 				PyErr_SetString(PyExc_OverflowError,
-					"math range error (overflow)");
+					"math range error"); /* overflow */
 			else
 				PyErr_SetString(PyExc_ValueError,
-					"math domain error (singularity)");
+					"math domain error"); /* singularity */
 			return NULL;
 	}
 	if (Py_IS_FINITE(r) && errno && is_error(r))

Modified: python/branches/py3k-urllib/Objects/dictobject.c
==============================================================================
--- python/branches/py3k-urllib/Objects/dictobject.c	(original)
+++ python/branches/py3k-urllib/Objects/dictobject.c	Tue Jul  1 06:02:29 2008
@@ -1845,7 +1845,7 @@
 {
 	Py_ssize_t res;
 
-	res = sizeof(PyDictObject) + sizeof(mp->ma_table);
+	res = sizeof(PyDictObject);
 	if (mp->ma_table != mp->ma_smalltable)
 		res = res + (mp->ma_mask + 1) * sizeof(PyDictEntry);
 	return PyLong_FromSsize_t(res);

Modified: python/branches/py3k-urllib/Objects/listobject.c
==============================================================================
--- python/branches/py3k-urllib/Objects/listobject.c	(original)
+++ python/branches/py3k-urllib/Objects/listobject.c	Tue Jul  1 06:02:29 2008
@@ -45,7 +45,16 @@
 	 * system realloc().
 	 * The growth pattern is:  0, 4, 8, 16, 25, 35, 46, 58, 72, 88, ...
 	 */
-	new_allocated = (newsize >> 3) + (newsize < 9 ? 3 : 6) + newsize;
+	new_allocated = (newsize >> 3) + (newsize < 9 ? 3 : 6);
+
+	/* check for integer overflow */
+	if (new_allocated > PY_SIZE_MAX - newsize) {
+		PyErr_NoMemory();
+		return -1;
+	} else {
+		new_allocated += newsize;
+	}
+
 	if (newsize == 0)
 		new_allocated = 0;
 	items = self->ob_item;
@@ -118,8 +127,9 @@
 		return NULL;
 	}
 	nbytes = size * sizeof(PyObject *);
-	/* Check for overflow */
-	if (nbytes / sizeof(PyObject *) != (size_t)size)
+	/* Check for overflow without an actual overflow,
+	 *  which can cause compiler to optimise out */
+	if (size > PY_SIZE_MAX / sizeof(PyObject *))
 		return PyErr_NoMemory();
 	if (numfree) {
 		numfree--;
@@ -1323,6 +1333,10 @@
 	 * we don't care what's in the block.
 	 */
 	merge_freemem(ms);
+	if (need > PY_SSIZE_T_MAX / sizeof(PyObject*)) {
+		PyErr_NoMemory();
+		return -1;
+	}
 	ms->a = (PyObject **)PyMem_Malloc(need * sizeof(PyObject*));
 	if (ms->a) {
 		ms->alloced = need;
@@ -2415,6 +2429,8 @@
 				step = -step;
 			}
 
+			assert(slicelength <= PY_SIZE_MAX / sizeof(PyObject*));
+
 			garbage = (PyObject**)
 				PyMem_MALLOC(slicelength*sizeof(PyObject*));
 			if (!garbage) {

Modified: python/branches/py3k-urllib/Objects/longobject.c
==============================================================================
--- python/branches/py3k-urllib/Objects/longobject.c	(original)
+++ python/branches/py3k-urllib/Objects/longobject.c	Tue Jul  1 06:02:29 2008
@@ -1981,6 +1981,14 @@
 		goto onError;
 	if (pend)
 		*pend = str;
+	long_normalize(z);
+	if (ABS(Py_SIZE(z)) <= 1) {
+		long res = MEDIUM_VALUE(z);
+		if (-NSMALLPOSINTS <= res && res <= NSMALLPOSINTS) {
+			Py_DECREF(z);
+			return PyLong_FromLong(res);
+		}
+	}
 	return (PyObject *) z;
 
  onError:

Modified: python/branches/py3k-urllib/Objects/memoryobject.c
==============================================================================
--- python/branches/py3k-urllib/Objects/memoryobject.c	(original)
+++ python/branches/py3k-urllib/Objects/memoryobject.c	Tue Jul  1 06:02:29 2008
@@ -151,8 +151,11 @@
         char *ptr;
         void (*func)(int, Py_ssize_t *, Py_ssize_t *);
 
+        if (view->ndim > PY_SSIZE_T_MAX / sizeof(Py_ssize_t)) {
+                PyErr_NoMemory();
+                return -1;
+        }
 
-        /* XXX(nnorwitz): need to check for overflow! */
         indices = (Py_ssize_t *)PyMem_Malloc(sizeof(Py_ssize_t)*view->ndim);
         if (indices == NULL) {
                 PyErr_NoMemory();

Modified: python/branches/py3k-urllib/Objects/obmalloc.c
==============================================================================
--- python/branches/py3k-urllib/Objects/obmalloc.c	(original)
+++ python/branches/py3k-urllib/Objects/obmalloc.c	Tue Jul  1 06:02:29 2008
@@ -526,9 +526,9 @@
 		numarenas = maxarenas ? maxarenas << 1 : INITIAL_ARENA_OBJECTS;
 		if (numarenas <= maxarenas)
 			return NULL;	/* overflow */
-		nbytes = numarenas * sizeof(*arenas);
-		if (nbytes / sizeof(*arenas) != numarenas)
+		if (numarenas > PY_SIZE_MAX / sizeof(*arenas))
 			return NULL;	/* overflow */
+		nbytes = numarenas * sizeof(*arenas);
 		arenaobj = (struct arena_object *)realloc(arenas, nbytes);
 		if (arenaobj == NULL)
 			return NULL;

Modified: python/branches/py3k-urllib/Objects/stringlib/formatter.h
==============================================================================
--- python/branches/py3k-urllib/Objects/stringlib/formatter.h	(original)
+++ python/branches/py3k-urllib/Objects/stringlib/formatter.h	Tue Jul  1 06:02:29 2008
@@ -313,8 +313,8 @@
    as determined in _calc_integer_widths().  returns the pointer to
    where the digits go. */
 static STRINGLIB_CHAR *
-fill_number(STRINGLIB_CHAR *p_buf, const NumberFieldWidths *spec,
-            Py_ssize_t n_digits, STRINGLIB_CHAR fill_char)
+fill_non_digits(STRINGLIB_CHAR *p_buf, const NumberFieldWidths *spec,
+		Py_ssize_t n_digits, STRINGLIB_CHAR fill_char)
 {
     STRINGLIB_CHAR* p_digits;
 
@@ -557,18 +557,17 @@
 	pnumeric_chars += leading_chars_to_skip;
     }
 
-    /* Calculate the widths of the various leading and trailing parts */
-    calc_number_widths(&spec, sign, n_digits, format);
-
     if (format->type == 'n')
 	    /* Compute how many additional chars we need to allocate
 	       to hold the thousands grouping. */
-	    STRINGLIB_GROUPING(pnumeric_chars, n_digits,
-			       pnumeric_chars+n_digits,
+	    STRINGLIB_GROUPING(NULL, n_digits, n_digits,
 			       0, &n_grouping_chars, 0);
 
+    /* Calculate the widths of the various leading and trailing parts */
+    calc_number_widths(&spec, sign, n_digits + n_grouping_chars, format);
+
     /* Allocate a new string to hold the result */
-    result = STRINGLIB_NEW(NULL, spec.n_total + n_grouping_chars);
+    result = STRINGLIB_NEW(NULL, spec.n_total);
     if (!result)
 	goto done;
     p = STRINGLIB_STR(result);
@@ -587,21 +586,20 @@
     }
 
     /* Insert the grouping, if any, after the uppercasing of 'X', so we can
-       ensure that grouping chars won't be affeted. */
-    if (n_grouping_chars && format->type == 'n') {
+       ensure that grouping chars won't be affected. */
+    if (n_grouping_chars) {
 	    /* We know this can't fail, since we've already
 	       reserved enough space. */
 	    STRINGLIB_CHAR *pstart = p + n_leading_chars;
-	    int r = STRINGLIB_GROUPING(pstart, n_digits,
-				       pstart + n_digits,
+	    int r = STRINGLIB_GROUPING(pstart, n_digits, n_digits,
 				       spec.n_total+n_grouping_chars-n_leading_chars,
 				       NULL, 0);
 	    assert(r);
     }
 
-    /* Fill in the non-digit parts */
-    fill_number(p, &spec, n_digits,
-                format->fill_char == '\0' ? ' ' : format->fill_char);
+    /* Fill in the non-digit parts (padding, sign, etc.) */
+    fill_non_digits(p, &spec, n_digits + n_grouping_chars,
+		    format->fill_char == '\0' ? ' ' : format->fill_char);
 
 done:
     Py_XDECREF(tmp);
@@ -739,9 +737,9 @@
     if (result == NULL)
         goto done;
 
-    /* fill in the non-digit parts */
-    fill_number(STRINGLIB_STR(result), &spec, n_digits,
-                format->fill_char == '\0' ? ' ' : format->fill_char);
+    /* Fill in the non-digit parts (padding, sign, etc.) */
+    fill_non_digits(STRINGLIB_STR(result), &spec, n_digits,
+		    format->fill_char == '\0' ? ' ' : format->fill_char);
 
     /* fill in the digit parts */
     memmove(STRINGLIB_STR(result) +

Modified: python/branches/py3k-urllib/Objects/stringlib/localeutil.h
==============================================================================
--- python/branches/py3k-urllib/Objects/stringlib/localeutil.h	(original)
+++ python/branches/py3k-urllib/Objects/stringlib/localeutil.h	Tue Jul  1 06:02:29 2008
@@ -8,10 +8,9 @@
 /**
  * _Py_InsertThousandsGrouping:
  * @buffer: A pointer to the start of a string.
- * @len: The length of the string.
- * @plast: A pointer to the end of of the digits in the string.  This
- *         may be before the end of the string (if the string contains
- *         decimals, for example).
+ * @n_buffer: The length of the string.
+ * @n_digits: The number of digits in the string, in which we want
+ *            to put the grouping chars.
  * @buf_size: The maximum size of the buffer pointed to by buffer.
  * @count: If non-NULL, points to a variable that will receive the
  *         number of characters we need to insert (and no formatting
@@ -21,10 +20,11 @@
  *         string.
  *
  * Inserts thousand grouping characters (as defined in the current
- *  locale) into the string between buffer and plast.  If count is
- *  non-NULL, don't do any formatting, just count the number of
- *  characters to insert.  This is used by the caller to appropriately
- *  resize the buffer, if needed.
+ *  locale) into the string between buffer and buffer+n_digits.  If
+ *  count is non-NULL, don't do any formatting, just count the number
+ *  of characters to insert.  This is used by the caller to
+ *  appropriately resize the buffer, if needed.  If count is non-NULL,
+ *  buffer can be NULL (it is not dereferenced at all in that case).
  *
  * Return value: 0 on error, else 1.  Note that no error can occur if
  *  count is non-NULL.
@@ -34,8 +34,8 @@
  **/
 int
 _Py_InsertThousandsGrouping(STRINGLIB_CHAR *buffer,
-			    Py_ssize_t len,
-			    STRINGLIB_CHAR *plast,
+			    Py_ssize_t n_buffer,
+			    Py_ssize_t n_digits,
 			    Py_ssize_t buf_size,
 			    Py_ssize_t *count,
 			    int append_zero_char)
@@ -44,15 +44,22 @@
 	const char *grouping = locale_data->grouping;
 	const char *thousands_sep = locale_data->thousands_sep;
 	Py_ssize_t thousands_sep_len = strlen(thousands_sep);
-	STRINGLIB_CHAR *pend = buffer + len; /* current end of buffer */
-	STRINGLIB_CHAR *pmax = buffer + buf_size;       /* max of buffer */
+	STRINGLIB_CHAR *pend = NULL; /* current end of buffer */
+	STRINGLIB_CHAR *pmax = NULL; /* max of buffer */
 	char current_grouping;
+	Py_ssize_t remaining = n_digits; /* Number of chars remaining to
+					    be looked at */
 
 	/* Initialize the character count, if we're just counting. */
 	if (count)
 		*count = 0;
+	else {
+		/* We're not just counting, we're modifying buffer */
+		pend = buffer + n_buffer;
+		pmax = buffer + buf_size;
+	}
 
-	/* Starting at plast and working right-to-left, keep track of
+	/* Starting at the end and working right-to-left, keep track of
 	   what grouping needs to be added and insert that. */
 	current_grouping = *grouping++;
 
@@ -60,11 +67,11 @@
 	if (current_grouping == 0)
 		return 1;
 
-	while (plast - buffer > current_grouping) {
+	while (remaining > current_grouping) {
 		/* Always leave buffer and pend valid at the end of this
 		   loop, since we might leave with a return statement. */
 
-		plast -= current_grouping;
+		remaining -= current_grouping;
 		if (count) {
 			/* We're only counting, not touching the memory. */
 			*count += thousands_sep_len;
@@ -72,6 +79,8 @@
 		else {
 			/* Do the formatting. */
 
+			STRINGLIB_CHAR *plast = buffer + remaining;
+
 			/* Is there room to insert thousands_sep_len chars? */
 			if (pmax - pend < thousands_sep_len)
 				/* No room. */
@@ -111,7 +120,7 @@
 	if (append_zero_char) {
 		/* Append a zero character to mark the end of the string,
 		   if there's room. */
-		if (pend - plast < 1)
+		if (pend - (buffer + remaining) < 1)
 			/* No room, error. */
 			return 0;
 		*pend = 0;

Modified: python/branches/py3k-urllib/Objects/tupleobject.c
==============================================================================
--- python/branches/py3k-urllib/Objects/tupleobject.c	(original)
+++ python/branches/py3k-urllib/Objects/tupleobject.c	Tue Jul  1 06:02:29 2008
@@ -683,13 +683,25 @@
 	
 }
 
+static PyObject *
+tuple_sizeof(PyTupleObject *self)
+{
+	Py_ssize_t res;
+
+	res = PyTuple_Type.tp_basicsize + Py_SIZE(self) * sizeof(PyObject *);
+	return PyLong_FromSsize_t(res);
+}
+
 PyDoc_STRVAR(index_doc,
 "T.index(value, [start, [stop]]) -> integer -- return first index of value");
 PyDoc_STRVAR(count_doc,
 "T.count(value) -> integer -- return number of occurrences of value");
+PyDoc_STRVAR(sizeof_doc,
+"T.__sizeof__() -- size of T in memory, in bytes");
 
 static PyMethodDef tuple_methods[] = {
 	{"__getnewargs__",	(PyCFunction)tuple_getnewargs,	METH_NOARGS},
+	{"__sizeof__",	(PyCFunction)tuple_sizeof, METH_NOARGS, sizeof_doc},
 	{"index",	(PyCFunction)tupleindex,  METH_VARARGS, index_doc},
 	{"count",	(PyCFunction)tuplecount,  METH_O, count_doc},
 	{NULL,		NULL}		/* sentinel */

Modified: python/branches/py3k-urllib/PC/_msi.c
==============================================================================
--- python/branches/py3k-urllib/PC/_msi.c	(original)
+++ python/branches/py3k-urllib/PC/_msi.c	Tue Jul  1 06:02:29 2008
@@ -1065,5 +1065,5 @@
     if (!MSIError)
 	return NULL;
     PyModule_AddObject(m, "MSIError", MSIError);
-    return NULL;
+    return m;
 }

Modified: python/branches/py3k-urllib/PCbuild/sqlite3.vcproj
==============================================================================
--- python/branches/py3k-urllib/PCbuild/sqlite3.vcproj	(original)
+++ python/branches/py3k-urllib/PCbuild/sqlite3.vcproj	Tue Jul  1 06:02:29 2008
@@ -305,6 +305,7 @@
 			/>
 			<Tool
 				Name="VCLinkerTool"
+				OutputFile="$(OutDir)\$(ProjectName).dll"
 			/>
 			<Tool
 				Name="VCALinkTool"
@@ -428,6 +429,7 @@
 			/>
 			<Tool
 				Name="VCLinkerTool"
+				OutputFile="$(OutDir)\$(ProjectName).dll"
 			/>
 			<Tool
 				Name="VCALinkTool"

Modified: python/branches/py3k-urllib/Parser/node.c
==============================================================================
--- python/branches/py3k-urllib/Parser/node.c	(original)
+++ python/branches/py3k-urllib/Parser/node.c	Tue Jul  1 06:02:29 2008
@@ -91,6 +91,9 @@
 	if (current_capacity < 0 || required_capacity < 0)
 		return E_OVERFLOW;
 	if (current_capacity < required_capacity) {
+		if (required_capacity > PY_SIZE_MAX / sizeof(node)) {
+			return E_NOMEM;
+		}
 		n = n1->n_child;
 		n = (node *) PyObject_REALLOC(n,
 					      required_capacity * sizeof(node));

Modified: python/branches/py3k-urllib/Python/_warnings.c
==============================================================================
--- python/branches/py3k-urllib/Python/_warnings.c	(original)
+++ python/branches/py3k-urllib/Python/_warnings.c	Tue Jul  1 06:02:29 2008
@@ -280,6 +280,11 @@
     PyObject *item = Py_None;
     const char *action;
     int rc;
+    
+    if (registry && !PyDict_Check(registry) && (registry != Py_None)) {
+        PyErr_SetString(PyExc_TypeError, "'registry' must be a dict");
+        return NULL;
+    }
 
     /* Normalize module. */
     if (module == NULL) {
@@ -303,6 +308,8 @@
     else {
         text = message;
         message = PyObject_CallFunction(category, "O", message);
+        if (message == NULL)
+            goto cleanup;
     }
 
     lineno_obj = PyLong_FromLong(lineno);
@@ -314,7 +321,7 @@
     if (key == NULL)
         goto cleanup;
 
-    if (registry != NULL) {
+    if ((registry != NULL) && (registry != Py_None)) {
         rc = already_warned(registry, key, 0);
         if (rc == -1)
             goto cleanup;
@@ -336,12 +343,13 @@
        is "always". */
     rc = 0;
     if (strcmp(action, "always") != 0) {
-        if (registry != NULL && PyDict_SetItem(registry, key, Py_True) < 0)
+        if (registry != NULL && registry != Py_None &&
+                PyDict_SetItem(registry, key, Py_True) < 0)
             goto cleanup;
         else if (strcmp(action, "ignore") == 0)
             goto return_none;
         else if (strcmp(action, "once") == 0) {
-            if (registry == NULL) {
+            if (registry == NULL || registry == Py_None) {
                 registry = get_once_registry();
                 if (registry == NULL)
                     goto cleanup;
@@ -351,7 +359,7 @@
         }
         else if (strcmp(action, "module") == 0) {
             /* registry[(text, category, 0)] = 1 */
-            if (registry != NULL)
+            if (registry != NULL && registry != Py_None)
                 rc = update_registry(registry, text, category, 0); 
         }
         else if (strcmp(action, "default") != 0) {
@@ -435,7 +443,7 @@
     Py_XDECREF(text);
     Py_XDECREF(lineno_obj);
     Py_DECREF(module);
-    Py_DECREF(message);
+    Py_XDECREF(message);
     return result;  /* Py_None or NULL. */
 }
 

Modified: python/branches/py3k-urllib/Python/asdl.c
==============================================================================
--- python/branches/py3k-urllib/Python/asdl.c	(original)
+++ python/branches/py3k-urllib/Python/asdl.c	Tue Jul  1 06:02:29 2008
@@ -5,8 +5,22 @@
 asdl_seq_new(int size, PyArena *arena)
 {
 	asdl_seq *seq = NULL;
-	size_t n = sizeof(asdl_seq) +
-			(size ? (sizeof(void *) * (size - 1)) : 0);
+	size_t n = (size ? (sizeof(void *) * (size - 1)) : 0);
+
+	/* check size is sane */
+	if (size < 0 || size == INT_MIN || 
+		(size && ((size - 1) > (PY_SIZE_MAX / sizeof(void *))))) {
+		PyErr_NoMemory();
+		return NULL;
+	}
+
+	/* check if size can be added safely */
+	if (n > PY_SIZE_MAX - sizeof(asdl_seq)) {
+		PyErr_NoMemory();
+		return NULL;
+	}
+
+	n += sizeof(asdl_seq);
 
 	seq = (asdl_seq *)PyArena_Malloc(arena, n);
 	if (!seq) {
@@ -22,8 +36,22 @@
 asdl_int_seq_new(int size, PyArena *arena)
 {
 	asdl_int_seq *seq = NULL;
-	size_t n = sizeof(asdl_seq) +
-			(size ? (sizeof(int) * (size - 1)) : 0);
+	size_t n = (size ? (sizeof(void *) * (size - 1)) : 0);
+
+	/* check size is sane */
+	if (size < 0 || size == INT_MIN || 
+		(size && ((size - 1) > (PY_SIZE_MAX / sizeof(void *))))) {
+			PyErr_NoMemory();
+			return NULL;
+	}
+
+	/* check if size can be added safely */
+	if (n > PY_SIZE_MAX - sizeof(asdl_seq)) {
+		PyErr_NoMemory();
+		return NULL;
+	}
+
+	n += sizeof(asdl_seq);
 
 	seq = (asdl_int_seq *)PyArena_Malloc(arena, n);
 	if (!seq) {

Modified: python/branches/py3k-urllib/Python/ast.c
==============================================================================
--- python/branches/py3k-urllib/Python/ast.c	(original)
+++ python/branches/py3k-urllib/Python/ast.c	Tue Jul  1 06:02:29 2008
@@ -3145,6 +3145,9 @@
         buf = (char *)s;
         u = NULL;
     } else {
+        /* check for integer overflow */
+        if (len > PY_SIZE_MAX / 4)
+            return NULL;
         /* "\XX" may become "\u005c\uHHLL" (12 bytes) */
         u = PyBytes_FromStringAndSize((char *)NULL, len * 4);
         if (u == NULL)

Modified: python/branches/py3k-urllib/Python/compile.c
==============================================================================
--- python/branches/py3k-urllib/Python/compile.c	(original)
+++ python/branches/py3k-urllib/Python/compile.c	Tue Jul  1 06:02:29 2008
@@ -227,6 +227,10 @@
 		return ident; /* Don't mangle if class is just underscores */
 	}
 	plen = Py_UNICODE_strlen(p);
+
+	assert(1 <= PY_SSIZE_T_MAX - nlen);
+	assert(1 + nlen <= PY_SSIZE_T_MAX - plen);
+
 	ident = PyUnicode_FromStringAndSize(NULL, 1 + nlen + plen);
 	if (!ident)
 		return 0;
@@ -635,6 +639,12 @@
 		size_t oldsize, newsize;
 		oldsize = b->b_ialloc * sizeof(struct instr);
 		newsize = oldsize << 1;
+
+		if (oldsize > (PY_SIZE_MAX >> 1)) {
+			PyErr_NoMemory();
+			return -1;
+		}
+
 		if (newsize == 0) {
 			PyErr_NoMemory();
 			return -1;
@@ -3711,6 +3721,10 @@
 	a->a_lnotab = PyBytes_FromStringAndSize(NULL, DEFAULT_LNOTAB_SIZE);
 	if (!a->a_lnotab)
 		return 0;
+	if (nblocks > PY_SIZE_MAX / sizeof(basicblock *)) {
+		PyErr_NoMemory();
+		return 0;
+	}
 	a->a_postorder = (basicblock **)PyObject_Malloc(
 					    sizeof(basicblock *) * nblocks);
 	if (!a->a_postorder) {
@@ -3819,10 +3833,14 @@
 		nbytes = a->a_lnotab_off + 2 * ncodes;
 		len = PyBytes_GET_SIZE(a->a_lnotab);
 		if (nbytes >= len) {
-			if (len * 2 < nbytes)
+			if ((len <= INT_MAX / 2) && (len * 2 < nbytes))
 				len = nbytes;
-			else
+			else if (len <= INT_MAX / 2)
 				len *= 2;
+			else {
+				PyErr_NoMemory();
+				return 0;
+			}
 			if (_PyBytes_Resize(&a->a_lnotab, len) < 0)
 				return 0;
 		}
@@ -3841,10 +3859,14 @@
 		nbytes = a->a_lnotab_off + 2 * ncodes;
 		len = PyBytes_GET_SIZE(a->a_lnotab);
 		if (nbytes >= len) {
-			if (len * 2 < nbytes)
+			if ((len <= INT_MAX / 2) && len * 2 < nbytes)
 				len = nbytes;
-			else
+			else if (len <= INT_MAX / 2)
 				len *= 2;
+			else {
+				PyErr_NoMemory();
+				return 0;
+			}
 			if (_PyBytes_Resize(&a->a_lnotab, len) < 0)
 				return 0;
 		}
@@ -3903,6 +3925,8 @@
 	if (i->i_lineno && !assemble_lnotab(a, i))
 		return 0;
 	if (a->a_offset + size >= len) {
+		if (len > PY_SSIZE_T_MAX / 2)
+			return 0;
 		if (_PyBytes_Resize(&a->a_bytecode, len * 2) < 0)
 		    return 0;
 	}

Modified: python/branches/py3k-urllib/Python/marshal.c
==============================================================================
--- python/branches/py3k-urllib/Python/marshal.c	(original)
+++ python/branches/py3k-urllib/Python/marshal.c	Tue Jul  1 06:02:29 2008
@@ -70,7 +70,7 @@
 	size = PyBytes_Size(p->str);
 	newsize = size + size + 1024;
 	if (newsize > 32*1024*1024) {
-		newsize = size + 1024*1024;
+		newsize = size + (size >> 3);	/* 12.5% overallocation */
 	}
 	if (_PyBytes_Resize(&p->str, newsize) != 0) {
 		p->ptr = p->end = NULL;
@@ -1191,7 +1191,7 @@
 	{NULL,		NULL}		/* sentinel */
 };
 
-static struct PyModuleDef impmodule = {
+static struct PyModuleDef marshalmodule = {
 	PyModuleDef_HEAD_INIT,
 	"marshal",
 	NULL,
@@ -1208,7 +1208,7 @@
 PyMODINIT_FUNC
 PyMarshal_Init(void)
 {
-	PyObject *mod = PyModule_Create(&impmodule);
+	PyObject *mod = PyModule_Create(&marshalmodule);
 	if (mod == NULL)
 		return NULL;
 	PyModule_AddIntConstant(mod, "version", Py_MARSHAL_VERSION);

Modified: python/branches/py3k-urllib/Python/pystrtod.c
==============================================================================
--- python/branches/py3k-urllib/Python/pystrtod.c	(original)
+++ python/branches/py3k-urllib/Python/pystrtod.c	Tue Jul  1 06:02:29 2008
@@ -364,8 +364,8 @@
 	/* At this point, p points just past the right-most character we
 	   want to format.  We need to add the grouping string for the
 	   characters between buffer and p. */
-	return _PyBytes_InsertThousandsGrouping(buffer, len, p,
-						 buf_size, NULL, 1);
+	return _PyBytes_InsertThousandsGrouping(buffer, len, p-buffer,
+						buf_size, NULL, 1);
 }
 
 /* see FORMATBUFLEN in unicodeobject.c */

Modified: python/branches/py3k-urllib/README
==============================================================================
--- python/branches/py3k-urllib/README	(original)
+++ python/branches/py3k-urllib/README	Tue Jul  1 06:02:29 2008
@@ -1,5 +1,5 @@
-This is Python version 3.0 alpha 5
-==================================
+This is Python version 3.0 beta 1
+=================================
 
 For notes specific to this release, see RELNOTES in this directory.
 Copyright (c) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008
@@ -22,7 +22,7 @@
 ----------------
 
 The release plan is to have a series of alpha releases in 2007 and 2008,
-beta releases in 2008, and a final release in August 2008.  The alpha
+beta releases in 2008, and a final release in September 2008.  The alpha
 releases are primarily aimed at developers who want a sneak peek at the
 new langauge, especially those folks who plan to port their code to
 Python 3000.  The hope is that by the time of the final release, many

Modified: python/branches/py3k-urllib/RELNOTES
==============================================================================
--- python/branches/py3k-urllib/RELNOTES	(original)
+++ python/branches/py3k-urllib/RELNOTES	Tue Jul  1 06:02:29 2008
@@ -6,6 +6,12 @@
 Please report bugs to http://bugs.python.org/.
 
 
+Version 3.0b1 - Release Date 18-Jun-2008
+----------------------------------------
+
+Please search the bug tracker for critical issues in Python 3.0.
+
+
 Version 3.0a5 - Release Date 08-May-2008
 ----------------------------------------
 

Modified: python/branches/py3k-urllib/Tools/buildbot/external-amd64.bat
==============================================================================
--- python/branches/py3k-urllib/Tools/buildbot/external-amd64.bat	(original)
+++ python/branches/py3k-urllib/Tools/buildbot/external-amd64.bat	Tue Jul  1 06:02:29 2008
@@ -12,7 +12,7 @@
 )
 
 if not exist tcltk64\bin\tk85g.dll (
-    cd tk-8.5.2.1\win    
+    cd tk-8.5.2.0\win    
     nmake -f makefile.vc COMPILERFLAGS=-DWINVER=0x0500 OPTS=noxp DEBUG=1 MACHINE=AMD64 INSTALLDIR=..\..\tcltk64 TCLDIR=..\..\tcl-8.5.2.1 clean
     nmake -f makefile.vc COMPILERFLAGS=-DWINVER=0x0500 OPTS=noxp DEBUG=1 MACHINE=AMD64 INSTALLDIR=..\..\tcltk64 TCLDIR=..\..\tcl-8.5.2.1 all
     nmake -f makefile.vc COMPILERFLAGS=-DWINVER=0x0500 OPTS=noxp DEBUG=1 MACHINE=AMD64 INSTALLDIR=..\..\tcltk64 TCLDIR=..\..\tcl-8.5.2.1 install

Modified: python/branches/py3k-urllib/Tools/faqwiz/faqwiz.py
==============================================================================
--- python/branches/py3k-urllib/Tools/faqwiz/faqwiz.py	(original)
+++ python/branches/py3k-urllib/Tools/faqwiz/faqwiz.py	Tue Jul  1 06:02:29 2008
@@ -138,8 +138,8 @@
         value = cookies[COOKIE_NAME]
     except KeyError:
         return {}
-    import urllib
-    value = urllib.unquote(value)
+    import urllib.parse
+    value = urllib.parse.unquote(value)
     words = value.split('/')
     while len(words) < 3:
         words.append('')
@@ -153,8 +153,8 @@
 def send_my_cookie(ui):
     name = COOKIE_NAME
     value = "%s/%s/%s" % (ui.author, ui.email, ui.password)
-    import urllib
-    value = urllib.quote(value)
+    import urllib.parse
+    value = urllib.parse.quote(value)
     then = now + COOKIE_LIFETIME
     gmt = time.gmtime(then)
     path = os.environ.get('SCRIPT_NAME', '/cgi-bin/')

Modified: python/branches/py3k-urllib/Tools/msi/msi.py
==============================================================================
--- python/branches/py3k-urllib/Tools/msi/msi.py	(original)
+++ python/branches/py3k-urllib/Tools/msi/msi.py	Tue Jul  1 06:02:29 2008
@@ -92,7 +92,8 @@
     '_ctypes.pyd',
     '_ctypes_test.pyd',
     '_sqlite3.pyd',
-    '_hashlib.pyd'
+    '_hashlib.pyd',
+    '_multiprocessing.pyd'
 ]
 
 # Well-known component UUIDs

Modified: python/branches/py3k-urllib/Tools/msi/msilib.py
==============================================================================
--- python/branches/py3k-urllib/Tools/msi/msilib.py	(original)
+++ python/branches/py3k-urllib/Tools/msi/msilib.py	Tue Jul  1 06:02:29 2008
@@ -284,7 +284,8 @@
 
 def init_database(name, schema,
                   ProductName, ProductCode, ProductVersion,
-                  Manufacturer):
+                  Manufacturer,
+                  request_uac = False):
     try:
         os.unlink(name)
     except OSError:
@@ -306,7 +307,11 @@
     si.SetProperty(PID_AUTHOR, Manufacturer)
     si.SetProperty(PID_TEMPLATE, msi_type)
     si.SetProperty(PID_REVNUMBER, gen_uuid())
-    si.SetProperty(PID_WORDCOUNT, 2) # long file names, compressed, original media
+    if request_uac:
+        wc = 2 # long file names, compressed, original media
+    else:
+        wc = 2 | 8 # +never invoke UAC
+    si.SetProperty(PID_WORDCOUNT, wc)
     si.SetProperty(PID_PAGECOUNT, 200)
     si.SetProperty(PID_APPNAME, "Python MSI Library")
     # XXX more properties

Modified: python/branches/py3k-urllib/Tools/versioncheck/pyversioncheck.py
==============================================================================
--- python/branches/py3k-urllib/Tools/versioncheck/pyversioncheck.py	(original)
+++ python/branches/py3k-urllib/Tools/versioncheck/pyversioncheck.py	Tue Jul  1 06:02:29 2008
@@ -1,5 +1,5 @@
 """pyversioncheck - Module to help with checking versions"""
-import urllib
+import urllib.request
 import email
 import sys
 
@@ -47,7 +47,7 @@
     if verbose >= VERBOSE_EACHFILE:
         print('  Checking %s'%url)
     try:
-        fp = urllib.urlopen(url)
+        fp = urllib.request.urlopen(url)
     except IOError as arg:
         if verbose >= VERBOSE_EACHFILE:
             print('    Cannot open:', arg)

Modified: python/branches/py3k-urllib/Tools/webchecker/webchecker.py
==============================================================================
--- python/branches/py3k-urllib/Tools/webchecker/webchecker.py	(original)
+++ python/branches/py3k-urllib/Tools/webchecker/webchecker.py	Tue Jul  1 06:02:29 2008
@@ -113,13 +113,13 @@
 import getopt
 import pickle
 
-import urllib
-import urlparse
+import urllib.request
+import urllib.parse as urlparse
 import sgmllib
 import cgi
 
 import mimetypes
-import robotparser
+from urllib import robotparser
 
 # Extract real version number if necessary
 if __version__[0] == '$':
@@ -487,7 +487,7 @@
         if url in self.name_table:
             return self.name_table[url]
 
-        scheme, path = urllib.splittype(url)
+        scheme, path = urllib.request.splittype(url)
         if scheme in ('mailto', 'news', 'javascript', 'telnet'):
             self.note(1, " Not checking %s URL" % scheme)
             return None
@@ -733,13 +733,13 @@
         return self.__url
 
 
-class MyURLopener(urllib.FancyURLopener):
+class MyURLopener(urllib.request.FancyURLopener):
 
-    http_error_default = urllib.URLopener.http_error_default
+    http_error_default = urllib.request.URLopener.http_error_default
 
     def __init__(*args):
         self = args[0]
-        urllib.FancyURLopener.__init__(*args)
+        urllib.request.FancyURLopener.__init__(*args)
         self.addheaders = [
             ('User-agent', 'Python-webchecker/%s' % __version__),
             ]
@@ -769,7 +769,7 @@
                 s.write('<A HREF="%s">%s</A>\n' % (q, q))
             s.seek(0)
             return s
-        return urllib.FancyURLopener.open_file(self, url)
+        return urllib.request.FancyURLopener.open_file(self, url)
 
 
 class MyHTMLParser(sgmllib.SGMLParser):

Modified: python/branches/py3k-urllib/Tools/webchecker/websucker.py
==============================================================================
--- python/branches/py3k-urllib/Tools/webchecker/websucker.py	(original)
+++ python/branches/py3k-urllib/Tools/webchecker/websucker.py	Tue Jul  1 06:02:29 2008
@@ -6,8 +6,8 @@
 
 import os
 import sys
-import urllib
 import getopt
+import urllib.parse
 
 import webchecker
 
@@ -87,11 +87,11 @@
             self.message("didn't save %s: %s", path, str(msg))
 
     def savefilename(self, url):
-        type, rest = urllib.splittype(url)
-        host, path = urllib.splithost(rest)
+        type, rest = urllib.parse.splittype(url)
+        host, path = urllib.parse.splithost(rest)
         path = path.lstrip("/")
-        user, host = urllib.splituser(host)
-        host, port = urllib.splitnport(host)
+        user, host = urllib.parse.splituser(host)
+        host, port = urllib.parse.splitnport(host)
         host = host.lower()
         if not path or path[-1] == "/":
             path = path + "index.html"

Modified: python/branches/py3k-urllib/setup.py
==============================================================================
--- python/branches/py3k-urllib/setup.py	(original)
+++ python/branches/py3k-urllib/setup.py	Tue Jul  1 06:02:29 2008
@@ -656,6 +656,7 @@
                              # have issues on many platforms.  I've temporarily
                              # disabled 4.6 to see what the odd platform
                              # buildbots say.
+        max_db_ver = (4, 7)  # XXX(matthias.klose): test with 4.7 on some buildds
         min_db_ver = (3, 3)
         db_setup_debug = False   # verbose debug prints from this script?
 
@@ -1176,8 +1177,6 @@
                        Extension('_gestalt', ['_gestalt.c'],
                        extra_link_args=['-framework', 'Carbon'])
                        )
-        else:
-            missing.append('_gestalt')
 
         self.extensions.extend(exts)
 


More information about the Python-3000-checkins mailing list