Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

addVariable doesn't properly support Domain subclasses #50

Closed
WillDHB opened this issue Apr 8, 2019 · 3 comments
Closed

addVariable doesn't properly support Domain subclasses #50

WillDHB opened this issue Apr 8, 2019 · 3 comments

Comments

@WillDHB
Copy link
Contributor

WillDHB commented Apr 8, 2019

It seems like addVariable is intended to support using a subclass of Domain as a domain. However, this logic:

if hasattr(domain, "__getitem__"):
    domain = Domain(domain)
elif isinstance(domain, Domain):
    domain = copy.copy(domain)

will always convert to a Domain, since Domain objects implement __getitem__. It would appear that replacing it with this code would fix it:

if isinstance(domain, Domain):
    domain = copy.copy(domain)
elif hasattr(domain, "__getitem__"):
    domain = Domain(domain)
@scls19fr
Copy link
Member

scls19fr commented Apr 9, 2019

Hi @WillDHB

PR with tests are always welcome

Kind regards

WillDHB added a commit to WillDHB/python-constraint that referenced this issue Apr 10, 2019
@WillDHB
Copy link
Contributor Author

WillDHB commented Apr 10, 2019

Done. Sorry the code in the bug report was mangled; I didn't notice until just now.

@scls19fr
Copy link
Member

To avoid code to be mangled, you just need triple backtick (see my edit)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants