Opened 11 years ago
Closed 11 years ago
#23664 closed Bug (fixed)
bool evaluation on an OrderedSet gives different results in Py2 and Py3
| Reported by: | Thomas C | Owned by: | nobody |
|---|---|---|---|
| Component: | Utilities | Version: | dev |
| Severity: | Normal | Keywords: | Python3, OrderedSet |
| Cc: | Triage Stage: | Ready for checkin | |
| Has patch: | yes | Needs documentation: | no |
| Needs tests: | no | Patch needs improvement: | no |
| Easy pickings: | no | UI/UX: | no |
Description
bool(OrderedSet()) evaluates to False in Python 2, True in Python 3 because __bool__ is not defined (but __nonzero__ is).
I searched the codebase for similar cases and found that it was the same with QuerySet, though this does not have consequences as QuerySet.__len__ is defined and bool will use that in Py3.
The PR addresses both classes for consistency.
Change History (2)
comment:1 by , 11 years ago
| Triage Stage: | Unreviewed → Ready for checkin |
|---|
comment:2 by , 11 years ago
| Resolution: | → fixed |
|---|---|
| Status: | new → closed |
Note:
See TracTickets
for help on using tickets.
The PR (https://github.com/django/django/pull/3380/files) looks good to me.
Let's see what the CI server has to say about it.