Skip to content

Commit

Permalink
- try a different solution
Browse files Browse the repository at this point in the history
  • Loading branch information
dataflake committed May 15, 2024
1 parent adab2bd commit 753daca
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 14 deletions.
3 changes: 0 additions & 3 deletions src/zope/interface/_compat.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,7 @@ def _normalize_name(name):
return name
raise TypeError("name must be a string or ASCII-only bytes")


PYPY = hasattr(sys, 'pypy_version_info')
_version = sys.version_info
IS_PY313_OR_GREATER = _version.major == 3 and _version.minor >= 13


def _c_optimizations_required():
Expand Down
14 changes: 3 additions & 11 deletions src/zope/interface/tests/test_advice.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,21 +51,13 @@ def test_w_class(self):
self.assertTrue(d is advisory_testing.my_globals)

def test_inside_function_call(self):
from zope.interface._compat import IS_PY313_OR_GREATER
from zope.interface.advice import getFrameInfo
kind, module, f_locals, f_globals = getFrameInfo(sys._getframe())
self.assertEqual(kind, "function call")

if IS_PY313_OR_GREATER:
# Python 3.13b1 implements PEP 667, which changes the type of
# ``f_locals`` from a mapping to a ``FrameLocalsProxy`` object
# while the return value of ``locals()`` is still a mapping, so
# they no longer point to the same object.
# See https://peps.python.org/pep-0667 and
# https://github.com/python/cpython/pull/115153
self.assertDictEqual(dict(f_locals), locals())
else:
self.assertTrue(f_locals is locals()) # ???
frame = sys._getframe()
self.assertEqual(f_locals, frame.f_locals)
self.assertEqual(f_locals, locals())

for d in module.__dict__, f_globals:
self.assertTrue(d is globals())
Expand Down

0 comments on commit 753daca

Please sign in to comment.