@@ -1577,9 +1577,10 @@ dummy_func(
15771577 err = PyObject_DelItem (ns , name );
15781578 // Can't use ERROR_IF here.
15791579 if (err != 0 ) {
1580- _PyEval_FormatExcCheckArg (tstate , PyExc_NameError ,
1581- NAME_ERROR_MSG ,
1582- name );
1580+ const char * err_msg = PyMapping_HasKey (BUILTINS (), name )
1581+ ? CANNOT_DELETE_BUILTIN_ERROR_MSG
1582+ : NAME_ERROR_MSG ;
1583+ _PyEval_FormatExcCheckArg (tstate , PyExc_NameError , err_msg , name );
15831584 ERROR_NO_POP ();
15841585 }
15851586 }
@@ -1720,8 +1721,11 @@ dummy_func(
17201721 ERROR_NO_POP ();
17211722 }
17221723 if (err == 0 ) {
1724+ const char * err_msg = PyMapping_HasKey (BUILTINS (), name )
1725+ ? CANNOT_DELETE_BUILTIN_ERROR_MSG
1726+ : NAME_ERROR_MSG ;
17231727 _PyEval_FormatExcCheckArg (tstate , PyExc_NameError ,
1724- NAME_ERROR_MSG , name );
1728+ err_msg , name );
17251729 ERROR_NO_POP ();
17261730 }
17271731 }
@@ -1888,10 +1892,13 @@ dummy_func(
18881892 inst (DELETE_FAST , (-- )) {
18891893 _PyStackRef v = GETLOCAL (oparg );
18901894 if (PyStackRef_IsNull (v )) {
1891- _PyEval_FormatExcCheckArg (tstate , PyExc_UnboundLocalError ,
1892- UNBOUNDLOCAL_ERROR_MSG ,
1893- PyTuple_GetItem (_PyFrame_GetCode (frame )-> co_localsplusnames , oparg )
1894- );
1895+ PyObject * name ;
1896+ name = PyTuple_GetItem (_PyFrame_GetCode (frame )-> co_localsplusnames ,
1897+ oparg );
1898+ const char * err_msg = PyMapping_HasKey (BUILTINS (), name )
1899+ ? CANNOT_DELETE_BUILTIN_ERROR_MSG
1900+ : UNBOUNDLOCAL_ERROR_MSG ;
1901+ _PyEval_FormatExcCheckArg (tstate , PyExc_UnboundLocalError , err_msg );
18951902 ERROR_IF (true);
18961903 }
18971904 _PyStackRef tmp = GETLOCAL (oparg );
0 commit comments