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

Misleading exception message frompathlib.PurePath() when mixing str and bytes arguments #103525

Closed
Labels
3.12only security fixestopic-pathlibtype-bugAn unexpected behavior, bug, or error
@barneygale

Description

@barneygale

Since6716254, attempting to create apathlib.PurePath orPath object with mixedstr andbytes arguments raises a TypeError (yay!) with a misleading message (booo!):

>>>importpathlib>>>pathlib.Path('foo',b'bar')TypeError:Can'tmixstringsandbytesinpathcomponents

This message implies that bytes are supported, as long as we don't mix them with strings. And yet when we try that:

>>>pathlib.Path(b'foo',b'bar')TypeError:argumentshouldbeastroranos.PathLikeobjectwhere__fspath__returnsastr,not'bytes'

This message is better, and should be used in the former case.

Linked PRs

Metadata

Metadata

Assignees

No one assigned

    Labels

    3.12only security fixestopic-pathlibtype-bugAn unexpected behavior, bug, or error

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions


      [8]ページ先頭

      ©2009-2025 Movatter.jp