Open
Conversation
htgoebel
suggested changes
Jan 2, 2025
| Given a tzinfo class, use known APIs to determine TZID, or use tzname. | ||
| """ | ||
| if str(tzinfo) == 'UTC': | ||
| return None |
There was a problem hiding this comment.
I suggest merging this clause into the next which has a comment about UTC.
Author
There was a problem hiding this comment.
I tested a merger of this with the following line, as you suggested. I guess an error from the test suite in branch-0.9:
======================================================================
ERROR: test_pytz_timezone_serializing (__main__.TestIcalendar)
Serializing with timezones from pytz test
----------------------------------------------------------------------
Traceback (most recent call last):
File "tests.py", line 727, in test_pytz_timezone_serializing
tz.serialize()
File "/Users/d/work/personal/vobject-tmp/vobject/base.py", line 258, in serialize
return behavior.serialize(self, buf, lineLength, validate, *args, **kwargs)
File "/Users/d/work/personal/vobject-tmp/vobject/behavior.py", line 157, in serialize
cls.validate(obj, raiseException=True)
File "/Users/d/work/personal/vobject-tmp/vobject/icalendar.py", line 1073, in validate
raise ValidateError(m)
vobject.base.ValidateError: 'VTIMEZONE components must contain a valid TZID'
----------------------------------------------------------------------
I haven't had a chance to look into this yet. It's quite possible that the test case is incorrect.
Author
There was a problem hiding this comment.
My patch was:
--- a/vobject/icalendar.py
+++ b/vobject/icalendar.py
@@ -332,7 +332,7 @@ class TimezoneComponent(Component):
"""
# If tzinfo is UTC, we don't need a TZID
- if tzinfo is None or (not allowUTC and tzinfo_eq(tzinfo, utc)):
+ if tzinfo is None or str(tzinfo) == 'UTC' or (not allowUTC and tzinfo_eq(tzinfo, utc)):
return None
# Try pytz tzid key
There was a problem hiding this comment.
This is strange! Just to exclude a weird case: Have you tried
if str(tzinfo) == 'UTC' of tzinfo is None or (not allowUTC and tzinfo_eq(tzinfo, utc)):
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.
See skarim#184