You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Here's a way to reproduce after installing TensorFlow 2.12.0
fromtensorflow.python.trackableimportdata_structuresfromtensorflow.python.typesimporttracestandard_dict= {'foo': 'bar'}
wrapped_dict=data_structures._DictWrapper(standard_dict)
# Prints Falseprint(isinstance(standard_dict, trace.SupportsTracingProtocol))
# The following line throws "TypeError: this __dict__ descriptor does not support '_DictWrapper' objects"print(isinstance(wrapped_dict, trace.SupportsTracingProtocol))
i.e, running the above spits out the following:
Traceback (most recent call last):
File "test.py", line 8, in <module>
print(isinstance(wrapped_dict, trace.SupportsTracingProtocol))
File "/home/xxx/src/.venv/lib/python3.8/site-packages/typing_extensions.py", line 605, in __instancecheck__
val = inspect.getattr_static(instance, attr)
File "/usr/lib/python3.8/inspect.py", line 1596, in getattr_static
instance_result = _check_instance(obj, attr)
File "/usr/lib/python3.8/inspect.py", line 1543, in _check_instance
instance_dict = object.__getattribute__(obj, "__dict__")
TypeError: this __dict__ descriptor does not support '_DictWrapper' objects
The text was updated successfully, but these errors were encountered:
Looks to me like it's probably an issue with wrapt rather than typing_extensions or TensorFlow, actually. We discussed this a bit in python/cpython#105134.
Wrapt raises TypeError if you do object.__getattribute__(<some_wrapt_ObjectProxy_instance, '__dict__'). I know of no way to construct a class using pure Python that has this behaviour (wrapt achieves this behaviour by using a C extension), and it breaks some fundamental assumptions that the stdlib function inspect.getattr_static makes. That, in turn, breaks typing_extensions.
It's possible TensorFlow is doing something wrong or typing_extensions is at fault 🤷🏽
dfe4889 appears to be the culprit.
Here's a way to reproduce after installing TensorFlow 2.12.0
i.e, running the above spits out the following:
The text was updated successfully, but these errors were encountered: