[Bug]: incompatible (wrt CPython 3.12) signatures for some integer math functions and int's methods
维护者通常 1 天内回复
还没有人认领这个 Issue。
评估
调研方向
首先定位 GraalPy 中 math.comb、factorial、gcd、isqrt、lcm、perm 和 int.from_bytes/to_bytes 的实现或入口点。运行提供的 inspect.signature 与 CPython 的比较;当签名、参数名称、默认值和仅限位置标记与报告的 CPython 3.12 行为一致时,即视为完成。
由索引模型根据 Issue 内容生成。
描述
Describe the bug
Python 3.12.13 (tags/v3.12.13:3bb231a6a5d, May 14 2026, 11:06:30) [GCC 14.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import math, inspect
>>> for fn in ["comb", "factorial", "gcd", "isqrt", "lcm", "perm"]:
... f = getattr(math, fn)
... print(f, inspect.signature(f))
...
<built-in function comb> (n, k, /)
<built-in function factorial> (n, /)
<built-in function gcd> (*integers)
<built-in function isqrt> (n, /)
<built-in function lcm> (*integers)
<built-in function perm> (n, k=None, /)
>>> for meth in dir(int):
... m = getattr(int, meth)
... if meth.startswith("_") or not callable(m):
... continue
... try:
... print(meth, inspect.signature(m))
... except ValueError:
... pass
...
as_integer_ratio (self, /)
bit_count (self, /)
bit_length (self, /)
from_bytes (bytes, byteorder='big', *, signed=False)
is_integer (self, /)
to_bytes (self, /, length=1, byteorder='big', *, signed=False)
In the GraalPy instead:
Python 3.12.8 (Tue Jun 23 15:17:16 UTC 2026)
[Graal, GraalVM CE, Java 25.0.3 (amd64)] on 'linux'
Type "help", "copyright", "credits" or "license" for more information.
>>> import math, inspect
>>> for fn in ["comb", "factorial", "gcd", "isqrt", "lcm", "perm"]:
... f = getattr(math, fn)
... print(f, inspect.signature(f))
...
<built-in function comb> (a, b, /)
<built-in function factorial> (a, /)
<built-in function gcd> (*args, **kwargs)
<built-in function isqrt> (a, /)
<built-in function lcm> (*args, **kwargs)
<built-in function perm> (n, k, /)
>>> for meth in dir(int):
... m = getattr(int, meth)
... if meth.startswith("_") or not callable(m):
... continue
... try:
... print(meth, inspect.signature(m))
... except ValueError:
... pass
...
as_integer_ratio (self, /)
bit_count (self, /)
bit_length (self, /)
conjugate (self, /)
from_bytes (bytes, byteorder, /, *, signed)
is_integer (self, /)
to_bytes (self, length, byteorder, /, *, signed)
As you can see, all present function signatures from the math module are different. Of course, most functions have positional-only arguments and naming differences aren't significant. But differences for gcd, lcm and perm - are. Same true for to_bytes/from_bytes methods: they lack default values and incorrectly specify positional-only arguments.
Though, I would appreciate if signatures will be fully compatible, including naming of positional-only parameters. The reason is that such naming is used in the Python prose docs, e.g. https://docs.python.org/3.12/library/math.html#math.comb. The GraalPy has no documentation like this for the stdlib.
Operating system
Linux
CPU architecture
x86_64
GraalPy version
25.1.3
JDK version
No response
Context configuration
No response
Steps to reproduce
See bug description.
Expected behavior
Match CPython.
Stack trace
Additional context
No response
- 主要语言
- Python
- 星标
- 1.7k
- 派生
- 155
- 平均合并
- 6 小时 28 分钟
- 30 天内合并 PR
- 49
环境准备
在浏览器里用你自己的 GitHub 账号启动这个项目的开发容器。
- 没有 Dockerfile 或 Docker Compose 文件
- 没有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
oracle/graalpython 的其他 Issue
-
bug
难度 2/5 1-3 小时 新手友好度 74/100
oracle/graalpython#1105 ·
维护者通常 1 天内回复
-
bug
难度 2/5 1-3 小时 新手友好度 78/100
oracle/graalpython#1102 ·
维护者通常 1 天内回复
-
bug
难度 3/5 1-2 天 新手友好度 74/100
oracle/graalpython#1133 ·
维护者通常 1 天内回复
-
bug
难度 3/5 1-2 天 新手友好度 68/100
oracle/graalpython#1112 ·
维护者通常 1 天内回复
-
bug
难度 3/5 1-2 天 新手友好度 68/100
oracle/graalpython#1111 ·
维护者通常 1 天内回复
查看 oracle/graalpython 的全部 Issue
相似的 Issue
-
难度 2/5 1-3 小时 新手友好度 68/100
维护者通常 3 天内回复
-
难度 2/5 1-3 小时 新手友好度 88/100
modelcontextprotocol/python-sdk#3648 ·
维护者通常 1 天内回复
-
docs good first issue
难度 2/5 1-3 小时 新手友好度 78/100
VenetoStato/giorgio#6 ·
-
难度 1/5 1 小时以内 新手友好度 70/100
EclipseFdn/open-vsx.org#13831 ·
维护者通常 1 天内回复
-
feature request
难度 2/5 1-3 小时 新手友好度 68/100
维护者通常 2 天内回复