Skip to content

Commit 9d8d2a4

Browse files
committed
Update whatsnew/2.7.rst, add a few links and fix a couple of XXX. Also add a paragraph about DeprecationWarnings in cmdline.rst.
1 parent 1f6e225 commit 9d8d2a4

File tree

2 files changed

+69
-64
lines changed

2 files changed

+69
-64
lines changed

Doc/using/cmdline.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -315,6 +315,10 @@ Miscellaneous options
315315
:option:`-W` options are ignored (though, a warning message is printed about
316316
invalid options when the first warning is issued).
317317

318+
Starting from Python 2.7, :exc:`DeprecationWarning` and its descendants
319+
are ignored by default. The :option:`-Wd` option can be used to re-enable
320+
them.
321+
318322
Warnings can also be controlled from within a Python program using the
319323
:mod:`warnings` module.
320324

Doc/whatsnew/2.7.rst

Lines changed: 65 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
.. hyperlink all the methods & functions.
1010
1111
.. T_STRING_INPLACE not described in main docs
12-
.. "Format String Syntax" in string.rst could use many more examples.
1312
1413
.. $Id$
1514
Rules for maintenance:
@@ -57,12 +56,12 @@ release of 2.7 is currently scheduled for July 2010; the detailed
5756
schedule is described in :pep:`373`.
5857

5958
Numeric handling has been improved in many ways, for both
60-
floating-point numbers and for the :class:`Decimal` class. There are
61-
some useful additions to the standard library, such as a greatly
62-
enhanced :mod:`unittest` module, the :mod:`argparse` module for
63-
parsing command-line options, convenient ordered-dictionary and
64-
:class:`Counter` classes in the :mod:`collections` module, and many
65-
other improvements.
59+
floating-point numbers and for the :class:`~decimal.Decimal` class.
60+
There are some useful additions to the standard library, such as a
61+
greatly enhanced :mod:`unittest` module, the :mod:`argparse` module
62+
for parsing command-line options, convenient :class:`~collections.OrderedDict`
63+
and :class:`~collections.Counter` classes in the :mod:`collections` module,
64+
and many other improvements.
6665

6766
Python 2.7 is planned to be the last of the 2.x releases, so we worked
6867
on making it a good release for the long term. To help with porting
@@ -117,8 +116,8 @@ Two consequences of the long-term significance of 2.7 are:
117116
with responding to these concerns.
118117

119118
You can re-enable display of :exc:`DeprecationWarning` messages by
120-
running Python with the :option:`-Wdefault` (short form:
121-
:option:`-Wd`) switch, or by setting the :envvar:`PYTHONWARNINGS`
119+
running Python with the :option:`-Wdefault <-W>` (short form:
120+
:option:`-Wd <-W>`) switch, or by setting the :envvar:`PYTHONWARNINGS`
122121
environment variable to ``"default"`` (or ``"d"``) before running
123122
Python. Python code can also re-enable them
124123
by calling ``warnings.simplefilter('default')``.
@@ -135,7 +134,7 @@ for migrating to the 3.x series.
135134
A partial list of 3.1 features that were backported to 2.7:
136135

137136
* The syntax for set literals (``{1,2,3}`` is a mutable set).
138-
* Dictionary and set comprehensions (``{ i: i*2 for i in range(3)}``).
137+
* Dictionary and set comprehensions (``{i: i*2 for i in range(3)}``).
139138
* Multiple context managers in a single :keyword:`with` statement.
140139
* A new version of the :mod:`io` library, rewritten in C for performance.
141140
* The ordered-dictionary type described in :ref:`pep-0372`.
@@ -155,7 +154,7 @@ Other new Python3-mode warnings include:
155154
* :func:`operator.isCallable` and :func:`operator.sequenceIncludes`,
156155
which are not supported in 3.x, now trigger warnings.
157156
* The :option:`-3` switch now automatically
158-
enables the :option:`-Qwarn` switch that causes warnings
157+
enables the :option:`-Qwarn <-Q>` switch that causes warnings
159158
about using classic division with integers and long integers.
160159

161160

@@ -390,7 +389,8 @@ standard input or output.
390389

391390
.. seealso::
392391

393-
`argparse module documentation <http://docs.python.org/dev/library/argparse.html>`__
392+
`argparse documentation <http://docs.python.org/dev/library/argparse.html>`__
393+
The documentation page of the argparse module.
394394

395395
`Upgrading optparse code to use argparse <http://docs.python.org/dev/library/argparse.html#upgrading-optparse-code>`__
396396
Part of the Python documentation, describing how to convert
@@ -402,8 +402,6 @@ standard input or output.
402402
PEP 391: Dictionary-Based Configuration For Logging
403403
====================================================
404404

405-
.. XXX not documented in library reference yet; add link here once it's added.
406-
407405
The :mod:`logging` module is very flexible; applications can define
408406
a tree of logging subsystems, and each logger in this tree can filter
409407
out certain messages, format them differently, and direct messages to
@@ -412,21 +410,21 @@ a varying number of handlers.
412410
All this flexibility can require a lot of configuration. You can
413411
write Python statements to create objects and set their properties,
414412
but a complex set-up requires verbose but boring code.
415-
:mod:`logging` also supports a :func:`~logging.config.fileConfig`
413+
:mod:`logging` also supports a :func:`~logging.fileConfig`
416414
function that parses a file, but the file format doesn't support
417415
configuring filters, and it's messier to generate programmatically.
418416

419-
Python 2.7 adds a :func:`~logging.config.dictConfig` function that
417+
Python 2.7 adds a :func:`~logging.dictConfig` function that
420418
uses a dictionary to configure logging. There are many ways to
421419
produce a dictionary from different sources: construct one with code;
422420
parse a file containing JSON; or use a YAML parsing library if one is
423-
installed.
421+
installed. For more information see :ref:`logging-config-api`.
424422

425423
The following example configures two loggers, the root logger and a
426-
logger named "network". Messages sent to the root logger will be
424+
logger named "network". Messages sent to the root logger will be
427425
sent to the system log using the syslog protocol, and messages
428426
to the "network" logger will be written to a :file:`network.log` file
429-
that will be rotated once the log reaches 1Mb.
427+
that will be rotated once the log reaches 1MB.
430428

431429
::
432430

@@ -445,7 +443,7 @@ that will be rotated once the log reaches 1Mb.
445443
'filename': '/logs/network.log',
446444
'formatter': 'standard',
447445
'level': 'INFO',
448-
'maxBytes': 1024*1024},
446+
'maxBytes': 1000000},
449447
'syslog': {'class': 'logging.handlers.SysLogHandler',
450448
'formatter': 'standard',
451449
'level': 'ERROR'}},
@@ -483,16 +481,19 @@ implemented by Vinay Sajip, are:
483481
for UDP or :const:`socket.SOCK_STREAM` for TCP. The default
484482
protocol remains UDP.
485483

486-
* :class:`Logger` instances gained a :meth:`getChild` method that retrieves a
487-
descendant logger using a relative path. For example,
488-
once you retrieve a logger by doing ``log = getLogger('app')``,
484+
* :class:`~logging.Logger` instances gained a :meth:`~logging.Logger.getChild`
485+
method that retrieves a descendant logger using a relative path.
486+
For example, once you retrieve a logger by doing ``log = getLogger('app')``,
489487
calling ``log.getChild('network.listen')`` is equivalent to
490488
``getLogger('app.network.listen')``.
491489

492-
* The :class:`LoggerAdapter` class gained a :meth:`isEnabledFor` method
493-
that takes a *level* and returns whether the underlying logger would
490+
* The :class:`~logging.LoggerAdapter` class gained a
491+
:meth:`~logging.LoggerAdapter.isEnabledFor` method that takes a
492+
*level* and returns whether the underlying logger would
494493
process a message of that level of importance.
495494

495+
.. XXX: Logger objects don't have a class declaration so the link don't work
496+
496497
.. seealso::
497498

498499
:pep:`391` - Dictionary-Based Configuration For Logging
@@ -501,14 +502,15 @@ implemented by Vinay Sajip, are:
501502
PEP 3106: Dictionary Views
502503
====================================================
503504

504-
The dictionary methods :meth:`keys`, :meth:`values`, and :meth:`items`
505-
are different in Python 3.x. They return an object called a :dfn:`view`
506-
instead of a fully materialized list.
505+
The dictionary methods :meth:`~dict.keys`, :meth:`~dict.values`, and
506+
:meth:`~dict.items` are different in Python 3.x. They return an object
507+
called a :dfn:`view` instead of a fully materialized list.
507508

508-
It's not possible to change the return values of :meth:`keys`,
509-
:meth:`values`, and :meth:`items` in Python 2.7 because too much code
510-
would break. Instead the 3.x versions were added under the new names
511-
:meth:`viewkeys`, :meth:`viewvalues`, and :meth:`viewitems`.
509+
It's not possible to change the return values of :meth:`~dict.keys`,
510+
:meth:`~dict.values`, and :meth:`~dict.items` in Python 2.7 because
511+
too much code would break. Instead the 3.x versions were added
512+
under the new names :meth:`~dict.viewkeys`, :meth:`~dict.viewvalues`,
513+
and :meth:`~dict.viewitems`.
512514

513515
::
514516

@@ -550,8 +552,8 @@ over the view::
550552
RuntimeError: dictionary changed size during iteration
551553

552554
You can use the view methods in Python 2.x code, and the 2to3
553-
converter will change them to the standard :meth:`keys`,
554-
:meth:`values`, and :meth:`items` methods.
555+
converter will change them to the standard :meth:`~dict.keys`,
556+
:meth:`~dict.values`, and :meth:`~dict.items` methods.
555557

556558
.. seealso::
557559

@@ -624,7 +626,7 @@ Some smaller changes made to the core Python language are:
624626
``{}`` continues to represent an empty dictionary; use
625627
``set()`` for an empty set.
626628

627-
>>> {1,2,3,4,5}
629+
>>> {1, 2, 3, 4, 5}
628630
set([1, 2, 3, 4, 5])
629631
>>> set() # empty set
630632
set([])
@@ -794,7 +796,7 @@ Some smaller changes made to the core Python language are:
794796
``None`` as its first argument. (Fixed by Georg Brandl;
795797
:issue:`4759`.)
796798

797-
.. bytearray doesn't seem to be documented
799+
.. XXX bytearray doesn't seem to be documented
798800
799801
* When using ``@classmethod`` and ``@staticmethod`` to wrap
800802
methods as class or static methods, the wrapper object now
@@ -1054,7 +1056,7 @@ changes, or look through the Subversion logs for all the details.
10541056
:meth:`~collections.deque.count` method that returns the number of
10551057
contained elements equal to the supplied argument *x*, and a
10561058
:meth:`~collections.deque.reverse` method that reverses the elements
1057-
of the deque in-place. :class:`deque` also exposes its maximum
1059+
of the deque in-place. :class:`~collections.deque` also exposes its maximum
10581060
length as the read-only :attr:`~collections.deque.maxlen` attribute.
10591061
(Both features added by Raymond Hettinger.)
10601062

@@ -1135,15 +1137,14 @@ changes, or look through the Subversion logs for all the details.
11351137
``Decimal('0.1000000000000000055511151231257827021181583404541015625')``.
11361138
(Implemented by Raymond Hettinger; :issue:`4796`.)
11371139

1138-
Comparing instances of :class:`Decimal` with floating-point
1140+
Comparing instances of :class:`~decimal.Decimal` with floating-point
11391141
numbers now produces sensible results based on the numeric values
11401142
of the operands. Previously such comparisons would fall back to
11411143
Python's default rules for comparing objects, which produced arbitrary
11421144
results based on their type. Note that you still cannot combine
11431145
:class:`Decimal` and floating-point in other operations such as addition,
11441146
since you should be explicitly choosing how to convert between float and
1145-
:class:`Decimal`.
1146-
(Fixed by Mark Dickinson; :issue:`2531`.)
1147+
:class:`~decimal.Decimal`. (Fixed by Mark Dickinson; :issue:`2531`.)
11471148

11481149
The constructor for :class:`~decimal.Decimal` now accepts
11491150
floating-point numbers (added by Raymond Hettinger; :issue:`8257`)
@@ -1195,8 +1196,8 @@ changes, or look through the Subversion logs for all the details.
11951196

11961197
Ordering comparisons (``<``, ``<=``, ``>``, ``>=``) between
11971198
fractions and complex numbers now raise a :exc:`TypeError`.
1198-
This fixes an oversight, making the :class:`Fraction` match the other
1199-
numeric types.
1199+
This fixes an oversight, making the :class:`~fractions.Fraction`
1200+
match the other numeric types.
12001201

12011202
.. revision 79455
12021203
@@ -1210,15 +1211,15 @@ changes, or look through the Subversion logs for all the details.
12101211
uploads thanks to an added *rest* parameter (patch by Pablo Mouzo;
12111212
:issue:`6845`.)
12121213

1213-
* New class decorator: :func:`total_ordering` in the :mod:`functools`
1214+
* New class decorator: :func:`~functools.total_ordering` in the :mod:`functools`
12141215
module takes a class that defines an :meth:`__eq__` method and one of
12151216
:meth:`__lt__`, :meth:`__le__`, :meth:`__gt__`, or :meth:`__ge__`,
12161217
and generates the missing comparison methods. Since the
12171218
:meth:`__cmp__` method is being deprecated in Python 3.x,
12181219
this decorator makes it easier to define ordered classes.
12191220
(Added by Raymond Hettinger; :issue:`5479`.)
12201221

1221-
New function: :func:`cmp_to_key` will take an old-style comparison
1222+
New function: :func:`~functools.cmp_to_key` will take an old-style comparison
12221223
function that expects two arguments and return a new callable that
12231224
can be used as the *key* parameter to functions such as
12241225
:func:`sorted`, :func:`min` and :func:`max`, etc. The primary
@@ -1345,7 +1346,7 @@ changes, or look through the Subversion logs for all the details.
13451346
with any object literal that decodes to a list of pairs.
13461347
(Contributed by Raymond Hettinger; :issue:`5381`.)
13471348

1348-
* The :mod:`mailbox` module's :class:`Maildir` class now records the
1349+
* The :mod:`mailbox` module's :class:`~mailbox.Maildir` class now records the
13491350
timestamp on the directories it reads, and only re-reads them if the
13501351
modification time has subsequently changed. This improves
13511352
performance by avoiding unneeded directory scans. (Fixed by
@@ -1466,10 +1467,10 @@ changes, or look through the Subversion logs for all the details.
14661467
defaults to False; if overridden to be True,
14671468
new request connections will have the TCP_NODELAY option set to
14681469
prevent buffering many small sends into a single TCP packet.
1469-
The :attr:`~SocketServer.TCPServer.timeout` class attribute can hold
1470+
The :attr:`~SocketServer.BaseServer.timeout` class attribute can hold
14701471
a timeout in seconds that will be applied to the request socket; if
1471-
no request is received within that time, :meth:`handle_timeout`
1472-
will be called and :meth:`handle_request` will return.
1472+
no request is received within that time, :meth:`~SocketServer.BaseServer.handle_timeout`
1473+
will be called and :meth:`~SocketServer.BaseServer.handle_request` will return.
14731474
(Contributed by Kristján Valur Jónsson; :issue:`6192` and :issue:`6267`.)
14741475

14751476
* Updated module: the :mod:`sqlite3` module has been updated to
@@ -1479,7 +1480,7 @@ changes, or look through the Subversion logs for all the details.
14791480
and then call :meth:`~sqlite3.Connection.load_extension` to load a particular shared library.
14801481
(Updated by Gerhard Häring.)
14811482

1482-
* The :mod:`ssl` module's :class:`ssl.SSLSocket` objects now support the
1483+
* The :mod:`ssl` module's :class:`~ssl.SSLSocket` objects now support the
14831484
buffer API, which fixed a test suite failure (fix by Antoine Pitrou;
14841485
:issue:`7133`) and automatically set
14851486
OpenSSL's :cmacro:`SSL_MODE_AUTO_RETRY`, which will prevent an error
@@ -1535,7 +1536,7 @@ changes, or look through the Subversion logs for all the details.
15351536
on receiving an :const:`EINTR` signal. (Reported by several people; final
15361537
patch by Gregory P. Smith in :issue:`1068268`.)
15371538

1538-
* New function: :func:`~symtable.is_declared_global` in the :mod:`symtable` module
1539+
* New function: :func:`~symtable.Symbol.is_declared_global` in the :mod:`symtable` module
15391540
returns true for variables that are explicitly declared to be global,
15401541
false for ones that are implicitly global.
15411542
(Contributed by Jeremy Hylton.)
@@ -1716,7 +1717,7 @@ Some of the functions in the module are:
17161717
Makefile and the :file:`pyconfig.h` file.
17171718
* :func:`~sysconfig.get_config_vars` returns a dictionary containing
17181719
all of the configuration variables.
1719-
* :func:`~sysconfig.getpath` returns the configured path for
1720+
* :func:`~sysconfig.get_path` returns the configured path for
17201721
a particular type of module: the standard library,
17211722
site-specific modules, platform-specific modules, etc.
17221723
* :func:`~sysconfig.is_python_build` returns true if you're running a
@@ -1778,7 +1779,7 @@ any importable test files named ``test*.py``::
17781779
Consult the :mod:`unittest` module documentation for more details.
17791780
(Developed in :issue:`6001`.)
17801781

1781-
The :func:`main` function supports some other new options:
1782+
The :func:`~unittest.main` function supports some other new options:
17821783

17831784
* :option:`-b` or :option:`--buffer` will buffer the standard output
17841785
and standard error streams during each test. If the test passes,
@@ -1796,7 +1797,7 @@ The :func:`main` function supports some other new options:
17961797
being tested or the tests being run have defined a signal handler of
17971798
their own, by noticing that a signal handler was already set and
17981799
calling it. If this doesn't work for you, there's a
1799-
:func:`removeHandler` decorator that can be used to mark tests that
1800+
:func:`~unittest.removeHandler` decorator that can be used to mark tests that
18001801
should have the control-C handling disabled.
18011802

18021803
* :option:`-f` or :option:`--failfast` makes
@@ -1923,7 +1924,7 @@ GvR worked on merging them into Python's version of :mod:`unittest`.
19231924

19241925
:func:`unittest.main` now takes an optional ``exit`` argument. If
19251926
False, :func:`~unittest.main` doesn't call :func:`sys.exit`, allowing
1926-
:func:`main` to be used from the interactive interpreter.
1927+
:func:`~unittest.main` to be used from the interactive interpreter.
19271928
(Contributed by J. Pablo Fernández; :issue:`3379`.)
19281929

19291930
:class:`~unittest.TestResult` has new :meth:`~unittest.TestResult.startTestRun` and
@@ -2117,7 +2118,7 @@ Changes to Python's build process and to the C API include:
21172118
:cmacro:`Py_ISSPACE`,
21182119
:cmacro:`Py_ISUPPER`,
21192120
:cmacro:`Py_ISXDIGIT`,
2120-
and :cmacro:`Py_TOLOWER`, :cmacro:`Py_TOUPPER`.
2121+
:cmacro:`Py_TOLOWER`, and :cmacro:`Py_TOUPPER`.
21212122
All of these functions are analogous to the C
21222123
standard macros for classifying characters, but ignore the current
21232124
locale setting, because in
@@ -2263,11 +2264,11 @@ Port-Specific Changes: Windows
22632264
(Contributed by David Cournapeau; :issue:`4365`.)
22642265

22652266
* The :mod:`_winreg` module for accessing the registry now implements
2266-
the :func:`CreateKeyEx` and :func:`DeleteKeyEx` functions, extended
2267-
versions of previously-supported functions that take several extra
2268-
arguments. The :func:`DisableReflectionKey`,
2269-
:func:`EnableReflectionKey`, and :func:`QueryReflectionKey` were also
2270-
tested and documented.
2267+
the :func:`~_winreg.CreateKeyEx` and :func:`~_winreg.DeleteKeyEx`
2268+
functions, extended versions of previously-supported functions that
2269+
take several extra arguments. The :func:`~_winreg.DisableReflectionKey`,
2270+
:func:`~_winreg.EnableReflectionKey`, and :func:`~_winreg.QueryReflectionKey`
2271+
were also tested and documented.
22712272
(Implemented by Brian Curtin: :issue:`7347`.)
22722273

22732274
* The new :cfunc:`_beginthreadex` API is used to start threads, and
@@ -2384,20 +2385,20 @@ that may require changes to your code:
23842385

23852386
In the standard library:
23862387

2387-
* Operations with :class:`datetime` instances that resulted in a year
2388+
* Operations with :class:`~datetime.datetime` instances that resulted in a year
23882389
falling outside the supported range didn't always raise
23892390
:exc:`OverflowError`. Such errors are now checked more carefully
23902391
and will now raise the exception. (Reported by Mark Leander, patch
23912392
by Anand B. Pillai and Alexander Belopolsky; :issue:`7150`.)
23922393

2393-
* When using :class:`Decimal` instances with a string's
2394+
* When using :class:`~decimal.Decimal` instances with a string's
23942395
:meth:`format` method, the default alignment was previously
23952396
left-alignment. This has been changed to right-alignment, which might
23962397
change the output of your programs.
23972398
(Changed by Mark Dickinson; :issue:`6857`.)
23982399

23992400
Comparisons involving a signaling NaN value (or ``sNAN``) now signal
2400-
:const:`InvalidOperation` instead of silently returning a true or
2401+
:const:`~decimal.InvalidOperation` instead of silently returning a true or
24012402
false value depending on the comparison operator. Quiet NaN values
24022403
(or ``NaN``) are now hashable. (Fixed by Mark Dickinson;
24032404
:issue:`7279`.)
@@ -2408,7 +2409,7 @@ In the standard library:
24082409
or comment (which looks like `<!-- comment -->`).
24092410
(Patch by Neil Muller; :issue:`2746`.)
24102411

2411-
* The :meth:`readline` method of :class:`StringIO` objects now does
2412+
* The :meth:`~StringIO.StringIO.readline` method of :class:`~StringIO.StringIO` objects now does
24122413
nothing when a negative length is requested, as other file-like
24132414
objects do. (:issue:`7348`).
24142415

0 commit comments

Comments
 (0)