Merged revisions 53451-53537 via svnmerge from

svn+ssh://pythondev@svn.python.org/python/trunk

........
  r53454 | brett.cannon | 2007-01-15 20:12:08 +0100 (Mon, 15 Jan 2007) | 3 lines

  Add a note for strptime that just because strftime supports some extra
  directive that is not documented that strptime will as well.
........
  r53458 | vinay.sajip | 2007-01-16 10:50:07 +0100 (Tue, 16 Jan 2007) | 1 line

  Updated rotating file handlers to use _open().
........
  r53459 | marc-andre.lemburg | 2007-01-16 14:03:06 +0100 (Tue, 16 Jan 2007) | 2 lines

  Add news items for the recent pybench and platform changes.
........
  r53460 | sjoerd.mullender | 2007-01-16 17:42:38 +0100 (Tue, 16 Jan 2007) | 4 lines

  Fixed ntpath.expandvars to not replace references to non-existing
  variables with nothing.  Also added tests.
  This fixes bug #494589.
........
  r53464 | neal.norwitz | 2007-01-17 07:23:51 +0100 (Wed, 17 Jan 2007) | 1 line

  Give Calvin Spealman access for python-dev summaries.
........
  r53465 | neal.norwitz | 2007-01-17 09:37:26 +0100 (Wed, 17 Jan 2007) | 1 line

  Remove Calvin since he only has access to the website currently.
........
  r53466 | thomas.heller | 2007-01-17 10:40:34 +0100 (Wed, 17 Jan 2007) | 2 lines

  Replace C++ comments with C comments.
........
  r53472 | andrew.kuchling | 2007-01-17 20:55:06 +0100 (Wed, 17 Jan 2007) | 1 line

  [Part of bug #1599254] Add suggestion to Mailbox docs to use Maildir, and warn user to lock/unlock mailboxes when modifying them
........
  r53475 | georg.brandl | 2007-01-17 22:09:04 +0100 (Wed, 17 Jan 2007) | 2 lines

  Bug #1637967: missing //= operator in list.
........
  r53477 | georg.brandl | 2007-01-17 22:19:58 +0100 (Wed, 17 Jan 2007) | 2 lines

  Bug #1629125: fix wrong data type (int -> Py_ssize_t) in PyDict_Next docs.
........
  r53481 | neal.norwitz | 2007-01-18 06:40:58 +0100 (Thu, 18 Jan 2007) | 1 line

  Try reverting part of r53145 that seems to cause the Windows buildbots to fail in test_uu.UUFileTest.test_encode
........
  r53482 | fred.drake | 2007-01-18 06:42:30 +0100 (Thu, 18 Jan 2007) | 1 line

  add missing version entry
........
  r53483 | neal.norwitz | 2007-01-18 07:20:55 +0100 (Thu, 18 Jan 2007) | 7 lines

  This test doesn't pass on Windows.  The cause seems to be that chmod
  doesn't support the same funcationality as on Unix.  I'm not sure if
  this fix is the best (or if it will even work)--it's a test to see
  if the buildbots start passing again.

  It might be better to not even run this test if it's windows (or non-posix).
........
  r53488 | neal.norwitz | 2007-01-19 06:53:33 +0100 (Fri, 19 Jan 2007) | 1 line

  SF #1635217, Fix unbalanced paren
........
  r53489 | martin.v.loewis | 2007-01-19 07:42:22 +0100 (Fri, 19 Jan 2007) | 3 lines

  Prefix AST symbols with _Py_. Fixes #1637022.
  Will backport.
........
  r53497 | martin.v.loewis | 2007-01-19 19:01:38 +0100 (Fri, 19 Jan 2007) | 2 lines

  Add UUIDs for 2.5.1 and 2.5.2
........
  r53499 | raymond.hettinger | 2007-01-19 19:07:18 +0100 (Fri, 19 Jan 2007) | 1 line

  SF# 1635892:  Fix docs for betavariate's input parameters .
........
  r53503 | martin.v.loewis | 2007-01-20 15:05:39 +0100 (Sat, 20 Jan 2007) | 2 lines

  Merge 53501 and 53502 from 25 branch:
  Add /GS- for AMD64 and Itanium builds where missing.
........
  r53504 | walter.doerwald | 2007-01-20 18:28:31 +0100 (Sat, 20 Jan 2007) | 2 lines

  Port test_resource.py to unittest.
........
  r53505 | walter.doerwald | 2007-01-20 19:19:33 +0100 (Sat, 20 Jan 2007) | 2 lines

  Add argument tests an calls of resource.getrusage().
........
  r53506 | walter.doerwald | 2007-01-20 20:03:17 +0100 (Sat, 20 Jan 2007) | 2 lines

  resource.RUSAGE_BOTH might not exist.
........
  r53507 | walter.doerwald | 2007-01-21 00:07:28 +0100 (Sun, 21 Jan 2007) | 2 lines

  Port test_new.py to unittest.
........
  r53508 | martin.v.loewis | 2007-01-21 10:33:07 +0100 (Sun, 21 Jan 2007) | 2 lines

  Patch #1610575: Add support for _Bool to struct.
........
  r53509 | georg.brandl | 2007-01-21 11:28:43 +0100 (Sun, 21 Jan 2007) | 3 lines

  Bug #1486663: don't reject keyword arguments for subclasses of builtin
  types.
........
  r53511 | georg.brandl | 2007-01-21 11:35:10 +0100 (Sun, 21 Jan 2007) | 2 lines

  Patch #1627441: close sockets properly in urllib2.
........
  r53517 | georg.brandl | 2007-01-22 20:40:21 +0100 (Mon, 22 Jan 2007) | 3 lines

  Use new email module names (#1637162, #1637159, #1637157).
........
  r53518 | andrew.kuchling | 2007-01-22 21:26:40 +0100 (Mon, 22 Jan 2007) | 1 line

  Improve pattern used for mbox 'From' lines; add a simple test
........
  r53519 | andrew.kuchling | 2007-01-22 21:27:50 +0100 (Mon, 22 Jan 2007) | 1 line

  Make comment match the code
........
  r53522 | georg.brandl | 2007-01-22 22:10:33 +0100 (Mon, 22 Jan 2007) | 2 lines

  Bug #1249573: fix rfc822.parsedate not accepting a certain date format
........
  r53524 | georg.brandl | 2007-01-22 22:23:41 +0100 (Mon, 22 Jan 2007) | 2 lines

  Bug #1627316: handle error in condition/ignore pdb commands more gracefully.
........
  r53526 | lars.gustaebel | 2007-01-23 12:17:33 +0100 (Tue, 23 Jan 2007) | 4 lines

  Patch #1507247: tarfile.py: use current umask for intermediate
  directories.
........
  r53527 | thomas.wouters | 2007-01-23 14:42:00 +0100 (Tue, 23 Jan 2007) | 13 lines


  SF patch #1630975: Fix crash when replacing sys.stdout in sitecustomize

  When running the interpreter in an environment that would cause it to set
  stdout/stderr/stdin's encoding, having a sitecustomize that would replace
  them with something other than PyFile objects would crash the interpreter.
  Fix it by simply ignoring the encoding-setting for non-files.

  This could do with a test, but I can think of no maintainable and portable
  way to test this bug, short of adding a sitecustomize.py to the buildsystem
  and have it always run with it (hmmm....)
........
  r53528 | thomas.wouters | 2007-01-23 14:50:49 +0100 (Tue, 23 Jan 2007) | 4 lines


  Add news entry about last checkin (oops.)
........
  r53531 | martin.v.loewis | 2007-01-23 22:11:47 +0100 (Tue, 23 Jan 2007) | 4 lines

  Make PyTraceBack_Here use the current thread, not the
  frame's thread state. Fixes #1579370.
  Will backport.
........
  r53535 | brett.cannon | 2007-01-24 00:21:22 +0100 (Wed, 24 Jan 2007) | 5 lines

  Fix crasher for when an object's __del__ creates a new weakref to itself.
  Patch only fixes new-style classes; classic classes still buggy.

  Closes bug #1377858.  Already backported.
........
  r53536 | walter.doerwald | 2007-01-24 01:42:19 +0100 (Wed, 24 Jan 2007) | 2 lines

  Port test_popen.py to unittest.
........
This commit is contained in:
Thomas Wouters 2007-02-01 18:02:27 +00:00
parent ec7027fc5b
commit b213704f3c
77 changed files with 1417 additions and 495 deletions

View File

@ -2082,7 +2082,7 @@ format.
\begin{verbatim}
PyObject *key, *value;
int pos = 0;
Py_ssize_t pos = 0;
while (PyDict_Next(self->dict, &pos, &key, &value)) {
/* do something interesting with the values... */
@ -2097,7 +2097,7 @@ while (PyDict_Next(self->dict, &pos, &key, &value)) {
\begin{verbatim}
PyObject *key, *value;
int pos = 0;
Py_ssize_t pos = 0;
while (PyDict_Next(self->dict, &pos, &key, &value)) {
int i = PyInt_AS_LONG(value) + 1;

View File

@ -50,6 +50,7 @@ GPL-compatible; the table below summarizes the various releases.
\linev{2.4.1}{2.4}{2005}{PSF}{yes}
\linev{2.4.2}{2.4.1}{2005}{PSF}{yes}
\linev{2.4.3}{2.4.2}{2006}{PSF}{yes}
\linev{2.4.4}{2.4.3}{2006}{PSF}{yes}
\linev{2.5}{2.4}{2006}{PSF}{yes}
\end{tablev}

2
Doc/dist/dist.tex vendored
View File

@ -692,7 +692,7 @@ Some examples:
\begin{tableii}{l|l}{code}{Provides Expression}{Explanation}
\lineii{mypkg} {Provide \code{mypkg}, using the distribution version}
\lineii{mypkg (1.1} {Provide \code{mypkg} version 1.1, regardless of the
\lineii{mypkg (1.1)} {Provide \code{mypkg} version 1.1, regardless of the
distribution version}
\end{tableii}

View File

@ -25,22 +25,29 @@ Maildir, mbox, MH, Babyl, and MMDF.
A mailbox, which may be inspected and modified.
\end{classdesc*}
The \class{Mailbox} class defines an interface and
is not intended to be instantiated. Instead, format-specific
subclasses should inherit from \class{Mailbox} and your code
should instantiate a particular subclass.
The \class{Mailbox} interface is dictionary-like, with small keys
corresponding to messages. Keys are issued by the \class{Mailbox} instance
with which they will be used and are only meaningful to that \class{Mailbox}
instance. A key continues to identify a message even if the corresponding
message is modified, such as by replacing it with another message. Messages may
be added to a \class{Mailbox} instance using the set-like method
\method{add()} and removed using a \code{del} statement or the set-like methods
\method{remove()} and \method{discard()}.
corresponding to messages. Keys are issued by the \class{Mailbox}
instance with which they will be used and are only meaningful to that
\class{Mailbox} instance. A key continues to identify a message even
if the corresponding message is modified, such as by replacing it with
another message.
Messages may be added to a \class{Mailbox} instance using the set-like
method \method{add()} and removed using a \code{del} statement or the
set-like methods \method{remove()} and \method{discard()}.
\class{Mailbox} interface semantics differ from dictionary semantics in some
noteworthy ways. Each time a message is requested, a new representation
(typically a \class{Message} instance) is generated, based upon the current
state of the mailbox. Similarly, when a message is added to a \class{Mailbox}
instance, the provided message representation's contents are copied. In neither
case is a reference to the message representation kept by the \class{Mailbox}
instance.
noteworthy ways. Each time a message is requested, a new
representation (typically a \class{Message} instance) is generated
based upon the current state of the mailbox. Similarly, when a message
is added to a \class{Mailbox} instance, the provided message
representation's contents are copied. In neither case is a reference
to the message representation kept by the \class{Mailbox} instance.
The default \class{Mailbox} iterator iterates over message representations, not
keys as the default dictionary iterator does. Moreover, modification of a
@ -51,9 +58,14 @@ skipped, though using a key from an iterator may result in a
\exception{KeyError} exception if the corresponding message is subsequently
removed.
\class{Mailbox} itself is intended to define an interface and to be inherited
from by format-specific subclasses but is not intended to be instantiated.
Instead, you should instantiate a subclass.
Be very cautious when modifying mailboxes that might also be changed
by some other process. The safest mailbox format to use for such
tasks is Maildir; try to avoid using single-file formats such as mbox
for concurrent writing. If you're modifying a mailbox, no matter what
the format, you must lock it by calling the \method{lock()} and
\method{unlock()} methods before making any changes. Failing to lock
the mailbox runs the risk of losing data if some other process makes
changes to the mailbox while your Python code is running.
\class{Mailbox} instances have the following methods:
@ -202,15 +214,16 @@ general it is incorrect for \var{arg} to be a \class{Mailbox} instance.
\begin{methoddesc}{flush}{}
Write any pending changes to the filesystem. For some \class{Mailbox}
subclasses, changes are always written immediately and this method does
nothing.
subclasses, changes are always written immediately and \method{flush()} does
nothing, but you should still make a habit of calling this method.
\end{methoddesc}
\begin{methoddesc}{lock}{}
Acquire an exclusive advisory lock on the mailbox so that other processes know
not to modify it. An \exception{ExternalClashError} is raised if the lock is
not available. The particular locking mechanisms used depend upon the mailbox
format.
format. You should \emph{always} lock the mailbox before making any
modifications to its contents.
\end{methoddesc}
\begin{methoddesc}{unlock}{}
@ -1373,36 +1386,55 @@ of the format-specific information that can be converted:
\begin{verbatim}
import mailbox
destination = mailbox.MH('~/Mail')
destination.lock()
for message in mailbox.Babyl('~/RMAIL'):
destination.add(MHMessage(message))
destination.flush()
destination.unlock()
\end{verbatim}
An example of sorting mail from numerous mailing lists, being careful to avoid
mail corruption due to concurrent modification by other programs, mail loss due
to interruption of the program, or premature termination due to malformed
messages in the mailbox:
This example sorts mail from several mailing lists into different
mailboxes, being careful to avoid mail corruption due to concurrent
modification by other programs, mail loss due to interruption of the
program, or premature termination due to malformed messages in the
mailbox:
\begin{verbatim}
import mailbox
import email.Errors
list_names = ('python-list', 'python-dev', 'python-bugs')
boxes = dict((name, mailbox.mbox('~/email/%s' % name)) for name in list_names)
inbox = mailbox.Maildir('~/Maildir', None)
inbox = mailbox.Maildir('~/Maildir', factory=None)
for key in inbox.iterkeys():
try:
message = inbox[key]
except email.Errors.MessageParseError:
continue # The message is malformed. Just leave it.
for name in list_names:
list_id = message['list-id']
if list_id and name in list_id:
# Get mailbox to use
box = boxes[name]
# Write copy to disk before removing original.
# If there's a crash, you might duplicate a message, but
# that's better than losing a message completely.
box.lock()
box.add(message)
box.flush() # Write copy to disk before removing original.
box.flush()
box.unlock()
# Remove original message
inbox.lock()
inbox.discard(key)
inbox.flush()
inbox.unlock()
break # Found destination, so stop looking.
for box in boxes.itervalues():
box.close()
\end{verbatim}

View File

@ -185,7 +185,7 @@ these equations can be found in any statistics text.
\begin{funcdesc}{betavariate}{alpha, beta}
Beta distribution. Conditions on the parameters are
\code{\var{alpha} > -1} and \code{\var{beta} > -1}.
\code{\var{alpha} > 0} and \code{\var{beta} > 0}.
Returned values range between 0 and 1.
\end{funcdesc}

View File

@ -50,14 +50,15 @@ C and Python values should be obvious given their types:
\lineiv{c}{\ctype{char}}{string of length 1}{}
\lineiv{b}{\ctype{signed char}}{integer}{}
\lineiv{B}{\ctype{unsigned char}}{integer}{}
\lineiv{t}{\ctype{_Bool}}{bool}{(1)}
\lineiv{h}{\ctype{short}}{integer}{}
\lineiv{H}{\ctype{unsigned short}}{integer}{}
\lineiv{i}{\ctype{int}}{integer}{}
\lineiv{I}{\ctype{unsigned int}}{long}{}
\lineiv{l}{\ctype{long}}{integer}{}
\lineiv{L}{\ctype{unsigned long}}{long}{}
\lineiv{q}{\ctype{long long}}{long}{(1)}
\lineiv{Q}{\ctype{unsigned long long}}{long}{(1)}
\lineiv{q}{\ctype{long long}}{long}{(2)}
\lineiv{Q}{\ctype{unsigned long long}}{long}{(2)}
\lineiv{f}{\ctype{float}}{float}{}
\lineiv{d}{\ctype{double}}{float}{}
\lineiv{s}{\ctype{char[]}}{string}{}
@ -70,6 +71,11 @@ Notes:
\begin{description}
\item[(1)]
The \character{t} conversion code corresponds to the \ctype{_Bool} type
defined by C99. If this type is not available, it is simulated using a
\ctype{char}. In standard mode, it is always represented by one byte.
\versionadded{2.6}
\item[(2)]
The \character{q} and \character{Q} conversion codes are available in
native mode only if the platform C compiler supports C \ctype{long long},
or, on Windows, \ctype{__int64}. They are always available in standard
@ -118,6 +124,12 @@ example, the Alpha and Merced processors use 64-bit pointer values,
meaning a Python long integer will be used to hold the pointer; other
platforms use 32-bit pointers and will use a Python integer.
For the \character{t} format character, the return value is either
\constant{True} or \constant{False}. When packing, the truth value
of the argument object is used. Either 0 or 1 in the native or standard
bool representation will be packed, and any non-zero value will be True
when unpacking.
By default, C numbers are represented in the machine's native format
and byte order, and properly aligned by skipping pad bytes if
necessary (according to the rules used by the C compiler).
@ -151,6 +163,7 @@ for any type (so you have to use pad bytes);
\ctype{long long} (\ctype{__int64} on Windows) is 8 bytes;
\ctype{float} and \ctype{double} are 32-bit and 64-bit
IEEE floating point numbers, respectively.
\ctype{_Bool} is 1 byte.
Note the difference between \character{@} and \character{=}: both use
native byte order, but the size and alignment of the latter is

View File

@ -324,6 +324,12 @@ Support for the \code{\%Z} directive is based on the values contained in
it is platform-specific except for recognizing UTC and GMT which are
always known (and are considered to be non-daylight savings
timezones).
Only the directives specified in the documentation are supported. Because
\code{strftime()} is implemented per platform it can sometimes offer more
directives than those listed. But \code{strptime()} is independent of any
platform and thus does not necessarily support all directives available that
are not documented as supported.
\end{funcdesc}
\begin{datadesc}{struct_time}

View File

@ -1997,8 +1997,8 @@ complicated).
\methodline[numeric object]{__ixor__}{self, other}
\methodline[numeric object]{__ior__}{self, other}
These methods are called to implement the augmented arithmetic
operations (\code{+=}, \code{-=}, \code{*=}, \code{/=}, \code{\%=},
\code{**=}, \code{<<=}, \code{>>=}, \code{\&=},
operations (\code{+=}, \code{-=}, \code{*=}, \code{/=}, \code{//=},
\code{\%=}, \code{**=}, \code{<<=}, \code{>>=}, \code{\&=},
\code{\textasciicircum=}, \code{|=}). These methods should attempt to do the
operation in-place (modifying \var{self}) and return the result (which
could be, but does not have to be, \var{self}). If a specific method

View File

@ -366,97 +366,157 @@ struct _alias {
};
mod_ty Module(asdl_seq * body, PyArena *arena);
mod_ty Interactive(asdl_seq * body, PyArena *arena);
mod_ty Expression(expr_ty body, PyArena *arena);
mod_ty Suite(asdl_seq * body, PyArena *arena);
stmt_ty FunctionDef(identifier name, arguments_ty args, asdl_seq * body,
asdl_seq * decorators, expr_ty returns, int lineno, int
col_offset, PyArena *arena);
stmt_ty ClassDef(identifier name, asdl_seq * bases, asdl_seq * body, int
lineno, int col_offset, PyArena *arena);
stmt_ty Return(expr_ty value, int lineno, int col_offset, PyArena *arena);
stmt_ty Delete(asdl_seq * targets, int lineno, int col_offset, PyArena *arena);
stmt_ty Assign(asdl_seq * targets, expr_ty value, int lineno, int col_offset,
PyArena *arena);
stmt_ty AugAssign(expr_ty target, operator_ty op, expr_ty value, int lineno,
int col_offset, PyArena *arena);
stmt_ty Print(expr_ty dest, asdl_seq * values, bool nl, int lineno, int
col_offset, PyArena *arena);
stmt_ty For(expr_ty target, expr_ty iter, asdl_seq * body, asdl_seq * orelse,
int lineno, int col_offset, PyArena *arena);
stmt_ty While(expr_ty test, asdl_seq * body, asdl_seq * orelse, int lineno, int
col_offset, PyArena *arena);
stmt_ty If(expr_ty test, asdl_seq * body, asdl_seq * orelse, int lineno, int
col_offset, PyArena *arena);
stmt_ty With(expr_ty context_expr, expr_ty optional_vars, asdl_seq * body, int
lineno, int col_offset, PyArena *arena);
stmt_ty Raise(expr_ty type, expr_ty inst, expr_ty tback, int lineno, int
col_offset, PyArena *arena);
stmt_ty TryExcept(asdl_seq * body, asdl_seq * handlers, asdl_seq * orelse, int
lineno, int col_offset, PyArena *arena);
stmt_ty TryFinally(asdl_seq * body, asdl_seq * finalbody, int lineno, int
#define Module(a0, a1) _Py_Module(a0, a1)
mod_ty _Py_Module(asdl_seq * body, PyArena *arena);
#define Interactive(a0, a1) _Py_Interactive(a0, a1)
mod_ty _Py_Interactive(asdl_seq * body, PyArena *arena);
#define Expression(a0, a1) _Py_Expression(a0, a1)
mod_ty _Py_Expression(expr_ty body, PyArena *arena);
#define Suite(a0, a1) _Py_Suite(a0, a1)
mod_ty _Py_Suite(asdl_seq * body, PyArena *arena);
#define FunctionDef(a0, a1, a2, a3, a4, a5, a6, a7) _Py_FunctionDef(a0, a1, a2, a3, a4, a5, a6, a7)
stmt_ty _Py_FunctionDef(identifier name, arguments_ty args, asdl_seq * body,
asdl_seq * decorators, expr_ty returns, int lineno, int
col_offset, PyArena *arena);
#define ClassDef(a0, a1, a2, a3, a4, a5) _Py_ClassDef(a0, a1, a2, a3, a4, a5)
stmt_ty _Py_ClassDef(identifier name, asdl_seq * bases, asdl_seq * body, int
lineno, int col_offset, PyArena *arena);
#define Return(a0, a1, a2, a3) _Py_Return(a0, a1, a2, a3)
stmt_ty _Py_Return(expr_ty value, int lineno, int col_offset, PyArena *arena);
#define Delete(a0, a1, a2, a3) _Py_Delete(a0, a1, a2, a3)
stmt_ty _Py_Delete(asdl_seq * targets, int lineno, int col_offset, PyArena
*arena);
#define Assign(a0, a1, a2, a3, a4) _Py_Assign(a0, a1, a2, a3, a4)
stmt_ty _Py_Assign(asdl_seq * targets, expr_ty value, int lineno, int
col_offset, PyArena *arena);
stmt_ty Assert(expr_ty test, expr_ty msg, int lineno, int col_offset, PyArena
*arena);
stmt_ty Import(asdl_seq * names, int lineno, int col_offset, PyArena *arena);
stmt_ty ImportFrom(identifier module, asdl_seq * names, int level, int lineno,
int col_offset, PyArena *arena);
stmt_ty Global(asdl_seq * names, int lineno, int col_offset, PyArena *arena);
stmt_ty Expr(expr_ty value, int lineno, int col_offset, PyArena *arena);
stmt_ty Pass(int lineno, int col_offset, PyArena *arena);
stmt_ty Break(int lineno, int col_offset, PyArena *arena);
stmt_ty Continue(int lineno, int col_offset, PyArena *arena);
expr_ty BoolOp(boolop_ty op, asdl_seq * values, int lineno, int col_offset,
PyArena *arena);
expr_ty BinOp(expr_ty left, operator_ty op, expr_ty right, int lineno, int
col_offset, PyArena *arena);
expr_ty UnaryOp(unaryop_ty op, expr_ty operand, int lineno, int col_offset,
PyArena *arena);
expr_ty Lambda(arguments_ty args, expr_ty body, int lineno, int col_offset,
PyArena *arena);
expr_ty IfExp(expr_ty test, expr_ty body, expr_ty orelse, int lineno, int
col_offset, PyArena *arena);
expr_ty Dict(asdl_seq * keys, asdl_seq * values, int lineno, int col_offset,
PyArena *arena);
expr_ty Set(asdl_seq * elts, int lineno, int col_offset, PyArena *arena);
expr_ty ListComp(expr_ty elt, asdl_seq * generators, int lineno, int
#define AugAssign(a0, a1, a2, a3, a4, a5) _Py_AugAssign(a0, a1, a2, a3, a4, a5)
stmt_ty _Py_AugAssign(expr_ty target, operator_ty op, expr_ty value, int
lineno, int col_offset, PyArena *arena);
#define Print(a0, a1, a2, a3, a4, a5) _Py_Print(a0, a1, a2, a3, a4, a5)
stmt_ty _Py_Print(expr_ty dest, asdl_seq * values, bool nl, int lineno, int
col_offset, PyArena *arena);
#define For(a0, a1, a2, a3, a4, a5, a6) _Py_For(a0, a1, a2, a3, a4, a5, a6)
stmt_ty _Py_For(expr_ty target, expr_ty iter, asdl_seq * body, asdl_seq *
orelse, int lineno, int col_offset, PyArena *arena);
#define While(a0, a1, a2, a3, a4, a5) _Py_While(a0, a1, a2, a3, a4, a5)
stmt_ty _Py_While(expr_ty test, asdl_seq * body, asdl_seq * orelse, int lineno,
int col_offset, PyArena *arena);
#define If(a0, a1, a2, a3, a4, a5) _Py_If(a0, a1, a2, a3, a4, a5)
stmt_ty _Py_If(expr_ty test, asdl_seq * body, asdl_seq * orelse, int lineno,
int col_offset, PyArena *arena);
#define With(a0, a1, a2, a3, a4, a5) _Py_With(a0, a1, a2, a3, a4, a5)
stmt_ty _Py_With(expr_ty context_expr, expr_ty optional_vars, asdl_seq * body,
int lineno, int col_offset, PyArena *arena);
#define Raise(a0, a1, a2, a3, a4, a5) _Py_Raise(a0, a1, a2, a3, a4, a5)
stmt_ty _Py_Raise(expr_ty type, expr_ty inst, expr_ty tback, int lineno, int
col_offset, PyArena *arena);
#define TryExcept(a0, a1, a2, a3, a4, a5) _Py_TryExcept(a0, a1, a2, a3, a4, a5)
stmt_ty _Py_TryExcept(asdl_seq * body, asdl_seq * handlers, asdl_seq * orelse,
int lineno, int col_offset, PyArena *arena);
#define TryFinally(a0, a1, a2, a3, a4) _Py_TryFinally(a0, a1, a2, a3, a4)
stmt_ty _Py_TryFinally(asdl_seq * body, asdl_seq * finalbody, int lineno, int
col_offset, PyArena *arena);
#define Assert(a0, a1, a2, a3, a4) _Py_Assert(a0, a1, a2, a3, a4)
stmt_ty _Py_Assert(expr_ty test, expr_ty msg, int lineno, int col_offset,
PyArena *arena);
#define Import(a0, a1, a2, a3) _Py_Import(a0, a1, a2, a3)
stmt_ty _Py_Import(asdl_seq * names, int lineno, int col_offset, PyArena
*arena);
#define ImportFrom(a0, a1, a2, a3, a4, a5) _Py_ImportFrom(a0, a1, a2, a3, a4, a5)
stmt_ty _Py_ImportFrom(identifier module, asdl_seq * names, int level, int
lineno, int col_offset, PyArena *arena);
#define Global(a0, a1, a2, a3) _Py_Global(a0, a1, a2, a3)
stmt_ty _Py_Global(asdl_seq * names, int lineno, int col_offset, PyArena
*arena);
#define Expr(a0, a1, a2, a3) _Py_Expr(a0, a1, a2, a3)
stmt_ty _Py_Expr(expr_ty value, int lineno, int col_offset, PyArena *arena);
#define Pass(a0, a1, a2) _Py_Pass(a0, a1, a2)
stmt_ty _Py_Pass(int lineno, int col_offset, PyArena *arena);
#define Break(a0, a1, a2) _Py_Break(a0, a1, a2)
stmt_ty _Py_Break(int lineno, int col_offset, PyArena *arena);
#define Continue(a0, a1, a2) _Py_Continue(a0, a1, a2)
stmt_ty _Py_Continue(int lineno, int col_offset, PyArena *arena);
#define BoolOp(a0, a1, a2, a3, a4) _Py_BoolOp(a0, a1, a2, a3, a4)
expr_ty _Py_BoolOp(boolop_ty op, asdl_seq * values, int lineno, int col_offset,
PyArena *arena);
#define BinOp(a0, a1, a2, a3, a4, a5) _Py_BinOp(a0, a1, a2, a3, a4, a5)
expr_ty _Py_BinOp(expr_ty left, operator_ty op, expr_ty right, int lineno, int
col_offset, PyArena *arena);
#define UnaryOp(a0, a1, a2, a3, a4) _Py_UnaryOp(a0, a1, a2, a3, a4)
expr_ty _Py_UnaryOp(unaryop_ty op, expr_ty operand, int lineno, int col_offset,
PyArena *arena);
#define Lambda(a0, a1, a2, a3, a4) _Py_Lambda(a0, a1, a2, a3, a4)
expr_ty _Py_Lambda(arguments_ty args, expr_ty body, int lineno, int col_offset,
PyArena *arena);
#define IfExp(a0, a1, a2, a3, a4, a5) _Py_IfExp(a0, a1, a2, a3, a4, a5)
expr_ty _Py_IfExp(expr_ty test, expr_ty body, expr_ty orelse, int lineno, int
col_offset, PyArena *arena);
#define Dict(a0, a1, a2, a3, a4) _Py_Dict(a0, a1, a2, a3, a4)
expr_ty _Py_Dict(asdl_seq * keys, asdl_seq * values, int lineno, int
col_offset, PyArena *arena);
expr_ty GeneratorExp(expr_ty elt, asdl_seq * generators, int lineno, int
#define Set(a0, a1, a2, a3) _Py_Set(a0, a1, a2, a3)
expr_ty _Py_Set(asdl_seq * elts, int lineno, int col_offset, PyArena *arena);
#define ListComp(a0, a1, a2, a3, a4) _Py_ListComp(a0, a1, a2, a3, a4)
expr_ty _Py_ListComp(expr_ty elt, asdl_seq * generators, int lineno, int
col_offset, PyArena *arena);
expr_ty Yield(expr_ty value, int lineno, int col_offset, PyArena *arena);
expr_ty Compare(expr_ty left, asdl_int_seq * ops, asdl_seq * comparators, int
lineno, int col_offset, PyArena *arena);
expr_ty Call(expr_ty func, asdl_seq * args, asdl_seq * keywords, expr_ty
starargs, expr_ty kwargs, int lineno, int col_offset, PyArena
*arena);
expr_ty Num(object n, int lineno, int col_offset, PyArena *arena);
expr_ty Str(string s, int lineno, int col_offset, PyArena *arena);
expr_ty Ellipsis(int lineno, int col_offset, PyArena *arena);
expr_ty Attribute(expr_ty value, identifier attr, expr_context_ty ctx, int
lineno, int col_offset, PyArena *arena);
expr_ty Subscript(expr_ty value, slice_ty slice, expr_context_ty ctx, int
lineno, int col_offset, PyArena *arena);
expr_ty Name(identifier id, expr_context_ty ctx, int lineno, int col_offset,
PyArena *arena);
expr_ty List(asdl_seq * elts, expr_context_ty ctx, int lineno, int col_offset,
PyArena *arena);
expr_ty Tuple(asdl_seq * elts, expr_context_ty ctx, int lineno, int col_offset,
PyArena *arena);
slice_ty Slice(expr_ty lower, expr_ty upper, expr_ty step, PyArena *arena);
slice_ty ExtSlice(asdl_seq * dims, PyArena *arena);
slice_ty Index(expr_ty value, PyArena *arena);
comprehension_ty comprehension(expr_ty target, expr_ty iter, asdl_seq * ifs,
PyArena *arena);
excepthandler_ty excepthandler(expr_ty type, identifier name, asdl_seq * body,
int lineno, int col_offset, PyArena *arena);
arguments_ty arguments(asdl_seq * args, identifier vararg, expr_ty
varargannotation, asdl_seq * kwonlyargs, identifier
kwarg, expr_ty kwargannotation, asdl_seq * defaults,
asdl_seq * kw_defaults, PyArena *arena);
arg_ty SimpleArg(identifier arg, expr_ty annotation, PyArena *arena);
arg_ty NestedArgs(asdl_seq * args, PyArena *arena);
keyword_ty keyword(identifier arg, expr_ty value, PyArena *arena);
alias_ty alias(identifier name, identifier asname, PyArena *arena);
#define GeneratorExp(a0, a1, a2, a3, a4) _Py_GeneratorExp(a0, a1, a2, a3, a4)
expr_ty _Py_GeneratorExp(expr_ty elt, asdl_seq * generators, int lineno, int
col_offset, PyArena *arena);
#define Yield(a0, a1, a2, a3) _Py_Yield(a0, a1, a2, a3)
expr_ty _Py_Yield(expr_ty value, int lineno, int col_offset, PyArena *arena);
#define Compare(a0, a1, a2, a3, a4, a5) _Py_Compare(a0, a1, a2, a3, a4, a5)
expr_ty _Py_Compare(expr_ty left, asdl_int_seq * ops, asdl_seq * comparators,
int lineno, int col_offset, PyArena *arena);
#define Call(a0, a1, a2, a3, a4, a5, a6, a7) _Py_Call(a0, a1, a2, a3, a4, a5, a6, a7)
expr_ty _Py_Call(expr_ty func, asdl_seq * args, asdl_seq * keywords, expr_ty
starargs, expr_ty kwargs, int lineno, int col_offset, PyArena
*arena);
#define Num(a0, a1, a2, a3) _Py_Num(a0, a1, a2, a3)
expr_ty _Py_Num(object n, int lineno, int col_offset, PyArena *arena);
#define Str(a0, a1, a2, a3) _Py_Str(a0, a1, a2, a3)
expr_ty _Py_Str(string s, int lineno, int col_offset, PyArena *arena);
#define Ellipsis(a0, a1, a2) _Py_Ellipsis(a0, a1, a2)
expr_ty _Py_Ellipsis(int lineno, int col_offset, PyArena *arena);
#define Attribute(a0, a1, a2, a3, a4, a5) _Py_Attribute(a0, a1, a2, a3, a4, a5)
expr_ty _Py_Attribute(expr_ty value, identifier attr, expr_context_ty ctx, int
lineno, int col_offset, PyArena *arena);
#define Subscript(a0, a1, a2, a3, a4, a5) _Py_Subscript(a0, a1, a2, a3, a4, a5)
expr_ty _Py_Subscript(expr_ty value, slice_ty slice, expr_context_ty ctx, int
lineno, int col_offset, PyArena *arena);
#define Name(a0, a1, a2, a3, a4) _Py_Name(a0, a1, a2, a3, a4)
expr_ty _Py_Name(identifier id, expr_context_ty ctx, int lineno, int
col_offset, PyArena *arena);
#define List(a0, a1, a2, a3, a4) _Py_List(a0, a1, a2, a3, a4)
expr_ty _Py_List(asdl_seq * elts, expr_context_ty ctx, int lineno, int
col_offset, PyArena *arena);
#define Tuple(a0, a1, a2, a3, a4) _Py_Tuple(a0, a1, a2, a3, a4)
expr_ty _Py_Tuple(asdl_seq * elts, expr_context_ty ctx, int lineno, int
col_offset, PyArena *arena);
#define Slice(a0, a1, a2, a3) _Py_Slice(a0, a1, a2, a3)
slice_ty _Py_Slice(expr_ty lower, expr_ty upper, expr_ty step, PyArena *arena);
#define ExtSlice(a0, a1) _Py_ExtSlice(a0, a1)
slice_ty _Py_ExtSlice(asdl_seq * dims, PyArena *arena);
#define Index(a0, a1) _Py_Index(a0, a1)
slice_ty _Py_Index(expr_ty value, PyArena *arena);
#define comprehension(a0, a1, a2, a3) _Py_comprehension(a0, a1, a2, a3)
comprehension_ty _Py_comprehension(expr_ty target, expr_ty iter, asdl_seq *
ifs, PyArena *arena);
#define excepthandler(a0, a1, a2, a3, a4, a5) _Py_excepthandler(a0, a1, a2, a3, a4, a5)
excepthandler_ty _Py_excepthandler(expr_ty type, identifier name, asdl_seq *
body, int lineno, int col_offset, PyArena
*arena);
#define arguments(a0, a1, a2, a3, a4, a5, a6, a7, a8) _Py_arguments(a0, a1, a2, a3, a4, a5, a6, a7, a8)
arguments_ty _Py_arguments(asdl_seq * args, identifier vararg, expr_ty
varargannotation, asdl_seq * kwonlyargs, identifier
kwarg, expr_ty kwargannotation, asdl_seq * defaults,
asdl_seq * kw_defaults, PyArena *arena);
#define SimpleArg(a0, a1, a2) _Py_SimpleArg(a0, a1, a2)
arg_ty _Py_SimpleArg(identifier arg, expr_ty annotation, PyArena *arena);
#define NestedArgs(a0, a1) _Py_NestedArgs(a0, a1)
arg_ty _Py_NestedArgs(asdl_seq * args, PyArena *arena);
#define keyword(a0, a1, a2) _Py_keyword(a0, a1, a2)
keyword_ty _Py_keyword(identifier arg, expr_ty value, PyArena *arena);
#define alias(a0, a1, a2) _Py_alias(a0, a1, a2)
alias_ty _Py_alias(identifier name, identifier asname, PyArena *arena);
PyObject* PyAST_mod2obj(mod_ty t);

View File

@ -368,7 +368,7 @@ PyAPI_FUNC(PyObject *) _PyType_Lookup(PyTypeObject *, PyObject *);
/* Generic operations on objects */
PyAPI_FUNC(int) PyObject_Print(PyObject *, FILE *, int);
PyAPI_FUNC(void) _Py_Break(void);
PyAPI_FUNC(void) _Py_BreakPoint(void);
PyAPI_FUNC(void) _PyObject_Dump(PyObject *);
PyAPI_FUNC(PyObject *) PyObject_Repr(PyObject *);
PyAPI_FUNC(PyObject *) _PyObject_Str(PyObject *);

View File

@ -1,4 +1,4 @@
# Copyright 2001-2005 by Vinay Sajip. All Rights Reserved.
# Copyright 2001-2007 by Vinay Sajip. All Rights Reserved.
#
# Permission to use, copy, modify, and distribute this software and its
# documentation for any purpose and without fee is hereby granted,
@ -22,7 +22,7 @@ Apache's log4j system.
Should work under Python versions >= 1.5.2, except that source line
information is not available unless 'sys._getframe()' is.
Copyright (C) 2001-2004 Vinay Sajip. All Rights Reserved.
Copyright (C) 2001-2007 Vinay Sajip. All Rights Reserved.
To use, simply 'import logging' and log away!
"""
@ -135,10 +135,8 @@ class RotatingFileHandler(BaseRotatingHandler):
os.remove(dfn)
os.rename(self.baseFilename, dfn)
#print "%s -> %s" % (self.baseFilename, dfn)
if self.encoding:
self.stream = codecs.open(self.baseFilename, 'w', self.encoding)
else:
self.stream = open(self.baseFilename, 'w')
self.mode = 'w'
self.stream = self._open()
def shouldRollover(self, record):
"""
@ -281,10 +279,8 @@ class TimedRotatingFileHandler(BaseRotatingHandler):
s.sort()
os.remove(s[0])
#print "%s -> %s" % (self.baseFilename, dfn)
if self.encoding:
self.stream = codecs.open(self.baseFilename, 'w', self.encoding)
else:
self.stream = open(self.baseFilename, 'w')
self.mode = 'w'
self.stream = self._open()
self.rolloverAt = self.rolloverAt + self.interval
class WatchedFileHandler(logging.FileHandler):
@ -786,7 +782,7 @@ class SMTPHandler(logging.Handler):
try:
import smtplib
try:
from email.Utils import formatdate
from email.utils import formatdate
except ImportError:
formatdate = self.date_time
port = self.mailport

View File

@ -16,8 +16,8 @@ import socket
import errno
import copy
import email
import email.Message
import email.Generator
import email.message
import email.generator
import rfc822
import StringIO
try:
@ -193,9 +193,9 @@ class Mailbox:
# To get native line endings on disk, the user-friendly \n line endings
# used in strings and by email.Message are translated here.
"""Dump message contents to target file."""
if isinstance(message, email.Message.Message):
if isinstance(message, email.message.Message):
buffer = StringIO.StringIO()
gen = email.Generator.Generator(buffer, mangle_from_, 0)
gen = email.generator.Generator(buffer, mangle_from_, 0)
gen.flatten(message)
buffer.seek(0)
target.write(buffer.read().replace('\n', os.linesep))
@ -704,7 +704,7 @@ class _mboxMMDF(_singlefileMailbox):
message = ''
elif isinstance(message, _mboxMMDFMessage):
from_line = 'From ' + message.get_from()
elif isinstance(message, email.Message.Message):
elif isinstance(message, email.message.Message):
from_line = message.get_unixfrom() # May be None.
if from_line is None:
from_line = 'From MAILER-DAEMON %s' % time.asctime(time.gmtime())
@ -1254,9 +1254,9 @@ class Babyl(_singlefileMailbox):
self._file.write(os.linesep)
else:
self._file.write('1,,' + os.linesep)
if isinstance(message, email.Message.Message):
if isinstance(message, email.message.Message):
orig_buffer = StringIO.StringIO()
orig_generator = email.Generator.Generator(orig_buffer, False, 0)
orig_generator = email.generator.Generator(orig_buffer, False, 0)
orig_generator.flatten(message)
orig_buffer.seek(0)
while True:
@ -1267,7 +1267,7 @@ class Babyl(_singlefileMailbox):
self._file.write('*** EOOH ***' + os.linesep)
if isinstance(message, BabylMessage):
vis_buffer = StringIO.StringIO()
vis_generator = email.Generator.Generator(vis_buffer, False, 0)
vis_generator = email.generator.Generator(vis_buffer, False, 0)
vis_generator.flatten(message.get_visible())
while True:
line = vis_buffer.readline()
@ -1323,12 +1323,12 @@ class Babyl(_singlefileMailbox):
return (start, stop)
class Message(email.Message.Message):
class Message(email.message.Message):
"""Message with mailbox-format-specific properties."""
def __init__(self, message=None):
"""Initialize a Message instance."""
if isinstance(message, email.Message.Message):
if isinstance(message, email.message.Message):
self._become_message(copy.deepcopy(message))
if isinstance(message, Message):
message._explain_to(self)
@ -1337,7 +1337,7 @@ class Message(email.Message.Message):
elif hasattr(message, "read"):
self._become_message(email.message_from_file(message))
elif message is None:
email.Message.Message.__init__(self)
email.message.Message.__init__(self)
else:
raise TypeError('Invalid message type: %s' % type(message))
@ -1468,7 +1468,7 @@ class _mboxMMDFMessage(Message):
def __init__(self, message=None):
"""Initialize an mboxMMDFMessage instance."""
self.set_from('MAILER-DAEMON', True)
if isinstance(message, email.Message.Message):
if isinstance(message, email.message.Message):
unixfrom = message.get_unixfrom()
if unixfrom is not None and unixfrom.startswith('From '):
self.set_from(unixfrom[5:])
@ -1990,10 +1990,12 @@ class UnixMailbox(_Mailbox):
# that the two characters preceding "From " are \n\n or the beginning of
# the file. Fixing this would require a more extensive rewrite than is
# necessary. For convenience, we've added a PortableUnixMailbox class
# which uses the more lenient _fromlinepattern regular expression.
# which does no checking of the format of the 'From' line.
_fromlinepattern = r"From \s*[^\s]+\s+\w\w\w\s+\w\w\w\s+\d?\d\s+" \
r"\d?\d:\d\d(:\d\d)?(\s+[^\s]+)?\s+\d\d\d\d\s*$"
_fromlinepattern = (r"From \s*[^\s]+\s+\w\w\w\s+\w\w\w\s+\d?\d\s+"
r"\d?\d:\d\d(:\d\d)?(\s+[^\s]+)?\s+\d\d\d\d\s*"
r"[^\s]*\s*"
"$")
_regexp = None
def _strict_isrealfromline(self, line):

View File

@ -344,8 +344,10 @@ def expandvars(path):
var = path[:index]
if var in os.environ:
res = res + os.environ[var]
else:
res = res + '${' + var + '}'
except ValueError:
res = res + path
res = res + '${' + path
index = pathlen - 1
else:
var = ''
@ -357,8 +359,10 @@ def expandvars(path):
c = path[index:index + 1]
if var in os.environ:
res = res + os.environ[var]
else:
res = res + '$' + var
if c != '':
res = res + c
index = index - 1
else:
res = res + c
index = index + 1

View File

@ -479,7 +479,12 @@ class Pdb(bdb.Bdb, cmd.Cmd):
def do_condition(self, arg):
# arg is breakpoint number and condition
args = arg.split(' ', 1)
bpnum = int(args[0].strip())
try:
bpnum = int(args[0].strip())
except ValueError:
# something went wrong
print >>self.stdout, \
'Breakpoint index %r is not a number' % args[0]
try:
cond = args[1]
except:
@ -494,7 +499,12 @@ class Pdb(bdb.Bdb, cmd.Cmd):
def do_ignore(self,arg):
"""arg is bp number followed by ignore count."""
args = arg.split()
bpnum = int(args[0].strip())
try:
bpnum = int(args[0].strip())
except ValueError:
# something went wrong
print >>self.stdout, \
'Breakpoint index %r is not a number' % args[0]
try:
count = int(args[1].strip())
except:

View File

@ -569,7 +569,7 @@ class Random(_random.Random):
def betavariate(self, alpha, beta):
"""Beta distribution.
Conditions on the parameters are alpha > -1 and beta} > -1.
Conditions on the parameters are alpha > 0 and beta > 0.
Returned values range between 0 and 1.
"""

View File

@ -850,6 +850,11 @@ def parsedate_tz(data):
if data[0][-1] in (',', '.') or data[0].lower() in _daynames:
# There's a dayname here. Skip it
del data[0]
else:
# no space after the "weekday,"?
i = data[0].rfind(',')
if i >= 0:
data[0] = data[0][i+1:]
if len(data) == 3: # RFC 850 date, deprecated
stuff = data[0].split('-')
if len(stuff) == 3:

View File

@ -43,10 +43,10 @@ Example:
import socket
import re
import email.Utils
import email.utils
import base64
import hmac
from email.base64MIME import encode as encode_base64
from email.base64mime import encode as encode_base64
from sys import stderr
__all__ = ["SMTPException","SMTPServerDisconnected","SMTPResponseException",
@ -172,7 +172,7 @@ def quoteaddr(addr):
"""
m = (None, None)
try:
m = email.Utils.parseaddr(addr)[1]
m = email.utils.parseaddr(addr)[1]
except AttributeError:
pass
if m == (None, None): # Indicates parse failure or AttributeError

View File

@ -204,9 +204,10 @@ class _fileobject(object):
__slots__ = ["mode", "bufsize", "softspace",
# "closed" is a property, see below
"_sock", "_rbufsize", "_wbufsize", "_rbuf", "_wbuf"]
"_sock", "_rbufsize", "_wbufsize", "_rbuf", "_wbuf",
"_close"]
def __init__(self, sock, mode='rb', bufsize=-1):
def __init__(self, sock, mode='rb', bufsize=-1, close=False):
self._sock = sock
self.mode = mode # Not actually used in this version
if bufsize < 0:
@ -222,6 +223,7 @@ class _fileobject(object):
self._wbufsize = bufsize
self._rbuf = "" # A string
self._wbuf = [] # A list of strings
self._close = close
def _getclosed(self):
return self._sock is None
@ -232,6 +234,8 @@ class _fileobject(object):
if self._sock:
self.flush()
finally:
if self._close:
self._sock.close()
self._sock = None
def __del__(self):

View File

@ -1632,19 +1632,7 @@ class TarFile(object):
# Create all upper directories.
upperdirs = os.path.dirname(targetpath)
if upperdirs and not os.path.exists(upperdirs):
ti = TarInfo()
ti.name = upperdirs
ti.type = DIRTYPE
ti.mode = 0777
ti.mtime = tarinfo.mtime
ti.uid = tarinfo.uid
ti.gid = tarinfo.gid
ti.uname = tarinfo.uname
ti.gname = tarinfo.gname
try:
self._extract_member(ti, ti.name)
except:
pass
os.makedirs(upperdirs)
if tarinfo.islnk() or tarinfo.issym():
self._dbg(1, "%s -> %s" % (tarinfo.name, tarinfo.linkname))

View File

@ -1,11 +1,12 @@
import weakref
# http://python.org/sf/1377858
# Fixed for new-style classes in 2.5c1.
ref = None
def test_weakref_in_del():
class Target(object):
class Target():
def __del__(self):
global ref
ref = weakref.ref(self)

View File

@ -1,6 +0,0 @@
test_new
new.module()
new.classobj()
new.instancemethod()
new.function()
new.code()

View File

@ -1,3 +0,0 @@
test_popen
Test popen:
popen seemed to process the command-line correctly

View File

@ -1,2 +0,0 @@
test_resource
True

View File

@ -12,6 +12,10 @@ from pickle import loads, dumps
class ArraySubclass(array.array):
pass
class ArraySubclassWithKwargs(array.array):
def __init__(self, typecode, newarg=None):
array.array.__init__(typecode)
tests = [] # list to accumulate all tests
typecodes = "cubBhHiIlLfd"
@ -683,6 +687,9 @@ class BaseTest(unittest.TestCase):
b = array.array('B', range(64))
self.assertEqual(rc, sys.getrefcount(10))
def test_subclass_with_kwargs(self):
# SF bug #1486663 -- this used to erroneously raise a TypeError
ArraySubclassWithKwargs('b', newarg=1)
class StringTest(BaseTest):

View File

@ -486,6 +486,16 @@ class TestSubclass(unittest.TestCase):
d1 == d2 # not clear if this is supposed to be True or False,
# but it used to give a SystemError
class SubclassWithKwargs(deque):
def __init__(self, newarg=1):
deque.__init__(self)
class TestSubclassWithKwargs(unittest.TestCase):
def test_subclass_with_kwargs(self):
# SF bug #1486663 -- this used to erroneously raise a TypeError
SubclassWithKwargs(newarg=1)
#==============================================================================
libreftest = """
@ -599,6 +609,7 @@ def test_main(verbose=None):
TestBasic,
TestVariousIteratorArgs,
TestSubclass,
TestSubclassWithKwargs,
)
test_support.run_unittest(*test_classes)

View File

@ -50,11 +50,17 @@ class DumbDBMTestCase(unittest.TestCase):
finally:
os.umask(old_umask)
expected_mode = 0635
if os.name != 'posix':
# Windows only supports setting the read-only attribute.
# This shouldn't fail, but doesn't work like Unix either.
expected_mode = 0666
import stat
st = os.stat(_fname + '.dat')
self.assertEqual(stat.S_IMODE(st.st_mode), 0635)
self.assertEqual(stat.S_IMODE(st.st_mode), expected_mode)
st = os.stat(_fname + '.dir')
self.assertEqual(stat.S_IMODE(st.st_mode), 0635)
self.assertEqual(stat.S_IMODE(st.st_mode), expected_mode)
def test_close_twice(self):
f = dumbdbm.open(_fname)

View File

@ -744,6 +744,21 @@ class RegressionTests(unittest.TestCase):
self.assertRaises(AssertionError, list, cycle(gen1()))
self.assertEqual(hist, [0,1])
class SubclassWithKwargsTest(unittest.TestCase):
def test_keywords_in_subclass(self):
# count is not subclassable...
for cls in (repeat, izip, ifilter, ifilterfalse, chain, imap,
starmap, islice, takewhile, dropwhile, cycle):
class Subclass(cls):
def __init__(self, newarg=None, *args):
cls.__init__(self, *args)
try:
Subclass(newarg=1)
except TypeError as err:
# we expect type errors because of wrong argument count
self.failIf("does not take keyword arguments" in err.args[0])
libreftest = """ Doctest for examples in the library reference: libitertools.tex
@ -938,7 +953,8 @@ __test__ = {'libreftest' : libreftest}
def test_main(verbose=None):
test_classes = (TestBasicOps, TestVariousIteratorArgs, TestGC,
RegressionTests, LengthTransparency)
RegressionTests, LengthTransparency,
SubclassWithKwargsTest)
test_support.run_unittest(*test_classes)
# verify reference counting

View File

@ -4,7 +4,7 @@ import time
import stat
import socket
import email
import email.Message
import email.message
import rfc822
import re
import StringIO
@ -22,7 +22,7 @@ class TestBase(unittest.TestCase):
def _check_sample(self, msg):
# Inspect a mailbox.Message representation of the sample message
self.assert_(isinstance(msg, email.Message.Message))
self.assert_(isinstance(msg, email.message.Message))
self.assert_(isinstance(msg, mailbox.Message))
for key, value in _sample_headers.iteritems():
self.assert_(value in msg.get_all(key))
@ -30,7 +30,7 @@ class TestBase(unittest.TestCase):
self.assert_(len(msg.get_payload()) == len(_sample_payloads))
for i, payload in enumerate(_sample_payloads):
part = msg.get_payload(i)
self.assert_(isinstance(part, email.Message.Message))
self.assert_(isinstance(part, email.message.Message))
self.assert_(not isinstance(part, mailbox.Message))
self.assert_(part.get_payload() == payload)
@ -939,7 +939,7 @@ class TestMessage(TestBase):
self._delete_recursively(self._path)
def test_initialize_with_eMM(self):
# Initialize based on email.Message.Message instance
# Initialize based on email.message.Message instance
eMM = email.message_from_string(_sample_message)
msg = self._factory(eMM)
self._post_initialize_hook(msg)
@ -965,7 +965,7 @@ class TestMessage(TestBase):
# Initialize without arguments
msg = self._factory()
self._post_initialize_hook(msg)
self.assert_(isinstance(msg, email.Message.Message))
self.assert_(isinstance(msg, email.message.Message))
self.assert_(isinstance(msg, mailbox.Message))
self.assert_(isinstance(msg, self._factory))
self.assert_(msg.keys() == [])
@ -992,7 +992,7 @@ class TestMessage(TestBase):
mailbox.BabylMessage, mailbox.MMDFMessage):
other_msg = class_()
msg._explain_to(other_msg)
other_msg = email.Message.Message()
other_msg = email.message.Message()
self.assertRaises(TypeError, lambda: msg._explain_to(other_msg))
def _post_initialize_hook(self, msg):
@ -1732,11 +1732,11 @@ class MaildirTestCase(unittest.TestCase):
def test_unix_mbox(self):
### should be better!
import email.Parser
import email.parser
fname = self.createMessage("cur", True)
n = 0
for msg in mailbox.PortableUnixMailbox(open(fname),
email.Parser.Parser().parse):
email.parser.Parser().parse):
n += 1
self.assertEqual(msg["subject"], "Simple Test")
self.assertEqual(len(str(msg)), len(FROM_)+len(DUMMY_MESSAGE))

View File

@ -1,180 +1,158 @@
from test.test_support import verbose, verify, TestFailed
import sys
import new
import unittest
from test import test_support
import sys, new
class Eggs:
def get_yolks(self):
return self.yolks
class NewTest(unittest.TestCase):
def test_spam(self):
class Eggs:
def get_yolks(self):
return self.yolks
print 'new.module()'
m = new.module('Spam')
if verbose:
print m
m.Eggs = Eggs
sys.modules['Spam'] = m
import Spam
m = new.module('Spam')
m.Eggs = Eggs
sys.modules['Spam'] = m
import Spam
def get_more_yolks(self):
return self.yolks + 3
def get_more_yolks(self):
return self.yolks + 3
print 'new.classobj()'
C = new.classobj('Spam', (Spam.Eggs,), {'get_more_yolks': get_more_yolks})
if verbose:
print C
# new.classobj()
C = new.classobj('Spam', (Spam.Eggs,), {'get_more_yolks': get_more_yolks})
def break_yolks(self):
self.yolks = self.yolks - 2
print 'new.instancemethod()'
c = C()
c.yolks = 3
im = new.instancemethod(break_yolks, c, C)
if verbose:
print im
def break_yolks(self):
self.yolks = self.yolks - 2
verify(c.get_yolks() == 3 and c.get_more_yolks() == 6,
'Broken call of hand-crafted class instance')
im()
verify(c.get_yolks() == 1 and c.get_more_yolks() == 4,
'Broken call of hand-crafted instance method')
# new.instancemethod()
c = C()
c.yolks = 3
im = new.instancemethod(break_yolks, c, C)
im = new.instancemethod(break_yolks, c)
im()
verify(c.get_yolks() == -1)
try:
new.instancemethod(break_yolks, None)
except TypeError:
pass
else:
raise TestFailed, "dangerous instance method creation allowed"
self.assertEqual(c.get_yolks(), 3,
'Broken call of hand-crafted class instance')
self.assertEqual(c.get_more_yolks(), 6,
'Broken call of hand-crafted class instance')
# Verify that instancemethod() doesn't allow keyword args
try:
new.instancemethod(break_yolks, c, kw=1)
except TypeError:
pass
else:
raise TestFailed, "instancemethod shouldn't accept keyword args"
im()
self.assertEqual(c.get_yolks(), 1,
'Broken call of hand-crafted instance method')
self.assertEqual(c.get_more_yolks(), 4,
'Broken call of hand-crafted instance method')
# It's unclear what the semantics should be for a code object compiled at
# module scope, but bound and run in a function. In CPython, `c' is global
# (by accident?) while in Jython, `c' is local. The intent of the test
# clearly is to make `c' global, so let's be explicit about it.
codestr = '''
global c
a = 1
b = 2
c = a + b
'''
im = new.instancemethod(break_yolks, c)
im()
self.assertEqual(c.get_yolks(), -1)
ccode = compile(codestr, '<string>', 'exec')
# Jython doesn't have a __builtins__, so use a portable alternative
import __builtin__
g = {'c': 0, '__builtins__': __builtin__}
# this test could be more robust
print 'new.function()'
func = new.function(ccode, g)
if verbose:
print func
func()
verify(g['c'] == 3,
'Could not create a proper function object')
# Verify that dangerous instance method creation is forbidden
self.assertRaises(TypeError, new.instancemethod, break_yolks, None)
# test the various extended flavors of function.new
def f(x):
def g(y):
return x + y
return g
g = f(4)
new.function(f.func_code, {}, "blah")
g2 = new.function(g.func_code, {}, "blah", (2,), g.func_closure)
verify(g2() == 6)
g3 = new.function(g.func_code, {}, "blah", None, g.func_closure)
verify(g3(5) == 9)
def test_closure(func, closure, exc):
try:
new.function(func.func_code, {}, "", None, closure)
except exc:
pass
else:
print "corrupt closure accepted"
# Verify that instancemethod() doesn't allow keyword args
self.assertRaises(TypeError, new.instancemethod, break_yolks, c, kw=1)
test_closure(g, None, TypeError) # invalid closure
test_closure(g, (1,), TypeError) # non-cell in closure
test_closure(g, (1, 1), ValueError) # closure is wrong size
test_closure(f, g.func_closure, ValueError) # no closure needed
def test_scope(self):
# It's unclear what the semantics should be for a code object compiled
# at module scope, but bound and run in a function. In CPython, `c' is
# global (by accident?) while in Jython, `c' is local. The intent of
# the test clearly is to make `c' global, so let's be explicit about it.
codestr = '''
global c
a = 1
b = 2
c = a + b
'''
print 'new.code()'
# bogus test of new.code()
# Note: Jython will never have new.code()
if hasattr(new, 'code'):
def f(a): pass
codestr = "\n".join(l.strip() for l in codestr.splitlines())
c = f.func_code
argcount = c.co_argcount
kwonlyargcount = c.co_kwonlyargcount
nlocals = c.co_nlocals
stacksize = c.co_stacksize
flags = c.co_flags
codestring = c.co_code
constants = c.co_consts
names = c.co_names
varnames = c.co_varnames
filename = c.co_filename
name = c.co_name
firstlineno = c.co_firstlineno
lnotab = c.co_lnotab
freevars = c.co_freevars
cellvars = c.co_cellvars
ccode = compile(codestr, '<string>', 'exec')
# Jython doesn't have a __builtins__, so use a portable alternative
import __builtin__
g = {'c': 0, '__builtins__': __builtin__}
d = new.code(argcount, kwonlyargcount,
nlocals, stacksize, flags, codestring,
constants, names, varnames, filename, name,
firstlineno, lnotab, freevars, cellvars)
# this test could be more robust
func = new.function(ccode, g)
func()
self.assertEqual(g['c'], 3, 'Could not create a proper function object')
# test backwards-compatibility version with no freevars or cellvars
d = new.code(argcount, kwonlyargcount,
nlocals, stacksize, flags, codestring,
constants, names, varnames, filename, name,
firstlineno, lnotab)
def test_function(self):
# test the various extended flavors of function.new
def f(x):
def g(y):
return x + y
return g
g = f(4)
new.function(f.func_code, {}, "blah")
g2 = new.function(g.func_code, {}, "blah", (2,), g.func_closure)
self.assertEqual(g2(), 6)
g3 = new.function(g.func_code, {}, "blah", None, g.func_closure)
self.assertEqual(g3(5), 9)
def test_closure(func, closure, exc):
self.assertRaises(exc, new.function, func.func_code, {}, "", None, closure)
try: # this used to trigger a SystemError
d = new.code(-argcount, kwonlyargcount,
nlocals, stacksize, flags, codestring,
constants, names, varnames, filename, name,
firstlineno, lnotab)
except ValueError:
pass
else:
raise TestFailed, "negative co_argcount didn't trigger an exception"
test_closure(g, None, TypeError) # invalid closure
test_closure(g, (1,), TypeError) # non-cell in closure
test_closure(g, (1, 1), ValueError) # closure is wrong size
test_closure(f, g.func_closure, ValueError) # no closure needed
try: # this used to trigger a SystemError
d = new.code(argcount, kwonlyargcount,
-nlocals, stacksize, flags, codestring,
constants, names, varnames, filename, name,
firstlineno, lnotab)
except ValueError:
pass
else:
raise TestFailed, "negative co_nlocals didn't trigger an exception"
# Note: Jython will never have new.code()
if hasattr(new, 'code'):
def test_code(self):
# bogus test of new.code()
def f(a): pass
try: # this used to trigger a Py_FatalError!
d = new.code(argcount, kwonlyargcount,
nlocals, stacksize, flags, codestring,
constants, (5,), varnames, filename, name,
firstlineno, lnotab)
except TypeError:
pass
else:
raise TestFailed, "non-string co_name didn't trigger an exception"
c = f.func_code
argcount = c.co_argcount
kwonlyargcount = c.co_kwonlyargcount
nlocals = c.co_nlocals
stacksize = c.co_stacksize
flags = c.co_flags
codestring = c.co_code
constants = c.co_consts
names = c.co_names
varnames = c.co_varnames
filename = c.co_filename
name = c.co_name
firstlineno = c.co_firstlineno
lnotab = c.co_lnotab
freevars = c.co_freevars
cellvars = c.co_cellvars
# new.code used to be a way to mutate a tuple...
class S(str): pass
t = (S("ab"),)
d = new.code(argcount, kwonlyargcount,
nlocals, stacksize, flags, codestring,
constants, t, varnames, filename, name,
firstlineno, lnotab)
verify(type(t[0]) is S, "eek, tuple changed under us!")
d = new.code(argcount, kwonlyargcount, nlocals, stacksize, flags,
codestring, constants, names, varnames, filename,
name, firstlineno, lnotab, freevars, cellvars)
if verbose:
print d
# test backwards-compatibility version with no freevars or cellvars
d = new.code(argcount, kwonlyargcount, nlocals, stacksize,
flags, codestring, constants, names, varnames,
filename, name, firstlineno, lnotab)
# negative co_argcount used to trigger a SystemError
self.assertRaises(ValueError, new.code,
-argcount, kwonlyargcount, nlocals, stacksize, flags,
codestring, constants, names, varnames, filename, name,
firstlineno, lnotab)
# negative co_nlocals used to trigger a SystemError
self.assertRaises(ValueError, new.code,
argcount, kwonlyargcount, -nlocals, stacksize, flags,
codestring, constants, names, varnames, filename, name,
firstlineno, lnotab)
# non-string co_name used to trigger a Py_FatalError
self.assertRaises(TypeError, new.code,
argcount, kwonlyargcount, nlocals, stacksize, flags,
codestring, constants, (5,), varnames, filename, name,
firstlineno, lnotab)
# new.code used to be a way to mutate a tuple...
class S(str):
pass
t = (S("ab"),)
d = new.code(argcount, kwonlyargcount, nlocals, stacksize,
flags, codestring, constants, t, varnames,
filename, name, firstlineno, lnotab)
self.assert_(type(t[0]) is S, "eek, tuple changed under us!")
def test_main():
test_support.run_unittest(NewTest)
if __name__ == "__main__":
test_main()

View File

@ -115,6 +115,28 @@ tester("ntpath.normpath('K:../.././..')", r'K:..\..\..')
tester("ntpath.normpath('C:////a/b')", r'C:\a\b')
tester("ntpath.normpath('//machine/share//a/b')", r'\\machine\share\a\b')
oldenv = os.environ.copy()
try:
os.environ.clear()
os.environ["foo"] = "bar"
os.environ["{foo"] = "baz1"
os.environ["{foo}"] = "baz2"
tester('ntpath.expandvars("foo")', "foo")
tester('ntpath.expandvars("$foo bar")', "bar bar")
tester('ntpath.expandvars("${foo}bar")', "barbar")
tester('ntpath.expandvars("$[foo]bar")', "$[foo]bar")
tester('ntpath.expandvars("$bar bar")', "$bar bar")
tester('ntpath.expandvars("$?bar")', "$?bar")
tester('ntpath.expandvars("${foo}bar")', "barbar")
tester('ntpath.expandvars("$foo}bar")', "bar}bar")
tester('ntpath.expandvars("${foo")', "${foo")
tester('ntpath.expandvars("${{foo}}")', "baz1}")
tester('ntpath.expandvars("$foo$foo")', "barbar")
tester('ntpath.expandvars("$bar$bar")', "$bar$bar")
finally:
os.environ.clear()
os.environ.update(oldenv)
# ntpath.abspath() can only be used on a system with the "nt" module
# (reasonably), so we protect this test with "import nt". This allows
# the rest of the tests for the ntpath module to be run to completion

View File

@ -109,11 +109,44 @@ class MaildirTestCase(unittest.TestCase):
self.assertEqual(len(str(msg)), len(FROM_)+len(DUMMY_MESSAGE))
self.assertEqual(n, 1)
class MboxTestCase(unittest.TestCase):
def setUp(self):
# create a new maildir mailbox to work with:
self._path = test_support.TESTFN
def tearDown(self):
os.unlink(self._path)
def test_from_regex (self):
# Testing new regex from bug #1633678
f = open(self._path, 'w')
f.write("""From fred@example.com Mon May 31 13:24:50 2004 +0200
Subject: message 1
body1
From fred@example.com Mon May 31 13:24:50 2004 -0200
Subject: message 2
body2
From fred@example.com Mon May 31 13:24:50 2004
Subject: message 3
body3
From fred@example.com Mon May 31 13:24:50 2004
Subject: message 4
body4
""")
f.close()
box = mailbox.UnixMailbox(open(self._path, 'r'))
self.assert_(len(list(iter(box))) == 4)
# XXX We still need more tests!
def test_main():
test_support.run_unittest(MaildirTestCase)
test_support.run_unittest(MaildirTestCase, MboxTestCase)
if __name__ == "__main__":

View File

@ -4,10 +4,9 @@
Particularly useful for platforms that fake popen.
"""
import os
import sys
from test.test_support import TestSkipped, reap_children
from os import popen
import unittest
from test import test_support
import os, sys
# Test that command-lines get down as we expect.
# To do this we execute:
@ -17,24 +16,32 @@ from os import popen
python = sys.executable
if ' ' in python:
python = '"' + python + '"' # quote embedded space for cmdline
def _do_test_commandline(cmdline, expected):
cmd = '%s -c "import sys;print sys.argv" %s' % (python, cmdline)
data = popen(cmd).read()
got = eval(data)[1:] # strip off argv[0]
if got != expected:
print "Error in popen commandline handling."
print " executed '%s', expected '%r', but got '%r'" \
% (cmdline, expected, got)
def _test_commandline():
_do_test_commandline("foo bar", ["foo", "bar"])
_do_test_commandline('foo "spam and eggs" "silly walk"', ["foo", "spam and eggs", "silly walk"])
_do_test_commandline('foo "a \\"quoted\\" arg" bar', ["foo", 'a "quoted" arg', "bar"])
print "popen seemed to process the command-line correctly"
class PopenTest(unittest.TestCase):
def _do_test_commandline(self, cmdline, expected):
cmd = '%s -c "import sys;print sys.argv" %s' % (python, cmdline)
data = os.popen(cmd).read()
got = eval(data)[1:] # strip off argv[0]
self.assertEqual(got, expected)
def main():
print "Test popen:"
_test_commandline()
reap_children()
def test_popen(self):
self.assertRaises(TypeError, os.popen)
self._do_test_commandline(
"foo bar",
["foo", "bar"]
)
self._do_test_commandline(
'foo "spam and eggs" "silly walk"',
["foo", "spam and eggs", "silly walk"]
)
self._do_test_commandline(
'foo "a \\"quoted\\" arg" bar',
["foo", 'a "quoted" arg', "bar"]
)
test_support.reap_children()
main()
def test_main():
test_support.run_unittest(PopenTest)
if __name__ == "__main__":
test_main()

View File

@ -374,6 +374,8 @@ class PosixPathTest(unittest.TestCase):
self.assertEqual(posixpath.expandvars("$foo}bar"), "bar}bar")
self.assertEqual(posixpath.expandvars("${foo"), "${foo")
self.assertEqual(posixpath.expandvars("${{foo}}"), "baz1}")
self.assertEqual(posixpath.expandvars("$foo$foo"), "barbar")
self.assertEqual(posixpath.expandvars("$bar$bar"), "$bar$bar")
finally:
os.environ.clear()
os.environ.update(oldenv)

View File

@ -517,6 +517,14 @@ class TestModule(unittest.TestCase):
# tests validity but not completeness of the __all__ list
self.failUnless(set(random.__all__) <= set(dir(random)))
def test_random_subclass_with_kwargs(self):
# SF bug #1486663 -- this used to erroneously raise a TypeError
class Subclass(random.Random):
def __init__(self, newarg=None):
random.Random.__init__(self)
Subclass(newarg=1)
def test_main(verbose=None):
testclasses = [WichmannHill_TestBasicOps,
MersenneTwister_TestBasicOps,

View File

@ -1,56 +1,96 @@
import os
import resource
import unittest
from test import test_support
from test.test_support import TESTFN
# This test is checking a few specific problem spots. RLIMIT_FSIZE
# should be RLIM_INFINITY, which will be a really big number on a
# platform with large file support. On these platforms, we need to
# test that the get/setrlimit functions properly convert the number to
# a C long long and that the conversion doesn't raise an error.
import os, resource
try:
cur, max = resource.getrlimit(resource.RLIMIT_FSIZE)
except AttributeError:
pass
else:
print resource.RLIM_INFINITY == max
resource.setrlimit(resource.RLIMIT_FSIZE, (cur, max))
# This test is checking a few specific problem spots with the resource module.
# Now check to see what happens when the RLIMIT_FSIZE is small. Some
# versions of Python were terminated by an uncaught SIGXFSZ, but
# pythonrun.c has been fixed to ignore that exception. If so, the
# write() should return EFBIG when the limit is exceeded.
class ResourceTest(unittest.TestCase):
# At least one platform has an unlimited RLIMIT_FSIZE and attempts to
# change it raise ValueError instead.
def test_args(self):
self.assertRaises(TypeError, resource.getrlimit)
self.assertRaises(TypeError, resource.getrlimit, 42, 42)
self.assertRaises(TypeError, resource.setrlimit)
self.assertRaises(TypeError, resource.setrlimit, 42, 42, 42)
try:
try:
resource.setrlimit(resource.RLIMIT_FSIZE, (1024, max))
limit_set = 1
except ValueError:
limit_set = 0
f = open(TESTFN, "wb")
f.write("X" * 1024)
try:
f.write("Y")
f.flush()
except IOError:
if not limit_set:
raise
f.close()
os.unlink(TESTFN)
finally:
resource.setrlimit(resource.RLIMIT_FSIZE, (cur, max))
def test_fsize_ismax(self):
try:
(cur, max) = resource.getrlimit(resource.RLIMIT_FSIZE)
except AttributeError:
pass
else:
# RLIMIT_FSIZE should be RLIM_INFINITY, which will be a really big
# number on a platform with large file support. On these platforms,
# we need to test that the get/setrlimit functions properly convert
# the number to a C long long and that the conversion doesn't raise
# an error.
self.assertEqual(resource.RLIM_INFINITY, max)
resource.setrlimit(resource.RLIMIT_FSIZE, (cur, max))
# And be sure that setrlimit is checking for really large values
too_big = 10**50
try:
resource.setrlimit(resource.RLIMIT_FSIZE, (too_big, max))
except (OverflowError, ValueError):
pass
try:
resource.setrlimit(resource.RLIMIT_FSIZE, (max, too_big))
except (OverflowError, ValueError):
pass
def test_fsize_enforced(self):
try:
(cur, max) = resource.getrlimit(resource.RLIMIT_FSIZE)
except AttributeError:
pass
else:
# Check to see what happens when the RLIMIT_FSIZE is small. Some
# versions of Python were terminated by an uncaught SIGXFSZ, but
# pythonrun.c has been fixed to ignore that exception. If so, the
# write() should return EFBIG when the limit is exceeded.
# At least one platform has an unlimited RLIMIT_FSIZE and attempts
# to change it raise ValueError instead.
try:
try:
resource.setrlimit(resource.RLIMIT_FSIZE, (1024, max))
limit_set = True
except ValueError:
limit_set = False
f = open(test_support.TESTFN, "wb")
f.write("X" * 1024)
try:
f.write("Y")
f.flush()
except IOError:
if not limit_set:
raise
f.close()
os.unlink(test_support.TESTFN)
finally:
resource.setrlimit(resource.RLIMIT_FSIZE, (cur, max))
def test_fsize_toobig(self):
# Be sure that setrlimit is checking for really large values
too_big = 10**50
try:
(cur, max) = resource.getrlimit(resource.RLIMIT_FSIZE)
except AttributeError:
pass
else:
try:
resource.setrlimit(resource.RLIMIT_FSIZE, (too_big, max))
except (OverflowError, ValueError):
pass
try:
resource.setrlimit(resource.RLIMIT_FSIZE, (max, too_big))
except (OverflowError, ValueError):
pass
def test_getrusage(self):
self.assertRaises(TypeError, resource.getrusage)
self.assertRaises(TypeError, resource.getrusage, 42, 42)
usageself = resource.getrusage(resource.RUSAGE_SELF)
usagechildren = resource.getrusage(resource.RUSAGE_CHILDREN)
# May not be available on all systems.
try:
usageboth = resource.getrusage(resource.RUSAGE_BOTH)
except (ValueError, AttributeError):
pass
def test_main(verbose=None):
test_support.run_unittest(ResourceTest)
if __name__ == "__main__":
test_main()

View File

@ -809,6 +809,31 @@ class SmallBufferedFileObjectClassTestCase(FileObjectClassTestCase):
bufsize = 2 # Exercise the buffering code
class Urllib2FileobjectTest(unittest.TestCase):
# urllib2.HTTPHandler has "borrowed" socket._fileobject, and requires that
# it close the socket if the close c'tor argument is true
def testClose(self):
class MockSocket:
closed = False
def flush(self): pass
def close(self): self.closed = True
# must not close unless we request it: the original use of _fileobject
# by module socket requires that the underlying socket not be closed until
# the _socketobject that created the _fileobject is closed
s = MockSocket()
f = socket._fileobject(s)
f.close()
self.assert_(not s.closed)
s = MockSocket()
f = socket._fileobject(s, close=True)
f.close()
self.assert_(s.closed)
class TCPTimeoutTest(SocketTCPTest):
def testTCPTimeout(self):
@ -961,7 +986,8 @@ def test_main():
FileObjectClassTestCase,
UnbufferedFileObjectClassTestCase,
LineBufferedFileObjectClassTestCase,
SmallBufferedFileObjectClassTestCase
SmallBufferedFileObjectClassTestCase,
Urllib2FileobjectTest,
])
if hasattr(socket, "socketpair"):
tests.append(BasicSocketPairTest)

View File

@ -84,8 +84,8 @@ sz = struct.calcsize('i')
if sz * 3 != struct.calcsize('iii'):
raise TestFailed, 'inconsistent sizes'
fmt = 'cbxxxxxxhhhhiillffd'
fmt3 = '3c3b18x12h6i6l6f3d'
fmt = 'cbxxxxxxhhhhiillffdt'
fmt3 = '3c3b18x12h6i6l6f3d3t'
sz = struct.calcsize(fmt)
sz3 = struct.calcsize(fmt3)
if sz * 3 != sz3:
@ -108,19 +108,21 @@ i = 65535
l = 65536
f = 3.1415
d = 3.1415
t = True
for prefix in ('', '@', '<', '>', '=', '!'):
for format in ('xcbhilfd', 'xcBHILfd'):
for format in ('xcbhilfdt', 'xcBHILfdt'):
format = prefix + format
if verbose:
print "trying:", format
s = struct.pack(format, c, b, h, i, l, f, d)
cp, bp, hp, ip, lp, fp, dp = struct.unpack(format, s)
s = struct.pack(format, c, b, h, i, l, f, d, t)
cp, bp, hp, ip, lp, fp, dp, tp = struct.unpack(format, s)
if (cp != c or bp != b or hp != h or ip != i or lp != l or
int(100 * fp) != int(100 * f) or int(100 * dp) != int(100 * d)):
int(100 * fp) != int(100 * f) or int(100 * dp) != int(100 * d) or
tp != t):
# ^^^ calculate only to two decimal places
raise TestFailed, "unpack/pack not transitive (%s, %s)" % (
str(format), str((cp, bp, hp, ip, lp, fp, dp)))
str(format), str((cp, bp, hp, ip, lp, fp, dp, tp)))
# Test some of the new features in detail
@ -158,6 +160,11 @@ tests = [
('f', -2.0, '\300\000\000\000', '\000\000\000\300', 0),
('d', -2.0, '\300\000\000\000\000\000\000\000',
'\000\000\000\000\000\000\000\300', 0),
('t', 0, '\0', '\0', 0),
('t', 3, '\1', '\1', 1),
('t', True, '\1', '\1', 0),
('t', [], '\0', '\0', 1),
('t', (1,), '\1', '\1', 1),
]
for fmt, arg, big, lil, asy in tests:
@ -612,3 +619,50 @@ def test_pack_into_fn():
test_unpack_from()
test_pack_into()
test_pack_into_fn()
def test_bool():
for prefix in tuple("<>!=")+('',):
false = (), [], [], '', 0
true = [1], 'test', 5, -1, 0xffffffff+1, 0xffffffff/2
falseFormat = prefix + 't' * len(false)
if verbose:
print 'trying bool pack/unpack on', false, 'using format', falseFormat
packedFalse = struct.pack(falseFormat, *false)
unpackedFalse = struct.unpack(falseFormat, packedFalse)
trueFormat = prefix + 't' * len(true)
if verbose:
print 'trying bool pack/unpack on', true, 'using format', trueFormat
packedTrue = struct.pack(trueFormat, *true)
unpackedTrue = struct.unpack(trueFormat, packedTrue)
if len(true) != len(unpackedTrue):
raise TestFailed('unpacked true array is not of same size as input')
if len(false) != len(unpackedFalse):
raise TestFailed('unpacked false array is not of same size as input')
for t in unpackedFalse:
if t is not False:
raise TestFailed('%r did not unpack as False' % t)
for t in unpackedTrue:
if t is not True:
raise TestFailed('%r did not unpack as false' % t)
if prefix and verbose:
print 'trying size of bool with format %r' % (prefix+'t')
packed = struct.pack(prefix+'t', 1)
if len(packed) != struct.calcsize(prefix+'t'):
raise TestFailed('packed length is not equal to calculated size')
if len(packed) != 1 and prefix:
raise TestFailed('encoded bool is not one byte: %r' % packed)
elif not prefix and verbose:
print 'size of bool in native format is %i' % (len(packed))
for c in '\x01\x7f\xff\x0f\xf0':
if struct.unpack('>t', c)[0] is not True:
raise TestFailed('%c did not unpack as True' % c)
test_bool()

View File

@ -64,6 +64,27 @@ class AuthTests(unittest.TestCase):
# urllib2.urlopen, "http://evil:thing@example.com")
class CloseSocketTest(unittest.TestCase):
def test_close(self):
import socket, httplib, gc
# calling .close() on urllib2's response objects should close the
# underlying socket
# delve deep into response to fetch socket._socketobject
response = urllib2.urlopen("http://www.python.org/")
abused_fileobject = response.fp
self.assert_(abused_fileobject.__class__ is socket._fileobject)
httpresponse = abused_fileobject._sock
self.assert_(httpresponse.__class__ is httplib.HTTPResponse)
fileobject = httpresponse.fp
self.assert_(fileobject.__class__ is socket._fileobject)
self.assert_(not fileobject.closed)
response.close()
self.assert_(fileobject.closed)
class urlopenNetworkTests(unittest.TestCase):
"""Tests urllib2.urlopen using the network.
@ -263,8 +284,12 @@ class OtherNetworkTests(unittest.TestCase):
def test_main():
test_support.requires("network")
test_support.run_unittest(URLTimeoutTest, urlopenNetworkTests,
AuthTests, OtherNetworkTests)
test_support.run_unittest(URLTimeoutTest,
urlopenNetworkTests,
AuthTests,
OtherNetworkTests,
CloseSocketTest,
)
if __name__ == "__main__":
test_main()

View File

@ -114,11 +114,11 @@ class UUFileTest(unittest.TestCase):
def test_encode(self):
try:
fin = open(self.tmpin, 'w')
fin = open(self.tmpin, 'wb')
fin.write(plaintext)
fin.close()
fin = open(self.tmpin, 'r')
fin = open(self.tmpin, 'rb')
fout = open(self.tmpout, 'w')
uu.encode(fin, fout, self.tmpin, mode=0644)
fin.close()

View File

@ -6,6 +6,8 @@ import weakref
from test import test_support
# Used in ReferencesTestCase.test_ref_created_during_del() .
ref_from_del = None
class C:
def method(self):
@ -630,6 +632,18 @@ class ReferencesTestCase(TestBase):
finally:
gc.set_threshold(*thresholds)
def test_ref_created_during_del(self):
# Bug #1377858
# A weakref created in an object's __del__() would crash the
# interpreter when the weakref was cleaned up since it would refer to
# non-existent memory. This test should not segfault the interpreter.
class Target(object):
def __del__(self):
global ref_from_del
ref_from_del = weakref.ref(self)
w = Target()
class SubclassableWeakrefTestCase(unittest.TestCase):

View File

@ -452,7 +452,7 @@ class URLopener:
def open_local_file(self, url):
"""Use local file."""
import mimetypes, mimetools, email.Utils
import mimetypes, mimetools, email.utils
try:
from cStringIO import StringIO
except ImportError:
@ -464,7 +464,7 @@ class URLopener:
except OSError as e:
raise IOError(e.errno, e.strerror, e.filename)
size = stats.st_size
modified = email.Utils.formatdate(stats.st_mtime, usegmt=True)
modified = email.utils.formatdate(stats.st_mtime, usegmt=True)
mtype = mimetypes.guess_type(url)[0]
headers = mimetools.Message(StringIO(
'Content-Type: %s\nContent-Length: %d\nLast-modified: %s\n' %

View File

@ -1087,7 +1087,7 @@ class AbstractHTTPHandler(BaseHandler):
# out of socket._fileobject() and into a base class.
r.recv = r.read
fp = socket._fileobject(r)
fp = socket._fileobject(r, close=True)
resp = addinfourl(fp, r.msg, req.get_full_url())
resp.code = r.status
@ -1209,14 +1209,14 @@ class FileHandler(BaseHandler):
# not entirely sure what the rules are here
def open_local_file(self, req):
import email.Utils
import email.utils
import mimetypes
host = req.get_host()
file = req.get_selector()
localfile = url2pathname(file)
stats = os.stat(localfile)
size = stats.st_size
modified = email.Utils.formatdate(stats.st_mtime, usegmt=True)
modified = email.utils.formatdate(stats.st_mtime, usegmt=True)
mtype = mimetypes.guess_type(file)[0]
headers = mimetools.Message(StringIO(
'Content-type: %s\nContent-length: %d\nLast-modified: %s\n' %

View File

@ -68,22 +68,25 @@ EXPORT(void) _testfunc_v(int a, int b, int *presult)
EXPORT(int) _testfunc_i_bhilfd(signed char b, short h, int i, long l, float f, double d)
{
// printf("_testfunc_i_bhilfd got %d %d %d %ld %f %f\n",
// b, h, i, l, f, d);
/* printf("_testfunc_i_bhilfd got %d %d %d %ld %f %f\n",
b, h, i, l, f, d);
*/
return (int)(b + h + i + l + f + d);
}
EXPORT(float) _testfunc_f_bhilfd(signed char b, short h, int i, long l, float f, double d)
{
// printf("_testfunc_f_bhilfd got %d %d %d %ld %f %f\n",
// b, h, i, l, f, d);
/* printf("_testfunc_f_bhilfd got %d %d %d %ld %f %f\n",
b, h, i, l, f, d);
*/
return (float)(b + h + i + l + f + d);
}
EXPORT(double) _testfunc_d_bhilfd(signed char b, short h, int i, long l, float f, double d)
{
// printf("_testfunc_d_bhilfd got %d %d %d %ld %f %f\n",
// b, h, i, l, f, d);
/* printf("_testfunc_d_bhilfd got %d %d %d %ld %f %f\n",
b, h, i, l, f, d);
*/
return (double)(b + h + i + l + f + d);
}
@ -378,8 +381,9 @@ PyAPI_FUNC(int) unpack_bitfields(struct BITS *bits, char name)
}
PyMethodDef module_methods[] = {
// {"get_last_tf_arg_s", get_last_tf_arg_s, METH_NOARGS},
// {"get_last_tf_arg_u", get_last_tf_arg_u, METH_NOARGS},
/* {"get_last_tf_arg_s", get_last_tf_arg_s, METH_NOARGS},
{"get_last_tf_arg_u", get_last_tf_arg_u, METH_NOARGS},
*/
{"func_si", py_func_si, METH_VARARGS},
{"func", py_func, METH_NOARGS},
{ NULL, NULL, 0, NULL},

View File

@ -481,7 +481,7 @@ random_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
RandomObject *self;
PyObject *tmp;
if (!_PyArg_NoKeywords("Random()", kwds))
if (type == &Random_Type && !_PyArg_NoKeywords("Random()", kwds))
return NULL;
self = (RandomObject *)type->tp_alloc(type, 0);

View File

@ -104,6 +104,15 @@ typedef struct { char c; PY_LONG_LONG x; } s_long_long;
#define LONG_LONG_ALIGN (sizeof(s_long_long) - sizeof(PY_LONG_LONG))
#endif
#ifdef HAVE_C99_BOOL
#define BOOL_TYPE _Bool
typedef struct { char c; _Bool x; } s_bool;
#define BOOL_ALIGN (sizeof(s_bool) - sizeof(BOOL_TYPE))
#else
#define BOOL_TYPE char
#define BOOL_ALIGN 0
#endif
#define STRINGIFY(x) #x
#ifdef __powerc
@ -533,6 +542,15 @@ nu_ulonglong(const char *p, const formatdef *f)
#endif
static PyObject *
nu_bool(const char *p, const formatdef *f)
{
BOOL_TYPE x;
memcpy((char *)&x, p, sizeof x);
return PyBool_FromLong(x != 0);
}
static PyObject *
nu_float(const char *p, const formatdef *f)
{
@ -709,6 +727,16 @@ np_ulonglong(char *p, PyObject *v, const formatdef *f)
}
#endif
static int
np_bool(char *p, PyObject *v, const formatdef *f)
{
BOOL_TYPE y;
y = PyObject_IsTrue(v);
memcpy(p, (char *)&y, sizeof y);
return 0;
}
static int
np_float(char *p, PyObject *v, const formatdef *f)
{
@ -769,6 +797,7 @@ static formatdef native_table[] = {
{'q', sizeof(PY_LONG_LONG), LONG_LONG_ALIGN, nu_longlong, np_longlong},
{'Q', sizeof(PY_LONG_LONG), LONG_LONG_ALIGN, nu_ulonglong,np_ulonglong},
#endif
{'t', sizeof(BOOL_TYPE), BOOL_ALIGN, nu_bool, np_bool},
{'f', sizeof(float), FLOAT_ALIGN, nu_float, np_float},
{'d', sizeof(double), DOUBLE_ALIGN, nu_double, np_double},
{'P', sizeof(void *), VOID_P_ALIGN, nu_void_p, np_void_p},
@ -863,6 +892,14 @@ bu_double(const char *p, const formatdef *f)
return unpack_double(p, 0);
}
static PyObject *
bu_bool(const char *p, const formatdef *f)
{
char x;
memcpy((char *)&x, p, sizeof x);
return PyBool_FromLong(x != 0);
}
static int
bp_int(char *p, PyObject *v, const formatdef *f)
{
@ -967,6 +1004,15 @@ bp_double(char *p, PyObject *v, const formatdef *f)
return _PyFloat_Pack8(x, (unsigned char *)p, 0);
}
static int
bp_bool(char *p, PyObject *v, const formatdef *f)
{
char y;
y = PyObject_IsTrue(v);
memcpy(p, (char *)&y, sizeof y);
return 0;
}
static formatdef bigendian_table[] = {
{'x', 1, 0, NULL},
#ifdef PY_STRUCT_OVERFLOW_MASKING
@ -988,6 +1034,7 @@ static formatdef bigendian_table[] = {
{'L', 4, 0, bu_uint, bp_uint},
{'q', 8, 0, bu_longlong, bp_longlong},
{'Q', 8, 0, bu_ulonglong, bp_ulonglong},
{'t', 1, 0, bu_bool, bp_bool},
{'f', 4, 0, bu_float, bp_float},
{'d', 8, 0, bu_double, bp_double},
{0}
@ -1206,6 +1253,8 @@ static formatdef lilendian_table[] = {
{'L', 4, 0, lu_uint, lp_uint},
{'q', 8, 0, lu_longlong, lp_longlong},
{'Q', 8, 0, lu_ulonglong, lp_ulonglong},
{'t', 1, 0, bu_bool, bp_bool}, /* Std rep not endian dep,
but potentially different from native rep -- reuse bx_bool funcs. */
{'f', 4, 0, lu_float, lp_float},
{'d', 8, 0, lu_double, lp_double},
{0}

View File

@ -1797,7 +1797,7 @@ array_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
PyObject *initial = NULL, *it = NULL;
struct arraydescr *descr;
if (!_PyArg_NoKeywords("array.array()", kwds))
if (type == &Arraytype && !_PyArg_NoKeywords("array.array()", kwds))
return NULL;
if (!PyArg_ParseTuple(args, "c|O:array", &c, &initial))

View File

@ -95,7 +95,7 @@ deque_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
dequeobject *deque;
block *b;
if (!_PyArg_NoKeywords("deque()", kwds))
if (type == &deque_type && !_PyArg_NoKeywords("deque()", kwds))
return NULL;
/* create dequeobject structure */

View File

@ -681,7 +681,7 @@ cycle_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
PyObject *saved;
cycleobject *lz;
if (!_PyArg_NoKeywords("cycle()", kwds))
if (type == &cycle_type && !_PyArg_NoKeywords("cycle()", kwds))
return NULL;
if (!PyArg_UnpackTuple(args, "cycle", 1, 1, &iterable))
@ -831,7 +831,7 @@ dropwhile_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
PyObject *it;
dropwhileobject *lz;
if (!_PyArg_NoKeywords("dropwhile()", kwds))
if (type == &dropwhile_type && !_PyArg_NoKeywords("dropwhile()", kwds))
return NULL;
if (!PyArg_UnpackTuple(args, "dropwhile", 2, 2, &func, &seq))
@ -975,7 +975,7 @@ takewhile_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
PyObject *it;
takewhileobject *lz;
if (!_PyArg_NoKeywords("takewhile()", kwds))
if (type == &takewhile_type && !_PyArg_NoKeywords("takewhile()", kwds))
return NULL;
if (!PyArg_UnpackTuple(args, "takewhile", 2, 2, &func, &seq))
@ -1120,7 +1120,7 @@ islice_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
Py_ssize_t numargs;
isliceobject *lz;
if (!_PyArg_NoKeywords("islice()", kwds))
if (type == &islice_type && !_PyArg_NoKeywords("islice()", kwds))
return NULL;
if (!PyArg_UnpackTuple(args, "islice", 2, 4, &seq, &a1, &a2, &a3))
@ -1311,7 +1311,7 @@ starmap_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
PyObject *it;
starmapobject *lz;
if (!_PyArg_NoKeywords("starmap()", kwds))
if (type == &starmap_type && !_PyArg_NoKeywords("starmap()", kwds))
return NULL;
if (!PyArg_UnpackTuple(args, "starmap", 2, 2, &func, &seq))
@ -1443,7 +1443,7 @@ imap_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
imapobject *lz;
Py_ssize_t numargs, i;
if (!_PyArg_NoKeywords("imap()", kwds))
if (type == &imap_type && !_PyArg_NoKeywords("imap()", kwds))
return NULL;
numargs = PyTuple_Size(args);
@ -1625,7 +1625,7 @@ chain_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
Py_ssize_t i;
PyObject *ittuple;
if (!_PyArg_NoKeywords("chain()", kwds))
if (type == &chain_type && !_PyArg_NoKeywords("chain()", kwds))
return NULL;
/* obtain iterators */
@ -1768,7 +1768,7 @@ ifilter_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
PyObject *it;
ifilterobject *lz;
if (!_PyArg_NoKeywords("ifilter()", kwds))
if (type == &ifilter_type && !_PyArg_NoKeywords("ifilter()", kwds))
return NULL;
if (!PyArg_UnpackTuple(args, "ifilter", 2, 2, &func, &seq))
@ -1912,7 +1912,8 @@ ifilterfalse_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
PyObject *it;
ifilterfalseobject *lz;
if (!_PyArg_NoKeywords("ifilterfalse()", kwds))
if (type == &ifilterfalse_type &&
!_PyArg_NoKeywords("ifilterfalse()", kwds))
return NULL;
if (!PyArg_UnpackTuple(args, "ifilterfalse", 2, 2, &func, &seq))
@ -2054,7 +2055,7 @@ count_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
countobject *lz;
Py_ssize_t cnt = 0;
if (!_PyArg_NoKeywords("count()", kwds))
if (type == &count_type && !_PyArg_NoKeywords("count()", kwds))
return NULL;
if (!PyArg_ParseTuple(args, "|n:count", &cnt))
@ -2153,7 +2154,7 @@ izip_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
PyObject *result;
Py_ssize_t tuplesize = PySequence_Length(args);
if (!_PyArg_NoKeywords("izip()", kwds))
if (type == &izip_type && !_PyArg_NoKeywords("izip()", kwds))
return NULL;
/* args must be a tuple */
@ -2336,7 +2337,7 @@ repeat_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
PyObject *element;
Py_ssize_t cnt = -1;
if (!_PyArg_NoKeywords("repeat()", kwds))
if (type == &repeat_type && !_PyArg_NoKeywords("repeat()", kwds))
return NULL;
if (!PyArg_ParseTuple(args, "O|n:repeat", &element, &cnt))

View File

@ -354,6 +354,8 @@ PyFile_SetEncoding(PyObject *f, const char *enc)
{
PyFileObject *file = (PyFileObject*)f;
PyObject *str = PyString_FromString(enc);
assert(PyFile_Check(f));
if (!str)
return 0;
Py_DECREF(file->f_encoding);

View File

@ -314,7 +314,7 @@ PyObject_Print(PyObject *op, FILE *fp, int flags)
/* For debugging convenience. Set a breakpoint here and call it from your DLL */
void
_Py_Break(void)
_Py_BreakPoint(void)
{
}

View File

@ -655,6 +655,17 @@ subtype_dealloc(PyObject *self)
goto endlabel; /* resurrected */
else
_PyObject_GC_UNTRACK(self);
/* New weakrefs could be created during the finalizer call.
If this occurs, clear them out without calling their
finalizers since they might rely on part of the object
being finalized that has already been destroyed. */
if (type->tp_weaklistoffset && !base->tp_weaklistoffset) {
/* Modeled after GET_WEAKREFS_LISTPTR() */
PyWeakReference **list = (PyWeakReference **) \
PyObject_GET_WEAKREFS_LISTPTR(self);
while (*list)
_PyWeakref_ClearRef(*list);
}
}
/* Clear slots up to the nearest base with a different tp_dealloc */

View File

@ -57,6 +57,9 @@ clear_weakref(PyWeakReference *self)
PyWeakref_GET_OBJECT(self));
if (*list == self)
/* If 'self' is the end of the list (and thus self->wr_next == NULL)
then the weakref list itself (and thus the value of *list) will
end up being set to NULL. */
*list = self->wr_next;
self->wr_object = Py_None;
if (self->wr_prev != NULL)

View File

@ -130,7 +130,7 @@
ATLMinimizesCRunTimeLibraryUsage="FALSE">
<Tool
Name="VCCLCompilerTool"
AdditionalOptions=" /USECL:MS_ITANIUM"
AdditionalOptions=" /USECL:MS_ITANIUM /GS-"
Optimization="2"
InlineFunctionExpansion="1"
AdditionalIncludeDirectories="..\Include;..\PC;&quot;..\..\db-4.4.20\build_win32&quot;"

View File

@ -129,7 +129,7 @@
ATLMinimizesCRunTimeLibraryUsage="FALSE">
<Tool
Name="VCCLCompilerTool"
AdditionalOptions=" /USECL:MS_ITANIUM"
AdditionalOptions=" /USECL:MS_ITANIUM /GS-"
Optimization="2"
InlineFunctionExpansion="1"
AdditionalIncludeDirectories="..\Include,..\PC,..\Modules\expat"

View File

@ -129,7 +129,7 @@
CharacterSet="2">
<Tool
Name="VCCLCompilerTool"
AdditionalOptions=" /USECL:MS_ITANIUM"
AdditionalOptions=" /USECL:MS_ITANIUM /GS-"
Optimization="2"
InlineFunctionExpansion="1"
AdditionalIncludeDirectories="..\Include,..\PC"
@ -150,7 +150,7 @@
<Tool
Name="VCLinkerTool"
AdditionalOptions=" /MACHINE:IA64 /USELINK:MS_SDK"
AdditionalDependencies="fci.lib msi.lib rpcrt4.lib"
AdditionalDependencies="fci.lib msi.lib rpcrt4.lib bufferoverflowU.lib"
OutputFile="./_msi.pyd"
LinkIncremental="1"
SuppressStartupBanner="TRUE"

View File

@ -128,7 +128,7 @@
ATLMinimizesCRunTimeLibraryUsage="FALSE">
<Tool
Name="VCCLCompilerTool"
AdditionalOptions=" /USECL:MS_ITANIUM"
AdditionalOptions=" /USECL:MS_ITANIUM /GS-"
Optimization="2"
InlineFunctionExpansion="1"
AdditionalIncludeDirectories="..\Include,..\PC"

View File

@ -131,7 +131,7 @@
ATLMinimizesCRunTimeLibraryUsage="FALSE">
<Tool
Name="VCCLCompilerTool"
AdditionalOptions=" /USECL:MS_ITANIUM"
AdditionalOptions=" /USECL:MS_ITANIUM /GS-"
Optimization="2"
InlineFunctionExpansion="1"
AdditionalIncludeDirectories="..\Include;..\PC;..\..\sqlite-source-3.3.4"
@ -193,7 +193,7 @@
ATLMinimizesCRunTimeLibraryUsage="FALSE">
<Tool
Name="VCCLCompilerTool"
AdditionalOptions=" /USECL:MS_OPTERON"
AdditionalOptions=" /USECL:MS_OPTERON /GS-"
Optimization="2"
InlineFunctionExpansion="1"
AdditionalIncludeDirectories="..\Include;..\PC;..\..\sqlite-source-3.3.4"

View File

@ -31,7 +31,7 @@ _ssl$(SUFFIX): $(SSL_SOURCE) $(SSL_LIB_DIR)/libeay32.lib $(SSL_LIB_DIR)/ssleay32
_hashlib$(SUFFIX): $(HASH_SOURCE) $(SSL_LIB_DIR)/libeay32.lib ../PC/*.h ../Include/*.h
@if not exist "$(TEMP)/_hashlib/." mkdir "$(TEMP)/_hashlib"
cl /nologo /c $(HASH_SOURCE) $(CFLAGS) /Fo$(TEMP)\_hashlib\$*.obj $(INCLUDES)
cl /nologo /c $(HASH_SOURCE) $(CFLAGS) $(EXTRA_CFLAGS) /Fo$(TEMP)\_hashlib\$*.obj $(INCLUDES)
link /nologo @<<
/dll /out:_hashlib$(SUFFIX) $(HASH_LIBS) $(TEMP)\_hashlib\$*.obj
<<

View File

@ -126,7 +126,7 @@
CharacterSet="2">
<Tool
Name="VCCLCompilerTool"
AdditionalOptions=" /USECL:MS_ITANIUM"
AdditionalOptions=" /USECL:MS_ITANIUM /GS-"
Optimization="2"
InlineFunctionExpansion="1"
AdditionalIncludeDirectories="..\Include,..\PC"

View File

@ -130,7 +130,7 @@
ATLMinimizesCRunTimeLibraryUsage="FALSE">
<Tool
Name="VCCLCompilerTool"
AdditionalOptions=" /USECL:MS_ITANIUM"
AdditionalOptions=" /USECL:MS_ITANIUM /GS-"
Optimization="2"
InlineFunctionExpansion="1"
AdditionalIncludeDirectories="..\..\tcltk\include,..\Include,..\PC"

View File

@ -169,6 +169,8 @@ def main():
defs = "SSL_DIR=\"%s\"" % (ssl_dir,)
if debug:
defs = defs + " " + "DEBUG=1"
if arch in ('amd64', 'ia64'):
defs = defs + " EXTRA_CFLAGS=/GS-"
makeCommand = 'nmake /nologo -f _ssl.mak ' + defs + " " + make_flags
print "Executing:", makeCommand
sys.stdout.flush()

View File

@ -137,7 +137,7 @@ nmake /nologo /f makefile.msc lib
ATLMinimizesCRunTimeLibraryUsage="FALSE">
<Tool
Name="VCCLCompilerTool"
AdditionalOptions=" /USECL:MS_ITANIUM"
AdditionalOptions=" /USECL:MS_ITANIUM /GS-"
Optimization="2"
InlineFunctionExpansion="1"
AdditionalIncludeDirectories="..\Include,..\PC,..\..\bzip2-1.0.3"

View File

@ -128,7 +128,7 @@
ATLMinimizesCRunTimeLibraryUsage="FALSE">
<Tool
Name="VCCLCompilerTool"
AdditionalOptions=" /USECL:MS_ITANIUM"
AdditionalOptions=" /USECL:MS_ITANIUM /GS-"
Optimization="2"
InlineFunctionExpansion="1"
AdditionalIncludeDirectories="..\Include,..\PC,..\Modules\expat"
@ -189,7 +189,7 @@
ATLMinimizesCRunTimeLibraryUsage="FALSE">
<Tool
Name="VCCLCompilerTool"
AdditionalOptions=" /USECL:MS_OPTERON"
AdditionalOptions=" /USECL:MS_OPTERON /GS-"
Optimization="2"
InlineFunctionExpansion="1"
AdditionalIncludeDirectories="..\Include,..\PC,..\Modules\expat"

View File

@ -137,7 +137,7 @@
CharacterSet="2">
<Tool
Name="VCCLCompilerTool"
AdditionalOptions=" /USECL:MS_ITANIUM /VSEXTCOMP_VERBOSE"
AdditionalOptions=" /USECL:MS_ITANIUM /GS-"
Optimization="2"
InlineFunctionExpansion="1"
AdditionalIncludeDirectories="..\Include,..\PC"

View File

@ -144,7 +144,7 @@
ATLMinimizesCRunTimeLibraryUsage="FALSE">
<Tool
Name="VCCLCompilerTool"
AdditionalOptions=" /USECL:MS_ITANIUM"
AdditionalOptions=" /USECL:MS_ITANIUM /GS-"
Optimization="2"
InlineFunctionExpansion="1"
AdditionalIncludeDirectories="..\Include,..\PC"

View File

@ -130,7 +130,7 @@
ATLMinimizesCRunTimeLibraryUsage="FALSE">
<Tool
Name="VCCLCompilerTool"
AdditionalOptions=" /USECL:MS_ITANIUM"
AdditionalOptions=" /USECL:MS_ITANIUM /GS-"
Optimization="2"
InlineFunctionExpansion="1"
AdditionalIncludeDirectories="..\Include,..\PC"

View File

@ -130,7 +130,7 @@
ATLMinimizesCRunTimeLibraryUsage="FALSE">
<Tool
Name="VCCLCompilerTool"
AdditionalOptions=" /USECL:MS_ITANIUM"
AdditionalOptions=" /USECL:MS_ITANIUM /GS-"
Optimization="2"
InlineFunctionExpansion="1"
AdditionalIncludeDirectories="..\Include,..\PC"

View File

@ -126,7 +126,7 @@
CharacterSet="2">
<Tool
Name="VCCLCompilerTool"
AdditionalOptions=" /USECL:MS_ITANIUM"
AdditionalOptions=" /USECL:MS_ITANIUM /GS-"
Optimization="2"
InlineFunctionExpansion="1"
AdditionalIncludeDirectories="..\Include,..\PC"

View File

@ -128,7 +128,7 @@
CharacterSet="2">
<Tool
Name="VCCLCompilerTool"
AdditionalOptions=" /USECL:MS_ITANIUM"
AdditionalOptions=" /USECL:MS_ITANIUM /GS-"
Optimization="2"
InlineFunctionExpansion="1"
AdditionalIncludeDirectories="..\Include,..\PC"

View File

@ -260,7 +260,12 @@ class PrototypeVisitor(EmitVisitor):
argstr += ", PyArena *arena"
else:
argstr = "PyArena *arena"
self.emit("%s %s(%s);" % (ctype, name, argstr), 0)
margs = "a0"
for i in range(1, len(args)+1):
margs += ", a%d" % i
self.emit("#define %s(%s) _Py_%s(%s)" % (name, margs, name, margs), 0,
reflow = 0)
self.emit("%s _Py_%s(%s);" % (ctype, name, argstr), 0)
def visitProduct(self, prod, name):
self.emit_function(name, get_c_type(name),

View File

@ -273,7 +273,8 @@ Py_InitializeEx(int install_sigs)
sys_isatty = PyObject_CallMethod(sys_stream, "isatty", "");
if (!sys_isatty)
PyErr_Clear();
if(sys_isatty && PyObject_IsTrue(sys_isatty)) {
if(sys_isatty && PyObject_IsTrue(sys_isatty) &&
PyFile_Check(sys_stream)) {
if (!PyFile_SetEncoding(sys_stream, codeset))
Py_FatalError("Cannot set codeset of stdin");
}
@ -283,7 +284,8 @@ Py_InitializeEx(int install_sigs)
sys_isatty = PyObject_CallMethod(sys_stream, "isatty", "");
if (!sys_isatty)
PyErr_Clear();
if(sys_isatty && PyObject_IsTrue(sys_isatty)) {
if(sys_isatty && PyObject_IsTrue(sys_isatty) &&
PyFile_Check(sys_stream)) {
if (!PyFile_SetEncoding(sys_stream, codeset))
Py_FatalError("Cannot set codeset of stdout");
}
@ -293,7 +295,8 @@ Py_InitializeEx(int install_sigs)
sys_isatty = PyObject_CallMethod(sys_stream, "isatty", "");
if (!sys_isatty)
PyErr_Clear();
if(sys_isatty && PyObject_IsTrue(sys_isatty)) {
if(sys_isatty && PyObject_IsTrue(sys_isatty) &&
PyFile_Check(sys_stream)) {
if (!PyFile_SetEncoding(sys_stream, codeset))
Py_FatalError("Cannot set codeset of stderr");
}

View File

@ -1110,17 +1110,17 @@ _PySys_Init(void)
if (PyErr_Occurred())
return NULL;
#ifdef MS_WINDOWS
if(isatty(_fileno(stdin))){
if(isatty(_fileno(stdin)) && PyFile_Check(sysin)) {
sprintf(buf, "cp%d", GetConsoleCP());
if (!PyFile_SetEncoding(sysin, buf))
return NULL;
}
if(isatty(_fileno(stdout))) {
if(isatty(_fileno(stdout)) && PyFile_Check(sysout)) {
sprintf(buf, "cp%d", GetConsoleOutputCP());
if (!PyFile_SetEncoding(sysout, buf))
return NULL;
}
if(isatty(_fileno(stderr))) {
if(isatty(_fileno(stderr)) && PyFile_Check(syserr)) {
sprintf(buf, "cp%d", GetConsoleOutputCP());
if (!PyFile_SetEncoding(syserr, buf))
return NULL;

View File

@ -113,7 +113,7 @@ newtracebackobject(PyTracebackObject *next, PyFrameObject *frame)
int
PyTraceBack_Here(PyFrameObject *frame)
{
PyThreadState *tstate = frame->f_tstate;
PyThreadState *tstate = PyThreadState_GET();
PyTracebackObject *oldtb = (PyTracebackObject *) tstate->curexc_traceback;
PyTracebackObject *tb = newtracebackobject(oldtb, frame);
if (tb == NULL)

View File

@ -33,4 +33,8 @@ product_codes = {
'2.5.121': '{8e9321bc-6b24-48a3-8fd4-c95f8e531e5f}', # 2.5c1
'2.5.122': '{a6cd508d-9599-45da-a441-cbffa9f7e070}', # 2.5c2
'2.5.150': '{0a2c5854-557e-48c8-835a-3b9f074bdcaa}', # 2.5.0
'2.5.1121':'{0378b43e-6184-4c2f-be1a-4a367781cd54}', # 2.5.1c1
'2.5.1150':'{31800004-6386-4999-a519-518f2d78d8f0}', # 2.5.1
'2.5.2150':'{6304a7da-1132-4e91-a343-a296269eab8a}', # 2.5.2c1
'2.5.2150':'{6b976adf-8ae8-434e-b282-a06c7f624d2f}', # 2.5.2
}

463
configure vendored
View File

@ -1,5 +1,5 @@
#! /bin/sh
# From configure.in Revision: 51211 .
# From configure.in Revision: 53017 .
# Guess values for system-dependent variables and create Makefiles.
# Generated by GNU Autoconf 2.61 for python 3.0.
#
@ -10606,6 +10606,467 @@ cat >>confdefs.h <<_ACEOF
_ACEOF
fi
{ echo "$as_me:$LINENO: checking for _Bool support" >&5
echo $ECHO_N "checking for _Bool support... $ECHO_C" >&6; }
have_c99_bool=no
cat >conftest.$ac_ext <<_ACEOF
/* confdefs.h. */
_ACEOF
cat confdefs.h >>conftest.$ac_ext
cat >>conftest.$ac_ext <<_ACEOF
/* end confdefs.h. */
int
main ()
{
_Bool x; x = (_Bool)0;
;
return 0;
}
_ACEOF
rm -f conftest.$ac_objext
if { (ac_try="$ac_compile"
case "(($ac_try" in
*\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
*) ac_try_echo=$ac_try;;
esac
eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
(eval "$ac_compile") 2>conftest.er1
ac_status=$?
grep -v '^ *+' conftest.er1 >conftest.err
rm -f conftest.er1
cat conftest.err >&5
echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); } && {
test -z "$ac_c_werror_flag" ||
test ! -s conftest.err
} && test -s conftest.$ac_objext; then
cat >>confdefs.h <<\_ACEOF
#define HAVE_C99_BOOL 1
_ACEOF
have_c99_bool=yes
else
echo "$as_me: failed program was:" >&5
sed 's/^/| /' conftest.$ac_ext >&5
fi
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
{ echo "$as_me:$LINENO: result: $have_c99_bool" >&5
echo "${ECHO_T}$have_c99_bool" >&6; }
if test "$have_c99_bool" = yes ; then
{ echo "$as_me:$LINENO: checking for _Bool" >&5
echo $ECHO_N "checking for _Bool... $ECHO_C" >&6; }
if test "${ac_cv_type__Bool+set}" = set; then
echo $ECHO_N "(cached) $ECHO_C" >&6
else
cat >conftest.$ac_ext <<_ACEOF
/* confdefs.h. */
_ACEOF
cat confdefs.h >>conftest.$ac_ext
cat >>conftest.$ac_ext <<_ACEOF
/* end confdefs.h. */
$ac_includes_default
typedef _Bool ac__type_new_;
int
main ()
{
if ((ac__type_new_ *) 0)
return 0;
if (sizeof (ac__type_new_))
return 0;
;
return 0;
}
_ACEOF
rm -f conftest.$ac_objext
if { (ac_try="$ac_compile"
case "(($ac_try" in
*\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
*) ac_try_echo=$ac_try;;
esac
eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
(eval "$ac_compile") 2>conftest.er1
ac_status=$?
grep -v '^ *+' conftest.er1 >conftest.err
rm -f conftest.er1
cat conftest.err >&5
echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); } && {
test -z "$ac_c_werror_flag" ||
test ! -s conftest.err
} && test -s conftest.$ac_objext; then
ac_cv_type__Bool=yes
else
echo "$as_me: failed program was:" >&5
sed 's/^/| /' conftest.$ac_ext >&5
ac_cv_type__Bool=no
fi
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
fi
{ echo "$as_me:$LINENO: result: $ac_cv_type__Bool" >&5
echo "${ECHO_T}$ac_cv_type__Bool" >&6; }
# The cast to long int works around a bug in the HP C Compiler
# version HP92453-01 B.11.11.23709.GP, which incorrectly rejects
# declarations like `int a3[[(sizeof (unsigned char)) >= 0]];'.
# This bug is HP SR number 8606223364.
{ echo "$as_me:$LINENO: checking size of _Bool" >&5
echo $ECHO_N "checking size of _Bool... $ECHO_C" >&6; }
if test "${ac_cv_sizeof__Bool+set}" = set; then
echo $ECHO_N "(cached) $ECHO_C" >&6
else
if test "$cross_compiling" = yes; then
# Depending upon the size, compute the lo and hi bounds.
cat >conftest.$ac_ext <<_ACEOF
/* confdefs.h. */
_ACEOF
cat confdefs.h >>conftest.$ac_ext
cat >>conftest.$ac_ext <<_ACEOF
/* end confdefs.h. */
$ac_includes_default
typedef _Bool ac__type_sizeof_;
int
main ()
{
static int test_array [1 - 2 * !(((long int) (sizeof (ac__type_sizeof_))) >= 0)];
test_array [0] = 0
;
return 0;
}
_ACEOF
rm -f conftest.$ac_objext
if { (ac_try="$ac_compile"
case "(($ac_try" in
*\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
*) ac_try_echo=$ac_try;;
esac
eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
(eval "$ac_compile") 2>conftest.er1
ac_status=$?
grep -v '^ *+' conftest.er1 >conftest.err
rm -f conftest.er1
cat conftest.err >&5
echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); } && {
test -z "$ac_c_werror_flag" ||
test ! -s conftest.err
} && test -s conftest.$ac_objext; then
ac_lo=0 ac_mid=0
while :; do
cat >conftest.$ac_ext <<_ACEOF
/* confdefs.h. */
_ACEOF
cat confdefs.h >>conftest.$ac_ext
cat >>conftest.$ac_ext <<_ACEOF
/* end confdefs.h. */
$ac_includes_default
typedef _Bool ac__type_sizeof_;
int
main ()
{
static int test_array [1 - 2 * !(((long int) (sizeof (ac__type_sizeof_))) <= $ac_mid)];
test_array [0] = 0
;
return 0;
}
_ACEOF
rm -f conftest.$ac_objext
if { (ac_try="$ac_compile"
case "(($ac_try" in
*\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
*) ac_try_echo=$ac_try;;
esac
eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
(eval "$ac_compile") 2>conftest.er1
ac_status=$?
grep -v '^ *+' conftest.er1 >conftest.err
rm -f conftest.er1
cat conftest.err >&5
echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); } && {
test -z "$ac_c_werror_flag" ||
test ! -s conftest.err
} && test -s conftest.$ac_objext; then
ac_hi=$ac_mid; break
else
echo "$as_me: failed program was:" >&5
sed 's/^/| /' conftest.$ac_ext >&5
ac_lo=`expr $ac_mid + 1`
if test $ac_lo -le $ac_mid; then
ac_lo= ac_hi=
break
fi
ac_mid=`expr 2 '*' $ac_mid + 1`
fi
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
done
else
echo "$as_me: failed program was:" >&5
sed 's/^/| /' conftest.$ac_ext >&5
cat >conftest.$ac_ext <<_ACEOF
/* confdefs.h. */
_ACEOF
cat confdefs.h >>conftest.$ac_ext
cat >>conftest.$ac_ext <<_ACEOF
/* end confdefs.h. */
$ac_includes_default
typedef _Bool ac__type_sizeof_;
int
main ()
{
static int test_array [1 - 2 * !(((long int) (sizeof (ac__type_sizeof_))) < 0)];
test_array [0] = 0
;
return 0;
}
_ACEOF
rm -f conftest.$ac_objext
if { (ac_try="$ac_compile"
case "(($ac_try" in
*\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
*) ac_try_echo=$ac_try;;
esac
eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
(eval "$ac_compile") 2>conftest.er1
ac_status=$?
grep -v '^ *+' conftest.er1 >conftest.err
rm -f conftest.er1
cat conftest.err >&5
echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); } && {
test -z "$ac_c_werror_flag" ||
test ! -s conftest.err
} && test -s conftest.$ac_objext; then
ac_hi=-1 ac_mid=-1
while :; do
cat >conftest.$ac_ext <<_ACEOF
/* confdefs.h. */
_ACEOF
cat confdefs.h >>conftest.$ac_ext
cat >>conftest.$ac_ext <<_ACEOF
/* end confdefs.h. */
$ac_includes_default
typedef _Bool ac__type_sizeof_;
int
main ()
{
static int test_array [1 - 2 * !(((long int) (sizeof (ac__type_sizeof_))) >= $ac_mid)];
test_array [0] = 0
;
return 0;
}
_ACEOF
rm -f conftest.$ac_objext
if { (ac_try="$ac_compile"
case "(($ac_try" in
*\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
*) ac_try_echo=$ac_try;;
esac
eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
(eval "$ac_compile") 2>conftest.er1
ac_status=$?
grep -v '^ *+' conftest.er1 >conftest.err
rm -f conftest.er1
cat conftest.err >&5
echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); } && {
test -z "$ac_c_werror_flag" ||
test ! -s conftest.err
} && test -s conftest.$ac_objext; then
ac_lo=$ac_mid; break
else
echo "$as_me: failed program was:" >&5
sed 's/^/| /' conftest.$ac_ext >&5
ac_hi=`expr '(' $ac_mid ')' - 1`
if test $ac_mid -le $ac_hi; then
ac_lo= ac_hi=
break
fi
ac_mid=`expr 2 '*' $ac_mid`
fi
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
done
else
echo "$as_me: failed program was:" >&5
sed 's/^/| /' conftest.$ac_ext >&5
ac_lo= ac_hi=
fi
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
fi
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
# Binary search between lo and hi bounds.
while test "x$ac_lo" != "x$ac_hi"; do
ac_mid=`expr '(' $ac_hi - $ac_lo ')' / 2 + $ac_lo`
cat >conftest.$ac_ext <<_ACEOF
/* confdefs.h. */
_ACEOF
cat confdefs.h >>conftest.$ac_ext
cat >>conftest.$ac_ext <<_ACEOF
/* end confdefs.h. */
$ac_includes_default
typedef _Bool ac__type_sizeof_;
int
main ()
{
static int test_array [1 - 2 * !(((long int) (sizeof (ac__type_sizeof_))) <= $ac_mid)];
test_array [0] = 0
;
return 0;
}
_ACEOF
rm -f conftest.$ac_objext
if { (ac_try="$ac_compile"
case "(($ac_try" in
*\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
*) ac_try_echo=$ac_try;;
esac
eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
(eval "$ac_compile") 2>conftest.er1
ac_status=$?
grep -v '^ *+' conftest.er1 >conftest.err
rm -f conftest.er1
cat conftest.err >&5
echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); } && {
test -z "$ac_c_werror_flag" ||
test ! -s conftest.err
} && test -s conftest.$ac_objext; then
ac_hi=$ac_mid
else
echo "$as_me: failed program was:" >&5
sed 's/^/| /' conftest.$ac_ext >&5
ac_lo=`expr '(' $ac_mid ')' + 1`
fi
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
done
case $ac_lo in
?*) ac_cv_sizeof__Bool=$ac_lo;;
'') if test "$ac_cv_type__Bool" = yes; then
{ { echo "$as_me:$LINENO: error: cannot compute sizeof (_Bool)
See \`config.log' for more details." >&5
echo "$as_me: error: cannot compute sizeof (_Bool)
See \`config.log' for more details." >&2;}
{ (exit 77); exit 77; }; }
else
ac_cv_sizeof__Bool=0
fi ;;
esac
else
cat >conftest.$ac_ext <<_ACEOF
/* confdefs.h. */
_ACEOF
cat confdefs.h >>conftest.$ac_ext
cat >>conftest.$ac_ext <<_ACEOF
/* end confdefs.h. */
$ac_includes_default
typedef _Bool ac__type_sizeof_;
static long int longval () { return (long int) (sizeof (ac__type_sizeof_)); }
static unsigned long int ulongval () { return (long int) (sizeof (ac__type_sizeof_)); }
#include <stdio.h>
#include <stdlib.h>
int
main ()
{
FILE *f = fopen ("conftest.val", "w");
if (! f)
return 1;
if (((long int) (sizeof (ac__type_sizeof_))) < 0)
{
long int i = longval ();
if (i != ((long int) (sizeof (ac__type_sizeof_))))
return 1;
fprintf (f, "%ld\n", i);
}
else
{
unsigned long int i = ulongval ();
if (i != ((long int) (sizeof (ac__type_sizeof_))))
return 1;
fprintf (f, "%lu\n", i);
}
return ferror (f) || fclose (f) != 0;
;
return 0;
}
_ACEOF
rm -f conftest$ac_exeext
if { (ac_try="$ac_link"
case "(($ac_try" in
*\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
*) ac_try_echo=$ac_try;;
esac
eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
(eval "$ac_link") 2>&5
ac_status=$?
echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); } && { ac_try='./conftest$ac_exeext'
{ (case "(($ac_try" in
*\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
*) ac_try_echo=$ac_try;;
esac
eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
(eval "$ac_try") 2>&5
ac_status=$?
echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); }; }; then
ac_cv_sizeof__Bool=`cat conftest.val`
else
echo "$as_me: program exited with status $ac_status" >&5
echo "$as_me: failed program was:" >&5
sed 's/^/| /' conftest.$ac_ext >&5
( exit $ac_status )
if test "$ac_cv_type__Bool" = yes; then
{ { echo "$as_me:$LINENO: error: cannot compute sizeof (_Bool)
See \`config.log' for more details." >&5
echo "$as_me: error: cannot compute sizeof (_Bool)
See \`config.log' for more details." >&2;}
{ (exit 77); exit 77; }; }
else
ac_cv_sizeof__Bool=0
fi
fi
rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext
fi
rm -f conftest.val
fi
{ echo "$as_me:$LINENO: result: $ac_cv_sizeof__Bool" >&5
echo "${ECHO_T}$ac_cv_sizeof__Bool" >&6; }
cat >>confdefs.h <<_ACEOF
#define SIZEOF__BOOL $ac_cv_sizeof__Bool
_ACEOF
fi
{ echo "$as_me:$LINENO: checking for uintptr_t" >&5

View File

@ -1218,6 +1218,17 @@ if test "$have_long_long" = yes ; then
AC_CHECK_SIZEOF(long long, 8)
fi
AC_MSG_CHECKING(for _Bool support)
have_c99_bool=no
AC_TRY_COMPILE([], [_Bool x; x = (_Bool)0;], [
AC_DEFINE(HAVE_C99_BOOL, 1, [Define this if you have the type _Bool.])
have_c99_bool=yes
])
AC_MSG_RESULT($have_c99_bool)
if test "$have_c99_bool" = yes ; then
AC_CHECK_SIZEOF(_Bool, 1)
fi
AC_CHECK_TYPES(uintptr_t,
[AC_CHECK_SIZEOF(uintptr_t, 4)],
[], [#ifdef HAVE_STDINT_H

View File

@ -64,6 +64,9 @@
/* Define if pthread_sigmask() does not work on your system. */
#undef HAVE_BROKEN_PTHREAD_SIGMASK
/* Define this if you have the type _Bool. */
#undef HAVE_C99_BOOL
/* Define to 1 if you have the `chown' function. */
#undef HAVE_CHOWN
@ -835,6 +838,9 @@
/* The size of a `wchar_t', as computed by sizeof. */
#undef SIZEOF_WCHAR_T
/* The size of a `_Bool', as computed by sizeof. */
#undef SIZEOF__BOOL
/* Define to 1 if you have the ANSI C header files. */
#undef STDC_HEADERS