Hacktoberfest 2026:维护者为十月标记出来的 issue,仍然开放、适合新手。 浏览 Hacktoberfest issue

[Bug]: invalid signature of int.__new__ and missing signatures for __new__ dunders in extensions

未关闭
#1,192 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 1 天内回复

还没有人认领这个 Issue。

评估

难度
4/5
预计耗时
3-5 天
新手友好度
48/100
Issue 类型
缺陷
描述清晰度
基本清楚
活跃度
活跃
技术栈
python
领域
backend

调研方向

Start by reproducing the reported inspect.signature results for int.__new__ and gmp.mpz.__new__, then compare them with the expected CPython signatures. The issue does not name implementation files or tests, so locate the code and tests that determine signatures for built-in and extension __new__ methods. Done means both report the generic (*args, **kwargs) signature.

由索引模型根据 Issue 内容生成。

描述

bug
Describe the bug

In some sense it's a continuation of #998, but I think it deserves a separate issue.

GraalPy reports int.__new__() signature being <Signature (cls, x, /, base)>. That's just invalid, assuming e.g. that non keyword base argument is supported:

Python 3.13.14 (Thu Sep 17 18:51:21 UTC 2026)
[Graal, Oracle GraalVM, Java 25.0.4.1.1 (amd64)] on 'linux'
Type "help", "copyright", "credits" or "license" for more information.
>>> int('123', 16)
291

Also, in fact - default values for x and base are supported. Unfortunately, such methods can't be expressed by some targeted signature.

In CPython it is generic, <Signature (*args, **kwargs)>, and same for __new__() dunders in extensions (Here signatures in the GraalPy are missing.). Perhaps, GraalPy should do same. (Though note that PyPy3 has behavior similar to the GraalPy, but invalid signature here is <Signature (x=0, base=None, /)>.)

Operating system

Linux

CPU architecture

x86_64

GraalPy version

25.0.4.1.1

JDK version

No response

Context configuration

No response

Steps to reproduce
pip install python-gmp
Python 3.13.14 (Thu Sep 17 18:51:21 UTC 2026)
[Graal, Oracle GraalVM, Java 25.0.4.1.1 (amd64)] on 'linux'
Type "help", "copyright", "credits" or "license" for more information.
>>> import gmp, inspect
>>> inspect.signature(int.__new__)
<Signature (cls, x, /, base)>
>>> inspect.signature(gmp.mpz.__new__)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
    inspect.signature(gmp.mpz.__new__)
    ~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^
  File "/home/sk/graalpy3.13-25.4.4.1.1-linux-amd64/lib/python3.13/inspect.py", line 3399, in signature
    return Signature.from_callable(obj, follow_wrapped=follow_wrapped,
           ~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
                                   globals=globals, locals=locals, eval_str=eval_str)
                                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/sk/graalpy3.13-25.4.4.1.1-linux-amd64/lib/python3.13/inspect.py", line 3122, in from_callable
    return _signature_from_callable(obj, sigcls=cls,
                                    follow_wrapper_chains=follow_wrapped,
                                    globals=globals, locals=locals, eval_str=eval_str)
  File "/home/sk/graalpy3.13-25.4.4.1.1-linux-amd64/lib/python3.13/inspect.py", line 2615, in _signature_from_callable
    return _signature_from_builtin(sigcls, obj,
                                   skip_bound_arg=skip_bound_arg)
  File "/home/sk/graalpy3.13-25.4.4.1.1-linux-amd64/lib/python3.13/inspect.py", line 2401, in _signature_from_builtin
    raise ValueError("no signature found for builtin {!r}".format(func))
ValueError: no signature found for builtin <built-in method __new__ of type object at 0x42603ed>
Expected behavior
Python 3.16.0a0 (heads/main:ee68f5f46a1, Aug 12 2026, 11:19:39) [GCC 14.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import gmp, inspect
>>> inspect.signature(int.__new__)
<Signature (*args, **kwargs)>
>>> inspect.signature(gmp.mpz.__new__)
<Signature (*args, **kwargs)>
Stack trace

Additional context

No response

主要语言
Python
星标
1.7k
派生
155
平均合并
6 小时 26 分钟
30 天内合并 PR
53

环境准备

在 Codespaces 中打开

在浏览器里用你自己的 GitHub 账号启动这个项目的开发容器。

  • 没有 Dockerfile 或 Docker Compose 文件
  • 没有 Pull Request 模板
  • 阅读贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

oracle/graalpython 的其他 Issue

查看 oracle/graalpython 的全部 Issue

相似的 Issue

更多 Python Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。