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

py3: minor fix to sage.categories.additive_magmas #24294

Closed
embray opened this issue Nov 28, 2017 · 5 comments
Closed

py3: minor fix to sage.categories.additive_magmas #24294

embray opened this issue Nov 28, 2017 · 5 comments

Comments

@embray
Copy link
Contributor

embray commented Nov 28, 2017

Replace __nonzero__ with __bool__ for Python 3.

On Python 2 alias __bool__ back to __nonzero__ and delete __bool__.
This allows SageObject._test_not_implemented_methods to pass on Python 2 and 3 for classes that implement this abstract interface.

This could just as easily be done the other way around and I'm not overly particular about it--I just prefer __bool__ for its clearer name.

Component: python3

Author: Erik Bray

Branch/Commit: c84bbe1

Reviewer: Jeroen Demeyer

Issue created by migration from https://trac.sagemath.org/ticket/24294

@embray embray added this to the sage-8.1 milestone Nov 28, 2017
@jdemeyer
Copy link

comment:2

Is there anything wrong with just doing

__nonzero__ = __bool__

unconditionally (as we do in many places in Sage)?

What you are doing here seems like needless complexity...

@embray
Copy link
Contributor Author

embray commented Nov 28, 2017

comment:3

Yes, in this specific case. Again it has to do with the SageObject._test_not_implemented_methods. It loops over an object's dir() and in this case may find a __nonzero__ that's not implemented.

@jdemeyer
Copy link

comment:4

OK, let it be.

@jdemeyer
Copy link

Reviewer: Jeroen Demeyer

@vbraun
Copy link
Member

vbraun commented Dec 16, 2017

Changed branch from u/embray/python3/additive-magmas-bool to c84bbe1

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

No branches or pull requests

3 participants