Skip to content

Commit b64e42e

Browse files
miss-islingtonvsajip
authored andcommitted
bpo-37331: Clarify format of socket handler messages in the documentation. (GH-14234) (GH-14236)
(cherry picked from commit f06b569)
1 parent 9eb4b2c commit b64e42e

File tree

1 file changed

+14
-4
lines changed

1 file changed

+14
-4
lines changed

Doc/library/logging.handlers.rst

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -470,7 +470,12 @@ sends logging output to a network socket. The base class uses a TCP socket.
470470
.. method:: makePickle(record)
471471

472472
Pickles the record's attribute dictionary in binary format with a length
473-
prefix, and returns it ready for transmission across the socket.
473+
prefix, and returns it ready for transmission across the socket. The
474+
details of this operation are equivalent to::
475+
476+
data = pickle.dumps(record_attr_dict, 1)
477+
datalen = struct.pack('>L', len(data))
478+
return datalen + data
474479

475480
Note that pickles aren't completely secure. If you are concerned about
476481
security, you may want to override this method to implement a more secure
@@ -481,8 +486,12 @@ sends logging output to a network socket. The base class uses a TCP socket.
481486

482487
.. method:: send(packet)
483488

484-
Send a pickled string *packet* to the socket. This function allows for
485-
partial sends which can happen when the network is busy.
489+
Send a pickled byte-string *packet* to the socket. The format of the sent
490+
byte-string is as described in the documentation for
491+
:meth:`~SocketHandler.makePickle`.
492+
493+
This function allows for partial sends, which can happen when the network
494+
is busy.
486495

487496

488497
.. method:: createSocket()
@@ -543,7 +552,8 @@ over UDP sockets.
543552

544553
.. method:: send(s)
545554

546-
Send a pickled string to a socket.
555+
Send a pickled byte-string to a socket. The format of the sent byte-string
556+
is as described in the documentation for :meth:`SocketHandler.makePickle`.
547557

548558

549559
.. _syslog-handler:

0 commit comments

Comments
 (0)