pandas
pandas copied to clipboard
Fix evaluations on Python 3.12
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)
- [x] Tests added and passed if fixing a bug or adding a new feature
- [x] 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.
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)
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.