File tree Expand file tree Collapse file tree 1 file changed +19
-1
lines changed
Expand file tree Collapse file tree 1 file changed +19
-1
lines changed Original file line number Diff line number Diff line change @@ -74,6 +74,11 @@ func (vm *Vm) PUSH(obj py.Object){
7474vm .frame .Stack = append (vm .frame .Stack , obj )
7575}
7676
77+ // Push items to top of vm stack
78+ func (vm * Vm ) EXTEND (items py.Tuple ){
79+ vm .frame .Stack = append (vm .frame .Stack , items ... )
80+ }
81+
7782// Adds a traceback to the exc passed in for the current vm state
7883func (vm * Vm ) AddTraceback (exc * py.ExceptionInfo ){
7984exc .Traceback = & py.Traceback {
@@ -725,7 +730,20 @@ func do_DELETE_NAME(vm *Vm, namei int32){
725730// stack right-to-left.
726731func do_UNPACK_SEQUENCE (vm * Vm , count int32 ){
727732defer vm .CheckException ()
728- vm .NotImplemented ("UNPACK_SEQUENCE" , count )
733+ it := vm .POP ()
734+ i := count
735+ items := make (py.Tuple , count )
736+ py .Iterate (it , func (item py.Object ){
737+ i --
738+ if i < 0 {
739+ panic (py .ExceptionNewf (py .ValueError , "Too many values to unpack (expected %d)" , count ))
740+ }
741+ items [i ] = item
742+ })
743+ if i != 0 {
744+ panic (py .ExceptionNewf (py .ValueError , "Need more than %d values to unpack (expected %d)" , count - i , count ))
745+ }
746+ vm .EXTEND (items )
729747}
730748
731749// Implements TOS.name = TOS1, where namei is the index of name in
You can’t perform that action at this time.
0 commit comments