Skip to content

Deprecation of PyException_HEAD #142410

@Krishna-web-hub

Description

@Krishna-web-hub

Summary

This issue proposes the depreciation of the PyException_HEAD macro.

During review of PR #141522 (Document PyException_HEAD), the reviewers indicated that
this macro is internal, should not be documented, and should instead be deprecated.

  • PyException_HEAD is an internal macro used in CPython to define exception types.
  • It is not part of the public C API and was never intended to be used externally.
  • However, a small number of external projects have copied this pattern (for example,
    confluent_kafka).
  • If there are some internals change in the future (e.g. for PEP 697), this macro will
    create a maintenance burden.

This deprecation would allow external projects time to migrate, rather than breaking
them immediately.

Proposed actions

  • Marking the macro as deprecated in the header using Py_DEPRECATED() or a
    compiler warning.
  • We can also add the documentation note stating that the macro is deprecated and may be
    removed in a future release.
  • We can add a NEWS entry.
  • Recommending that new code use exception creation patterns compatible with PEP 697.

No behavior change or removal is proposed at this time.

CC

@ZeroIntensity
@vstinner
@StanFromIreland

Has this already been discussed elsewhere?

This has been discussed in one of the closed pr #141522

Links to previous discussion of this feature:

#141522

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions