Skip to content

Exception thrown by shlex.quote changed in 3.14 and is not documented #138804

@cybit

Description

@cybit

Bug report

Bug description:

It seems to me that #132036 not only made the import time faster but did also change the exception thrown if the arguments in shlex.quote are not of type str.

It used to be "TypeError", now it is "AttributeError" .

I am not able to find this change in the release notes or the PR.

Test code:

import shlex

shlex.quote(123)

Test run on the shell:

for i in 10 11 12 13 14 ; do echo "3.$i" ; uv run --python 3.$i test.py 2>&1 | tail -n 1 ; done
3.10
TypeError: expected string or bytes-like object
3.11
TypeError: expected string or bytes-like object, got 'int'
3.12
TypeError: expected string or bytes-like object, got 'int'
3.13
TypeError: expected string or bytes-like object, got 'int'
3.14
AttributeError: 'int' object has no attribute 'isascii'

CPython versions tested on:

3.10, 3.11, 3.12, 3.13, 3.14

Operating systems tested on:

macOS

Linked PRs

Metadata

Metadata

Assignees

No one assigned

    Labels

    3.14bugs and security fixes3.15new features, bugs and security fixeseasystdlibStandard Library Python modules in the Lib/ directorytype-bugAn unexpected behavior, bug, or error

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions