[Python-3000-checkins] r56847 - in python/branches/p3yk: Doc/howto/urllib2.rst Doc/lib/libstringio.tex Doc/tut/tut.tex Lib/sgmllib.py Lib/test/test_StringIO.py Modules/cStringIO.c Python/ast.c

guido.van.rossum python-3000-checkins at python.org
Thu Aug 9 16:03:35 CEST 2007


Author: guido.van.rossum
Date: Thu Aug  9 16:03:34 2007
New Revision: 56847

Modified:
   python/branches/p3yk/   (props changed)
   python/branches/p3yk/Doc/howto/urllib2.rst
   python/branches/p3yk/Doc/lib/libstringio.tex
   python/branches/p3yk/Doc/tut/tut.tex
   python/branches/p3yk/Lib/sgmllib.py
   python/branches/p3yk/Lib/test/test_StringIO.py
   python/branches/p3yk/Modules/cStringIO.c
   python/branches/p3yk/Python/ast.c
Log:
Merged revisions 56760-56846 via svnmerge from 
svn+ssh://pythondev@svn.python.org/python/trunk

........
  r56762 | georg.brandl | 2007-08-06 00:37:58 -0700 (Mon, 06 Aug 2007) | 2 lines
  
  Place #ifdef Py_USING_UNICODE around decode_unicode().
........
  r56763 | georg.brandl | 2007-08-06 00:39:09 -0700 (Mon, 06 Aug 2007) | 2 lines
  
  Replace unnecessary function call.
........
  r56764 | georg.brandl | 2007-08-06 00:52:20 -0700 (Mon, 06 Aug 2007) | 2 lines
  
  Patch #1765839: add link to https+proxy urllib2 opener.
........
  r56797 | georg.brandl | 2007-08-07 00:13:24 -0700 (Tue, 07 Aug 2007) | 2 lines
  
  Bug #1769002: fix a now-wrong sentence in the tutorial.
........
  r56830 | georg.brandl | 2007-08-08 06:03:41 -0700 (Wed, 08 Aug 2007) | 3 lines
  
  Revert the fix for #1548891, it broke backwards compatibility with arbitrary read buffers.
  Fixes #1730114.
........
  r56833 | georg.brandl | 2007-08-08 06:50:02 -0700 (Wed, 08 Aug 2007) | 2 lines
  
  Fix compilation warning.
........


Modified: python/branches/p3yk/Doc/howto/urllib2.rst
==============================================================================
--- python/branches/p3yk/Doc/howto/urllib2.rst	(original)
+++ python/branches/p3yk/Doc/howto/urllib2.rst	Thu Aug  9 16:03:34 2007
@@ -541,7 +541,9 @@
 .. note::
 
     Currently ``urllib2`` *does not* support fetching of ``https``
-    locations through a proxy. This can be a problem.
+    locations through a proxy.  However, this can be enabled by extending
+    urllib2 as shown in the recipe [#]_.
+
 
 Sockets and Layers
 ==================
@@ -596,3 +598,6 @@
        is set to use the proxy, which urllib2 picks up on. In order to test
        scripts with a localhost server, I have to prevent urllib2 from using
        the proxy.
+.. [#] urllib2 opener for SSL proxy (CONNECT method): `ASPN Cookbook Recipe 
+       <http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/456195>`_.
+ 

Modified: python/branches/p3yk/Doc/lib/libstringio.tex
==============================================================================
--- python/branches/p3yk/Doc/lib/libstringio.tex	(original)
+++ python/branches/p3yk/Doc/lib/libstringio.tex	Thu Aug  9 16:03:34 2007
@@ -78,6 +78,10 @@
 module, those provided by this module are not able to accept Unicode
 strings that cannot be encoded as plain \ASCII{} strings.
 
+Calling \function{StringIO()} with a Unicode string parameter populates
+the object with the buffer representation of the Unicode string, instead of
+encoding the string.
+
 Another difference from the \refmodule{StringIO} module is that calling
 \function{StringIO()} with a string parameter creates a read-only object.
 Unlike an object created without a string parameter, it does not have

Modified: python/branches/p3yk/Doc/tut/tut.tex
==============================================================================
--- python/branches/p3yk/Doc/tut/tut.tex	(original)
+++ python/branches/p3yk/Doc/tut/tut.tex	Thu Aug  9 16:03:34 2007
@@ -2942,15 +2942,14 @@
 statement looks for a top-level module with the given name.
 
 When packages are structured into subpackages (as with the
-\module{sound} package in the example), there's no shortcut to refer
-to submodules of sibling packages - the full name of the subpackage
-must be used.  For example, if the module
-\module{sound.filters.vocoder} needs to use the \module{echo} module
-in the \module{sound.effects} package, it can use \code{from
-sound.effects import echo}.
+\module{sound} package in the example), you can use absolute
+imports to refer to submodules of siblings packages.
+For example, if the module \module{sound.filters.vocoder} needs to
+use the \module{echo} module in the \module{sound.effects} package,
+it can use \code{from sound.effects import echo}.
 
 Starting with Python 2.5, in addition to the implicit relative imports
-described above, you can write explicit relative imports with the
+described above, you can also write explicit relative imports with the
 \code{from module import name} form of import statement. These explicit
 relative imports use leading dots to indicate the current and parent
 packages involved in the relative import. From the \module{surround}

Modified: python/branches/p3yk/Lib/sgmllib.py
==============================================================================
--- python/branches/p3yk/Lib/sgmllib.py	(original)
+++ python/branches/p3yk/Lib/sgmllib.py	Thu Aug  9 16:03:34 2007
@@ -428,7 +428,7 @@
         if replacement is None:
             self.unknown_entityref(name)
         else:
-            self.handle_data(self.convert_entityref(name))
+            self.handle_data(replacement)
 
     # Example -- handle data, should be overridden
     def handle_data(self, data):

Modified: python/branches/p3yk/Lib/test/test_StringIO.py
==============================================================================
--- python/branches/p3yk/Lib/test/test_StringIO.py	(original)
+++ python/branches/p3yk/Lib/test/test_StringIO.py	Thu Aug  9 16:03:34 2007
@@ -121,28 +121,6 @@
 class TestcStringIO(TestGenericStringIO):
     MODULE = cStringIO
 
-    def test_unicode(self):
-
-        if not test_support.have_unicode: return
-
-        # The cStringIO module converts Unicode strings to character
-        # strings when writing them to cStringIO objects.
-        # Check that this works.
-
-        f = self.MODULE.StringIO()
-        f.write(unicode(self._line[:5]))
-        s = f.getvalue()
-        self.assertEqual(s, 'abcde')
-        self.assertEqual(type(s), types.StringType)
-
-        f = self.MODULE.StringIO(unicode(self._line[:5]))
-        s = f.getvalue()
-        self.assertEqual(s, 'abcde')
-        self.assertEqual(type(s), types.StringType)
-
-        self.assertRaises(UnicodeEncodeError, self.MODULE.StringIO,
-                          unicode('\xf4', 'latin-1'))
-
 import sys
 if sys.platform.startswith('java'):
     # Jython doesn't have a buffer object, so we just do a useless

Modified: python/branches/p3yk/Modules/cStringIO.c
==============================================================================
--- python/branches/p3yk/Modules/cStringIO.c	(original)
+++ python/branches/p3yk/Modules/cStringIO.c	Thu Aug  9 16:03:34 2007
@@ -664,8 +664,11 @@
   char *buf;
   Py_ssize_t size;
 
-  if (PyObject_AsCharBuffer(s, (const char **)&buf, &size) != 0)
-      return NULL;
+  if (PyObject_AsReadBuffer(s, (const void **)&buf, &size)) {
+    PyErr_Format(PyExc_TypeError, "expected read buffer, %.200s found",
+                 s->ob_type->tp_name);
+    return NULL;
+  }
 
   self = PyObject_New(Iobject, &Itype);
   if (!self) return NULL;

Modified: python/branches/p3yk/Python/ast.c
==============================================================================
--- python/branches/p3yk/Python/ast.c	(original)
+++ python/branches/p3yk/Python/ast.c	Thu Aug  9 16:03:34 2007
@@ -3143,6 +3143,7 @@
 #endif
 }
 
+#ifdef Py_USING_UNICODE
 static PyObject *
 decode_unicode(const char *s, size_t len, int rawmode, const char *encoding)
 {
@@ -3204,6 +3205,7 @@
     Py_XDECREF(u);
     return v;
 }
+#endif
 
 /* s is a Python string literal, including the bracketing quote characters,
  * and r &/or u prefixes (if any), and embedded escape sequences (if any).


More information about the Python-3000-checkins mailing list