Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

PyArg_ParseTupleAndKeywords() and non-ASCII keyword names #110815

Closed
Labels
3.11only security fixes3.12only security fixes3.13bugs and security fixestopic-C-APItopic-unicodetype-bugAn unexpected behavior, bug, or errortype-crashA hard crash of the interpreter, possibly with a core dump
@serhiy-storchaka

Description

@serhiy-storchaka

Most of C strings in the C API are implied to be UTF-8 encoded. PyArg_ParseTupleAndKeywords() mostly works with non-ASCII keyword names as they are UTF-8 encoded. Except one case, when you pass argument by keyword with invalid non-ASCII name to a function that has optional parameter with non-ASCII UTF-8 encoded name. In this case you get a crash in the debug build.

It was caused by combination off4934ea anda83a6a3 (bpo-28701,#72887). Before these changes you simply got inaccurate or even wrong error message.

Examples:

  1. Parameters: "ä"
    Keyword arguments: "ë"
    Old behavior: TypeError "'ë' is an invalid keyword argument for this function"
    Current behavior: crash
    Expected behavior: TypeError "'ë' is an invalid keyword argument for this function"

  2. Parameters: "ä"
    Keyword arguments: "ä"
    Old behavior: TypeError "invalid keyword argument for this function"
    Current behavior: crash
    Expected behavior: TypeError "'ä' is an invalid keyword argument for this function"

  3. Parameters: "ä", "ë"
    Keyword arguments: "ä", "ë"
    Old behavior: TypeError "'ë' is an invalid keyword argument for this function"
    Current behavior: crash
    Expected behavior: TypeError "'ä' is an invalid keyword argument for this function"

In case 1 the pre-bpo-28701 behavior was correct, in case 2 it was correct but not precise (it failed to find the name of invalid keyword argument), in case 3 it was wrong (it found wrong name). In all cases there is a crash currently.

Linked PRs

Metadata

Metadata

Assignees

No one assigned

    Labels

    3.11only security fixes3.12only security fixes3.13bugs and security fixestopic-C-APItopic-unicodetype-bugAn unexpected behavior, bug, or errortype-crashA hard crash of the interpreter, possibly with a core dump

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions


      [8]ページ先頭

      ©2009-2025 Movatter.jp