Skip to content

Conversation

@Delgan
Copy link
Contributor

@Delgan Delgan commented Jan 26, 2018

This PR is intended to fix #167.

Basically, the issue was that Pendulum defaults to "" for the local timezone name if it can't be determined properly, but the tz attribute of Pendulum() does not accept empty string. This was causing an error while trying to re-create a pickled instance of Pendulum.

To fix that, I made use of #161. Now that TimezoneInfo objects are picklable, we can directly use them to serialize any instance of Pendulum, rather than their string representation.

I also had to fix a small bug in the __getinitargs__() method of the FixedTimezone class, as it should return a tuple but it did not.

Any Pendulum instance with an empty timezone name should now be correctly unpickable.

As to why the timezone name could not be determined, it seems to be a bug with Windows 10 bash shell. Here is a discussion of another project facing the same issue: HowardHinnant/date#102
There does not seem to be any way to know the timezone's name. However, it is recommended to run sudo dpkg-reconfigure tzdata to fix it, which I did and it works fine now.

@sdispater
Copy link
Collaborator

Thanks a lot for this and the detailed explanation !

One thing though: Could you base your PR on the 1.x branch?

The master branch will soon be holding the work towards the 2.0 release so it will have some breaking changes.

@Delgan Delgan changed the base branch from master to 1.x January 26, 2018 19:27
@Delgan
Copy link
Contributor Author

Delgan commented Jan 26, 2018

Done. 👍

@sdispater sdispater merged commit 56f93ba into python-pendulum:1.x Jan 29, 2018
@sdispater
Copy link
Collaborator

Thanks !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants