: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.
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
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
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
#. :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`.
#. :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.)
Outputs the record to the file.
+See :ref:`library-config` for more information on how to use
+:class:`NullHandler`.
+
WatchedFileHandler
^^^^^^^^^^^^^^^^^^
.. 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)
.. 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
Windows ``'win32'``
Windows/Cygwin ``'cygwin'``
Mac OS X ``'darwin'``
- Mac OS 9 ``'mac'``
OS/2 ``'os2'``
OS/2 EMX ``'os2emx'``
RiscOS ``'riscos'``
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``.
-
.. 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`
#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
*/
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 ------------------------------------------ */
#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))
#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))) && \
extern "C" {
#endif
-PyAPI_FUNC(int) PyUnicode_ClearFreeList(void);
-
/* --- Unicode Type ------------------------------------------------------- */
typedef struct {
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
/* === 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.
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
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
-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
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()
[
.B \-x
]
+[
+.B \-3
+]
.br
[
.B \-c
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
-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\
#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
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)) {
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)) {
@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():
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;;