Skip to content

Commit e59ba68

Browse files
committed
Merge branch 'multi_inputs' of https://github.com/s-ball/cpython into multi_inputs
2 parents 1ecc1f3 + 12acb83 commit e59ba68

File tree

7 files changed

+56
-10
lines changed

7 files changed

+56
-10
lines changed

Doc/library/xmlrpc.client.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,8 @@ between conformable Python objects and XML on the wire.
6161
The *headers* parameter is an optional sequence of HTTP headers to send with
6262
each request, expressed as a sequence of 2-tuples representing the header
6363
name and value. (e.g. ``[('Header-Name', 'value')]``).
64+
If an HTTPS URL is provided, *context* may be :class:`ssl.SSLContext`
65+
and configures the SSL settings of the underlying HTTPS connection.
6466
The obsolete *use_datetime* flag is similar to *use_builtin_types* but it
6567
applies only to date/time values.
6668

@@ -75,9 +77,7 @@ between conformable Python objects and XML on the wire.
7577
portion will be base64-encoded as an HTTP 'Authorization' header, and sent to
7678
the remote server as part of the connection process when invoking an XML-RPC
7779
method. You only need to use this if the remote server requires a Basic
78-
Authentication user and password. If an HTTPS URL is provided, *context* may
79-
be :class:`ssl.SSLContext` and configures the SSL settings of the underlying
80-
HTTPS connection.
80+
Authentication user and password.
8181

8282
The returned instance is a proxy object with methods that can be used to invoke
8383
corresponding RPC calls on the remote server. If the remote server supports the

Lib/test/test_bytes.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2380,12 +2380,22 @@ def ass_subscript(b, a): # MODIFIES!
23802380
b.wait()
23812381
a[:] = c
23822382

2383+
def ass_subscript2(b, a, c): # MODIFIES!
2384+
b.wait()
2385+
a[:] = c
2386+
assert b'\xdd' not in a
2387+
23832388
def mod(b, a):
23842389
c = tuple(range(4096))
23852390
b.wait()
23862391
try: a % c
23872392
except TypeError: pass
23882393

2394+
def mod2(b, a, c):
2395+
b.wait()
2396+
d = a % c
2397+
assert b'\xdd' not in d
2398+
23892399
def repr_(b, a):
23902400
b.wait()
23912401
repr(a)
@@ -2503,7 +2513,9 @@ def check(funcs, a=None, *args):
25032513

25042514
check([clear] + [contains] * 10)
25052515
check([clear] + [subscript] * 10)
2516+
check([clear2] + [ass_subscript2] * 10, None, bytearray(b'0' * 0x400000))
25062517
check([clear] + [mod] * 10, bytearray(b'%d' * 4096))
2518+
check([clear2] + [mod2] * 10, bytearray(b'%s'), bytearray(b'0' * 0x400000))
25072519

25082520
check([clear] + [capitalize] * 10, bytearray(b'a' * 0x40000))
25092521
check([clear] + [center] * 10, bytearray(b'a' * 0x40000))

Lib/test/test_grammar.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1972,6 +1972,18 @@ async def foo():
19721972
with self.assertRaises(Done):
19731973
foo().send(None)
19741974

1975+
def test_complex_lambda(self):
1976+
def test1(foo, bar):
1977+
return ""
1978+
1979+
def test2():
1980+
return f"{test1(
1981+
foo=lambda: '、、、、、、、、、、、、、、、、、',
1982+
bar=lambda: 'abcdefghijklmnopqrstuvwxyz 123456789 123456789',
1983+
)}"
1984+
1985+
self.assertEqual(test2(), "")
1986+
19751987

19761988
if __name__ == '__main__':
19771989
unittest.main()
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Fix two more :class:`bytearray` functions for :term:`free threading`.
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
Fix a bug that was causing ``UnicodeDecodeError`` or ``SystemError`` to be
2+
raised when using f-strings with ``lambda`` expressions with non-ASCII
3+
characters. Patch by Pablo Galindo

Objects/bytearrayobject.c

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -864,9 +864,16 @@ static int
864864
bytearray_ass_subscript(PyObject *op, PyObject *index, PyObject *values)
865865
{
866866
int ret;
867-
Py_BEGIN_CRITICAL_SECTION(op);
868-
ret = bytearray_ass_subscript_lock_held(op, index, values);
869-
Py_END_CRITICAL_SECTION();
867+
if (values != NULL && PyByteArray_Check(values)) {
868+
Py_BEGIN_CRITICAL_SECTION2(op, values);
869+
ret = bytearray_ass_subscript_lock_held(op, index, values);
870+
Py_END_CRITICAL_SECTION2();
871+
}
872+
else {
873+
Py_BEGIN_CRITICAL_SECTION(op);
874+
ret = bytearray_ass_subscript_lock_held(op, index, values);
875+
Py_END_CRITICAL_SECTION();
876+
}
870877
return ret;
871878
}
872879

@@ -2751,9 +2758,16 @@ static PyObject *
27512758
bytearray_mod(PyObject *v, PyObject *w)
27522759
{
27532760
PyObject *ret;
2754-
Py_BEGIN_CRITICAL_SECTION(v);
2755-
ret = bytearray_mod_lock_held(v, w);
2756-
Py_END_CRITICAL_SECTION();
2761+
if (PyByteArray_Check(w)) {
2762+
Py_BEGIN_CRITICAL_SECTION2(v, w);
2763+
ret = bytearray_mod_lock_held(v, w);
2764+
Py_END_CRITICAL_SECTION2();
2765+
}
2766+
else {
2767+
Py_BEGIN_CRITICAL_SECTION(v);
2768+
ret = bytearray_mod_lock_held(v, w);
2769+
Py_END_CRITICAL_SECTION();
2770+
}
27572771
return ret;
27582772
}
27592773

Parser/lexer/lexer.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -211,9 +211,13 @@ _PyLexer_update_fstring_expr(struct tok_state *tok, char cur)
211211
break;
212212
case '}':
213213
case '!':
214-
case ':':
215214
tok_mode->last_expr_end = strlen(tok->start);
216215
break;
216+
case ':':
217+
if (tok_mode->last_expr_end == -1) {
218+
tok_mode->last_expr_end = strlen(tok->start);
219+
}
220+
break;
217221
default:
218222
Py_UNREACHABLE();
219223
}

0 commit comments

Comments
 (0)