New submission from Jean Carlo Machado :
datetime.utcnow() already present a warning box describing the risk of using it
without specifying timezone information. However, one might still have the same
problem and never encounter this warning information by doing
datetime.now().isoformat(). Or just by not reading the docs of datetime.utcnow,
just the datetime.isoformat docs.
By adding a similar warning to the datetime.isoformat() we could make the risk
clearer and reduce the likelihood of errors. Is when calling isoformat() where
people get confident to be producing ISO's.
I just recently had an incident in my company where we produced naive datetimes
using datetime.now() and serialized them using isoformat() while expecting them
to be a transferrable ISO format. Nevertheless, the other system read the dates
without Z in the end and interpreted it as local time.
If you agree that this suggestion could be a good improvement to the docs, I
can send a patch in the next 2 weeks.
--
assignee: docs@python
components: Documentation
messages: 411046
nosy: docs@python, jeanCarloMachado
priority: normal
severity: normal
status: open
title: datetime.isoformat() documentation does not point to the risk of using
it with naive datetime objects
type: enhancement
versions: Python 3.11
___
Python tracker
<https://bugs.python.org/issue46447>
___
___
Python-bugs-list mailing list
Unsubscribe:
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com