Skip to content

Commit acc3605

Browse files
committed
Preserve CPython complex packing behavior after upstream F/D support
Merge current main and reuse its complex format types and unpacking. Keep only conversion, warning, and opposite-endian overflow fixes. Codex assisted with conflict resolution, implementation, tests, and review. Constraint: F/D format support is already present in upstream RustPython#8780 Tested: CPython 3.14.7 comparison; struct/memoryview/complex/cmath; pytest; workspace and C-API tests; Clippy; prek Assisted-by: Codex:gpt-6-astra
2 parents f6550c4 + 7f314dd commit acc3605

334 files changed

Lines changed: 45776 additions & 38447 deletions

File tree

Some content is hidden

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

‎.cspell.dict/cpython.txt‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,7 @@ mimalloc
153153
miscompiles
154154
mult
155155
multibytecodec
156+
mycmp
156157
mystricmp
157158
mystrnicmp
158159
nameobj
@@ -187,6 +188,8 @@ numkwonly
187188
numposorkw
188189
nvars
189190
obmalloc
191+
odict
192+
ODICT
190193
opname
191194
opnames
192195
orelse

‎.cspell.dict/rust-more.txt‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ powf
6060
powi
6161
prepended
6262
punct
63+
qself
6364
replacen
6465
retag
6566
rmatch

‎.github/workflows/update-doc-db.yml‎

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -82,8 +82,8 @@ jobs:
8282
# Merge all artifacts
8383
jq -s "add" --sort-keys crates/doc/generated/*.json > crates/doc/generated/merged.json
8484
85-
# Format merged json for the phf macro
86-
jq -r 'to_entries[] | " \(.key | @json) => \(.value | @json),"' crates/doc/generated/merged.json > crates/doc/generated/raw_entries.txt
85+
# Format merged json as a sorted const slice
86+
jq -r 'to_entries[] | " (\(.key | @json), \(.value | @json)),"' crates/doc/generated/merged.json > crates/doc/generated/raw_entries.txt
8787
8888
OUTPUT_FILE='crates/doc/src/data.inc.rs'
8989
@@ -93,9 +93,10 @@ jobs:
9393
echo "// CPython version: ${PYTHON_VERSION}"
9494
echo '// spell-checker: disable'
9595
echo ''
96-
echo "pub static DB: phf::Map<&'static str, &'static str> = phf::phf_map! {"
96+
echo '#[rustfmt::skip]'
97+
echo 'pub const DB: &[(&str, &str)] = &['
9798
cat crates/doc/generated/raw_entries.txt
98-
echo '};'
99+
echo '];'
99100
} > "$OUTPUT_FILE"
100101
101102
- uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1

‎Cargo.lock‎

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

‎Cargo.toml‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -430,3 +430,6 @@ unnecessary_box_returns = "warn"
430430
unnecessary_join = "warn"
431431
unnecessary_wraps = "warn"
432432
unnested_or_patterns = "warn"
433+
434+
[lints]
435+
workspace = true

‎Lib/io.py‎

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,10 +55,15 @@
5555

5656
from _collections_abc import _check_methods
5757
from _io import (DEFAULT_BUFFER_SIZE, BlockingIOError, UnsupportedOperation,
58-
open, open_code, FileIO, BytesIO, StringIO, BufferedReader,
58+
open, open_code, BytesIO, StringIO, BufferedReader,
5959
BufferedWriter, BufferedRWPair, BufferedRandom,
6060
IncrementalNewlineDecoder, text_encoding, TextIOWrapper)
6161

62+
# XXX: RUSTPYTHON; FileIO needs host_env, optional without it
63+
try:
64+
from _io import FileIO
65+
except ImportError:
66+
FileIO = None
6267

6368
# for seek()
6469
SEEK_SET = 0
@@ -80,7 +85,8 @@ class BufferedIOBase(_io._BufferedIOBase, IOBase):
8085
class TextIOBase(_io._TextIOBase, IOBase):
8186
__doc__ = _io._TextIOBase.__doc__
8287

83-
RawIOBase.register(FileIO)
88+
if FileIO is not None: # XXX: RUSTPYTHON; see the try/except above
89+
RawIOBase.register(FileIO)
8490

8591
for klass in (BytesIO, BufferedReader, BufferedWriter, BufferedRandom,
8692
BufferedRWPair):

‎Lib/test/test_abc.py‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,6 @@ def method_two(self):
168168
msg = r"class C without an implementation for abstract methods 'method_one', 'method_two'"
169169
self.assertRaisesRegex(TypeError, msg, C)
170170

171-
@unittest.expectedFailure # TODO: RUSTPYTHON; AssertionError: False is not true
172171
def test_abstractmethod_integration(self):
173172
for abstractthing in [abc.abstractmethod, abc.abstractproperty,
174173
abc.abstractclassmethod,

‎Lib/test/test_builtin.py‎

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2711,43 +2711,35 @@ def detach_readline(self):
27112711
else:
27122712
yield
27132713

2714-
@unittest.expectedFailure # TODO: RUSTPYTHON; AssertionError: got 0 lines in pipe but expected 2, child output was: quux
27152714
def test_input_tty(self):
27162715
# Test input() functionality when wired to a tty
27172716
self.check_input_tty("prompt", b"quux")
27182717

2719-
@unittest.expectedFailure # TODO: RUSTPYTHON; AssertionError: got 0 lines in pipe but expected 2, child output was: quux
27202718
def test_input_tty_non_ascii(self):
27212719
# Check stdin/stdout encoding is used when invoking PyOS_Readline()
27222720
self.check_input_tty("prompté", b"quux\xc3\xa9", "utf-8")
27232721

2724-
@unittest.expectedFailure # TODO: RUSTPYTHON; AssertionError: got 0 lines in pipe but expected 2, child output was: quux
27252722
def test_input_tty_non_ascii_unicode_errors(self):
27262723
# Check stdin/stdout error handler is used when invoking PyOS_Readline()
27272724
self.check_input_tty("prompté", b"quux\xe9", "ascii")
27282725

2729-
@unittest.expectedFailure # TODO: RUSTPYTHON; AssertionError: got 0 lines in pipe but expected 2, child output was: quux
27302726
def test_input_tty_null_in_prompt(self):
27312727
self.check_input_tty("prompt\0", b"",
27322728
expected='ValueError: input: prompt string cannot contain '
27332729
'null characters')
27342730

2735-
@unittest.expectedFailure # TODO: RUSTPYTHON; AssertionError: got 0 lines in pipe but expected 2, child output was: quux
27362731
def test_input_tty_nonencodable_prompt(self):
27372732
self.check_input_tty("prompté", b"quux", "ascii", stdout_errors='strict',
27382733
expected="UnicodeEncodeError: 'ascii' codec can't encode "
27392734
"character '\\xe9' in position 6: ordinal not in "
27402735
"range(128)")
27412736

2742-
@unittest.expectedFailure # TODO: RUSTPYTHON; AssertionError: got 0 lines in pipe but expected 2, child output was: quux
27432737
def test_input_tty_nondecodable_input(self):
27442738
self.check_input_tty("prompt", b"quux\xe9", "ascii", stdin_errors='strict',
27452739
expected="UnicodeDecodeError: 'ascii' codec can't decode "
27462740
"byte 0xe9 in position 4: ordinal not in "
27472741
"range(128)")
27482742

2749-
@unittest.skip("TODO: RUSTPYTHON; FAILURE, WORKER BUG")
2750-
@unittest.expectedFailure # TODO: RUSTPYTHON; AssertionError: got 0 lines in pipe but expected 2, child output was: quux
27512743
def test_input_no_stdout_fileno(self):
27522744
# Issue #24402: If stdin is the original terminal but stdout.fileno()
27532745
# fails, do not use the original stdout file descriptor
@@ -3036,7 +3028,6 @@ class B:
30363028
with self.assertRaises(TypeError):
30373029
type('A', (B,), {'__slots__': '__weakref__'})
30383030

3039-
@unittest.skip("TODO: RUSTPYTHON; random failure")
30403031
def test_namespace_order(self):
30413032
# bpo-34320: namespace should preserve order
30423033
od = collections.OrderedDict([('a', 1), ('b', 2)])

‎Lib/test/test_codecs.py‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2154,7 +2154,6 @@ def test_basic(self):
21542154

21552155

21562156
class BasicUnicodeTest(unittest.TestCase, MixInCheckStateHandling):
2157-
@unittest.expectedFailure # TODO: RUSTPYTHON; charmap_encode rejects a None mapping
21582157
def test_basics(self):
21592158
s = "abc123" # all codecs should be able to encode these
21602159
for encoding in all_unicode_encodings:
@@ -2307,7 +2306,6 @@ def test_encoding_map_type_initialized(self):
23072306
table_type = type(cp1140.encoding_table)
23082307
self.assertEqual(table_type, table_type)
23092308

2310-
@unittest.expectedFailure # TODO: RUSTPYTHON; charmap_encode rejects a None mapping
23112309
def test_decoder_state(self):
23122310
# Check that getstate() and setstate() handle the state properly
23132311
u = "abc123"

‎Lib/test/test_dataclasses/__init__.py‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5000,7 +5000,6 @@ class Date(Ordered):
50005000
self.assertFalse(inspect.isabstract(Date))
50015001
self.assertGreater(Date(2020,12,25), Date(2020,8,31))
50025002

5003-
@unittest.expectedFailure # TODO: RUSTPYTHON
50045003
def test_maintain_abc(self):
50055004
class A(abc.ABC):
50065005
@abc.abstractmethod

0 commit comments

Comments
 (0)