Repository navigation
Conversation
`rrulestr` resolves the `TZID` parameter of `DTSTART`, `RDATE` and `EXDATE` with `tz.gettz` when no `tzids` argument is given. `gettz` also accepts file names: an absolute path is opened directly, and a relative key like `"../../etc/localtime"` was deprecated for this reason, but absolute paths were left as they are. A `TZID` in a rule string is an identifier like `"America/New_York"`, and rule strings often come from calendar data the application did not write, so `DTSTART;TZID=/etc/localtime:...` parsed with the host's local zone attached, `TZID=/etc/passwd` raised `ValueError` while a path that does not exist parsed as a naive datetime, and `TZID=../../etc/localtime` raised `DeprecatedTzKeyWarning` out of the parser. The default lookup now treats an absolute path, or a key that leaves `TZPATH`, as a zone that is not found, so the result is naive, as it is for any other unknown `TZID`. Callers that pass their own `tzids` are not affected, and neither is `gettz` itself.
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary of changes
rrulestrresolves theTZIDparameter ofDTSTART,RDATEandEXDATEwithtz.gettzwhen notzidsargument is given.gettzalso accepts file names: an absolute path is opened directly, and a relative key such as../../etc/localtimewas deprecated in #1130 because it loads a file from anywhere on the file system, but absolute paths were left as they are. ATZIDin a rule string is an identifier likeAmerica/New_York, and rule strings often come from calendar data the application did not write, so the input decides which file the library opens:DTSTART;TZID=/etc/localtime:20200101T000000parses with the host's local zone attached,TZID=/etc/passwdraisesValueError: Invalid TZif file: magic not foundwhileTZID=/etc/does-not-existparses as a naive datetime, which tells the caller whether a file exists, andTZID=../../etc/localtimeraisesDeprecatedTzKeyWarningout of the parser. The default lookup now goes through a small helper that treats an absolute path, or a key that leavesTZPATH, as a zone that is not found, so the datetime is naive, as it is for any other unknownTZID. Callers that pass their owntzidsmapping or callable are not affected, and neither isgettzitself. The new tests fail on master and pass with this change; the full suite and darker are green locally, apart fromtest_dst_matches_tzdata_zi[tzpath], which already fails against this machine's system tzdata on master. The changelog fragment is an orphan fragment (+rrulestr-tzid-path.bugfix.rst) because the PR number was not known when the branch was made; I can rename it to the PR number if you prefer.Pull Request Checklist