Skip to content

Commit 8792507

Browse files
committed
Default to UTC if not local timezone can be found
Fixes #715
1 parent 9590c65 commit 8792507

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

pendulum/tz/local_timezone.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,14 @@
44
import os
55
import re
66
import sys
7+
import warnings
78

89
from contextlib import contextmanager
910
from typing import Iterator
1011
from typing import cast
1112

1213
from pendulum.tz.exceptions import InvalidTimezone
14+
from pendulum.tz.timezone import UTC
1315
from pendulum.tz.timezone import FixedTimezone
1416
from pendulum.tz.timezone import Timezone
1517

@@ -239,7 +241,11 @@ def _get_unix_timezone(_root: str = "/") -> Timezone:
239241
with open(tzpath, "rb") as f:
240242
return Timezone.from_file(f)
241243

242-
raise RuntimeError("Unable to find any timezone configuration")
244+
warnings.warn(
245+
"Unable not find any timezone configuration, defaulting to UTC.", stacklevel=1
246+
)
247+
248+
return UTC
243249

244250

245251
def _tz_from_env(tzenv: str) -> Timezone:

0 commit comments

Comments
 (0)