New PG Range.__eq__() should not raise an exception comparing with a non-Range value
See original GitHub issueDescribe the bug
As written, the method Range.eq() declares its argument as other: Any
, but it really expects another instance of the same class, otherwise it raises an exception.
To Reproduce
>>> from sqlalchemy.dialects.postgresql import Range
>>> r = Range(1,10)
>>> r == None
Error
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/lele/wip/sqlalchemy/lib/sqlalchemy/dialects/postgresql/ranges.py", line 294, in __eq__
elif self.empty != other.empty:
AttributeError: 'NoneType' object has no attribute 'empty'
Versions
- OS: any
- Python: any
- SQLAlchemy: 2.0.0b4+
- Database: irrilevant
- DBAPI (eg: psycopg, cx_oracle, mysqlclient): irrilevant
Additional context
@CaselIT suggested to return NotImplemented
, that seems the right thing to do accordingly to the documentation.
Issue Analytics
- State:
- Created 9 months ago
- Comments:8 (5 by maintainers)
Top Results From Across the Web
Pitfalls to having __eq__ raise an exception? - python
I have a type where equality comparison doesn't make sense. Explicitly comparing two instances of this type for either reference or value ......
Read more >7.3. Other Comparison Operators
A binary comparison operator compares two variables or quantities. Note that integer and string comparison use a different set of operators. integer comparison....
Read more >Oracle® Fusion Applications Workforce Development ...
User Guides address the tasks in one or more business processes. They are intended for users who perform these tasks, and managers looking...
Read more >Diff - 5442ff6bad80f910f84ddf265393796d5fa9d977^2 ... - Google Git
It avoids + // trying to do future verification optimizations when processing the vdex file. + DCHECK(failure_kind == verifier::MethodVerifier::kSoftFailure || ...
Read more >FICO Xpress Optimizer Python interface Reference Manual
Installing the Xpress Python interface does not require ... The Xpress Python interface raises its own exceptions in the event of a modeling,...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
no sorry, my mistake. This issue is not closed because it’s missing the “closes / fixes #issue-id” .
The commit message is
it should be
No problem!