Xqt created this task.
Xqt added projects: Pywikibot, Pywikibot-tests.
Restricted Application added subscribers: pywikibot-bugs-list, Aklapper.
TASK DESCRIPTION
**Steps to replicate the issue** (include links if applicable):
>>> from pywikibot import Timestamp
>>> ts = Timestamp.now()
>>> ts
**What happens?**:
`Timestamp(2022, 12, 24, 10, 49, 6, 958707)` is given for CPython but
pywikibot.time.Timestamp(2022, 12, 24, 10, 49, 6, 958707) for Pypy.
https://github.com/wikimedia/pywikibot/actions/runs/3768283603/jobs/6406590317
Timestamp inherits from datetime.datetime. The __repr__ of datetime is
definded as:
def __repr__(self):
"""Convert to formal string, for repr()."""
L = [self._year, self._month, self._day, # These are never zero
self._hour, self._minute, self._second, self._microsecond]
if L[-1] == 0:
del L[-1]
if L[-1] == 0:
del L[-1]
s = "%s.%s(%s)" % (self.__class__.__module__,
self.__class__.__qualname__,
", ".join(map(str, L)))
if self._tzinfo is not None:
assert s[-1:] == ")"
s = s[:-1] + ", tzinfo=%r" % self._tzinfo + ")"
if self._fold:
assert s[-1:] == ")"
s = s[:-1] + ", fold=1)"
return s
but obviously only pypy takes this into account. Neither datetime.__repr__
nor Timestamp.__repr__ calls it because the datetime implementation is
overridden by _datetime:
try:
from _datetime import *
except ImportError:
pass
I guess this is a C-implementation.
**What should have happened instead?**:
The result should be unique.
**Software version** (skip for WMF-hosted wikis like Wikipedia):
Tested with CPython 3.6-3.12 and Pypy 3.7
TASK DETAIL
https://phabricator.wikimedia.org/T325905
EMAIL PREFERENCES
https://phabricator.wikimedia.org/settings/panel/emailpreferences/
To: Xqt
Cc: Aklapper, pywikibot-bugs-list, Xqt, PotsdamLamb, Jyoo1011, JohnsonLee01,
SHEKH, Dijkstra, Khutuck, Zkhalido, Viztor, Wenyi, Tbscho, MayS, Mdupont,
JJMC89, Dvorapa, Altostratus, Avicennasis, mys_721tx, jayvdb, Masti, Alchimista
_______________________________________________
pywikibot-bugs mailing list -- [email protected]
To unsubscribe send an email to [email protected]