Errors with the pstats-python-profiler when using Metaclasses

i am getting various errors when i try to run the code below with pstats,
specifically when i try to get a more detailed view using the pstats-python-profiler

from direct.showbase.ShowBase import ShowBase
from panda3d.core import loadPrcFileData

variablesConfig = '''
want-pstats 1
pstats-python-profiler 1  # without this the game and pstats run fine
loadPrcFileData('', variablesConfig)

class TypeAbility(type):
    def __new__(typ, name, bases, dct):
        # without this __new__ #1 runs fine 
        # but #2 and #3 both trow the bad argument error
        # no system error though
        return super().__new__(typ, name, bases, dct)

    def getCopy(cls):
        # TypeError: bad argument type for built-in operation
        return type(f'Copy{cls.__name__}', (cls,), {})
        return super().__new__(type(cls), f'Copy{cls.__name__}', (cls,), {})

        # SystemError: <class 'super'> returned a result with an exception set
        return super().__new__(type, f'Copy{cls.__name__}', (cls,), {})

class Ability(metaclass = TypeAbility):...

class Main(ShowBase):
    def __init__(self):
        q = Ability.getCopy()


i would like to use the third version of getCopy, but i don’t know what is causing the errors.
apologies in advance if i am missing something obvious, this is my first post

Looks like a bug. Can you please post this in the issue tracker? Thanks!