Ich versuche, einen neuen Codetyp zu erstellen. Der folgende Code läuft in Python 2.7 gut, aber in Python 3.2 erhalte ich einen Fehler: < /p>
def newCode(co_argcount = 0, co_nlocals = 0, co_stacksize = 0, co_flags = 0x0000,
co_code = bytes(), co_consts = (), co_names = (), co_varnames = (),
filename = "", name = "", firstlineno = 0, co_lnotab = bytes(),
co_freevars = (), co_cellvars = ()):
"""wrapper for CodeType so that we can remember the synatax"""
print(type(co_stacksize))
return types.CodeType(co_argcount, co_nlocals, co_stacksize,
co_flags, co_code, co_consts, co_names, co_varnames,
filename, name, firstlineno, co_lnotab, co_freevars, co_cellvars)
< /code>
Verwendung: < /p>
return newCode(co_code = code, co_stacksize = size, co_consts = consts)
< /code>
Die Debug -Zeile beweist, dass ich ein int als co_stacksize einsende ... Was hat sich in Python 3 geändert, damit dies nicht funktioniert? < /p>
Bearbeiten:
Hier ist der Fehler (weiß nicht, warum ich das vorher vergessen habe): < /p>
TypeError: Eine Ganzzahl ist erforderlich
Typingror bei der Erstellung von Codetypen in Python 3 ⇐ Python
-
- Similar Topics
- Replies
- Views
- Last post