This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: Mistakes in online docs under \"5.3 Pure Embedding\"
Type: Stage:
Components: Documentation Versions: Python 2.4
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: georg.brandl Nosy List: georg.brandl, georg.brandl, mcsmart, pterk
Priority: normal Keywords:

Created on 2005-07-05 14:11 by mcsmart, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Messages (6)
msg25718 - (view) Author: Matt Smart (mcsmart) Date: 2005-07-05 14:11
I'm looking at the "5.3 Pure Embedding" page:
  http://python.org/doc/2.4.1/ext/pure-embedding.html

1.
  pFunc = PyDict_GetItemString(pDict, argv[2]);
- /* pFun: Borrowed reference */
+ /* pFunc: Borrowed reference */

2.
The code snippet in the section starting with "After initializing the 
interpreter," does not follow the code in the example.  It uses 
PyObject_GetAttrString() instead of PyObject_GetItemString(), 
which creates a new reference instead of borrowing one, and 
therefore needs a Py_XDEREF(pFunc) call that is also not in the 
initial example.
msg25719 - (view) Author: Peter van Kampen (pterk) Date: 2005-07-12 10:59
Logged In: YES 
user_id=174455

These seem to have been fixed already in CVS (although I
can't find a duplicate report). Suggest closing.
msg25720 - (view) Author: Georg Brandl (georg.brandl) * (Python committer) Date: 2005-07-12 11:35
Logged In: YES 
user_id=1188172

Only the first part has been fixed. The second is beyond my
decision and must be considered by someone other.
msg25721 - (view) Author: Peter van Kampen (pterk) Date: 2005-07-12 12:57
Logged In: YES 
user_id=174455

Reinhold, I must confess I am confused. I'm trying to
unravel  what goes in in CVS with all the branches. It seems
this was corrected in rev. 1.5 of embedding.tex (from
2002!?). Looking at cvs (HEAD) I also see:

python/dist/src/Doc/ext/embedding.tex (line ~180):

\begin{verbatim}
    pFunc = PyObject_GetAttrString(pModule, argv[2]);
    /* pFunc is a new reference */

    if (pFunc && PyCallable_Check(pFunc)) {
        ...
    }
    Py_XDECREF(pFunc);
\end{verbatim}

This seems to fix the problem? Also looking at 
http://python.org/doc/2.4.1/ext/pure-embedding.html *today*
I don't see 'Borrowed  reference' and but 'a new reference'
and including a PyXDEREF. Am I totally missing the point of
the bug-report or is the time-machine flying again?
msg25722 - (view) Author: Georg Brandl (georg.brandl) * (Python committer) Date: 2005-07-12 13:12
Logged In: YES 
user_id=1188172

I thought the same when I first read this report. On this
HTML page, there's the large code sample at the top, and
below are explanations. In the large sample the code with
GetItemString and without Py_XDECREF. Both are OK, but
different, and that's what the reporter's problem was.

But thanks to your digging in the CVS history, I can tell
that the intended code is the second version with GetAttrString.
msg25723 - (view) Author: Georg Brandl (georg.brandl) * (Python committer) Date: 2005-07-12 13:18
Logged In: YES 
user_id=1188172

Okay. Fixed as Doc/ext/run-func.c r1.4.20.1, r1.5.
History
Date User Action Args
2022-04-11 14:56:12adminsetgithub: 42162
2005-07-05 14:11:47mcsmartcreate