Skip to content

Commit cc715dc

Browse files
authored
Merge branch 'main' into issue-133682-fix-set-ordering
2 parents 4154a73 + 2cd24eb commit cc715dc

File tree

10 files changed

+46
-19
lines changed

10 files changed

+46
-19
lines changed

Doc/library/ssl.rst

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -934,6 +934,13 @@ Constants
934934

935935
.. versionadded:: 3.13
936936

937+
.. data:: HAS_PSK_TLS13
938+
939+
Whether the OpenSSL library has built-in support for External PSKs in TLS
940+
1.3 as described in :rfc:`9258`.
941+
942+
.. versionadded:: next
943+
937944
.. data:: HAS_PHA
938945

939946
Whether the OpenSSL library has built-in support for TLS-PHA.

Doc/whatsnew/3.15.rst

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -86,10 +86,13 @@ New modules
8686
Improved modules
8787
================
8888

89-
module_name
90-
-----------
89+
ssl
90+
---
91+
92+
* Indicate through :data:`ssl.HAS_PSK_TLS13` whether the :mod:`ssl` module
93+
supports "External PSKs" in TLSv1.3, as described in RFC 9258.
94+
(Contributed by Will Childs-Klein in :gh:`133624`.)
9195

92-
* TODO
9396

9497
.. Add improved modules above alphabetically, not here at the end.
9598

Lib/ssl.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@
116116

117117
from _ssl import (
118118
HAS_SNI, HAS_ECDH, HAS_NPN, HAS_ALPN, HAS_SSLv2, HAS_SSLv3, HAS_TLSv1,
119-
HAS_TLSv1_1, HAS_TLSv1_2, HAS_TLSv1_3, HAS_PSK, HAS_PHA
119+
HAS_TLSv1_1, HAS_TLSv1_2, HAS_TLSv1_3, HAS_PSK, HAS_PSK_TLS13, HAS_PHA
120120
)
121121
from _ssl import _DEFAULT_CIPHERS, _OPENSSL_API_VERSION
122122

Lib/test/test_ssl.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4488,6 +4488,7 @@ def server_callback(identity):
44884488

44894489
@requires_tls_version('TLSv1_3')
44904490
@unittest.skipUnless(ssl.HAS_PSK, 'TLS-PSK disabled on this OpenSSL build')
4491+
@unittest.skipUnless(ssl.HAS_PSK_TLS13, 'TLS 1.3 PSK disabled on this OpenSSL build')
44914492
def test_psk_tls1_3(self):
44924493
psk = bytes.fromhex('deadbeef')
44934494
identity_hint = 'identity-hint'
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Indicate through :data:`ssl.HAS_PSK_TLS13` whether the :mod:`ssl` module supports "External PSKs" in TLSv1.3, as described in RFC 9258. Patch by Will Childs-Klein.

Modules/_io/clinic/stringio.c.h

Lines changed: 5 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Modules/_io/stringio.c

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -444,7 +444,7 @@ stringio_iternext(PyObject *op)
444444
/*[clinic input]
445445
@critical_section
446446
_io.StringIO.truncate
447-
pos as size: Py_ssize_t(accept={int, NoneType}, c_default="((stringio *)self)->pos") = None
447+
pos: object = None
448448
/
449449
450450
Truncate size to pos.
@@ -455,16 +455,26 @@ Returns the new absolute position.
455455
[clinic start generated code]*/
456456

457457
static PyObject *
458-
_io_StringIO_truncate_impl(stringio *self, Py_ssize_t size)
459-
/*[clinic end generated code: output=eb3aef8e06701365 input=fa8a6c98bb2ba780]*/
458+
_io_StringIO_truncate_impl(stringio *self, PyObject *pos)
459+
/*[clinic end generated code: output=c76c43b5ecfaf4e2 input=d59fd2ee49757ae6]*/
460460
{
461461
CHECK_INITIALIZED(self);
462462
CHECK_CLOSED(self);
463463

464-
if (size < 0) {
465-
PyErr_Format(PyExc_ValueError,
466-
"Negative size value %zd", size);
467-
return NULL;
464+
Py_ssize_t size;
465+
if (pos == Py_None) {
466+
size = self->pos;
467+
}
468+
else {
469+
size = PyLong_AsLong(pos);
470+
if (size == -1 && PyErr_Occurred()) {
471+
return NULL;
472+
}
473+
if (size < 0) {
474+
PyErr_Format(PyExc_ValueError,
475+
"negative pos value %zd", size);
476+
return NULL;
477+
}
468478
}
469479

470480
if (size < self->string_size) {

Modules/_ssl.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6626,6 +6626,12 @@ sslmodule_init_constants(PyObject *m)
66266626
addbool(m, "HAS_PSK", 1);
66276627
#endif
66286628

6629+
#ifdef OPENSSL_NO_EXTERNAL_PSK_TLS13
6630+
addbool(m, "HAS_PSK_TLS13", 0);
6631+
#else
6632+
addbool(m, "HAS_PSK_TLS13", 1);
6633+
#endif
6634+
66296635
#ifdef SSL_VERIFY_POST_HANDSHAKE
66306636
addbool(m, "HAS_PHA", 1);
66316637
#else

Python/ast_unparse.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -749,6 +749,7 @@ append_templatestr(PyUnicodeWriter *writer, expr_ty e)
749749
goto error;
750750
}
751751
}
752+
_PyArena_Free(arena);
752753

753754
return 0;
754755

Tools/cases_generator/interpreter_definition.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ and a piece of C code describing its semantics:
8181
(definition | family | pseudo)+
8282
8383
definition:
84-
"inst" "(" NAME ["," stack_effect] ")" "{" C-code "}"
84+
"inst" "(" NAME "," stack_effect ")" "{" C-code "}"
8585
|
8686
"op" "(" NAME "," stack_effect ")" "{" C-code "}"
8787
|

0 commit comments

Comments
 (0)