]> granicus.if.org Git - python/commitdiff
Merged revisions 68292,68344,68361,68378,68424,68426,68429-68430,68450,68457,68480...
authorGeorg Brandl <georg@python.org>
Wed, 14 Jan 2009 00:00:17 +0000 (00:00 +0000)
committerGeorg Brandl <georg@python.org>
Wed, 14 Jan 2009 00:00:17 +0000 (00:00 +0000)
svn+ssh://pythondev@svn.python.org/python/trunk

........
  r68292 | skip.montanaro | 2009-01-04 11:36:58 +0100 (So, 04 Jan 2009) | 3 lines

  If user configures --without-gcc give preference to $CC instead of blindly
  assuming the compiler will be "cc".
........
  r68344 | marc-andre.lemburg | 2009-01-05 20:43:35 +0100 (Mo, 05 Jan 2009) | 7 lines

  Fix #4846 (Py_UNICODE_ISSPACE causes linker error) by moving the declaration
  into the extern "C" section.

  Add a few more comments and apply some minor edits to make the file contents
  fit the original structure again.
........
  r68361 | antoine.pitrou | 2009-01-06 19:34:08 +0100 (Di, 06 Jan 2009) | 3 lines

  Use shutil.rmtree rather than os.rmdir.
........
  r68378 | mark.dickinson | 2009-01-07 18:48:33 +0100 (Mi, 07 Jan 2009) | 2 lines

  Issue #4869: clarify documentation for random.expovariate.
........
  r68424 | benjamin.peterson | 2009-01-09 03:53:35 +0100 (Fr, 09 Jan 2009) | 1 line

  specify what -3 warnings are about
........
  r68426 | benjamin.peterson | 2009-01-09 04:03:05 +0100 (Fr, 09 Jan 2009) | 1 line

  fix spelling
........
  r68429 | benjamin.peterson | 2009-01-09 04:05:14 +0100 (Fr, 09 Jan 2009) | 1 line

  add -3 to manpage
........
  r68430 | benjamin.peterson | 2009-01-09 04:07:27 +0100 (Fr, 09 Jan 2009) | 1 line

  be more specific in -3 option help
........
  r68450 | jeffrey.yasskin | 2009-01-09 17:47:07 +0100 (Fr, 09 Jan 2009) | 3 lines

  Fix issue 4884, preventing a crash in the socket code when python is compiled
  with llvm-gcc and run with a glibc <2.10.
........
  r68457 | kristjan.jonsson | 2009-01-09 21:10:59 +0100 (Fr, 09 Jan 2009) | 1 line

  Issue 3677:  Fix import from UNC paths on Windows.
........
  r68480 | vinay.sajip | 2009-01-10 14:38:04 +0100 (Sa, 10 Jan 2009) | 1 line

  Minor documentation changes cross-referencing NullHandler to the documentation on configuring logging in a library.
........
  r68481 | vinay.sajip | 2009-01-10 14:42:04 +0100 (Sa, 10 Jan 2009) | 1 line

  Corrected an incorrect self-reference.
........
  r68493 | benjamin.peterson | 2009-01-10 18:18:55 +0100 (Sa, 10 Jan 2009) | 1 line

  rewrite verbose conditionals
........
  r68495 | benjamin.peterson | 2009-01-10 18:36:44 +0100 (Sa, 10 Jan 2009) | 1 line

  tp_iter only exists with Py_TPFLAGS_HAVE_ITER #4901
........
  r68499 | mark.dickinson | 2009-01-10 20:14:55 +0100 (Sa, 10 Jan 2009) | 2 lines

  Remove an unnecessary check from test_decimal.
........
  r68501 | vinay.sajip | 2009-01-10 20:22:57 +0100 (Sa, 10 Jan 2009) | 1 line

  Corrected minor typo and added .currentmodule directives to fix missing cross-references.
........
  r68512 | benjamin.peterson | 2009-01-10 23:42:10 +0100 (Sa, 10 Jan 2009) | 1 line

  make tests fail if they can't be imported
........
  r68514 | benjamin.peterson | 2009-01-11 00:41:59 +0100 (So, 11 Jan 2009) | 1 line

  move seealso to a more appropiate place
........
  r68515 | benjamin.peterson | 2009-01-11 00:49:08 +0100 (So, 11 Jan 2009) | 1 line

  macos 9 isn't supported
........

17 files changed:
Doc/c-api/typeobj.rst
Doc/library/logging.rst
Doc/library/random.rst
Doc/library/sys.rst
Doc/using/cmdline.rst
Include/pyport.h
Include/unicodeobject.h
Lib/ctypes/test/__init__.py
Lib/random.py
Lib/test/test_decimal.py
Lib/test/test_import.py
Misc/python.man
Modules/main.c
Modules/socketmodule.c
Python/import.c
Tools/scripts/patchcheck.py
configure.in

index 463223a47847c9ef154f1406e9a84bb4ec50c24b..24f508e8b3a2e66569cd1632c5f4ecad081c6899 100644 (file)
@@ -743,7 +743,7 @@ set.
    :attr:`__weakref__`, the type inherits its :attr:`tp_weaklistoffset` from its
    base type.
 
-The next two fields only exist if the :const:`Py_TPFLAGS_HAVE_CLASS` flag bit is
+The next two fields only exist if the :const:`Py_TPFLAGS_HAVE_ITER` flag bit is
 set.
 
 
index 3e54422abe7ee8ce39ce5d0a513014d12aa7d5b8..cd1cbd28c9261d731f3aa4a0e72620291c63489c 100644 (file)
@@ -121,7 +121,7 @@ Another useful feature of the logging API is the ability to produce different
 messages at different log levels.  This allows you to instrument your code with
 debug messages, for example, but turning the log level down so that those debug
 messages are not written for your production system.  The default levels are
-``CRITICAL``, ``ERROR``, ``WARNING``, ``INFO``, ``DEBUG`` and ``UNSET``.
+``CRITICAL``, ``ERROR``, ``WARNING``, ``INFO``, ``DEBUG`` and ``NOTSET``.
 
 The logger, handler, and log message call each specify a level.  The log message
 is only emitted if the handler and logger are configured to emit messages of
@@ -422,6 +422,8 @@ You can see that the config file approach has a few advantages over the Python
 code approach, mainly separation of configuration and code and the ability of
 noncoders to easily modify the logging properties.
 
+.. _library-config:
+
 Configuring Logging for a Library
 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
 
@@ -524,6 +526,8 @@ provided:
 
 #. :class:`FileHandler` instances send error messages to disk files.
 
+.. currentmodule:: logging.handlers
+
 #. :class:`BaseRotatingHandler` is the base class for handlers that rotate log
    files at a certain point. It is not meant to be  instantiated directly. Instead,
    use :class:`RotatingFileHandler` or :class:`TimedRotatingFileHandler`.
@@ -553,7 +557,12 @@ provided:
 #. :class:`HTTPHandler` instances send error messages to an HTTP server using
    either ``GET`` or ``POST`` semantics.
 
-The :class:`NullHandler`, :class:`StreamHandler` and :class:`FileHandler`
+#. :class:`WatchedFileHandler` instances watch the file they are logging to. If
+the file changes, it is closed and reopened using the file name. This handler
+is only useful on Unix-like systems; Windows does not support the underlying
+mechanism used.
+
+The :class:`StreamHandler` and :class:`FileHandler`
 classes are defined in the core logging package. The other handlers are
 defined in a sub- module, :mod:`logging.handlers`. (There is also another
 sub-module, :mod:`logging.config`, for configuration functionality.)
@@ -1601,6 +1610,9 @@ sends logging output to a disk file.  It inherits the output functionality from
       Outputs the record to the file.
 
 
+See :ref:`library-config` for more information on how to use
+:class:`NullHandler`.
+
 WatchedFileHandler
 ^^^^^^^^^^^^^^^^^^
 
index 858888c9c557a336375923ec41452774385954ee..63c4bc71a5c97d41ba66f72e6faae9ef96e1ab5a 100644 (file)
@@ -210,9 +210,11 @@ be found in any statistics text.
 
 .. function:: expovariate(lambd)
 
-   Exponential distribution.  *lambd* is 1.0 divided by the desired mean.  (The
-   parameter would be called "lambda", but that is a reserved word in Python.)
-   Returned values range from 0 to positive infinity.
+   Exponential distribution.  *lambd* is 1.0 divided by the desired
+   mean.  It should be nonzero.  (The parameter would be called
+   "lambda", but that is a reserved word in Python.)  Returned values
+   range from 0 to positive infinity if *lambd* is positive, and from
+   negative infinity to 0 if *lambd* is negative.
 
 
 .. function:: gammavariate(alpha, beta)
index 1000694c7d02444c730ef72bcdf1d972b1e39b09..afdf52c5524f213a545bcc70ce1c5fb42c2f5f9f 100644 (file)
@@ -566,6 +566,10 @@ always available.
    .. versionchanged:: 2.3
       Unicode strings are no longer ignored.
 
+   .. seealso::
+      Module :mod:`site` This describes how to use .pth files to extend
+      :data:`sys.path`.
+
 
 .. data:: platform
 
@@ -583,7 +587,6 @@ always available.
    Windows          ``'win32'``
    Windows/Cygwin   ``'cygwin'``
    Mac OS X         ``'darwin'``
-   Mac OS 9         ``'mac'``
    OS/2             ``'os2'``
    OS/2 EMX         ``'os2emx'``
    RiscOS           ``'riscos'``
@@ -869,10 +872,3 @@ always available.
    first three characters of :const:`version`.  It is provided in the :mod:`sys`
    module for informational purposes; modifying this value has no effect on the
    registry keys used by Python. Availability: Windows.
-
-
-.. seealso::
-
-   Module :mod:`site`
-      This describes how to use .pth files to extend ``sys.path``.
-
index 643464b065d5759548a7168af74263396c111d14..2dd85f4441adc3c826e2f2432c4a427408981949 100644 (file)
@@ -356,7 +356,8 @@ Miscellaneous options
 
 .. cmdoption:: -3
 
-   Warn about Python 3.x incompatibilities. Among these are:
+   Warn about Python 3.x incompatibilities which cannot be fixed trivially by
+   :ref:`2to3 <2to3-reference>`. Among these are:
 
    * :meth:`dict.has_key`
    * :func:`apply`
index 15c8644f5671b6595ff0b3d38338afb0af6417c3..54411f25972447e1151206c6136e19155b1700b0 100644 (file)
@@ -709,6 +709,15 @@ typedef    struct fd_set {
 #define Py_FORMAT_PARSETUPLE(func,p1,p2)
 #endif
 
+/*
+ * Specify alignment on compilers that support it.
+ */
+#if defined(__GNUC__) && __GNUC__ >= 3
+#define Py_ALIGNED(x) __attribute__((aligned(x)))
+#else
+#define Py_ALIGNED(x)
+#endif
+
 /* Eliminate end-of-loop code not reached warnings from SunPro C
  * when using do{...}while(0) macros
  */
index cff0ac30e6daa54068d56a08210fabe5a260de22..2e399a013951841b0f3b45e5a89f9c120d90db79 100644 (file)
@@ -130,6 +130,10 @@ typedef unsigned int Py_UCS4;
 typedef unsigned long Py_UCS4; 
 #endif
 
+/* Py_UNICODE is the native Unicode storage format (code unit) used by
+   Python and represents a single Unicode element in the Unicode
+   type. */
+
 typedef PY_UNICODE_TYPE Py_UNICODE;
 
 /* --- UCS-2/UCS-4 Name Mangling ------------------------------------------ */
@@ -350,12 +354,12 @@ typedef PY_UNICODE_TYPE Py_UNICODE;
 
 #else
 
-/* Since splitting on whitespace is an important use case, and whitespace
-   in most situations is solely ASCII whitespace, we optimize for the common
-   case by using a quick look-up table with an inlined check.
- */
-PyAPI_DATA(const unsigned char) _Py_ascii_whitespace[];
+/* Since splitting on whitespace is an important use case, and
+   whitespace in most situations is solely ASCII whitespace, we
+   optimize for the common case by using a quick look-up table
+   _Py_ascii_whitespace (see below) with an inlined check.
 
+ */
 #define Py_UNICODE_ISSPACE(ch) \
        ((ch) < 128U ? _Py_ascii_whitespace[(ch)] : _PyUnicode_IsWhitespace(ch))
 
@@ -389,13 +393,14 @@ PyAPI_DATA(const unsigned char) _Py_ascii_whitespace[];
 #define Py_UNICODE_COPY(target, source, length)                                \
        Py_MEMCPY((target), (source), (length)*sizeof(Py_UNICODE))
 
-#define Py_UNICODE_FILL(target, value, length) do\
-    {Py_ssize_t i_; Py_UNICODE *t_ = (target); Py_UNICODE v_ = (value);\
+#define Py_UNICODE_FILL(target, value, length) \
+    do {Py_ssize_t i_; Py_UNICODE *t_ = (target); Py_UNICODE v_ = (value);\
         for (i_ = 0; i_ < (length); i_++) t_[i_] = v_;\
     } while (0)
 
-/* check if substring matches at given offset.  the offset must be
+/* Check if substring matches at given offset.  the offset must be
    valid, and the substring must not be empty */
+
 #define Py_UNICODE_MATCH(string, offset, substring) \
     ((*((string)->str + (offset)) == *((substring)->str)) && \
     ((*((string)->str + (offset) + (substring)->length-1) == *((substring)->str + (substring)->length-1))) && \
@@ -405,8 +410,6 @@ PyAPI_DATA(const unsigned char) _Py_ascii_whitespace[];
 extern "C" {
 #endif
 
-PyAPI_FUNC(int) PyUnicode_ClearFreeList(void);
-
 /* --- Unicode Type ------------------------------------------------------- */
 
 typedef struct {
@@ -605,6 +608,17 @@ PyAPI_FUNC(Py_ssize_t) PyUnicode_AsWideChar(
 
 PyAPI_FUNC(PyObject*) PyUnicode_FromOrdinal(int ordinal);
 
+/* --- Free-list management ----------------------------------------------- */
+
+/* Clear the free list used by the Unicode implementation.
+
+   This can be used to release memory used for objects on the free
+   list back to the Python memory allocator.
+
+*/
+
+PyAPI_FUNC(int) PyUnicode_ClearFreeList(void);
+
 /* === Builtin Codecs ===================================================== 
 
    Many of these APIs take two arguments encoding and errors. These
@@ -1323,6 +1337,10 @@ PyAPI_FUNC(PyObject *) _PyUnicode_XStrip(
 
 /* === Characters Type APIs =============================================== */
 
+/* Helper array used by Py_UNICODE_ISSPACE(). */
+
+PyAPI_DATA(const unsigned char) _Py_ascii_whitespace[];
+
 /* These should not be used directly. Use the Py_UNICODE_IS* and
    Py_UNICODE_TO* macros instead. 
 
index 70d647ba5e215f222249069c6ff85b2628c67564..52230928ba5b5cec72ef412dccfbd3d3e2777306 100644 (file)
@@ -67,9 +67,6 @@ def get_tests(package, mask, verbosity, exclude=()):
             if verbosity > 1:
                 print >> sys.stderr, "Skipped %s: %s" % (modname, detail)
             continue
-        except Exception, detail:
-            print >> sys.stderr, "Warning: could not import %s: %s" % (modname, detail)
-            continue
         for name in dir(mod):
             if name.startswith("_"):
                 continue
index 5879340a8d461753306ef4146c2ffabd45781eae..8b4c38edb1767219da53817d0b88eff550ee5333 100644 (file)
@@ -413,9 +413,11 @@ class Random(_random.Random):
     def expovariate(self, lambd):
         """Exponential distribution.
 
-        lambd is 1.0 divided by the desired mean.  (The parameter would be
-        called "lambda", but that is a reserved word in Python.)  Returned
-        values range from 0 to positive infinity.
+        lambd is 1.0 divided by the desired mean.  It should be
+        nonzero.  (The parameter would be called "lambda", but that is
+        a reserved word in Python.)  Returned values range from 0 to
+        positive infinity if lambd is positive, and from negative
+        infinity to 0 if lambd is negative.
 
         """
         # lambd: rate lambd = 1/mean
index 74304f70fe485538868a1c75dcb05305981c7cb9..b9955579dc10233f488a5f3396e94250a4991b16 100644 (file)
@@ -168,7 +168,6 @@ def outside_decNumber_bounds(v, context):
         -context.Emin > DEC_MAX_MATH):
         return True
     if not v._is_special and v and (
-        len(v._int) > DEC_MAX_MATH or
         v.adjusted() > DEC_MAX_MATH or
         v.adjusted() < 1-2*DEC_MAX_MATH):
         return True
index 7318a9e7e049fd461cdaf82c75c35b3a68ca6e18..db9c8ef6fc066a1e972fba73d349c26688ba28cb 100644 (file)
@@ -269,7 +269,7 @@ func_filename = func.func_code.co_filename
             if os.path.exists(file_name):
                 os.remove(file_name)
         if os.path.exists(self.dir_name):
-            os.rmdir(self.dir_name)
+            shutil.rmtree(self.dir_name)
 
     def import_module(self):
         ns = globals()
index 705f7bcbd4c544886cdec8883c87789e039d5be2..56d57f4a6805b90303b13726e54b2a162ee81e84 100644 (file)
@@ -54,6 +54,9 @@ python \- an interpreted, interactive, object-oriented programming language
 [
 .B \-x
 ]
+[
+.B \-3
+]
 .br
        [
 .B \-c
@@ -236,6 +239,9 @@ is thus equivalent to an omitted line number.
 Skip the first line of the source.  This is intended for a DOS
 specific hack only.  Warning: the line numbers in error messages will
 be off by one!
+.TP
+.B \-3
+Warn about Python 3.x incompatibilities that 2to3 cannot trivially fix.
 .SH INTERPRETER INTERFACE
 The interpreter interface resembles that of the UNIX shell: when
 called with standard input connected to a tty device, it prompts for
index 895a64f316fab9cb77b7ec98de8890a1b268271b..6ed2cd7abce7ac9ac9eb37a0b6fe2939eba73188 100644 (file)
@@ -86,7 +86,7 @@ static char *usage_3 = "\
 -x     : skip first line of source, allowing use of non-Unix forms of #!cmd\n\
 ";
 static char *usage_4 = "\
--3     : warn about Python 3.x incompatibilities\n\
+-3     : warn about Python 3.x incompatibilities that 2to3 cannot trivially fix\n\
 file   : program read from script file\n\
 -      : program read from stdin (default; interactive mode if a tty)\n\
 arg ...: arguments passed to program in sys.argv[1:]\n\n\
index deff28a1be9a13b255ec3f49af60c614cbb75a6c..c1e3cfe175d82d3e041df46abf5e614a49b96710 100644 (file)
@@ -3334,7 +3334,11 @@ socket_gethostbyaddr(PyObject *self, PyObject *args)
 #ifdef HAVE_GETHOSTBYNAME_R_3_ARG
        struct hostent_data data;
 #else
-       char buf[16384];
+       /* glibcs up to 2.10 assume that the buf argument to
+          gethostbyaddr_r is 8-byte aligned, which at least llvm-gcc
+          does not ensure. The attribute below instructs the compiler
+          to maintain this alignment. */
+       char buf[16384] Py_ALIGNED(8);
        int buf_len = (sizeof buf) - 1;
        int errnop;
 #endif
index 5c21e0bc3c078d018dcfdb42e3bf990a8d704222..5270b3771cf8d270aa7a572da7caf845fd0bb660 100644 (file)
@@ -3199,24 +3199,11 @@ NullImporter_init(NullImporter *self, PyObject *args, PyObject *kwds)
                return -1;
        } else {
 #ifndef RISCOS
+#ifndef MS_WINDOWS
                struct stat statbuf;
                int rv;
 
                rv = stat(path, &statbuf);
-#ifdef MS_WINDOWS
-               /* MS Windows stat() chokes on paths like C:\path\. Try to
-                * recover *one* time by stripping off a trailing slash or
-                * backslash. http://bugs.python.org/issue1293
-                */
-               if (rv != 0 && pathlen <= MAXPATHLEN &&
-                   (path[pathlen-1] == '/' || path[pathlen-1] == '\\')) {
-                       char mangled[MAXPATHLEN+1];
-
-                       strcpy(mangled, path);
-                       mangled[pathlen-1] = '\0';
-                       rv = stat(mangled, &statbuf);
-               }
-#endif
                if (rv == 0) {
                        /* it exists */
                        if (S_ISDIR(statbuf.st_mode)) {
@@ -3226,7 +3213,24 @@ NullImporter_init(NullImporter *self, PyObject *args, PyObject *kwds)
                                return -1;
                        }
                }
-#else
+#else /* MS_WINDOWS */
+               DWORD rv;
+               /* see issue1293 and issue3677:
+                * stat() on Windows doesn't recognise paths like
+                * "e:\\shared\\" and "\\\\whiterab-c2znlh\\shared" as dirs.
+                */
+               rv = GetFileAttributesA(path);
+               if (rv != INVALID_FILE_ATTRIBUTES) {
+                       /* it exists */
+                       if (rv & FILE_ATTRIBUTE_DIRECTORY) {
+                               /* it's a directory */
+                               PyErr_SetString(PyExc_ImportError,
+                                               "existing directory");
+                               return -1;
+                       }
+               }
+#endif
+#else /* RISCOS */
                if (object_exists(path)) {
                        /* it exists */
                        if (isdir(path)) {
index cc177e7aad0d7673f5583c569667bfe7b83b34de..e194c98cb04b3c84e79e2f9b00b0a1a880fd9773 100644 (file)
@@ -62,12 +62,12 @@ def docs_modified(file_paths):
 @status("Misc/ACKS updated", modal=True)
 def credit_given(file_paths):
     """Check if Misc/ACKS has been changed."""
-    return True if 'Misc/ACKS' in file_paths else False
+    return 'Misc/ACKS' in file_paths
 
 @status("Misc/NEWS updated", modal=True)
 def reported_news(file_paths):
     """Check if Misc/NEWS has been changed."""
-    return True if 'Misc/NEWS' in file_paths else False
+    return 'Misc/NEWS' in file_paths
 
 
 def main():
index 84c347a7678a37489b967885f5243ee9f5ab19ec..39317f43ee7dcdc6d75dd223d2ebe1746986603a 100644 (file)
@@ -407,7 +407,7 @@ AC_ARG_WITH(gcc,
             AC_HELP_STRING(--without-gcc,never use gcc),
 [
        case $withval in
-       no)     CC=cc
+       no)     CC=${CC:-cc}
                without_gcc=yes;;
        yes)    CC=gcc
                without_gcc=no;;