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

help() output oflambda with manually set__annotations__ is one char off #107155

Closed
Labels
3.11only security fixes3.12only security fixes3.13bugs and security fixesstdlibStandard Library Python modules in the Lib/ directorytype-bugAn unexpected behavior, bug, or error
@Dutcho

Description

@Dutcho

Bug report

help() output oflambda with manually set__annotations__ is slightly scrambled.

f = lambda a, b, c: 0              # lambdas cannot have annotationsf.__annotations__['return'] = int  # but you can set them manuallyhelp(f)                            # superfluous ")" and missed last char# <lambda> lambda a, b, c) -> inimport inspectprint(inspect.signature(f))        # correctly displays# (a, b, c) -> int

Note

This is a minor glitch for an atypical (perhaps even unsupported) use of annotations.

Hypothesis

Perhapshelp() uses (the same logic as)inspect.signature() and (to reflectlambda syntax) wants to drop the brackets "(...)", but then has aone-off error for its text slice (picking") -> in" instead of" -> int")

Environment

  • CPython versions tested on: 3.6.8 - 3.11.4, 3.12.0b4
  • Operating system and architecture: Windows 11

Linked PRs

Metadata

Metadata

Assignees

No one assigned

    Labels

    3.11only security fixes3.12only security fixes3.13bugs and security fixesstdlibStandard 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


      [8]ページ先頭

      ©2009-2025 Movatter.jp