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](https://pandas.pydata.org/pandas-docs/dev/development/contributing_codebase.html#writing-tests) if fixing a bug or adding a new feature
- [x] All [code checks passed](https://pandas.pydata.org/pandas-docs/dev/development/contributing_codebase.html#pre-commit).
- [n/a] Added [type annotations](https://pandas.pydata.org/pandas-docs/dev/development/contributing_codebase.html#type-hints) 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`](https://github.com/pandas-dev/pandas/actions/runs/7880360042/job/21502267281#step:8:51), 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](https://pandas.pydata.org/pandas-docs/stable/development/contributing.html#updating-your-pull-request) and respond to this comment if you're still interested in working on this. 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.