regebro / tzlocal

A Python module that tries to figure out what your local timezone is
MIT License
184 stars 58 forks source link

Added clause to not read from /etc/timezone if the file exists but is empty #57

Closed ZackaryWelch closed 6 years ago

ZackaryWelch commented 6 years ago

When creating a port on FreeBSD, I noticed a port using tzlocal would not run because the timezone reported was ' '. Apparently on some FreeBSD systems /etc/timezone exists but is empty, so tzlocal would open the file but return an invalid time zone, causing the program to crash. I added a clause in the if statement that checked if the file is empty in addition to existing, which fixed the crash.

regebro commented 6 years ago

Thanks! I added code that handles if the file is empty, although in a different way.