Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 7d4bfb3

Browse files
committed
Merged revisions 83536,83546-83548,83550,83554-83555,83558,83563,83565,83571,83574-83575 via svnmerge from
svn+ssh://[email protected]/python/branches/py3k ........ r83536 | georg.brandl | 2010-08-02 19:49:25 +0200 (Mo, 02 Aug 2010) | 1 line python#8578: mention danger of not incref'ing weak referenced object. ........ r83546 | georg.brandl | 2010-08-02 21:16:34 +0200 (Mo, 02 Aug 2010) | 1 line python#7973: Fix distutils options spelling. ........ r83547 | georg.brandl | 2010-08-02 21:19:26 +0200 (Mo, 02 Aug 2010) | 1 line python#7386: add example that shows that trailing path separators are stripped. ........ r83548 | georg.brandl | 2010-08-02 21:23:34 +0200 (Mo, 02 Aug 2010) | 1 line python#8172: how does one use a property? ........ r83550 | georg.brandl | 2010-08-02 21:32:43 +0200 (Mo, 02 Aug 2010) | 1 line python#9451: strengthen warning about __*__ special name usage. ........ r83554 | georg.brandl | 2010-08-02 21:43:05 +0200 (Mo, 02 Aug 2010) | 1 line python#7280: note about nasmw.exe. ........ r83555 | georg.brandl | 2010-08-02 21:44:48 +0200 (Mo, 02 Aug 2010) | 1 line python#8861: remove unused variable. ........ r83558 | georg.brandl | 2010-08-02 22:05:19 +0200 (Mo, 02 Aug 2010) | 1 line python#8648: document UTF-7 codec functions. ........ r83563 | georg.brandl | 2010-08-02 22:21:21 +0200 (Mo, 02 Aug 2010) | 1 line python#9037: add example how to raise custom exceptions from C code. ........ r83565 | georg.brandl | 2010-08-02 22:27:20 +0200 (Mo, 02 Aug 2010) | 1 line python#9111: document that do_help() looks at docstrings. ........ r83571 | georg.brandl | 2010-08-02 22:44:34 +0200 (Mo, 02 Aug 2010) | 1 line Clarify that abs() is not a namespace. ........ r83574 | georg.brandl | 2010-08-02 22:47:56 +0200 (Mo, 02 Aug 2010) | 1 line python#6867: epoll.register() returns None. ........ r83575 | georg.brandl | 2010-08-02 22:52:10 +0200 (Mo, 02 Aug 2010) | 1 line python#9238: zipfile does handle archive comments. ........
1 parent 09b7cba commit 7d4bfb3

15 files changed

Lines changed: 90 additions & 27 deletions

File tree

Doc/c-api/unicode.rst

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -567,6 +567,38 @@ These are the UTF-16 codec APIs:
567567
*NULL* if an exception was raised by the codec.
568568

569569

570+
UTF-7 Codecs
571+
""""""""""""
572+
573+
These are the UTF-7 codec APIs:
574+
575+
576+
.. cfunction:: PyObject* PyUnicode_DecodeUTF7(const char *s, Py_ssize_t size, const char *errors)
577+
578+
Create a Unicode object by decoding *size* bytes of the UTF-7 encoded string
579+
*s*. Return *NULL* if an exception was raised by the codec.
580+
581+
582+
.. cfunction:: PyObject* PyUnicode_DecodeUTF8Stateful(const char *s, Py_ssize_t size, const char *errors, Py_ssize_t *consumed)
583+
584+
If *consumed* is *NULL*, behave like :cfunc:`PyUnicode_DecodeUTF7`. If
585+
*consumed* is not *NULL*, trailing incomplete UTF-7 base-64 sections will not
586+
be treated as an error. Those bytes will not be decoded and the number of
587+
bytes that have been decoded will be stored in *consumed*.
588+
589+
590+
.. cfunction:: PyObject* PyUnicode_EncodeUTF7(const Py_UNICODE *s, Py_ssize_t size, int base64SetO, int base64WhiteSpace, const char *errors)
591+
592+
Encode the :ctype:`Py_UNICODE` buffer of the given size using UTF-7 and
593+
return a Python bytes object. Return *NULL* if an exception was raised by
594+
the codec.
595+
596+
If *base64SetO* is nonzero, "Set O" (punctuation that has no otherwise
597+
special meaning) will be encoded in base-64. If *base64WhiteSpace* is
598+
nonzero, whitespace will be encoded in base-64. Both are set to zero for the
599+
Python "utf-7" codec.
600+
601+
570602
Unicode-Escape Codecs
571603
"""""""""""""""""""""
572604

Doc/c-api/weakref.rst

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,10 +63,17 @@ as much as it can.
6363
.. cfunction:: PyObject* PyWeakref_GetObject(PyObject *ref)
6464

6565
Return the referenced object from a weak reference, *ref*. If the referent is
66-
no longer live, returns ``None``.
66+
no longer live, returns :const:`Py_None`.
6767

6868
.. versionadded:: 2.2
6969

70+
.. warning::
71+
72+
This function returns a **borrowed reference** to the referenced object.
73+
This means that you should always call :cfunc:`Py_INCREF` on the object
74+
except if you know that it cannot be destroyed while you are still
75+
using it.
76+
7077

7178
.. cfunction:: PyObject* PyWeakref_GET_OBJECT(PyObject *ref)
7279

Doc/distutils/builtdist.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ easily specify multiple formats in one run. If you need to do both, you can
176176
explicitly specify multiple :command:`bdist_\*` commands and their options::
177177

178178
python setup.py bdist_rpm --packager="John Doe <[email protected]>" \
179-
bdist_wininst --target_version="2.0"
179+
bdist_wininst --target-version="2.0"
180180

181181
Creating RPM packages is driven by a :file:`.spec` file, much as using the
182182
Distutils is driven by the setup script. To make your life easier, the

Doc/extending/extending.rst

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -228,9 +228,28 @@ needed to ensure that it will not be discarded, causing :cdata:`SpamError` to
228228
become a dangling pointer. Should it become a dangling pointer, C code which
229229
raises the exception could cause a core dump or other unintended side effects.
230230

231-
We discuss the use of PyMODINIT_FUNC as a function return type later in this
231+
We discuss the use of ``PyMODINIT_FUNC`` as a function return type later in this
232232
sample.
233233

234+
The :exc:`spam.error` exception can be raised in your extension module using a
235+
call to :cfunc:`PyErr_SetString` as shown below::
236+
237+
static PyObject *
238+
spam_system(PyObject *self, PyObject *args)
239+
{
240+
const char *command;
241+
int sts;
242+
243+
if (!PyArg_ParseTuple(args, "s", &command))
244+
return NULL;
245+
sts = system(command);
246+
if (sts < 0) {
247+
PyErr_SetString(SpamError, "System command failed");
248+
return NULL;
249+
}
250+
return PyLong_FromLong(sts);
251+
}
252+
234253

235254
.. _backtoexample:
236255

Doc/library/cmd.rst

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -80,11 +80,13 @@ A :class:`Cmd` instance has the following methods:
8080
are the beginning and ending indexes of the prefix text, which could be used to
8181
provide different completion depending upon which position the argument is in.
8282

83-
All subclasses of :class:`Cmd` inherit a predefined :meth:`do_help`. This
83+
All subclasses of :class:`Cmd` inherit a predefined :meth:`do_help`. This
8484
method, called with an argument ``'bar'``, invokes the corresponding method
85-
:meth:`help_bar`. With no argument, :meth:`do_help` lists all available help
86-
topics (that is, all commands with corresponding :meth:`help_\*` methods), and
87-
also lists any undocumented commands.
85+
:meth:`help_bar`, and if that is not present, prints the docstring of
86+
:meth:`do_bar`, if available. With no argument, :meth:`do_help` lists all
87+
available help topics (that is, all commands with corresponding
88+
:meth:`help_\*` methods or commands that have docstrings), and also lists any
89+
undocumented commands.
8890

8991

9092
.. method:: Cmd.onecmd(str)

Doc/library/functions.rst

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -874,7 +874,7 @@ available. They are listed here in alphabetical order.
874874

875875
*fget* is a function for getting an attribute value, likewise *fset* is a
876876
function for setting, and *fdel* a function for del'ing, an attribute. Typical
877-
use is to define a managed attribute x::
877+
use is to define a managed attribute ``x``::
878878

879879
class C(object):
880880
def __init__(self):
@@ -888,6 +888,9 @@ available. They are listed here in alphabetical order.
888888
del self._x
889889
x = property(getx, setx, delx, "I'm the 'x' property.")
890890

891+
If then *c* is an instance of *C*, ``c.x`` will invoke the getter,
892+
``c.x = value`` will invoke the setter and ``del c.x`` the deleter.
893+
891894
If given, *doc* will be the docstring of the property attribute. Otherwise, the
892895
property will copy *fget*'s docstring (if it exists). This makes it possible to
893896
create read-only properties easily using :func:`property` as a :term:`decorator`::

Doc/library/os.path.rst

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,9 @@ write files see :func:`open`, and for accessing the filesystem see the
212212
.. function:: normpath(path)
213213

214214
Normalize a pathname. This collapses redundant separators and up-level
215-
references so that ``A//B``, ``A/./B`` and ``A/foo/../B`` all become ``A/B``.
215+
references so that ``A//B``, ``A/B/``, ``A/./B`` and ``A/foo/../B`` all become
216+
``A/B``.
217+
216218
It does not normalize the case (use :func:`normcase` for that). On Windows, it
217219
converts forward slashes to backward slashes. It should be understood that this
218220
may change the meaning of the path if it contains symbolic links!

Doc/library/zipfile.rst

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,8 @@ advanced use of this module will require an understanding of the format, as
1515
defined in `PKZIP Application Note
1616
<http://www.pkware.com/documents/casestudies/APPNOTE.TXT>`_.
1717

18-
This module does not currently handle multi-disk ZIP files, or ZIP files
19-
which have appended comments (although it correctly handles comments
20-
added to individual archive members---for which see the :ref:`zipinfo-objects`
21-
documentation). It can handle ZIP files that use the ZIP64 extensions
18+
This module does not currently handle multi-disk ZIP files.
19+
It can handle ZIP files that use the ZIP64 extensions
2220
(that is ZIP files that are more than 4 GByte in size). It supports
2321
decryption of encrypted files in ZIP archives, but it currently cannot
2422
create an encrypted file. Decryption is extremely slow as it is
@@ -67,7 +65,6 @@ The module defines the following items:
6765

6866
Returns ``True`` if *filename* is a valid ZIP file based on its magic number,
6967
otherwise returns ``False``. *filename* may be a file or file-like object too.
70-
This module does not currently handle ZIP files which have appended comments.
7168

7269
.. versionchanged:: 2.7
7370
Support for file and file-like objects.

Doc/reference/lexical_analysis.rst

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -386,11 +386,12 @@ characters:
386386
information on this convention.
387387

388388
``__*__``
389-
System-defined names. These names are defined by the interpreter and its
390-
implementation (including the standard library); applications should not expect
391-
to define additional names using this convention. The set of names of this
392-
class defined by Python may be extended in future versions. See section
393-
:ref:`specialnames`.
389+
System-defined names. These names are defined by the interpreter and its
390+
implementation (including the standard library). Current system names are
391+
discussed in the :ref:`specialnames` section and elsewhere. More will likely
392+
be defined in future versions of Python. *Any* use of ``__*__`` names, in
393+
any context, that does not follow explicitly documented use, is subject to
394+
breakage without warning.
394395

395396
``__*``
396397
Class-private names. Names in this category, when used within the context of a

Doc/tutorial/classes.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ Let's begin with some definitions.
6464
A *namespace* is a mapping from names to objects. Most namespaces are currently
6565
implemented as Python dictionaries, but that's normally not noticeable in any
6666
way (except for performance), and it may change in the future. Examples of
67-
namespaces are: the set of built-in names (functions such as :func:`abs`, and
67+
namespaces are: the set of built-in names (containing functions such as :func:`abs`, and
6868
built-in exception names); the global names in a module; and the local names in
6969
a function invocation. In a sense the set of attributes of an object also form
7070
a namespace. The important thing to know about namespaces is that there is

0 commit comments

Comments
 (0)