diff --git a/.gitignore b/.gitignore index 97dd01c18445..8191bc39e393 100644 --- a/.gitignore +++ b/.gitignore @@ -14,6 +14,7 @@ .pydevproject *.swp .idea +.vscode/ # Compiled source # ################### diff --git a/lib/matplotlib/dates.py b/lib/matplotlib/dates.py index bd27bef3759a..3dff61acfde8 100644 --- a/lib/matplotlib/dates.py +++ b/lib/matplotlib/dates.py @@ -840,12 +840,12 @@ def tick_values(self, vmin, vmax): # We need to cap at the endpoints of valid datetime try: start = vmin - delta - except ValueError: + except (ValueError, OverflowError): start = _from_ordinalf(1.0) try: stop = vmax + delta - except ValueError: + except (ValueError, OverflowError): # The magic number! stop = _from_ordinalf(3652059.9999999) diff --git a/lib/matplotlib/tests/test_dates.py b/lib/matplotlib/tests/test_dates.py index 5a25e6182b7e..9f69d2ea7639 100644 --- a/lib/matplotlib/tests/test_dates.py +++ b/lib/matplotlib/tests/test_dates.py @@ -128,6 +128,14 @@ def test_RRuleLocator(): fig.autofmt_xdate() +def test_RRuleLocator_dayrange(): + loc = mdates.DayLocator() + x1 = datetime.datetime(year=1, month=1, day=1, tzinfo=pytz.UTC) + y1 = datetime.datetime(year=1, month=1, day=16, tzinfo=pytz.UTC) + loc.tick_values(x1, y1) + # On success, no overflow error shall be thrown + + @image_comparison(baseline_images=['DateFormatter_fractionalSeconds'], extensions=['png']) def test_DateFormatter():