folly icon indicating copy to clipboard operation
folly copied to clipboard

Fix: Replace _Py_IsFinalizing with Py_IsFinalizing for Python 3.13 compatibility and added version hex

Open Ko496-glitch opened this issue 1 year ago • 8 comments

Summary

  • Addressed issue #2358 by replacing the deprecated _Py_IsFinalizing with the public API Py_IsFinalizing, introduced in Python 3.13.
  • Added version gating using PY_VERSION_HEX to ensure compatibility with older Python versions.

Changes:

  • Updated AsyncioExecutor.h:
    • Replaced _Py_IsFinalizing with Py_IsFinalizing.
    • Added a macro to alias _Py_IsFinalizing for Python versions before 3.13.

Reference:

  • Related issue: #2358

Ko496-glitch avatar Jan 09 '25 04:01 Ko496-glitch

Hi @Ko496-glitch!

Thank you for your pull request and welcome to our community.

Action Required

In order to merge any pull request (code, docs, etc.), we require contributors to sign our Contributor License Agreement, and we don't seem to have one on file for you.

Process

In order for us to review and merge your suggested changes, please sign at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need to sign the corporate CLA.

Once the CLA is signed, our tooling will perform checks and validations. Afterwards, the pull request will be tagged with CLA signed. The tagging process may take up to 1 hour after signing. Please give it that time before contacting us about it.

If you have received this in error or have any questions, please contact us at [email protected]. Thanks!

facebook-github-bot avatar Jan 09 '25 04:01 facebook-github-bot

Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Meta Open Source project. Thanks!

facebook-github-bot avatar Jan 09 '25 04:01 facebook-github-bot

@Ko496-glitch I noticed you working in this area and wanted to draw your attention to this PR #2361 I would be interested in how you are building and encountered the python 3.13 issue and any review comments on the PR. That PR also handles the issue Issue #2358

gmarzot avatar Jan 09 '25 16:01 gmarzot

@gmarzot for this issue i just went through the python directory in the codebase and checked for the most relevant file, good amount of info was already presented as this issue was also handled back in june in pr #42034. The change also seems good to the issuer. let me know if you want any other info on this PR.

Ko496-glitch avatar Jan 09 '25 16:01 Ko496-glitch

@gmarzot Hi just checking in to see if everything is good for this PR?

Ko496-glitch avatar Jan 12 '25 03:01 Ko496-glitch

@gmarzot Hi just checking in to see if everything is good for this PR?

I think something like this below is clearer and more direct:

 private:
  static bool isPyFinalizing() noexcept {
#if PY_VERSION_HEX <= 0x03070000     // unsupported anyway - can remove
    return false;
#elif PY_VERSION_HEX >= 0x030D0000  // Python 3.13+
    return Py_IsFinalizing();
#else
    return _Py_IsFinalizing();
#endif
  }

I think the PR I have here includes this solution and addresses a number of other issues getting the python bindings working so I would recommend that PR to the maintainers

gmarzot avatar Jan 12 '25 16:01 gmarzot

@Orvid has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator.

facebook-github-bot avatar Jan 13 '25 20:01 facebook-github-bot

A quick fix for that is to use -D_Py_IsFinalizing=Py_IsFinalizing in case of sys.version_info >= (3, 13).

novitae avatar Feb 20 '25 16:02 novitae