Open gpshead opened 2 years ago
It would be nice if the error message directly mentioned the sys.set_int_max_str_digits function as a way to increase the limit.
from https://github.com/sympy/sympy/issues/24033#issuecomment-1242342344 is also a possibility.
I wished I had something to link to from a URL in the exception error message itself, but did not do that when polishing up the change as we've never done such a thing before in CPython that I'm aware of. URLs in standard exception messages opens a can of works about long term URL stability requirements, a desire for them to be short, and a PSF managed canonical URL shortener that could be used for that purpose to avoid stale links from older versions as our web presence evolves.
I agree with these points, but there is some prior art of putting URLs in exception messages. (I know this only because I was just hacking on this part of the code).
Instead of a URL, you could say something like "See the docs about 'integer safety' for more information." As long as you keep that phrase in the docs in a searchable format, it should be easy enough to find from the error. I also try to put the exact error message into the docs that someone might copy and paste in Google, so that the docs are a close or exact match for the phrase.
You might also look into how SQLAlchemy has implemented links, I think they use a short/redirect like you've described.
sys.set_int_max_str_digits(0)
will raise on pre-patch versions. maybe:
import sys
try:
sys.set_int_max_str_digits(0)
except AttributeError:
pass
Based on this discussion comment: https://discuss.python.org/t/int-str-conversions-broken-in-latest-python-bugfix-releases/18889/17
We need to call this out better in whatever places are most meaningful to our users who may otherwise get lost or frustrated.
I fully expect that a stackoverflow
python
question regardingValueError: Exceeds the limit (4300) for integer string conversion
will wind up restating and linking to the most accessible docs about this, so why not have those docs be our own?I wished I had something to link to from a URL in the exception error message itself, but did not do that when polishing up the change as we've never done such a thing before in CPython that I'm aware of. URLs in standard exception messages opens a can of works about long term URL stability requirements, a desire for them to be short, and a PSF managed canonical URL shortener that could be used for that purpose to avoid stale links from older versions as our web presence evolves.