Skip to content

Commit ac0097f

Browse files
Fix a typo in the denominator attribute name in _pydatetime
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
1 parent d65baa9 commit ac0097f

2 files changed

Lines changed: 26 additions & 1 deletion

File tree

‎Lib/_pydatetime.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1801,7 +1801,7 @@ def _fromtimestamp(cls, t, utc, tz):
18011801
n, d = t.as_integer_ratio()
18021802
except AttributeError:
18031803
n = t.numerator
1804-
d = t.denumerator
1804+
d = t.denominator
18051805
except AttributeError:
18061806
frac, t = _math.modf(t)
18071807
us = round(frac * 1e6)

‎Lib/test/datetimetester.py‎

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3097,6 +3097,31 @@ def utcfromtimestamp(*args, **kwargs):
30973097
self.assertEqual(t.second, 1)
30983098
self.assertEqual(t.microsecond, 0)
30993099

3100+
@support.run_with_tz('MSK-03') # Something east of Greenwich
3101+
def test_microsecond_rounding_ratio(self):
3102+
# A number which only has the numerator and denominator attributes.
3103+
class Ratio:
3104+
def __init__(self, fraction):
3105+
self.numerator = fraction.numerator
3106+
self.denominator = fraction.denominator
3107+
3108+
F = fractions.Fraction
3109+
fts = self.theclass.fromtimestamp
3110+
for value in [
3111+
F(0), F(1, 1_000_000), F(-1, 1_000_000),
3112+
F(5, 10_000_000), F(-5, 10_000_000), F(15, 10_000_000),
3113+
2_147_475_000 + F(5, 10_000_000),
3114+
2_147_475_000 +
3115+
F( 5_000_000_000_000_000_000_000_000_000_000_000,
3116+
9_999_999_999_999_999_999_999_999_999_999_999_999_999),
3117+
2_147_475_000 +
3118+
F( 9_999_995_000_000_000_000_000_000_000_000_000_000_000,
3119+
10_000_000_000_000_000_000_000_000_000_000_000_000_001),
3120+
2_147_475_000 + F(9_999_995, 10_000_000),
3121+
]:
3122+
with self.subTest(value=value):
3123+
self.assertEqual(fts(Ratio(value)), fts(value))
3124+
31003125
def test_timestamp_limits(self):
31013126
with self.subTest("minimum UTC"):
31023127
min_dt = self.theclass.min.replace(tzinfo=timezone.utc)

0 commit comments

Comments
 (0)