Skip to content

Conversation

@SwayamInSync
Copy link
Member

closes #249

@SwayamInSync SwayamInSync added this to the v1.0 milestone Jan 8, 2026
Copy link
Contributor

@juntyr juntyr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks!

@SwayamInSync SwayamInSync requested a review from ngoldbaum January 9, 2026 17:58
{
if (mod != Py_None) {
PyErr_SetString(PyExc_TypeError,
"pow() 3rd argument not allowed unless all arguments are integers");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The way the if statement above is written, the bit starting with "unless" is incorrect unless I'm missing something. Not sure if you meant to implement what's in the error or if the error is wrong.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cpython's pow function take 3 args but the last arg is only valid if the inputs are integers, for float values it passes the py_none there.
quaddtype is floating-point so we anyways don't need that argument and if in case somebody explicitly called pow with a 3rd argument (mod) then it'll be a mistake and error out

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the standard behaviour so we are in this PR implementing the same

In [5]: pow(2.0, 1,2)
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
Cell In[5], line 1
----> 1 pow(2.0, 1,2)

TypeError: pow() 3rd argument not allowed unless all arguments are integers

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In quaddtype it should be as

In [2]: a = QuadPrecision("1")

In [3]: pow(a, 2)
Out[3]: QuadPrecision('1.0e+000', backend='sleef')

In [4]: pow(a, 2, 1)
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
Cell In[4], line 1
----> 1 pow(a, 2, 1)

TypeError: pow() 3rd argument not allowed unless all arguments are integers

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for explaining.

@ngoldbaum ngoldbaum merged commit d9b1154 into numpy:main Jan 9, 2026
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

QuadPrecision(2) ** 100 crashes on Pyodide

3 participants