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

Skip to content

Commit 939c178

Browse files
committed
Merged revisions 71874,71882,71890 via svnmerge from
svn+ssh://[email protected]/python/trunk ........ r71874 | jeroen.ruigrok | 2009-04-25 13:59:09 +0200 (za, 25 apr 2009) | 2 lines First attempt to document PyObject_HEAD_INIT and PyVarObject_HEAD_INIT. ........ r71882 | jeroen.ruigrok | 2009-04-25 14:49:10 +0200 (za, 25 apr 2009) | 3 lines Issue #4239: adjust email examples not to use connect() and terminate with quit() and not close(). ........ r71890 | jeroen.ruigrok | 2009-04-25 15:07:40 +0200 (za, 25 apr 2009) | 3 lines Rewrite a sentence to be more in line with the rest of the documentation with regard to person and audience. ........
1 parent f4a9f96 commit 939c178

6 files changed

Lines changed: 29 additions & 15 deletions

File tree

Doc/c-api/init.rst

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -489,13 +489,13 @@ thread could immediately acquire the lock and store its own thread state in the
489489
global variable). Conversely, when acquiring the lock and restoring the thread
490490
state, the lock must be acquired before storing the thread state pointer.
491491

492-
Why am I going on with so much detail about this? Because when threads are
493-
created from C, they don't have the global interpreter lock, nor is there a
494-
thread state data structure for them. Such threads must bootstrap themselves
495-
into existence, by first creating a thread state data structure, then acquiring
496-
the lock, and finally storing their thread state pointer, before they can start
497-
using the Python/C API. When they are done, they should reset the thread state
498-
pointer, release the lock, and finally free their thread state data structure.
492+
It is important to note that when threads are created from C, they don't have
493+
the global interpreter lock, nor is there a thread state data structure for
494+
them. Such threads must bootstrap themselves into existence, by first
495+
creating a thread state data structure, then acquiring the lock, and finally
496+
storing their thread state pointer, before they can start using the Python/C
497+
API. When they are done, they should reset the thread state pointer, release
498+
the lock, and finally free their thread state data structure.
499499

500500
Threads can take advantage of the :cfunc:`PyGILState_\*` functions to do all of
501501
the above automatically. The typical idiom for calling into Python from a C

Doc/c-api/structures.rst

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,24 @@ These macros are used in the definition of :ctype:`PyObject` and
6969
Note that :cmacro:`PyObject_HEAD` is part of the expansion, and that its own
7070
expansion varies depending on the definition of :cmacro:`Py_TRACE_REFS`.
7171

72-
.. cmacro:: PyObject_HEAD_INIT
72+
73+
.. cmacro:: PyObject_HEAD_INIT(type)
74+
75+
This is a macro which expands to initialization values for a new
76+
:ctype:`PyObject` type. This macro expands to::
77+
78+
_PyObject_EXTRA_INIT
79+
1, type,
80+
81+
82+
.. cmacro:: PyVarObject_HEAD_INIT(type, size)
83+
84+
This is a macro which expands to initialization values for a new
85+
:ctype:`PyVarObject` type, including the :attr:`ob_size` field.
86+
This macro expands to::
87+
88+
_PyObject_EXTRA_INIT
89+
1, type, size,
7390

7491

7592
.. ctype:: PyCFunction

Doc/includes/email-alternative.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,4 +45,4 @@
4545
# sendmail function takes 3 arguments: sender's address, recipient's address
4646
# and message to send - here it is sent as one string.
4747
s.sendmail(me, you, msg.as_string())
48-
s.close()
48+
s.quit()

Doc/includes/email-dir.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,9 +106,8 @@ def main():
106106
fp.close()
107107
else:
108108
s = smtplib.SMTP()
109-
s.connect()
110109
s.sendmail(opts.sender, opts.recipients, composed)
111-
s.close()
110+
s.quit()
112111

113112

114113
if __name__ == '__main__':

Doc/includes/email-mime.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,5 @@
2727

2828
# Send the email via our own SMTP server.
2929
s = smtplib.SMTP()
30-
s.connect()
3130
s.sendmail(me, family, msg.as_string())
32-
s.close()
31+
s.quit()

Doc/includes/email-simple.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,5 @@
2020
# Send the message via our own SMTP server, but don't include the
2121
# envelope header.
2222
s = smtplib.SMTP()
23-
s.connect()
2423
s.sendmail(me, [you], msg.as_string())
25-
s.close()
24+
s.quit()

0 commit comments

Comments
 (0)