@@ -478,9 +478,9 @@ PyRun_SimpleStringFlags(const char *command, PyCompilerFlags *flags)
478
478
479
479
static int
480
480
parse_syntax_error (PyObject * err , PyObject * * message , PyObject * * filename ,
481
- int * lineno , int * offset , PyObject * * text )
481
+ Py_ssize_t * lineno , Py_ssize_t * offset , PyObject * * text )
482
482
{
483
- int hold ;
483
+ Py_ssize_t hold ;
484
484
PyObject * v ;
485
485
_Py_IDENTIFIER (msg );
486
486
_Py_IDENTIFIER (filename );
@@ -513,7 +513,7 @@ parse_syntax_error(PyObject *err, PyObject **message, PyObject **filename,
513
513
v = _PyObject_GetAttrId (err , & PyId_lineno );
514
514
if (!v )
515
515
goto finally ;
516
- hold = _PyLong_AsInt (v );
516
+ hold = PyLong_AsSsize_t (v );
517
517
Py_DECREF (v );
518
518
if (hold < 0 && PyErr_Occurred ())
519
519
goto finally ;
@@ -526,7 +526,7 @@ parse_syntax_error(PyObject *err, PyObject **message, PyObject **filename,
526
526
* offset = -1 ;
527
527
Py_DECREF (v );
528
528
} else {
529
- hold = _PyLong_AsInt (v );
529
+ hold = PyLong_AsSsize_t (v );
530
530
Py_DECREF (v );
531
531
if (hold < 0 && PyErr_Occurred ())
532
532
goto finally ;
@@ -552,7 +552,7 @@ parse_syntax_error(PyObject *err, PyObject **message, PyObject **filename,
552
552
}
553
553
554
554
static void
555
- print_error_text (PyObject * f , int offset , PyObject * text_obj )
555
+ print_error_text (PyObject * f , Py_ssize_t offset , PyObject * text_obj )
556
556
{
557
557
/* Convert text to a char pointer; return if error */
558
558
const char * text = PyUnicode_AsUTF8 (text_obj );
@@ -586,7 +586,7 @@ print_error_text(PyObject *f, int offset, PyObject *text_obj)
586
586
break ;
587
587
}
588
588
Py_ssize_t inl = nl - text ;
589
- if (inl >= ( Py_ssize_t ) offset ) {
589
+ if (inl >= offset ) {
590
590
break ;
591
591
}
592
592
inl += 1 ;
@@ -833,7 +833,7 @@ print_exception(PyObject *f, PyObject *value)
833
833
_PyObject_HasAttrId (value , & PyId_print_file_and_line ))
834
834
{
835
835
PyObject * message , * filename , * text ;
836
- int lineno , offset ;
836
+ Py_ssize_t lineno , offset ;
837
837
if (!parse_syntax_error (value , & message , & filename ,
838
838
& lineno , & offset , & text ))
839
839
PyErr_Clear ();
@@ -843,7 +843,7 @@ print_exception(PyObject *f, PyObject *value)
843
843
Py_DECREF (value );
844
844
value = message ;
845
845
846
- line = PyUnicode_FromFormat (" File \"%S\", line %d \n" ,
846
+ line = PyUnicode_FromFormat (" File \"%S\", line %zd \n" ,
847
847
filename , lineno );
848
848
Py_DECREF (filename );
849
849
if (line != NULL ) {
0 commit comments