USING PYCForge

Fixing conversion errors

A diagnostic identifies the source that could not convert and explains why. Start with the first error, make a focused correction, and convert again.

Find and fix the source

  1. Select the diagnostic in the workspace to open its module and highlight the affected text.
  2. Read the message and suggested correction. Keep the error code if you need to report the issue.
  3. Compare your code with the matching example in Help.
  4. Convert all included files again after editing. The old C output does not update until conversion succeeds.

Variable and string errors added in 1.1

CodeCheck thisTypical correction
PYC4501Annotation and assigned value disagree.Keep one type per variable. Use 1.0 for float; assign declarations before reading them.
PYC4502A constant numeric value is unsupported or out of range.Keep integer values within signed 64-bit limits and use finite floats.
PYC4503A string contains NUL or cannot be encoded as valid UTF-8.Use valid Unicode text without embedded NUL characters.
PYC4504Constant expansion exceeded a conversion limit.Reduce repetitions, expanded strings, or source size.
PYC4505A constant string operation is invalid.Check index bounds, slice steps, method arguments, and supported methods.
PYC4506An assignment target or unpacking form is unsupported.Use scalar names and matching flat tuple/list assignments; avoid nested or starred targets.
PYC4507A module value needs unsupported runtime work or mutable state.Use constant initializers, avoid conflicting names, and pass changing values as function parameters.
PYC4510A string operation received a non-string value.Keep both operands string-valued on every path.

Other common errors

Code or familyTypical issueNext step
PYC100xInvalid conversion request or resource setting.Try the default settings and check the requested limits.
PYC28xx–PYC29xxUnsupported function, expression, call, return, or variable use.Read the specific message and the matching reference page.
PYC2940A variable may be read before assignment.Initialize it before use on every continuing path.
PYC2941A loop variable is used where it may not exist.Initialize a separate result before the loop.
PYC2943A variable changes type.Use a consistent type in all assignments and branches.
PYC34xxUnsupported container form or use.Check Containers and records.
PYC35xxMissing module, unsupported import, or conflicting name.Add the required source file and use a direct function import.
PYC36xxUnsupported record class or field access.Use the exact simple record example.
PYC9xxxInternal conversion error.Save a minimal example, the exact message, and the installed version for a bug report.

Set errors

Use 1–64 unique literals of one numeric or Boolean type. Assign the set to a local name and use that name for membership checks. PYC3411 reports unsupported set indexing; PYC3412 reports unsupported set iteration. Use an ordered list or tuple when your program needs indexing or iteration.

File errors during conversion

CodeTypical correction
PYC3901Use one direct function-body with open statement per session.
PYC3902Do not reassign the built-in name open.
PYC3903Check path, literal mode, encoding='utf-8', and newline=''.
PYC3904Give the handle a fresh local name.
PYC3905Use one supported read or write and the documented return form.
PYC3906Do not alias the handle or use it after the with; return a read value as documented.
PYC3907Reduce the number of file operations.
PYC3908Call file-access functions from the C caller, rather than another converted Python function.

Errors when the generated C runs use numeric status values instead. See Check file errors from C.

Understand the result

If a result includes warnings, review them before using the generated C.