8000 FIX: add check for py3.5 to fail if naive datetime · matplotlib/matplotlib@dadeae6 · GitHub
[go: up one dir, main page]

Skip to content

Commit dadeae6

Browse files
committed
FIX: add check for py3.5 to fail if naive datetime
1 parent bd44dc9 commit dadeae6

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

lib/matplotlib/dates.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1411,7 +1411,14 @@ def tick_values(self, vmin, vmax):
14111411
ymin = self.base.le(vmin.year) * self.base.step
14121412
ymax = self.base.ge(vmax.year) * self.base.step
14131413

1414-
ticks = [vmin.replace(year=ymin, **self.replaced).astimezone(self.tz)]
1414+
vmin = vmin.replace(year=ymin, **self.replaced)
1415+
try:
1416+
ticks = [vmin.astimezone(self.tz)]
1417+
except ValueError:
1418+
raise ValueError('naive datetime objects cannot be used '
1419+
'with matplotlib for python < 3.6; '
1420+
'astimezone() cannot '
1421+
'be applied to a naive datetime.')
14151422
while True:
14161423
dt = ticks[-1]
14171424
if dt.year >= ymax:

0 commit comments

Comments
 (0)
0