From b722ece6af9244689a82b4a85f05512107b3a714 Mon Sep 17 00:00:00 2001
From: ShaharNaveh <50263213+ShaharNaveh@users.noreply.github.com>
Date: Sat, 14 Feb 2026 18:16:15 +0200
Subject: [PATCH 1/5] Update `test_pyclbr.py` from 3.14.3
---
Lib/test/test_pyclbr.py | 59 ++++++++++++++++++++++++++++++-----------
1 file changed, 43 insertions(+), 16 deletions(-)
diff --git a/Lib/test/test_pyclbr.py b/Lib/test/test_pyclbr.py
index 9ac4a6efe..9e7a67ebe 100644
--- a/Lib/test/test_pyclbr.py
+++ b/Lib/test/test_pyclbr.py
@@ -3,16 +3,17 @@
Nick Mathewson
'''
+import importlib.machinery
import sys
+from contextlib import contextmanager
from textwrap import dedent
from types import FunctionType, MethodType, BuiltinFunctionType
import pyclbr
from unittest import TestCase, main as unittest_main
from test.test_importlib import util as test_importlib_util
import warnings
-from test.support.testcase import ExtraAssertions
-import unittest # TODO: RUSTPYTHON
+import unittest # XXX: RUSTPYTHON; importing to be able to skip tests
StaticMethodType = type(staticmethod(lambda: None))
@@ -25,7 +26,30 @@ ClassMethodType = type(classmethod(lambda c: None))
# is imperfect (as designed), testModule is called with a set of
# members to ignore.
-class PyclbrTest(TestCase, ExtraAssertions):
+
+@contextmanager
+def temporary_main_spec():
+ """
+ A context manager that temporarily sets the `__spec__` attribute
+ of the `__main__` module if it's missing.
+ """
+ main_mod = sys.modules.get("__main__")
+ if main_mod is None:
+ yield # Do nothing if __main__ is not present
+ return
+
+ original_spec = getattr(main_mod, "__spec__", None)
+ if original_spec is None:
+ main_mod.__spec__ = importlib.machinery.ModuleSpec(
+ name="__main__", loader=None, origin="built-in"
+ )
+ try:
+ yield
+ finally:
+ main_mod.__spec__ = original_spec
+
+
+class PyclbrTest(TestCase):
def assertListEq(self, l1, l2, ignore):
''' succeed iff {l1} - {ignore} == {l2} - {ignore} '''
@@ -81,7 +105,7 @@ class PyclbrTest(TestCase, ExtraAssertions):
for name, value in dict.items():
if name in ignore:
continue
- self.assertHasAttr(module, name, ignore)
+ self.assertHasAttr(module, name)
py_item = getattr(module, name)
if isinstance(value, pyclbr.Function):
self.assertIsInstance(py_item, (FunctionType, BuiltinFunctionType))
@@ -105,6 +129,8 @@ class PyclbrTest(TestCase, ExtraAssertions):
actualMethods = []
for m in py_item.__dict__.keys():
+ if m == "__annotate__":
+ continue
if ismethod(py_item, getattr(py_item, m), m):
actualMethods.append(m)
@@ -146,12 +172,12 @@ class PyclbrTest(TestCase, ExtraAssertions):
self.checkModule('pyclbr')
# XXX: Metaclasses are not supported
# self.checkModule('ast')
- self.checkModule('doctest', ignore=("TestResults", "_SpoofOut",
- "DocTestCase", '_DocTestSuite'))
+ with temporary_main_spec():
+ self.checkModule('doctest', ignore=("TestResults", "_SpoofOut",
+ "DocTestCase", '_DocTestSuite'))
self.checkModule('difflib', ignore=("Match",))
- # TODO: RUSTPYTHON
- @unittest.expectedFailure
+ @unittest.expectedFailure # TODO: RUSTPYTHON
def test_cases(self):
# see test.pyclbr_input for the rationale behind the ignored symbols
self.checkModule('test.pyclbr_input', ignore=['om', 'f'])
@@ -217,8 +243,7 @@ class PyclbrTest(TestCase, ExtraAssertions):
compare(None, actual, None, expected)
- # TODO: RUSTPYTHON
- @unittest.expectedFailure
+ @unittest.expectedFailure # TODO: RUSTPYTHON
def test_others(self):
cm = self.checkModule
@@ -228,12 +253,14 @@ class PyclbrTest(TestCase, ExtraAssertions):
with warnings.catch_warnings():
warnings.simplefilter('ignore', DeprecationWarning)
cm('sre_parse', ignore=('dump', 'groups', 'pos')) # from sre_constants import *; property
- cm(
- 'pdb',
- # pyclbr does not handle elegantly `typing` or properties
- ignore=('Union', '_ModuleTarget', '_ScriptTarget', '_ZipTarget'),
- )
- cm('pydoc', ignore=('input', 'output',)) # properties
+ with temporary_main_spec():
+ cm(
+ 'pdb',
+ # pyclbr does not handle elegantly `typing` or properties
+ ignore=('Union', '_ModuleTarget', '_ScriptTarget', '_ZipTarget', 'curframe_locals',
+ '_InteractState', 'rlcompleter'),
+ )
+ cm('pydoc', ignore=('input', 'output',)) # properties
# Tests for modules inside packages
cm('email.parser')
From 9a40f9adecd48e59a6cdfa3cf43fa4f5f1ec7f8d Mon Sep 17 00:00:00 2001
From: ShaharNaveh <50263213+ShaharNaveh@users.noreply.github.com>
Date: Sat, 14 Feb 2026 18:18:53 +0200
Subject: [PATCH 2/5] Update `xmlrpc`
---
Lib/test/test_xmlrpc.py | 12 ++++++------
Lib/xmlrpc/server.py | 3 ++-
2 files changed, 8 insertions(+), 7 deletions(-)
diff --git a/Lib/test/test_xmlrpc.py b/Lib/test/test_xmlrpc.py
index 6b2e6c44c..bb2a1ef09 100644
--- a/Lib/test/test_xmlrpc.py
+++ b/Lib/test/test_xmlrpc.py
@@ -187,7 +187,7 @@ class XMLRPCTestCase(unittest.TestCase):
xmlrpclib.loads(strg)[0][0])
self.assertRaises(TypeError, xmlrpclib.dumps, (arg1,))
- @unittest.expectedFailure # TODO: RUSTPYTHON
+ @unittest.expectedFailure # TODO: RUSTPYTHON
def test_dump_encoding(self):
value = {'key\u20ac\xa4':
'value\u20ac\xa4'}
@@ -228,7 +228,7 @@ class XMLRPCTestCase(unittest.TestCase):
self.assertIs(type(newvalue), xmlrpclib.Binary)
self.assertIsNone(m)
- @unittest.expectedFailure # TODO: RUSTPYTHON
+ @unittest.expectedFailure # TODO: RUSTPYTHON
def test_loads_unsupported(self):
ResponseError = xmlrpclib.ResponseError
data = ''
@@ -278,7 +278,7 @@ class XMLRPCTestCase(unittest.TestCase):
'a1'
'', {'a': 1, 'b': 2})
- @unittest.expectedFailure # TODO: RUSTPYTHON
+ @unittest.expectedFailure # TODO: RUSTPYTHON
def test_load_extension_types(self):
check = self.check_loads
check('', None)
@@ -311,7 +311,7 @@ class XMLRPCTestCase(unittest.TestCase):
def test_ssl_presence(self):
try:
- import ssl
+ import ssl # noqa: F401
except ImportError:
has_ssl = False
else:
@@ -832,7 +832,7 @@ class SimpleServerTestCase(BaseServerTestCase):
# protocol error; provide additional information in test output
self.fail("%s\n%s" % (e, getattr(e, "headers", "")))
- @unittest.expectedFailure # TODO: RUSTPYTHON
+ @unittest.expectedFailure # TODO: RUSTPYTHON
def test_client_encoding(self):
start_string = '\u20ac'
end_string = '\xa4'
@@ -1013,7 +1013,7 @@ class SimpleServerEncodingTestCase(BaseServerTestCase):
def threadFunc(evt, numrequests, requestHandler=None, encoding=None):
http_server(evt, numrequests, requestHandler, 'iso-8859-15')
- @unittest.expectedFailure # TODO: RUSTPYTHON
+ @unittest.expectedFailure # TODO: RUSTPYTHON
def test_server_encoding(self):
start_string = '\u20ac'
end_string = '\xa4'
diff --git a/Lib/xmlrpc/server.py b/Lib/xmlrpc/server.py
index 4dddb1d10..3e6871157 100644
--- a/Lib/xmlrpc/server.py
+++ b/Lib/xmlrpc/server.py
@@ -239,7 +239,7 @@ class SimpleXMLRPCDispatcher:
see http://www.xmlrpc.com/discuss/msgReader$1208"""
- self.funcs.update({'system.multicall' : self.system_multicall})
+ self.funcs['system.multicall'] = self.system_multicall
def _marshaled_dispatch(self, data, dispatch_method = None, path = None):
"""Dispatches an XML-RPC method from marshalled (XML) data.
@@ -578,6 +578,7 @@ class SimpleXMLRPCServer(socketserver.TCPServer,
"""
allow_reuse_address = True
+ allow_reuse_port = False
# Warning: this is for debugging purposes only! Never set this to True in
# production code, as will be sending out sensitive information (exception
From 11a8655d0df6bdd41782ebf796bbad756bf3f4ea Mon Sep 17 00:00:00 2001
From: ShaharNaveh <50263213+ShaharNaveh@users.noreply.github.com>
Date: Sat, 14 Feb 2026 18:19:57 +0200
Subject: [PATCH 3/5] Update `mailbox.py`
---
Lib/mailbox.py | 6 +-----
Lib/test/test_mailbox.py | 4 +---
2 files changed, 2 insertions(+), 8 deletions(-)
diff --git a/Lib/mailbox.py b/Lib/mailbox.py
index b00d9e863..364af6bb0 100644
--- a/Lib/mailbox.py
+++ b/Lib/mailbox.py
@@ -2183,11 +2183,7 @@ def _unlock_file(f):
def _create_carefully(path):
"""Create a file if it doesn't exist and open for reading and writing."""
- fd = os.open(path, os.O_CREAT | os.O_EXCL | os.O_RDWR, 0o666)
- try:
- return open(path, 'rb+')
- finally:
- os.close(fd)
+ return open(path, 'xb+')
def _create_temporary(path):
"""Create a temp file based on path and open for reading and writing."""
diff --git a/Lib/test/test_mailbox.py b/Lib/test/test_mailbox.py
index 940baf394..0169948e4 100644
--- a/Lib/test/test_mailbox.py
+++ b/Lib/test/test_mailbox.py
@@ -1,7 +1,6 @@
import os
import sys
import time
-import stat
import socket
import email
import email.message
@@ -13,7 +12,6 @@ from test.support import import_helper
from test.support import os_helper
from test.support import refleak_helper
from test.support import socket_helper
-from test.support.testcase import ExtraAssertions
import unittest
import textwrap
import mailbox
@@ -1267,7 +1265,7 @@ class _TestMboxMMDF(_TestSingleFile):
self._box.close()
-class TestMbox(_TestMboxMMDF, unittest.TestCase, ExtraAssertions):
+class TestMbox(_TestMboxMMDF, unittest.TestCase):
_factory = lambda self, path, factory=None: mailbox.mbox(path, factory)
From 5dfeee25bb9ec31e0bc6705081a617f34f3c2d40 Mon Sep 17 00:00:00 2001
From: ShaharNaveh <50263213+ShaharNaveh@users.noreply.github.com>
Date: Sat, 14 Feb 2026 18:27:31 +0200
Subject: [PATCH 4/5] Update `test_binascii.py`
---
Lib/test/test_binascii.py | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/Lib/test/test_binascii.py b/Lib/test/test_binascii.py
index cf11ffce7..fa0277104 100644
--- a/Lib/test/test_binascii.py
+++ b/Lib/test/test_binascii.py
@@ -38,13 +38,13 @@ class BinASCIITest(unittest.TestCase):
def test_exceptions(self):
# Check module exceptions
- self.assertTrue(issubclass(binascii.Error, Exception))
- self.assertTrue(issubclass(binascii.Incomplete, Exception))
+ self.assertIsSubclass(binascii.Error, Exception)
+ self.assertIsSubclass(binascii.Incomplete, Exception)
def test_functions(self):
# Check presence of all functions
for name in all_functions:
- self.assertTrue(hasattr(getattr(binascii, name), '__call__'))
+ self.assertHasAttr(getattr(binascii, name), '__call__')
self.assertRaises(TypeError, getattr(binascii, name))
def test_returned_value(self):
@@ -117,7 +117,7 @@ class BinASCIITest(unittest.TestCase):
# empty strings. TBD: shouldn't it raise an exception instead ?
self.assertEqual(binascii.a2b_base64(self.type2test(fillers)), b'')
- @unittest.expectedFailure # TODO: RUSTPYTHON
+ @unittest.expectedFailure # TODO: RUSTPYTHON
def test_base64_strict_mode(self):
# Test base64 with strict mode on
def _assertRegexTemplate(assert_regex: str, data: bytes, non_strict_mode_expected_result: bytes):
From 15555d42e7c84ba75fed30cfec4160350dba6c56 Mon Sep 17 00:00:00 2001
From: "github-actions[bot]"
Date: Sat, 14 Feb 2026 16:32:00 +0000
Subject: [PATCH 5/5] Auto-format: cargo fmt --all
---
crates/stdlib/src/hashlib.rs | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)
diff --git a/crates/stdlib/src/hashlib.rs b/crates/stdlib/src/hashlib.rs
index 5a2a55b93..27e435725 100644
--- a/crates/stdlib/src/hashlib.rs
+++ b/crates/stdlib/src/hashlib.rs
@@ -701,9 +701,8 @@ pub mod _hashlib {
if len < 1 {
return Err(vm.new_value_error("key length must be greater than 0.".to_owned()));
}
- usize::try_from(len).map_err(|_| {
- vm.new_overflow_error("key length is too great.".to_owned())
- })?
+ usize::try_from(len)
+ .map_err(|_| vm.new_overflow_error("key length is too great.".to_owned()))?
}
None => hash_digest_size(&name).ok_or_else(|| unsupported_hash(&name, vm))?,
};