You have been subscribed to a public bug:
On my system, /etc/timezone is 2 lines, one comment, then a timezone
definition:
# Ansible managed:
/nfs/users/nfs_p/pj2/Documents/Ansible/2.4.6/roles/core/sanger.localisation/templates/ubu_timezone_file.j2
modified on 2018-09-24 17:30:26 by pj2 on deskpro22189
Europe/London
pytz's _get_localzone code doesn't parse this correctly, resulting in
pytz.exceptions.UnknownTimeZoneError: ''
this is because the code first splits on the first space, and then
splits the result on the # character (resulting in an empty string); I
demonstrate it here by copying the logic from unix.py ll56 et seq:
>>> with open("/etc/timezone", "rb") as tzfile:
... data = tzfile.read()
... etctz = data.strip().decode()
... print("'%s'" % etctz)
... if ' ' in etctz:
... a = etctz.split(' ', 1)
... print(a)
... if '#' in a[0]:
... b=a[0].split('#', 1)
... print(b)
...
'# Ansible managed:
/nfs/users/nfs_p/pj2/Documents/Ansible/2.4.6/roles/core/sanger.localisation/templates/ubu_timezone_file.j2
modified on 2018-09-24 17:30:26 by pj2 on deskpro22189
Europe/London'
['#', 'Ansible managed:
/nfs/users/nfs_p/pj2/Documents/Ansible/2.4.6/roles/core/sanger.localisation/templates/ubu_timezone_file.j2
modified on 2018-09-24 17:30:26 by pj2 on deskpro22189\nEurope/London']
['', '']
I think it would be better to do a line-by-line read of the file, and
discard comment lines (i.e. where first character is #)?
** Affects: python-tzlocal (Ubuntu)
Importance: Undecided
Status: New
--
/etc/timezone parsing doesn't deal with comments properly
https://bugs.launchpad.net/bugs/1797857
You received this bug notification because you are a member of Ubuntu Bugs,
which is subscribed to Ubuntu.
--
ubuntu-bugs mailing list
[email protected]
https://lists.ubuntu.com/mailman/listinfo/ubuntu-bugs