File tree Expand file tree Collapse file tree 1 file changed +18
-1
lines changed Expand file tree Collapse file tree 1 file changed +18
-1
lines changed Original file line number Diff line number Diff line change @@ -2460,8 +2460,25 @@ ast_for_atom(struct compiling *c, const node *n)
24602460 return NULL ;
24612461 }
24622462 pynum = parsenumber (c , STR (ch ));
2463- if (!pynum )
2463+ if (!pynum ) {
2464+ PyThreadState * tstate = PyThreadState_GET ();
2465+ // The only way a ValueError should happen in _this_ code is via
2466+ // PyLong_FromString hitting a length limit.
2467+ if (tstate -> curexc_type == PyExc_ValueError &&
2468+ tstate -> curexc_value != NULL ) {
2469+ PyObject * type , * value , * tb ;
2470+ // This acts as PyErr_Clear() as we're replacing curexc.
2471+ PyErr_Fetch (& type , & value , & tb );
2472+ Py_XDECREF (tb );
2473+ Py_DECREF (type );
2474+ ast_error (c , ch ,
2475+ "%S - Consider hexidecimal for huge integer literals "
2476+ "to avoid decimal conversion limits." ,
2477+ value );
2478+ Py_DECREF (value );
2479+ }
24642480 return NULL ;
2481+ }
24652482
24662483 if (PyArena_AddPyObject (c -> c_arena , pynum ) < 0 ) {
24672484 Py_DECREF (pynum );
You can’t perform that action at this time.
0 commit comments