@@ -33,24 +33,33 @@ bound into a function.
33
33
34
34
Return the number of free variables in *co *.
35
35
36
- .. c :function :: PyCodeObject* PyCode_New (int argcount, int kwonlyargcount, int nlocals, int stacksize, int flags, PyObject *code, PyObject *consts, PyObject *names, PyObject *varnames, PyObject *freevars, PyObject *cellvars, PyObject *filename, PyObject *name, int firstlineno, PyObject *lnotab )
36
+ .. c :function :: PyCodeObject* PyCode_New (int argcount, int kwonlyargcount, int nlocals, int stacksize, int flags, PyObject *code, PyObject *consts, PyObject *names, PyObject *varnames, PyObject *freevars, PyObject *cellvars, PyObject *filename, PyObject *name, int firstlineno, PyObject *linetable, PyObject *exceptiontable )
37
37
38
38
Return a new code object. If you need a dummy code object to create a frame,
39
39
use :c:func: `PyCode_NewEmpty ` instead. Calling :c:func: `PyCode_New ` directly
40
- can bind you to a precise Python version since the definition of the bytecode
41
- changes often.
40
+ will bind you to a precise Python version since the definition of the bytecode
41
+ changes often. The many arguments of this function are inter-dependent in complex
42
+ ways, meaning that subtle changes to values are likely to result in incorrect
43
+ execution or VM crashes. Use this function only with extreme care.
42
44
43
- .. c :function :: PyCodeObject* PyCode_NewWithPosOnlyArgs (int argcount, int posonlyargcount, int kwonlyargcount, int nlocals, int stacksize, int flags, PyObject *code, PyObject *consts, PyObject *names, PyObject *varnames, PyObject *freevars, PyObject *cellvars, PyObject *filename, PyObject *name, int firstlineno, PyObject *lnotab)
45
+ .. versionchanged :: 3.11
46
+ Added ``exceptiontable `` parameter.
47
+
48
+ .. c :function :: PyCodeObject* PyCode_NewWithPosOnlyArgs (int argcount, int posonlyargcount, int kwonlyargcount, int nlocals, int stacksize, int flags, PyObject *code, PyObject *consts, PyObject *names, PyObject *varnames, PyObject *freevars, PyObject *cellvars, PyObject *filename, PyObject *name, int firstlineno, PyObject *linetable, PyObject *exceptiontable)
44
49
45
50
Similar to :c:func: `PyCode_New `, but with an extra "posonlyargcount" for positional-only arguments.
51
+ The same caveats that apply to ``PyCode_New `` also apply to this function.
46
52
47
53
.. versionadded :: 3.8
48
54
55
+ .. versionchanged :: 3.11
56
+ Added ``exceptiontable `` parameter.
57
+
49
58
.. c :function :: PyCodeObject* PyCode_NewEmpty (const char *filename, const char *funcname, int firstlineno)
50
59
51
60
Return a new empty code object with the specified filename,
52
- function name, and first line number. It is illegal to
53
- :func: ` exec ` or :func: ` eval ` the resulting code object .
61
+ function name, and first line number. The resulting code
62
+ object will raise an `` Exception `` if executed .
54
63
55
64
.. c :function :: int PyCode_Addr2Line (PyCodeObject *co, int byte_offset)
56
65
0 commit comments