Skip to content

gh-149402: don't assume single-character type codes (struct/array/ctypes)#149483

Open
skirpichev wants to merge 4 commits intopython:mainfrom
skirpichev:improve-pep3118-docs-p1/149402
Open

gh-149402: don't assume single-character type codes (struct/array/ctypes)#149483
skirpichev wants to merge 4 commits intopython:mainfrom
skirpichev:improve-pep3118-docs-p1/149402

Conversation

@skirpichev
Copy link
Copy Markdown
Member

@skirpichev skirpichev commented May 7, 2026

In the struct docs, section "Format Characters" was renamed to "Type Codes".

…ay/ctypes)

In the struct docs, section "Format Characters" was renamed to "Type
Codes".
@skirpichev skirpichev requested a review from vstinner May 7, 2026 04:56
@bedevere-app bedevere-app Bot added docs Documentation in the Doc dir skip news awaiting review labels May 7, 2026
@github-project-automation github-project-automation Bot moved this to Todo in Docs PRs May 7, 2026
@skirpichev
Copy link
Copy Markdown
Member Author

RTFD failure seems to be not related to the PR.

@vstinner
Copy link
Copy Markdown
Member

vstinner commented May 7, 2026

"docs/readthedocs.org:cpython-previews" failed with:

Error while cloning the repository: There was a problem cloning your repository. Please check the command output for more information.

Too bad, I like to use it to read rendered documentation :-)

@skirpichev
Copy link
Copy Markdown
Member Author

Maybe you can restart it?

@vstinner
Copy link
Copy Markdown
Member

vstinner commented May 7, 2026

In the struct docs, section "Format Characters" was renamed to "Type Codes".

Hum. I wanted to proposing renaming them to "Format Strings", but a "Format String" has already a different meaning in struct, it's the whole string starting with an optional endian character (@, <, >, =, !), followed by format characters with size and alignment. Format Strings: https://docs.python.org/dev/library/struct.html#format-strings.

The term "type code" is already used by the array module: the "type codes" table has a "type column", and there is the array.typecodes tuple. It's good to reuse the term. Doc: https://docs.python.org/dev/library/array.html

memoryview.cast() first parameter is called "format", and it's a format string (format character with an optional "@" prefix). Doc: https://docs.python.org/dev/library/stdtypes.html#memoryview.cast. cast() error message says "native format".

I think that I'm fine with replacing "Format Characters" with "Type Codes" :-)

Can you replace "format characters" with "type codes" in Objects/memoryview.c in comments and in the error:

        PyErr_SetString(PyExc_ValueError,
            "memoryview: destination format must be a native single "
            "character format prefixed with an optional '@'");

@vstinner
Copy link
Copy Markdown
Member

vstinner commented May 7, 2026

Maybe you can restart it?

I don't see how I can restart a failed RTD job. But it's fine, it will be retried at the next commit anyway.

@skirpichev
Copy link
Copy Markdown
Member Author

Can you replace "format characters" with "type codes" in Objects/memoryview.c in comments and in the error:

the error message looks different for me:

            "memoryview: destination format must be a native "
            "format prefixed with an optional '@'");

I think it's fine.

I did replacement for comments, though.

@read-the-docs-community
Copy link
Copy Markdown

Documentation build overview

📚 cpython-previews | 🛠️ Build #32580821 | 📁 Comparing a591fbe against main (612140e)

  🔍 Preview build  

4 files changed
± library/array.html
± library/binary.html
± library/ctypes.html
± library/struct.html

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

awaiting review docs Documentation in the Doc dir skip news

Projects

Status: Todo

Development

Successfully merging this pull request may close these issues.

2 participants