gh-146238: add missing tests for 'e', 'Zf' and 'Zd' array type codes in test_buffer.py#149345
Open
skirpichev wants to merge 6 commits intopython:mainfrom
Open
gh-146238: add missing tests for 'e', 'Zf' and 'Zd' array type codes in test_buffer.py#149345skirpichev wants to merge 6 commits intopython:mainfrom
skirpichev wants to merge 6 commits intopython:mainfrom
Conversation
This amends e79fd60. I'll not fix this for 'F'/'D' complex types as they might be removed.
Member
Author
|
CC @vstinner |
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as spam.
This comment was marked as spam.
vstinner
reviewed
May 5, 2026
| for case in cases: | ||
| case.append(0) | ||
| fmt = case.typecode | ||
| if struct.calcsize(fmt) <= MAX_ALIGN: |
Member
There was a problem hiding this comment.
You already skipped formats larger than MAX_ALIGN in cases = [array.array(fmt) for fmt in ARRAY if struct.calcsize(fmt) <= MAX_ALIGN], no?
Comment on lines
+4500
to
+4503
| align = max(struct.calcsize(fmt) for fmt in ARRAY | ||
| if struct.calcsize(fmt) <= MAX_ALIGN) | ||
| cases = [array.array(fmt) for fmt in ARRAY | ||
| if struct.calcsize(fmt) <= MAX_ALIGN] |
Member
There was a problem hiding this comment.
I suggest adding a comment explaining why we skip some formats:
Suggested change
| align = max(struct.calcsize(fmt) for fmt in ARRAY | |
| if struct.calcsize(fmt) <= MAX_ALIGN) | |
| cases = [array.array(fmt) for fmt in ARRAY | |
| if struct.calcsize(fmt) <= MAX_ALIGN] | |
| # Skip formats larger than the normal alignment of 'max_align_t', | |
| # in bytes. | |
| formats = [fmt for fmt in ARRAY if struct.calcsize(fmt) <= MAX_ALIGN] | |
| align = max(struct.calcsize(fmt) for fmt in formats) | |
| cases = [array.array(fmt) for fmt in formats] |
Comment on lines
144
to
148
| # Format codes supported by array.array | ||
| ARRAY = NATIVE.copy() | ||
| for k in NATIVE: | ||
| if not k in "bBhHiIlLfd": | ||
| if not k in list("bBhHiIlLefd") + ['Zf', 'Zd']: | ||
| del ARRAY[k] |
Member
There was a problem hiding this comment.
I suggest only building the list once, replace not k in with k not in, replace k with fmt and add missing array formats (uw and qQ):
# Format codes supported by array.array
ARRAY = NATIVE.copy()
_ARRAY_FORMATS = list("bBuwhHiIlLqQefd") + ['Zf', 'Zd']
for fmt in NATIVE:
if fmt not in _ARRAY_FORMATS:
del ARRAY[fmt]
Member
|
test_buffer fails on WASI: |
Member
|
On WASI, Would it make sense to use |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This amends e79fd60.