[Python-3000-checkins] r59421 - in python/branches/py3k: Doc/ACKS.txt Doc/c-api/newtypes.rst Doc/library/bdb.rst Doc/library/logging.rst Doc/library/objects.rst Doc/library/othergui.rst Doc/library/re.rst Doc/library/ssl.rst Doc/library/tarfile.rst Doc/using/windows.rst Include/abstract.h Lib/distutils/sysconfig.py Lib/test/list_tests.py Lib/test/test_xmlrpc.py Misc/ACKS Objects/abstract.c Objects/bytesobject.c Objects/listobject.c PC/pyconfig.h PCbuild9/build_tkinter.py PCbuild9/make_buildinfo.c PCbuild9/pyproject.vsprops PCbuild9/readme.txt

christian.heimes python-3000-checkins at python.org
Sat Dec 8 16:33:57 CET 2007


Author: christian.heimes
Date: Sat Dec  8 16:33:56 2007
New Revision: 59421

Modified:
   python/branches/py3k/   (props changed)
   python/branches/py3k/Doc/ACKS.txt
   python/branches/py3k/Doc/c-api/newtypes.rst
   python/branches/py3k/Doc/library/bdb.rst
   python/branches/py3k/Doc/library/logging.rst
   python/branches/py3k/Doc/library/objects.rst
   python/branches/py3k/Doc/library/othergui.rst
   python/branches/py3k/Doc/library/re.rst
   python/branches/py3k/Doc/library/ssl.rst
   python/branches/py3k/Doc/library/tarfile.rst
   python/branches/py3k/Doc/using/windows.rst
   python/branches/py3k/Include/abstract.h
   python/branches/py3k/Lib/distutils/sysconfig.py
   python/branches/py3k/Lib/test/list_tests.py
   python/branches/py3k/Lib/test/test_xmlrpc.py
   python/branches/py3k/Misc/ACKS
   python/branches/py3k/Objects/abstract.c
   python/branches/py3k/Objects/bytesobject.c
   python/branches/py3k/Objects/listobject.c
   python/branches/py3k/PC/pyconfig.h
   python/branches/py3k/PCbuild9/build_tkinter.py
   python/branches/py3k/PCbuild9/make_buildinfo.c
   python/branches/py3k/PCbuild9/pyproject.vsprops
   python/branches/py3k/PCbuild9/readme.txt
Log:
Merged revisions 59376-59406 via svnmerge from 
svn+ssh://pythondev@svn.python.org/python/trunk

........
  r59377 | georg.brandl | 2007-12-06 01:24:23 +0100 (Thu, 06 Dec 2007) | 2 lines
  
  Add another GHOP student to ACKS.
........
  r59378 | raymond.hettinger | 2007-12-06 01:56:53 +0100 (Thu, 06 Dec 2007) | 5 lines
  
  Fix Issue 1045.
  Factor-out common calling code by simplifying the length_hint API.
  Speed-up the function by caching the PyObject_String for the attribute lookup.
........
  r59380 | georg.brandl | 2007-12-06 02:52:24 +0100 (Thu, 06 Dec 2007) | 2 lines
  
  Diverse markup fixes.
........
  r59383 | georg.brandl | 2007-12-06 10:45:39 +0100 (Thu, 06 Dec 2007) | 2 lines
  
  Better re.split examples.
........
  r59386 | christian.heimes | 2007-12-06 14:15:13 +0100 (Thu, 06 Dec 2007) | 2 lines
  
  Fixed get_config_h_filename for Windows. Without the patch it can't find the pyconfig.h file inside a build tree.
  Added several small unit tests for sysconfig.
........
  r59387 | christian.heimes | 2007-12-06 14:30:11 +0100 (Thu, 06 Dec 2007) | 1 line
  
  Silence more warnings, _CRT_NONSTDC_NO_DEPRECATE is already defined in pyconfig.h but several projects don't include it.
........
  r59389 | christian.heimes | 2007-12-06 14:55:01 +0100 (Thu, 06 Dec 2007) | 1 line
  
  Disabled one test that is failing on Unix
........
  r59399 | christian.heimes | 2007-12-06 22:13:06 +0100 (Thu, 06 Dec 2007) | 8 lines
  
  Several Windows related cleanups:
  * Removed a #define from pyconfig.h. The macro was already defined a few lines higher.
  * Fixed path to tix in the build_tkinter.py script
  * Changed make_buildinfo.c to use versions of unlink and strcat which are considered safe by Windows (as suggested by MvL).
  * Removed two defines from pyproject.vsprops that are no longer required. Both are defined in pyconfig.h and make_buildinfo.c doesn't use the unsafe versions any more (as suggested by MvL).
  * Added some more information about PGO and the property files to PCbuild9/readme.txt.
  
  Are you fine with the changes, Martin?
........
  r59400 | raymond.hettinger | 2007-12-07 02:53:01 +0100 (Fri, 07 Dec 2007) | 4 lines
  
  Don't have the docs berate themselves.  Keep a professional tone.
  If a todo is needed, put it in the tracker.
........
  r59402 | georg.brandl | 2007-12-07 10:07:10 +0100 (Fri, 07 Dec 2007) | 3 lines
  
  Increase unit test coverage of SimpleXMLRPCServer.
  Written for GHOP by Turkay Eren.
........
  r59406 | georg.brandl | 2007-12-07 16:16:57 +0100 (Fri, 07 Dec 2007) | 2 lines
  
  Update to windows doc from Robert.
........


Modified: python/branches/py3k/Doc/ACKS.txt
==============================================================================
--- python/branches/py3k/Doc/ACKS.txt	(original)
+++ python/branches/py3k/Doc/ACKS.txt	Sat Dec  8 16:33:56 2007
@@ -122,6 +122,7 @@
 * Vincent Marchetti
 * Laura Matson
 * Daniel May
+* Rebecca McCreary
 * Doug Mennella
 * Paolo Milani
 * Skip Montanaro

Modified: python/branches/py3k/Doc/c-api/newtypes.rst
==============================================================================
--- python/branches/py3k/Doc/c-api/newtypes.rst	(original)
+++ python/branches/py3k/Doc/c-api/newtypes.rst	Sat Dec  8 16:33:56 2007
@@ -1541,13 +1541,13 @@
 .. cmember:: binaryfunc PySequenceMethods.sq_concat
 
    This function is used by :cfunc:`PySequence_Concat` and has the same
-   signature.  It is also used by the `+` operator, after trying the numeric
+   signature.  It is also used by the ``+`` operator, after trying the numeric
    addition via the :attr:`tp_as_number.nb_add` slot.
 
 .. cmember:: ssizeargfunc PySequenceMethods.sq_repeat
 
    This function is used by :cfunc:`PySequence_Repeat` and has the same
-   signature.  It is also used by the `*` operator, after trying numeric
+   signature.  It is also used by the ``*`` operator, after trying numeric
    multiplication via the :attr:`tp_as_number.nb_mul` slot.
 
 .. cmember:: ssizeargfunc PySequenceMethods.sq_item

Modified: python/branches/py3k/Doc/library/bdb.rst
==============================================================================
--- python/branches/py3k/Doc/library/bdb.rst	(original)
+++ python/branches/py3k/Doc/library/bdb.rst	Sat Dec  8 16:33:56 2007
@@ -239,7 +239,7 @@
 .. method:: Bdb.clear_bpbynumber(arg)
 
    Delete the breakpoint which has the index *arg* in the
-   :attr:`Breakpoint.bpbynumber`.  If `arg` is not numeric or out of range,
+   :attr:`Breakpoint.bpbynumber`.  If *arg* is not numeric or out of range,
    return an error message.
 
 .. method:: Bdb.clear_all_file_breaks(filename)

Modified: python/branches/py3k/Doc/library/logging.rst
==============================================================================
--- python/branches/py3k/Doc/library/logging.rst	(original)
+++ python/branches/py3k/Doc/library/logging.rst	Sat Dec  8 16:33:56 2007
@@ -741,7 +741,7 @@
       The proposal which described this feature for inclusion in the Python standard
       library.
 
-   `Original Python :mod:`logging` package <http://www.red-dove.com/python_logging.html>`_
+   `Original Python logging package <http://www.red-dove.com/python_logging.html>`_
       This is the original source for the :mod:`logging` package.  The version of the
       package available from this site is suitable for use with Python 1.5.2, 2.1.x
       and 2.2.x, which do not include the :mod:`logging` package in the standard

Modified: python/branches/py3k/Doc/library/objects.rst
==============================================================================
--- python/branches/py3k/Doc/library/objects.rst	(original)
+++ python/branches/py3k/Doc/library/objects.rst	Sat Dec  8 16:33:56 2007
@@ -25,8 +25,3 @@
 have no real choice.)  See :ref:`operator-summary` for the complete picture on
 operator priorities.
 
-.. rubric:: Footnotes
-
-.. [#] Most descriptions sorely lack explanations of the exceptions that may be raised
-   --- this will be fixed in a future version of this manual.
-

Modified: python/branches/py3k/Doc/library/othergui.rst
==============================================================================
--- python/branches/py3k/Doc/library/othergui.rst	(original)
+++ python/branches/py3k/Doc/library/othergui.rst	Sat Dec  8 16:33:56 2007
@@ -48,7 +48,7 @@
       online `tutorial <http://www.pygtk.org/pygtk2tutorial/index.html>`_ is
       available.
 
-   `PyQt <//http://www.riverbankcomputing.co.uk/pyqt/index.php>`_
+   `PyQt <http://www.riverbankcomputing.co.uk/pyqt/index.php>`_
       PyQt is a :program:`sip`\ -wrapped binding to the Qt toolkit.  Qt is an
       extensive C++ GUI application development framework that is
       available for Unix, Windows and Mac OS X. :program:`sip` is a tool

Modified: python/branches/py3k/Doc/library/re.rst
==============================================================================
--- python/branches/py3k/Doc/library/re.rst	(original)
+++ python/branches/py3k/Doc/library/re.rst	Sat Dec  8 16:33:56 2007
@@ -1078,16 +1078,21 @@
 easily read and modified by Python as demonstrated in the following example that
 creates a phonebook.
 
-First, get the input using triple-quoted string syntax::
+First, here is the input.  Normally it may come from a file, here we are using
+triple-quoted string syntax::
 
-   >>> input = """Ross McFluff 834.345.1254 155 Elm Street
-   Ronald Heathmore 892.345.3428 436 Finley Avenue
-   Frank Burger 925.541.7625 662 South Dogwood Way
-   Heather Albrecht 548.326.4584 919 Park Place"""
+   >>> input = """Ross McFluff: 834.345.1254 155 Elm Street
 
-Then, convert the string into a list with each line having its own entry::
+   Ronald Heathmore: 892.345.3428 436 Finley Avenue
+   Frank Burger: 925.541.7625 662 South Dogwood Way
 
-   >>> entries = re.split("\n", input)
+
+   Heather Albrecht: 548.326.4584 919 Park Place"""
+
+The entries are separated by one or more newlines. Now we convert the string
+into a list with each nonempty line having its own entry::
+
+   >>> entries = re.split("\n+", input)
    >>> entries
    ['Ross McFluff 834.345.1254 155 Elm Street',
    'Ronald Heathmore 892.345.3428 436 Finley Avenue',
@@ -1098,16 +1103,17 @@
 number, and address.  We use the ``maxsplit`` paramater of :func:`split`
 because the address has spaces, our splitting pattern, in it::
 
-   >>> [re.split(" ", entry, 3) for entry in entries]
+   >>> [re.split(":? ", entry, 3) for entry in entries]
    [['Ross', 'McFluff', '834.345.1254', '155 Elm Street'],
    ['Ronald', 'Heathmore', '892.345.3428', '436 Finley Avenue'],
    ['Frank', 'Burger', '925.541.7625', '662 South Dogwood Way'],
    ['Heather', 'Albrecht', '548.326.4584', '919 Park Place']]
 
-With a ``maxsplit`` of ``4``, we could seperate the house number from the street
-name::
+The ``:?`` pattern matches the colon after the last name, so that it does not
+occur in the result list.  With a ``maxsplit`` of ``4``, we could seperate the
+house number from the street name::
 
-   >>> [re.split(" ", entry, 4) for entry in entries]
+   >>> [re.split(":? ", entry, 4) for entry in entries]
    [['Ross', 'McFluff', '834.345.1254', '155', 'Elm Street'],
    ['Ronald', 'Heathmore', '892.345.3428', '436', 'Finley Avenue'],
    ['Frank', 'Burger', '925.541.7625', '662', 'South Dogwood Way'],

Modified: python/branches/py3k/Doc/library/ssl.rst
==============================================================================
--- python/branches/py3k/Doc/library/ssl.rst	(original)
+++ python/branches/py3k/Doc/library/ssl.rst	Sat Dec  8 16:33:56 2007
@@ -109,13 +109,14 @@
 
        ========================  =========  =========  ==========  =========
         *client* / **server**    **SSLv2**  **SSLv3**  **SSLv23**  **TLSv1**
+       ------------------------  ---------  ---------  ----------  ---------
         *SSLv2*                    yes        no         yes*        no
         *SSLv3*                    yes        yes        yes         no
         *SSLv23*                   yes        no         yes         no
         *TLSv1*                    no         no         yes         yes
        ========================  =========  =========  ==========  =========
 
-   `*` In some older versions of OpenSSL (for instance, 0.9.7l on OS X 10.4),
+   In some older versions of OpenSSL (for instance, 0.9.7l on OS X 10.4),
    an SSLv2 client could not connect to an SSLv23 server.
 
    The parameter ``do_handshake_on_connect`` specifies whether to do the SSL

Modified: python/branches/py3k/Doc/library/tarfile.rst
==============================================================================
--- python/branches/py3k/Doc/library/tarfile.rst	(original)
+++ python/branches/py3k/Doc/library/tarfile.rst	Sat Dec  8 16:33:56 2007
@@ -13,7 +13,7 @@
 
 The :mod:`tarfile` module makes it possible to read and write tar
 archives, including those using gzip or bz2 compression.
-(`.zip` files can be read and written using the :mod:`zipfile` module.)
+(:file:`.zip` files can be read and written using the :mod:`zipfile` module.)
 
 Some facts and figures:
 

Modified: python/branches/py3k/Doc/using/windows.rst
==============================================================================
--- python/branches/py3k/Doc/using/windows.rst	(original)
+++ python/branches/py3k/Doc/using/windows.rst	Sat Dec  8 16:33:56 2007
@@ -73,6 +73,8 @@
     Popular modules (such as PyWin32) with their respective documentation, tool
     suite for building extensible python applications
 
+Notice that these packages are likely to install *older* versions of Python.
+
 
 
 Configuring Python
@@ -85,10 +87,11 @@
 Excursus: Setting environment variables
 ---------------------------------------
 
-Windows has a built-in dialog for changing environment variables: Right-click
-the icon for your machine (usually located on your Desktop and called "My
-Computer") and choose :menuselection:`Properties` there.  Then, open the
-:guilabel:`Advanced` tab and click the :guilabel:`Environment Variables` button.
+Windows has a built-in dialog for changing environment variables (following
+guide applies to XP classical view): Right-click the icon for your machine 
+(usually located on your Desktop and called "My Computer") and choose 
+:menuselection:`Properties` there.  Then, open the :guilabel:`Advanced` tab 
+and click the :guilabel:`Environment Variables` button.
 
 In short, your path is:
 
@@ -107,7 +110,8 @@
     set PYTHONPATH=%PYTHONPATH%;C:\My_python_lib
 
 To make this setting permanent, you could add the corresponding command line to
-your :file:`autoexec.bat`.
+your :file:`autoexec.bat`. :program:`msconfig` is a graphical interface to this
+file.
 
 Viewing environment variables can also be done more straight-forward: The
 command prompt will expand strings wrapped into percent signs automatically::
@@ -124,6 +128,9 @@
    http://support.microsoft.com/kb/310519
       How To Manage Environment Variables in Windows XP
 
+   http://www.chem.gla.ac.uk/~louis/software/faq/q1.html
+      Setting Environment variables, Louis J. Farrugia
+
 
 Finding the Python executable
 -----------------------------

Modified: python/branches/py3k/Include/abstract.h
==============================================================================
--- python/branches/py3k/Include/abstract.h	(original)
+++ python/branches/py3k/Include/abstract.h	Sat Dec  8 16:33:56 2007
@@ -410,25 +410,12 @@
      PyAPI_FUNC(Py_ssize_t) PyObject_Length(PyObject *o);
 #define PyObject_Length PyObject_Size
 
-     PyAPI_FUNC(Py_ssize_t) _PyObject_LengthHint(PyObject *o);
+     PyAPI_FUNC(Py_ssize_t) _PyObject_LengthHint(PyObject *o, Py_ssize_t);
 
        /*
-         Return the size of object o.  If the object, o, provides
-	 both sequence and mapping protocols, the sequence size is
-	 returned. On error, -1 is returned.  If the object provides
-	 a __length_hint__() method, its value is returned.  This is an
-	 internal undocumented API provided for performance reasons;
-	 for compatibility, don't use it outside the core.  This is the
-	 equivalent to the Python expression: 
-		try:
-			return len(o)
-		except (AttributeError, TypeError):
-			exc_type, exc_value, exc_tb = sys.exc_info()
-			try:
-				return o.__length_hint__()
-			except:
-				pass
-			raise exc_type, exc_value, exc_tb
+         Guess the size of object o using len(o) or o.__length_hint__().
+         If neither of those return a non-negative value, then return the
+         default value.  This function never fails. All exceptions are cleared.
        */
 
      PyAPI_FUNC(PyObject *) PyObject_GetItem(PyObject *o, PyObject *key);

Modified: python/branches/py3k/Lib/distutils/sysconfig.py
==============================================================================
--- python/branches/py3k/Lib/distutils/sysconfig.py	(original)
+++ python/branches/py3k/Lib/distutils/sysconfig.py	Sat Dec  8 16:33:56 2007
@@ -22,13 +22,17 @@
 PREFIX = os.path.normpath(sys.prefix)
 EXEC_PREFIX = os.path.normpath(sys.exec_prefix)
 
+# Path to the base directory of the project. On Windows the binary may
+# live in project/PCBuild9
+project_base = os.path.dirname(os.path.abspath(sys.executable))
+if os.name == "nt" and "pcbuild" in project_base[-8:].lower():
+    project_base = os.path.abspath(os.path.join(project_base, os.path.pardir))
+
 # python_build: (Boolean) if true, we're either building Python or
 # building an extension with an un-installed Python, so we use
 # different (hard-wired) directories.
-
-argv0_path = os.path.dirname(os.path.abspath(sys.executable))
-python_build = os.path.isfile(os.path.join(argv0_path, "Modules", "Setup"))
-
+python_build = os.path.isfile(os.path.join(project_base, "Modules",
+                                           "Setup.dist"))
 
 def get_python_version():
     """Return a string containing the major and minor Python version,
@@ -177,7 +181,10 @@
 def get_config_h_filename():
     """Return full pathname of installed pyconfig.h file."""
     if python_build:
-        inc_dir = argv0_path
+        if os.name == "nt":
+            inc_dir = os.path.join(project_base, "PC")
+        else:
+            inc_dir = project_base
     else:
         inc_dir = get_python_inc(plat_specific=1)
     if get_python_version() < '2.2':
@@ -402,6 +409,8 @@
 
     g['SO'] = '.pyd'
     g['EXE'] = ".exe"
+    g['VERSION'] = get_python_version().replace(".", "")
+    g['BINDIR'] = os.path.dirname(os.path.abspath(sys.executable))
 
     global _config_vars
     _config_vars = g

Modified: python/branches/py3k/Lib/test/list_tests.py
==============================================================================
--- python/branches/py3k/Lib/test/list_tests.py	(original)
+++ python/branches/py3k/Lib/test/list_tests.py	Sat Dec  8 16:33:56 2007
@@ -521,7 +521,5 @@
         # Bug #1242657
         class F(object):
             def __iter__(self):
-                yield 23
-            def __len__(self):
                 raise KeyboardInterrupt
         self.assertRaises(KeyboardInterrupt, list, F())

Modified: python/branches/py3k/Lib/test/test_xmlrpc.py
==============================================================================
--- python/branches/py3k/Lib/test/test_xmlrpc.py	(original)
+++ python/branches/py3k/Lib/test/test_xmlrpc.py	Sat Dec  8 16:33:56 2007
@@ -7,6 +7,9 @@
 import SimpleXMLRPCServer
 import threading
 import mimetools
+import httplib
+import socket
+import os
 from test import test_support
 
 alist = [{'astring': 'foo at bar.baz.spam',
@@ -254,9 +257,16 @@
 def http_server(evt, numrequests):
     class TestInstanceClass:
         def div(self, x, y):
-            '''This is the div function'''
             return x // y
 
+        def _methodHelp(self, name):
+            if name == 'div':
+                return 'This is the div function'
+
+    def my_function():
+        '''This is my function'''
+        return True
+
     try:
         serv = SimpleXMLRPCServer.SimpleXMLRPCServer(("localhost", 0),
                         logRequests=False, bind_and_activate=False)
@@ -268,6 +278,7 @@
         serv.register_multicall_functions()
         serv.register_function(pow)
         serv.register_function(lambda x,y: x+y, 'add')
+        serv.register_function(my_function)
         serv.register_instance(TestInstanceClass())
 
         # handle up to 'numrequests' requests
@@ -284,7 +295,6 @@
 
 
 
-
 class SimpleServerTestCase(unittest.TestCase):
     def setUp(self):
         # enable traceback reporting
@@ -318,12 +328,25 @@
             # protocol error; provide additional information in test output
             self.fail("%s\n%s" % (e, e.headers))
 
+    def test_404(self):
+        # send POST with httplib, it should return 404 header and
+        # 'Not Found' message.
+        import pdb; pdb.set_trace()
+        conn = httplib.HTTPConnection('localhost', PORT)
+        conn.request(b'POST', b'/this-is-not-valid')
+        response = conn.getresponse()
+        conn.close()
+
+        self.assertEqual(response.status, 404)
+        self.assertEqual(response.reason, 'Not Found')
+
     def test_introspection1(self):
         try:
             p = xmlrpclib.ServerProxy('http://localhost:%d' % PORT)
             meth = p.system.listMethods()
-            expected_methods = set(['pow', 'div', 'add', 'system.listMethods',
-                'system.methodHelp', 'system.methodSignature', 'system.multicall'])
+            expected_methods = set(['pow', 'div', 'my_function', 'add',
+                                    'system.listMethods', 'system.methodHelp',
+                                    'system.methodSignature', 'system.multicall'])
             self.assertEqual(set(meth), expected_methods)
         except xmlrpclib.ProtocolError as e:
             # protocol error; provide additional information in test output
@@ -331,6 +354,7 @@
 
     def test_introspection2(self):
         try:
+            # test _methodHelp()
             p = xmlrpclib.ServerProxy('http://localhost:%d' % PORT)
             divhelp = p.system.methodHelp('div')
             self.assertEqual(divhelp, 'This is the div function')
@@ -339,6 +363,18 @@
             self.fail("%s\n%s" % (e, e.headers))
 
     def test_introspection3(self):
+        try:
+            # test native doc
+            p = xmlrpclib.ServerProxy('http://localhost:%d' % PORT)
+            myfunction = p.system.methodHelp('my_function')
+            self.assertEqual(myfunction, 'This is my function')
+        except xmlrpclib.ProtocolError as e:
+            # ignore failures due to non-blocking socket 'unavailable' errors
+            if not is_unavailable_exception(e):
+                # protocol error; provide additional information in test output
+                self.fail("%s\n%s" % (e, e.headers))
+
+    def test_introspection4(self):
         # the SimpleXMLRPCServer doesn't support signatures, but
         # at least check that we can try making the call
         try:
@@ -364,6 +400,34 @@
             # protocol error; provide additional information in test output
             self.fail("%s\n%s" % (e, e.headers))
 
+    def test_non_existing_multicall(self):
+        try:
+            p = xmlrpclib.ServerProxy('http://localhost:%d' % PORT)
+            multicall = xmlrpclib.MultiCall(p)
+            multicall.this_is_not_exists()
+            result = multicall()
+
+            # result.results contains;
+            # [{'faultCode': 1, 'faultString': '<type \'exceptions.Exception\'>:'
+            #   'method "this_is_not_exists" is not supported'>}]
+
+            self.assertEqual(result.results[0]['faultCode'], 1)
+            self.assertEqual(result.results[0]['faultString'],
+                '<type \'exceptions.Exception\'>:method "this_is_not_exists" '
+                'is not supported')
+        except xmlrpclib.ProtocolError as e:
+            # ignore failures due to non-blocking socket 'unavailable' errors
+            if not is_unavailable_exception(e):
+                # protocol error; provide additional information in test output
+                self.fail("%s\n%s" % (e, e.headers))
+
+    def test_dotted_attribute(self):
+        # this will raise AttirebuteError because code don't want us to use
+        # private methods
+        self.assertRaises(AttributeError,
+                          SimpleXMLRPCServer.resolve_dotted_attribute, str, '__add')
+
+        self.assert_(SimpleXMLRPCServer.resolve_dotted_attribute(str, 'title'))
 
 # This is a contrived way to make a failure occur on the server side
 # in order to test the _send_traceback_header flag on the server
@@ -447,6 +511,70 @@
         else:
             self.fail('ProtocolError not raised')
 
+class CGIHandlerTestCase(unittest.TestCase):
+    def setUp(self):
+        self.cgi = SimpleXMLRPCServer.CGIXMLRPCRequestHandler()
+
+    def tearDown(self):
+        self.cgi = None
+
+    def test_cgi_get(self):
+        os.environ['REQUEST_METHOD'] = 'GET'
+        # if the method is GET and no request_text is given, it runs handle_get
+        # get sysout output
+        tmp = sys.stdout
+        sys.stdout = open(test_support.TESTFN, "w")
+        self.cgi.handle_request()
+        sys.stdout.close()
+        sys.stdout = tmp
+
+        # parse Status header
+        handle = open(test_support.TESTFN, "r").read()
+        status = handle.split()[1]
+        message = ' '.join(handle.split()[2:4])
+
+        self.assertEqual(status, '400')
+        self.assertEqual(message, 'Bad Request')
+
+        os.remove(test_support.TESTFN)
+        os.environ['REQUEST_METHOD'] = ''
+
+    def test_cgi_xmlrpc_response(self):
+        data = """<?xml version='1.0'?>
+<methodCall>
+    <methodName>test_method</methodName>
+    <params>
+        <param>
+            <value><string>foo</string></value>
+        </param>
+        <param>
+            <value><string>bar</string></value>
+        </param>
+     </params>
+</methodCall>
+"""
+        open("xmldata.txt", "w").write(data)
+        tmp1 = sys.stdin
+        tmp2 = sys.stdout
+
+        sys.stdin = open("xmldata.txt", "r")
+        sys.stdout = open(test_support.TESTFN, "w")
+
+        self.cgi.handle_request()
+
+        sys.stdin.close()
+        sys.stdout.close()
+        sys.stdin = tmp1
+        sys.stdout = tmp2
+
+        # will respond exception, if so, our goal is achieved ;)
+        handle = open(test_support.TESTFN, "r").read()
+
+        # start with 44th char so as not to get http header, we just need only xml
+        self.assertRaises(xmlrpclib.Fault, xmlrpclib.loads, handle[44:])
+
+        os.remove("xmldata.txt")
+        os.remove(test_support.TESTFN)
 
 def test_main():
     xmlrpc_tests = [XMLRPCTestCase, HelperTestCase, DateTimeTestCase,
@@ -459,6 +587,7 @@
     if sys.platform != 'win32':
         xmlrpc_tests.append(SimpleServerTestCase)
         xmlrpc_tests.append(FailingServerTestCase)
+        xmlrpc_tests.append(CGIHandlerTestCase)
 
     test_support.run_unittest(*xmlrpc_tests)
 

Modified: python/branches/py3k/Misc/ACKS
==============================================================================
--- python/branches/py3k/Misc/ACKS	(original)
+++ python/branches/py3k/Misc/ACKS	Sat Dec  8 16:33:56 2007
@@ -190,6 +190,7 @@
 Jeff Epler
 Tom Epperly
 Stoffel Erasmus
+Turkay Eren
 Jürgen A. Erhard
 Michael Ernst
 Ben Escoto

Modified: python/branches/py3k/Objects/abstract.c
==============================================================================
--- python/branches/py3k/Objects/abstract.c	(original)
+++ python/branches/py3k/Objects/abstract.c	Sat Dec  8 16:33:56 2007
@@ -80,29 +80,47 @@
 }
 #define PyObject_Length PyObject_Size
 
+
+/* The length hint function returns a non-negative value from o.__len__()
+   or o.__length_hint__().  If those methods aren't found or return a negative
+   value, then the defaultvalue is returned.  This function never fails. 
+   Accordingly, it will mask exceptions raised in either method.
+*/
+
 Py_ssize_t
-_PyObject_LengthHint(PyObject *o)
+_PyObject_LengthHint(PyObject *o, Py_ssize_t defaultvalue)
 {
-	Py_ssize_t rv = PyObject_Size(o);
-	if (rv != -1)
+	static PyObject *hintstrobj = NULL;
+	PyObject *ro;
+	Py_ssize_t rv;
+
+	/* try o.__len__() */
+	rv = PyObject_Size(o);
+	if (rv >= 0)
 		return rv;
-	if (PyErr_ExceptionMatches(PyExc_TypeError) ||
-	    PyErr_ExceptionMatches(PyExc_AttributeError)) {
-		PyObject *err_type, *err_value, *err_tb, *ro;
-
-		PyErr_Fetch(&err_type, &err_value, &err_tb);
-		ro = PyObject_CallMethod(o, "__length_hint__", NULL);
-		if (ro != NULL) {
-			rv = PyLong_AsLong(ro);
-			Py_DECREF(ro);
-			Py_XDECREF(err_type);
-			Py_XDECREF(err_value);
-			Py_XDECREF(err_tb);
-			return rv;
-		}
-		PyErr_Restore(err_type, err_value, err_tb);
+	if (PyErr_Occurred())
+		PyErr_Clear();
+
+	/* cache a hashed version of the attribute string */
+	if (hintstrobj == NULL) {
+		hintstrobj = PyUnicode_InternFromString("__length_hint__");
+		if (hintstrobj == NULL)
+			goto defaultcase;
 	}
-	return -1;
+
+	/* try o.__length_hint__() */
+	ro = PyObject_CallMethodObjArgs(o, hintstrobj, NULL);
+	if (ro == NULL)
+		goto defaultcase;
+	rv = PyLong_AsSsize_t(ro);
+	Py_DECREF(ro);
+	if (rv >= 0)
+		return rv;
+
+defaultcase:
+	if (PyErr_Occurred())
+		PyErr_Clear();
+	return defaultvalue;
 }
 
 PyObject *
@@ -1655,17 +1673,7 @@
 		return NULL;
 
 	/* Guess result size and allocate space. */
-	n = _PyObject_LengthHint(v);
-	if (n < 0) {
-		if (PyErr_Occurred()
-		    && !PyErr_ExceptionMatches(PyExc_TypeError)
-		    && !PyErr_ExceptionMatches(PyExc_AttributeError)) {
-			Py_DECREF(it);
-			return NULL;
-		}
-		PyErr_Clear();
-		n = 10;	 /* arbitrary */
-	}
+	n = _PyObject_LengthHint(v, 10);
 	result = PyTuple_New(n);
 	if (result == NULL)
 		goto Fail;

Modified: python/branches/py3k/Objects/bytesobject.c
==============================================================================
--- python/branches/py3k/Objects/bytesobject.c	(original)
+++ python/branches/py3k/Objects/bytesobject.c	Sat Dec  8 16:33:56 2007
@@ -2598,19 +2598,8 @@
     if (it == NULL)
         return NULL;
 
-    /* Try to determine the length of the argument. */
-    buf_size = _PyObject_LengthHint(arg);
-    /* The length of the argument is unknown or invalid. */
-    if (buf_size < 0) {
-        if (PyErr_Occurred()
-            && !PyErr_ExceptionMatches(PyExc_TypeError)
-            && !PyErr_ExceptionMatches(PyExc_AttributeError)) {
-            Py_DECREF(it);
-            return NULL;
-        }
-        PyErr_Clear();
-        buf_size = 32;          /* arbitrary */
-    }
+    /* Try to determine the length of the argument. 32 is abitrary. */
+    buf_size = _PyObject_LengthHint(arg, 32);
 
     buf = (char *)PyMem_Malloc(buf_size * sizeof(char));
     if (buf == NULL)

Modified: python/branches/py3k/Objects/listobject.c
==============================================================================
--- python/branches/py3k/Objects/listobject.c	(original)
+++ python/branches/py3k/Objects/listobject.c	Sat Dec  8 16:33:56 2007
@@ -758,17 +758,7 @@
 	iternext = *it->ob_type->tp_iternext;
 
 	/* Guess a result list size. */
-	n = _PyObject_LengthHint(b);
-	if (n < 0) {
-		if (PyErr_Occurred()
-		    && !PyErr_ExceptionMatches(PyExc_TypeError)
-		    && !PyErr_ExceptionMatches(PyExc_AttributeError)) {
-			Py_DECREF(it);
-			return NULL;
-		}
-		PyErr_Clear();
-		n = 8;	/* arbitrary */
-	}
+	n = _PyObject_LengthHint(b, 8);
 	m = Py_Size(self);
 	mn = m + n;
 	if (mn >= m) {

Modified: python/branches/py3k/PC/pyconfig.h
==============================================================================
--- python/branches/py3k/PC/pyconfig.h	(original)
+++ python/branches/py3k/PC/pyconfig.h	Sat Dec  8 16:33:56 2007
@@ -209,12 +209,6 @@
 #define Py_IS_INFINITY(X) (!_finite(X) && !_isnan(X))
 #define Py_IS_FINITE(X) _finite(X)
 
-/* Turn off warnings about deprecated C runtime functions in 
-   VisualStudio .NET 2005 */
-#if _MSC_VER >= 1400 && !defined _CRT_SECURE_NO_DEPRECATE
-#define _CRT_SECURE_NO_DEPRECATE
-#endif
-
 #endif /* _MSC_VER */
 
 /* define some ANSI types that are not defined in earlier Win headers */

Modified: python/branches/py3k/PCbuild9/build_tkinter.py
==============================================================================
--- python/branches/py3k/PCbuild9/build_tkinter.py	(original)
+++ python/branches/py3k/PCbuild9/build_tkinter.py	Sat Dec  8 16:33:56 2007
@@ -14,7 +14,7 @@
 
 TCL = "tcl8.4.16"
 TK = "tk8.4.16"
-TIX = "Tix8.4.0"
+TIX = "tix-8.4.0"
 #TIX = "Tix8.4.2"
 ROOT = os.path.abspath(os.path.join(here, par, par))
 NMAKE = "nmake /nologo "
@@ -53,6 +53,7 @@
 
     # TIX
     if True:
+        # python9.mak is available at http://svn.python.org
         os.chdir(os.path.join(ROOT, TIX, "win"))
         if clean:
             system(NMAKE + "/f python9.mak clean")

Modified: python/branches/py3k/PCbuild9/make_buildinfo.c
==============================================================================
--- python/branches/py3k/PCbuild9/make_buildinfo.c	(original)
+++ python/branches/py3k/PCbuild9/make_buildinfo.c	Sat Dec  8 16:33:56 2007
@@ -3,6 +3,8 @@
 #include <sys/stat.h>
 #include <stdio.h>
 
+#define CMD_SIZE 500
+
 /* This file creates the getbuildinfo.o object, by first
    invoking subwcrev.exe (if found), and then invoking cl.exe.
    As a side effect, it might generate PCBuild\getbuildinfo2.c
@@ -23,7 +25,7 @@
 {
 	struct _stat st;
 	HKEY hTortoise;
-	char command[500];
+	char command[CMD_SIZE+1];
 	DWORD type, size;
 	if (_stat(".svn", &st) < 0)
 		return 0;
@@ -40,11 +42,11 @@
 	    type != REG_SZ)
 		/* Registry corrupted */
 		return 0;
-	strcat(command, "bin\\subwcrev.exe");
+	strcat_s(command, CMD_SIZE, "bin\\subwcrev.exe");
 	if (_stat(command+1, &st) < 0)
 		/* subwcrev.exe not part of the release */
 		return 0;
-	strcat(command, "\" .. ..\\Modules\\getbuildinfo.c getbuildinfo2.c");
+	strcat_s(command, CMD_SIZE, "\" .. ..\\Modules\\getbuildinfo.c getbuildinfo2.c");
 	puts(command); fflush(stdout);
 	if (system(command) < 0)
 		return 0;
@@ -60,17 +62,17 @@
 		return EXIT_FAILURE;
 	}
 	if (strcmp(argv[1], "Release") == 0) {
-		strcat(command, "-MD ");
+		strcat_s(command, CMD_SIZE, "-MD ");
 	}
 	else if (strcmp(argv[1], "Debug") == 0) {
-		strcat(command, "-D_DEBUG -MDd ");
+		strcat_s(command, CMD_SIZE, "-D_DEBUG -MDd ");
 	}
 	else if (strcmp(argv[1], "ReleaseItanium") == 0) {
-		strcat(command, "-MD /USECL:MS_ITANIUM ");
+		strcat_s(command, CMD_SIZE, "-MD /USECL:MS_ITANIUM ");
 	}
 	else if (strcmp(argv[1], "ReleaseAMD64") == 0) {
-		strcat(command, "-MD ");
-		strcat(command, "-MD /USECL:MS_OPTERON ");
+		strcat_s(command, CMD_SIZE, "-MD ");
+		strcat_s(command, CMD_SIZE, "-MD /USECL:MS_OPTERON ");
 	}
 	else {
 		fprintf(stderr, "unsupported configuration %s\n", argv[1]);
@@ -78,14 +80,14 @@
 	}
 
 	if ((do_unlink = make_buildinfo2()))
-		strcat(command, "getbuildinfo2.c -DSUBWCREV ");
+		strcat_s(command, CMD_SIZE, "getbuildinfo2.c -DSUBWCREV ");
 	else
-		strcat(command, "..\\Modules\\getbuildinfo.c");
-	strcat(command, " -Fogetbuildinfo.o -I..\\Include -I..\\PC");
+		strcat_s(command, CMD_SIZE, "..\\Modules\\getbuildinfo.c");
+	strcat_s(command, CMD_SIZE, " -Fogetbuildinfo.o -I..\\Include -I..\\PC");
 	puts(command); fflush(stdout);
 	result = system(command);
 	if (do_unlink)
-		unlink("getbuildinfo2.c");
+		_unlink("getbuildinfo2.c");
 	if (result < 0)
 		return EXIT_FAILURE;
 	return 0;

Modified: python/branches/py3k/PCbuild9/pyproject.vsprops
==============================================================================
--- python/branches/py3k/PCbuild9/pyproject.vsprops	(original)
+++ python/branches/py3k/PCbuild9/pyproject.vsprops	Sat Dec  8 16:33:56 2007
@@ -12,7 +12,7 @@
 		InlineFunctionExpansion="1"
 		EnableIntrinsicFunctions="true"
 		AdditionalIncludeDirectories="..\Include; ..\PC"
-		PreprocessorDefinitions="_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;_WIN32"
+		PreprocessorDefinitions="_WIN32"
 		StringPooling="true"
 		ExceptionHandling="0"
 		RuntimeLibrary="0"

Modified: python/branches/py3k/PCbuild9/readme.txt
==============================================================================
--- python/branches/py3k/PCbuild9/readme.txt	(original)
+++ python/branches/py3k/PCbuild9/readme.txt	Sat Dec  8 16:33:56 2007
@@ -281,6 +281,14 @@
 Profile Guided Optimization
 ---------------------------
 
+The solution has two configurations for PGO. The PGInstrument configuration
+must be build first. The PGInstrument binaries are lniked against a profiling
+library and contain extra debug information. The PGUpdate configuration takes the profiling data and generates optimized binaries.
+
+The build_pgo.bat script automates the creation of optimized binaries. It
+creates the PGI files, runs the unit test suite or PyBench with the PGI
+python and finally creates the optimized files.
+
 http://msdn2.microsoft.com/en-us/library/e7k32f4k(VS.90).aspx
 
 Static library
@@ -300,7 +308,7 @@
 (*.vsprops). The properties can be viewed and altered in the Property
 Manager (View -> Other Windows -> Property Manager).
 
- * debug (debug macros)
+ * debug (debug macro: _DEBUG)
  * pginstrument (PGO)
  * pgupdate (PGO)
     +-- pginstrument
@@ -310,8 +318,8 @@
  * pyd_d (python extension, debug build)
     +-- debug
     +-- pyproject
- * pyproject (base settings for all projects)
- * release (release macros)
+ * pyproject (base settings for all projects, user macros like PyDllName)
+ * release (release macro: NDEBUG)
  * x64 (AMD64 / x64 platform specific settings)
 
 The pyproject propertyfile defines _WIN32 and x64 defines _WIN64 and _M_X64
@@ -320,6 +328,7 @@
 
 YOUR OWN EXTENSION DLLs
 -----------------------
+
 If you want to create your own extension module DLL, there's an example
 with easy-to-follow instructions in ../PC/example/; read the file
 readme.txt there first.


More information about the Python-3000-checkins mailing list