Skip to content

Commit a602728

Browse files
fix: Also preserve trailing nulls in strings, not just bytes
Extended the fix to remove rstrip from strings as well and store actual byte lengths for both strings and bytes in format metadata.
1 parent 3f874bc commit a602728

3,347 files changed

Lines changed: 1407863 additions & 5 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.

Lib/multiprocessing/shared_memory.py

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -286,7 +286,7 @@ class ShareableList:
286286
_alignment = 8
287287
_back_transforms_mapping = {
288288
0: lambda value: value, # int, float, bool
289-
1: lambda value: value.rstrip(b'\x00').decode(_encoding), # str
289+
1: lambda value: value.decode(_encoding), # str
290290
2: lambda value: value, # bytes
291291
3: lambda _value: None, # None
292292
}
@@ -355,9 +355,11 @@ def __init__(self, sequence=None, *, name=None):
355355
self._offset_data_start,
356356
*(v.encode(_enc) if isinstance(v, str) else v for v in sequence)
357357
)
358-
# For bytes, store actual length so retrieval is exact
358+
# For bytes and str, store actual byte length so retrieval is exact
359359
_stored_formats = [
360-
self._types_mapping[bytes] % (len(v),) if isinstance(v, bytes) else f
360+
(self._types_mapping[str] % (len(v.encode(_enc)),) if isinstance(v, str)
361+
else self._types_mapping[bytes] % (len(v),) if isinstance(v, bytes)
362+
else f)
361363
for v, f in zip(sequence, _formats)
362364
]
363365
struct.pack_into(
@@ -481,8 +483,9 @@ def __setitem__(self, position, value):
481483

482484
self._set_packing_format_and_transform(
483485
position,
484-
self._types_mapping[bytes] % (len(encoded_value),)
485-
if isinstance(value, bytes) else new_format,
486+
(self._types_mapping[bytes] % (len(encoded_value),) if isinstance(value, bytes)
487+
else self._types_mapping[str] % (len(encoded_value),) if isinstance(value, str)
488+
else new_format),
486489
value
487490
)
488491
struct.pack_into(new_format, self.shm.buf, offset, encoded_value)

install/bin/idle3

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
idle3.15

install/bin/idle3.15

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
#!/home/stefanze/src/cpython-up-to-date/install/bin/python3.15
2+
3+
from idlelib.pyshell import main
4+
if __name__ == '__main__':
5+
main()

install/bin/pip3

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#!/home/stefanze/src/cpython-up-to-date/install/bin/python3.15
2+
import sys
3+
from pip._internal.cli.main import main
4+
if __name__ == '__main__':
5+
sys.argv[0] = sys.argv[0].removesuffix('.exe')
6+
sys.exit(main())

install/bin/pip3.15

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#!/home/stefanze/src/cpython-up-to-date/install/bin/python3.15
2+
import sys
3+
from pip._internal.cli.main import main
4+
if __name__ == '__main__':
5+
sys.argv[0] = sys.argv[0].removesuffix('.exe')
6+
sys.exit(main())

install/bin/pydoc3

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
pydoc3.15

install/bin/pydoc3.15

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
#!/home/stefanze/src/cpython-up-to-date/install/bin/python3.15
2+
3+
import pydoc
4+
if __name__ == '__main__':
5+
pydoc.cli()

install/bin/python3

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
python3.15

install/bin/python3-config

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
python3.15-config

install/bin/python3.15

38.7 MB
Binary file not shown.

0 commit comments

Comments
 (0)