enthought / enthought/traits

Unexpected supports_protocol behavior

Open
#591 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
Python
Stars
462
Forks
90
PR merge metrics
No merged PRs in 30d

Description

We use `supports_protocol` to check if objects being handled can be adapted to a specific protocol and use the information appropriately.

Trying to adapt an object to a specific protocol can result in three behaviors

- the object is adaptatable, in which case `supports_protocol` returns `True`
- the object is unadaptable because no appropriate adapters are registered with the adaptation machinery, in which case `supports_protocol` returns `False`
- the object is unadaptable because an `AdaptationError` occurs during adaptation.
- the object is unadaptable because other `Exception`s occur during adaptation.

At the moment, the `AdaptationError`s are not handled by `supports_protocol`, which we believe they should. The adapters registered could be explicitly raising `AdaptationError`s - which should be caught by `supports_protocol`, which would then return `False`.

https://github.com/enthought/traits/blob/5dddc966b8f87e5550e83c98e14b4a251b33b561/traits/adaptation/adaptation_manager.py#L183-L191

Contributor guide

No contributing guide indexed for this repository

Research direction

Start in traits/adaptation/adaptation_manager.py at lines 183-191, linked from the issue, and trace how supports_protocol handles adaptation failures. Verify the behavior for adapters that raise AdaptationError, and consider the existing adaptation-related tests when checking the result. Done means those cases return False without changing the handling of other exceptions.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
backend
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
52/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.