Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix evaluations on Python 3.12 #57391

Closed
wants to merge 4 commits into from
Closed

Conversation

QuLogic
Copy link
Contributor

@QuLogic QuLogic commented Feb 13, 2024

List comprehensions no longer get their own scope [1], so adding a level to the (eventual) call to sys._getframe goes outside the actual caller. If running in pytest (so that there is a scope outside the caller), you end up looking in some unrelated scope. If you are running a script, then sys._getframe raises an error that the level is out of bounds.

The Bitwise operations warning in test_scalar_unary appears to always be raised, so remove the condition.

[1] https://docs.python.org/3.12/whatsnew/3.12.html#whatsnew312-pep709

I'm not entirely sure why neither issue is seen on CI, but there are so many tests/workflows, I'm also not sure which one to check. I guess I'll see how this goes in this PR.

  • [n/a] closes #xxxx (Replace xxxx with the GitHub issue number)
  • Tests added and passed if fixing a bug or adding a new feature
  • All code checks passed.
  • [n/a] Added type annotations to new arguments/methods/functions.
  • Added an entry in the latest doc/source/whatsnew/vX.X.X.rst file if fixing a bug or adding a new feature.

List comprehensions no longer get their own scope [1], so adding a level
to the (eventual) call to `sys._getframe` goes outside the actual
caller. If running in `pytest` (so that there is a scope outside the
caller), you end up looking in some unrelated scope. If you are running
a script, then `sys._getframe` raises an error that the level is out of
bounds.

The `Bitwise operations` warning in `test_scalar_unary` appears to
always be raised, so remove the condition.

[1] https://docs.python.org/3.12/whatsnew/3.12.html#whatsnew312-pep709
@QuLogic
Copy link
Contributor Author

QuLogic commented Feb 13, 2024

OK, so tests on CI are failing with the change to the warning condition. However, if you check the logs for main, it seems like the warning is raised, but from a weird spot that isn't caught:

/home/runner/micromamba/envs/test/lib/python3.12/site-packages/coverage/parser.py:402: DeprecationWarning: Bitwise inversion '~' on bool is deprecated. This returns the bitwise inversion of the underlying int object and is usually not what you expect from negating a bool. Use the 'not' operator for boolean negation or ~int(x) if you really want the bitwise inversion of the underlying int.
  self.code = compile(text, filename, "exec", dont_inherit=True)

@simonjayhawkins simonjayhawkins added Testing pandas testing functions or related to the test suite Python 3.12 labels Feb 13, 2024
Copy link
Contributor

This pull request is stale because it has been open for thirty days with no activity. Please update and respond to this comment if you're still interested in working on this.

@github-actions github-actions bot added the Stale label Mar 15, 2024
@mroeschke
Copy link
Member

Thanks for the pull request, but it appears to have gone stale. If interested in continuing, please merge in the main branch, address any review comments and/or failing tests, and we can reopen.

@mroeschke mroeschke closed this Aug 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Python 3.12 Stale Testing pandas testing functions or related to the test suite
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants