Skip to content

Commit cab2ef5

Browse files
[3.13] gh-126890: Restore stripped ssl docstrings (GH-127281) (#127513)
(cherry picked from commit c112de1) Co-authored-by: Peter Bierma <zintensitydev@gmail.com>
1 parent f41d8d8 commit cab2ef5

File tree

2 files changed

+153
-125
lines changed

2 files changed

+153
-125
lines changed

Modules/_ssl.c

+50-13
Original file line numberDiff line numberDiff line change
@@ -2155,11 +2155,17 @@ _ssl__SSLSocket_compression_impl(PySSLSocket *self)
21552155
@critical_section
21562156
@getter
21572157
_ssl._SSLSocket.context
2158+
2159+
This changes the context associated with the SSLSocket.
2160+
2161+
This is typically used from within a callback function set by the sni_callback
2162+
on the SSLContext to change the certificate information associated with the
2163+
SSLSocket before the cryptographic exchange handshake messages.
21582164
[clinic start generated code]*/
21592165

21602166
static PyObject *
21612167
_ssl__SSLSocket_context_get_impl(PySSLSocket *self)
2162-
/*[clinic end generated code: output=d23e82f72f32e3d7 input=25aa82e4d9fa344a]*/
2168+
/*[clinic end generated code: output=d23e82f72f32e3d7 input=7cbb97407c2ace30]*/
21632169
{
21642170
return Py_NewRef(self->ctx);
21652171
}
@@ -2226,11 +2232,15 @@ _ssl__SSLSocket_server_hostname_get_impl(PySSLSocket *self)
22262232
@critical_section
22272233
@getter
22282234
_ssl._SSLSocket.owner
2235+
2236+
The Python-level owner of this object.
2237+
2238+
Passed as "self" in servername callback.
22292239
[clinic start generated code]*/
22302240

22312241
static PyObject *
22322242
_ssl__SSLSocket_owner_get_impl(PySSLSocket *self)
2233-
/*[clinic end generated code: output=1f278cb930382927 input=bc2861ff3cf1402e]*/
2243+
/*[clinic end generated code: output=1f278cb930382927 input=978a8382d9c25c92]*/
22342244
{
22352245
if (self->owner == NULL) {
22362246
Py_RETURN_NONE;
@@ -2844,11 +2854,13 @@ _ssl__SSLSocket_verify_client_post_handshake_impl(PySSLSocket *self)
28442854
@critical_section
28452855
@getter
28462856
_ssl._SSLSocket.session
2857+
2858+
The underlying SSLSession object.
28472859
[clinic start generated code]*/
28482860

28492861
static PyObject *
28502862
_ssl__SSLSocket_session_get_impl(PySSLSocket *self)
2851-
/*[clinic end generated code: output=a5cd5755b35da670 input=b9792df9255a9f63]*/
2863+
/*[clinic end generated code: output=a5cd5755b35da670 input=d427318604244bf8]*/
28522864
{
28532865
/* get_session can return sessions from a server-side connection,
28542866
* it does not check for handshake done or client socket. */
@@ -3650,11 +3662,13 @@ _ssl__SSLContext_maximum_version_set_impl(PySSLContext *self,
36503662
@critical_section
36513663
@getter
36523664
_ssl._SSLContext.num_tickets
3665+
3666+
Control the number of TLSv1.3 session tickets.
36533667
[clinic start generated code]*/
36543668

36553669
static PyObject *
36563670
_ssl__SSLContext_num_tickets_get_impl(PySSLContext *self)
3657-
/*[clinic end generated code: output=3d06d016318846c9 input=1dee26d75163c073]*/
3671+
/*[clinic end generated code: output=3d06d016318846c9 input=1e2599a2e22564ff]*/
36583672
{
36593673
// Clinic seems to be misbehaving when the comment is wrapped with in directive
36603674
#if defined(TLS1_3_VERSION) && !defined(OPENSSL_NO_TLS1_3)
@@ -3698,11 +3712,13 @@ _ssl__SSLContext_num_tickets_set_impl(PySSLContext *self, PyObject *value)
36983712
@critical_section
36993713
@getter
37003714
_ssl._SSLContext.security_level
3715+
3716+
The current security level.
37013717
[clinic start generated code]*/
37023718

37033719
static PyObject *
37043720
_ssl__SSLContext_security_level_get_impl(PySSLContext *self)
3705-
/*[clinic end generated code: output=56ece09e6a9572d0 input=a0416598e07c3183]*/
3721+
/*[clinic end generated code: output=56ece09e6a9572d0 input=2bdeecb57bb86e3f]*/
37063722
{
37073723
PyObject *res = PyLong_FromLong(SSL_CTX_get_security_level(self->ctx));
37083724
return res;
@@ -4659,11 +4675,18 @@ _servername_callback(SSL *s, int *al, void *args)
46594675
@critical_section
46604676
@getter
46614677
_ssl._SSLContext.sni_callback
4678+
4679+
Set a callback that will be called when a server name is provided by the SSL/TLS client in the SNI extension.
4680+
4681+
If the argument is None then the callback is disabled. The method is called
4682+
with the SSLSocket, the server name as a string, and the SSLContext object.
4683+
4684+
See RFC 6066 for details of the SNI extension.
46624685
[clinic start generated code]*/
46634686

46644687
static PyObject *
46654688
_ssl__SSLContext_sni_callback_get_impl(PySSLContext *self)
4666-
/*[clinic end generated code: output=961e6575cdfaf036 input=22dd28c31fdc4318]*/
4689+
/*[clinic end generated code: output=961e6575cdfaf036 input=9b2473c5e984cfe6]*/
46674690
{
46684691
PyObject *cb = self->set_sni_cb;
46694692
if (cb == NULL) {
@@ -5236,11 +5259,13 @@ memory_bio_dealloc(PySSLMemoryBIO *self)
52365259
@critical_section
52375260
@getter
52385261
_ssl.MemoryBIO.pending
5262+
5263+
The number of bytes pending in the memory BIO.
52395264
[clinic start generated code]*/
52405265

52415266
static PyObject *
52425267
_ssl_MemoryBIO_pending_get_impl(PySSLMemoryBIO *self)
5243-
/*[clinic end generated code: output=19236a32a51ac8ff input=c0b6d14eba107f6a]*/
5268+
/*[clinic end generated code: output=19236a32a51ac8ff input=02d9063d8ac31732]*/
52445269
{
52455270
size_t res = BIO_ctrl_pending(self->bio);
52465271
return PyLong_FromSize_t(res);
@@ -5250,11 +5275,13 @@ _ssl_MemoryBIO_pending_get_impl(PySSLMemoryBIO *self)
52505275
@critical_section
52515276
@getter
52525277
_ssl.MemoryBIO.eof
5278+
5279+
Whether the memory BIO is at EOF.
52535280
[clinic start generated code]*/
52545281

52555282
static PyObject *
52565283
_ssl_MemoryBIO_eof_get_impl(PySSLMemoryBIO *self)
5257-
/*[clinic end generated code: output=c255a9ea16e31b92 input=0f5c6be69752e04c]*/
5284+
/*[clinic end generated code: output=c255a9ea16e31b92 input=c6ecc12c4509de1f]*/
52585285
{
52595286
size_t pending = BIO_ctrl_pending(self->bio);
52605287
return PyBool_FromLong((pending == 0) && self->eof_written);
@@ -5495,11 +5522,13 @@ PySSLSession_clear(PySSLSession *self)
54955522
@critical_section
54965523
@getter
54975524
_ssl.SSLSession.time
5525+
5526+
Session creation time (seconds since epoch).
54985527
[clinic start generated code]*/
54995528

55005529
static PyObject *
55015530
_ssl_SSLSession_time_get_impl(PySSLSession *self)
5502-
/*[clinic end generated code: output=4b887b9299de9be4 input=8d1e4afd09103279]*/
5531+
/*[clinic end generated code: output=4b887b9299de9be4 input=67f2325284450ae2]*/
55035532
{
55045533
#if OPENSSL_VERSION_NUMBER >= 0x30300000L
55055534
return _PyLong_FromTime_t(SSL_SESSION_get_time_ex(self->session));
@@ -5512,11 +5541,13 @@ _ssl_SSLSession_time_get_impl(PySSLSession *self)
55125541
@critical_section
55135542
@getter
55145543
_ssl.SSLSession.timeout
5544+
5545+
Session timeout (delta in seconds).
55155546
[clinic start generated code]*/
55165547

55175548
static PyObject *
55185549
_ssl_SSLSession_timeout_get_impl(PySSLSession *self)
5519-
/*[clinic end generated code: output=82339c148ab2f7d1 input=ae5e84a9d85df60d]*/
5550+
/*[clinic end generated code: output=82339c148ab2f7d1 input=cd17c2b087c442f2]*/
55205551
{
55215552
long timeout = SSL_SESSION_get_timeout(self->session);
55225553
PyObject *res = PyLong_FromLong(timeout);
@@ -5527,11 +5558,13 @@ _ssl_SSLSession_timeout_get_impl(PySSLSession *self)
55275558
@critical_section
55285559
@getter
55295560
_ssl.SSLSession.ticket_lifetime_hint
5561+
5562+
Ticket life time hint.
55305563
[clinic start generated code]*/
55315564

55325565
static PyObject *
55335566
_ssl_SSLSession_ticket_lifetime_hint_get_impl(PySSLSession *self)
5534-
/*[clinic end generated code: output=c8b6db498136c275 input=d0e06942ddd8d07f]*/
5567+
/*[clinic end generated code: output=c8b6db498136c275 input=f0e2df50961a7806]*/
55355568
{
55365569
unsigned long hint = SSL_SESSION_get_ticket_lifetime_hint(self->session);
55375570
return PyLong_FromUnsignedLong(hint);
@@ -5541,11 +5574,13 @@ _ssl_SSLSession_ticket_lifetime_hint_get_impl(PySSLSession *self)
55415574
@critical_section
55425575
@getter
55435576
_ssl.SSLSession.id
5577+
5578+
Session ID.
55445579
[clinic start generated code]*/
55455580

55465581
static PyObject *
55475582
_ssl_SSLSession_id_get_impl(PySSLSession *self)
5548-
/*[clinic end generated code: output=c532fb96b10c5adf input=e7322372cf6325dd]*/
5583+
/*[clinic end generated code: output=c532fb96b10c5adf input=0a379e64312b776d]*/
55495584

55505585
{
55515586
const unsigned char *id;
@@ -5558,11 +5593,13 @@ _ssl_SSLSession_id_get_impl(PySSLSession *self)
55585593
@critical_section
55595594
@getter
55605595
_ssl.SSLSession.has_ticket
5596+
5597+
Does the session contain a ticket?
55615598
[clinic start generated code]*/
55625599

55635600
static PyObject *
55645601
_ssl_SSLSession_has_ticket_get_impl(PySSLSession *self)
5565-
/*[clinic end generated code: output=aa3ccfc40b10b96d input=1a48ae8955fa9601]*/
5602+
/*[clinic end generated code: output=aa3ccfc40b10b96d input=fa475555f53a5086]*/
55665603
{
55675604
int res = SSL_SESSION_has_ticket(self->session);
55685605
return res ? Py_True : Py_False;

0 commit comments

Comments
 (0)