Skip to content

Commit d09a5ae

Browse files
committed
Merge remote-tracking branch 'upstream/main' into clippy-collapsible-else-if
2 parents 0d5bf96 + 77070eb commit d09a5ae

84 files changed

Lines changed: 2433 additions & 788 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.python-version

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
3.14.4
1+
3.14.5

Cargo.toml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,7 @@ libloading = "0.9"
224224
liblzma = "0.4"
225225
liblzma-sys = "0.4"
226226
libsqlite3-sys = "0.37"
227-
libz-sys = { package = "libz-rs-sys", version = "0.5" }
227+
libz-rs-sys = "0.5"
228228
lock_api = "0.4"
229229
log = "0.4.29"
230230
nix = { version = "0.31", features = ["fs", "user", "process", "term", "time", "signal", "ioctl", "socket", "sched", "zerocopy", "dir", "hostname", "net", "poll"] }
@@ -338,7 +338,6 @@ inefficient_to_string = "warn"
338338
redundant_clone = "warn"
339339
debug_assert_with_mut_call = "warn"
340340
unused_peekable = "warn"
341-
manual_is_variant_and = "warn"
342341
or_fun_call = "warn"
343342
unnested_or_patterns = "warn"
344343

@@ -351,4 +350,6 @@ explicit_iter_loop = "warn"
351350
filter_map_next = "warn"
352351
flat_map_option = "warn"
353352
inconsistent_struct_constructor = "warn"
353+
manual_is_variant_and = "warn"
354+
map_unwrap_or = "warn"
354355
must_use_candidate = "warn"

Lib/argparse.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2678,7 +2678,7 @@ def _check_value(self, action, value):
26782678

26792679
if value not in choices:
26802680
args = {'value': str(value),
2681-
'choices': ', '.join(map(str, action.choices))}
2681+
'choices': ', '.join(repr(str(choice)) for choice in action.choices)}
26822682
msg = _('invalid choice: %(value)r (choose from %(choices)s)')
26832683

26842684
if self.suggest_on_error and isinstance(value, str):

Lib/configparser.py

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -315,12 +315,15 @@ def __init__(self, source, *args):
315315

316316
def append(self, lineno, line):
317317
self.errors.append((lineno, line))
318-
self.message += '\n\t[line %2d]: %s' % (lineno, repr(line))
318+
self.message += f'\n\t[line {lineno:2d}]: {line!r}'
319319

320320
def combine(self, others):
321+
messages = [self.message]
321322
for other in others:
322-
for error in other.errors:
323-
self.append(*error)
323+
for lineno, line in other.errors:
324+
self.errors.append((lineno, line))
325+
messages.append(f'\n\t[line {lineno:2d}]: {line!r}')
326+
self.message = "".join(messages)
324327
return self
325328

326329
@staticmethod
@@ -613,15 +616,19 @@ class RawConfigParser(MutableMapping):
613616
\] # ]
614617
"""
615618
_OPT_TMPL = r"""
616-
(?P<option>.*?) # very permissive!
619+
(?P<option> # very permissive!
620+
(?:(?!{delim})\S)* # non-delimiter non-whitespace
621+
(?:\s+(?:(?!{delim})\S)+)*) # optionally more words
617622
\s*(?P<vi>{delim})\s* # any number of space/tab,
618623
# followed by any of the
619624
# allowed delimiters,
620625
# followed by any space/tab
621626
(?P<value>.*)$ # everything up to eol
622627
"""
623628
_OPT_NV_TMPL = r"""
624-
(?P<option>.*?) # very permissive!
629+
(?P<option> # very permissive!
630+
(?:(?!{delim})\S)* # non-delimiter non-whitespace
631+
(?:\s+(?:(?!{delim})\S)+)*) # optionally more words
625632
\s*(?: # any number of space/tab,
626633
(?P<vi>{delim})\s* # optionally followed by
627634
# any of the allowed

Lib/ensurepip/__init__.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,14 @@
1010

1111

1212
__all__ = ["version", "bootstrap"]
13-
_PIP_VERSION = "25.3"
13+
_PIP_VERSION = "26.0.1"
1414

1515
# Directory of system wheel packages. Some Linux distribution packaging
1616
# policies recommend against bundling dependencies. For example, Fedora
1717
# installs wheel packages in the /usr/share/python-wheels/ directory and don't
1818
# install the ensurepip._bundled package.
19-
if (_pkg_dir := sysconfig.get_config_var('WHEEL_PKG_DIR')) is not None:
19+
_pkg_dir = sysconfig.get_config_var('WHEEL_PKG_DIR')
20+
if _pkg_dir:
2021
_WHEEL_PKG_DIR = Path(_pkg_dir).resolve()
2122
else:
2223
_WHEEL_PKG_DIR = None
1.7 MB
Binary file not shown.

Lib/logging/__init__.py

Lines changed: 14 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1475,8 +1475,6 @@ class Logger(Filterer):
14751475
level, and "input.csv", "input.xls" and "input.gnu" for the sub-levels.
14761476
There is no arbitrary limit to the depth of nesting.
14771477
"""
1478-
_tls = threading.local()
1479-
14801478
def __init__(self, name, level=NOTSET):
14811479
"""
14821480
Initialize the logger with a name and an optional level.
@@ -1673,19 +1671,14 @@ def handle(self, record):
16731671
This method is used for unpickled records received from a socket, as
16741672
well as those created locally. Logger-level filtering is applied.
16751673
"""
1676-
if self._is_disabled():
1674+
if self.disabled:
16771675
return
1678-
1679-
self._tls.in_progress = True
1680-
try:
1681-
maybe_record = self.filter(record)
1682-
if not maybe_record:
1683-
return
1684-
if isinstance(maybe_record, LogRecord):
1685-
record = maybe_record
1686-
self.callHandlers(record)
1687-
finally:
1688-
self._tls.in_progress = False
1676+
maybe_record = self.filter(record)
1677+
if not maybe_record:
1678+
return
1679+
if isinstance(maybe_record, LogRecord):
1680+
record = maybe_record
1681+
self.callHandlers(record)
16891682

16901683
def addHandler(self, hdlr):
16911684
"""
@@ -1773,7 +1766,7 @@ def isEnabledFor(self, level):
17731766
"""
17741767
Is this logger enabled for level 'level'?
17751768
"""
1776-
if self._is_disabled():
1769+
if self.disabled:
17771770
return False
17781771

17791772
try:
@@ -1823,11 +1816,6 @@ def _hierlevel(logger):
18231816
if isinstance(item, Logger) and item.parent is self and
18241817
_hierlevel(item) == 1 + _hierlevel(item.parent))
18251818

1826-
def _is_disabled(self):
1827-
# We need to use getattr as it will only be set the first time a log
1828-
# message is recorded on any given thread
1829-
return self.disabled or getattr(self._tls, 'in_progress', False)
1830-
18311819
def __repr__(self):
18321820
level = getLevelName(self.getEffectiveLevel())
18331821
return '<%s %s (%s)>' % (self.__class__.__name__, self.name, level)
@@ -1864,9 +1852,9 @@ class LoggerAdapter(object):
18641852

18651853
def __init__(self, logger, extra=None, merge_extra=False):
18661854
"""
1867-
Initialize the adapter with a logger and a dict-like object which
1868-
provides contextual information. This constructor signature allows
1869-
easy stacking of LoggerAdapters, if so desired.
1855+
Initialize the adapter with a logger and an optional dict-like object
1856+
which provides contextual information. This constructor signature
1857+
allows easy stacking of LoggerAdapters, if so desired.
18701858
18711859
You can effectively pass keyword arguments as shown in the
18721860
following example:
@@ -1897,8 +1885,9 @@ def process(self, msg, kwargs):
18971885
Normally, you'll only need to override this one method in a
18981886
LoggerAdapter subclass for your specific needs.
18991887
"""
1900-
if self.merge_extra and "extra" in kwargs:
1901-
kwargs["extra"] = {**self.extra, **kwargs["extra"]}
1888+
if self.merge_extra and kwargs.get("extra") is not None:
1889+
if self.extra is not None:
1890+
kwargs["extra"] = {**self.extra, **kwargs["extra"]}
19021891
else:
19031892
kwargs["extra"] = self.extra
19041893
return msg, kwargs

Lib/logging/config.py

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -865,6 +865,8 @@ def configure_handler(self, config):
865865
else:
866866
factory = klass
867867
kwargs = {k: config[k] for k in config if (k != '.' and valid_ident(k))}
868+
# When deprecation ends for using the 'strm' parameter, remove the
869+
# "except TypeError ..."
868870
try:
869871
result = factory(**kwargs)
870872
except TypeError as te:
@@ -876,6 +878,15 @@ def configure_handler(self, config):
876878
#(e.g. by Django)
877879
kwargs['strm'] = kwargs.pop('stream')
878880
result = factory(**kwargs)
881+
882+
import warnings
883+
warnings.warn(
884+
"Support for custom logging handlers with the 'strm' argument "
885+
"is deprecated and scheduled for removal in Python 3.16. "
886+
"Define handlers with the 'stream' argument instead.",
887+
DeprecationWarning,
888+
stacklevel=2,
889+
)
879890
if formatter:
880891
result.setFormatter(formatter)
881892
if level is not None:
@@ -1006,7 +1017,8 @@ class ConfigSocketReceiver(ThreadingTCPServer):
10061017
A simple TCP socket-based logging config receiver.
10071018
"""
10081019

1009-
allow_reuse_address = 1
1020+
allow_reuse_address = True
1021+
allow_reuse_port = False
10101022

10111023
def __init__(self, host='localhost', port=DEFAULT_LOGGING_CONFIG_PORT,
10121024
handler=None, ready=None, verify=None):

Lib/logging/handlers.py

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,11 @@ def shouldRollover(self, record):
196196
if self.stream is None: # delay was set...
197197
self.stream = self._open()
198198
if self.maxBytes > 0: # are we rolling over?
199-
pos = self.stream.tell()
199+
try:
200+
pos = self.stream.tell()
201+
except io.UnsupportedOperation:
202+
# gh-143237: Never rollover a named pipe.
203+
return False
200204
if not pos:
201205
# gh-116263: Never rollover an empty file
202206
return False
@@ -855,7 +859,7 @@ class SysLogHandler(logging.Handler):
855859
}
856860

857861
def __init__(self, address=('localhost', SYSLOG_UDP_PORT),
858-
facility=LOG_USER, socktype=None):
862+
facility=LOG_USER, socktype=None, timeout=None):
859863
"""
860864
Initialize a handler.
861865
@@ -872,6 +876,7 @@ def __init__(self, address=('localhost', SYSLOG_UDP_PORT),
872876
self.address = address
873877
self.facility = facility
874878
self.socktype = socktype
879+
self.timeout = timeout
875880
self.socket = None
876881
self.createSocket()
877882

@@ -933,6 +938,8 @@ def createSocket(self):
933938
err = sock = None
934939
try:
935940
sock = socket.socket(af, socktype, proto)
941+
if self.timeout:
942+
sock.settimeout(self.timeout)
936943
if socktype == socket.SOCK_STREAM:
937944
sock.connect(sa)
938945
break
@@ -1529,6 +1536,19 @@ def __init__(self, queue, *handlers, respect_handler_level=False):
15291536
self._thread = None
15301537
self.respect_handler_level = respect_handler_level
15311538

1539+
def __enter__(self):
1540+
"""
1541+
For use as a context manager. Starts the listener.
1542+
"""
1543+
self.start()
1544+
return self
1545+
1546+
def __exit__(self, *args):
1547+
"""
1548+
For use as a context manager. Stops the listener.
1549+
"""
1550+
self.stop()
1551+
15321552
def dequeue(self, block):
15331553
"""
15341554
Dequeue a record and return it, optionally blocking.

0 commit comments

Comments
 (0)