Merged revisions 70866-70868,70870-70871,70893,70896,70902,70905,70907,70912,70915,70927,70933,70940,70944,70954,70963,70998,71056 via svnmerge from

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

........
  r70866 | georg.brandl | 2009-03-31 21:06:57 +0200 (Di, 31 Mär 2009) | 1 line

  #4882: document named group behavior a bit better.
........
  r70867 | georg.brandl | 2009-03-31 21:10:35 +0200 (Di, 31 Mär 2009) | 1 line

  #1096310: document usage of sys.__std*__ a bit better.
........
  r70868 | georg.brandl | 2009-03-31 21:12:17 +0200 (Di, 31 Mär 2009) | 1 line

  #5190: export make_option in __all__.
........
  r70870 | georg.brandl | 2009-03-31 21:26:24 +0200 (Di, 31 Mär 2009) | 1 line

  #4411: document mro() and __mro__. (I hope I got it right.)
........
  r70871 | georg.brandl | 2009-03-31 21:30:56 +0200 (Di, 31 Mär 2009) | 1 line

  #5618: fix typo.
........
  r70893 | georg.brandl | 2009-03-31 22:56:32 +0200 (Di, 31 Mär 2009) | 1 line

  #1530012: move TQS section before raw strings.
........
  r70896 | georg.brandl | 2009-03-31 23:15:33 +0200 (Di, 31 Mär 2009) | 1 line

  #5598: document DocFileSuite *args argument.
........
  r70902 | georg.brandl | 2009-03-31 23:43:03 +0200 (Di, 31 Mär 2009) | 1 line

  #1675026: add a note about a strange Windows problem, and remove notes about AtheOS.
........
  r70905 | georg.brandl | 2009-04-01 00:03:40 +0200 (Mi, 01 Apr 2009) | 1 line

  #5563: more documentation for bdist_msi.
........
  r70907 | georg.brandl | 2009-04-01 00:18:19 +0200 (Mi, 01 Apr 2009) | 1 line

  #3427: document correct return type for urlopen().info().
........
  r70912 | georg.brandl | 2009-04-01 00:35:46 +0200 (Mi, 01 Apr 2009) | 1 line

  #5617: add a handy function to print a unicode string to gdbinit.
........
  r70915 | georg.brandl | 2009-04-01 00:40:16 +0200 (Mi, 01 Apr 2009) | 1 line

  #5018: remove confusing paragraph.
........
  r70927 | georg.brandl | 2009-04-01 01:01:27 +0200 (Mi, 01 Apr 2009) | 1 line

  Dont shout to users.
........
  r70933 | georg.brandl | 2009-04-01 02:04:33 +0200 (Mi, 01 Apr 2009) | 2 lines

  Issue #5635: Fix running test_sys with tracing enabled.
........
  r70940 | georg.brandl | 2009-04-01 06:21:14 +0200 (Mi, 01 Apr 2009) | 2 lines

  The SimpleXMLRPCServer's CGI handler now runs like a pony.
........
  r70944 | georg.brandl | 2009-04-01 06:32:39 +0200 (Mi, 01 Apr 2009) | 1 line

  #5631: add upload to list of possible commands, which is presented in --help-commands.
........
  r70954 | georg.brandl | 2009-04-01 17:23:43 +0200 (Mi, 01 Apr 2009) | 1 line

  Fix test_xmlrpc and make the CGI handler work with no CONTENT_LENGTH.
........
  r70963 | georg.brandl | 2009-04-01 19:46:01 +0200 (Mi, 01 Apr 2009) | 1 line

  #5655: fix docstring oversight.
........
  r70998 | georg.brandl | 2009-04-01 23:54:21 +0200 (Mi, 01 Apr 2009) | 1 line

  In Pdb, stop assigning values to __builtin__._ which interferes with the one commonly installed by gettext.
........
  r71056 | georg.brandl | 2009-04-02 19:43:07 +0200 (Do, 02 Apr 2009) | 2 lines

  Actually the displayhook should print the repr.
........
This commit is contained in:
Georg Brandl 2009-04-05 21:21:05 +00:00
parent 8943caf716
commit 9b08e05e1e
19 changed files with 168 additions and 137 deletions

View File

@ -247,7 +247,7 @@ definition with the same method name.
T_OBJECT_EX PyObject \*
T_CHAR char
T_BYTE char
T_UNBYTE unsigned char
T_UBYTE unsigned char
T_UINT unsigned int
T_USHORT unsigned short
T_ULONG unsigned long

View File

@ -1775,8 +1775,16 @@ This module supplies the abstract base class :class:`Command`.
.. module:: distutils.command.bdist_msi
:synopsis: Build a binary distribution as a Windows MSI file
.. class:: bdist_msi(Command)
.. % todo
Builds a `Windows Installer`_ (.msi) binary package.
.. _Windows Installer: http://msdn.microsoft.com/en-us/library/cc185688(VS.85).aspx
In most cases, the ``bdist_msi`` installer is a better choice than the
``bdist_wininst`` installer, because it provides better support for
Win64 platforms, allows administrators to perform non-interactive
installations, and allows installation through group policies.
:mod:`distutils.command.bdist_rpm` --- Build a binary distribution as a Redhat RPM and SRPM

View File

@ -965,7 +965,7 @@ There are two main functions for creating :class:`unittest.TestSuite` instances
from text files and modules with doctests:
.. function:: DocFileSuite([module_relative][, package][, setUp][, tearDown][, globs][, optionflags][, parser][, encoding])
.. function:: DocFileSuite(*paths, [module_relative][, package][, setUp][, tearDown][, globs][, optionflags][, parser][, encoding])
Convert doctest tests from one or more text files to a
:class:`unittest.TestSuite`.
@ -983,45 +983,47 @@ from text files and modules with doctests:
Optional argument *module_relative* specifies how the filenames in *paths*
should be interpreted:
* If *module_relative* is ``True`` (the default), then each filename specifies
an OS-independent module-relative path. By default, this path is relative to
the calling module's directory; but if the *package* argument is specified, then
it is relative to that package. To ensure OS-independence, each filename should
use ``/`` characters to separate path segments, and may not be an absolute path
(i.e., it may not begin with ``/``).
* If *module_relative* is ``True`` (the default), then each filename in
*paths* specifies an OS-independent module-relative path. By default, this
path is relative to the calling module's directory; but if the *package*
argument is specified, then it is relative to that package. To ensure
OS-independence, each filename should use ``/`` characters to separate path
segments, and may not be an absolute path (i.e., it may not begin with
``/``).
* If *module_relative* is ``False``, then each filename specifies an OS-specific
path. The path may be absolute or relative; relative paths are resolved with
respect to the current working directory.
* If *module_relative* is ``False``, then each filename in *paths* specifies
an OS-specific path. The path may be absolute or relative; relative paths
are resolved with respect to the current working directory.
Optional argument *package* is a Python package or the name of a Python package
whose directory should be used as the base directory for module-relative
filenames. If no package is specified, then the calling module's directory is
used as the base directory for module-relative filenames. It is an error to
specify *package* if *module_relative* is ``False``.
Optional argument *package* is a Python package or the name of a Python
package whose directory should be used as the base directory for
module-relative filenames in *paths*. If no package is specified, then the
calling module's directory is used as the base directory for module-relative
filenames. It is an error to specify *package* if *module_relative* is
``False``.
Optional argument *setUp* specifies a set-up function for the test suite. This
is called before running the tests in each file. The *setUp* function will be
passed a :class:`DocTest` object. The setUp function can access the test
globals as the *globs* attribute of the test passed.
Optional argument *tearDown* specifies a tear-down function for the test suite.
This is called after running the tests in each file. The *tearDown* function
Optional argument *setUp* specifies a set-up function for the test suite.
This is called before running the tests in each file. The *setUp* function
will be passed a :class:`DocTest` object. The setUp function can access the
test globals as the *globs* attribute of the test passed.
Optional argument *tearDown* specifies a tear-down function for the test
suite. This is called after running the tests in each file. The *tearDown*
function will be passed a :class:`DocTest` object. The setUp function can
access the test globals as the *globs* attribute of the test passed.
Optional argument *globs* is a dictionary containing the initial global
variables for the tests. A new copy of this dictionary is created for each
test. By default, *globs* is a new empty dictionary.
Optional argument *optionflags* specifies the default doctest options for the
tests, created by or-ing together individual option flags. See section
:ref:`doctest-options`. See function :func:`set_unittest_reportflags` below for
a better way to set reporting options.
:ref:`doctest-options`. See function :func:`set_unittest_reportflags` below
for a better way to set reporting options.
Optional argument *parser* specifies a :class:`DocTestParser` (or subclass) that
should be used to extract tests from the files. It defaults to a normal parser
(i.e., ``DocTestParser()``).
Optional argument *parser* specifies a :class:`DocTestParser` (or subclass)
that should be used to extract tests from the files. It defaults to a normal
parser (i.e., ``DocTestParser()``).
Optional argument *encoding* specifies an encoding that should be used to
convert the file to unicode.
@ -1029,8 +1031,8 @@ from text files and modules with doctests:
.. versionadded:: 2.4
.. versionchanged:: 2.5
The global ``__file__`` was added to the globals provided to doctests loaded
from a text file using :func:`DocFileSuite`.
The global ``__file__`` was added to the globals provided to doctests
loaded from a text file using :func:`DocFileSuite`.
.. versionchanged:: 2.5
The parameter *encoding* was added.

View File

@ -231,16 +231,18 @@ The special characters are:
``(?P<name>...)``
Similar to regular parentheses, but the substring matched by the group is
accessible via the symbolic group name *name*. Group names must be valid Python
identifiers, and each group name must be defined only once within a regular
expression. A symbolic group is also a numbered group, just as if the group
were not named. So the group named 'id' in the example below can also be
referenced as the numbered group 1.
accessible within the rest of the regular expression via the symbolic group
name *name*. Group names must be valid Python identifiers, and each group
name must be defined only once within a regular expression. A symbolic group
is also a numbered group, just as if the group were not named. So the group
named ``id`` in the example below can also be referenced as the numbered group
``1``.
For example, if the pattern is ``(?P<id>[a-zA-Z_]\w*)``, the group can be
referenced by its name in arguments to methods of match objects, such as
``m.group('id')`` or ``m.end('id')``, and also by name in pattern text (for
example, ``(?P=id)``) and replacement text (such as ``\g<id>``).
``m.group('id')`` or ``m.end('id')``, and also by name in the regular
expression itself (using ``(?P=id)``) and replacement text given to
``.sub()`` (using ``\g<id>``).
``(?P=name)``
Matches whatever text was matched by the earlier group named *name*.

View File

@ -2653,9 +2653,24 @@ types, where they are relevant. Some of these are not reported by the
The name of the class or type.
The following attributes are only supported by :term:`new-style class`\ es.
.. attribute:: class.__mro__
This attribute is a tuple of classes that are considered when looking for
base classes during method resolution.
.. method:: class.mro()
This method can be overridden by a metaclass to customize the method
resolution order for its instances. It is called at class instantiation, and
its result is stored in :attr:`__mro__`.
.. method:: class.__subclasses__
:term:`New-style class`\ es keep a list of weak references to their immediate
Each new-style class keeps a list of weak references to its immediate
subclasses. This method returns a list of all those references still alive.
Example::

View File

@ -850,9 +850,14 @@ always available.
__stderr__
These objects contain the original values of ``stdin``, ``stderr`` and
``stdout`` at the start of the program. They are used during finalization, and
could be useful to restore the actual files to known working file objects in
case they have been overwritten with a broken object.
``stdout`` at the start of the program. They are used during finalization,
and could be useful to print to the actual standard stream no matter if the
``sys.std*`` object has been redirected.
It can also be used to restore the actual files to known working file objects
in case they have been overwritten with a broken object. However, the
preferred way to do this is to explicitly save the previous stream before
replacing it, and restore the saved object.
.. data:: tracebacklimit

View File

@ -49,7 +49,7 @@ High-level interface
.. index:: module: mimetools
The :meth:`info` method returns an instance of the class
:class:`mimetools.Message` containing meta-information associated with the
:class:`httplib.HTTPMessage` containing meta-information associated with the
URL. When the method is HTTP, these headers are those returned by the server
at the head of the retrieved HTML page (including Content-Length and
Content-Type). When the method is FTP, a Content-Length header will be

View File

@ -401,13 +401,11 @@ The reverse operation is also possible::
>>> x, y, z = t
This is called, appropriately enough, *sequence unpacking*. Sequence unpacking
requires the list of variables on the left to have the same number of elements
as the length of the sequence. Note that multiple assignment is really just a
combination of tuple packing and sequence unpacking!
There is a small bit of asymmetry here: packing multiple values always creates
a tuple, and unpacking works for any sequence.
This is called, appropriately enough, *sequence unpacking* and works for any
sequence on the right-hand side. Sequence unpacking requires the list of
variables on the left to have the same number of elements as the length of the
sequence. Note that multiple assignment is really just a combination of tuple
packing and sequence unpacking.
.. XXX Add a bit on the difference between tuples and lists.

View File

@ -199,21 +199,6 @@ the following::
several lines of text just as you would do in C.
Note that whitespace at the beginning of the line is significant.
If we make the string literal a "raw" string, however, the ``\n`` sequences are
not converted to newlines, but the backslash at the end of the line, and the
newline character in the source, are both included in the string as data. Thus,
the example::
hello = r"This is a rather long string containing\n\
several lines of text much as you would do in C."
print hello
would print::
This is a rather long string containing\n\
several lines of text much as you would do in C.
Or, strings can be surrounded in a pair of matching triple-quotes: ``"""`` or
``'''``. End of lines do not need to be escaped when using triple-quotes, but
they will be included in the string. ::
@ -230,6 +215,20 @@ produces the following output::
-h Display this usage message
-H hostname Hostname to connect to
If we make the string literal a "raw" string, ``\n`` sequences are not converted
to newlines, but the backslash at the end of the line, and the newline character
in the source, are both included in the string as data. Thus, the example::
hello = r"This is a rather long string containing\n\
several lines of text much as you would do in C."
print hello
would print::
This is a rather long string containing\n\
several lines of text much as you would do in C.
The interpreter prints the result of string operations in the same way as they
are typed for input: inside quotes, and with quotes and other funny characters
escaped by backslashes, to show the precise value. The string is enclosed in

View File

@ -598,8 +598,12 @@ class CGIXMLRPCRequestHandler(SimpleXMLRPCDispatcher):
self.handle_get()
else:
# POST data is normally available through stdin
try:
length = int(os.environ.get('CONTENT_LENGTH', None))
except (TypeError, ValueError):
length = -1
if request_text is None:
request_text = sys.stdin.read()
request_text = sys.stdin.read(length)
self.handle_xmlrpc(request_text)

View File

@ -24,6 +24,8 @@ __all__ = ['build',
'bdist_dumb',
'bdist_rpm',
'bdist_wininst',
'upload',
# These two are reserved for future use:
#'bdist_sdux',
#'bdist_pkgtool',

View File

@ -16,7 +16,7 @@ def glob(pathname):
return list(iglob(pathname))
def iglob(pathname):
"""Return a list of paths matching a pathname pattern.
"""Return an iterator which yields the paths matching a pathname pattern.
The pattern may contain simple shell-style wildcards a la fnmatch.

View File

@ -11,6 +11,7 @@ For support, use the optik-users@lists.sourceforge.net mailing list
__version__ = "1.5.3"
__all__ = ['Option',
'make_option',
'SUPPRESS_HELP',
'SUPPRESS_USAGE',
'Values',

View File

@ -194,6 +194,12 @@ class Pdb(bdb.Bdb, cmd.Cmd):
self.cmdloop()
self.forget()
def displayhook(self, obj):
"""Custom displayhook for the exec in default(), which prevents
assignment of the _ variable in the builtins.
"""
print repr(obj)
def default(self, line):
if line[:1] == '!': line = line[1:]
locals = self.curframe.f_locals
@ -202,13 +208,16 @@ class Pdb(bdb.Bdb, cmd.Cmd):
code = compile(line + '\n', '<stdin>', 'single')
save_stdout = sys.stdout
save_stdin = sys.stdin
save_displayhook = sys.displayhook
try:
sys.stdin = self.stdin
sys.stdout = self.stdout
sys.displayhook = self.displayhook
exec code in globals, locals
finally:
sys.stdout = save_stdout
sys.stdin = save_stdin
sys.displayhook = save_displayhook
except:
t, v = sys.exc_info()[:2]
if type(t) == type(''):

View File

@ -221,6 +221,11 @@ class SysModuleTest(unittest.TestCase):
sys.setdlopenflags(oldflags)
def test_refcount(self):
# n here must be a global in order for this test to pass while
# tracing with a python function. Tracing calls PyFrame_FastToLocals
# which will add a copy of any locals to the frame object, causing
# the reference count to increase by 2 instead of 1.
global n
self.assertRaises(TypeError, sys.getrefcount)
c = sys.getrefcount(None)
n = None

View File

@ -624,7 +624,11 @@ class CGIHandlerTestCase(unittest.TestCase):
sys.stdin = open("xmldata.txt", "r")
sys.stdout = open(test_support.TESTFN, "w")
self.cgi.handle_request()
os.environ['CONTENT_LENGTH'] = str(len(data))
try:
self.cgi.handle_request()
finally:
del os.environ['CONTENT_LENGTH']
sys.stdin.close()
sys.stdout.close()

View File

@ -97,6 +97,23 @@ Library
- Issue 1726172: fix IndexError in the case of and empty response in ftplib.
- In Pdb, prevent the reassignment of __builtin__._ by sys.displayhook on
printing out values.
- Issue #4572: added SEEK_* symbolic constants to io module.
- Issue #1665206 (partially): Move imports in cgitb to the top of the module
instead of performing them in functions. Helps prevent import deadlocking in
threads.
- Issue #5647: MutableSet.__iand__() no longer mutates self during iteration.
- Actually make the SimpleXMLRPCServer CGI handler work.
- Issue #2522: locale.format now checks its first argument to ensure it has
been passed only one pattern, avoiding mysterious errors where it appeared
that it was failing to do localization.
- Issue 2625: added missing iteritems() call to the for loop in
mailbox.MH.get_message().
@ -508,6 +525,18 @@ Extension Modules
- Issue #4396: The parser module now correctly validates the with statement.
Tests
-----
- Issue #5635: Fix running test_sys with tracing enabled.
- regrtest no longer treats ImportError as equivalent to SkipTest. Imports
that should cause a test to be skipped are now done using import_module
from test support, which does the conversion.
- Issue #5083: New 'gui' resource for regrtest.
What's New in Python 2.6 final
==============================

View File

@ -138,3 +138,16 @@ define pystackv
end
select-frame 0
end
# generally useful macro to print a Unicode string
def pu
set $uni = $arg0
set $i = 0
while (*$uni && $i++<100)
if (*$uni < 0x80)
print *(char*)$uni++
else
print /x *(short*)$uni++
end
end
end

73
README
View File

@ -665,75 +665,10 @@ Cygwin: With recent (relative to the time of writing, 2001-12-19)
News regarding these platforms with more recent Cygwin
versions would be appreciated!
AtheOS: Official support has been stopped as of Python 2.6. All code will be
removed in Python 2.7 unless a maintainer steps forward for this
platform.
From Octavian Cerna <tavy at ylabs.com>:
Before building:
Make sure you have shared versions of the libraries you
want to use with Python. You will have to compile them
yourself, or download precompiled packages.
Recommended libraries:
ncurses-4.2
readline-4.2a
zlib-1.1.4
Build:
$ ./configure --prefix=/usr/python
$ make
Python is always built as a shared library, otherwise
dynamic loading would not work.
Testing:
$ make test
Install:
# make install
# pkgmanager -a /usr/python
AtheOS issues:
- large file support: due to a stdio bug in glibc/libio,
access to large files may not work correctly. fseeko()
tries to seek to a negative offset. ftello() returns a
negative offset, it looks like a 32->64bit
sign-extension issue. The lowlevel functions (open,
lseek, etc) are OK.
- sockets: AF_UNIX is defined in the C library and in
Python, but not implemented in the system.
- select: poll is available in the C library, but does not
work (It does not return POLLNVAL for bad fds and
hangs).
- posix: statvfs and fstatvfs always return ENOSYS.
- disabled modules:
- mmap: not yet implemented in AtheOS
- nis: broken (on an unconfigured system
yp_get_default_domain() returns junk instead of
error)
- dl: dynamic loading doesn't work via dlopen()
- resource: getrimit and setrlimit are not yet
implemented
- if you are getting segmentation faults, you probably are
low on memory. AtheOS doesn't handle very well an
out-of-memory condition and simply SEGVs the process.
Tested on:
AtheOS-0.3.7
gcc-2.95
binutils-2.10
make-3.78
Windows: When executing Python scripts on the command line using file type
associations (i.e. starting "script.py" instead of "python script.py"),
redirects may not work unless you set a specific registry key. See
the Knowledge Base article <http://support.microsoft.com/kb/321788>.
Configuring the bsddb and dbm modules