Skip to content

Commit d8654cf

Browse files
committed
Merged revisions 59259-59274 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk ........ r59260 | lars.gustaebel | 2007-12-01 22:02:12 +0100 (Sat, 01 Dec 2007) | 5 lines Issue python#1531: Read fileobj from the current offset, do not seek to the start. (will backport to 2.5) ........ r59262 | georg.brandl | 2007-12-01 23:24:47 +0100 (Sat, 01 Dec 2007) | 4 lines Document PyEval_* functions from ceval.c. Credits to Michael Sloan from GHOP. ........ r59263 | georg.brandl | 2007-12-01 23:27:56 +0100 (Sat, 01 Dec 2007) | 2 lines Add a few refcount data entries. ........ r59264 | georg.brandl | 2007-12-01 23:38:48 +0100 (Sat, 01 Dec 2007) | 4 lines Add test suite for cmd module. Written by Michael Schneider for GHOP. ........ r59265 | georg.brandl | 2007-12-01 23:42:46 +0100 (Sat, 01 Dec 2007) | 3 lines Add examples to the ElementTree documentation. Written by h4wk.cz for GHOP. ........ r59266 | georg.brandl | 2007-12-02 00:12:45 +0100 (Sun, 02 Dec 2007) | 3 lines Add "Using Python on Windows" document, by Robert Lehmann. Written for GHOP. ........ r59271 | georg.brandl | 2007-12-02 15:34:34 +0100 (Sun, 02 Dec 2007) | 3 lines Add example to mmap docs. Written for GHOP by Rafal Rawicki. ........ r59272 | georg.brandl | 2007-12-02 15:37:29 +0100 (Sun, 02 Dec 2007) | 2 lines Convert bdb.rst line endings to Unix style. ........ r59274 | georg.brandl | 2007-12-02 15:58:50 +0100 (Sun, 02 Dec 2007) | 4 lines Add more entries to the glossary. Written by Jeff Wheeler for GHOP. ........
1 parent b27ce7e commit d8654cf

35 files changed

+1314
-432
lines changed

Doc/ACKS.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,7 @@ docs@python.org), and we'll be glad to correct the problem.
163163
* Justin Sheehy
164164
* Michael Simcich
165165
* Ionel Simionescu
166+
* Michael Sloan
166167
* Gregory P. Smith
167168
* Roy Smith
168169
* Clay Spence
@@ -185,6 +186,7 @@ docs@python.org), and we'll be glad to correct the problem.
185186
* Glyn Webster
186187
* Bob Weiner
187188
* Eddy Welbourne
189+
* Jeff Wheeler
188190
* Mats Wichmann
189191
* Gerry Wiener
190192
* Timothy Wild

Doc/Makefile

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,10 @@ htmlhelp: build
5757
@echo "Build finished; now you can run HTML Help Workshop with the" \
5858
"build/htmlhelp/pydoc.hhp project file."
5959

60+
latex: BUILDER = latex
61+
latex: build
62+
@echo "Build finished; the LaTeX files are in build/latex."
63+
6064
clean:
6165
-rm -rf build/*
6266
-rm -rf tools/sphinx

Doc/README.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,9 @@ Available make targets are:
5353
To create the CHM file, you need to run the Microsoft HTML Help Workshop
5454
over the generated project (.hhp) file.
5555

56+
* "latex", which builds LaTeX source files that can be run with "pdflatex"
57+
to produce PDF documents.
58+
5659
A "make update" updates the Subversion checkouts in `tools/`.
5760

5861

Doc/c-api/init.rst

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -615,6 +615,14 @@ supports the creation of additional interpreters (using
615615
deadlock ensues. (This function is available even when thread support is
616616
disabled at compile time.)
617617

618+
619+
.. cfunction:: void PyEval_ReInitThreads()
620+
621+
This function is called from :cfunc:`PyOS_AfterFork` to ensure that newly
622+
created child processes don't hold locks referring to threads which
623+
are not running in the child process.
624+
625+
618626
The following macros are normally used without a trailing semicolon; look for
619627
example usage in the Python source distribution.
620628

@@ -876,6 +884,46 @@ in previous versions.
876884
:cfunc:`PyEval_SetProfile`, except the tracing function does receive line-number
877885
events.
878886

887+
.. cfunction:: PyObject* PyEval_GetCallStats(PyObject *self)
888+
889+
Return a tuple of function call counts. There are constants defined for the
890+
positions within the tuple:
891+
892+
+-------------------------------+-------+
893+
| Name | Value |
894+
+===============================+=======+
895+
| :const:`PCALL_ALL` | 0 |
896+
+-------------------------------+-------+
897+
| :const:`PCALL_FUNCTION` | 1 |
898+
+-------------------------------+-------+
899+
| :const:`PCALL_FAST_FUNCTION` | 2 |
900+
+-------------------------------+-------+
901+
| :const:`PCALL_FASTER_FUNCTION`| 3 |
902+
+-------------------------------+-------+
903+
| :const:`PCALL_METHOD` | 4 |
904+
+-------------------------------+-------+
905+
| :const:`PCALL_BOUND_METHOD` | 5 |
906+
+-------------------------------+-------+
907+
| :const:`PCALL_CFUNCTION` | 6 |
908+
+-------------------------------+-------+
909+
| :const:`PCALL_TYPE` | 7 |
910+
+-------------------------------+-------+
911+
| :const:`PCALL_GENERATOR` | 8 |
912+
+-------------------------------+-------+
913+
| :const:`PCALL_OTHER` | 9 |
914+
+-------------------------------+-------+
915+
| :const:`PCALL_POP` | 10 |
916+
+-------------------------------+-------+
917+
918+
:const:`PCALL_FAST_FUNCTION` means no argument tuple needs to be created.
919+
:const:`PCALL_FASTER_FUNCTION` means that the fast-path frame setup code is used.
920+
921+
If there is a method call where the call can be optimized by changing
922+
the argument tuple and calling the function directly, it gets recorded
923+
twice.
924+
925+
This function is only present if Python is compiled with :const:`CALL_PROFILE`
926+
defined.
879927

880928
.. _advanced-debugging:
881929

Doc/c-api/utilities.rst

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -989,3 +989,52 @@ The following functions provide locale-independent string to number conversions.
989989

990990
See the Unix man page :manpage:`atof(2)` for details.
991991

992+
993+
.. _reflection:
994+
995+
Reflection
996+
==========
997+
998+
.. cfunction:: PyObject* PyEval_GetBuiltins()
999+
1000+
Return a dictionary of the builtins in the current execution frame,
1001+
or the interpreter of the thread state if no frame is currently executing.
1002+
1003+
1004+
.. cfunction:: PyObject* PyEval_GetLocals()
1005+
1006+
Return a dictionary of the local variables in the current execution frame,
1007+
or *NULL* if no frame is currently executing.
1008+
1009+
1010+
.. cfunction:: PyObject* PyEval_GetGlobals()
1011+
1012+
Return a dictionary of the global variables in the current execution frame,
1013+
or *NULL* if no frame is currently executing.
1014+
1015+
1016+
.. cfunction:: PyFrameObject* PyEval_GetFrame()
1017+
1018+
Return the current thread state's frame, which is *NULL* if no frame is
1019+
currently executing.
1020+
1021+
1022+
.. cfunction:: int PyEval_GetRestricted()
1023+
1024+
If there is a current frame and it is executing in restricted mode, return true,
1025+
otherwise false.
1026+
1027+
1028+
.. cfunction:: const char* PyEval_GetFuncName(PyObject *func)
1029+
1030+
Return the name of *func* if it is a function, class or instance object, else the
1031+
name of *func*\s type.
1032+
1033+
1034+
.. cfunction:: const char* PyEval_GetFuncDesc(PyObject *func)
1035+
1036+
Return a description string, depending on the type of *func*.
1037+
Return values include "()" for functions and methods, " constructor",
1038+
" instance", and " object". Concatenated with the result of
1039+
:cfunc:`PyEval_GetFuncName`, the result will be a description of
1040+
*func*.

Doc/c-api/veryhigh.rst

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -229,6 +229,43 @@ the same library that the Python runtime is using.
229229
be parsed or compiled.
230230

231231

232+
.. cfunction:: PyObject* PyEval_EvalCode(PyCodeObject *co, PyObject *globals, PyObject *locals)
233+
234+
This is a simplified interface to :cfunc:`PyEval_EvalCodeEx`, with just
235+
the code object, and the dictionaries of global and local variables.
236+
The other arguments are set to *NULL*.
237+
238+
239+
.. cfunction:: PyObject* PyEval_EvalCodeEx(PyCodeObject *co, PyObject *globals, PyObject *locals, PyObject **args, int argcount, PyObject **kws, int kwcount, PyObject **defs, int defcount, PyObject *closure)
240+
241+
Evaluate a precompiled code object, given a particular environment for its
242+
evaluation. This environment consists of dictionaries of global and local
243+
variables, arrays of arguments, keywords and defaults, and a closure tuple of
244+
cells.
245+
246+
247+
.. cfunction:: PyObject* PyEval_EvalFrame(PyFrameObject *f)
248+
249+
Evaluate an execution frame. This is a simplified interface to
250+
PyEval_EvalFrameEx, for backward compatibility.
251+
252+
253+
.. cfunction:: PyObject* PyEval_EvalFrameEx(PyFrameObject *f, int throwflag)
254+
255+
This is the main, unvarnished function of Python interpretation. It is
256+
literally 2000 lines long. The code object associated with the execution
257+
frame *f* is executed, interpreting bytecode and executing calls as needed.
258+
The additional *throwflag* parameter can mostly be ignored - if true, then
259+
it causes an exception to immediately be thrown; this is used for the
260+
:meth:`throw` methods of generator objects.
261+
262+
263+
.. cfunction:: int PyEval_MergeCompilerFlags(PyCompilerFlags *cf)
264+
265+
This function changes the flags of the current evaluation frame, and returns
266+
true on success, false on failure.
267+
268+
232269
.. cvar:: int Py_eval_input
233270

234271
.. index:: single: Py_CompileString()

Doc/data/refcounts.dat

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -309,6 +309,11 @@ PyEval_AcquireLock:void:::
309309
PyEval_AcquireThread:void:::
310310
PyEval_AcquireThread:PyThreadState*:tstate::
311311

312+
PyEval_GetBuiltins:PyObject*::0:
313+
PyEval_GetLocals:PyObject*::0:
314+
PyEval_GetGlobals:PyObject*::0:
315+
PyEval_GetFrame:PyObject*::0:
316+
312317
PyEval_InitThreads:void:::
313318

314319
PyEval_ReleaseLock:void:::

Doc/distutils/extending.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
.. _extending:
1+
.. _extending-distutils:
22

33
*******************
44
Extending Distutils

Doc/extending/extending.rst

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -466,10 +466,10 @@ Later, when it is time to call the function, you call the C function
466466
:cfunc:`PyEval_CallObject`. This function has two arguments, both pointers to
467467
arbitrary Python objects: the Python function, and the argument list. The
468468
argument list must always be a tuple object, whose length is the number of
469-
arguments. To call the Python function with no arguments, pass an empty tuple;
470-
to call it with one argument, pass a singleton tuple. :cfunc:`Py_BuildValue`
471-
returns a tuple when its format string consists of zero or more format codes
472-
between parentheses. For example::
469+
arguments. To call the Python function with no arguments, pass in NULL, or
470+
an empty tuple; to call it with one argument, pass a singleton tuple.
471+
:cfunc:`Py_BuildValue` returns a tuple when its format string consists of zero
472+
or more format codes between parentheses. For example::
473473

474474
int arg;
475475
PyObject *arglist;
@@ -527,9 +527,22 @@ event code, you might use the following code::
527527
Py_DECREF(result);
528528

529529
Note the placement of ``Py_DECREF(arglist)`` immediately after the call, before
530-
the error check! Also note that strictly spoken this code is not complete:
530+
the error check! Also note that strictly speaking this code is not complete:
531531
:cfunc:`Py_BuildValue` may run out of memory, and this should be checked.
532532

533+
You may also call a function with keyword arguments by using
534+
:cfunc:`PyEval_CallObjectWithKeywords`. As in the above example, we use
535+
:cfunc:`Py_BuildValue` to construct the dictionary. ::
536+
537+
PyObject *dict;
538+
...
539+
dict = Py_BuildValue("{s:i}", "name", val);
540+
result = PyEval_CallObjectWithKeywords(my_callback, NULL, dict);
541+
Py_DECREF(dict);
542+
if (result == NULL)
543+
return NULL; /* Pass error back */
544+
/* Here maybe use the result */
545+
Py_DECREF(result);
533546

534547
.. _parsetuple:
535548

0 commit comments

Comments
 (0)