@@ -26,13 +26,13 @@ use crate::{
2626} ;
2727use alloc:: fmt;
2828use bstr:: ByteSlice ;
29+ use core:: cell:: UnsafeCell ;
2930use core:: iter:: zip;
3031use core:: sync:: atomic;
3132use core:: sync:: atomic:: AtomicPtr ;
3233use core:: sync:: atomic:: Ordering :: Relaxed ;
3334use indexmap:: IndexMap ;
3435use itertools:: Itertools ;
35- use core:: cell:: UnsafeCell ;
3636use rustpython_common:: atomic:: { PyAtomic , Radium } ;
3737use rustpython_common:: {
3838 boxvec:: BoxVec ,
@@ -1822,16 +1822,18 @@ impl ExecutingFrame<'_> {
18221822 // Same as LoadFast but explicitly checks for unbound locals
18231823 // (LoadFast in RustPython already does this check)
18241824 let idx = idx. get ( arg) as usize ;
1825- let x = unsafe { self . fastlocals . borrow ( ) } [ idx] . clone ( ) . ok_or_else ( || {
1826- vm. new_exception_msg (
1827- vm. ctx . exceptions . unbound_local_error . to_owned ( ) ,
1828- format ! (
1829- "local variable '{}' referenced before assignment" ,
1830- self . code. varnames[ idx]
1825+ let x = unsafe { self . fastlocals . borrow ( ) } [ idx]
1826+ . clone ( )
1827+ . ok_or_else ( || {
1828+ vm. new_exception_msg (
1829+ vm. ctx . exceptions . unbound_local_error . to_owned ( ) ,
1830+ format ! (
1831+ "local variable '{}' referenced before assignment" ,
1832+ self . code. varnames[ idx]
1833+ )
1834+ . into ( ) ,
18311835 )
1832- . into ( ) ,
1833- )
1834- } ) ?;
1836+ } ) ?;
18351837 self . push_value ( x) ;
18361838 Ok ( None )
18371839 }
@@ -1870,16 +1872,18 @@ impl ExecutingFrame<'_> {
18701872 // Currently this just clones like LoadFast.
18711873 Instruction :: LoadFastBorrow ( idx) => {
18721874 let idx = idx. get ( arg) as usize ;
1873- let x = unsafe { self . fastlocals . borrow ( ) } [ idx] . clone ( ) . ok_or_else ( || {
1874- vm. new_exception_msg (
1875- vm. ctx . exceptions . unbound_local_error . to_owned ( ) ,
1876- format ! (
1877- "local variable '{}' referenced before assignment" ,
1878- self . code. varnames[ idx]
1875+ let x = unsafe { self . fastlocals . borrow ( ) } [ idx]
1876+ . clone ( )
1877+ . ok_or_else ( || {
1878+ vm. new_exception_msg (
1879+ vm. ctx . exceptions . unbound_local_error . to_owned ( ) ,
1880+ format ! (
1881+ "local variable '{}' referenced before assignment" ,
1882+ self . code. varnames[ idx]
1883+ )
1884+ . into ( ) ,
18791885 )
1880- . into ( ) ,
1881- )
1882- } ) ?;
1886+ } ) ?;
18831887 self . push_value ( x) ;
18841888 Ok ( None )
18851889 }
0 commit comments