zopefoundation / DateTime

This package provides a DateTime data type, as known from Zope. Unless you need to communicate with Zope APIs, you're probably better off using Python's built-in datetime module.
Other
19 stars 25 forks source link

`DateTime.DateTime.equalTo` now breaks with string argument #60

Closed perrinjerome closed 9 months ago

perrinjerome commented 9 months ago

BUG/PROBLEM REPORT / FEATURE REQUEST

Since DateTime 5.2, using DateTime.DateTime.equalTo with something else than a DateTime or a number throws AttributeError. This is a regression from https://github.com/zopefoundation/DateTime/pull/54 ( cc @fdiary )

What I did:

>>> import DateTime
>>> DateTime.DateTime() == ""
False
>>> DateTime.DateTime().equalTo("")
Traceback (most recent call last):
  File "<console>", line 1, in <module>
  File "./DateTime/src/DateTime/DateTime.py", line 1295, in equalTo
    return self._micros == t._micros
AttributeError: 'str' object has no attribute '_micros'

What I expect to happen:

DateTime.DateTime().equalTo("") should be False

What actually happened:

AttributeError: 'str' object has no attribute '_micros'

What version of Python and Zope/Addons I am using:

This is current master branch 955f3b920b2020c2407e7d9f4aa24e6ef7d20d9d