advanced patterns when using context managers with custom classes in Python 3.10
I'm working with an scenario when implementing a context manager in my custom class. The expectation is that the resource should be properly managed, but I'm seeing some unexpected behavior. Here's my implementation for the context manager: ```python class MyResource: def __enter__(self): print('Acquiring resource') return self def __exit__(self, exc_type, exc_val, exc_tb): print('Releasing resource') return True # Suppressing exceptions for testing # Usage with MyResource() as resource: print('Using resource') raise ValueError('An behavior occurred') # This should be suppressed ``` I expected that the `ValueError` would be suppressed because I return `True` in `__exit__`, but I still see the traceback. When I change the return value in `__exit__` to `False`, I get the expected behavior where it propagates the exception. I've also tried logging the exception details inside the `__exit__` method to see what's happening: ```python def __exit__(self, exc_type, exc_val, exc_tb): print(f'Exception type: {exc_type}') print(f'Exception value: {exc_val}') print(f'Traceback: {exc_tb}') return True ``` This logs the exception, but it still appears to propagate. I've confirmed that Iām using Python 3.10 by running `python --version`. Is there a subtlety in how context managers work that I'm missing? What could be causing this scenario?