Commit Graph

237 Commits

Author SHA1 Message Date
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
Fred Drake 5838d0fc84 Document the PyInstance_*() functions and data. 2001-01-28 06:39:35 +00:00
Fred Drake 5566c1ce36 Fixed a bunch of typos caught by Gilles Civario. 2001-01-19 22:48:33 +00:00
Marc-André Lemburg a544ea2354 Undoing the whitespace patches which sneaked into the earlier patch. 2001-01-17 18:04:31 +00:00
Marc-André Lemburg ad7c98e264 This patch adds a new builtin unistr() which behaves like str()
except that it always returns Unicode objects.

A new C API PyObject_Unicode() is also provided.

This closes patch #101664.

Written by Marc-Andre Lemburg. Copyright assigned to Guido van Rossum.
2001-01-17 17:09:53 +00:00
Fred Drake 81473b12b7 The Python/C API deals in PyObject*, not PyDictObject*. 2001-01-08 05:53:53 +00:00
Fred Drake 316ef7c574 Markup nit: Command line options should be marked with \programopt. 2001-01-04 05:56:34 +00:00
Guido van Rossum e22e4b2b59 Oops. The value "0 or +1" for the category argument of PyErr_Warn()
doesn't work.  Make it 0.  (Although it really *should* be 0 or +1 --
the refcount is incremented when it is raised as an exception, but not
otherwise.)
2000-12-19 03:58:11 +00:00
Guido van Rossum 9a18a7ed03 Document Pyerr_Warn().
Add an XXX comment at the beginning expressing disappointment over the
confusing way refcount behavior of arguments is documented.
2000-12-19 03:53:57 +00:00
Guido van Rossum 3dbb406335 Document Pyerr_Warn(). 2000-12-19 03:53:01 +00:00
Fred Drake 6b3f3f2861 In the first discussion showing how to handle exceptions from C, make the
Python equivalent actually equivalent to the C code.  Also, in the C code,
place the "goto" statements on a line by themselves for better visibility
of statements that affect control flow.

This closes bug #123398.
2000-11-29 15:48:22 +00:00
Fred Drake ee814bf2c9 Added documentation for the Py_InitModule*() family of functions. 2000-11-28 22:34:32 +00:00
Fred Drake 0ac000cd54 Updates to reflect pending changes to the XML conversion process. 2000-11-22 16:42:37 +00:00
Fred Drake 8902442e2f Added exception to the rule that the buffer returned by PyString_AsString()
and PyString_AsStringAndSize() for strings that were just created using
PyString_FromStringAndSize(NULL, n).

This closes bug #117377.

Added warning about passing NULL to the concrete object functions; many of
them use the appropriate Py<Type>_Check() test, but do not check for NULL.

"de-allocated" --> "deallocated"
2000-10-23 16:00:54 +00:00
Fred Drake 89fb035248 For PyErr_Format(), note that the exception parameter can be a string or
class, but not an instance (since an instance will be created using the
formatted message string as the constructor parameter).
2000-10-14 05:49:30 +00:00
Fred Drake 5d64421c23 Fix a couple of places where the descriptions of *_GET_SIZE() macros said
they were similar to *_GetSize(); should be similar to *_Size().

Error noted by William Park <parkw@better.net>.
2000-10-07 12:31:50 +00:00
Neil Schemenauer 410cb6be8f The _PyTuple_Resize() last_is_sticky flag must now always be false. 2000-10-05 19:38:24 +00:00
Fred Drake ffe58ca6ef Reversely --> Conversely
This closes SourceForge bug #115673.
2000-09-29 17:31:54 +00:00
Fred Drake 0b71ceaeff Note that including Python.h includes limits.h when available. 2000-09-26 05:51:50 +00:00
Fred Drake 891150bdf2 Added documentation for the new PyModule_*() convenience functions.
This closes SourceForge patch #101233.
2000-09-23 03:25:42 +00:00
Fred Drake 1fa9365066 Added refcount information for the *_InPlace*() API series.
This closes SourceForge bug #114287.
2000-09-22 18:19:37 +00:00
Fred Drake c0e6c5beb2 PyNumber_Coerce() returns an int, not a PyObject *. 2000-09-22 18:17:49 +00:00
Fred Drake ed773ef78d Include the new text on reporting bugs in a few useful places.
This closes SourceForge bug #114792.
2000-09-21 21:35:22 +00:00
Marc-André Lemburg d1ba443206 This patch adds a new Python C API called PyString_AsStringAndSize()
which implements the automatic conversion from Unicode to a string
object using the default encoding.

The new API is then put to use to have eval() and exec accept
Unicode objects as code parameter. This closes bugs #110924
and #113890.

As side-effect, the traditional C APIs PyString_Size() and
PyString_AsString() will also accept Unicode objects as
parameters.
2000-09-19 21:04:18 +00:00
Guido van Rossum c96ec6ef2b Document new APIs PyOS_getsig() and PyOS_setsig().
(Is there no macro to document a typedef?)

Fred, please check my latex!
2000-09-16 16:30:48 +00:00
Fred Drake d5d0435617 Use \shortversion in a number of places.
This partially addresses SourceForge bug #114318.
2000-09-14 20:24:17 +00:00
Fred Drake 933f0c38ef Avoid reference to specific versions of Python where possible.
This partially addresses SourceForge bug #114318.
2000-09-14 18:12:48 +00:00
Fred Drake 7740a01096 Thomas Wouters <thomas@xs4all.net>:
Fix up some of the PyNumber_*() documentation.
Add documentation for the InPlace API calls.
2000-09-12 20:27:05 +00:00
Fred Drake f913e542be Vladimir Marangozov <Vladimir.Marangozov@inrialpes.fr>:
Here are some changes to the C API docs. The memory examples & API have
been updated because one malloc family is gone (Py_Malloc).
You'll see other small additions to the "building new types" section
for completeness and some cleanup at the end of the memory section.
2000-09-12 20:17:17 +00:00
Fred Drake 81cccb7563 Added documentation for PySequence_Fast() and PySequence_Fast_GET_ITEM(). 2000-09-12 15:22:05 +00:00
Moshe Zadka 57a5932f13 Update documentation for PyErr_Format, because the function has changed.
Connected to patch 100895
2000-09-01 09:47:20 +00:00
Fred Drake e0d9a83bea Document PyImport_AppendInittab(), PyImport_ExtendInittab(), and
struct _inittab.

This closes SourceForge bug #111499.
2000-09-01 05:30:00 +00:00
Jeremy Hylton b709df3810 refactor __del__ exception handler into PyErr_WriteUnraisable
add sanity check to gc: if an exception occurs during GC, call
PyErr_WriteUnraisable and then call Py_FatalEror.
2000-09-01 02:47:25 +00:00
Fred Drake 17e6343d2d Document PyOS_CheckStack().
Fix a couple of really minor markup nits.
2000-08-31 05:50:40 +00:00
Fred Drake 34c391d743 Correct the reference count information for the parameters of
PyErr_Restore().
2000-08-15 04:36:16 +00:00