{"record":{"id":"2c33b995a7b14eee","repo":"jax-ml/jax","slug":"value-of-type-type-self-is-not-convertible-to-o","errorCode":null,"errorMessage":"Value of type {type(self)} is not convertible to oct.","messagePattern":"Value of type (.+?) is not convertible to oct\\.","errorType":"exception","errorClass":"TypeError","httpStatus":null,"severity":"error","filePath":"jax/_src/core.py","lineNumber":1143,"sourceCode":"\n  def __complex__(self):\n    check_scalar_conversion(self)\n    if not hasattr(self.aval, \"_complex\"):\n      raise TypeError(f\"Value of type {type(self)} is not convertible to complex.\")\n    return self.aval._complex(self)\n\n  def __hex__(self):\n    if is_concrete(self): return hex(self.to_concrete_value())\n    check_integer_conversion(self)\n    if not hasattr(self.aval, \"_hex\"):\n      raise TypeError(f\"Value of type {type(self)} is not convertible to hex.\")\n    return self.aval._hex(self)\n\n  def __oct__(self):\n    if is_concrete(self): return oct(self.to_concrete_value())\n    check_integer_conversion(self)\n    if not hasattr(self.aval, \"_oct\"):\n      raise TypeError(f\"Value of type {type(self)} is not convertible to oct.\")\n    return self.aval._oct(self)\n\n  def __index__(self):\n    if is_concrete(self): return operator.index(self.to_concrete_value())\n    check_integer_conversion(self)\n    if not hasattr(self.aval, \"_index\"):\n      raise TypeError(f\"Value of type {type(self)} is not convertible to integer index.\")\n    return self.aval._index(self)\n\n  # raises a useful error on attempts to pickle a Tracer.\n  def __reduce__(self):\n    raise ConcretizationTypeError(\n      self, (\"The error occurred in the __reduce__ method, which may \"\n             \"indicate an attempt to serialize/pickle a traced value.\"))\n\n  # raises the better error message from ShapedArray\n  def __setitem__(self, key, value):\n    if not hasattr(self.aval, \"_setitem\"):","sourceCodeStart":1125,"sourceCodeEnd":1161,"githubUrl":"https://github.com/jax-ml/jax/blob/1e1c6a8fc06dfcd1247076ec5cae4640cea5d7bb/jax/_src/core.py#L1125-L1161","documentation":"Raised by JAXTracer.__oct__ when oct() is called on a JAX Tracer. Tracers stand for values under construction by transformations such as jit, grad, or vmap and carry no concrete host value, so an octal string representation cannot be produced. JAX raises this TypeError to make the abstract-value leak obvious.","triggerScenarios":"Calling oct(tracer) inside jitted or autodiff-traced code; old-style '%o' % tracer formatting in traced functions; debugging bit flags or permission masks held in traced integers.","commonSituations":"Legacy Python 2-era or systems-flavored code (masks, file modes) reused inside jax.jit; verbose debug logging of traced integer state; porting NumPy integer pipelines that stringify intermediates.","solutions":["Drop oct() from traced code; inspect values with jax.debug.print instead.","Return the traced value and call oct() on the concrete output after jit returns.","If base-8 math is needed, do it with jax.numpy (e.g. x // 8**k % 8) rather than string formatting."],"exampleFix":"# before\n@jax.jit\ndef f(mode):\n    log(oct(mode))    # TypeError\n    return mode & 0o777\n\n# after\n@jax.jit\ndef f(mode):\n    jax.debug.print('mode={mode:o}', mode=mode)\n    return mode & 0o777","handlingStrategy":"validation","validationCode":"import jax\ndef oct_or_placeholder(x) -> str:\n    if isinstance(x, jax.core.Tracer):\n        return '<tracer>'  # or jax.debug.print inside trace\n    return oct(int(x))","typeGuard":"import jax\ndef is_tracer(x) -> bool:\n    return isinstance(x, jax.core.Tracer)","tryCatchPattern":null,"preventionTips":["Avoid string-radix formatting of traced integers; compute digits with jnp ops if needed.","Move oct() diagnostics outside transformations.","Audit logging code reused from non-JAX codebases before placing it under jit."],"tags":["jax","tracer","oct","formatting"],"backgroundTag":"jax-tracer-concretization","analyzedSha":"1e1c6a8fc06dfcd1247076ec5cae4640cea5d7bb","analyzedAt":"2026-08-27T09:53:25.647Z","schemaVersion":2},"datasetVersion":"2026-08-27T13:17:12.746Z"}