Commit Graph

271 Commits

Author SHA1 Message Date
Fred Drake 9ad70f9cb0 Add more text from Guido on the type structure fields.
Small additional changes.
2002-04-16 16:22:24 +00:00
Fred Drake 0e0b6180ba Add documentation for PyObject_Call().
Note that PyObject_Size() is a synonym for PyObject_Length().
This closes SF patch #544330 (contributed by Thomas Heller).
2002-04-15 20:51:19 +00:00
Fred Drake 188ecd141a Integrated more text from Guido. 2002-04-15 18:44:46 +00:00
Fred Drake 4d2a95dfe7 Integrate a bunch of new text from Guido. 2002-04-12 22:47:18 +00:00
Fred Drake f495ef7466 Warn people away from PyModule_GetDict(), but not too strongly.
(The real issue is whether modules can benefit from an alternate
implementation strategy rather than using a dictionary.  We should migrate
away from direct dictionary manipulation to allow more room for Jeremy to
flex the implementation with changes in globals lookup.)
2002-04-12 19:32:07 +00:00
Fred Drake 28de8d4b37 Add a (very) simple description of PyType_Ready(). 2002-04-12 16:15:10 +00:00
Fred Drake e3c764b6c2 Document PyType_CheckExact(), PyType_IS_GC().
Update description of PyType_Check().
2002-04-10 17:52:52 +00:00
Fred Drake 4d61775a35 Started filling in the information about some of the basic types and macros
used to define Python objects.
2002-04-09 21:22:07 +00:00
Fred Drake 375e30225e Update to use the new \csimplemacro macro 2002-04-09 21:09:42 +00:00
Tim Peters 87bbdd3085 Minor clarification about what's actually promised for PyMem_Malloc(0).
I probably didn't do a correct thing for the LaTeX spelling of the
integer 1.
2002-04-06 09:14:33 +00:00
Fred Drake 68304ccce3 Move reference material on PyArg_Parse*() out of the Extending & Embedding
document to the C API reference.  Move some instructional text from the API
reference to the Extending & Embedding manual.

Fix the descriptions of the es and es# formats for PyArg_Parse*().
This closes SF bug #536516.
2002-04-05 23:01:14 +00:00
Fred Drake 243ea71669 Correct the descriptions of the PyObject_As*Buffer() return values.
This closes SF bug #539081.
2002-04-04 04:10:36 +00:00
Fred Drake 7bf9715a8b Introduce two new flag bits that can be set in a PyMethodDef method
descriptor, as used for the tp_methods slot of a type.  These new flag
bits are both optional, and mutually exclusive.  Most methods will not
use either.  These flags are used to create special method types which
exist in the same namespace as normal methods without having to use
tedious construction code to insert the new special method objects in
the type's tp_dict after PyType_Ready() has been called.

If METH_CLASS is specified, the method will represent a class method
like that returned by the classmethod() built-in.

If METH_STATIC is specified, the method will represent a static method
like that returned by the staticmethod() built-in.

These flags may not be used in the PyMethodDef table for modules since
these special method types are not meaningful in that case; a
ValueError will be raised if these flags are found in that context.
2002-03-28 05:33:33 +00:00
Skip Montanaro 9e38c100ab fix a typo in PyErr_Format table and add row for 'p' format char
closes bug 534495
2002-03-27 13:42:50 +00:00
Neil Schemenauer 194152845c Fix example for PyErr_SetFromErrno() (need to pass exception type). 2002-03-23 20:57:11 +00:00
Fred Drake 6ccdccd35d Add a note that Py_None needs the same reference count treatment as any
other PyObject *.
This closes SF bug #494007.
2002-03-12 20:12:54 +00:00
Fred Drake 314bae50b9 Documentation for PyObject_GetIter(), contributed by Greg Chapman
(with only minor changes by Fred).
This closes SF bug #498607.
2002-03-11 18:46:29 +00:00
Fred Drake 8371e840d2 Correct the refcount information for the PyWeakref_GetObject() function.
This closes SF bug #520087.
2002-02-20 05:07:36 +00:00
Skip Montanaro ea3ceaa913 PyDict_Next: update doc to indicate that pkey and pvalue return values are
borrowed references.
2002-01-23 10:54:41 +00:00
Skip Montanaro a23bc42ad5 add missing return value info for PyDict_DelItem 2002-01-23 08:18:30 +00:00
Fred Drake 8b8fe288b3 Close an improperly-closed verbatim environment.
This closes SF patch #496215.

Add a little more detail to the example that had not been closed.

Bugfix: this should be made part of 2.2.1.
2001-12-26 16:53:48 +00:00
Fred Drake 54e6294197 A number of small adjustments. 2001-12-11 19:40:16 +00:00
Tim Peters f582b82fe9 SF bug #491415 PyDict_UpdateFromSeq2() unused
PyDict_UpdateFromSeq2():  removed it.
PyDict_MergeFromSeq2():  made it public and documented it.
PyDict_Merge() docs:  updated to reveal <wink> that the second
argument can be any mapping object.
2001-12-11 18:51:08 +00:00
Fred Drake 32a3587345 Document that PyString_FromString() cannot take NULL as a parameter.
This closes SF bug #489872.
2001-12-06 20:38:15 +00:00
Fred Drake 551ffae30c Clarify that the Python runtime may behave mysteriously when an exception
is not handled properly.
This closes SF bug #485153.
2001-12-03 17:56:09 +00:00
Fred Drake 3570551d6f Remove most references to __members__ and __methods__, leaving only one pair
of references that now state that these attributes have been removed,
directing the reader to the dir() function.
This closes SF bug #456420.
2001-12-03 17:32:27 +00:00
Fred Drake f07125ee53 PyErr_Format() does not return a new reference; it always returns NULL.
This closes SF bug #488387.
2001-12-03 16:36:43 +00:00
Fred Drake 454af89712 Update the signature of PyFile_WriteString(). 2001-11-29 22:42:59 +00:00
Fred Drake c37b65ee10 Clean up some markup cruft. A number of the macros that take no
parameters (like \UNIX) are commonly entered using an empty group to
separate the markup from a following inter-word space; this is not
needed when the next character is punctuation, or the markup is the
last thing in the enclosing group.  These cases were marked
inconsistently; the empty group is now *only* used when needed.
2001-11-28 07:26:15 +00:00
Fred Drake cd8474e6a2 Add documentation for the PyCell* APIs. 2001-11-26 21:29:17 +00:00
Fred Drake 50ecc15d05 Add omitted word for clarity. 2001-11-17 06:39:18 +00:00
Thomas Heller bfeeeee851 Fix obvious typos. 2001-11-12 07:46:31 +00:00
Fred Drake 94ead57dc3 Added version annotations, remove hard tabs. 2001-11-09 23:34:26 +00:00
Jeremy Hylton 89c3a22a27 Add PyObject_CheckReadBuffer(), which returns true if its argument
supports the single-segment readable buffer interface.

Add documentation for this and other PyObject_XXXBuffer() calls.
2001-11-09 21:59:42 +00:00
Fred Drake 1b58bff8a0 More refcount information. 2001-10-29 17:43:14 +00:00
Fred Drake b0c079e3e5 PyObject_CallFunctionObArgs() ---> PyObject_CallFunctionObjArgs()
PyObject_CallMethodObArgs() ---> PyObject_CallMethodObjArgs()
2001-10-28 02:39:03 +00:00
Fred Drake c44e9eca66 Added docs for PyObject_CallFunctionObArgs() and PyObject_CallMethodObArgs().
Minor cleanups & markup consistency fixes.
2001-10-26 16:38:38 +00:00
Fred Drake 81c7aa2c7b Added refcount data for PyObject_CallFunctionObArgs() and
PyObject_CallMethodObArgs().
2001-10-26 16:29:22 +00:00
Tim Peters 1fc240e851 Generalize dictionary() to accept a sequence of 2-sequences. At the
outer level, the iterator protocol is used for memory-efficiency (the
outer sequence may be very large if fully materialized); at the inner
level, PySequence_Fast() is used for time-efficiency (these should
always be sequences of length 2).

dictobject.c, new functions PyDict_{Merge,Update}FromSeq2.  These are
wholly analogous to PyDict_{Merge,Update}, but process a sequence-of-2-
sequences argument instead of a mapping object.  For now, I left these
functions file static, so no corresponding doc changes.  It's tempting
to change dict.update() to allow a sequence-of-2-seqs argument too.

Also changed the name of dictionary's keyword argument from "mapping"
to "x".  Got a better name?  "mapping_or_sequence_of_pairs" isn't
attractive, although more so than "mosop" <wink>.

abstract.h, abstract.tex:  Added new PySequence_Fast_GET_SIZE function,
much faster than going thru the all-purpose PySequence_Size.

libfuncs.tex:
- Document dictionary().
- Fiddle tuple() and list() to admit that their argument is optional.
- The long-winded repetitions of "a sequence, a container that supports
  iteration, or an iterator object" is getting to be a PITA.  Many
  months ago I suggested factoring this out into "iterable object",
  where the definition of that could include being explicit about
  generators too (as is, I'm not sure a reader outside of PythonLabs
  could guess that "an iterator object" includes a generator call).
- Please check my curly braces -- I'm going blind <0.9 wink>.

abstract.c, PySequence_Tuple():  When PyObject_GetIter() fails, leave
its error msg alone now (the msg it produces has improved since
PySequence_Tuple was generalized to accept iterable objects, and
PySequence_Tuple was also stomping on the msg in cases it shouldn't
have even before PyObject_GetIter grew a better msg).
2001-10-26 05:06:50 +00:00
Fred Drake 847c51a181 Slightly better conformance to the Python C style guide. 2001-10-25 15:53:44 +00:00
Fred Drake c84f2c5068 Documentation for the new PyArg_UnpackTuple() function. 2001-10-23 21:10:18 +00:00
Fred Drake 5bf1ecd503 Update the description of PyTrace_EXCEPT. 2001-10-16 19:23:55 +00:00
Fred Drake 0fae49fc7b Added documentation for the functions listed in marshal.h.
Prompted by Jim Ahlstrom.  This closes SF patch #470614.
2001-10-14 04:45:51 +00:00
Fred Drake 3adf79e3e2 Break the Python/C API manual into smaller files by chapter. This manual
has grown beyond what font-lock will work with using the default (X)Emacs
settings.

Indentation of the description has been made consistent, and a number of
smaller markup adjustments have been made as well.
2001-10-12 19:01:43 +00:00
Fred Drake bf88b68f38 Add documentation for the public API for weak reference objects. 2001-10-05 22:03:58 +00:00
Fred Drake 6f3d82693a Expand the documentation of the low-level tracing/profiling interface.
This reflects what is currently in CVS, which may change before 2.2 is final.
2001-10-03 21:52:51 +00:00
Greg Ward e22871e9ed Typo fix. 2001-09-26 18:12:49 +00:00
Fred Drake f244b2e47c Add more signature information and some descriptions for the new APIs
introduced in Python 2.2.
Add documentation for the slice object interface (not complete).
Added version annotations for several of the Python 2.2 APIs already
documented.
2001-09-24 15:31:50 +00:00
Fred Drake 23a78cf1c1 Add more reference count information. 2001-09-24 15:29:47 +00:00
Fred Drake d61d0d3f6d Added API information for the PyCallIter_*() and PySeqIter_*() functions.
Added signatures for some new PyType_*() functions.
2001-09-23 02:05:26 +00:00
Fred Drake f47d8ef683 Document all the Py*_CheckExact() functions.
Document many more of the PyLong_{As,From}*() functions.
2001-09-20 19:18:52 +00:00
Fred Drake 9c75ff785a Fix parameter for PyInt_Check().
Add refcount information for other recently documented APIs.
2001-09-06 18:06:46 +00:00
Fred Drake f8d7a5d391 Document the PyMethod_* type object, functions, and macros. 2001-09-06 17:12:44 +00:00
Fred Drake 396ca574dd Document the rule that Python.h must be included before any standard
headers.  This is the final checkin for SF bug #458768.
2001-09-06 16:30:30 +00:00
Martin v. Löwis 7c82a3e0fc Patch #449815: Set filesystemencoding based on CODESET. 2001-09-05 17:09:48 +00:00
Tim Peters 7eea37e831 At Guido's suggestion, here's a new C API function, PyObject_Dir(), like
__builtin__.dir().  Moved the guts from bltinmodule.c to object.c.
2001-09-04 22:08:56 +00:00
Neil Schemenauer 55cdc88c09 Update documentation for GC API. Closes SF patch #421893. 2001-08-30 15:24:17 +00:00
Barry Warsaw 8c64a54f75 Refcount info for PyString_FromFormat() and PyString_FromFormatV().
Closes SF patch #455666.
2001-08-28 02:32:04 +00:00
Barry Warsaw c86aa57f58 Documentation for PyString_FromFormat() and PyString_FromFormatV().
Closes SF patch #455666.
2001-08-28 02:31:28 +00:00
Fred Drake 0e40c3d012 Document PyTuple_GET_SIZE(), removing confusing sentence from PyDict_Copy()
description.

This fixes SF bug #453111.
2001-08-20 16:48:59 +00:00
Martin v. Löwis e3eb1f2b23 Patch #427190: Implement and use METH_NOARGS and METH_O. 2001-08-16 13:15:00 +00:00
Fred Drake 680cabb225 Add "exceptions" to the list of fundamental modules
created by Py_Initialize().

This closes SF bug #450621.
2001-08-14 15:32:16 +00:00
Fred Drake 11ee90289c Added documentation for PyDict_Update() and PyDict_Merge(). 2001-08-10 21:31:12 +00:00
Fred Drake 024ef6f493 Remove the bogus flags parameter from the PyFile_WriteString() signature;
it has no such parameter.

This closes SF bug #449761.
2001-08-10 14:27:38 +00:00
Fred Drake 0197858f62 Added documentation for PyNumber_*FloorDivide(), PyNumber_*TrueDivide(),
PyInterpreterState_*Head(), PyInterpreterState_Next(), and
PyThreadState_Next().

Wrapped some long lines, added some others.
2001-08-08 19:14:53 +00:00
Fred Drake 03590c6bdc Reference counting information for PyNumber_*FloorDivide() and
PyNumber_*TrueDivide().
2001-08-08 18:50:18 +00:00
Fred Drake f90490ef94 Move away from apply() to using extended call syntax for some example
fragments when discussing equivalence of thhe C API to what a Python
programmer sees.

Added descriptions of PyEval_SetProfile() and PyEval_SetTrace().
2001-08-02 18:00:28 +00:00
Fred Drake 88fdaa7c9e Typo: PyArgs_ParseTuple --> PyArg_ParseTuple
Moved the PyArg_Parse*(), Py_BuildValue() functions to the Utilities
chapter, added a minimal description and reference to the Extending
manual for Py_BuildValue().
2001-07-20 20:56:11 +00:00
Fred Drake 6d988559a3 Added information on Py_BuildValue(). 2001-07-20 20:55:31 +00:00
Fred Drake 68db730324 Adding what's done of the documentation for the new profiling &
tracing interface.  Incomplete, but better to check it in since I've
been including it in my updates.
2001-07-17 19:48:30 +00:00
Fred Drake 755c23dcc4 Oops, one more caret. 2001-07-14 03:05:53 +00:00
Fred Drake 377fb1e1f6 Fix the markup of the caret charater in a couple of places; LaTeX's
special character bite us again.  ;-(

This fixes SF bug #440911.
2001-07-14 03:01:48 +00:00
Fred Drake fa774872b8 Move the section on concrete numeric objects before the section on
concrete sequence objects, since their API is simpler.

This is in response to a comment in SF bug #440037.
2001-07-11 20:35:37 +00:00
Fred Drake d854831ddd Corrected the refcount information for PyList_SET_ITEM(). 2001-07-10 16:19:13 +00:00
Fred Drake bab2965c7c Document PyObject_New(), PyObject_NewVar(), PyObject_Init(),
PyObject_InitVar(), PyObject_Del(), PyObject_NEW(),
PyObject_NEW_VAR(), and PyObject_DEL().

Add notes to PyMem_Malloc() and PyMem_New() about the memory buffers
not being initialized.

This fixes SF bug #439012.


Added explicit return value information for PyList_SetItem(),
PyDict_SetItem(), and PyDict_SetItemString().  Corrected return type
for PyList_SET_ITEM().

Fixed index entries in the descriptions of PyLong_AsLong() and
PyLong_AsUnignedLong().

This fixes the API manual portion of SF bug #440037.


Note that the headers properly declare everything as 'extern "C"' for
C++ users.

Document _Py_NoneStruct.

Added links to the Extending & Embedding manual for PyArg_ParseTuple()
and PyArg_ParseTupleAndKeywords().

Added note that PyArg_Parse() should not be used in new code.

Fix up a few style nits -- avoid "e.g." and "i.e." -- these make
translation more difficult, as well as reading the English more
difficult for non-native speakers.
2001-07-10 16:10:08 +00:00
Thomas Wouters e30ac57038 Fix for SF bug #436525, reported by Greg Kochanski:
The block/unblock thread macros are called 'Py_BLOCK_THREADS' and
'Py_UNBLOCK_THREADS', not 'Py_BEGIN_BLOCK_THREADS' and
'Py_BEGIN_UNBLOCK_THREADS'.
2001-07-09 14:35:01 +00:00
Fred Drake 8e0c09da62 More reference count information. 2001-07-06 23:31:49 +00:00
Fred Drake 490d34dbad Move license information to a less annoying location in the document.
Add documentation for PyErr_SetFromErrnoWithFilename().
2001-06-20 21:39:12 +00:00
Fred Drake 00d0cb6ec3 Explained more differences between PyList_SetItem() and PyList_SET_ITEM().
In particular, the affect on existing list content was not sufficiently
explained.

This closes SF bug #429554.
2001-06-03 03:12:57 +00:00
Fred Drake 96a2a80065 Users of PySequence_GET_FAST() should get the length of the sequence using
PySequence_Size(), not PyObject_Size(): the later considers the mapping
methods as well as the sequence methods, which is not needed here.  Either
should be equally fast in this case, but PySequence_Size() offers a better
conceptual match.
2001-05-29 18:51:41 +00:00
Fred Drake b2625eb10e Removed information on the old third parameter to _PyTuple_Resize().
Added information on PyIter_Check(), PyIter_Next(),
PyObject_Unicode(), PyString_AsDecodedObject(),
PyString_AsEncodedObject(), and PyThreadState_GetDict().
2001-05-29 15:34:06 +00:00
Fred Drake fac312ff88 Do not start API descriptions with "Does the same, but ..." -- actually
state *which* other function the current one is like, even if the
descriptions are adjacent.

Revise the _PyTuple_Resize() description to reflect the removal of the
third parameter.
2001-05-29 15:13:00 +00:00
Fred Drake 24e621918b Add documentation for Py_Main() and PyThreadState_GetDict(). 2001-05-21 15:56:55 +00:00
Fred Drake fc43d00c17 Typo: "that" --> "than"
This closes SF bug #425320.
2001-05-21 15:03:35 +00:00
Marc-André Lemburg 2d9204199f This patch changes the way the string .encode() method works slightly
and introduces a new method .decode().

The major change is that strg.encode() will no longer try to convert
Unicode returns from the codec into a string, but instead pass along
the Unicode object as-is. The same is now true for all other codec
return types. The underlying C APIs were changed accordingly.

Note that even though this does have the potential of breaking
existing code, the chances are low since conversion from Unicode
previously took place using the default encoding which is normally
set to ASCII rendering this auto-conversion mechanism useless for
most Unicode encodings.

The good news is that you can now use .encode() and .decode() with
much greater ease and that the door was opened for better accessibility
of the builtin codecs.

As demonstration of the new feature, the patch includes a few new
codecs which allow string to string encoding and decoding (rot13,
hex, zip, uu, base64).

Written by Marc-Andre Lemburg. Copyright assigned to the PSF.
2001-05-15 12:00:02 +00:00
Fred Drake a8e0827614 Hmm... better add a version annotation for the Iterator Protocol section. 2001-05-07 17:47:07 +00:00
Fred Drake dbcaeda79a Added documentation for PyIter_Check() and PyIter_Next().
Wrapped a long line.
2001-05-07 17:42:18 +00:00
Marc-André Lemburg 8155e0e541 This patch originated from an idea by Martin v. Loewis who submitted a
patch for sharing single character Unicode objects.

Martin's patch had to be reworked in a number of ways to take Unicode
resizing into consideration as well. Here's what the updated patch
implements:

* Single character Unicode strings in the Latin-1 range are shared
  (not only ASCII chars as in Martin's original patch).

* The ASCII and Latin-1 codecs make use of this optimization,
  providing a noticable speedup for single character strings. Most
  Unicode methods can use the optimization as well (by virtue
  of using PyUnicode_FromUnicode()).

* Some code cleanup was done (replacing memcpy with Py_UNICODE_COPY)

* The PyUnicode_Resize() can now also handle the case of resizing
  unicode_empty which previously resulted in an error.

* Modified the internal API _PyUnicode_Resize() and
  the public PyUnicode_Resize() API to handle references to
  shared objects correctly. The _PyUnicode_Resize() signature
  changed due to this.

* Callers of PyUnicode_FromUnicode() may now only modify the Unicode
  object contents of the returned object in case they called the API
  with NULL as content template.

Note that even though this patch passes the regression tests, there
may still be subtle bugs in the sharing code.
2001-04-23 14:44:21 +00:00
Fred Drake 8d00a0ffc3 Michael Hudson:
Update docs for PyDict_Next() based on the most recent changes to the
dictionary code.

This closes SF patch #409864.
2001-04-13 17:55:02 +00:00
Fred Drake d20d8b319c Work around the conversion of ">>" and "<<" to guillemets. Reported by Ping. 2001-04-13 14:52:39 +00:00
Greg Stein 4d4d0034c0 Correct the documentation for getreadbufferproc and getwritebufferproc.
Fixes bug #233308 from Travis Oliphant.
2001-04-07 16:14:49 +00:00
Fred Drake c6a3cb4baf Document PySequence_Size(), and describe PySequence_Length() as simply an
alternate name for the same function.
2001-04-04 01:25:17 +00:00
Fred Drake 58c8f9f631 Added documentation for PyObject_IsInstance() and PyObject_IsSubclass(). 2001-03-28 21:14:32 +00:00
Fred Drake 8f6df46d40 Strengthen the constraints on calling PyObject_GC_Fini(). 2001-03-23 17:42:09 +00:00
Fred Drake e28d8aef2d Be more clear about the specific rules for supporting the cyclic GC in an
extension object.  Also included an example showing exactly what needs to
be done and nothing else.

This closes SF bug #228591.
2001-03-22 16:30:17 +00:00
Fred Drake c392b570db Integrated an expanded version of some text from Neil Schemenauer about
supporting cyclic garbage collection.  (This is not all of it, but I'm
taking a break!)

Also fixed some markup nits.
2001-03-21 22:15:01 +00:00
Fred Drake 83e01bf6c8 Finally fill in the documentation for the PyDict_Next() function. It is
different enough to actually require an explanation.  ;-)

Fix a couple of PyDictObject* types that should be PyObject* types.
2001-03-16 15:41:29 +00:00
Guido van Rossum 1874c8f23b Document PyErr_WarnExplicit(). 2001-02-28 23:46:44 +00:00
Fred Drake a05460c148 PyTuple_*() functions take PyObject* parameters, not PyTupleObject* values.
This closes SF bug #131304.
2001-02-12 17:38:18 +00:00
Fred Drake f0e08ef9cb Remove an now-false statement about there being only one type flag
defined.
2001-02-03 01:11:26 +00:00