Skip to content

Commit 4bc096c

Browse files
committed
Fix local_timezone on Windows for Python 2.7
1 parent deb9ede commit 4bc096c

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

pendulum/tz/local_timezone.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,14 @@
22
import os
33
import re
44

5+
try:
6+
import _winreg as winreg
7+
except ImportError:
8+
try:
9+
import winreg
10+
except ImportError:
11+
winreg = None
12+
513
from contextlib import contextmanager
614
from typing import Union
715

@@ -51,8 +59,6 @@ def _get_system_timezone(): # type: () -> Timezone
5159

5260

5361
def _get_windows_timezone(): # type: () -> Timezone
54-
import winreg
55-
5662
from .data.windows import windows_timezones
5763

5864
# Windows is special. It has unique time zone names (in several

0 commit comments

Comments
 (0)