[Python-checkins] r81508 - in python/branches/py3k-jit: Doc/c-api/init.rst Doc/c-api/sys.rst Doc/howto/descriptor.rst Doc/howto/index.rst Doc/library/argparse.rst Doc/library/decimal.rst Doc/library/fcntl.rst Doc/library/ftplib.rst Doc/library/getopt.rst Doc/library/hashlib.rst Doc/library/io.rst Doc/library/json.rst Doc/library/multiprocessing.rst Doc/library/optparse.rst Doc/library/os.rst Doc/library/socket.rst Doc/library/ssl.rst Doc/library/stdtypes.rst Doc/library/symtable.rst Doc/library/sys.rst Doc/library/syslog.rst Doc/library/telnetlib.rst Doc/library/tempfile.rst Doc/library/test.rst Doc/library/unittest.rst Doc/library/urllib.request.rst Doc/library/winreg.rst Doc/reference/datamodel.rst Doc/tutorial/datastructures.rst Include/pyport.h Include/sysmodule.h Lib/_abcoll.py Lib/argparse.py Lib/asyncore.py Lib/codecs.py Lib/decimal.py Lib/distutils/log.py Lib/distutils/tests/test_log.py Lib/encodings/utf_16.py Lib/encodings/utf_32.py Lib/fractions.py Lib/functools.py Lib/importlib/_bootstrap.py Lib/importlib/test/source/test_file_loader.py Lib/lib2to3/refactor.py Lib/linecache.py Lib/os.py Lib/pipes.py Lib/ssl.py Lib/subprocess.py Lib/sysconfig.py Lib/tabnanny.py Lib/test/regrtest.py Lib/test/test_argparse.py Lib/test/test_asyncore.py Lib/test/test_codecs.py Lib/test/test_collections.py Lib/test/test_complex.py Lib/test/test_decimal.py Lib/test/test_float.py Lib/test/test_gdb.py Lib/test/test_getargs2.py Lib/test/test_import.py Lib/test/test_linecache.py Lib/test/test_numeric_tower.py Lib/test/test_os.py Lib/test/test_pipes.py Lib/test/test_ssl.py Lib/test/test_subprocess.py Lib/test/test_sys.py Lib/test/test_sysconfig.py Lib/test/test_warnings.py Misc/NEWS Modules/_io/textio.c Modules/_sqlite/connection.c Modules/_sqlite/cursor.c Modules/_sqlite/row.c Modules/_sqlite/statement.c Modules/_ssl.c Modules/main.c Objects/complexobject.c Objects/longobject.c Objects/moduleobject.c Objects/object.c Objects/typeobject.c Parser/asdl.py Python/_warnings.c Python/bltinmodule.c Python/getargs.c Python/pythonrun.c Python/sysmodule.c Tools/gdb/libpython.py

collin.winter python-checkins at python.org
Tue May 25 03:17:50 CEST 2010


Author: collin.winter
Date: Tue May 25 03:17:49 2010
New Revision: 81508

Log:
Merged revisions 81281,81283,81288,81290-81292,81299,81314,81319-81325,81352,81356,81358-81361,81364-81368,81370,81372,81375,81378,81387,81392-81393,81397,81400,81403,81406,81410,81417-81418,81421,81424,81427,81435,81438,81442,81446,81452,81455,81457,81461,81470,81474,81476,81481,81485-81486,81491,81493,81495 via svnmerge from 
svn+ssh://pythondev@svn.python.org/python/branches/py3k

................
  r81281 | senthil.kumaran | 2010-05-17 20:26:11 -0700 (Mon, 17 May 2010) | 9 lines
  
  Merged revisions 81279 via svnmerge from 
  svn+ssh://pythondev@svn.python.org/python/trunk
  
  ........
    r81279 | senthil.kumaran | 2010-05-18 08:50:43 +0530 (Tue, 18 May 2010) | 3 lines
    
    Fix minor typo.
  ........
................
  r81283 | senthil.kumaran | 2010-05-17 20:58:36 -0700 (Mon, 17 May 2010) | 3 lines
  
  Removing the reference in the docs for overriding _urlopener global value. See Issue8619 for details.
................
  r81288 | senthil.kumaran | 2010-05-18 06:48:45 -0700 (Tue, 18 May 2010) | 9 lines
  
  Merged revisions 81286 via svnmerge from 
  svn+ssh://pythondev@svn.python.org/python/trunk
  
  ........
    r81286 | senthil.kumaran | 2010-05-18 19:10:23 +0530 (Tue, 18 May 2010) | 3 lines
    
    Doc Fix. Correct link to Zephyr ASDL Abstract page.
  ........
................
  r81290 | barry.warsaw | 2010-05-18 07:15:20 -0700 (Tue, 18 May 2010) | 2 lines
  
  Repair test failure.  Bug 8727.
................
  r81291 | victor.stinner | 2010-05-18 10:17:23 -0700 (Tue, 18 May 2010) | 5 lines
  
  Issue #8513: os.get_exec_path() supports b'PATH' key and bytes value.
  subprocess.Popen() and os._execvpe() support bytes program name. Add
  os.supports_bytes_environ flag: True if the native OS type of the environment
  is bytes (eg. False on Windows).
................
  r81292 | victor.stinner | 2010-05-18 10:24:09 -0700 (Tue, 18 May 2010) | 2 lines
  
  Add versionadded (3.2) tag to os.supports_bytes_environ documentation
................
  r81299 | giampaolo.rodola | 2010-05-18 13:11:58 -0700 (Tue, 18 May 2010) | 9 lines
  
  Merged revisions 81294 via svnmerge from 
  svn+ssh://pythondev@svn.python.org/python/trunk
  
  ........
    r81294 | giampaolo.rodola | 2010-05-18 22:04:31 +0200 (mar, 18 mag 2010) | 1 line
    
    Fix issue #8573 (asyncore._strerror bug): fixed os.strerror typo; included NameError in the tuple of expected exception; added test case for asyncore._strerror.
  ........
................
  r81314 | victor.stinner | 2010-05-18 17:03:09 -0700 (Tue, 18 May 2010) | 2 lines
  
  Issue #6697: Fix a crash if a module attribute name contains a surrogate
................
  r81319 | victor.stinner | 2010-05-18 17:34:15 -0700 (Tue, 18 May 2010) | 2 lines
  
  Issue #6697: Check that _PyUnicode_AsString() result is not NULL
................
  r81320 | victor.stinner | 2010-05-18 17:54:06 -0700 (Tue, 18 May 2010) | 2 lines
  
  Issue #6697: Fix a crash if a keyword contains a surrogate
................
  r81321 | victor.stinner | 2010-05-18 18:06:22 -0700 (Tue, 18 May 2010) | 4 lines
  
  Issue #6697: Fix a crash if sys.stdin or sys.stdout encoding contain a surrogate
  
  This is *very* unlikely :-)
................
  r81322 | victor.stinner | 2010-05-18 18:17:01 -0700 (Tue, 18 May 2010) | 5 lines
  
  Issue #6697: Check that _PyUnicode_AsString() result is not NULL in textio.c
  
  The bug may occurs if locale.getpreferredencoding() returns an encoding with a
  surrogate (very unlikely!).
................
  r81323 | victor.stinner | 2010-05-18 18:27:23 -0700 (Tue, 18 May 2010) | 4 lines
  
  Issue #6697: Check that _PyUnicode_AsString() result is not NULL in _sqlite
  
  Strip also some trailing spaces
................
  r81324 | victor.stinner | 2010-05-18 18:42:46 -0700 (Tue, 18 May 2010) | 5 lines
  
  Issue #6697: Check that _PyUnicode_AsString() result is not NULL in typeobject
  
  Type name and slots are already checked for surrogates somewhere else, but it's
  better to ensure that the result is not NULL.
................
  r81325 | victor.stinner | 2010-05-18 18:50:45 -0700 (Tue, 18 May 2010) | 4 lines
  
  Ooops, add missing ";" in my previous commit (r81324, typeobject.c)
  
  It's time to go to bed...
................
  r81352 | stefan.krah | 2010-05-19 08:52:31 -0700 (Wed, 19 May 2010) | 9 lines
  
  Merged revisions 81350 via svnmerge from 
  svn+ssh://pythondev@svn.python.org/python/trunk
  
  ........
    r81350 | stefan.krah | 2010-05-19 17:46:39 +0200 (Wed, 19 May 2010) | 1 line
    
    Fix typos in docstrings.
  ........
................
  r81356 | stefan.krah | 2010-05-19 09:09:41 -0700 (Wed, 19 May 2010) | 9 lines
  
  Merged revisions 81354 via svnmerge from 
  svn+ssh://pythondev@svn.python.org/python/trunk
  
  ........
    r81354 | stefan.krah | 2010-05-19 17:59:40 +0200 (Wed, 19 May 2010) | 3 lines
    
    Fix typo.
  ........
................
  r81358 | victor.stinner | 2010-05-19 09:53:30 -0700 (Wed, 19 May 2010) | 4 lines
  
  Issue #8589: Decode PYTHONWARNINGS environment variable with the file system
  encoding and surrogateespace error handler instead of the locale encoding to be
  consistent with os.environ. Add PySys_AddWarnOptionUnicode() function.
................
  r81359 | victor.stinner | 2010-05-19 10:00:07 -0700 (Wed, 19 May 2010) | 4 lines
  
  Issue #8663: distutils.log emulates backslashreplace error handler. Fix
  compilation in a non-ASCII directory if stdout encoding is ASCII (eg. if stdout
  is not a TTY).
................
  r81360 | victor.stinner | 2010-05-19 10:11:19 -0700 (Wed, 19 May 2010) | 5 lines
  
  regrtest.py: call replace_stdout() before the first call to print()
  
  print("==  ", os.getcwd()) fails if the current working directory is not ASCII
  whereas sys.stdout encoding is ASCII.
................
  r81361 | victor.stinner | 2010-05-19 10:15:50 -0700 (Wed, 19 May 2010) | 2 lines
  
  Oops, add the new test_log.py for distutils test suite (missing part of r81359)
................
  r81364 | victor.stinner | 2010-05-19 13:40:50 -0700 (Wed, 19 May 2010) | 3 lines
  
  Issue #8766: Initialize _warnings module before importing the first module.
  Fix a crash if an empty directory called "encodings" exists in sys.path.
................
  r81365 | georg.brandl | 2010-05-19 13:57:08 -0700 (Wed, 19 May 2010) | 77 lines
  
  Merged revisions 80030,80067,80069,80080-80081,80084,80432-80433,80465-80470,81059,81065-81067 via svnmerge from 
  svn+ssh://pythondev@svn.python.org/python/trunk
  
  ........
    r80030 | georg.brandl | 2010-04-13 08:43:54 +0200 (Di, 13 Apr 2010) | 1 line
    
    Get rid of multi-row cells.
  ........
    r80067 | georg.brandl | 2010-04-14 10:53:38 +0200 (Mi, 14 Apr 2010) | 1 line
    
    #5341: typo.
  ........
    r80069 | georg.brandl | 2010-04-14 15:50:31 +0200 (Mi, 14 Apr 2010) | 1 line
    
    Add an x-ref to where the O_ constants are documented and move the SEEK_ constants after lseek().
  ........
    r80080 | georg.brandl | 2010-04-14 21:16:38 +0200 (Mi, 14 Apr 2010) | 1 line
    
    #8399: add note about Windows and O_BINARY.
  ........
    r80081 | georg.brandl | 2010-04-14 23:34:44 +0200 (Mi, 14 Apr 2010) | 1 line
    
    #5250: document __instancecheck__ and __subclasscheck__.  I hope the part about the class/metaclass distinction is understandable.
  ........
    r80084 | georg.brandl | 2010-04-14 23:46:45 +0200 (Mi, 14 Apr 2010) | 1 line
    
    Fix missing.
  ........
    r80432 | georg.brandl | 2010-04-24 10:56:58 +0200 (Sa, 24 Apr 2010) | 1 line
    
    Markup fixes.
  ........
    r80433 | georg.brandl | 2010-04-24 11:08:10 +0200 (Sa, 24 Apr 2010) | 1 line
    
    #7507: quote "!" in pipes.quote(); it is a special character for some shells.
  ........
    r80465 | georg.brandl | 2010-04-25 12:29:17 +0200 (So, 25 Apr 2010) | 1 line
    
    Remove LaTeXy index entry syntax.
  ........
    r80466 | georg.brandl | 2010-04-25 12:54:42 +0200 (So, 25 Apr 2010) | 1 line
    
    Patch from Tim Hatch: Better cross-referencing in socket and winreg docs.
  ........
    r80467 | georg.brandl | 2010-04-25 12:55:16 +0200 (So, 25 Apr 2010) | 1 line
    
    Patch from Tim Hatch: Remove reference to winreg being the fabled high-level registry interface.
  ........
    r80468 | georg.brandl | 2010-04-25 12:55:58 +0200 (So, 25 Apr 2010) | 1 line
    
    Patch from Tim Hatch: Minor spelling changes to _winreg docs.
  ........
    r80469 | georg.brandl | 2010-04-25 12:56:41 +0200 (So, 25 Apr 2010) | 1 line
    
    Fix code example to have valid syntax so that it can be highlighted.
  ........
    r80470 | georg.brandl | 2010-04-25 12:57:15 +0200 (So, 25 Apr 2010) | 1 line
    
    Patch from Tim Hatch: Make socket setblocking <-> settimeout examples symmetric.
  ........
    r81059 | georg.brandl | 2010-05-10 23:02:51 +0200 (Mo, 10 Mai 2010) | 1 line
    
    #8642: fix wrong function name.
  ........
    r81065 | georg.brandl | 2010-05-10 23:46:50 +0200 (Mo, 10 Mai 2010) | 1 line
    
    Fix reference direction.
  ........
    r81066 | georg.brandl | 2010-05-10 23:50:57 +0200 (Mo, 10 Mai 2010) | 1 line
    
    Consolidate deprecation messages.
  ........
    r81067 | georg.brandl | 2010-05-10 23:51:33 +0200 (Mo, 10 Mai 2010) | 1 line
    
    Fix typo.
  ........
................
  r81366 | georg.brandl | 2010-05-19 13:58:02 -0700 (Wed, 19 May 2010) | 61 lines
  
  Recorded merge of revisions 80030,80067,80069,80080-80081,80084,80432-80433,80465,80470,81059,81065-81067 via svnmerge from 
  svn+ssh://pythondev@svn.python.org/python/trunk
  
  ........
    r80030 | georg.brandl | 2010-04-13 08:43:54 +0200 (Di, 13 Apr 2010) | 1 line
    
    Get rid of multi-row cells.
  ........
    r80067 | georg.brandl | 2010-04-14 10:53:38 +0200 (Mi, 14 Apr 2010) | 1 line
    
    #5341: typo.
  ........
    r80069 | georg.brandl | 2010-04-14 15:50:31 +0200 (Mi, 14 Apr 2010) | 1 line
    
    Add an x-ref to where the O_ constants are documented and move the SEEK_ constants after lseek().
  ........
    r80080 | georg.brandl | 2010-04-14 21:16:38 +0200 (Mi, 14 Apr 2010) | 1 line
    
    #8399: add note about Windows and O_BINARY.
  ........
    r80081 | georg.brandl | 2010-04-14 23:34:44 +0200 (Mi, 14 Apr 2010) | 1 line
    
    #5250: document __instancecheck__ and __subclasscheck__.  I hope the part about the class/metaclass distinction is understandable.
  ........
    r80084 | georg.brandl | 2010-04-14 23:46:45 +0200 (Mi, 14 Apr 2010) | 1 line
    
    Fix missing.
  ........
    r80432 | georg.brandl | 2010-04-24 10:56:58 +0200 (Sa, 24 Apr 2010) | 1 line
    
    Markup fixes.
  ........
    r80433 | georg.brandl | 2010-04-24 11:08:10 +0200 (Sa, 24 Apr 2010) | 1 line
    
    #7507: quote "!" in pipes.quote(); it is a special character for some shells.
  ........
    r80465 | georg.brandl | 2010-04-25 12:29:17 +0200 (So, 25 Apr 2010) | 1 line
    
    Remove LaTeXy index entry syntax.
  ........
    r80470 | georg.brandl | 2010-04-25 12:57:15 +0200 (So, 25 Apr 2010) | 1 line
    
    Patch from Tim Hatch: Make socket setblocking <-> settimeout examples symmetric.
  ........
    r81059 | georg.brandl | 2010-05-10 23:02:51 +0200 (Mo, 10 Mai 2010) | 1 line
    
    #8642: fix wrong function name.
  ........
    r81065 | georg.brandl | 2010-05-10 23:46:50 +0200 (Mo, 10 Mai 2010) | 1 line
    
    Fix reference direction.
  ........
    r81066 | georg.brandl | 2010-05-10 23:50:57 +0200 (Mo, 10 Mai 2010) | 1 line
    
    Consolidate deprecation messages.
  ........
    r81067 | georg.brandl | 2010-05-10 23:51:33 +0200 (Mo, 10 Mai 2010) | 1 line
    
    Fix typo.
  ........
................
  r81367 | georg.brandl | 2010-05-19 14:03:51 -0700 (Wed, 19 May 2010) | 21 lines
  
  Recorded merge of revisions 80466-80469 via svnmerge from 
  svn+ssh://pythondev@svn.python.org/python/trunk
  
  ........
    r80466 | georg.brandl | 2010-04-25 12:54:42 +0200 (So, 25 Apr 2010) | 1 line
    
    Patch from Tim Hatch: Better cross-referencing in socket and winreg docs.
  ........
    r80467 | georg.brandl | 2010-04-25 12:55:16 +0200 (So, 25 Apr 2010) | 1 line
    
    Patch from Tim Hatch: Remove reference to winreg being the fabled high-level registry interface.
  ........
    r80468 | georg.brandl | 2010-04-25 12:55:58 +0200 (So, 25 Apr 2010) | 1 line
    
    Patch from Tim Hatch: Minor spelling changes to _winreg docs.
  ........
    r80469 | georg.brandl | 2010-04-25 12:56:41 +0200 (So, 25 Apr 2010) | 1 line
    
    Fix code example to have valid syntax so that it can be highlighted.
  ........
................
  r81368 | georg.brandl | 2010-05-19 14:06:36 -0700 (Wed, 19 May 2010) | 9 lines
  
  Merged revisions 80068 via svnmerge from 
  svn+ssh://pythondev@svn.python.org/python/trunk
  
  ........
    r80068 | georg.brandl | 2010-04-14 10:56:01 +0200 (Mi, 14 Apr 2010) | 1 line
    
    #5341: fix typo and adapt docstring syntax.
  ........
................
  r81370 | georg.brandl | 2010-05-19 14:39:51 -0700 (Wed, 19 May 2010) | 1 line
  
  Add descriptor HOWTO to py3k docs.
................
  r81372 | tarek.ziade | 2010-05-19 15:25:00 -0700 (Wed, 19 May 2010) | 9 lines
  
  Merged revisions 81371 via svnmerge from 
  svn+ssh://pythondev@svn.python.org/python/trunk
  
  ........
    r81371 | tarek.ziade | 2010-05-20 00:20:14 +0200 (Thu, 20 May 2010) | 1 line
    
    #8759: Fixed user paths in sysconfig for posix and os2 schemes
  ........
................
  r81375 | victor.stinner | 2010-05-19 16:04:56 -0700 (Wed, 19 May 2010) | 9 lines
  
  Issue #8559: improve unicode support of (gdb) libpython.py
  
   * Escape non printable characters (use locale.getpreferredencoding())
   * Fix support of surrogate pairs
   * test_gdb.py: use ascii() instead of repr() in gdb program arguments to avoid
     encoding issues
   * Fix test_strings() of test_gdb.py for encoding different than UTF-8
     (eg. ACSII)
................
  r81378 | victor.stinner | 2010-05-20 04:30:37 -0700 (Thu, 20 May 2010) | 14 lines
  
  Blocked revisions 81377 via svnmerge
  
  ........
    r81377 | victor.stinner | 2010-05-20 13:29:45 +0200 (jeu., 20 mai 2010) | 8 lines
    
    libpython.py: fix support of non-BMP unicode characters
    
    Forward port some code from Python3:
    
     * join surrogate pairs if sizeof(Py_UNICODE)==2
     * Enable non-BMP test on narrow builds using u"\U0001D121" instead of
       unichr(0x1D121)
  ........
................
  r81387 | benjamin.peterson | 2010-05-20 15:29:43 -0700 (Thu, 20 May 2010) | 9 lines
  
  Merged revisions 81385 via svnmerge from 
  svn+ssh://pythondev@svn.python.org/python/trunk
  
  ........
    r81385 | benjamin.peterson | 2010-05-20 17:23:37 -0500 (Thu, 20 May 2010) | 1 line
    
    fix extra 't' #8778
  ........
................
  r81392 | antoine.pitrou | 2010-05-21 02:56:06 -0700 (Fri, 21 May 2010) | 5 lines
  
  Issue #4870: Add an `options` attribute to SSL contexts, as well as 
  several ``OP_*`` constants to the `ssl` module.  This allows to selectively
  disable protocol versions, when used in combination with `PROTOCOL_SSLv23`.
................
  r81393 | victor.stinner | 2010-05-21 03:52:08 -0700 (Fri, 21 May 2010) | 3 lines
  
  Issue #8774: tabnanny uses the encoding cookie (#coding:...) to use the correct
  encoding
................
  r81397 | mark.dickinson | 2010-05-21 07:55:26 -0700 (Fri, 21 May 2010) | 10 lines
  
  Issue #8748: Fix two issues with comparisons between complex and integer
  objects.  (1) The comparison could incorrectly return True in some cases
  (2**53+1 == complex(2**53) == 2**53), breaking transivity of equality.
  (2) The comparison raised an OverflowError for large integers, leading
  to unpredictable exceptions when combining integers and complex objects
  in sets or dicts.
  
  Patch by Meador Inge.
................
  r81400 | antoine.pitrou | 2010-05-21 10:25:34 -0700 (Fri, 21 May 2010) | 12 lines
  
  Merged revisions 81398 via svnmerge from 
  svn+ssh://pythondev@svn.python.org/python/trunk
  
  ........
    r81398 | antoine.pitrou | 2010-05-21 19:12:38 +0200 (ven., 21 mai 2010) | 6 lines
    
    Issue #5753: A new C API function, :cfunc:`PySys_SetArgvEx`, allows
    embedders of the interpreter to set sys.argv without also modifying
    sys.path.  This helps fix `CVE-2008-5983
    <http://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2008-5983>`_.
  ........
................
  r81403 | victor.stinner | 2010-05-21 13:13:12 -0700 (Fri, 21 May 2010) | 5 lines
  
  Issue #8780: Fix a regression introduced by r78946 in subprocess on Windows
  
  Ensure that stdout / stderr is inherited from the parent if stdout=PIPE /
  stderr=PIPE is not used.
................
  r81406 | georg.brandl | 2010-05-21 13:28:13 -0700 (Fri, 21 May 2010) | 9 lines
  
  Merged revisions 81404 via svnmerge from 
  svn+ssh://pythondev@svn.python.org/python/trunk
  
  ........
    r81404 | georg.brandl | 2010-05-21 22:24:45 +0200 (Fr, 21 Mai 2010) | 1 line
    
    #8783: replace link to now dead hash collision FAQ.
  ........
................
  r81410 | georg.brandl | 2010-05-21 13:45:12 -0700 (Fri, 21 May 2010) | 1 line
  
  Remove redundant example.
................
  r81417 | benjamin.peterson | 2010-05-21 13:55:22 -0700 (Fri, 21 May 2010) | 9 lines
  
  Merged revisions 81414 via svnmerge from 
  svn+ssh://pythondev@svn.python.org/python/trunk
  
  ........
    r81414 | benjamin.peterson | 2010-05-21 15:51:45 -0500 (Fri, 21 May 2010) | 1 line
    
    return NotImplemented from Mapping when comparing to a non-mapping #8729
  ........
................
  r81418 | georg.brandl | 2010-05-21 13:57:33 -0700 (Fri, 21 May 2010) | 9 lines
  
  Recorded merge of revisions 81415 via svnmerge from 
  svn+ssh://pythondev@svn.python.org/python/trunk
  
  ........
    r81415 | georg.brandl | 2010-05-21 22:52:46 +0200 (Fr, 21 Mai 2010) | 1 line
    
    typo
  ........
................
  r81421 | georg.brandl | 2010-05-21 14:01:32 -0700 (Fri, 21 May 2010) | 1 line
  
  Fix variable name in example.
................
  r81424 | georg.brandl | 2010-05-21 14:03:02 -0700 (Fri, 21 May 2010) | 8 lines
  
  Blocked revisions 81419 via svnmerge
  
  ........
    r81419 | georg.brandl | 2010-05-21 22:58:12 +0200 (Fr, 21 Mai 2010) | 1 line
    
    Add missing parameter in SimpleXMLRPCServer signature.
  ........
................
  r81427 | georg.brandl | 2010-05-21 14:12:07 -0700 (Fri, 21 May 2010) | 1 line
  
  Fix signatures for the various TemporaryFile class^Wfunctions.
................
  r81435 | georg.brandl | 2010-05-21 14:33:23 -0700 (Fri, 21 May 2010) | 9 lines
  
  Merged revisions 81431 via svnmerge from 
  svn+ssh://pythondev@svn.python.org/python/trunk
  
  ........
    r81431 | georg.brandl | 2010-05-21 23:30:47 +0200 (Fr, 21 Mai 2010) | 1 line
    
    #8707: remove duplicate paragraph part.
  ........
................
  r81438 | benjamin.peterson | 2010-05-21 14:45:06 -0700 (Fri, 21 May 2010) | 25 lines
  
  Merged revisions 81428-81429,81432-81433,81437 via svnmerge from 
  svn+ssh://pythondev@svn.python.org/python/trunk
  
  ........
    r81428 | benjamin.peterson | 2010-05-21 16:16:12 -0500 (Fri, 21 May 2010) | 1 line
    
    use addCleanup
  ........
    r81429 | benjamin.peterson | 2010-05-21 16:17:22 -0500 (Fri, 21 May 2010) | 1 line
    
    fix name
  ........
    r81432 | benjamin.peterson | 2010-05-21 16:31:24 -0500 (Fri, 21 May 2010) | 1 line
    
    ensure the last line has a trailing newline #8782
  ........
    r81433 | benjamin.peterson | 2010-05-21 16:32:49 -0500 (Fri, 21 May 2010) | 1 line
    
    remove debugging rubish
  ........
    r81437 | benjamin.peterson | 2010-05-21 16:35:44 -0500 (Fri, 21 May 2010) | 1 line
    
    simplify and modernize updatecache()
  ........
................
  r81442 | georg.brandl | 2010-05-21 14:48:27 -0700 (Fri, 21 May 2010) | 9 lines
  
  Merged revisions 81440 via svnmerge from 
  svn+ssh://pythondev@svn.python.org/python/trunk
  
  ........
    r81440 | georg.brandl | 2010-05-21 23:47:05 +0200 (Fr, 21 Mai 2010) | 1 line
    
    Correct info for Semaphore.acquire() semantics under OSX.
  ........
................
  r81446 | georg.brandl | 2010-05-21 14:49:47 -0700 (Fri, 21 May 2010) | 9 lines
  
  Merged revisions 81443 via svnmerge from 
  svn+ssh://pythondev@svn.python.org/python/trunk
  
  ........
    r81443 | georg.brandl | 2010-05-21 23:48:57 +0200 (Fr, 21 Mai 2010) | 1 line
    
    typo
  ........
................
  r81452 | georg.brandl | 2010-05-21 15:04:32 -0700 (Fri, 21 May 2010) | 9 lines
  
  Merged revisions 81450 via svnmerge from 
  svn+ssh://pythondev@svn.python.org/python/trunk
  
  ........
    r81450 | georg.brandl | 2010-05-22 00:03:29 +0200 (Sa, 22 Mai 2010) | 1 line
    
    #8709: mention Windows support for os.devnull.
  ........
................
  r81455 | victor.stinner | 2010-05-21 15:52:10 -0700 (Fri, 21 May 2010) | 9 lines
  
  Blocked revisions 81454 via svnmerge
  
  ........
    r81454 | victor.stinner | 2010-05-22 00:50:28 +0200 (sam., 22 mai 2010) | 3 lines
    
    Issue #5640: Fix Shift-JIS incremental encoder for error handlers different
    than strict
  ........
................
  r81457 | victor.stinner | 2010-05-21 16:45:42 -0700 (Fri, 21 May 2010) | 3 lines
  
  Issue #3798: sys.exit(message) writes the message to sys.stderr file, instead
  of the C file stderr, to use stderr encoding and error handler
................
  r81461 | victor.stinner | 2010-05-21 19:16:27 -0700 (Fri, 21 May 2010) | 10 lines
  
  Merged revisions 81459 via svnmerge from 
  svn+ssh://pythondev@svn.python.org/python/trunk
  
  ........
    r81459 | victor.stinner | 2010-05-22 04:11:07 +0200 (sam., 22 mai 2010) | 3 lines
    
    Issue #6268: Fix seek() method of codecs.open(), don't read the BOM twice
    after seek(0)
  ........
................
  r81470 | mark.dickinson | 2010-05-22 05:02:35 -0700 (Sat, 22 May 2010) | 1 line
  
  Issue #8749: remove unused code in Objects/object.c.  Thanks Yaniv Aknin.
................
  r81474 | victor.stinner | 2010-05-22 09:59:09 -0700 (Sat, 22 May 2010) | 20 lines
  
  Merged revisions 81471-81472 via svnmerge from 
  svn+ssh://pythondev@svn.python.org/python/trunk
  
  ........
    r81471 | victor.stinner | 2010-05-22 15:37:56 +0200 (sam., 22 mai 2010) | 7 lines
    
    Issue #6268: More bugfixes about BOM, UTF-16 and UTF-32
    
     * Fix seek() method of codecs.open(), don't write the BOM twice after seek(0)
     * Fix reset() method of codecs, UTF-16, UTF-32 and StreamWriter classes
     * test_codecs: use "w+" mode instead of "wt+". "t" mode is not supported by
       Solaris or Windows, but does it really exist? I found it the in the issue.
  ........
    r81472 | victor.stinner | 2010-05-22 15:44:25 +0200 (sam., 22 mai 2010) | 4 lines
    
    Fix my last commit (r81471) about codecs
    
    Rememder: don't touch the code just before a commit
  ........
................
  r81476 | mark.dickinson | 2010-05-22 11:35:36 -0700 (Sat, 22 May 2010) | 2 lines
  
  #Issue 8540: Make Context._clamp attribute public in decimal module.
................
  r81481 | benjamin.peterson | 2010-05-22 11:59:24 -0700 (Sat, 22 May 2010) | 20 lines
  
  Merged revisions 81479 via svnmerge from 
  svn+ssh://pythondev@svn.python.org/python/trunk
  
  ................
    r81479 | benjamin.peterson | 2010-05-22 13:52:21 -0500 (Sat, 22 May 2010) | 13 lines
    
    Merged revisions 80937,81478 via svnmerge from 
    svn+ssh://pythondev@svn.python.org/sandbox/trunk/2to3/lib2to3
    
    ........
      r80937 | benjamin.peterson | 2010-05-07 14:10:58 -0500 (Fri, 07 May 2010) | 1 line
      
      remove redundant unicode call
    ........
      r81478 | benjamin.peterson | 2010-05-22 13:47:39 -0500 (Sat, 22 May 2010) | 1 line
      
      ensure doctests have some future_features
    ........
  ................
................
  r81485 | mark.dickinson | 2010-05-23 06:26:48 -0700 (Sun, 23 May 2010) | 1 line
  
  Remove duplicate NEWS entry.
................
  r81486 | mark.dickinson | 2010-05-23 06:33:13 -0700 (Sun, 23 May 2010) | 6 lines
  
  Issue #8188: Introduce a new scheme for computing hashes of numbers
  (instances of int, float, complex, decimal.Decimal and
  fractions.Fraction) that makes it easy to maintain the invariant that
  hash(x) == hash(y) whenever x and y have equal value.
................
  r81491 | steven.bethard | 2010-05-23 20:21:08 -0700 (Sun, 23 May 2010) | 9 lines
  
  Merged revisions 81490 via svnmerge from 
  svn+ssh://pythondev@svn.python.org/python/trunk
  
  ........
    r81490 | steven.bethard | 2010-05-23 19:38:00 -0700 (Sun, 23 May 2010) | 1 line
    
    argparse documentation updates (including updates to optparse and getopt documentation that were promised in the PEP)
  ........
................
  r81493 | steven.bethard | 2010-05-23 20:47:38 -0700 (Sun, 23 May 2010) | 9 lines
  
  Merged revisions 81492 via svnmerge from 
  svn+ssh://pythondev@svn.python.org/python/trunk
  
  ........
    r81492 | steven.bethard | 2010-05-23 20:45:26 -0700 (Sun, 23 May 2010) | 1 line
    
    Fix default value for version help. Approved by Benjamin on python-dev: http://mail.python.org/pipermail/python-dev/2010-May/100231.html
  ........
................
  r81495 | antoine.pitrou | 2010-05-24 08:58:43 -0700 (Mon, 24 May 2010) | 3 lines
  
  Add a versionadded tag for SSL contexts.
................


Added:
   python/branches/py3k-jit/Doc/howto/descriptor.rst
      - copied unchanged from r81495, /python/branches/py3k/Doc/howto/descriptor.rst
   python/branches/py3k-jit/Lib/distutils/tests/test_log.py
      - copied unchanged from r81495, /python/branches/py3k/Lib/distutils/tests/test_log.py
   python/branches/py3k-jit/Lib/test/test_numeric_tower.py
      - copied unchanged from r81495, /python/branches/py3k/Lib/test/test_numeric_tower.py
Modified:
   python/branches/py3k-jit/   (props changed)
   python/branches/py3k-jit/Doc/c-api/init.rst
   python/branches/py3k-jit/Doc/c-api/sys.rst
   python/branches/py3k-jit/Doc/howto/index.rst
   python/branches/py3k-jit/Doc/library/argparse.rst
   python/branches/py3k-jit/Doc/library/decimal.rst
   python/branches/py3k-jit/Doc/library/fcntl.rst
   python/branches/py3k-jit/Doc/library/ftplib.rst
   python/branches/py3k-jit/Doc/library/getopt.rst
   python/branches/py3k-jit/Doc/library/hashlib.rst
   python/branches/py3k-jit/Doc/library/io.rst
   python/branches/py3k-jit/Doc/library/json.rst
   python/branches/py3k-jit/Doc/library/multiprocessing.rst
   python/branches/py3k-jit/Doc/library/optparse.rst
   python/branches/py3k-jit/Doc/library/os.rst
   python/branches/py3k-jit/Doc/library/socket.rst
   python/branches/py3k-jit/Doc/library/ssl.rst
   python/branches/py3k-jit/Doc/library/stdtypes.rst
   python/branches/py3k-jit/Doc/library/symtable.rst
   python/branches/py3k-jit/Doc/library/sys.rst
   python/branches/py3k-jit/Doc/library/syslog.rst
   python/branches/py3k-jit/Doc/library/telnetlib.rst
   python/branches/py3k-jit/Doc/library/tempfile.rst
   python/branches/py3k-jit/Doc/library/test.rst
   python/branches/py3k-jit/Doc/library/unittest.rst
   python/branches/py3k-jit/Doc/library/urllib.request.rst
   python/branches/py3k-jit/Doc/library/winreg.rst
   python/branches/py3k-jit/Doc/reference/datamodel.rst
   python/branches/py3k-jit/Doc/tutorial/datastructures.rst
   python/branches/py3k-jit/Include/pyport.h
   python/branches/py3k-jit/Include/sysmodule.h
   python/branches/py3k-jit/Lib/_abcoll.py
   python/branches/py3k-jit/Lib/argparse.py
   python/branches/py3k-jit/Lib/asyncore.py
   python/branches/py3k-jit/Lib/codecs.py
   python/branches/py3k-jit/Lib/decimal.py
   python/branches/py3k-jit/Lib/distutils/log.py
   python/branches/py3k-jit/Lib/encodings/utf_16.py
   python/branches/py3k-jit/Lib/encodings/utf_32.py
   python/branches/py3k-jit/Lib/fractions.py
   python/branches/py3k-jit/Lib/functools.py
   python/branches/py3k-jit/Lib/importlib/_bootstrap.py
   python/branches/py3k-jit/Lib/importlib/test/source/test_file_loader.py
   python/branches/py3k-jit/Lib/lib2to3/refactor.py
   python/branches/py3k-jit/Lib/linecache.py
   python/branches/py3k-jit/Lib/os.py
   python/branches/py3k-jit/Lib/pipes.py
   python/branches/py3k-jit/Lib/ssl.py
   python/branches/py3k-jit/Lib/subprocess.py
   python/branches/py3k-jit/Lib/sysconfig.py
   python/branches/py3k-jit/Lib/tabnanny.py
   python/branches/py3k-jit/Lib/test/regrtest.py
   python/branches/py3k-jit/Lib/test/test_argparse.py
   python/branches/py3k-jit/Lib/test/test_asyncore.py
   python/branches/py3k-jit/Lib/test/test_codecs.py
   python/branches/py3k-jit/Lib/test/test_collections.py
   python/branches/py3k-jit/Lib/test/test_complex.py
   python/branches/py3k-jit/Lib/test/test_decimal.py
   python/branches/py3k-jit/Lib/test/test_float.py
   python/branches/py3k-jit/Lib/test/test_gdb.py
   python/branches/py3k-jit/Lib/test/test_getargs2.py
   python/branches/py3k-jit/Lib/test/test_import.py
   python/branches/py3k-jit/Lib/test/test_linecache.py
   python/branches/py3k-jit/Lib/test/test_os.py
   python/branches/py3k-jit/Lib/test/test_pipes.py
   python/branches/py3k-jit/Lib/test/test_ssl.py
   python/branches/py3k-jit/Lib/test/test_subprocess.py
   python/branches/py3k-jit/Lib/test/test_sys.py
   python/branches/py3k-jit/Lib/test/test_sysconfig.py
   python/branches/py3k-jit/Lib/test/test_warnings.py
   python/branches/py3k-jit/Misc/NEWS
   python/branches/py3k-jit/Modules/_io/textio.c
   python/branches/py3k-jit/Modules/_sqlite/connection.c
   python/branches/py3k-jit/Modules/_sqlite/cursor.c
   python/branches/py3k-jit/Modules/_sqlite/row.c
   python/branches/py3k-jit/Modules/_sqlite/statement.c
   python/branches/py3k-jit/Modules/_ssl.c
   python/branches/py3k-jit/Modules/main.c
   python/branches/py3k-jit/Objects/complexobject.c
   python/branches/py3k-jit/Objects/longobject.c
   python/branches/py3k-jit/Objects/moduleobject.c
   python/branches/py3k-jit/Objects/object.c
   python/branches/py3k-jit/Objects/typeobject.c
   python/branches/py3k-jit/Parser/asdl.py
   python/branches/py3k-jit/Python/_warnings.c
   python/branches/py3k-jit/Python/bltinmodule.c
   python/branches/py3k-jit/Python/getargs.c
   python/branches/py3k-jit/Python/pythonrun.c
   python/branches/py3k-jit/Python/sysmodule.c
   python/branches/py3k-jit/Tools/gdb/libpython.py

Modified: python/branches/py3k-jit/Doc/c-api/init.rst
==============================================================================
--- python/branches/py3k-jit/Doc/c-api/init.rst	(original)
+++ python/branches/py3k-jit/Doc/c-api/init.rst	Tue May 25 03:17:49 2010
@@ -22,6 +22,7 @@
       module: sys
       triple: module; search; path
       single: PySys_SetArgv()
+      single: PySys_SetArgvEx()
       single: Py_Finalize()
 
    Initialize the Python interpreter.  In an application embedding  Python, this
@@ -31,7 +32,7 @@
    the table of loaded modules (``sys.modules``), and creates the fundamental
    modules :mod:`builtins`, :mod:`__main__` and :mod:`sys`.  It also initializes
    the module search path (``sys.path``). It does not set ``sys.argv``; use
-   :cfunc:`PySys_SetArgv` for that.  This is a no-op when called for a second time
+   :cfunc:`PySys_SetArgvEx` for that.  This is a no-op when called for a second time
    (without calling :cfunc:`Py_Finalize` first).  There is no return value; it is a
    fatal error if the initialization fails.
 
@@ -337,7 +338,7 @@
    ``sys.version``.
 
 
-.. cfunction:: void PySys_SetArgv(int argc, wchar_t **argv)
+.. cfunction:: void PySys_SetArgvEx(int argc, wchar_t **argv, int updatepath)
 
    .. index::
       single: main()
@@ -352,14 +353,41 @@
    string.  If this function fails to initialize :data:`sys.argv`, a fatal
    condition is signalled using :cfunc:`Py_FatalError`.
 
-   This function also prepends the executed script's path to :data:`sys.path`.
-   If no script is executed (in the case of calling ``python -c`` or just the
-   interactive interpreter), the empty string is used instead.
+   If *updatepath* is zero, this is all the function does.  If *updatepath*
+   is non-zero, the function also modifies :data:`sys.path` according to the
+   following algorithm:
+
+   - If the name of an existing script is passed in ``argv[0]``, the absolute
+     path of the directory where the script is located is prepended to
+     :data:`sys.path`.
+   - Otherwise (that is, if *argc* is 0 or ``argv[0]`` doesn't point
+     to an existing file name), an empty string is prepended to
+     :data:`sys.path`, which is the same as prepending the current working
+     directory (``"."``).
+
+   .. note::
+      It is recommended that applications embedding the Python interpreter
+      for purposes other than executing a single script pass 0 as *updatepath*,
+      and update :data:`sys.path` themselves if desired.
+      See `CVE-2008-5983 <http://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2008-5983>`_.
+
+      On versions before 3.1.3, you can achieve the same effect by manually
+      popping the first :data:`sys.path` element after having called
+      :cfunc:`PySys_SetArgv`, for example using::
+
+         PyRun_SimpleString("import sys; sys.path.pop(0)\n");
+
+   .. versionadded:: 3.1.3
 
    .. XXX impl. doesn't seem consistent in allowing 0/NULL for the params;
       check w/ Guido.
 
 
+.. cfunction:: void PySys_SetArgv(int argc, wchar_t **argv)
+
+   This function works like :cfunc:`PySys_SetArgv` with *updatepath* set to 1.
+
+
 .. cfunction:: void Py_SetPythonHome(wchar_t *home)
 
    Set the default "home" directory, that is, the location of the standard

Modified: python/branches/py3k-jit/Doc/c-api/sys.rst
==============================================================================
--- python/branches/py3k-jit/Doc/c-api/sys.rst	(original)
+++ python/branches/py3k-jit/Doc/c-api/sys.rst	Tue May 25 03:17:49 2010
@@ -81,6 +81,10 @@
 
    Append *s* to :data:`sys.warnoptions`.
 
+.. cfunction:: void PySys_AddWarnOptionUnicode(PyObject *unicode)
+
+   Append *unicode* to :data:`sys.warnoptions`.
+
 .. cfunction:: void PySys_SetPath(wchar_t *path)
 
    Set :data:`sys.path` to a list object of paths found in *path* which should

Modified: python/branches/py3k-jit/Doc/howto/index.rst
==============================================================================
--- python/branches/py3k-jit/Doc/howto/index.rst	(original)
+++ python/branches/py3k-jit/Doc/howto/index.rst	Tue May 25 03:17:49 2010
@@ -16,6 +16,7 @@
    advocacy.rst
    cporting.rst
    curses.rst
+   descriptor.rst
    doanddont.rst
    functional.rst
    regex.rst

Modified: python/branches/py3k-jit/Doc/library/argparse.rst
==============================================================================
--- python/branches/py3k-jit/Doc/library/argparse.rst	(original)
+++ python/branches/py3k-jit/Doc/library/argparse.rst	Tue May 25 03:17:49 2010
@@ -672,8 +672,8 @@
 
     >>> import argparse
     >>> parser = argparse.ArgumentParser(prog='PROG')
-    >>> parser.add_argument('-v', '--version', action='version', version='%(prog)s 2.0')
-    >>> parser.parse_args(['-v'])
+    >>> parser.add_argument('--version', action='version', version='%(prog)s 2.0')
+    >>> parser.parse_args(['--version'])
     PROG 2.0
 
 You can also specify an arbitrary action by passing an object that implements
@@ -1725,3 +1725,6 @@
 * Replace strings with implicit arguments such as ``%default`` or ``%prog`` with
   the standard python syntax to use dictionaries to format strings, that is,
   ``%(default)s`` and ``%(prog)s``.
+
+* Replace the OptionParser constructor ``version`` argument with a call to
+  ``parser.add_argument('--version', action='version', version='<the version>')``

Modified: python/branches/py3k-jit/Doc/library/decimal.rst
==============================================================================
--- python/branches/py3k-jit/Doc/library/decimal.rst	(original)
+++ python/branches/py3k-jit/Doc/library/decimal.rst	Tue May 25 03:17:49 2010
@@ -122,7 +122,7 @@
    >>> from decimal import *
    >>> getcontext()
    Context(prec=28, rounding=ROUND_HALF_EVEN, Emin=-999999999, Emax=999999999,
-           capitals=1, flags=[], traps=[Overflow, DivisionByZero,
+           capitals=1, clamp=0, flags=[], traps=[Overflow, DivisionByZero,
            InvalidOperation])
 
    >>> getcontext().prec = 7       # Set a new precision
@@ -244,7 +244,7 @@
 
    >>> ExtendedContext
    Context(prec=9, rounding=ROUND_HALF_EVEN, Emin=-999999999, Emax=999999999,
-           capitals=1, flags=[], traps=[])
+           capitals=1, clamp=0, flags=[], traps=[])
    >>> setcontext(ExtendedContext)
    >>> Decimal(1) / Decimal(7)
    Decimal('0.142857143')
@@ -269,7 +269,7 @@
    Decimal('3.14159292')
    >>> getcontext()
    Context(prec=9, rounding=ROUND_HALF_EVEN, Emin=-999999999, Emax=999999999,
-           capitals=1, flags=[Inexact, Rounded], traps=[])
+           capitals=1, clamp=0, 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
@@ -891,7 +891,7 @@
 :class:`Context` constructor.
 
 
-.. class:: Context(prec=None, rounding=None, traps=None, flags=None, Emin=None, Emax=None, capitals=1)
+.. class:: Context(prec=None, rounding=None, traps=None, flags=None, Emin=None, Emax=None, capitals=None, clamp=None)
 
    Creates a new context.  If a field is not specified or is :const:`None`, the
    default values are copied from the :const:`DefaultContext`.  If the *flags*
@@ -922,6 +922,23 @@
    :const:`1`, exponents are printed with a capital :const:`E`; otherwise, a
    lowercase :const:`e` is used: :const:`Decimal('6.02e+23')`.
 
+   The *clamp* field is either :const:`0` (the default) or :const:`1`.
+   If set to :const:`1`, the exponent ``e`` of a :class:`Decimal`
+   instance representable in this context is strictly limited to the
+   range ``Emin - prec + 1 <= e <= Emax - prec + 1``.  If *clamp* is
+   :const:`0` then a weaker condition holds: the adjusted exponent of
+   the :class:`Decimal` instance is at most ``Emax``.  When *clamp* is
+   :const:`1`, a large normal number will, where possible, have its
+   exponent reduced and a corresponding number of zeros added to its
+   coefficient, in order to fit the exponent constraints; this
+   preserves the value of the number but loses information about
+   significant trailing zeros.  For example::
+
+      >>> Context(prec=6, Emax=999, clamp=1).create_decimal('1.23e999')
+      Decimal('1.23000E+999')
+
+   A *clamp* value of :const:`1` allows compatibility with the
+   fixed-width decimal interchange formats specified in IEEE 754.
 
    The :class:`Context` class defines several general purpose methods as well as
    a large number of methods for doing arithmetic directly in a given context.

Modified: python/branches/py3k-jit/Doc/library/fcntl.rst
==============================================================================
--- python/branches/py3k-jit/Doc/library/fcntl.rst	(original)
+++ python/branches/py3k-jit/Doc/library/fcntl.rst	Tue May 25 03:17:49 2010
@@ -8,8 +8,8 @@
 
 
 .. index::
-   pair: UNIX at Unix; file control
-   pair: UNIX at Unix; I/O control
+   pair: UNIX; file control
+   pair: UNIX; I/O control
 
 This module performs file control and I/O control on file descriptors. It is an
 interface to the :cfunc:`fcntl` and :cfunc:`ioctl` Unix routines.

Modified: python/branches/py3k-jit/Doc/library/ftplib.rst
==============================================================================
--- python/branches/py3k-jit/Doc/library/ftplib.rst	(original)
+++ python/branches/py3k-jit/Doc/library/ftplib.rst	Tue May 25 03:17:49 2010
@@ -122,7 +122,7 @@
    The set of all exceptions (as a tuple) that methods of :class:`FTP`
    instances may raise as a result of problems with the FTP connection (as
    opposed to programming errors made by the caller).  This set includes the
-   four exceptions listed below as well as :exc:`socket.error` and
+   four exceptions listed above as well as :exc:`socket.error` and
    :exc:`IOError`.
 
 .. seealso::

Modified: python/branches/py3k-jit/Doc/library/getopt.rst
==============================================================================
--- python/branches/py3k-jit/Doc/library/getopt.rst	(original)
+++ python/branches/py3k-jit/Doc/library/getopt.rst	Tue May 25 03:17:49 2010
@@ -5,6 +5,12 @@
    :synopsis: Portable parser for command line options; support both short and
               long option names.
 
+.. note::
+   The :mod:`getopt` module is a parser for command line options whose API is
+   designed to be familiar to users of the C :cfunc:`getopt` function. Users who
+   are unfamiliar with the C :cfunc:`getopt` function or who would like to write
+   less code and get better help and error messages should consider using the
+   :mod:`argparse` module instead.
 
 This module helps scripts to parse the command line arguments in ``sys.argv``.
 It supports the same conventions as the Unix :cfunc:`getopt` function (including
@@ -136,9 +142,21 @@
    if __name__ == "__main__":
        main()
 
+Note that an equivalent command line interface could be produced with less code
+and more informative help and error messages by using the :mod:`argparse` module::
+
+   import argparse
+
+   if __name__ == '__main__':
+       parser = argparse.ArgumentParser()
+       parser.add_argument('-o', '--output')
+       parser.add_argument('-v', dest='verbose', action='store_true')
+       args = parser.parse_args()
+       # ... do something with args.output ...
+       # ... do something with args.verbose ..
 
 .. seealso::
 
-   Module :mod:`optparse`
-      More object-oriented command line option parsing.
+   Module :mod:`argparse`
+      Alternative command line option and argument parsing library.
 

Modified: python/branches/py3k-jit/Doc/library/hashlib.rst
==============================================================================
--- python/branches/py3k-jit/Doc/library/hashlib.rst	(original)
+++ python/branches/py3k-jit/Doc/library/hashlib.rst	Tue May 25 03:17:49 2010
@@ -151,7 +151,7 @@
    http://csrc.nist.gov/publications/fips/fips180-2/fips180-2.pdf
       The FIPS 180-2 publication on Secure Hash Algorithms.
 
-   http://www.cryptography.com/cnews/hash.html
-      Hash Collision FAQ with information on which algorithms have known issues and
+   http://en.wikipedia.org/wiki/Cryptographic_hash_function#Cryptographic_hash_algorithms
+      Wikipedia article with information on which algorithms have known issues and
       what that means regarding their use.
 

Modified: python/branches/py3k-jit/Doc/library/io.rst
==============================================================================
--- python/branches/py3k-jit/Doc/library/io.rst	(original)
+++ python/branches/py3k-jit/Doc/library/io.rst	Tue May 25 03:17:49 2010
@@ -240,7 +240,7 @@
 
       Flush and close this stream. This method has no effect if the file is
       already closed. Once the file is closed, any operation on the file
-      (e.g. reading or writing) will raise an :exc:`ValueError`.
+      (e.g. reading or writing) will raise a :exc:`ValueError`.
 
       As a convenience, it is allowed to call this method more than once;
       only the first call, however, will have an effect.

Modified: python/branches/py3k-jit/Doc/library/json.rst
==============================================================================
--- python/branches/py3k-jit/Doc/library/json.rst	(original)
+++ python/branches/py3k-jit/Doc/library/json.rst	Tue May 25 03:17:49 2010
@@ -209,7 +209,7 @@
    specified.  Encodings that are not ASCII based (such as UCS-2) are not
    allowed and should be decoded to :class:`str` first.
 
-   The other arguments have the same meaning as in :func:`dump`.
+   The other arguments have the same meaning as in :func:`load`.
 
 
 Encoders and decoders

Modified: python/branches/py3k-jit/Doc/library/multiprocessing.rst
==============================================================================
--- python/branches/py3k-jit/Doc/library/multiprocessing.rst	(original)
+++ python/branches/py3k-jit/Doc/library/multiprocessing.rst	Tue May 25 03:17:49 2010
@@ -837,7 +837,7 @@
 
    A bounded semaphore object: a clone of :class:`threading.BoundedSemaphore`.
 
-   (On Mac OS X this is indistinguishable from :class:`Semaphore` because
+   (On Mac OS X, this is indistinguishable from :class:`Semaphore` because
    ``sem_getvalue()`` is not implemented on that platform).
 
 .. class:: Condition([lock])
@@ -879,9 +879,8 @@
    specifies a timeout in seconds.  If *block* is ``False`` then *timeout* is
    ignored.
 
-.. note::
-   On OS/X ``sem_timedwait`` is unsupported, so timeout arguments for the
-   aforementioned :meth:`acquire` methods will be ignored on OS/X.
+   On Mac OS X, ``sem_timedwait`` is unsupported, so calling ``acquire()`` with
+   a timeout will emulate that function's behavior using a sleeping loop.
 
 .. note::
 

Modified: python/branches/py3k-jit/Doc/library/optparse.rst
==============================================================================
--- python/branches/py3k-jit/Doc/library/optparse.rst	(original)
+++ python/branches/py3k-jit/Doc/library/optparse.rst	Tue May 25 03:17:49 2010
@@ -3,6 +3,12 @@
 
 .. module:: optparse
    :synopsis: Command-line option parsing library.
+   :deprecated:
+
+.. deprecated:: 2.7
+   The :mod:`optparse` module is deprecated and will not be developed further;
+   development will continue with the :mod:`argparse` module.
+
 .. moduleauthor:: Greg Ward <gward at python.net>
 .. sectionauthor:: Greg Ward <gward at python.net>
 

Modified: python/branches/py3k-jit/Doc/library/os.rst
==============================================================================
--- python/branches/py3k-jit/Doc/library/os.rst	(original)
+++ python/branches/py3k-jit/Doc/library/os.rst	Tue May 25 03:17:49 2010
@@ -142,7 +142,8 @@
    synchronized (modify :data:`environb` updates :data:`environ`, and vice
    versa).
 
-   Availability: Unix.
+   :data:`environb` is only available if :data:`supports_bytes_environ` is
+   True.
 
    .. versionadded:: 3.2
 
@@ -457,6 +458,14 @@
    Availability: Unix, Windows.
 
 
+.. data:: supports_bytes_environ
+
+   True if the native OS type of the environment is bytes (eg. False on
+   Windows).
+
+   .. versionadded:: 3.2
+
+
 .. function:: umask(mask)
 
    Set the current numeric umask and return the previous umask.
@@ -688,6 +697,14 @@
    Availability: Unix, Windows.
 
 
+.. data:: SEEK_SET
+          SEEK_CUR
+          SEEK_END
+
+   Parameters to the :func:`lseek` function. Their values are 0, 1, and 2,
+   respectively. Availability: Windows, Unix.
+
+
 .. function:: open(file, flags[, mode])
 
    Open the file *file* and set various flags according to *flags* and possibly
@@ -697,7 +714,8 @@
 
    For a description of the flag and mode values, see the C run-time documentation;
    flag constants (like :const:`O_RDONLY` and :const:`O_WRONLY`) are defined in
-   this module too (see below).
+   this module too (see :ref:`open-constants`).  In particular, on Windows adding
+   :const:`O_BINARY` is needed to open files in binary mode.
 
    Availability: Unix, Windows.
 
@@ -785,6 +803,12 @@
       :func:`fdopen`, or :data:`sys.stdout` or :data:`sys.stderr`, use its
       :meth:`~file.write` method.
 
+
+.. _open-constants:
+
+``open()`` flag constants
+~~~~~~~~~~~~~~~~~~~~~~~~~
+
 The following constants are options for the *flags* parameter to the
 :func:`~os.open` function.  They can be combined using the bitwise OR operator
 ``|``.  Some of them are not available on all platforms.  For descriptions of
@@ -836,14 +860,6 @@
    the C library.
 
 
-.. data:: SEEK_SET
-          SEEK_CUR
-          SEEK_END
-
-   Parameters to the :func:`lseek` function. Their values are 0, 1, and 2,
-   respectively. Availability: Windows, Unix.
-
-
 .. _os-file-dir:
 
 Files and Directories
@@ -2178,8 +2194,8 @@
 
 .. data:: devnull
 
-   The file path of the null device. For example: ``'/dev/null'`` for POSIX.
-   Also available via :mod:`os.path`.
+   The file path of the null device. For example: ``'/dev/null'`` for
+   POSIX, ``'nul'`` for Windows.  Also available via :mod:`os.path`.
 
 
 .. _os-miscfunc:

Modified: python/branches/py3k-jit/Doc/library/socket.rst
==============================================================================
--- python/branches/py3k-jit/Doc/library/socket.rst	(original)
+++ python/branches/py3k-jit/Doc/library/socket.rst	Tue May 25 03:17:49 2010
@@ -89,8 +89,9 @@
 and out-of-memory conditions can be raised; errors related to socket or address
 semantics raise the error :exc:`socket.error`.
 
-Non-blocking mode is supported through :meth:`setblocking`.  A generalization of
-this based on timeouts is supported through :meth:`settimeout`.
+Non-blocking mode is supported through :meth:`~socket.setblocking`.  A
+generalization of this based on timeouts is supported through
+:meth:`~socket.settimeout`.
 
 The module :mod:`socket` exports the following constants and functions:
 
@@ -559,7 +560,9 @@
    :platform: Windows
 
    The :meth:`ioctl` method is a limited interface to the WSAIoctl system
-   interface. Please refer to the MSDN documentation for more information.
+   interface.  Please refer to the `Win32 documentation
+   <http://msdn.microsoft.com/en-us/library/ms741621%28VS.85%29.aspx>`_ for more
+   information.
 
    On other platforms, the generic :func:`fcntl.fcntl` and :func:`fcntl.ioctl`
    functions may be used; they accept a socket object as their first argument.
@@ -662,7 +665,7 @@
    blocking mode.  In non-blocking mode, if a :meth:`recv` call doesn't find any
    data, or if a :meth:`send` call can't immediately dispose of the data, a
    :exc:`error` exception is raised; in blocking mode, the calls block until they
-   can proceed. ``s.setblocking(0)`` is equivalent to ``s.settimeout(0)``;
+   can proceed. ``s.setblocking(0)`` is equivalent to ``s.settimeout(0.0)``;
    ``s.setblocking(1)`` is equivalent to ``s.settimeout(None)``.
 
 
@@ -691,21 +694,21 @@
 non-blocking mode, operations fail (with an error that is unfortunately
 system-dependent) if they cannot be completed immediately.  In timeout mode,
 operations fail if they cannot be completed within the timeout specified for the
-socket or if the system returns an error.  The :meth:`setblocking` method is simply
-a shorthand for certain :meth:`settimeout` calls.
+socket or if the system returns an error.  The :meth:`~socket.setblocking`
+method is simply a shorthand for certain :meth:`~socket.settimeout` calls.
 
 Timeout mode internally sets the socket in non-blocking mode.  The blocking and
 timeout modes are shared between file descriptors and socket objects that refer
 to the same network endpoint.  A consequence of this is that file objects
-returned by the :meth:`makefile` method must only be used when the socket is in
-blocking mode; in timeout or non-blocking mode file operations that cannot be
-completed immediately will fail.
-
-Note that the :meth:`connect` operation is subject to the timeout setting, and
-in general it is recommended to call :meth:`settimeout` before calling
-:meth:`connect` or pass a timeout parameter to :meth:`create_connection`.
-The system network stack may return a connection timeout error
-of its own regardless of any Python socket timeout setting.
+returned by the :meth:`~socket.makefile` method must only be used when the
+socket is in blocking mode; in timeout or non-blocking mode file operations
+that cannot be completed immediately will fail.
+
+Note that the :meth:`~socket.connect` operation is subject to the timeout
+setting, and in general it is recommended to call :meth:`~socket.settimeout`
+before calling :meth:`~socket.connect` or pass a timeout parameter to
+:meth:`create_connection`.  The system network stack may return a connection
+timeout error of its own regardless of any Python socket timeout setting.
 
 
 .. method:: socket.setsockopt(level, optname, value)
@@ -727,8 +730,8 @@
    are disallowed.  If *how* is :const:`SHUT_RDWR`, further sends and receives are
    disallowed.
 
-Note that there are no methods :meth:`read` or :meth:`write`; use :meth:`recv`
-and :meth:`send` without *flags* argument instead.
+Note that there are no methods :meth:`read` or :meth:`write`; use
+:meth:`~socket.recv` and :meth:`~socket.send` without *flags* argument instead.
 
 Socket objects also have these (read-only) attributes that correspond to the
 values given to the :class:`socket` constructor.
@@ -757,11 +760,12 @@
 Here are four minimal example programs using the TCP/IP protocol: a server that
 echoes all data that it receives back (servicing only one client), and a client
 using it.  Note that a server must perform the sequence :func:`socket`,
-:meth:`bind`, :meth:`listen`, :meth:`accept` (possibly repeating the
-:meth:`accept` to service more than one client), while a client only needs the
-sequence :func:`socket`, :meth:`connect`.  Also note that the server does not
-:meth:`send`/:meth:`recv` on the  socket it is listening on but on the new
-socket returned by :meth:`accept`.
+:meth:`~socket.bind`, :meth:`~socket.listen`, :meth:`~socket.accept` (possibly
+repeating the :meth:`~socket.accept` to service more than one client), while a
+client only needs the sequence :func:`socket`, :meth:`~socket.connect`.  Also
+note that the server does not :meth:`~socket.send`/:meth:`~socket.recv` on the
+socket it is listening on but on the new socket returned by
+:meth:`~socket.accept`.
 
 The first two examples support IPv4 only. ::
 

Modified: python/branches/py3k-jit/Doc/library/ssl.rst
==============================================================================
--- python/branches/py3k-jit/Doc/library/ssl.rst	(original)
+++ python/branches/py3k-jit/Doc/library/ssl.rst	Tue May 25 03:17:49 2010
@@ -257,6 +257,37 @@
    modern version, and probably the best choice for maximum protection, if both
    sides can speak it.
 
+.. data:: OP_ALL
+
+   Enables workarounds for various bugs present in other SSL implementations.
+   This option is set by default.
+
+   .. versionadded:: 3.2
+
+.. data:: OP_NO_SSLv2
+
+   Prevents an SSLv2 connection.  This option is only applicable in
+   conjunction with :const:`PROTOCOL_SSLv23`.  It prevents the peers from
+   choosing SSLv2 as the protocol version.
+
+   .. versionadded:: 3.2
+
+.. data:: OP_NO_SSLv3
+
+   Prevents an SSLv3 connection.  This option is only applicable in
+   conjunction with :const:`PROTOCOL_SSLv23`.  It prevents the peers from
+   choosing SSLv3 as the protocol version.
+
+   .. versionadded:: 3.2
+
+.. data:: OP_NO_TLSv1
+
+   Prevents a TLSv1 connection.  This option is only applicable in
+   conjunction with :const:`PROTOCOL_SSLv23`.  It prevents the peers from
+   choosing TLSv1 as the protocol version.
+
+   .. versionadded:: 3.2
+
 .. data:: OPENSSL_VERSION
 
    The version string of the OpenSSL library loaded by the interpreter::
@@ -379,6 +410,8 @@
 SSL Contexts
 ------------
 
+.. versionadded:: 3.2
+
 .. class:: SSLContext(protocol)
 
    An object holding various data longer-lived than single SSL connections,
@@ -440,6 +473,17 @@
    and *suppress_ragged_eofs* have the same meaning as in the top-level
    :func:`wrap_socket` function.
 
+.. attribute:: SSLContext.options
+
+   An integer representing the set of SSL options enabled on this context.
+   The default value is :data:`OP_ALL`, but you can specify other options
+   such as :data:`OP_NO_SSLv2` by ORing them together.
+
+   .. note::
+      With versions of OpenSSL older than 0.9.8m, it is only possible
+      to set options, not to clear them.  Attempting to clear an option
+      (by resetting the corresponding bits) will raise a ``ValueError``.
+
 .. attribute:: SSLContext.protocol
 
    The protocol version chosen when constructing the context.  This attribute
@@ -794,6 +838,20 @@
       equivalent unless anonymous ciphers are enabled (they are disabled
       by default).
 
+Protocol versions
+^^^^^^^^^^^^^^^^^
+
+SSL version 2 is considered insecure and is therefore dangerous to use.  If
+you want maximum compatibility between clients and servers, it is recommended
+to use :const:`PROTOCOL_SSLv23` as the protocol version and then disable
+SSLv2 explicitly using the :data:`SSLContext.options` attribute::
+
+   context = ssl.SSLContext(ssl.PROTOCOL_SSLv23)
+   context.options |= ssl.OP_NO_SSLv2
+
+The SSL context created above will allow SSLv3 and TLSv1 connections, but
+not SSLv2.
+
 
 .. seealso::
 

Modified: python/branches/py3k-jit/Doc/library/stdtypes.rst
==============================================================================
--- python/branches/py3k-jit/Doc/library/stdtypes.rst	(original)
+++ python/branches/py3k-jit/Doc/library/stdtypes.rst	Tue May 25 03:17:49 2010
@@ -595,6 +595,109 @@
    '0x1.d380000000000p+11'
 
 
+.. _numeric-hash:
+
+Hashing of numeric types
+------------------------
+
+For numbers ``x`` and ``y``, possibly of different types, it's a requirement
+that ``hash(x) == hash(y)`` whenever ``x == y`` (see the :meth:`__hash__`
+method documentation for more details).  For ease of implementation and
+efficiency across a variety of numeric types (including :class:`int`,
+:class:`float`, :class:`decimal.Decimal` and :class:`fractions.Fraction`)
+Python's hash for numeric types is based on a single mathematical function
+that's defined for any rational number, and hence applies to all instances of
+:class:`int` and :class:`fraction.Fraction`, and all finite instances of
+:class:`float` and :class:`decimal.Decimal`.  Essentially, this function is
+given by reduction modulo ``P`` for a fixed prime ``P``.  The value of ``P`` is
+made available to Python as the :attr:`modulus` attribute of
+:data:`sys.hash_info`.
+
+.. impl-detail::
+
+   Currently, the prime used is ``P = 2**31 - 1`` on machines with 32-bit C
+   longs and ``P = 2**61 - 1`` on machines with 64-bit C longs.
+
+Here are the rules in detail:
+
+ - If ``x = m / n`` is a nonnegative rational number and ``n`` is not divisible
+   by ``P``, define ``hash(x)`` as ``m * invmod(n, P) % P``, where ``invmod(n,
+   P)`` gives the inverse of ``n`` modulo ``P``.
+
+ - If ``x = m / n`` is a nonnegative rational number and ``n`` is
+   divisible by ``P`` (but ``m`` is not) then ``n`` has no inverse
+   modulo ``P`` and the rule above doesn't apply; in this case define
+   ``hash(x)`` to be the constant value ``sys.hash_info.inf``.
+
+ - If ``x = m / n`` is a negative rational number define ``hash(x)``
+   as ``-hash(-x)``.  If the resulting hash is ``-1``, replace it with
+   ``-2``.
+
+ - The particular values ``sys.hash_info.inf``, ``-sys.hash_info.inf``
+   and ``sys.hash_info.nan`` are used as hash values for positive
+   infinity, negative infinity, or nans (respectively).  (All hashable
+   nans have the same hash value.)
+
+ - For a :class:`complex` number ``z``, the hash values of the real
+   and imaginary parts are combined by computing ``hash(z.real) +
+   sys.hash_info.imag * hash(z.imag)``, reduced modulo
+   ``2**sys.hash_info.width`` so that it lies in
+   ``range(-2**(sys.hash_info.width - 1), 2**(sys.hash_info.width -
+   1))``.  Again, if the result is ``-1``, it's replaced with ``-2``.
+
+
+To clarify the above rules, here's some example Python code,
+equivalent to the builtin hash, for computing the hash of a rational
+number, :class:`float`, or :class:`complex`::
+
+
+   import sys, math
+
+   def hash_fraction(m, n):
+       """Compute the hash of a rational number m / n.
+
+       Assumes m and n are integers, with n positive.
+       Equivalent to hash(fractions.Fraction(m, n)).
+
+       """
+       P = sys.hash_info.modulus
+       # Remove common factors of P.  (Unnecessary if m and n already coprime.)
+       while m % P == n % P == 0:
+           m, n = m // P, n // P
+
+       if n % P == 0:
+           hash_ = sys.hash_info.inf
+       else:
+           # Fermat's Little Theorem: pow(n, P-1, P) is 1, so
+           # pow(n, P-2, P) gives the inverse of n modulo P.
+           hash_ = (abs(m) % P) * pow(n, P - 2, P) % P
+       if m < 0:
+           hash_ = -hash_
+       if hash_ == -1:
+           hash_ = -2
+       return hash_
+
+   def hash_float(x):
+       """Compute the hash of a float x."""
+
+       if math.isnan(x):
+           return sys.hash_info.nan
+       elif math.isinf(x):
+           return sys.hash_info.inf if x > 0 else -sys.hash_info.inf
+       else:
+           return hash_fraction(*x.as_integer_ratio())
+
+   def hash_complex(z):
+       """Compute the hash of a complex number z."""
+
+       hash_ = hash_float(z.real) + sys.hash_info.imag * hash_float(z.imag)
+       # do a signed reduction modulo 2**sys.hash_info.width
+       M = 2**(sys.hash_info.width - 1)
+       hash_ = (hash_ & (M - 1)) - (hash & M)
+       if hash_ == -1:
+           hash_ == -2
+       return hash_
+
 .. _typeiter:
 
 Iterator Types

Modified: python/branches/py3k-jit/Doc/library/symtable.rst
==============================================================================
--- python/branches/py3k-jit/Doc/library/symtable.rst	(original)
+++ python/branches/py3k-jit/Doc/library/symtable.rst	Tue May 25 03:17:49 2010
@@ -67,7 +67,7 @@
 
       Return ``True`` if the block uses ``exec``.
 
-   .. method:: has_import_start()
+   .. method:: has_import_star()
 
       Return ``True`` if the block uses a starred from-import.
 

Modified: python/branches/py3k-jit/Doc/library/sys.rst
==============================================================================
--- python/branches/py3k-jit/Doc/library/sys.rst	(original)
+++ python/branches/py3k-jit/Doc/library/sys.rst	Tue May 25 03:17:49 2010
@@ -446,6 +446,30 @@
       Changed to a named tuple and added *service_pack_minor*,
       *service_pack_major*, *suite_mask*, and *product_type*.
 
+
+.. data:: hash_info
+
+   A structseq giving parameters of the numeric hash implementation.  For
+   more details about hashing of numeric types, see :ref:`numeric-hash`.
+
+   +---------------------+--------------------------------------------------+
+   | attribute           | explanation                                      |
+   +=====================+==================================================+
+   | :const:`width`      | width in bits used for hash values               |
+   +---------------------+--------------------------------------------------+
+   | :const:`modulus`    | prime modulus P used for numeric hash scheme     |
+   +---------------------+--------------------------------------------------+
+   | :const:`inf`        | hash value returned for a positive infinity      |
+   +---------------------+--------------------------------------------------+
+   | :const:`nan`        | hash value returned for a nan                    |
+   +---------------------+--------------------------------------------------+
+   | :const:`imag`       | multiplier used for the imaginary part of a      |
+   |                     | complex number                                   |
+   +---------------------+--------------------------------------------------+
+
+   .. versionadded:: 3.2
+
+
 .. data:: hexversion
 
    The version number encoded as a single integer.  This is guaranteed to increase

Modified: python/branches/py3k-jit/Doc/library/syslog.rst
==============================================================================
--- python/branches/py3k-jit/Doc/library/syslog.rst	(original)
+++ python/branches/py3k-jit/Doc/library/syslog.rst	Tue May 25 03:17:49 2010
@@ -10,66 +10,63 @@
 Refer to the Unix manual pages for a detailed description of the ``syslog``
 facility.
 
-This module wraps the system ``syslog`` module.  A pure Python
-library that can speak to a syslog server is available in
-the :mod:`logging.handlers` module as :class:`SysLogHandler`.
+This module wraps the system ``syslog`` family of routines.  A pure Python
+library that can speak to a syslog server is available in the
+:mod:`logging.handlers` module as :class:`SysLogHandler`.
 
 The module defines the following functions:
 
 
 .. function:: syslog([priority,] message)
 
-   Send the string *message* to the system logger.  A trailing newline is
-   added if necessary.  Each message is tagged with a priority composed
-   of a *facility* and a *level*.  The optional *priority* argument, which
-   defaults to :const:`LOG_INFO`, determines the message priority.  If the
-   facility is not encoded in *priority* using logical-or (``LOG_INFO |
-   LOG_USER``), the value given in the :func:`openlog` call is used.
+   Send the string *message* to the system logger.  A trailing newline is added
+   if necessary.  Each message is tagged with a priority composed of a
+   *facility* and a *level*.  The optional *priority* argument, which defaults
+   to :const:`LOG_INFO`, determines the message priority.  If the facility is
+   not encoded in *priority* using logical-or (``LOG_INFO | LOG_USER``), the
+   value given in the :func:`openlog` call is used.
 
-   If :func:`openlog` has not been called prior to the call to
-   :func:'syslog', ``openlog()`` will be called with no arguments.
+   If :func:`openlog` has not been called prior to the call to :func:`syslog`,
+   ``openlog()`` will be called with no arguments.
 
 
 .. function:: openlog([ident[, logopt[, facility]]])
 
-   Logging options of subsequent :func:`syslog` calls can be set by
-   calling :func:`openlog`.  :func:`syslog` will call :func:`openlog`
-   with no arguments if the log is not currently open.
-
-   The optional *ident* keyword argument is a string which is prepended
-   to every message, and defaults to ''sys.argv[0]'' with leading
-   path components stripped.  The optional *logopt* keyword argument
-   (default=0) is a bit field - see below for possible values to combine.
-   The optional *facility* keyword argument (default=:const:`LOG_USER`)
-   sets the default facility for messages which do not have a facility
-   explicitly encoded.
-
-   .. versionchanged::3.2
-      In previous versions, keyword arguments were not allowed, and *ident*
-      was required.  The default for *ident* was dependent on the system
-      libraries, and often was ''python'' instead of the name of the
-      python program file.
+   Logging options of subsequent :func:`syslog` calls can be set by calling
+   :func:`openlog`.  :func:`syslog` will call :func:`openlog` with no arguments
+   if the log is not currently open.
+
+   The optional *ident* keyword argument is a string which is prepended to every
+   message, and defaults to ``sys.argv[0]`` with leading path components
+   stripped.  The optional *logopt* keyword argument (default is 0) is a bit
+   field -- see below for possible values to combine.  The optional *facility*
+   keyword argument (default is :const:`LOG_USER`) sets the default facility for
+   messages which do not have a facility explicitly encoded.
+
+   .. versionchanged:: 3.2
+      In previous versions, keyword arguments were not allowed, and *ident* was
+      required.  The default for *ident* was dependent on the system libraries,
+      and often was ``python`` instead of the name of the python program file.
 
 
 .. function:: closelog()
 
-   Reset the syslog module values and call the system library
-   ''closelog()''.
+   Reset the syslog module values and call the system library ``closelog()``.
 
-   This causes the module to behave as it does when initially imported.
-   For example, :func:'openlog' will be called on the first :func:'syslog'
-   call (if :func:'openlog' hasn't already been called), and *ident*
-   and other :func:'openlog' parameters are reset to defaults.
+   This causes the module to behave as it does when initially imported.  For
+   example, :func:`openlog` will be called on the first :func:`syslog` call (if
+   :func:`openlog` hasn't already been called), and *ident* and other
+   :func:`openlog` parameters are reset to defaults.
 
 
 .. function:: setlogmask(maskpri)
 
-   Set the priority mask to *maskpri* and return the previous mask value.
-   Calls to :func:`syslog` with a priority level not set in *maskpri*
-   are ignored.  The default is to log all priorities.  The function
-   ``LOG_MASK(pri)`` calculates the mask for the individual priority
-   *pri*.  The function ``LOG_UPTO(pri)`` calculates the mask for all
-   priorities up to and including *pri*.
+   Set the priority mask to *maskpri* and return the previous mask value.  Calls
+   to :func:`syslog` with a priority level not set in *maskpri* are ignored.
+   The default is to log all priorities.  The function ``LOG_MASK(pri)``
+   calculates the mask for the individual priority *pri*.  The function
+   ``LOG_UPTO(pri)`` calculates the mask for all priorities up to and including
+   *pri*.
 
 The module defines the following constants:
 
@@ -100,11 +97,11 @@
 
    syslog.syslog('Processing started')
    if error:
-      syslog.syslog(syslog.LOG_ERR, 'Processing started')
+       syslog.syslog(syslog.LOG_ERR, 'Processing started')
 
-An example of setting some log options, these would include the process ID
-in logged messages, and write the messages to the destination facility
-used for mail logging::
+An example of setting some log options, these would include the process ID in
+logged messages, and write the messages to the destination facility used for
+mail logging::
 
    syslog.openlog(logopt=syslog.LOG_PID, facility=syslog.LOG_MAIL)
    syslog.syslog('E-mail processing initiated...')

Modified: python/branches/py3k-jit/Doc/library/telnetlib.rst
==============================================================================
--- python/branches/py3k-jit/Doc/library/telnetlib.rst	(original)
+++ python/branches/py3k-jit/Doc/library/telnetlib.rst	Tue May 25 03:17:49 2010
@@ -27,16 +27,11 @@
    :class:`Telnet` represents a connection to a Telnet server. The instance is
    initially not connected by default; the :meth:`open` method must be used to
    establish a connection.  Alternatively, the host name and optional port
-   and timeout can be passed to the constructor, in which case the connection to
-   the server will be established before the constructor returns.  The optional
-   *timeout* parameter specifies a timeout in seconds for the connection attempt (if
-   not specified, the global default timeout setting will be used).
-
    number can be passed to the constructor, to, in which case the connection to
-   the server will be established before the constructor returns. The optional
+   the server will be established before the constructor returns.  The optional
    *timeout* parameter specifies a timeout in seconds for blocking operations
-   like the connection attempt (if not specified, or passed as None, the global
-   default timeout setting will be used).
+   like the connection attempt (if not specified, the global default timeout
+   setting will be used).
 
    Do not reopen an already connected instance.
 

Modified: python/branches/py3k-jit/Doc/library/tempfile.rst
==============================================================================
--- python/branches/py3k-jit/Doc/library/tempfile.rst	(original)
+++ python/branches/py3k-jit/Doc/library/tempfile.rst	Tue May 25 03:17:49 2010
@@ -27,8 +27,7 @@
 
 The module defines the following user-callable functions:
 
-
-.. function:: TemporaryFile(mode='w+b', bufsize=-1, suffix='', prefix='tmp', dir=None)
+.. function:: TemporaryFile(mode='w+b', buffering=None, encoding=None, newline=None, suffix='', prefix='tmp', dir=None)
 
    Return a file-like object that can be used as a temporary storage area.
    The file is created using :func:`mkstemp`. It will be destroyed as soon
@@ -41,8 +40,8 @@
    The *mode* parameter defaults to ``'w+b'`` so that the file created can
    be read and written without being closed.  Binary mode is used so that it
    behaves consistently on all platforms without regard for the data that is
-   stored.  *bufsize* defaults to ``-1``, meaning that the operating system
-   default is used.
+   stored.  *buffering*, *encoding* and *newline* are interpreted as for
+   :func:`open`.
 
    The *dir*, *prefix* and *suffix* parameters are passed to :func:`mkstemp`.
 
@@ -52,7 +51,7 @@
    :keyword:`with` statement, just like a normal file.
 
 
-.. function:: NamedTemporaryFile(mode='w+b', bufsize=-1, suffix='', prefix='tmp', dir=None, delete=True)
+.. function:: NamedTemporaryFile(mode='w+b', buffering=None, encoding=None, newline=None, suffix='', prefix='tmp', dir=None, delete=True)
 
    This function operates exactly as :func:`TemporaryFile` does, except that
    the file is guaranteed to have a visible name in the file system (on
@@ -67,7 +66,7 @@
    be used in a :keyword:`with` statement, just like a normal file.
 
 
-.. function:: SpooledTemporaryFile(max_size=0, mode='w+b', bufsize=-1, suffix='', prefix='tmp', dir=None)
+.. function:: SpooledTemporaryFile(max_size=0, mode='w+b', buffering=None, encoding=None, newline=None, suffix='', prefix='tmp', dir=None)
 
    This function operates exactly as :func:`TemporaryFile` does, except that
    data is spooled in memory until the file size exceeds *max_size*, or

Modified: python/branches/py3k-jit/Doc/library/test.rst
==============================================================================
--- python/branches/py3k-jit/Doc/library/test.rst	(original)
+++ python/branches/py3k-jit/Doc/library/test.rst	Tue May 25 03:17:49 2010
@@ -340,7 +340,7 @@
 
 .. function:: captured_stdout()
 
-   This is a context manager than runs the :keyword:`with` statement body using
+   This is a context manager that runs the :keyword:`with` statement body using
    a :class:`StringIO.StringIO` object as sys.stdout.  That object can be
    retrieved using the ``as`` clause of the :keyword:`with` statement.
 

Modified: python/branches/py3k-jit/Doc/library/unittest.rst
==============================================================================
--- python/branches/py3k-jit/Doc/library/unittest.rst	(original)
+++ python/branches/py3k-jit/Doc/library/unittest.rst	Tue May 25 03:17:49 2010
@@ -749,7 +749,7 @@
 
    .. method:: skipTest(reason)
 
-      Calling this during the a test method or :meth:`setUp` skips the current
+      Calling this during a test method or :meth:`setUp` skips the current
       test.  See :ref:`unittest-skipping` for more information.
 
       .. versionadded:: 3.1
@@ -773,8 +773,7 @@
       will be *msg* if given, otherwise it will be :const:`None`.
 
       .. deprecated:: 3.1
-         :meth:`failUnless`; use one of the ``assert`` variants.
-         :meth:`assert_`; use :meth:`assertTrue`.
+         :meth:`failUnless` and :meth:`assert_`; use :meth:`assertTrue`.
 
 
    .. method:: assertEqual(first, second, msg=None)

Modified: python/branches/py3k-jit/Doc/library/urllib.request.rst
==============================================================================
--- python/branches/py3k-jit/Doc/library/urllib.request.rst	(original)
+++ python/branches/py3k-jit/Doc/library/urllib.request.rst	Tue May 25 03:17:49 2010
@@ -126,26 +126,6 @@
    of the data it has downloaded, and just returns it.  In this case you just have
    to assume that the download was successful.
 
-
-.. data:: _urlopener
-
-   The public functions :func:`urlopen` and :func:`urlretrieve` create an instance
-   of the :class:`FancyURLopener` class and use it to perform their requested
-   actions.  To override this functionality, programmers can create a subclass of
-   :class:`URLopener` or :class:`FancyURLopener`, then assign an instance of that
-   class to the ``urllib.request._urlopener`` variable before calling the
-   desired function.  For example, applications may want to specify a different
-   :mailheader:`User-Agent` header than :class:`URLopener` defines.
-   This can be accomplished with the following code::
-
-      import urllib.request
-
-      class AppURLopener(urllib.request.FancyURLopener):
-          version = "App/1.7"
-
-      urllib.request._urlopener = AppURLopener()
-
-
 .. function:: urlcleanup()
 
    Clear the cache that may have been built up by previous calls to
@@ -624,7 +604,7 @@
    method on the currently installed global :class:`OpenerDirector`).  The
    optional *timeout* parameter specifies a timeout in seconds for blocking
    operations like the connection attempt (if not specified, the global default
-   timeout setting will be usedi). The timeout feature actually works only for
+   timeout setting will be used). The timeout feature actually works only for
    HTTP, HTTPS, FTP and FTPS connections).
 
 
@@ -1099,7 +1079,7 @@
 
    >>> import urllib.request
    >>> f = urllib.request.urlopen('http://www.python.org/')
-   >>> print(fp.read(100).decode('utf-8'))
+   >>> print(f.read(100).decode('utf-8'))
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtm
 

Modified: python/branches/py3k-jit/Doc/library/winreg.rst
==============================================================================
--- python/branches/py3k-jit/Doc/library/winreg.rst	(original)
+++ python/branches/py3k-jit/Doc/library/winreg.rst	Tue May 25 03:17:49 2010
@@ -8,21 +8,23 @@
 
 
 These functions expose the Windows registry API to Python.  Instead of using an
-integer as the registry handle, a handle object is used to ensure that the
-handles are closed correctly, even if the programmer neglects to explicitly
-close them.
+integer as the registry handle, a :ref:`handle object <handle-object>` is used
+to ensure that the handles are closed correctly, even if the programmer neglects
+to explicitly close them.
 
 This module offers the following functions:
 
 
 .. function:: CloseKey(hkey)
 
-   Closes a previously opened registry key. The hkey argument specifies a
+   Closes a previously opened registry key.  The *hkey* argument specifies a
    previously opened key.
 
    .. note::
-      If *hkey* is not closed using this method (or via :meth:`hkey.Close() <PyHKEY.Close>`),
-      it is closed when the *hkey* object is destroyed by Python.
+
+      If *hkey* is not closed using this method (or via :meth:`hkey.Close()
+      <PyHKEY.Close>`), it is closed when the *hkey* object is destroyed by
+      Python.
 
 
 .. function:: ConnectRegistry(computer_name, key)
@@ -120,7 +122,7 @@
 
    *res* is a reserved integer, and must be zero. The default is zero.
 
-   *sam* is an integer that specifies an access mask that describes the
+   *sam* is an integer that specifies an access mask that describes the desired
    security access for the key.  Default is :const:`KEY_ALL_ACCESS`.  See
    :ref:`Access Rights <access-rights>` for other allowed values.
 
@@ -183,13 +185,15 @@
    |       | registry type                              |
    +-------+--------------------------------------------+
    | ``2`` | An integer that identifies the type of the |
-   |       | value data                                 |
+   |       | value data (see table in docs for          |
+   |       | :meth:`SetValueEx`)                        |
    +-------+--------------------------------------------+
 
 
 .. function:: ExpandEnvironmentStrings(str)
 
-   Expands environment strings %NAME% in unicode string like :const:`REG_EXPAND_SZ`::
+   Expands environment variable placeholders ``%NAME%`` in strings like
+   :const:`REG_EXPAND_SZ`::
 
       >>> ExpandEnvironmentStrings('%windir%')
       'C:\\Windows'
@@ -223,23 +227,20 @@
    *key* is a handle returned by :func:`ConnectRegistry` or one of the constants
    :const:`HKEY_USERS` or :const:`HKEY_LOCAL_MACHINE`.
 
-   *sub_key* is a string that identifies the sub_key to load.
+   *sub_key* is a string that identifies the subkey to load.
 
    *file_name* is the name of the file to load registry data from. This file must
    have been created with the :func:`SaveKey` function. Under the file allocation
    table (FAT) file system, the filename may not have an extension.
 
-   A call to LoadKey() fails if the calling process does not have the
-   :const:`SE_RESTORE_PRIVILEGE` privilege. Note that privileges are different than
+   A call to :func:`LoadKey` fails if the calling process does not have the
+   :const:`SE_RESTORE_PRIVILEGE` privilege.  Note that privileges are different
    from permissions -- see the `RegLoadKey documentation
    <http://msdn.microsoft.com/en-us/library/ms724889%28v=VS.85%29.aspx>`__ for
    more details.
 
    If *key* is a handle returned by :func:`ConnectRegistry`, then the path
-   specified in *fileName* is relative to the remote computer.
-
-   The Win32 documentation implies *key* must be in the :const:`HKEY_USER` or
-   :const:`HKEY_LOCAL_MACHINE` tree. This may or may not be true.
+   specified in *file_name* is relative to the remote computer.
 
 
 .. function:: OpenKey(key, sub_key[, res[, sam]])
@@ -254,8 +255,8 @@
    *res* is a reserved integer, and must be zero.  The default is zero.
 
    *sam* is an integer that specifies an access mask that describes the desired
-   security access for the key.  Default is :const:`KEY_READ`.  See
-   :ref:`Access Rights <access-rights>` for other allowed values.
+   security access for the key.  Default is :const:`KEY_READ`.  See :ref:`Access
+   Rights <access-rights>` for other allowed values.
 
    The result is a new handle to the specified key.
 
@@ -327,7 +328,8 @@
    | ``0`` | The value of the registry item.         |
    +-------+-----------------------------------------+
    | ``1`` | An integer giving the registry type for |
-   |       | this value.                             |
+   |       | this value (see table in docs for       |
+   |       | :meth:`SetValueEx`)                     |
    +-------+-----------------------------------------+
 
 
@@ -338,10 +340,10 @@
    *key* is an already open key, or one of the predefined
    :ref:`HKEY_* constants <hkey-constants>`.
 
-   *file_name* is the name of the file to save registry data to. This file cannot
-   already exist. If this filename includes an extension, it cannot be used on file
-   allocation table (FAT) file systems by the :meth:`LoadKey`, :meth:`ReplaceKey`
-   or :meth:`RestoreKey` methods.
+   *file_name* is the name of the file to save registry data to.  This file
+   cannot already exist. If this filename includes an extension, it cannot be
+   used on file allocation table (FAT) file systems by the :meth:`LoadKey`
+   method.
 
    If *key* represents a key on a remote computer, the path described by
    *file_name* is relative to the remote computer. The caller of this method must
@@ -411,16 +413,16 @@
 .. function:: DisableReflectionKey(key)
 
    Disables registry reflection for 32-bit processes running on a 64-bit
-   Operating System.
+   operating system.
 
-   *key* is an already open key, or one of the predefined
-   :ref:`HKEY_* constants <hkey-constants>`.
+   *key* is an already open key, or one of the predefined :ref:`HKEY_* constants
+   <hkey-constants>`.
 
-   Will generally raise :exc:`NotImplemented` if executed on a 32-bit
-   Operating System.
+   Will generally raise :exc:`NotImplemented` if executed on a 32-bit operating
+   system.
 
    If the key is not on the reflection list, the function succeeds but has no
-   effect. Disabling reflection for a key does not affect reflection of any
+   effect.  Disabling reflection for a key does not affect reflection of any
    subkeys.
 
 
@@ -428,11 +430,11 @@
 
    Restores registry reflection for the specified disabled key.
 
-   *key* is an already open key, or one of the predefined
-   :ref:`HKEY_* constants <hkey-constants>`.
+   *key* is an already open key, or one of the predefined :ref:`HKEY_* constants
+   <hkey-constants>`.
 
-   Will generally raise :exc:`NotImplemented` if executed on a 32-bit
-   Operating System.
+   Will generally raise :exc:`NotImplemented` if executed on a 32-bit operating
+   system.
 
    Restoring reflection for a key does not affect reflection of any subkeys.
 
@@ -447,7 +449,7 @@
    Returns ``True`` if reflection is disabled.
 
    Will generally raise :exc:`NotImplemented` if executed on a 32-bit
-   Operating System.
+   operating system.
 
 
 .. _constants:
@@ -646,7 +648,7 @@
 
 This object wraps a Windows HKEY object, automatically closing it when the
 object is destroyed.  To guarantee cleanup, you can call either the
-:meth:`Close` method on the object, or the :func:`CloseKey` function.
+:meth:`~PyHKEY.Close` method on the object, or the :func:`CloseKey` function.
 
 All registry functions in this module return one of these objects.
 
@@ -666,8 +668,8 @@
 
 Handle objects can be converted to an integer (e.g., using the built-in
 :func:`int` function), in which case the underlying Windows handle value is
-returned.  You can also use the :meth:`Detach` method to return the integer
-handle, and also disconnect the Windows handle from the handle object.
+returned.  You can also use the :meth:`~PyHKEY.Detach` method to return the
+integer handle, and also disconnect the Windows handle from the handle object.
 
 
 .. method:: PyHKEY.Close()
@@ -692,11 +694,12 @@
 .. method:: PyHKEY.__enter__()
             PyHKEY.__exit__(\*exc_info)
 
-   The HKEY object implements :meth:`__enter__` and :meth:`__exit__` and thus
-   supports the context protocol for the :keyword:`with` statement::
+   The HKEY object implements :meth:`~object.__enter__` and
+   :meth:`~object.__exit__` and thus supports the context protocol for the
+   :keyword:`with` statement::
 
       with OpenKey(HKEY_LOCAL_MACHINE, "foo") as key:
-          # ... work with key ...
+          ...  # work with key
 
    will automatically close *key* when control leaves the :keyword:`with` block.
 

Modified: python/branches/py3k-jit/Doc/reference/datamodel.rst
==============================================================================
--- python/branches/py3k-jit/Doc/reference/datamodel.rst	(original)
+++ python/branches/py3k-jit/Doc/reference/datamodel.rst	Tue May 25 03:17:49 2010
@@ -1587,6 +1587,46 @@
 called *members*.
 
 
+Customizing instance and subclass checks
+----------------------------------------
+
+The following methods are used to override the default behavior of the
+:func:`isinstance` and :func:`issubclass` built-in functions.
+
+In particular, the metaclass :class:`abc.ABCMeta` implements these methods in
+order to allow the addition of Abstract Base Classes (ABCs) as "virtual base
+classes" to any class or type (including built-in types), and including to other
+ABCs.
+
+.. method:: class.__instancecheck__(self, instance)
+
+   Return true if *instance* should be considered a (direct or indirect)
+   instance of *class*. If defined, called to implement ``isinstance(instance,
+   class)``.
+
+
+.. method:: class.__subclasscheck__(self, subclass)
+
+   Return true if *subclass* should be considered a (direct or indirect)
+   subclass of *class*.  If defined, called to implement ``issubclass(subclass,
+   class)``.
+
+
+Note that these methods are looked up on the type (metaclass) of a class.  They
+cannot be defined as class methods in the actual class.  This is consistent with
+the lookup of special methods that are called on instances, only that in this
+case the instance is itself a class.
+
+.. seealso::
+
+   :pep:`3119` - Introducing Abstract Base Classes
+      Includes the specification for customizing :func:`isinstance` and
+      :func:`issubclass` behavior through :meth:`__instancecheck__` and
+      :meth:`__subclasscheck__`, with motivation for this functionality in the
+      context of adding Abstract Base Classes (see the :mod:`abc` module) to the
+      language.
+
+
 .. _callable-types:
 
 Emulating callable objects

Modified: python/branches/py3k-jit/Doc/tutorial/datastructures.rst
==============================================================================
--- python/branches/py3k-jit/Doc/tutorial/datastructures.rst	(original)
+++ python/branches/py3k-jit/Doc/tutorial/datastructures.rst	Tue May 25 03:17:49 2010
@@ -377,10 +377,7 @@
 
 Here is a brief demonstration::
 
-   >>> basket = {'apple', 'orange', 'apple', 'pear', 'orange', 'banana'}
-   >>> print(basket)
-   {'orange', 'banana', 'pear', 'apple'}
-   >>> fruit = ['apple', 'orange', 'apple', 'pear', 'orange', 'banana']
+   >>> basket = ['apple', 'orange', 'apple', 'pear', 'orange', 'banana']
    >>> fruit = set(basket)               # create a set without duplicates
    >>> fruit
    {'orange', 'pear', 'apple', 'banana'}

Modified: python/branches/py3k-jit/Include/pyport.h
==============================================================================
--- python/branches/py3k-jit/Include/pyport.h	(original)
+++ python/branches/py3k-jit/Include/pyport.h	Tue May 25 03:17:49 2010
@@ -126,6 +126,20 @@
 #endif
 #endif
 
+/* Parameters used for the numeric hash implementation.  See notes for
+   _PyHash_Double in Objects/object.c.  Numeric hashes are based on
+   reduction modulo the prime 2**_PyHASH_BITS - 1. */
+
+#if SIZEOF_LONG >= 8
+#define _PyHASH_BITS 61
+#else
+#define _PyHASH_BITS 31
+#endif
+#define _PyHASH_MODULUS ((1UL << _PyHASH_BITS) - 1)
+#define _PyHASH_INF 314159
+#define _PyHASH_NAN 0
+#define _PyHASH_IMAG 1000003UL
+
 /* uintptr_t is the C9X name for an unsigned integral type such that a
  * legitimate void* can be cast to uintptr_t and then back to void* again
  * without loss of information.  Similarly for intptr_t, wrt a signed

Modified: python/branches/py3k-jit/Include/sysmodule.h
==============================================================================
--- python/branches/py3k-jit/Include/sysmodule.h	(original)
+++ python/branches/py3k-jit/Include/sysmodule.h	Tue May 25 03:17:49 2010
@@ -10,6 +10,7 @@
 PyAPI_FUNC(PyObject *) PySys_GetObject(const char *);
 PyAPI_FUNC(int) PySys_SetObject(const char *, PyObject *);
 PyAPI_FUNC(void) PySys_SetArgv(int, wchar_t **);
+PyAPI_FUNC(void) PySys_SetArgvEx(int, wchar_t **, int);
 PyAPI_FUNC(void) PySys_SetPath(const wchar_t *);
 
 PyAPI_FUNC(void) PySys_WriteStdout(const char *format, ...)
@@ -21,6 +22,7 @@
 
 PyAPI_FUNC(void) PySys_ResetWarnOptions(void);
 PyAPI_FUNC(void) PySys_AddWarnOption(const wchar_t *);
+PyAPI_FUNC(void) PySys_AddWarnOptionUnicode(PyObject *);
 PyAPI_FUNC(int) PySys_HasWarnOptions(void);
 
 #ifdef __cplusplus

Modified: python/branches/py3k-jit/Lib/_abcoll.py
==============================================================================
--- python/branches/py3k-jit/Lib/_abcoll.py	(original)
+++ python/branches/py3k-jit/Lib/_abcoll.py	Tue May 25 03:17:49 2010
@@ -376,8 +376,9 @@
         return ValuesView(self)
 
     def __eq__(self, other):
-        return isinstance(other, Mapping) and \
-               dict(self.items()) == dict(other.items())
+        if not isinstance(other, Mapping):
+            return NotImplemented
+        return dict(self.items()) == dict(other.items())
 
     def __ne__(self, other):
         return not (self == other)

Modified: python/branches/py3k-jit/Lib/argparse.py
==============================================================================
--- python/branches/py3k-jit/Lib/argparse.py	(original)
+++ python/branches/py3k-jit/Lib/argparse.py	Tue May 25 03:17:49 2010
@@ -987,7 +987,7 @@
                  version=None,
                  dest=SUPPRESS,
                  default=SUPPRESS,
-                 help=None):
+                 help="show program's version number and exit"):
         super(_VersionAction, self).__init__(
             option_strings=option_strings,
             dest=dest,

Modified: python/branches/py3k-jit/Lib/asyncore.py
==============================================================================
--- python/branches/py3k-jit/Lib/asyncore.py	(original)
+++ python/branches/py3k-jit/Lib/asyncore.py	Tue May 25 03:17:49 2010
@@ -63,8 +63,8 @@
 
 def _strerror(err):
     try:
-        return strerror(err)
-    except (ValueError, OverflowError):
+        return os.strerror(err)
+    except (ValueError, OverflowError, NameError):
         if err in errorcode:
             return errorcode[err]
         return "Unknown error %s" %err

Modified: python/branches/py3k-jit/Lib/codecs.py
==============================================================================
--- python/branches/py3k-jit/Lib/codecs.py	(original)
+++ python/branches/py3k-jit/Lib/codecs.py	Tue May 25 03:17:49 2010
@@ -374,6 +374,11 @@
         """
         pass
 
+    def seek(self, offset, whence=0):
+        self.stream.seek(offset, whence)
+        if whence == 0 and offset == 0:
+            self.reset()
+
     def __getattr__(self, name,
                     getattr=getattr):
 
@@ -606,8 +611,8 @@
 
             Resets the codec buffers used for keeping state.
         """
-        self.reset()
         self.stream.seek(offset, whence)
+        self.reset()
 
     def __next__(self):
 
@@ -699,6 +704,12 @@
         self.reader.reset()
         self.writer.reset()
 
+    def seek(self, offset, whence=0):
+        self.stream.seek(offset, whence)
+        self.reader.reset()
+        if whence == 0 and offset == 0:
+            self.writer.reset()
+
     def __getattr__(self, name,
                     getattr=getattr):
 

Modified: python/branches/py3k-jit/Lib/decimal.py
==============================================================================
--- python/branches/py3k-jit/Lib/decimal.py	(original)
+++ python/branches/py3k-jit/Lib/decimal.py	Tue May 25 03:17:49 2010
@@ -164,7 +164,7 @@
     anything, though.
 
     handle  -- Called when context._raise_error is called and the
-               trap_enabler is set.  First argument is self, second is the
+               trap_enabler is not set.  First argument is self, second is the
                context.  More arguments can be given, those being after
                the explanation in _raise_error (For example,
                context._raise_error(NewError, '(-x)!', self._sign) would
@@ -862,7 +862,7 @@
     # that specified by IEEE 754.
 
     def __eq__(self, other, context=None):
-        other = _convert_other(other, allow_float=True)
+        other = _convert_other(other, allow_float = True)
         if other is NotImplemented:
             return other
         if self._check_nans(other, context):
@@ -870,7 +870,7 @@
         return self._cmp(other) == 0
 
     def __ne__(self, other, context=None):
-        other = _convert_other(other, allow_float=True)
+        other = _convert_other(other, allow_float = True)
         if other is NotImplemented:
             return other
         if self._check_nans(other, context):
@@ -879,7 +879,7 @@
 
 
     def __lt__(self, other, context=None):
-        other = _convert_other(other, allow_float=True)
+        other = _convert_other(other, allow_float = True)
         if other is NotImplemented:
             return other
         ans = self._compare_check_nans(other, context)
@@ -888,7 +888,7 @@
         return self._cmp(other) < 0
 
     def __le__(self, other, context=None):
-        other = _convert_other(other, allow_float=True)
+        other = _convert_other(other, allow_float = True)
         if other is NotImplemented:
             return other
         ans = self._compare_check_nans(other, context)
@@ -897,7 +897,7 @@
         return self._cmp(other) <= 0
 
     def __gt__(self, other, context=None):
-        other = _convert_other(other, allow_float=True)
+        other = _convert_other(other, allow_float = True)
         if other is NotImplemented:
             return other
         ans = self._compare_check_nans(other, context)
@@ -906,7 +906,7 @@
         return self._cmp(other) > 0
 
     def __ge__(self, other, context=None):
-        other = _convert_other(other, allow_float=True)
+        other = _convert_other(other, allow_float = True)
         if other is NotImplemented:
             return other
         ans = self._compare_check_nans(other, context)
@@ -935,55 +935,28 @@
 
     def __hash__(self):
         """x.__hash__() <==> hash(x)"""
-        # Decimal integers must hash the same as the ints
-        #
-        # The hash of a nonspecial noninteger Decimal must depend only
-        # on the value of that Decimal, and not on its representation.
-        # For example: hash(Decimal('100E-1')) == hash(Decimal('10')).
-
-        # Equality comparisons involving signaling nans can raise an
-        # exception; since equality checks are implicitly and
-        # unpredictably used when checking set and dict membership, we
-        # prevent signaling nans from being used as set elements or
-        # dict keys by making __hash__ raise an exception.
+
+        # In order to make sure that the hash of a Decimal instance
+        # agrees with the hash of a numerically equal integer, float
+        # or Fraction, we follow the rules for numeric hashes outlined
+        # in the documentation.  (See library docs, 'Built-in Types').
         if self._is_special:
             if self.is_snan():
                 raise TypeError('Cannot hash a signaling NaN value.')
             elif self.is_nan():
-                # 0 to match hash(float('nan'))
-                return 0
+                return _PyHASH_NAN
             else:
-                # values chosen to match hash(float('inf')) and
-                # hash(float('-inf')).
                 if self._sign:
-                    return -271828
+                    return -_PyHASH_INF
                 else:
-                    return 314159
+                    return _PyHASH_INF
 
-        # In Python 2.7, we're allowing comparisons (but not
-        # arithmetic operations) between floats and Decimals;  so if
-        # a Decimal instance is exactly representable as a float then
-        # its hash should match that of the float.
-        self_as_float = float(self)
-        if Decimal.from_float(self_as_float) == self:
-            return hash(self_as_float)
-
-        if self._isinteger():
-            op = _WorkRep(self.to_integral_value())
-            # to make computation feasible for Decimals with large
-            # exponent, we use the fact that hash(n) == hash(m) for
-            # any two nonzero integers n and m such that (i) n and m
-            # have the same sign, and (ii) n is congruent to m modulo
-            # 2**64-1.  So we can replace hash((-1)**s*c*10**e) with
-            # hash((-1)**s*c*pow(10, e, 2**64-1).
-            return hash((-1)**op.sign*op.int*pow(10, op.exp, 2**64-1))
-        # The value of a nonzero nonspecial Decimal instance is
-        # faithfully represented by the triple consisting of its sign,
-        # its adjusted exponent, and its coefficient with trailing
-        # zeros removed.
-        return hash((self._sign,
-                     self._exp+len(self._int),
-                     self._int.rstrip('0')))
+        if self._exp >= 0:
+            exp_hash = pow(10, self._exp, _PyHASH_MODULUS)
+        else:
+            exp_hash = pow(_PyHASH_10INV, -self._exp, _PyHASH_MODULUS)
+        hash_ = int(self._int) * exp_hash % _PyHASH_MODULUS
+        return hash_ if self >= 0 else -hash_
 
     def as_tuple(self):
         """Represents the number as a triple tuple.
@@ -1611,9 +1584,9 @@
         """Decapitate the payload of a NaN to fit the context"""
         payload = self._int
 
-        # maximum length of payload is precision if _clamp=0,
-        # precision-1 if _clamp=1.
-        max_payload_len = context.prec - context._clamp
+        # maximum length of payload is precision if clamp=0,
+        # precision-1 if clamp=1.
+        max_payload_len = context.prec - context.clamp
         if len(payload) > max_payload_len:
             payload = payload[len(payload)-max_payload_len:].lstrip('0')
             return _dec_from_triple(self._sign, payload, self._exp, True)
@@ -1638,11 +1611,11 @@
                 return Decimal(self)
 
         # if self is zero then exponent should be between Etiny and
-        # Emax if _clamp==0, and between Etiny and Etop if _clamp==1.
+        # Emax if clamp==0, and between Etiny and Etop if clamp==1.
         Etiny = context.Etiny()
         Etop = context.Etop()
         if not self:
-            exp_max = [context.Emax, Etop][context._clamp]
+            exp_max = [context.Emax, Etop][context.clamp]
             new_exp = min(max(self._exp, Etiny), exp_max)
             if new_exp != self._exp:
                 context._raise_error(Clamped)
@@ -1702,8 +1675,8 @@
         if self_is_subnormal:
             context._raise_error(Subnormal)
 
-        # fold down if _clamp == 1 and self has too few digits
-        if context._clamp == 1 and self._exp > Etop:
+        # fold down if clamp == 1 and self has too few digits
+        if context.clamp == 1 and self._exp > Etop:
             context._raise_error(Clamped)
             self_padded = self._int + '0'*(self._exp - Etop)
             return _dec_from_triple(self._sign, self_padded, Etop)
@@ -2451,7 +2424,7 @@
 
         if not dup:
             return _dec_from_triple(dup._sign, '0', 0)
-        exp_max = [context.Emax, context.Etop()][context._clamp]
+        exp_max = [context.Emax, context.Etop()][context.clamp]
         end = len(dup._int)
         exp = dup._exp
         while dup._int[end-1] == '0' and exp < exp_max:
@@ -3828,13 +3801,13 @@
     Emax -   Maximum exponent
     capitals -      If 1, 1*10^1 is printed as 1E+1.
                     If 0, printed as 1e1
-    _clamp - If 1, change exponents if too high (Default 0)
+    clamp -  If 1, change exponents if too high (Default 0)
     """
 
     def __init__(self, prec=None, rounding=None,
                  traps=None, flags=None,
                  Emin=None, Emax=None,
-                 capitals=None, _clamp=0,
+                 capitals=None, clamp=None,
                  _ignored_flags=None):
         if flags is None:
             flags = []
@@ -3855,7 +3828,8 @@
         """Show the current context."""
         s = []
         s.append('Context(prec=%(prec)d, rounding=%(rounding)s, '
-                 'Emin=%(Emin)d, Emax=%(Emax)d, capitals=%(capitals)d'
+                 'Emin=%(Emin)d, Emax=%(Emax)d, capitals=%(capitals)d, '
+                 'clamp=%(clamp)d'
                  % vars(self))
         names = [f.__name__ for f, v in self.flags.items() if v]
         s.append('flags=[' + ', '.join(names) + ']')
@@ -3872,23 +3846,45 @@
         """Returns a shallow copy from self."""
         nc = Context(self.prec, self.rounding, self.traps,
                      self.flags, self.Emin, self.Emax,
-                     self.capitals, self._clamp, self._ignored_flags)
+                     self.capitals, self.clamp, self._ignored_flags)
         return nc
 
     def copy(self):
         """Returns a deep copy from self."""
         nc = Context(self.prec, self.rounding, self.traps.copy(),
                      self.flags.copy(), self.Emin, self.Emax,
-                     self.capitals, self._clamp, self._ignored_flags)
+                     self.capitals, self.clamp, self._ignored_flags)
         return nc
     __copy__ = copy
 
+    # _clamp is provided for backwards compatibility with third-party
+    # code.  May be removed in Python >= 3.3.
+    def _get_clamp(self):
+        "_clamp mirrors the clamp attribute.  Its use is deprecated."
+        import warnings
+        warnings.warn('Use of the _clamp attribute is deprecated. '
+                      'Please use clamp instead.',
+                      DeprecationWarning)
+        return self.clamp
+
+    def _set_clamp(self, clamp):
+        "_clamp mirrors the clamp attribute.  Its use is deprecated."
+        import warnings
+        warnings.warn('Use of the _clamp attribute is deprecated. '
+                      'Please use clamp instead.',
+                      DeprecationWarning)
+        self.clamp = clamp
+
+    # don't bother with _del_clamp;  no sane 3rd party code should
+    # be deleting the _clamp attribute
+    _clamp = property(_get_clamp, _set_clamp)
+
     def _raise_error(self, condition, explanation = None, *args):
         """Handles an error
 
         If the flag is in _ignored_flags, returns the default response.
         Otherwise, it sets the flag, then, if the corresponding
-        trap_enabler is set, it reaises the exception.  Otherwise, it returns
+        trap_enabler is set, it reraises the exception.  Otherwise, it returns
         the default value after setting the flag.
         """
         error = _condition_map.get(condition, condition)
@@ -3965,7 +3961,7 @@
                                      "permitted.")
 
         d = Decimal(num, context=self)
-        if d._isnan() and len(d._int) > self.prec - self._clamp:
+        if d._isnan() and len(d._int) > self.prec - self.clamp:
             return self._raise_error(ConversionSyntax,
                                      "diagnostic info too long in NaN")
         return d._fix(self)
@@ -5875,7 +5871,8 @@
         flags=[],
         Emax=999999999,
         Emin=-999999999,
-        capitals=1
+        capitals=1,
+        clamp=0
 )
 
 # Pre-made alternate contexts offered by the specification
@@ -6194,6 +6191,17 @@
 # _SignedInfinity[sign] is infinity w/ that sign
 _SignedInfinity = (_Infinity, _NegativeInfinity)
 
+# Constants related to the hash implementation;  hash(x) is based
+# on the reduction of x modulo _PyHASH_MODULUS
+import sys
+_PyHASH_MODULUS = sys.hash_info.modulus
+# hash values to use for positive and negative infinities, and nans
+_PyHASH_INF = sys.hash_info.inf
+_PyHASH_NAN = sys.hash_info.nan
+del sys
+
+# _PyHASH_10INV is the inverse of 10 modulo the prime _PyHASH_MODULUS
+_PyHASH_10INV = pow(10, _PyHASH_MODULUS - 2, _PyHASH_MODULUS)
 
 
 if __name__ == '__main__':

Modified: python/branches/py3k-jit/Lib/distutils/log.py
==============================================================================
--- python/branches/py3k-jit/Lib/distutils/log.py	(original)
+++ python/branches/py3k-jit/Lib/distutils/log.py	Tue May 25 03:17:49 2010
@@ -27,6 +27,10 @@
                 stream = sys.stderr
             else:
                 stream = sys.stdout
+            if stream.errors == 'strict':
+                # emulate backslashreplace error handler
+                encoding = stream.encoding
+                msg = msg.encode(encoding, "backslashreplace").decode(encoding)
             stream.write('%s\n' % msg)
             stream.flush()
 

Modified: python/branches/py3k-jit/Lib/encodings/utf_16.py
==============================================================================
--- python/branches/py3k-jit/Lib/encodings/utf_16.py	(original)
+++ python/branches/py3k-jit/Lib/encodings/utf_16.py	Tue May 25 03:17:49 2010
@@ -103,17 +103,23 @@
 
 class StreamWriter(codecs.StreamWriter):
     def __init__(self, stream, errors='strict'):
-        self.bom_written = False
         codecs.StreamWriter.__init__(self, stream, errors)
+        self.encoder = None
+
+    def reset(self):
+        codecs.StreamWriter.reset(self)
+        self.encoder = None
 
     def encode(self, input, errors='strict'):
-        self.bom_written = True
-        result = codecs.utf_16_encode(input, errors)
-        if sys.byteorder == 'little':
-            self.encode = codecs.utf_16_le_encode
+        if self.encoder is None:
+            result = codecs.utf_16_encode(input, errors)
+            if sys.byteorder == 'little':
+                self.encoder = codecs.utf_16_le_encode
+            else:
+                self.encoder = codecs.utf_16_be_encode
+            return result
         else:
-            self.encode = codecs.utf_16_be_encode
-        return result
+            return self.encoder(input, errors)
 
 class StreamReader(codecs.StreamReader):
 

Modified: python/branches/py3k-jit/Lib/encodings/utf_32.py
==============================================================================
--- python/branches/py3k-jit/Lib/encodings/utf_32.py	(original)
+++ python/branches/py3k-jit/Lib/encodings/utf_32.py	Tue May 25 03:17:49 2010
@@ -98,17 +98,23 @@
 
 class StreamWriter(codecs.StreamWriter):
     def __init__(self, stream, errors='strict'):
-        self.bom_written = False
+        self.encoder = None
         codecs.StreamWriter.__init__(self, stream, errors)
 
+    def reset(self):
+        codecs.StreamWriter.reset(self)
+        self.encoder = None
+
     def encode(self, input, errors='strict'):
-        self.bom_written = True
-        result = codecs.utf_32_encode(input, errors)
-        if sys.byteorder == 'little':
-            self.encode = codecs.utf_32_le_encode
+        if self.encoder is None:
+            result = codecs.utf_32_encode(input, errors)
+            if sys.byteorder == 'little':
+                self.encoder = codecs.utf_32_le_encode
+            else:
+                self.encoder = codecs.utf_32_be_encode
+            return result
         else:
-            self.encode = codecs.utf_32_be_encode
-        return result
+            return self.encoder(input, errors)
 
 class StreamReader(codecs.StreamReader):
 

Modified: python/branches/py3k-jit/Lib/fractions.py
==============================================================================
--- python/branches/py3k-jit/Lib/fractions.py	(original)
+++ python/branches/py3k-jit/Lib/fractions.py	Tue May 25 03:17:49 2010
@@ -8,6 +8,7 @@
 import numbers
 import operator
 import re
+import sys
 
 __all__ = ['Fraction', 'gcd']
 
@@ -23,6 +24,12 @@
         a, b = b, a%b
     return a
 
+# Constants related to the hash implementation;  hash(x) is based
+# on the reduction of x modulo the prime _PyHASH_MODULUS.
+_PyHASH_MODULUS = sys.hash_info.modulus
+# Value to be used for rationals that reduce to infinity modulo
+# _PyHASH_MODULUS.
+_PyHASH_INF = sys.hash_info.inf
 
 _RATIONAL_FORMAT = re.compile(r"""
     \A\s*                      # optional whitespace at the start, then
@@ -528,16 +535,22 @@
 
         """
         # XXX since this method is expensive, consider caching the result
-        if self._denominator == 1:
-            # Get integers right.
-            return hash(self._numerator)
-        # Expensive check, but definitely correct.
-        if self == float(self):
-            return hash(float(self))
+
+        # In order to make sure that the hash of a Fraction agrees
+        # with the hash of a numerically equal integer, float or
+        # Decimal instance, we follow the rules for numeric hashes
+        # outlined in the documentation.  (See library docs, 'Built-in
+        # Types').
+
+        # dinv is the inverse of self._denominator modulo the prime
+        # _PyHASH_MODULUS, or 0 if self._denominator is divisible by
+        # _PyHASH_MODULUS.
+        dinv = pow(self._denominator, _PyHASH_MODULUS - 2, _PyHASH_MODULUS)
+        if not dinv:
+            hash_ = _PyHASH_INF
         else:
-            # Use tuple's hash to avoid a high collision rate on
-            # simple fractions.
-            return hash((self._numerator, self._denominator))
+            hash_ = abs(self._numerator) * dinv % _PyHASH_MODULUS
+        return hash_ if self >= 0 else -hash_
 
     def __eq__(a, b):
         """a == b"""

Modified: python/branches/py3k-jit/Lib/functools.py
==============================================================================
--- python/branches/py3k-jit/Lib/functools.py	(original)
+++ python/branches/py3k-jit/Lib/functools.py	Tue May 25 03:17:49 2010
@@ -51,7 +51,7 @@
                    assigned=assigned, updated=updated)
 
 def total_ordering(cls):
-    'Class decorator that fills-in missing ordering methods'
+    """Class decorator that fills in missing ordering methods"""
     convert = {
         '__lt__': [('__gt__', lambda self, other: other < self),
                    ('__le__', lambda self, other: not other < self),
@@ -78,7 +78,7 @@
     return cls
 
 def cmp_to_key(mycmp):
-    'Convert a cmp= function into a key= function'
+    """Convert a cmp= function into a key= function"""
     class K(object):
         def __init__(self, obj, *args):
             self.obj = obj

Modified: python/branches/py3k-jit/Lib/importlib/_bootstrap.py
==============================================================================
--- python/branches/py3k-jit/Lib/importlib/_bootstrap.py	(original)
+++ python/branches/py3k-jit/Lib/importlib/_bootstrap.py	Tue May 25 03:17:49 2010
@@ -494,8 +494,16 @@
         if ext_type == imp.PY_COMPILED:
             # We don't really care what the extension on self._base_path is,
             # as long as it has exactly one dot.
-            bytecode_path = imp.cache_from_source(self._base_path + '.py')
-            return (bytecode_path if _path_exists(bytecode_path) else None)
+            source_path = self._base_path + '.py'
+            pycache_path = imp.cache_from_source(source_path)
+            legacy_path = self._base_path + '.pyc'
+            # The rule is: if the source file exists, then Python always uses
+            # the __pycache__/foo.<tag>.pyc file.  If the source file does not
+            # exist, then Python uses the legacy path.
+            pyc_path = (pycache_path
+                        if _path_exists(source_path)
+                        else legacy_path)
+            return (pyc_path if _path_exists(pyc_path) else None)
         return super()._find_path(ext_type)
 
     @_check_name

Modified: python/branches/py3k-jit/Lib/importlib/test/source/test_file_loader.py
==============================================================================
--- python/branches/py3k-jit/Lib/importlib/test/source/test_file_loader.py	(original)
+++ python/branches/py3k-jit/Lib/importlib/test/source/test_file_loader.py	Tue May 25 03:17:49 2010
@@ -10,6 +10,8 @@
 import sys
 import unittest
 
+from test.support import make_legacy_pyc
+
 
 class SimpleTest(unittest.TestCase):
 
@@ -136,6 +138,7 @@
                 file.write(new_bc)
         if del_source:
             os.unlink(mapping[name])
+            make_legacy_pyc(mapping[name])
         return bytecode_path
 
     @source_util.writes_bytecode_files

Modified: python/branches/py3k-jit/Lib/lib2to3/refactor.py
==============================================================================
--- python/branches/py3k-jit/Lib/lib2to3/refactor.py	(original)
+++ python/branches/py3k-jit/Lib/lib2to3/refactor.py	Tue May 25 03:17:49 2010
@@ -564,7 +564,9 @@
         This is necessary to get correct line number / offset information
         in the parser diagnostics and embedded into the parse tree.
         """
-        return self.driver.parse_tokens(self.wrap_toks(block, lineno, indent))
+        tree = self.driver.parse_tokens(self.wrap_toks(block, lineno, indent))
+        tree.future_features = frozenset()
+        return tree
 
     def wrap_toks(self, block, lineno, indent):
         """Wraps a tokenize stream to systematically modify start/end."""

Modified: python/branches/py3k-jit/Lib/linecache.py
==============================================================================
--- python/branches/py3k-jit/Lib/linecache.py	(original)
+++ python/branches/py3k-jit/Lib/linecache.py	Tue May 25 03:17:49 2010
@@ -73,13 +73,13 @@
 
     if filename in cache:
         del cache[filename]
-    if not filename or filename[0] + filename[-1] == '<>':
+    if not filename or (filename.startswith('<') and filename.endswith('>')):
         return []
 
     fullname = filename
     try:
         stat = os.stat(fullname)
-    except os.error as msg:
+    except OSError:
         basename = filename
 
         # Try for a __loader__, if available
@@ -114,20 +114,23 @@
                 fullname = os.path.join(dirname, basename)
             except (TypeError, AttributeError):
                 # Not sufficiently string-like to do anything useful with.
+                continue
+            try:
+                stat = os.stat(fullname)
+                break
+            except os.error:
                 pass
-            else:
-                try:
-                    stat = os.stat(fullname)
-                    break
-                except os.error:
-                    pass
         else:
-            # No luck
             return []
-    with open(fullname, 'rb') as fp:
-        coding, line = tokenize.detect_encoding(fp.readline)
-    with open(fullname, 'r', encoding=coding) as fp:
-        lines = fp.readlines()
+    try:
+        with open(fullname, 'rb') as fp:
+            coding, line = tokenize.detect_encoding(fp.readline)
+        with open(fullname, 'r', encoding=coding) as fp:
+            lines = fp.readlines()
+    except IOError:
+        pass
+    if lines and not lines[-1].endswith('\n'):
+        lines[-1] += '\n'
     size, mtime = stat.st_size, stat.st_mtime
     cache[filename] = size, mtime, lines, fullname
     return lines

Modified: python/branches/py3k-jit/Lib/os.py
==============================================================================
--- python/branches/py3k-jit/Lib/os.py	(original)
+++ python/branches/py3k-jit/Lib/os.py	Tue May 25 03:17:49 2010
@@ -355,7 +355,11 @@
         return
     last_exc = saved_exc = None
     saved_tb = None
-    for dir in get_exec_path(env):
+    path_list = get_exec_path(env)
+    if name != 'nt':
+        file = fsencode(file)
+        path_list = map(fsencode, path_list)
+    for dir in path_list:
         fullname = path.join(dir, file)
         try:
             exec_func(fullname, *argrest)
@@ -380,7 +384,30 @@
     """
     if env is None:
         env = environ
-    return env.get('PATH', defpath).split(pathsep)
+
+    try:
+        path_list = env.get('PATH')
+    except TypeError:
+        path_list = None
+
+    if supports_bytes_environ:
+        try:
+            path_listb = env[b'PATH']
+        except (KeyError, TypeError):
+            pass
+        else:
+            if path_list is not None:
+                raise ValueError(
+                    "env cannot contain 'PATH' and b'PATH' keys")
+            path_list = path_listb
+
+        if path_list is not None and isinstance(path_list, bytes):
+            path_list = path_list.decode(sys.getfilesystemencoding(),
+                                         'surrogateescape')
+
+    if path_list is None:
+        path_list = defpath
+    return path_list.split(pathsep)
 
 
 # Change environ to automatically call putenv(), unsetenv if they exist.
@@ -482,9 +509,11 @@
     The optional second argument can specify an alternate default.
     key, default and the result are str."""
     return environ.get(key, default)
-__all__.append("getenv")
 
-if name not in ('os2', 'nt'):
+supports_bytes_environ = name not in ('os2', 'nt')
+__all__.extend(("getenv", "supports_bytes_environ"))
+
+if supports_bytes_environ:
     def _check_bytes(value):
         if not isinstance(value, bytes):
             raise TypeError("bytes expected, not %s" % type(value).__name__)

Modified: python/branches/py3k-jit/Lib/pipes.py
==============================================================================
--- python/branches/py3k-jit/Lib/pipes.py	(original)
+++ python/branches/py3k-jit/Lib/pipes.py	Tue May 25 03:17:49 2010
@@ -249,11 +249,11 @@
 
 # Reliably quote a string as a single argument for /bin/sh
 
-_safechars = string.ascii_letters + string.digits + '!@%_-+=:,./' # Safe unquoted
-_funnychars = '"`$\\'                           # Unsafe inside "double quotes"
+# Safe unquoted
+_safechars = frozenset(string.ascii_letters + string.digits + '@%_-+=:,./')
 
 def quote(file):
-    ''' return a shell-escaped version of the file string '''
+    """Return a shell-escaped version of the file string."""
     for c in file:
         if c not in _safechars:
             break
@@ -261,11 +261,6 @@
         if not file:
             return "''"
         return file
-    if '\'' not in file:
-        return '\'' + file + '\''
-    res = ''
-    for c in file:
-        if c in _funnychars:
-            c = '\\' + c
-        res = res + c
-    return '"' + res + '"'
+    # use single quotes, and put single quotes into double quotes
+    # the string $'b is then quoted as '$'"'"'b'
+    return "'" + file.replace("'", "'\"'\"'") + "'"

Modified: python/branches/py3k-jit/Lib/ssl.py
==============================================================================
--- python/branches/py3k-jit/Lib/ssl.py	(original)
+++ python/branches/py3k-jit/Lib/ssl.py	Tue May 25 03:17:49 2010
@@ -63,6 +63,7 @@
 from _ssl import CERT_NONE, CERT_OPTIONAL, CERT_REQUIRED
 from _ssl import (PROTOCOL_SSLv2, PROTOCOL_SSLv3, PROTOCOL_SSLv23,
                   PROTOCOL_TLSv1)
+from _ssl import OP_ALL, OP_NO_SSLv2, OP_NO_SSLv3, OP_NO_TLSv1
 from _ssl import RAND_status, RAND_egd, RAND_add
 from _ssl import (
     SSL_ERROR_ZERO_RETURN,

Modified: python/branches/py3k-jit/Lib/subprocess.py
==============================================================================
--- python/branches/py3k-jit/Lib/subprocess.py	(original)
+++ python/branches/py3k-jit/Lib/subprocess.py	Tue May 25 03:17:49 2010
@@ -843,7 +843,7 @@
             # Process startup details
             if startupinfo is None:
                 startupinfo = STARTUPINFO()
-            if None not in (p2cread, c2pwrite, errwrite):
+            if -1 not in (p2cread, c2pwrite, errwrite):
                 startupinfo.dwFlags |= _subprocess.STARTF_USESTDHANDLES
                 startupinfo.hStdInput = p2cread
                 startupinfo.hStdOutput = c2pwrite
@@ -1096,15 +1096,14 @@
                                         for k, v in env.items()]
                         else:
                             env_list = None  # Use execv instead of execve.
+                        executable = os.fsencode(executable)
                         if os.path.dirname(executable):
-                            executable_list = (os.fsencode(executable),)
+                            executable_list = (executable,)
                         else:
                             # This matches the behavior of os._execvpe().
-                            path_list = os.get_exec_path(env)
-                            executable_list = (os.path.join(dir, executable)
-                                               for dir in path_list)
-                            executable_list = tuple(os.fsencode(exe)
-                                                    for exe in executable_list)
+                            executable_list = tuple(
+                                os.path.join(os.fsencode(dir), executable)
+                                for dir in os.get_exec_path(env))
                         self.pid = _posixsubprocess.fork_exec(
                                 args, executable_list,
                                 close_fds, cwd, env_list,

Modified: python/branches/py3k-jit/Lib/sysconfig.py
==============================================================================
--- python/branches/py3k-jit/Lib/sysconfig.py	(original)
+++ python/branches/py3k-jit/Lib/sysconfig.py	Tue May 25 03:17:49 2010
@@ -47,10 +47,10 @@
         'data'   : '{base}',
         },
     'os2_home': {
-        'stdlib': '{userbase}/lib/python/{py_version_short}',
-        'platstdlib': '{userbase}/lib/python/{py_version_short}',
-        'purelib': '{userbase}/lib/python/{py_version_short}/site-packages',
-        'platlib': '{userbase}/lib/python/{py_version_short}/site-packages',
+        'stdlib': '{userbase}/lib/python{py_version_short}',
+        'platstdlib': '{userbase}/lib/python{py_version_short}',
+        'purelib': '{userbase}/lib/python{py_version_short}/site-packages',
+        'platlib': '{userbase}/lib/python{py_version_short}/site-packages',
         'include': '{userbase}/include/python{py_version_short}',
         'scripts': '{userbase}/bin',
         'data'   : '{userbase}',
@@ -65,10 +65,10 @@
         'data'   : '{userbase}',
         },
     'posix_user': {
-        'stdlib': '{userbase}/lib/python/{py_version_short}',
-        'platstdlib': '{userbase}/lib/python/{py_version_short}',
-        'purelib': '{userbase}/lib/python/{py_version_short}/site-packages',
-        'platlib': '{userbase}/lib/python/{py_version_short}/site-packages',
+        'stdlib': '{userbase}/lib/python{py_version_short}',
+        'platstdlib': '{userbase}/lib/python{py_version_short}',
+        'purelib': '{userbase}/lib/python{py_version_short}/site-packages',
+        'platlib': '{userbase}/lib/python{py_version_short}/site-packages',
         'include': '{userbase}/include/python{py_version_short}',
         'scripts': '{userbase}/bin',
         'data'   : '{userbase}',

Modified: python/branches/py3k-jit/Lib/tabnanny.py
==============================================================================
--- python/branches/py3k-jit/Lib/tabnanny.py	(original)
+++ python/branches/py3k-jit/Lib/tabnanny.py	Tue May 25 03:17:49 2010
@@ -93,8 +93,11 @@
                 check(fullname)
         return
 
+    with open(file, 'rb') as f:
+        encoding, lines = tokenize.detect_encoding(f.readline)
+
     try:
-        f = open(file)
+        f = open(file, encoding=encoding)
     except IOError as msg:
         errprint("%r: I/O Error: %s" % (file, msg))
         return

Modified: python/branches/py3k-jit/Lib/test/regrtest.py
==============================================================================
--- python/branches/py3k-jit/Lib/test/regrtest.py	(original)
+++ python/branches/py3k-jit/Lib/test/regrtest.py	Tue May 25 03:17:49 2010
@@ -258,6 +258,8 @@
     on the command line.
     """
 
+    replace_stdout()
+
     support.record_original_stdout(sys.stdout)
     try:
         opts, args = getopt.getopt(sys.argv[1:], 'hvqxsSrf:lu:t:TD:NLR:FwWM:nj:',
@@ -376,7 +378,6 @@
         elif o in ('-j', '--multiprocess'):
             use_mp = int(a)
         elif o == '--slaveargs':
-            replace_stdout()
             args, kwargs = json.loads(a)
             try:
                 result = runtest(*args, **kwargs)
@@ -515,8 +516,6 @@
     else:
         tests = iter(selected)
 
-    replace_stdout()
-
     if use_mp:
         try:
             from threading import Thread

Modified: python/branches/py3k-jit/Lib/test/test_argparse.py
==============================================================================
--- python/branches/py3k-jit/Lib/test/test_argparse.py	(original)
+++ python/branches/py3k-jit/Lib/test/test_argparse.py	Tue May 25 03:17:49 2010
@@ -3688,6 +3688,25 @@
         '''
     version = ''
 
+class TestHelpVersionAction(HelpTestCase):
+    """Test the default help for the version action"""
+
+    parser_signature = Sig(prog='PROG', description='description')
+    argument_signatures = [Sig('-V', '--version', action='version', version='3.6')]
+    argument_group_signatures = []
+    usage = '''\
+        usage: PROG [-h] [-V]
+        '''
+    help = usage + '''\
+
+        description
+
+        optional arguments:
+          -h, --help     show this help message and exit
+          -V, --version  show program's version number and exit
+        '''
+    version = ''
+
 # =====================================
 # Optional/Positional constructor tests
 # =====================================

Modified: python/branches/py3k-jit/Lib/test/test_asyncore.py
==============================================================================
--- python/branches/py3k-jit/Lib/test/test_asyncore.py	(original)
+++ python/branches/py3k-jit/Lib/test/test_asyncore.py	Tue May 25 03:17:49 2010
@@ -6,6 +6,7 @@
 import sys
 import time
 import warnings
+import errno
 
 from test import support
 from test.support import TESTFN, run_unittest, unlink
@@ -324,6 +325,14 @@
             self.assertTrue(len(w) == 1)
             self.assertTrue(issubclass(w[0].category, DeprecationWarning))
 
+    def test_strerror(self):
+        # refers to bug #8573
+        err = asyncore._strerror(errno.EPERM)
+        if hasattr(os, 'strerror'):
+            self.assertEqual(err, os.strerror(errno.EPERM))
+        err = asyncore._strerror(-1)
+        self.assertTrue("unknown error" in err.lower())
+
 
 class dispatcherwithsend_noread(asyncore.dispatcher_with_send):
     def readable(self):

Modified: python/branches/py3k-jit/Lib/test/test_codecs.py
==============================================================================
--- python/branches/py3k-jit/Lib/test/test_codecs.py	(original)
+++ python/branches/py3k-jit/Lib/test/test_codecs.py	Tue May 25 03:17:49 2010
@@ -1594,6 +1594,62 @@
                          b"\xe4\xeb\xef\xf6\xfc")
 
 
+class BomTest(unittest.TestCase):
+    def test_seek0(self):
+        data = "1234567890"
+        tests = ("utf-16",
+                 "utf-16-le",
+                 "utf-16-be",
+                 "utf-32",
+                 "utf-32-le",
+                 "utf-32-be")
+        for encoding in tests:
+            # Check if the BOM is written only once
+            with codecs.open(support.TESTFN, 'w+', encoding=encoding) as f:
+                f.write(data)
+                f.write(data)
+                f.seek(0)
+                self.assertEquals(f.read(), data * 2)
+                f.seek(0)
+                self.assertEquals(f.read(), data * 2)
+
+            # Check that the BOM is written after a seek(0)
+            with codecs.open(support.TESTFN, 'w+', encoding=encoding) as f:
+                f.write(data[0])
+                self.assertNotEquals(f.tell(), 0)
+                f.seek(0)
+                f.write(data)
+                f.seek(0)
+                self.assertEquals(f.read(), data)
+
+            # (StreamWriter) Check that the BOM is written after a seek(0)
+            with codecs.open(support.TESTFN, 'w+', encoding=encoding) as f:
+                f.writer.write(data[0])
+                self.assertNotEquals(f.writer.tell(), 0)
+                f.writer.seek(0)
+                f.writer.write(data)
+                f.seek(0)
+                self.assertEquals(f.read(), data)
+
+            # Check that the BOM is not written after a seek() at a position
+            # different than the start
+            with codecs.open(support.TESTFN, 'w+', encoding=encoding) as f:
+                f.write(data)
+                f.seek(f.tell())
+                f.write(data)
+                f.seek(0)
+                self.assertEquals(f.read(), data * 2)
+
+            # (StreamWriter) Check that the BOM is not written after a seek()
+            # at a position different than the start
+            with codecs.open(support.TESTFN, 'w+', encoding=encoding) as f:
+                f.writer.write(data)
+                f.writer.seek(f.writer.tell())
+                f.writer.write(data)
+                f.seek(0)
+                self.assertEquals(f.read(), data * 2)
+
+
 def test_main():
     support.run_unittest(
         UTF32Test,
@@ -1621,6 +1677,7 @@
         WithStmtTest,
         TypesTest,
         SurrogateEscapeTest,
+        BomTest,
     )
 
 

Modified: python/branches/py3k-jit/Lib/test/test_collections.py
==============================================================================
--- python/branches/py3k-jit/Lib/test/test_collections.py	(original)
+++ python/branches/py3k-jit/Lib/test/test_collections.py	Tue May 25 03:17:49 2010
@@ -1,6 +1,6 @@
 """Unit tests for collections.py."""
 
-import unittest, doctest
+import unittest, doctest, operator
 import inspect
 from test import support
 from collections import namedtuple, Counter, OrderedDict
@@ -246,6 +246,37 @@
         self.assertNotIsInstance(C(), abc)
         self.assertFalse(issubclass(C, abc))
 
+    def validate_comparison(self, instance):
+        ops = ['lt', 'gt', 'le', 'ge', 'ne', 'or', 'and', 'xor', 'sub']
+        operators = {}
+        for op in ops:
+            name = '__' + op + '__'
+            operators[name] = getattr(operator, name)
+
+        class Other:
+            def __init__(self):
+                self.right_side = False
+            def __eq__(self, other):
+                self.right_side = True
+                return True
+            __lt__ = __eq__
+            __gt__ = __eq__
+            __le__ = __eq__
+            __ge__ = __eq__
+            __ne__ = __eq__
+            __ror__ = __eq__
+            __rand__ = __eq__
+            __rxor__ = __eq__
+            __rsub__ = __eq__
+
+        for name, op in operators.items():
+            if not hasattr(instance, name):
+                continue
+            other = Other()
+            op(instance, other)
+            self.assertTrue(other.right_side,'Right side not called for %s.%s'
+                            % (type(instance), name))
+
 class TestOneTrickPonyABCs(ABCTestCase):
 
     def test_Hashable(self):
@@ -420,6 +451,14 @@
             self.assertIsInstance(sample(), Set)
             self.assertTrue(issubclass(sample, Set))
         self.validate_abstract_methods(Set, '__contains__', '__iter__', '__len__')
+        class MySet(Set):
+            def __contains__(self, x):
+                return False
+            def __len__(self):
+                return 0
+            def __iter__(self):
+                return iter([])
+        self.validate_comparison(MySet())
 
     def test_hash_Set(self):
         class OneTwoThreeSet(Set):
@@ -483,6 +522,14 @@
             self.assertTrue(issubclass(sample, Mapping))
         self.validate_abstract_methods(Mapping, '__contains__', '__iter__', '__len__',
             '__getitem__')
+        class MyMapping(collections.Mapping):
+            def __len__(self):
+                return 0
+            def __getitem__(self, i):
+                raise IndexError
+            def __iter__(self):
+                return iter(())
+        self.validate_comparison(MyMapping())
 
     def test_MutableMapping(self):
         for sample in [dict]:

Modified: python/branches/py3k-jit/Lib/test/test_complex.py
==============================================================================
--- python/branches/py3k-jit/Lib/test/test_complex.py	(original)
+++ python/branches/py3k-jit/Lib/test/test_complex.py	Tue May 25 03:17:49 2010
@@ -110,12 +110,18 @@
         self.assertRaises(TypeError, complex.__floordiv__, 3+0j, 0+0j)
 
     def test_richcompare(self):
-        self.assertRaises(OverflowError, complex.__eq__, 1+1j, 1<<10000)
+        self.assertIs(complex.__eq__(1+1j, 1<<10000), False)
         self.assertIs(complex.__lt__(1+1j, None), NotImplemented)
         self.assertIs(complex.__eq__(1+1j, 1+1j), True)
         self.assertIs(complex.__eq__(1+1j, 2+2j), False)
         self.assertIs(complex.__ne__(1+1j, 1+1j), False)
         self.assertIs(complex.__ne__(1+1j, 2+2j), True)
+        for i in range(1, 100):
+            f = i / 100.0
+            self.assertIs(complex.__eq__(f+0j, f), True)
+            self.assertIs(complex.__ne__(f+0j, f), False)
+            self.assertIs(complex.__eq__(complex(f, f), f), False)
+            self.assertIs(complex.__ne__(complex(f, f), f), True)
         self.assertIs(complex.__lt__(1+1j, 2+2j), NotImplemented)
         self.assertIs(complex.__le__(1+1j, 2+2j), NotImplemented)
         self.assertIs(complex.__gt__(1+1j, 2+2j), NotImplemented)
@@ -129,6 +135,23 @@
         self.assertIs(operator.ne(1+1j, 1+1j), False)
         self.assertIs(operator.ne(1+1j, 2+2j), True)
 
+    def test_richcompare_boundaries(self):
+        def check(n, deltas, is_equal, imag = 0.0):
+            for delta in deltas:
+                i = n + delta
+                z = complex(i, imag)
+                self.assertIs(complex.__eq__(z, i), is_equal(delta))
+                self.assertIs(complex.__ne__(z, i), not is_equal(delta))
+        # For IEEE-754 doubles the following should hold:
+        #    x in [2 ** (52 + i), 2 ** (53 + i + 1)] -> x mod 2 ** i == 0
+        # where the interval is representable, of course.
+        for i in range(1, 10):
+            pow = 52 + i
+            mult = 2 ** i
+            check(2 ** pow, range(1, 101), lambda delta: delta % mult == 0)
+            check(2 ** pow, range(1, 101), lambda delta: False, float(i))
+        check(2 ** 53, range(-100, 0), lambda delta: True)
+
     def test_mod(self):
         # % is no longer supported on complex numbers
         self.assertRaises(TypeError, (1+1j).__mod__, 0+0j)

Modified: python/branches/py3k-jit/Lib/test/test_decimal.py
==============================================================================
--- python/branches/py3k-jit/Lib/test/test_decimal.py	(original)
+++ python/branches/py3k-jit/Lib/test/test_decimal.py	Tue May 25 03:17:49 2010
@@ -27,11 +27,13 @@
 import math
 import os, sys
 import operator
+import warnings
 import pickle, copy
 import unittest
 from decimal import *
 import numbers
 from test.support import run_unittest, run_doctest, is_resource_enabled
+from test.support import check_warnings
 import random
 try:
     import threading
@@ -412,7 +414,7 @@
     def change_max_exponent(self, exp):
         self.context.Emax = exp
     def change_clamp(self, clamp):
-        self.context._clamp = clamp
+        self.context.clamp = clamp
 
 
 
@@ -1815,6 +1817,26 @@
         self.assertNotEqual(id(c.flags), id(d.flags))
         self.assertNotEqual(id(c.traps), id(d.traps))
 
+    def test__clamp(self):
+        # In Python 3.2, the private attribute `_clamp` was made
+        # public (issue 8540), with the old `_clamp` becoming a
+        # property wrapping `clamp`.  For the duration of Python 3.2
+        # only, the attribute should be gettable/settable via both
+        # `clamp` and `_clamp`; in Python 3.3, `_clamp` should be
+        # removed.
+        c = Context(clamp = 0)
+        self.assertEqual(c.clamp, 0)
+
+        with check_warnings(("", DeprecationWarning)):
+            c._clamp = 1
+        self.assertEqual(c.clamp, 1)
+        with check_warnings(("", DeprecationWarning)):
+            self.assertEqual(c._clamp, 1)
+        c.clamp = 0
+        self.assertEqual(c.clamp, 0)
+        with check_warnings(("", DeprecationWarning)):
+            self.assertEqual(c._clamp, 0)
+
     def test_abs(self):
         c = Context()
         d = c.abs(Decimal(-1))

Modified: python/branches/py3k-jit/Lib/test/test_float.py
==============================================================================
--- python/branches/py3k-jit/Lib/test/test_float.py	(original)
+++ python/branches/py3k-jit/Lib/test/test_float.py	Tue May 25 03:17:49 2010
@@ -914,15 +914,6 @@
         self.assertFalse(NAN.is_inf())
         self.assertFalse((0.).is_inf())
 
-    def test_hash_inf(self):
-        # the actual values here should be regarded as an
-        # implementation detail, but they need to be
-        # identical to those used in the Decimal module.
-        self.assertEqual(hash(float('inf')), 314159)
-        self.assertEqual(hash(float('-inf')), -271828)
-        self.assertEqual(hash(float('nan')), 0)
-
-
 fromHex = float.fromhex
 toHex = float.hex
 class HexFloatTestCase(unittest.TestCase):

Modified: python/branches/py3k-jit/Lib/test/test_gdb.py
==============================================================================
--- python/branches/py3k-jit/Lib/test/test_gdb.py	(original)
+++ python/branches/py3k-jit/Lib/test/test_gdb.py	Tue May 25 03:17:49 2010
@@ -8,6 +8,7 @@
 import subprocess
 import sys
 import unittest
+import locale
 
 from test.support import run_unittest, findfile
 
@@ -177,7 +178,7 @@
     def assertGdbRepr(self, val, exp_repr=None, cmds_after_breakpoint=None):
         # Ensure that gdb's rendering of the value in a debugged process
         # matches repr(value) in this process:
-        gdb_repr, gdb_output = self.get_gdb_repr('id(' + repr(val) + ')',
+        gdb_repr, gdb_output = self.get_gdb_repr('id(' + ascii(val) + ')',
                                                  cmds_after_breakpoint)
         if not exp_repr:
             exp_repr = repr(val)
@@ -226,31 +227,35 @@
 
     def test_strings(self):
         'Verify the pretty-printing of unicode strings'
+        encoding = locale.getpreferredencoding()
+        def check_repr(text):
+            try:
+                text.encode(encoding)
+                printable = True
+            except UnicodeEncodeError:
+                self.assertGdbRepr(text, ascii(text))
+            else:
+                self.assertGdbRepr(text)
+
         self.assertGdbRepr('')
         self.assertGdbRepr('And now for something hopefully the same')
         self.assertGdbRepr('string with embedded NUL here \0 and then some more text')
 
         # Test printing a single character:
         #    U+2620 SKULL AND CROSSBONES
-        self.assertGdbRepr('\u2620')
+        check_repr('\u2620')
 
         # Test printing a Japanese unicode string
         # (I believe this reads "mojibake", using 3 characters from the CJK
         # Unified Ideographs area, followed by U+3051 HIRAGANA LETTER KE)
-        self.assertGdbRepr('\u6587\u5b57\u5316\u3051')
+        check_repr('\u6587\u5b57\u5316\u3051')
 
         # Test a character outside the BMP:
         #    U+1D121 MUSICAL SYMBOL C CLEF
         # This is:
         # UTF-8: 0xF0 0x9D 0x84 0xA1
         # UTF-16: 0xD834 0xDD21
-        if sys.maxunicode == 0x10FFFF:
-            # wide unicode:
-            self.assertGdbRepr(chr(0x1D121))
-        else:
-            # narrow unicode:
-            self.assertGdbRepr(chr(0x1D121),
-                               "'\\U0000d834\\U0000dd21'")
+        check_repr(chr(0x1D121))
 
     def test_tuples(self):
         'Verify the pretty-printing of tuples'

Modified: python/branches/py3k-jit/Lib/test/test_getargs2.py
==============================================================================
--- python/branches/py3k-jit/Lib/test/test_getargs2.py	(original)
+++ python/branches/py3k-jit/Lib/test/test_getargs2.py	Tue May 25 03:17:49 2010
@@ -252,24 +252,28 @@
             getargs_keywords((1,2), 3, (4,(5,6)), (7,8,9), 10),
             (1, 2, 3, 4, 5, 6, 7, 8, 9, 10)
             )
+
     def test_mixed_args(self):
         # positional and keyword args
         self.assertEquals(
             getargs_keywords((1,2), 3, (4,(5,6)), arg4=(7,8,9), arg5=10),
             (1, 2, 3, 4, 5, 6, 7, 8, 9, 10)
             )
+
     def test_keyword_args(self):
         # all keywords
         self.assertEquals(
             getargs_keywords(arg1=(1,2), arg2=3, arg3=(4,(5,6)), arg4=(7,8,9), arg5=10),
             (1, 2, 3, 4, 5, 6, 7, 8, 9, 10)
             )
+
     def test_optional_args(self):
         # missing optional keyword args, skipping tuples
         self.assertEquals(
             getargs_keywords(arg1=(1,2), arg2=3, arg5=10),
             (1, 2, 3, -1, -1, -1, -1, -1, -1, 10)
             )
+
     def test_required_args(self):
         # required arg missing
         try:
@@ -278,6 +282,7 @@
             self.assertEquals(str(err), "Required argument 'arg2' (pos 2) not found")
         else:
             self.fail('TypeError should have been raised')
+
     def test_too_many_args(self):
         try:
             getargs_keywords((1,2),3,(4,(5,6)),(7,8,9),10,111)
@@ -285,6 +290,7 @@
             self.assertEquals(str(err), "function takes at most 5 arguments (6 given)")
         else:
             self.fail('TypeError should have been raised')
+
     def test_invalid_keyword(self):
         # extraneous keyword arg
         try:
@@ -294,6 +300,14 @@
         else:
             self.fail('TypeError should have been raised')
 
+    def test_surrogate_keyword(self):
+        try:
+            getargs_keywords((1,2), 3, (4,(5,6)), (7,8,9), **{'\uDC80': 10})
+        except TypeError as err:
+            self.assertEquals(str(err), "'\udc80' is an invalid keyword argument for this function")
+        else:
+            self.fail('TypeError should have been raised')
+
 def test_main():
     tests = [Signed_TestCase, Unsigned_TestCase, Tuple_TestCase, Keywords_TestCase]
     try:

Modified: python/branches/py3k-jit/Lib/test/test_import.py
==============================================================================
--- python/branches/py3k-jit/Lib/test/test_import.py	(original)
+++ python/branches/py3k-jit/Lib/test/test_import.py	Tue May 25 03:17:49 2010
@@ -142,7 +142,6 @@
             self.assertIs(orig_path, new_os.path)
             self.assertIsNot(orig_getenv, new_os.getenv)
 
-    @unittest.expectedFailure  # Issue 8727 is tracking the fix.
     def test_module_with_large_stack(self, module='longlist'):
         # Regression test for http://bugs.python.org/issue561858.
         filename = module + '.py'

Modified: python/branches/py3k-jit/Lib/test/test_linecache.py
==============================================================================
--- python/branches/py3k-jit/Lib/test/test_linecache.py	(original)
+++ python/branches/py3k-jit/Lib/test/test_linecache.py	Tue May 25 03:17:49 2010
@@ -31,6 +31,11 @@
 
 '''
 
+SOURCE_3 = '''
+def f():
+    return 3''' # No ending newline
+
+
 class LineCacheTests(unittest.TestCase):
 
     def test_getline(self):
@@ -63,6 +68,13 @@
         empty = linecache.getlines('a/b/c/__init__.py')
         self.assertEquals(empty, [])
 
+    def test_no_ending_newline(self):
+        self.addCleanup(support.unlink, support.TESTFN)
+        with open(support.TESTFN, "w") as fp:
+            fp.write(SOURCE_3)
+        lines = linecache.getlines(support.TESTFN)
+        self.assertEqual(lines, ["\n", "def f():\n", "    return 3\n"])
+
     def test_clearcache(self):
         cached = []
         for entry in TESTS:
@@ -81,39 +93,36 @@
 
     def test_checkcache(self):
         getline = linecache.getline
-        try:
-            # Create a source file and cache its contents
-            source_name = support.TESTFN + '.py'
-            with open(source_name, 'w') as source:
-                source.write(SOURCE_1)
-            getline(source_name, 1)
-
-            # Keep a copy of the old contents
-            source_list = []
-            with open(source_name) as source:
-                for index, line in enumerate(source):
-                    self.assertEquals(line, getline(source_name, index + 1))
-                    source_list.append(line)
+        # Create a source file and cache its contents
+        source_name = support.TESTFN + '.py'
+        self.addCleanup(support.unlink, source_name)
+        with open(source_name, 'w') as source:
+            source.write(SOURCE_1)
+        getline(source_name, 1)
+
+        # Keep a copy of the old contents
+        source_list = []
+        with open(source_name) as source:
+            for index, line in enumerate(source):
+                self.assertEquals(line, getline(source_name, index + 1))
+                source_list.append(line)
 
-            with open(source_name, 'w') as source:
-                source.write(SOURCE_2)
+        with open(source_name, 'w') as source:
+            source.write(SOURCE_2)
 
-            # Try to update a bogus cache entry
-            linecache.checkcache('dummy')
+        # Try to update a bogus cache entry
+        linecache.checkcache('dummy')
 
-            # Check that the cache matches the old contents
-            for index, line in enumerate(source_list):
+        # Check that the cache matches the old contents
+        for index, line in enumerate(source_list):
+            self.assertEquals(line, getline(source_name, index + 1))
+
+        # Update the cache and check whether it matches the new source file
+        linecache.checkcache(source_name)
+        with open(source_name) as source:
+            for index, line in enumerate(source):
                 self.assertEquals(line, getline(source_name, index + 1))
-
-            # Update the cache and check whether it matches the new source file
-            linecache.checkcache(source_name)
-            with open(source_name) as source:
-                for index, line in enumerate(source):
-                    self.assertEquals(line, getline(source_name, index + 1))
-                    source_list.append(line)
-
-        finally:
-            support.unlink(source_name)
+                source_list.append(line)
 
 def test_main():
     support.run_unittest(LineCacheTests)

Modified: python/branches/py3k-jit/Lib/test/test_os.py
==============================================================================
--- python/branches/py3k-jit/Lib/test/test_os.py	(original)
+++ python/branches/py3k-jit/Lib/test/test_os.py	Tue May 25 03:17:49 2010
@@ -370,7 +370,7 @@
 
     def setUp(self):
         self.__save = dict(os.environ)
-        if os.name not in ('os2', 'nt'):
+        if os.supports_bytes_environ:
             self.__saveb = dict(os.environb)
         for key, value in self._reference().items():
             os.environ[key] = value
@@ -378,7 +378,7 @@
     def tearDown(self):
         os.environ.clear()
         os.environ.update(self.__save)
-        if os.name not in ('os2', 'nt'):
+        if os.supports_bytes_environ:
             os.environb.clear()
             os.environb.update(self.__saveb)
 
@@ -445,7 +445,21 @@
         # Supplied PATH environment variable
         self.assertSequenceEqual(test_path, os.get_exec_path(test_env))
 
-    @unittest.skipIf(sys.platform == "win32", "POSIX specific test")
+        if os.supports_bytes_environ:
+            # env cannot contain 'PATH' and b'PATH' keys
+            self.assertRaises(ValueError,
+                os.get_exec_path, {'PATH': '1', b'PATH': b'2'})
+
+            # bytes key and/or value
+            self.assertSequenceEqual(os.get_exec_path({b'PATH': b'abc'}),
+                ['abc'])
+            self.assertSequenceEqual(os.get_exec_path({b'PATH': 'abc'}),
+                ['abc'])
+            self.assertSequenceEqual(os.get_exec_path({'PATH': b'abc'}),
+                ['abc'])
+
+    @unittest.skipUnless(os.supports_bytes_environ,
+                         "os.environb required for this test.")
     def test_environb(self):
         # os.environ -> os.environb
         value = 'euro\u20ac'
@@ -669,22 +683,54 @@
 
     @unittest.skipUnless(hasattr(os, '_execvpe'),
                          "No internal os._execvpe function to test.")
-    def test_internal_execvpe(self):
-        program_path = os.sep+'absolutepath'
-        program = 'executable'
-        fullpath = os.path.join(program_path, program)
-        arguments = ['progname', 'arg1', 'arg2']
+    def _test_internal_execvpe(self, test_type):
+        program_path = os.sep + 'absolutepath'
+        if test_type is bytes:
+            program = b'executable'
+            fullpath = os.path.join(os.fsencode(program_path), program)
+            native_fullpath = fullpath
+            arguments = [b'progname', 'arg1', 'arg2']
+        else:
+            program = 'executable'
+            arguments = ['progname', 'arg1', 'arg2']
+            fullpath = os.path.join(program_path, program)
+            if os.name != "nt":
+                native_fullpath = os.fsencode(fullpath)
+            else:
+                native_fullpath = fullpath
         env = {'spam': 'beans'}
 
+        # test os._execvpe() with an absolute path
         with _execvpe_mockup() as calls:
-            self.assertRaises(RuntimeError, os._execvpe, fullpath, arguments)
+            self.assertRaises(RuntimeError,
+                os._execvpe, fullpath, arguments)
             self.assertEqual(len(calls), 1)
             self.assertEqual(calls[0], ('execv', fullpath, (arguments,)))
 
+        # test os._execvpe() with a relative path:
+        # os.get_exec_path() returns defpath
         with _execvpe_mockup(defpath=program_path) as calls:
-            self.assertRaises(OSError, os._execvpe, program, arguments, env=env)
+            self.assertRaises(OSError,
+                os._execvpe, program, arguments, env=env)
             self.assertEqual(len(calls), 1)
-            self.assertEqual(calls[0], ('execve', fullpath, (arguments, env)))
+            self.assertSequenceEqual(calls[0],
+                ('execve', native_fullpath, (arguments, env)))
+
+        # test os._execvpe() with a relative path:
+        # os.get_exec_path() reads the 'PATH' variable
+        with _execvpe_mockup() as calls:
+            env_path = env.copy()
+            env_path['PATH'] = program_path
+            self.assertRaises(OSError,
+                os._execvpe, program, arguments, env=env_path)
+            self.assertEqual(len(calls), 1)
+            self.assertSequenceEqual(calls[0],
+                ('execve', native_fullpath, (arguments, env_path)))
+
+    def test_internal_execvpe_str(self):
+        self._test_internal_execvpe(str)
+        if os.name != "nt":
+            self._test_internal_execvpe(bytes)
 
 
 class Win32ErrorTests(unittest.TestCase):

Modified: python/branches/py3k-jit/Lib/test/test_pipes.py
==============================================================================
--- python/branches/py3k-jit/Lib/test/test_pipes.py	(original)
+++ python/branches/py3k-jit/Lib/test/test_pipes.py	Tue May 25 03:17:49 2010
@@ -70,9 +70,10 @@
         self.assertEqual(open(TESTFN).read(), d)
 
     def testQuoting(self):
-        safeunquoted = string.ascii_letters + string.digits + '!@%_-+=:,./'
-        unsafe = '"`$\\'
+        safeunquoted = string.ascii_letters + string.digits + '@%_-+=:,./'
+        unsafe = '"`$\\!'
 
+        self.assertEqual(pipes.quote(''), "''")
         self.assertEqual(pipes.quote(safeunquoted), safeunquoted)
         self.assertEqual(pipes.quote('test file name'), "'test file name'")
         for u in unsafe:
@@ -80,9 +81,7 @@
                               "'test%sname'" % u)
         for u in unsafe:
             self.assertEqual(pipes.quote("test%s'name'" % u),
-                              '"test\\%s\'name\'"' % u)
-
-        self.assertEqual(pipes.quote(''), "''")
+                             "'test%s'\"'\"'name'\"'\"''" % u)
 
     def testRepr(self):
         t = pipes.Template()

Modified: python/branches/py3k-jit/Lib/test/test_ssl.py
==============================================================================
--- python/branches/py3k-jit/Lib/test/test_ssl.py	(original)
+++ python/branches/py3k-jit/Lib/test/test_ssl.py	Tue May 25 03:17:49 2010
@@ -57,6 +57,14 @@
     if support.verbose:
         sys.stdout.write(prefix + exc_format)
 
+def can_clear_options():
+    # 0.9.8m or higher
+    return ssl.OPENSSL_VERSION_INFO >= (0, 9, 8, 13, 15)
+
+def no_sslv2_implies_sslv3_hello():
+    # 0.9.7h or higher
+    return ssl.OPENSSL_VERSION_INFO >= (0, 9, 7, 8, 15)
+
 
 class BasicSocketTests(unittest.TestCase):
 
@@ -189,6 +197,26 @@
         with self.assertRaisesRegexp(ssl.SSLError, "No cipher can be selected"):
             ctx.set_ciphers("^$:,;?*'dorothyx")
 
+    def test_options(self):
+        ctx = ssl.SSLContext(ssl.PROTOCOL_TLSv1)
+        # OP_ALL is the default value
+        self.assertEqual(ssl.OP_ALL, ctx.options)
+        ctx.options |= ssl.OP_NO_SSLv2
+        self.assertEqual(ssl.OP_ALL | ssl.OP_NO_SSLv2,
+                         ctx.options)
+        ctx.options |= ssl.OP_NO_SSLv3
+        self.assertEqual(ssl.OP_ALL | ssl.OP_NO_SSLv2 | ssl.OP_NO_SSLv3,
+                         ctx.options)
+        if can_clear_options():
+            ctx.options = (ctx.options & ~ssl.OP_NO_SSLv2) | ssl.OP_NO_TLSv1
+            self.assertEqual(ssl.OP_ALL | ssl.OP_NO_TLSv1 | ssl.OP_NO_SSLv3,
+                             ctx.options)
+            ctx.options = 0
+            self.assertEqual(0, ctx.options)
+        else:
+            with self.assertRaises(ValueError):
+                ctx.options = 0
+
     def test_verify(self):
         ctx = ssl.SSLContext(ssl.PROTOCOL_TLSv1)
         # Default value
@@ -445,12 +473,8 @@
 
             def wrap_conn(self):
                 try:
-                    self.sslconn = ssl.wrap_socket(self.sock, server_side=True,
-                                                   certfile=self.server.certificate,
-                                                   ssl_version=self.server.protocol,
-                                                   ca_certs=self.server.cacerts,
-                                                   cert_reqs=self.server.certreqs,
-                                                   ciphers=self.server.ciphers)
+                    self.sslconn = self.server.context.wrap_socket(
+                        self.sock, server_side=True)
                 except ssl.SSLError:
                     # XXX Various errors can have happened here, for example
                     # a mismatching protocol version, an invalid certificate,
@@ -462,7 +486,7 @@
                     self.close()
                     return False
                 else:
-                    if self.server.certreqs == ssl.CERT_REQUIRED:
+                    if self.server.context.verify_mode == ssl.CERT_REQUIRED:
                         cert = self.sslconn.getpeercert()
                         if support.verbose and self.server.chatty:
                             sys.stdout.write(" client cert is " + pprint.pformat(cert) + "\n")
@@ -542,19 +566,24 @@
                         # harness, we want to stop the server
                         self.server.stop()
 
-        def __init__(self, certificate, ssl_version=None,
+        def __init__(self, certificate=None, ssl_version=None,
                      certreqs=None, cacerts=None,
                      chatty=True, connectionchatty=False, starttls_server=False,
-                     ciphers=None):
-            if ssl_version is None:
-                ssl_version = ssl.PROTOCOL_TLSv1
-            if certreqs is None:
-                certreqs = ssl.CERT_NONE
-            self.certificate = certificate
-            self.protocol = ssl_version
-            self.certreqs = certreqs
-            self.cacerts = cacerts
-            self.ciphers = ciphers
+                     ciphers=None, context=None):
+            if context:
+                self.context = context
+            else:
+                self.context = ssl.SSLContext(ssl_version
+                                              if ssl_version is not None
+                                              else ssl.PROTOCOL_TLSv1)
+                self.context.verify_mode = (certreqs if certreqs is not None
+                                            else ssl.CERT_NONE)
+                if cacerts:
+                    self.context.load_verify_locations(cacerts)
+                if certificate:
+                    self.context.load_cert_chain(certificate)
+                if ciphers:
+                    self.context.set_ciphers(ciphers)
             self.chatty = chatty
             self.connectionchatty = connectionchatty
             self.starttls_server = starttls_server
@@ -820,18 +849,13 @@
             server.stop()
             server.join()
 
-    def server_params_test(certfile, protocol, certreqs, cacertsfile,
-                           client_certfile, client_protocol=None, indata=b"FOO\n",
-                           ciphers=None, chatty=True, connectionchatty=False):
+    def server_params_test(client_context, server_context, indata=b"FOO\n",
+                           chatty=True, connectionchatty=False):
         """
         Launch a server, connect a client to it and try various reads
         and writes.
         """
-        server = ThreadedEchoServer(certfile,
-                                    certreqs=certreqs,
-                                    ssl_version=protocol,
-                                    cacerts=cacertsfile,
-                                    ciphers=ciphers,
+        server = ThreadedEchoServer(context=server_context,
                                     chatty=chatty,
                                     connectionchatty=False)
         flag = threading.Event()
@@ -839,15 +863,8 @@
         # wait for it to start
         flag.wait()
         # try to connect
-        if client_protocol is None:
-            client_protocol = protocol
         try:
-            s = ssl.wrap_socket(socket.socket(),
-                                certfile=client_certfile,
-                                ca_certs=cacertsfile,
-                                ciphers=ciphers,
-                                cert_reqs=certreqs,
-                                ssl_version=client_protocol)
+            s = client_context.wrap_socket(socket.socket())
             s.connect((HOST, server.port))
             for arg in [indata, bytearray(indata), memoryview(indata)]:
                 if connectionchatty:
@@ -873,10 +890,8 @@
             server.stop()
             server.join()
 
-    def try_protocol_combo(server_protocol,
-                           client_protocol,
-                           expect_success,
-                           certsreqs=None):
+    def try_protocol_combo(server_protocol, client_protocol, expect_success,
+                           certsreqs=None, server_options=0, client_options=0):
         if certsreqs is None:
             certsreqs = ssl.CERT_NONE
         certtype = {
@@ -890,14 +905,21 @@
                              (ssl.get_protocol_name(client_protocol),
                               ssl.get_protocol_name(server_protocol),
                               certtype))
-        try:
+        client_context = ssl.SSLContext(client_protocol)
+        client_context.options = ssl.OP_ALL | client_options
+        server_context = ssl.SSLContext(server_protocol)
+        server_context.options = ssl.OP_ALL | server_options
+        for ctx in (client_context, server_context):
+            ctx.verify_mode = certsreqs
             # NOTE: we must enable "ALL" ciphers, otherwise an SSLv23 client
             # will send an SSLv3 hello (rather than SSLv2) starting from
             # OpenSSL 1.0.0 (see issue #8322).
-            server_params_test(CERTFILE, server_protocol, certsreqs,
-                               CERTFILE, CERTFILE, client_protocol,
-                               ciphers="ALL", chatty=False,
-                               connectionchatty=False)
+            ctx.set_ciphers("ALL")
+            ctx.load_cert_chain(CERTFILE)
+            ctx.load_verify_locations(CERTFILE)
+        try:
+            server_params_test(client_context, server_context,
+                               chatty=False, connectionchatty=False)
         # Protocol mismatch can result in either an SSLError, or a
         # "Connection reset by peer" error.
         except ssl.SSLError:
@@ -920,30 +942,27 @@
             """Basic test of an SSL client connecting to a server"""
             if support.verbose:
                 sys.stdout.write("\n")
-            server_params_test(CERTFILE, ssl.PROTOCOL_TLSv1, ssl.CERT_NONE,
-                               CERTFILE, CERTFILE, ssl.PROTOCOL_TLSv1,
-                               chatty=True, connectionchatty=True)
+            for protocol in PROTOCOLS:
+                context = ssl.SSLContext(protocol)
+                context.load_cert_chain(CERTFILE)
+                server_params_test(context, context,
+                                   chatty=True, connectionchatty=True)
 
         def test_getpeercert(self):
             if support.verbose:
                 sys.stdout.write("\n")
-            s2 = socket.socket()
-            server = ThreadedEchoServer(CERTFILE,
-                                        certreqs=ssl.CERT_NONE,
-                                        ssl_version=ssl.PROTOCOL_SSLv23,
-                                        cacerts=CERTFILE,
-                                        chatty=False)
+            context = ssl.SSLContext(ssl.PROTOCOL_SSLv23)
+            context.verify_mode = ssl.CERT_REQUIRED
+            context.load_verify_locations(CERTFILE)
+            context.load_cert_chain(CERTFILE)
+            server = ThreadedEchoServer(context=context, chatty=False)
             flag = threading.Event()
             server.start(flag)
             # wait for it to start
             flag.wait()
             # try to connect
             try:
-                s = ssl.wrap_socket(socket.socket(),
-                                    certfile=CERTFILE,
-                                    ca_certs=CERTFILE,
-                                    cert_reqs=ssl.CERT_REQUIRED,
-                                    ssl_version=ssl.PROTOCOL_SSLv23)
+                s = context.wrap_socket(socket.socket())
                 s.connect((HOST, server.port))
                 cert = s.getpeercert()
                 self.assertTrue(cert, "Can't get peer certificate.")
@@ -1031,6 +1050,15 @@
             try_protocol_combo(ssl.PROTOCOL_SSLv2, ssl.PROTOCOL_SSLv23, True)
             try_protocol_combo(ssl.PROTOCOL_SSLv2, ssl.PROTOCOL_SSLv3, False)
             try_protocol_combo(ssl.PROTOCOL_SSLv2, ssl.PROTOCOL_TLSv1, False)
+            # SSLv23 client with specific SSL options
+            if no_sslv2_implies_sslv3_hello():
+                # No SSLv2 => client will use an SSLv3 hello on recent OpenSSLs
+                try_protocol_combo(ssl.PROTOCOL_SSLv2, ssl.PROTOCOL_SSLv23, False,
+                                   client_options=ssl.OP_NO_SSLv2)
+            try_protocol_combo(ssl.PROTOCOL_SSLv2, ssl.PROTOCOL_SSLv23, True,
+                               client_options=ssl.OP_NO_SSLv3)
+            try_protocol_combo(ssl.PROTOCOL_SSLv2, ssl.PROTOCOL_SSLv23, True,
+                               client_options=ssl.OP_NO_TLSv1)
 
         def test_protocol_sslv23(self):
             """Connecting to an SSLv23 server with various client options"""
@@ -1056,6 +1084,16 @@
             try_protocol_combo(ssl.PROTOCOL_SSLv23, ssl.PROTOCOL_SSLv23, True, ssl.CERT_REQUIRED)
             try_protocol_combo(ssl.PROTOCOL_SSLv23, ssl.PROTOCOL_TLSv1, True, ssl.CERT_REQUIRED)
 
+            # Server with specific SSL options
+            try_protocol_combo(ssl.PROTOCOL_SSLv23, ssl.PROTOCOL_SSLv3, False,
+                               server_options=ssl.OP_NO_SSLv3)
+            # Will choose TLSv1
+            try_protocol_combo(ssl.PROTOCOL_SSLv23, ssl.PROTOCOL_SSLv23, True,
+                               server_options=ssl.OP_NO_SSLv2 | ssl.OP_NO_SSLv3)
+            try_protocol_combo(ssl.PROTOCOL_SSLv23, ssl.PROTOCOL_TLSv1, False,
+                               server_options=ssl.OP_NO_TLSv1)
+
+
         def test_protocol_sslv3(self):
             """Connecting to an SSLv3 server with various client options"""
             if support.verbose:
@@ -1066,6 +1104,10 @@
             try_protocol_combo(ssl.PROTOCOL_SSLv3, ssl.PROTOCOL_SSLv2, False)
             try_protocol_combo(ssl.PROTOCOL_SSLv3, ssl.PROTOCOL_SSLv23, False)
             try_protocol_combo(ssl.PROTOCOL_SSLv3, ssl.PROTOCOL_TLSv1, False)
+            if no_sslv2_implies_sslv3_hello():
+                # No SSLv2 => client will use an SSLv3 hello on recent OpenSSLs
+                try_protocol_combo(ssl.PROTOCOL_SSLv3, ssl.PROTOCOL_SSLv23, True,
+                                   client_options=ssl.OP_NO_SSLv2)
 
         def test_protocol_tlsv1(self):
             """Connecting to a TLSv1 server with various client options"""

Modified: python/branches/py3k-jit/Lib/test/test_subprocess.py
==============================================================================
--- python/branches/py3k-jit/Lib/test/test_subprocess.py	(original)
+++ python/branches/py3k-jit/Lib/test/test_subprocess.py	Tue May 25 03:17:49 2010
@@ -535,6 +535,17 @@
             if c.exception.errno != 2:  # ignore "no such file"
                 raise c.exception
 
+    def test_issue8780(self):
+        # Ensure that stdout is inherited from the parent
+        # if stdout=PIPE is not used
+        code = ';'.join((
+            'import subprocess, sys',
+            'retcode = subprocess.call('
+                "[sys.executable, '-c', 'print(\"Hello World!\")'])",
+            'assert retcode == 0'))
+        output = subprocess.check_output([sys.executable, '-c', code])
+        self.assert_(output.startswith(b'Hello World!'), ascii(output))
+
 
 # context manager
 class _SuppressCoreFiles(object):
@@ -825,6 +836,27 @@
             stdout = stdout.rstrip(b'\n\r')
             self.assertEquals(stdout.decode('ascii'), repr(value))
 
+    def test_bytes_program(self):
+        abs_program = os.fsencode(sys.executable)
+        path, program = os.path.split(sys.executable)
+        program = os.fsencode(program)
+
+        # absolute bytes path
+        exitcode = subprocess.call([abs_program, "-c", "pass"])
+        self.assertEquals(exitcode, 0)
+
+        # bytes program, unicode PATH
+        env = os.environ.copy()
+        env["PATH"] = path
+        exitcode = subprocess.call([program, "-c", "pass"], env=env)
+        self.assertEquals(exitcode, 0)
+
+        # bytes program, bytes PATH
+        envb = os.environb.copy()
+        envb[b"PATH"] = os.fsencode(path)
+        exitcode = subprocess.call([program, "-c", "pass"], env=envb)
+        self.assertEquals(exitcode, 0)
+
 
 @unittest.skipUnless(mswindows, "Windows specific tests")
 class Win32ProcessTestCase(BaseTestCase):

Modified: python/branches/py3k-jit/Lib/test/test_sys.py
==============================================================================
--- python/branches/py3k-jit/Lib/test/test_sys.py	(original)
+++ python/branches/py3k-jit/Lib/test/test_sys.py	Tue May 25 03:17:49 2010
@@ -147,9 +147,9 @@
                               "raise SystemExit(47)"])
         self.assertEqual(rc, 47)
 
-        def check_exit_message(code, expected):
+        def check_exit_message(code, expected, env=None):
             process = subprocess.Popen([sys.executable, "-c", code],
-                                       stderr=subprocess.PIPE)
+                                       stderr=subprocess.PIPE, env=env)
             stdout, stderr = process.communicate()
             self.assertEqual(process.returncode, 1)
             self.assertTrue(stderr.startswith(expected),
@@ -167,6 +167,14 @@
             r'import sys; sys.exit("surrogates:\uDCFF")',
             b"surrogates:\\udcff")
 
+        # test that the unicode message is encoded to the stderr encoding
+        # instead of the default encoding (utf8)
+        env = os.environ.copy()
+        env['PYTHONIOENCODING'] = 'latin-1'
+        check_exit_message(
+            r'import sys; sys.exit("h\xe9")',
+            b"h\xe9", env=env)
+
     def test_getdefaultencoding(self):
         self.assertRaises(TypeError, sys.getdefaultencoding, 42)
         # can't check more than the type, as the user might have changed it
@@ -419,6 +427,23 @@
         self.assertEqual(type(sys.int_info.bits_per_digit), int)
         self.assertEqual(type(sys.int_info.sizeof_digit), int)
         self.assertIsInstance(sys.hexversion, int)
+
+        self.assertEqual(len(sys.hash_info), 5)
+        self.assertLess(sys.hash_info.modulus, 2**sys.hash_info.width)
+        # sys.hash_info.modulus should be a prime; we do a quick
+        # probable primality test (doesn't exclude the possibility of
+        # a Carmichael number)
+        for x in range(1, 100):
+            self.assertEqual(
+                pow(x, sys.hash_info.modulus-1, sys.hash_info.modulus),
+                1,
+                "sys.hash_info.modulus {} is a non-prime".format(
+                    sys.hash_info.modulus)
+                )
+        self.assertIsInstance(sys.hash_info.inf, int)
+        self.assertIsInstance(sys.hash_info.nan, int)
+        self.assertIsInstance(sys.hash_info.imag, int)
+
         self.assertIsInstance(sys.maxsize, int)
         self.assertIsInstance(sys.maxunicode, int)
         self.assertIsInstance(sys.platform, str)

Modified: python/branches/py3k-jit/Lib/test/test_sysconfig.py
==============================================================================
--- python/branches/py3k-jit/Lib/test/test_sysconfig.py	(original)
+++ python/branches/py3k-jit/Lib/test/test_sysconfig.py	Tue May 25 03:17:49 2010
@@ -17,7 +17,7 @@
 from sysconfig import (get_paths, get_platform, get_config_vars,
                        get_path, get_path_names, _INSTALL_SCHEMES,
                        _get_default_scheme, _expand_vars,
-                       get_scheme_names)
+                       get_scheme_names, get_config_var)
 
 class TestSysConfig(unittest.TestCase):
 
@@ -254,6 +254,15 @@
         finally:
             unlink(link)
 
+    def test_user_similar(self):
+        # Issue 8759 : make sure the posix scheme for the users
+        # is similar to the global posix_prefix one
+        base = get_config_var('base')
+        user = get_config_var('userbase')
+        for name in ('stdlib', 'platstdlib', 'purelib', 'platlib'):
+            global_path = get_path(name, 'posix_prefix')
+            user_path = get_path(name, 'posix_user')
+            self.assertEquals(user_path, global_path.replace(base, user))
 
 def test_main():
     run_unittest(TestSysConfig)

Modified: python/branches/py3k-jit/Lib/test/test_warnings.py
==============================================================================
--- python/branches/py3k-jit/Lib/test/test_warnings.py	(original)
+++ python/branches/py3k-jit/Lib/test/test_warnings.py	Tue May 25 03:17:49 2010
@@ -738,20 +738,38 @@
     module = py_warnings
 
 
+class BootstrapTest(unittest.TestCase):
+    def test_issue_8766(self):
+        # "import encodings" emits a warning whereas the warnings is not loaded
+        # or not completly loaded (warnings imports indirectly encodings by
+        # importing linecache) yet
+        with support.temp_cwd() as cwd, support.temp_cwd('encodings'):
+            env = os.environ.copy()
+            env['PYTHONPATH'] = cwd
+
+            # encodings loaded by initfsencoding()
+            retcode = subprocess.call([sys.executable, '-c', 'pass'], env=env)
+            self.assertEqual(retcode, 0)
+
+            # Use -W to load warnings module at startup
+            retcode = subprocess.call(
+                [sys.executable, '-c', 'pass', '-W', 'always'],
+                env=env)
+            self.assertEqual(retcode, 0)
+
 def test_main():
     py_warnings.onceregistry.clear()
     c_warnings.onceregistry.clear()
-    support.run_unittest(CFilterTests,
-                                PyFilterTests,
-                                CWarnTests,
-                                PyWarnTests,
-                                CWCmdLineTests, PyWCmdLineTests,
-                                _WarningsTests,
-                                CWarningsDisplayTests, PyWarningsDisplayTests,
-                                CCatchWarningTests, PyCatchWarningTests,
-                                CEnvironmentVariableTests,
-                                PyEnvironmentVariableTests
-                             )
+    support.run_unittest(
+        CFilterTests, PyFilterTests,
+        CWarnTests, PyWarnTests,
+        CWCmdLineTests, PyWCmdLineTests,
+        _WarningsTests,
+        CWarningsDisplayTests, PyWarningsDisplayTests,
+        CCatchWarningTests, PyCatchWarningTests,
+        CEnvironmentVariableTests, PyEnvironmentVariableTests,
+        BootstrapTest,
+    )
 
 
 if __name__ == "__main__":

Modified: python/branches/py3k-jit/Misc/NEWS
==============================================================================
--- python/branches/py3k-jit/Misc/NEWS	(original)
+++ python/branches/py3k-jit/Misc/NEWS	Tue May 25 03:17:49 2010
@@ -31,6 +31,25 @@
 Core and Builtins
 -----------------
 
+- Issue #8188: Introduce a new scheme for computing hashes of numbers
+  (instances of int, float, complex, decimal.Decimal and
+  fractions.Fraction) that makes it easy to maintain the invariant
+  that hash(x) == hash(y) whenever x and y have equal value.
+
+- Issue #8748: Fix two issues with comparisons between complex and integer
+  objects.  (1) The comparison could incorrectly return True in some cases
+  (2**53+1 == complex(2**53) == 2**53), breaking transivity of equality.
+  (2) The comparison raised an OverflowError for large integers, leading
+  to unpredictable exceptions when combining integers and complex objects
+  in sets or dicts.
+
+- Issue #8766: Initialize _warnings module before importing the first module.
+  Fix a crash if an empty directory called "encodings" exists in sys.path.
+
+- Issue #8589: Decode PYTHONWARNINGS environment variable with the file system
+  encoding and surrogateespace error handler instead of the locale encoding to
+  be consistent with os.environ. Add PySys_AddWarnOptionUnicode() function.
+
 - PyObject_Dump() encodes unicode objects to utf8 with backslashreplace
   (instead of strict) error handler to escape surrogates
 
@@ -50,6 +69,8 @@
   PyUnicode_FromString() to support surrogates in the filename and use the
   right encoding
 
+- Issue #7507: Quote "!" in pipes.quote(); it is special to some shells.
+
 - PyUnicode_DecodeFSDefaultAndSize() uses surrogateescape error handler
 
 - Issue #8419: Prevent the dict constructor from accepting non-string keyword
@@ -331,6 +352,11 @@
 C-API
 -----
 
+- Issue #5753: A new C API function, :cfunc:`PySys_SetArgvEx`, allows
+  embedders of the interpreter to set sys.argv without also modifying
+  sys.path.  This helps fix `CVE-2008-5983
+  <http://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2008-5983>`_.
+
 - Add PyArg_ValidateKeywordArguments, which checks if all keyword arguments are
   strings in an efficient manner.
 
@@ -385,6 +411,42 @@
 Library
 -------
 
+- Issue #8540: Decimal module: rename the Context._clamp attribute to
+  Context.clamp and make it public.  This is useful in creating
+  contexts that correspond to the decimal interchange formats
+  specified in IEEE 754.
+
+- Issue #6268: Fix seek() method of codecs.open(), don't read or write the BOM
+  twice after seek(0). Fix also reset() method of codecs, UTF-16, UTF-32 and
+  StreamWriter classes.
+
+- Issue #3798: sys.exit(message) writes the message to sys.stderr file, instead
+  of the C file stderr, to use stderr encoding and error handler
+
+- Issue #8782: Add a trailing newline in linecache.updatecache to the last line
+  of files without one.
+
+- Issue #8729: Return NotImplemented from collections.Mapping.__eq__ when
+  comparing to a non-mapping.
+
+- Issue #8774: tabnanny uses the encoding cookie (#coding:...) to use the
+  correct encoding
+
+- Issue #4870: Add an `options` attribute to SSL contexts, as well as
+  several ``OP_*`` constants to the `ssl` module.  This allows to selectively
+  disable protocol versions, when used in combination with `PROTOCOL_SSLv23`.
+
+- Issue #8759: Fixed user paths in sysconfig for posix and os2 schemes.
+
+- Issue #8663: distutils.log emulates backslashreplace error handler. Fix
+  compilation in a non-ASCII directory if stdout encoding is ASCII (eg. if
+  stdout is not a TTY).
+
+- Issue #8513: os.get_exec_path() supports b'PATH' key and bytes value.
+  subprocess.Popen() and os._execvpe() support bytes program name. Add
+  os.supports_bytes_environ flag: True if the native OS type of the environment
+  is bytes (eg. False on Windows).
+
 - Issue #8633: tarfile is now able to read and write archives with "raw" binary
   pax headers as described in POSIX.1-2008.
 
@@ -456,7 +518,7 @@
 - Issue #8354: The siginterrupt setting is now preserved for all signals,
   not just SIGCHLD.
 
-- Issue #7192: webbrowser.get("firefox") now wors on Mac OS X, as does
+- Issue #7192: webbrowser.get("firefox") now works on Mac OS X, as does
   webbrowser.get("safari").
 
 - Issue #8464: tarfile no longer creates files with execute permissions set

Modified: python/branches/py3k-jit/Modules/_io/textio.c
==============================================================================
--- python/branches/py3k-jit/Modules/_io/textio.c	(original)
+++ python/branches/py3k-jit/Modules/_io/textio.c	Tue May 25 03:17:49 2010
@@ -905,8 +905,11 @@
                 Py_CLEAR(self->encoding);
         }
     }
-    if (self->encoding != NULL)
+    if (self->encoding != NULL) {
         encoding = _PyUnicode_AsString(self->encoding);
+        if (encoding == NULL)
+            goto error;
+    }
     else if (encoding != NULL) {
         self->encoding = PyUnicode_FromString(encoding);
         if (self->encoding == NULL)
@@ -935,6 +938,8 @@
     self->writetranslate = (newline == NULL || newline[0] != '\0');
     if (!self->readuniversal && self->readnl) {
         self->writenl = _PyUnicode_AsString(self->readnl);
+        if (self->writenl == NULL)
+            goto error;
         if (!strcmp(self->writenl, "\n"))
             self->writenl = NULL;
     }
@@ -2408,7 +2413,7 @@
     Py_DECREF(res);
     if (r < 0)
         return NULL;
-    
+
     if (r > 0) {
         Py_RETURN_NONE; /* stream already closed */
     }

Modified: python/branches/py3k-jit/Modules/_sqlite/connection.c
==============================================================================
--- python/branches/py3k-jit/Modules/_sqlite/connection.c	(original)
+++ python/branches/py3k-jit/Modules/_sqlite/connection.c	Tue May 25 03:17:49 2010
@@ -3,7 +3,7 @@
  * Copyright (C) 2004-2010 Gerhard Häring <gh at ghaering.de>
  *
  * This file is part of pysqlite.
- * 
+ *
  * This software is provided 'as-is', without any express or implied
  * warranty.  In no event will the authors be held liable for any damages
  * arising from the use of this software.
@@ -495,7 +495,9 @@
     } else if (PyFloat_Check(py_val)) {
         sqlite3_result_double(context, PyFloat_AsDouble(py_val));
     } else if (PyUnicode_Check(py_val)) {
-        sqlite3_result_text(context, _PyUnicode_AsString(py_val), -1, SQLITE_TRANSIENT);
+        char *str = _PyUnicode_AsString(py_val);
+        if (str != NULL)
+            sqlite3_result_text(context, str, -1, SQLITE_TRANSIENT);
     } else if (PyObject_CheckBuffer(py_val)) {
         if (PyObject_AsCharBuffer(py_val, &buffer, &buflen) != 0) {
             PyErr_SetString(PyExc_ValueError, "could not convert BLOB to buffer");
@@ -892,7 +894,7 @@
         }
 
         /* abort query if error occurred */
-        rc = 1; 
+        rc = 1;
     } else {
         rc = (int)PyObject_IsTrue(ret);
         Py_DECREF(ret);

Modified: python/branches/py3k-jit/Modules/_sqlite/cursor.c
==============================================================================
--- python/branches/py3k-jit/Modules/_sqlite/cursor.c	(original)
+++ python/branches/py3k-jit/Modules/_sqlite/cursor.c	Tue May 25 03:17:49 2010
@@ -368,7 +368,7 @@
                         }
                         PyOS_snprintf(buf, sizeof(buf) - 1, "Could not decode to UTF-8 column '%s' with text '%s'",
                                      colname , val_str);
-                        buf_bytes = PyByteArray_FromStringAndSize(buf, strlen(buf)); 
+                        buf_bytes = PyByteArray_FromStringAndSize(buf, strlen(buf));
                         if (!buf_bytes) {
                             PyErr_SetString(pysqlite_OperationalError, "Could not decode to UTF-8");
                         } else {
@@ -533,7 +533,7 @@
     }
 
     operation_cstr = _PyUnicode_AsStringAndSize(operation, &operation_len);
-    if (operation == NULL)
+    if (operation_cstr == NULL)
         goto error;
 
     /* reset description and rowcount */

Modified: python/branches/py3k-jit/Modules/_sqlite/row.c
==============================================================================
--- python/branches/py3k-jit/Modules/_sqlite/row.c	(original)
+++ python/branches/py3k-jit/Modules/_sqlite/row.c	Tue May 25 03:17:49 2010
@@ -83,6 +83,8 @@
         return item;
     } else if (PyUnicode_Check(idx)) {
         key = _PyUnicode_AsString(idx);
+        if (key == NULL)
+            return NULL;
 
         nitems = PyTuple_Size(self->description);
 

Modified: python/branches/py3k-jit/Modules/_sqlite/statement.c
==============================================================================
--- python/branches/py3k-jit/Modules/_sqlite/statement.c	(original)
+++ python/branches/py3k-jit/Modules/_sqlite/statement.c	Tue May 25 03:17:49 2010
@@ -130,7 +130,10 @@
             break;
         case TYPE_UNICODE:
             string = _PyUnicode_AsString(parameter);
-            rc = sqlite3_bind_text(self->st, pos, string, -1, SQLITE_TRANSIENT);
+            if (string != NULL)
+                rc = sqlite3_bind_text(self->st, pos, string, -1, SQLITE_TRANSIENT);
+            else
+                rc = -1;
             break;
         case TYPE_BUFFER:
             if (PyObject_AsCharBuffer(parameter, &buffer, &buflen) == 0) {

Modified: python/branches/py3k-jit/Modules/_ssl.c
==============================================================================
--- python/branches/py3k-jit/Modules/_ssl.c	(original)
+++ python/branches/py3k-jit/Modules/_ssl.c	Tue May 25 03:17:49 2010
@@ -113,6 +113,13 @@
 # undef HAVE_OPENSSL_RAND
 #endif
 
+/* SSL_CTX_clear_options() and SSL_clear_options() were first added in OpenSSL 0.9.8m */
+#if OPENSSL_VERSION_NUMBER >= 0x009080dfL
+# define HAVE_SSL_CTX_CLEAR_OPTIONS
+#else
+# undef HAVE_SSL_CTX_CLEAR_OPTIONS
+#endif
+
 typedef struct {
     PyObject_HEAD
     SSL_CTX *ctx;
@@ -1514,6 +1521,35 @@
 }
 
 static PyObject *
+get_options(PySSLContext *self, void *c)
+{
+    return PyLong_FromLong(SSL_CTX_get_options(self->ctx));
+}
+
+static int
+set_options(PySSLContext *self, PyObject *arg, void *c)
+{
+    long new_opts, opts, set, clear;
+    if (!PyArg_Parse(arg, "l", &new_opts))
+        return -1;
+    opts = SSL_CTX_get_options(self->ctx);
+    clear = opts & ~new_opts;
+    set = ~opts & new_opts;
+    if (clear) {
+#ifdef HAVE_SSL_CTX_CLEAR_OPTIONS
+        SSL_CTX_clear_options(self->ctx, clear);
+#else
+        PyErr_SetString(PyExc_ValueError,
+                        "can't clear options before OpenSSL 0.9.8m");
+        return -1;
+#endif
+    }
+    if (set)
+        SSL_CTX_set_options(self->ctx, set);
+    return 0;
+}
+
+static PyObject *
 load_cert_chain(PySSLContext *self, PyObject *args, PyObject *kwds)
 {
     char *kwlist[] = {"certfile", "keyfile", NULL};
@@ -1636,6 +1672,8 @@
 }
 
 static PyGetSetDef context_getsetlist[] = {
+    {"options", (getter) get_options,
+                (setter) set_options, NULL},
     {"verify_mode", (getter) get_verify_mode,
                     (setter) set_verify_mode, NULL},
     {NULL},            /* sentinel */
@@ -1953,6 +1991,12 @@
     PyModule_AddIntConstant(m, "PROTOCOL_TLSv1",
                             PY_SSL_VERSION_TLS1);
 
+    /* protocol options */
+    PyModule_AddIntConstant(m, "OP_ALL", SSL_OP_ALL);
+    PyModule_AddIntConstant(m, "OP_NO_SSLv2", SSL_OP_NO_SSLv2);
+    PyModule_AddIntConstant(m, "OP_NO_SSLv3", SSL_OP_NO_SSLv3);
+    PyModule_AddIntConstant(m, "OP_NO_TLSv1", SSL_OP_NO_TLSv1);
+
     /* OpenSSL version */
     /* SSLeay() gives us the version of the library linked against,
        which could be different from the headers version.

Modified: python/branches/py3k-jit/Modules/main.c
==============================================================================
--- python/branches/py3k-jit/Modules/main.c	(original)
+++ python/branches/py3k-jit/Modules/main.c	Tue May 25 03:17:49 2010
@@ -425,7 +425,7 @@
 #else
     if ((p = Py_GETENV("PYTHONWARNINGS")) && *p != '\0') {
         char *buf, *oldloc;
-        wchar_t *warning;
+        PyObject *warning;
 
         /* settle for strtok here as there's no one standard
            C89 wcstok */
@@ -437,9 +437,10 @@
         oldloc = strdup(setlocale(LC_ALL, NULL));
         setlocale(LC_ALL, "");
         for (p = strtok(buf, ","); p != NULL; p = strtok(NULL, ",")) {
-            if ((warning = _Py_char2wchar(p)) != NULL) {
-                PySys_AddWarnOption(warning);
-                PyMem_Free(warning);
+            warning = PyUnicode_DecodeFSDefault(p);
+            if (warning != NULL) {
+                PySys_AddWarnOptionUnicode(warning);
+                Py_DECREF(warning);
             }
         }
         setlocale(LC_ALL, oldloc);

Modified: python/branches/py3k-jit/Objects/complexobject.c
==============================================================================
--- python/branches/py3k-jit/Objects/complexobject.c	(original)
+++ python/branches/py3k-jit/Objects/complexobject.c	Tue May 25 03:17:49 2010
@@ -403,12 +403,12 @@
 static long
 complex_hash(PyComplexObject *v)
 {
-    long hashreal, hashimag, combined;
-    hashreal = _Py_HashDouble(v->cval.real);
-    if (hashreal == -1)
+    unsigned long hashreal, hashimag, combined;
+    hashreal = (unsigned long)_Py_HashDouble(v->cval.real);
+    if (hashreal == (unsigned long)-1)
         return -1;
-    hashimag = _Py_HashDouble(v->cval.imag);
-    if (hashimag == -1)
+    hashimag = (unsigned long)_Py_HashDouble(v->cval.imag);
+    if (hashimag == (unsigned long)-1)
         return -1;
     /* Note:  if the imaginary part is 0, hashimag is 0 now,
      * so the following returns hashreal unchanged.  This is
@@ -416,10 +416,10 @@
      * compare equal must have the same hash value, so that
      * hash(x + 0*j) must equal hash(x).
      */
-    combined = hashreal + 1000003 * hashimag;
-    if (combined == -1)
-        combined = -2;
-    return combined;
+    combined = hashreal + _PyHASH_IMAG * hashimag;
+    if (combined == (unsigned long)-1)
+        combined = (unsigned long)-2;
+    return (long)combined;
 }
 
 /* This macro may return! */
@@ -620,22 +620,58 @@
 complex_richcompare(PyObject *v, PyObject *w, int op)
 {
     PyObject *res;
-    Py_complex i, j;
-    TO_COMPLEX(v, i);
-    TO_COMPLEX(w, j);
+    Py_complex i;
+    int equal;
 
     if (op != Py_EQ && op != Py_NE) {
-        Py_INCREF(Py_NotImplemented);
-        return Py_NotImplemented;
+        goto Unimplemented;
+    }
+
+    assert(PyComplex_Check(v));
+    TO_COMPLEX(v, i);
+
+    if (PyLong_Check(w)) {
+        /* Check for 0.0 imaginary part first to avoid the rich
+         * comparison when possible.
+         */
+        if (i.imag == 0.0) {
+            PyObject *j, *sub_res;
+            j = PyFloat_FromDouble(i.real);
+            if (j == NULL)
+                return NULL;
+
+            sub_res = PyObject_RichCompare(j, w, op);
+            Py_DECREF(j);
+            return sub_res;
+        }
+        else {
+            equal = 0;
+        }
     }
+    else if (PyFloat_Check(w)) {
+        equal = (i.real == PyFloat_AsDouble(w) && i.imag == 0.0);
+    }
+    else if (PyComplex_Check(w)) {
+        Py_complex j;
 
-    if ((i.real == j.real && i.imag == j.imag) == (op == Py_EQ))
-        res = Py_True;
+        TO_COMPLEX(w, j);
+        equal = (i.real == j.real && i.imag == j.imag);
+    }
+    else {
+        goto Unimplemented;
+    }
+
+    if (equal == (op == Py_EQ))
+         res = Py_True;
     else
-        res = Py_False;
+         res = Py_False;
 
     Py_INCREF(res);
     return res;
+
+Unimplemented:
+    Py_INCREF(Py_NotImplemented);
+    return Py_NotImplemented;
 }
 
 static PyObject *

Modified: python/branches/py3k-jit/Objects/longobject.c
==============================================================================
--- python/branches/py3k-jit/Objects/longobject.c	(original)
+++ python/branches/py3k-jit/Objects/longobject.c	Tue May 25 03:17:49 2010
@@ -2571,18 +2571,37 @@
         sign = -1;
         i = -(i);
     }
-    /* The following loop produces a C unsigned long x such that x is
-       congruent to the absolute value of v modulo ULONG_MAX.  The
-       resulting x is nonzero if and only if v is. */
     while (--i >= 0) {
-        /* Force a native long #-bits (32 or 64) circular shift */
-        x = (x >> (8*SIZEOF_LONG-PyLong_SHIFT)) | (x << PyLong_SHIFT);
+        /* Here x is a quantity in the range [0, _PyHASH_MODULUS); we
+           want to compute x * 2**PyLong_SHIFT + v->ob_digit[i] modulo
+           _PyHASH_MODULUS.
+
+           The computation of x * 2**PyLong_SHIFT % _PyHASH_MODULUS
+           amounts to a rotation of the bits of x.  To see this, write
+
+             x * 2**PyLong_SHIFT = y * 2**_PyHASH_BITS + z
+
+           where y = x >> (_PyHASH_BITS - PyLong_SHIFT) gives the top
+           PyLong_SHIFT bits of x (those that are shifted out of the
+           original _PyHASH_BITS bits, and z = (x << PyLong_SHIFT) &
+           _PyHASH_MODULUS gives the bottom _PyHASH_BITS - PyLong_SHIFT
+           bits of x, shifted up.  Then since 2**_PyHASH_BITS is
+           congruent to 1 modulo _PyHASH_MODULUS, y*2**_PyHASH_BITS is
+           congruent to y modulo _PyHASH_MODULUS.  So
+
+             x * 2**PyLong_SHIFT = y + z (mod _PyHASH_MODULUS).
+
+           The right-hand side is just the result of rotating the
+           _PyHASH_BITS bits of x left by PyLong_SHIFT places; since
+           not all _PyHASH_BITS bits of x are 1s, the same is true
+           after rotation, so 0 <= y+z < _PyHASH_MODULUS and y + z is
+           the reduction of x*2**PyLong_SHIFT modulo
+           _PyHASH_MODULUS. */
+        x = ((x << PyLong_SHIFT) & _PyHASH_MODULUS) |
+            (x >> (_PyHASH_BITS - PyLong_SHIFT));
         x += v->ob_digit[i];
-        /* If the addition above overflowed we compensate by
-           incrementing.  This preserves the value modulo
-           ULONG_MAX. */
-        if (x < v->ob_digit[i])
-            x++;
+        if (x >= _PyHASH_MODULUS)
+            x -= _PyHASH_MODULUS;
     }
     x = x * sign;
     if (x == (unsigned long)-1)

Modified: python/branches/py3k-jit/Objects/moduleobject.c
==============================================================================
--- python/branches/py3k-jit/Objects/moduleobject.c	(original)
+++ python/branches/py3k-jit/Objects/moduleobject.c	Tue May 25 03:17:49 2010
@@ -263,10 +263,15 @@
     pos = 0;
     while (PyDict_Next(d, &pos, &key, &value)) {
         if (value != Py_None && PyUnicode_Check(key)) {
-            const char *s = _PyUnicode_AsString(key);
-            if (s[0] == '_' && s[1] != '_') {
-                if (Py_VerboseFlag > 1)
-                    PySys_WriteStderr("#   clear[1] %s\n", s);
+            Py_UNICODE *u = PyUnicode_AS_UNICODE(key);
+            if (u[0] == '_' && u[1] != '_') {
+                if (Py_VerboseFlag > 1) {
+                    const char *s = _PyUnicode_AsString(key);
+                    if (s != NULL)
+                        PySys_WriteStderr("#   clear[1] %s\n", s);
+                    else
+                        PyErr_Clear();
+                }
                 PyDict_SetItem(d, key, Py_None);
             }
         }
@@ -276,10 +281,17 @@
     pos = 0;
     while (PyDict_Next(d, &pos, &key, &value)) {
         if (value != Py_None && PyUnicode_Check(key)) {
-            const char *s = _PyUnicode_AsString(key);
-            if (s[0] != '_' || strcmp(s, "__builtins__") != 0) {
-                if (Py_VerboseFlag > 1)
-                    PySys_WriteStderr("#   clear[2] %s\n", s);
+            Py_UNICODE *u = PyUnicode_AS_UNICODE(key);
+            if (u[0] != '_'
+                || PyUnicode_CompareWithASCIIString(key, "__builtins__") != 0)
+            {
+                if (Py_VerboseFlag > 1) {
+                    const char *s = _PyUnicode_AsString(key);
+                    if (s != NULL)
+                        PySys_WriteStderr("#   clear[2] %s\n", s);
+                    else
+                        PyErr_Clear();
+                }
                 PyDict_SetItem(d, key, Py_None);
             }
         }

Modified: python/branches/py3k-jit/Objects/object.c
==============================================================================
--- python/branches/py3k-jit/Objects/object.c	(original)
+++ python/branches/py3k-jit/Objects/object.c	Tue May 25 03:17:49 2010
@@ -647,63 +647,101 @@
    All the utility functions (_Py_Hash*()) return "-1" to signify an error.
 */
 
+/* For numeric types, the hash of a number x is based on the reduction
+   of x modulo the prime P = 2**_PyHASH_BITS - 1.  It's designed so that
+   hash(x) == hash(y) whenever x and y are numerically equal, even if
+   x and y have different types.
+
+   A quick summary of the hashing strategy:
+
+   (1) First define the 'reduction of x modulo P' for any rational
+   number x; this is a standard extension of the usual notion of
+   reduction modulo P for integers.  If x == p/q (written in lowest
+   terms), the reduction is interpreted as the reduction of p times
+   the inverse of the reduction of q, all modulo P; if q is exactly
+   divisible by P then define the reduction to be infinity.  So we've
+   got a well-defined map
+
+      reduce : { rational numbers } -> { 0, 1, 2, ..., P-1, infinity }.
+
+   (2) Now for a rational number x, define hash(x) by:
+
+      reduce(x)   if x >= 0
+      -reduce(-x) if x < 0
+
+   If the result of the reduction is infinity (this is impossible for
+   integers, floats and Decimals) then use the predefined hash value
+   _PyHASH_INF for x >= 0, or -_PyHASH_INF for x < 0, instead.
+   _PyHASH_INF, -_PyHASH_INF and _PyHASH_NAN are also used for the
+   hashes of float and Decimal infinities and nans.
+
+   A selling point for the above strategy is that it makes it possible
+   to compute hashes of decimal and binary floating-point numbers
+   efficiently, even if the exponent of the binary or decimal number
+   is large.  The key point is that
+
+      reduce(x * y) == reduce(x) * reduce(y) (modulo _PyHASH_MODULUS)
+
+   provided that {reduce(x), reduce(y)} != {0, infinity}.  The reduction of a
+   binary or decimal float is never infinity, since the denominator is a power
+   of 2 (for binary) or a divisor of a power of 10 (for decimal).  So we have,
+   for nonnegative x,
+
+      reduce(x * 2**e) == reduce(x) * reduce(2**e) % _PyHASH_MODULUS
+
+      reduce(x * 10**e) == reduce(x) * reduce(10**e) % _PyHASH_MODULUS
+
+   and reduce(10**e) can be computed efficiently by the usual modular
+   exponentiation algorithm.  For reduce(2**e) it's even better: since
+   P is of the form 2**n-1, reduce(2**e) is 2**(e mod n), and multiplication
+   by 2**(e mod n) modulo 2**n-1 just amounts to a rotation of bits.
+
+   */
+
 long
 _Py_HashDouble(double v)
 {
-    double intpart, fractpart;
-    int expo;
-    long hipart;
-    long x;             /* the final hash value */
-    /* This is designed so that Python numbers of different types
-     * that compare equal hash to the same value; otherwise comparisons
-     * of mapping keys will turn out weird.
-     */
+    int e, sign;
+    double m;
+    unsigned long x, y;
 
     if (!Py_IS_FINITE(v)) {
         if (Py_IS_INFINITY(v))
-            return v < 0 ? -271828 : 314159;
+            return v > 0 ? _PyHASH_INF : -_PyHASH_INF;
         else
-            return 0;
+            return _PyHASH_NAN;
     }
-    fractpart = modf(v, &intpart);
-    if (fractpart == 0.0) {
-        /* This must return the same hash as an equal int or long. */
-        if (intpart > LONG_MAX/2 || -intpart > LONG_MAX/2) {
-            /* Convert to long and use its hash. */
-            PyObject *plong;                    /* converted to Python long */
-            plong = PyLong_FromDouble(v);
-            if (plong == NULL)
-                return -1;
-            x = PyObject_Hash(plong);
-            Py_DECREF(plong);
-            return x;
-        }
-        /* Fits in a C long == a Python int, so is its own hash. */
-        x = (long)intpart;
-        if (x == -1)
-            x = -2;
-        return x;
-    }
-    /* The fractional part is non-zero, so we don't have to worry about
-     * making this match the hash of some other type.
-     * Use frexp to get at the bits in the double.
-     * Since the VAX D double format has 56 mantissa bits, which is the
-     * most of any double format in use, each of these parts may have as
-     * many as (but no more than) 56 significant bits.
-     * So, assuming sizeof(long) >= 4, each part can be broken into two
-     * longs; frexp and multiplication are used to do that.
-     * Also, since the Cray double format has 15 exponent bits, which is
-     * the most of any double format in use, shifting the exponent field
-     * left by 15 won't overflow a long (again assuming sizeof(long) >= 4).
-     */
-    v = frexp(v, &expo);
-    v *= 2147483648.0;          /* 2**31 */
-    hipart = (long)v;           /* take the top 32 bits */
-    v = (v - (double)hipart) * 2147483648.0; /* get the next 32 bits */
-    x = hipart + (long)v + (expo << 15);
-    if (x == -1)
-        x = -2;
-    return x;
+
+    m = frexp(v, &e);
+
+    sign = 1;
+    if (m < 0) {
+        sign = -1;
+        m = -m;
+    }
+
+    /* process 28 bits at a time;  this should work well both for binary
+       and hexadecimal floating point. */
+    x = 0;
+    while (m) {
+        x = ((x << 28) & _PyHASH_MODULUS) | x >> (_PyHASH_BITS - 28);
+        m *= 268435456.0;  /* 2**28 */
+        e -= 28;
+        y = (unsigned long)m;  /* pull out integer part */
+        m -= y;
+        x += y;
+        if (x >= _PyHASH_MODULUS)
+            x -= _PyHASH_MODULUS;
+    }
+
+    /* adjust for the exponent;  first reduce it modulo _PyHASH_BITS */
+    e = e >= 0 ? e % _PyHASH_BITS : _PyHASH_BITS-1-((-1-e) % _PyHASH_BITS);
+    x = ((x << e) & _PyHASH_MODULUS) | x >> (_PyHASH_BITS - e);
+
+    x = x * sign;
+    if (x == (unsigned long)-1)
+        x = (unsigned long)-2;
+    return (long)x;
 }
 
 long
@@ -950,31 +988,7 @@
             goto done;
     }
 
-#if 0 /* XXX this is not quite _PyType_Lookup anymore */
-    /* Inline _PyType_Lookup */
-    {
-        Py_ssize_t i, n;
-        PyObject *mro, *base, *dict;
-
-        /* Look in tp_dict of types in MRO */
-        mro = tp->tp_mro;
-        assert(mro != NULL);
-        assert(PyTuple_Check(mro));
-        n = PyTuple_GET_SIZE(mro);
-        for (i = 0; i < n; i++) {
-            base = PyTuple_GET_ITEM(mro, i);
-            assert(PyType_Check(base));
-            dict = ((PyTypeObject *)base)->tp_dict;
-            assert(dict && PyDict_Check(dict));
-            descr = PyDict_GetItem(dict, name);
-            if (descr != NULL)
-                break;
-        }
-    }
-#else
     descr = _PyType_Lookup(tp, name);
-#endif
-
     Py_XINCREF(descr);
 
     f = NULL;

Modified: python/branches/py3k-jit/Objects/typeobject.c
==============================================================================
--- python/branches/py3k-jit/Objects/typeobject.c	(original)
+++ python/branches/py3k-jit/Objects/typeobject.c	Tue May 25 03:17:49 2010
@@ -1347,8 +1347,14 @@
     i = 0;
     while (PyDict_Next(set, &i, &k, &v) && (size_t)off < sizeof(buf)) {
         PyObject *name = class_name(k);
-        off += PyOS_snprintf(buf + off, sizeof(buf) - off, " %s",
-                             name ? _PyUnicode_AsString(name) : "?");
+        char *name_str;
+        if (name != NULL) {
+            name_str = _PyUnicode_AsString(name);
+            if (name_str == NULL)
+                name_str = "?";
+        } else
+            name_str = "?";
+        off += PyOS_snprintf(buf + off, sizeof(buf) - off, " %s", name_str);
         Py_XDECREF(name);
         if (--n && (size_t)(off+1) < sizeof(buf)) {
             buf[off++] = ',';
@@ -2220,6 +2226,10 @@
         for (i = 0; i < nslots; i++, mp++) {
             mp->name = _PyUnicode_AsString(
                 PyTuple_GET_ITEM(slots, i));
+            if (mp->name == NULL) {
+                Py_DECREF(type);
+                return NULL;
+            }
             mp->type = T_OBJECT_EX;
             mp->offset = slotoffset;
 
@@ -4911,6 +4921,7 @@
     PyObject *func, *res;
     static PyObject *hash_str;
     long h;
+    int overflow;
 
     func = lookup_method(self, "__hash__", &hash_str);
 
@@ -4927,14 +4938,27 @@
     Py_DECREF(func);
     if (res == NULL)
         return -1;
-    if (PyLong_Check(res))
+
+    if (!PyLong_Check(res)) {
+        PyErr_SetString(PyExc_TypeError,
+                        "__hash__ method should return an integer");
+        return -1;
+    }
+    /* Transform the PyLong `res` to a C long `h`.  For an existing
+       hashable Python object x, hash(x) will always lie within the range
+       of a C long.  Therefore our transformation must preserve values
+       that already lie within this range, to ensure that if x.__hash__()
+       returns hash(y) then hash(x) == hash(y). */
+    h = PyLong_AsLongAndOverflow(res, &overflow);
+    if (overflow)
+        /* res was not within the range of a C long, so we're free to
+           use any sufficiently bit-mixing transformation;
+           long.__hash__ will do nicely. */
         h = PyLong_Type.tp_hash(res);
-    else
-        h = PyLong_AsLong(res);
     Py_DECREF(res);
-           if (h == -1 && !PyErr_Occurred())
-           h = -2;
-           return h;
+    if (h == -1 && !PyErr_Occurred())
+        h = -2;
+    return h;
 }
 
 static PyObject *

Modified: python/branches/py3k-jit/Parser/asdl.py
==============================================================================
--- python/branches/py3k-jit/Parser/asdl.py	(original)
+++ python/branches/py3k-jit/Parser/asdl.py	Tue May 25 03:17:49 2010
@@ -1,7 +1,7 @@
 """An implementation of the Zephyr Abstract Syntax Definition Language.
 
 See http://asdl.sourceforge.net/ and
-http://www.cs.princeton.edu/~danwang/Papers/dsl97/dsl97-abstract.html.
+http://www.cs.princeton.edu/research/techreps/TR-554-97
 
 Only supports top level module decl, not view.  I'm guessing that view
 is intended to support the browser and I'm not interested in the

Modified: python/branches/py3k-jit/Python/_warnings.c
==============================================================================
--- python/branches/py3k-jit/Python/_warnings.c	(original)
+++ python/branches/py3k-jit/Python/_warnings.c	Tue May 25 03:17:49 2010
@@ -116,7 +116,7 @@
         _filters = warnings_filters;
     }
 
-    if (!PyList_Check(_filters)) {
+    if (_filters == NULL || !PyList_Check(_filters)) {
         PyErr_SetString(PyExc_ValueError,
                         MODULE_NAME ".filters must be a list");
         return NULL;

Modified: python/branches/py3k-jit/Python/bltinmodule.c
==============================================================================
--- python/branches/py3k-jit/Python/bltinmodule.c	(original)
+++ python/branches/py3k-jit/Python/bltinmodule.c	Tue May 25 03:17:49 2010
@@ -1610,6 +1610,7 @@
         char *prompt;
         char *s;
         PyObject *stdin_encoding;
+        char *stdin_encoding_str;
         PyObject *result;
 
         stdin_encoding = PyObject_GetAttrString(fin, "encoding");
@@ -1617,6 +1618,11 @@
             /* stdin is a text stream, so it must have an
                encoding. */
             return NULL;
+        stdin_encoding_str = _PyUnicode_AsString(stdin_encoding);
+        if (stdin_encoding_str  == NULL) {
+            Py_DECREF(stdin_encoding);
+            return NULL;
+        }
         tmp = PyObject_CallMethod(fout, "flush", "");
         if (tmp == NULL)
             PyErr_Clear();
@@ -1625,12 +1631,18 @@
         if (promptarg != NULL) {
             PyObject *stringpo;
             PyObject *stdout_encoding;
-            stdout_encoding = PyObject_GetAttrString(fout,
-                                                     "encoding");
+            char *stdout_encoding_str;
+            stdout_encoding = PyObject_GetAttrString(fout, "encoding");
             if (stdout_encoding == NULL) {
                 Py_DECREF(stdin_encoding);
                 return NULL;
             }
+            stdout_encoding_str = _PyUnicode_AsString(stdout_encoding);
+            if (stdout_encoding_str == NULL) {
+                Py_DECREF(stdin_encoding);
+                Py_DECREF(stdout_encoding);
+                return NULL;
+            }
             stringpo = PyObject_Str(promptarg);
             if (stringpo == NULL) {
                 Py_DECREF(stdin_encoding);
@@ -1638,7 +1650,7 @@
                 return NULL;
             }
             po = PyUnicode_AsEncodedString(stringpo,
-                _PyUnicode_AsString(stdout_encoding), NULL);
+                stdout_encoding_str, NULL);
             Py_DECREF(stdout_encoding);
             Py_DECREF(stringpo);
             if (po == NULL) {
@@ -1676,10 +1688,7 @@
                 result = NULL;
             }
             else {
-                result = PyUnicode_Decode
-                    (s, len-1,
-                     _PyUnicode_AsString(stdin_encoding),
-                     NULL);
+                result = PyUnicode_Decode(s, len-1, stdin_encoding_str, NULL);
             }
         }
         Py_DECREF(stdin_encoding);

Modified: python/branches/py3k-jit/Python/getargs.c
==============================================================================
--- python/branches/py3k-jit/Python/getargs.c	(original)
+++ python/branches/py3k-jit/Python/getargs.c	Tue May 25 03:17:49 2010
@@ -1755,18 +1755,21 @@
                                 "keywords must be strings");
                 return cleanreturn(0, freelist);
             }
+            /* check that _PyUnicode_AsString() result is not NULL */
             ks = _PyUnicode_AsString(key);
-            for (i = 0; i < len; i++) {
-                if (!strcmp(ks, kwlist[i])) {
-                    match = 1;
-                    break;
+            if (ks != NULL) {
+                for (i = 0; i < len; i++) {
+                    if (!strcmp(ks, kwlist[i])) {
+                        match = 1;
+                        break;
+                    }
                 }
             }
             if (!match) {
                 PyErr_Format(PyExc_TypeError,
-                             "'%s' is an invalid keyword "
+                             "'%U' is an invalid keyword "
                              "argument for this function",
-                             ks);
+                             key);
                 return cleanreturn(0, freelist);
             }
         }

Modified: python/branches/py3k-jit/Python/pythonrun.c
==============================================================================
--- python/branches/py3k-jit/Python/pythonrun.c	(original)
+++ python/branches/py3k-jit/Python/pythonrun.c	Tue May 25 03:17:49 2010
@@ -138,8 +138,8 @@
 static char*
 get_codeset(void)
 {
-    char* codeset;
-    PyObject *codec, *name;
+    char* codeset, *name_str;
+    PyObject *codec, *name = NULL;
 
     codeset = nl_langinfo(CODESET);
     if (!codeset || codeset[0] == '\0')
@@ -154,12 +154,16 @@
     if (!name)
         goto error;
 
-    codeset = strdup(_PyUnicode_AsString(name));
+    name_str = _PyUnicode_AsString(name);
+    if (name == NULL)
+        goto error;
+    codeset = strdup(name_str);
     Py_DECREF(name);
     return codeset;
 
 error:
     Py_XDECREF(codec);
+    Py_XDECREF(name);
     return NULL;
 }
 #endif
@@ -261,13 +265,15 @@
 
     _PyImportHooks_Init();
 
+    /* Initialize _warnings. */
+    _PyWarnings_Init();
+
     initfsencoding();
 
     if (install_sigs)
         initsigs(); /* Signal handling stuff, including initintr() */
 
     /* Initialize warnings. */
-    _PyWarnings_Init();
     if (PySys_HasWarnOptions()) {
         PyObject *warnings_module = PyImport_ImportModule("warnings");
         if (!warnings_module)
@@ -1061,22 +1067,34 @@
         if (!oenc)
             return -1;
         enc = _PyUnicode_AsString(oenc);
+        if (enc == NULL)
+            return -1;
     }
     v = PySys_GetObject("ps1");
     if (v != NULL) {
         v = PyObject_Str(v);
         if (v == NULL)
             PyErr_Clear();
-        else if (PyUnicode_Check(v))
+        else if (PyUnicode_Check(v)) {
             ps1 = _PyUnicode_AsString(v);
+            if (ps1 == NULL) {
+                PyErr_Clear();
+                ps1 = "";
+            }
+        }
     }
     w = PySys_GetObject("ps2");
     if (w != NULL) {
         w = PyObject_Str(w);
         if (w == NULL)
             PyErr_Clear();
-        else if (PyUnicode_Check(w))
+        else if (PyUnicode_Check(w)) {
             ps2 = _PyUnicode_AsString(w);
+            if (ps2 == NULL) {
+                PyErr_Clear();
+                ps2 = "";
+            }
+        }
     }
     arena = PyArena_New();
     if (arena == NULL) {
@@ -1369,10 +1387,12 @@
         exitcode = (int)PyLong_AsLong(value);
     else {
         PyObject *sys_stderr = PySys_GetObject("stderr");
-        if (sys_stderr != NULL)
-            PyObject_CallMethod(sys_stderr, "flush", NULL);
-        PyObject_Print(value, stderr, Py_PRINT_RAW);
-        fflush(stderr);
+        if (sys_stderr != NULL && sys_stderr != Py_None) {
+            PyFile_WriteObject(value, sys_stderr, Py_PRINT_RAW);
+        } else {
+            PyObject_Print(value, stderr, Py_PRINT_RAW);
+            fflush(stderr);
+        }
         PySys_WriteStderr("\n");
         exitcode = 1;
     }

Modified: python/branches/py3k-jit/Python/sysmodule.c
==============================================================================
--- python/branches/py3k-jit/Python/sysmodule.c	(original)
+++ python/branches/py3k-jit/Python/sysmodule.c	Tue May 25 03:17:49 2010
@@ -570,6 +570,57 @@
     return Py_None;
 }
 
+static PyTypeObject Hash_InfoType;
+
+PyDoc_STRVAR(hash_info_doc,
+"hash_info\n\
+\n\
+A struct sequence providing parameters used for computing\n\
+numeric hashes.  The attributes are read only.");
+
+static PyStructSequence_Field hash_info_fields[] = {
+    {"width", "width of the type used for hashing, in bits"},
+    {"modulus", "prime number giving the modulus on which the hash "
+                "function is based"},
+    {"inf", "value to be used for hash of a positive infinity"},
+    {"nan", "value to be used for hash of a nan"},
+    {"imag", "multiplier used for the imaginary part of a complex number"},
+    {NULL, NULL}
+};
+
+static PyStructSequence_Desc hash_info_desc = {
+    "sys.hash_info",
+    hash_info_doc,
+    hash_info_fields,
+    5,
+};
+
+PyObject *
+get_hash_info(void)
+{
+    PyObject *hash_info;
+    int field = 0;
+    hash_info = PyStructSequence_New(&Hash_InfoType);
+    if (hash_info == NULL)
+        return NULL;
+    PyStructSequence_SET_ITEM(hash_info, field++,
+                              PyLong_FromLong(8*sizeof(long)));
+    PyStructSequence_SET_ITEM(hash_info, field++,
+                              PyLong_FromLong(_PyHASH_MODULUS));
+    PyStructSequence_SET_ITEM(hash_info, field++,
+                              PyLong_FromLong(_PyHASH_INF));
+    PyStructSequence_SET_ITEM(hash_info, field++,
+                              PyLong_FromLong(_PyHASH_NAN));
+    PyStructSequence_SET_ITEM(hash_info, field++,
+                              PyLong_FromLong(_PyHASH_IMAG));
+    if (PyErr_Occurred()) {
+        Py_CLEAR(hash_info);
+        return NULL;
+    }
+    return hash_info;
+}
+
+
 PyDoc_STRVAR(setrecursionlimit_doc,
 "setrecursionlimit(n)\n\
 \n\
@@ -1048,21 +1099,26 @@
 }
 
 void
-PySys_AddWarnOption(const wchar_t *s)
+PySys_AddWarnOptionUnicode(PyObject *unicode)
 {
-    PyObject *str;
-
     if (warnoptions == NULL || !PyList_Check(warnoptions)) {
         Py_XDECREF(warnoptions);
         warnoptions = PyList_New(0);
         if (warnoptions == NULL)
             return;
     }
-    str = PyUnicode_FromWideChar(s, -1);
-    if (str != NULL) {
-        PyList_Append(warnoptions, str);
-        Py_DECREF(str);
-    }
+    PyList_Append(warnoptions, unicode);
+}
+
+void
+PySys_AddWarnOption(const wchar_t *s)
+{
+    PyObject *unicode;
+    unicode = PyUnicode_FromWideChar(s, -1);
+    if (unicode == NULL)
+        return;
+    PySys_AddWarnOptionUnicode(unicode);
+    Py_DECREF(unicode);
 }
 
 int
@@ -1477,6 +1533,11 @@
                         PyFloat_GetInfo());
     SET_SYS_FROM_STRING("int_info",
                         PyLong_GetInfo());
+    /* initialize hash_info */
+    if (Hash_InfoType.tp_name == 0)
+        PyStructSequence_InitType(&Hash_InfoType, &hash_info_desc);
+    SET_SYS_FROM_STRING("hash_info",
+                        get_hash_info());
     SET_SYS_FROM_STRING("maxunicode",
                         PyLong_FromLong(PyUnicode_GetMax()));
     SET_SYS_FROM_STRING("builtin_module_names",
@@ -1663,7 +1724,7 @@
 #endif
 
 void
-PySys_SetArgv(int argc, wchar_t **argv)
+PySys_SetArgvEx(int argc, wchar_t **argv, int updatepath)
 {
 #if defined(HAVE_REALPATH)
     wchar_t fullpath[MAXPATHLEN];
@@ -1676,7 +1737,7 @@
         Py_FatalError("no mem for sys.argv");
     if (PySys_SetObject("argv", av) != 0)
         Py_FatalError("can't assign sys.argv");
-    if (path != NULL) {
+    if (updatepath && path != NULL) {
         wchar_t *argv0 = argv[0];
         wchar_t *p = NULL;
         Py_ssize_t n = 0;
@@ -1763,6 +1824,12 @@
     Py_DECREF(av);
 }
 
+void
+PySys_SetArgv(int argc, wchar_t **argv)
+{
+    PySys_SetArgvEx(argc, argv, 1);
+}
+
 /* Reimplementation of PyFile_WriteString() no calling indirectly
    PyErr_CheckSignals(): avoid the call to PyObject_Str(). */
 

Modified: python/branches/py3k-jit/Tools/gdb/libpython.py
==============================================================================
--- python/branches/py3k-jit/Tools/gdb/libpython.py	(original)
+++ python/branches/py3k-jit/Tools/gdb/libpython.py	Tue May 25 03:17:49 2010
@@ -42,6 +42,7 @@
 '''
 from __future__ import with_statement
 import gdb
+import locale
 
 # Look up the gdb.Type for some standard types:
 _type_char_ptr = gdb.lookup_type('char').pointer() # char*
@@ -69,6 +70,7 @@
 
 hexdigits = "0123456789abcdef"
 
+ENCODING = locale.getpreferredencoding()
 
 class NullPyObjectPtr(RuntimeError):
     pass
@@ -1128,53 +1130,68 @@
 
             # Non-ASCII characters
             else:
-                ucs = ch;
-
-                if self.char_width == 2:
-                    ch2 = 0
+                ucs = ch
+                orig_ucs = None
+                if self.char_width() == 2:
                     # Get code point from surrogate pair
-                    if i < len(proxy):
+                    if (i < len(proxy)
+                    and 0xD800 <= ord(ch) < 0xDC00 \
+                    and 0xDC00 <= ord(proxy[i]) <= 0xDFFF):
                         ch2 = proxy[i]
-                        if (ord(ch) >= 0xD800 and ord(ch) < 0xDC00
-                            and ord(ch2) >= 0xDC00 and ord(ch2) <= 0xDFFF):
-                            ucs = (((ch & 0x03FF) << 10) | (ch2 & 0x03FF)) + 0x00010000;
-                            i += 1
+                        code = (ord(ch) & 0x03FF) << 10
+                        code |= ord(ch2) & 0x03FF
+                        code += 0x00010000
+                        orig_ucs = ucs
+                        ucs = unichr(code)
+                        i += 1
+                    else:
+                        ch2 = None
+
+                printable = _unichr_is_printable(ucs)
+                if printable:
+                    try:
+                        ucs.encode(ENCODING)
+                    except UnicodeEncodeError:
+                        printable = False
+                        if orig_ucs is not None:
+                            ucs = orig_ucs
+                            i -= 1
 
                 # Map Unicode whitespace and control characters
                 # (categories Z* and C* except ASCII space)
-                if not _unichr_is_printable(ucs):
+                if not printable:
                     # Unfortuately, Python 2's unicode type doesn't seem
                     # to expose the "isprintable" method
+                    code = ord(ucs)
 
                     # Map 8-bit characters to '\\xhh'
-                    if ucs <= 0xff:
+                    if code <= 0xff:
                         out.write('\\x')
-                        out.write(hexdigits[(ord(ucs) >> 4) & 0x000F])
-                        out.write(hexdigits[ord(ucs) & 0x000F])
+                        out.write(hexdigits[(code >> 4) & 0x000F])
+                        out.write(hexdigits[code & 0x000F])
                     # Map 21-bit characters to '\U00xxxxxx'
-                    elif ucs >= 0x10000:
+                    elif code >= 0x10000:
                         out.write('\\U')
-                        out.write(hexdigits[(ord(ucs) >> 28) & 0x0000000F])
-                        out.write(hexdigits[(ord(ucs) >> 24) & 0x0000000F])
-                        out.write(hexdigits[(ord(ucs) >> 20) & 0x0000000F])
-                        out.write(hexdigits[(ord(ucs) >> 16) & 0x0000000F])
-                        out.write(hexdigits[(ord(ucs) >> 12) & 0x0000000F])
-                        out.write(hexdigits[(ord(ucs) >> 8) & 0x0000000F])
-                        out.write(hexdigits[(ord(ucs) >> 4) & 0x0000000F])
-                        out.write(hexdigits[ord(ucs) & 0x0000000F])
+                        out.write(hexdigits[(code >> 28) & 0x0000000F])
+                        out.write(hexdigits[(code >> 24) & 0x0000000F])
+                        out.write(hexdigits[(code >> 20) & 0x0000000F])
+                        out.write(hexdigits[(code >> 16) & 0x0000000F])
+                        out.write(hexdigits[(code >> 12) & 0x0000000F])
+                        out.write(hexdigits[(code >> 8) & 0x0000000F])
+                        out.write(hexdigits[(code >> 4) & 0x0000000F])
+                        out.write(hexdigits[code & 0x0000000F])
                     # Map 16-bit characters to '\uxxxx'
                     else:
                         out.write('\\u')
-                        out.write(hexdigits[(ord(ucs) >> 12) & 0x000F])
-                        out.write(hexdigits[(ord(ucs) >> 8) & 0x000F])
-                        out.write(hexdigits[(ord(ucs) >> 4) & 0x000F])
-                        out.write(hexdigits[ord(ucs) & 0x000F])
+                        out.write(hexdigits[(code >> 12) & 0x000F])
+                        out.write(hexdigits[(code >> 8) & 0x000F])
+                        out.write(hexdigits[(code >> 4) & 0x000F])
+                        out.write(hexdigits[code & 0x000F])
                 else:
                     # Copy characters as-is
                     out.write(ch)
-                    if self.char_width == 2:
-                        if ord(ucs) >= 0x10000:
-                            out.write(ch2)
+                    if self.char_width() == 2 and (ch2 is not None):
+                        out.write(ch2)
 
         out.write(quote)
 


More information about the Python-checkins mailing list