Skip to content

TP0233

Error: can’t be used in a native program (M23)

  • a native program can't use Python, with help build it without '--native'
  • '<T>.<m>' can't be used in a native program: <message> (M23)
  • a Python extension can't use Python interop itself (M25)
  • an extension module can only pass Python objects along, with help do this in Python, and pass the result (M45)

From the golden case tests/cases/m25/tp0233_extension.tpn:

tp0233_extension.tpn
# An extension module runs natively, so it can't use Python interop itself (SPEC §17.1).
from python import json
def dump(n: int) -> str:
return json.dumps(n) as str

The compiler reports:

tp0233_extension.tpn:2:1: error TP0233: a Python extension can't use Python interop itself

The specification lists every code.