method: code.Code.new

 return new code object with modified attributes. 
            if rec-cursive is true then dive into code 
            objects contained in co_consts. 
        
    def new(self, rec=False, **kwargs): 

origin: code.Code

where:

exceptions that might appear during execution:

function source:

def new(self, rec=False, **kwargs): 
    """ return new code object with modified attributes. 
            if rec-cursive is true then dive into code 
            objects contained in co_consts. 
        """ 
    names = [x for x in dir(self.raw) if x[:3] == 'co_']
    for name in kwargs: 
        if name not in names: 
            raise TypeError("unknown code attribute: %r" %(name, ))
    if rec: 
        newconstlist = []
        co = self.raw
        cotype = type(co)
        for c in co.co_consts:
            if isinstance(c, cotype):
                c = self.__class__(c).new(rec=True, **kwargs) 
            newconstlist.append(c)
        return self.new(rec=False, co_consts=tuple(newconstlist), **kwargs) 
    for name in names:
        if name not in kwargs:
            kwargs[name] = getattr(self.raw, name)
    return py.std.new.code(
             kwargs['co_argcount'],
             kwargs['co_nlocals'],
             kwargs['co_stacksize'],
             kwargs['co_flags'],
             kwargs['co_code'],
             kwargs['co_consts'],
             kwargs['co_names'],
             kwargs['co_varnames'],
             kwargs['co_filename'],
             kwargs['co_name'],
             kwargs['co_firstlineno'],
             kwargs['co_lnotab'],
             kwargs['co_freevars'],
             kwargs['co_cellvars'],
    )

call sites:

called in /home/johnny/projects/merlinux/py/dist/py/code/code.py

traceback code.Code.new.0

called in /home/johnny/projects/merlinux/py/dist/py/code/testing/test_code.py

traceback code.Code.new.1

called in /home/johnny/projects/merlinux/py/dist/py/code/code.py

traceback code.Code.new.2

called in None</home/johnny/projects/merlinux/py/dist/py/test/raises.py:20>

traceback code.Code.new.3

called in /home/johnny/projects/merlinux/py/dist/py/code/source.py

traceback code.Code.new.4

called in /home/johnny/projects/merlinux/py/dist/py/code/code.py

traceback code.Code.new.5

called in /home/johnny/projects/merlinux/py/dist/py/code/source.py

traceback code.Code.new.6

called in /home/johnny/projects/merlinux/py/dist/py/code/code.py

traceback code.Code.new.7

called in /home/johnny/projects/merlinux/py/dist/py/code/testing/test_code.py

traceback code.Code.new.8

called in /home/johnny/projects/merlinux/py/dist/py/code/code.py

traceback code.Code.new.9

called in /home/johnny/projects/merlinux/py/dist/py/code/code.py

traceback code.Code.new.10

called in /home/johnny/projects/merlinux/py/dist/py/code/code.py

traceback code.Code.new.11

called in /home/johnny/projects/merlinux/py/dist/py/code/source.py

traceback code.Code.new.12

called in /home/johnny/projects/merlinux/py/dist/py/code/testing/test_code.py

traceback code.Code.new.13

called in /home/johnny/projects/merlinux/py/dist/py/code/code.py

traceback code.Code.new.14

called in /home/johnny/projects/merlinux/py/dist/py/code/code.py

traceback code.Code.new.15

called in /home/johnny/projects/merlinux/py/dist/py/code/code.py

traceback code.Code.new.16

called in /home/johnny/projects/merlinux/py/dist/py/code/source.py

traceback code.Code.new.17

called in /home/johnny/projects/merlinux/py/dist/py/code/source.py

traceback code.Code.new.18

called in /home/johnny/projects/merlinux/py/dist/py/code/code.py

traceback code.Code.new.19

called in /home/johnny/projects/merlinux/py/dist/py/code/code.py

traceback code.Code.new.20