1- // Copyright 2018 The go-python Authors. All rights reserved.
1+ // Copyright 2023 The go-python Authors. All rights reserved.
22// Use of this source code is governed by a BSD-style
33// license that can be found in the LICENSE file.
44
@@ -112,8 +112,6 @@ func NewCode(argcount int32, kwonlyargcount int32,
112112 filename_ Object , name_ Object , firstlineno int32 ,
113113 lnotab_ Object ) * Code {
114114
115- var cell2arg []byte
116-
117115 // Type assert the objects
118116 consts := consts_ .(Tuple )
119117 namesTuple := names_ .(Tuple )
@@ -154,7 +152,6 @@ func NewCode(argcount int32, kwonlyargcount int32,
154152 // return nil;
155153 // }
156154
157- n_cellvars := len (cellvars )
158155 intern_strings (namesTuple )
159156 intern_strings (varnamesTuple )
160157 intern_strings (freevarsTuple )
@@ -167,6 +164,38 @@ func NewCode(argcount int32, kwonlyargcount int32,
167164 }
168165 }
169166 }
167+
168+ return MakeCode (argcount ,
169+ kwonlyargcount ,
170+ nlocals ,
171+ stacksize ,
172+ flags ,
173+ code ,
174+ consts ,
175+ names ,
176+ varnames ,
177+ freevars ,
178+ cellvars ,
179+ filename ,
180+ name ,
181+ firstlineno ,
182+ lnotab )
183+ }
184+
185+ // Make a new code object
186+ func MakeCode (argcount int32 , kwonlyargcount int32 ,
187+ nlocals int32 , stacksize int32 , flags int32 ,
188+ code string , consts_ Object , names []string ,
189+ varnames []string , freevars []string , cellvars []string ,
190+ filename string , name string , firstlineno int32 ,
191+ lnotab string ) * Code {
192+
193+ var cell2arg []byte
194+
195+ // Type assert the objects
196+ consts := consts_ .(Tuple )
197+
198+ n_cellvars := len (cellvars )
170199 /* Create mapping between cells and arguments if needed. */
171200 if n_cellvars != 0 {
172201 total_args := argcount + kwonlyargcount
0 commit comments