GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — inspect.signature(bytes.hex) raises ValueError "builtin has invalid signature" · Issue #87233 · python/cpython

inspect.signature(bytes.hex) raises ValueError "builtin has invalid signature" #87233

New issue
Copy link
New issue
Copy link
Open
Open
inspect.signature(bytes.hex) raises ValueError "builtin has invalid signature"#87233
Copy link
Labels
3.10 (EOL)end of lifeend of lifestdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directorytype-featureA feature request or enhancementA feature request or enhancement

Description

verhovsky
mannequin
opened on Jan 29, 2021
Issue body actions
BPO 43067
Nosy @verhovsky

Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

Show more details

GitHub fields:

assignee = None
closed_at = None
created_at = <Date 2021-01-29.21:00:52.553>
labels = ['type-feature', 'library', '3.10']
title = 'inspect.signature(bytes.hex) raises ValueError "builtin has invalid signature"'
updated_at = <Date 2021-01-29.21:00:52.553>
user = 'https://github.com/verhovsky'

bugs.python.org fields:

activity = <Date 2021-01-29.21:00:52.553>
actor = 'boris'
assignee = 'none'
closed = False
closed_date = None
closer = None
components = ['Library (Lib)']
creation = <Date 2021-01-29.21:00:52.553>
creator = 'boris'
dependencies = []
files = []
hgrepos = []
issue_num = 43067
keywords = []
message_count = 1.0
messages = ['385940']
nosy_count = 1.0
nosy_names = ['boris']
pr_nums = []
priority = 'normal'
resolution = None
stage = None
status = 'open'
superseder = None
type = 'enhancement'
url = 'https://bugs.python.org/issue43067'
versions = ['Python 3.10']

Activity

  1. verhovsky commented on Jan 29, 2021

    @verhovsky
    verhovskymannequin
    on Jan 29, 2021
    MannequinAuthor
    More actions

    On Python 3.9

    >>> import inspect
    >>> inspect.signature(bytes.hex)
    Traceback (most recent call last):
      File "<stdin>", line 1, in <module>
      File "/usr/lib/python3.9/inspect.py", line 3118, in signature
        return Signature.from_callable(obj, follow_wrapped=follow_wrapped)
      File "/usr/lib/python3.9/inspect.py", line 2867, in from_callable
        return _signature_from_callable(obj, sigcls=cls,
      File "/usr/lib/python3.9/inspect.py", line 2322, in _signature_from_callable
        return _signature_from_builtin(sigcls, obj,
      File "/usr/lib/python3.9/inspect.py", line 2135, in _signature_from_builtin
        return _signature_fromstr(cls, func, s, skip_bound_arg)
      File "/usr/lib/python3.9/inspect.py", line 2005, in _signature_fromstr
        raise ValueError("{!r} builtin has invalid signature".format(obj))
    ValueError: <method 'hex' of 'bytes' objects> builtin has invalid signature

    This is also true for memoryview.hex and bytearray.hex . This happens because

    >>> bytes.hex.__text_signature__
    '($self, /, sep=<unrepresentable>, bytes_per_sep=1)'

    when it would make more sense for it to return

    '($self, /, sep='', bytes_per_sep=1)'

    or at least sep=None

  2. verhovsky
    added
    3.10 (EOL)end of lifeend of life
    stdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directory
    type-featureA feature request or enhancementA feature request or enhancement
    on Jan 29, 2021
  3. ezio-melotti
    transferred this issue fromon Apr 10, 2022
  4. JelleZijlstra commented on Nov 9, 2023

    @JelleZijlstra
    JelleZijlstra
    on Nov 9, 2023
    Member
    More actions

    I am looking at this because I realized it's preventing us from testing some signatures in typeshed.

    I got this to work:

    >>> import inspect
    >>> inspect.signature(bytes.hex)
    <Signature (self, /, sep=Ellipsis, bytes_per_sep=1)>
    

    But it feels wrong to claim Ellipsis as the default, because that's not really true. A more principled solution would be to add a Parameter.unrepresentable marker and use that as the default, but that feels like a change we can make only in 3.13, not in the bugfix branches.

    My leaning is to apply the fix suggested above in 3.13, and put some hack in stubtest (or other tools that want to inspect signatures) to make it work on earlier versions.

  5. JelleZijlstra commented on Nov 9, 2023

    @JelleZijlstra
    JelleZijlstra
    on Nov 9, 2023
    Member
    More actions

    This is basically @sobolevn's idea from https://discuss.python.org/t/ac-null-defaults-prevent-correct-signatures-lets-add-inspect-unrepresentable-to-fix-this/30753/6.

  6. sobolevn commented on Nov 9, 2023

    @sobolevn
    sobolevn
    on Nov 9, 2023
    Member
    More actions

    @serhiy-storchaka said that future inspect.signatures() is a better solution. But, it is in the works.

  7. JelleZijlstra
    added a commit that references this issue on Nov 9, 2023

    stubtest: hack for "<unrepresentable>" defaults

    3e2ca6f
  8. JelleZijlstra
    added a commit that references this issue on Nov 18, 2023

    stubtest: hack for "<unrepresentable>" defaults (#16433)

    706389d
  9. serhiy-storchaka
    added this to Inspect issues 🔍on Mar 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    3.10 (EOL)end of lifeend of lifestdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directorytype-featureA feature request or enhancementA feature request or enhancement

    Projects

    • Inspect issues 🔍
      Status
      No status
      Show more project fields

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

    You are visitor 01402503 — GeezerVison does not store the pages you look up.
    Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.