Opened 5 years ago
Closed 4 years ago
Last modified 4 years ago
#13622 closed Bug Report - General (fixed)
Python Bindings: traceback in datetime.timestamp()
Reported by: | rcrdnalor | Owned by: | rcrdnalor |
---|---|---|---|
Priority: | minor | Milestone: | 31.1 |
Component: | Bindings - Python | Version: | v31-fixes |
Severity: | medium | Keywords: | Python timestamp |
Cc: | Ticket locked: | no |
Description
Using Python3.6, the following sequence works:
$ python3 Python 3.6.9 (default, Apr 18 2020, 01:56:04) [GCC 8.4.0] on linux Type "help", "copyright", "credits" or "license" for more information. >>> from MythTV import datetime >>> t = datetime.now() >>> t.timestamp() 1590160731.214045
In contrast, on Python3.8, this gives an error:
$ python3 Python 3.8.2 (default, Apr 27 2020, 15:53:34) [GCC 9.3.0] on linux Type "help", "copyright", "credits" or "license" for more information. >>> from MythTV import datetime >>> t = datetime.now() >>> t.timestamp() Traceback (most recent call last): File "<stdin>", line 1, in <module> File "/home/local-admin/MythTV/mythservices/MythTV/utility/dt.py", line 483, in timestamp return ((utc_naive - utc_epoch).total_seconds()) TypeError: can't subtract offset-naive and offset-aware datetimes
Error reported on the MythTV forum: https://forum.mythtv.org/viewtopic.php?f=6&t=3793
Change History (4)
Note: See
TracTickets for help on using
tickets.
From the Python docs: https://docs.python.org/3/whatsnew/3.8.html
Arithmetic operations between subclasses of datetime.date or datetime.datetime and datetime.timedelta objects now return an instance of the subclass, rather than the base class. This also affects the return type of operations whose implementation (directly or indirectly) uses datetime.timedelta arithmetic, such as astimezone(). (Contributed by Paul Ganssle in bpo-32417.)
Complete review of MythTV's datetime implementation needed.