Repository: sdispater/pendulum

Issue:
Timezone is empty on Windows 10 bash shell, causing error while unpickling Pendulum objects
Hello.

This is maybe related to #161, but I'm not sure.

When I run this using the Windows 10 bash shell:
```python
import pendulum
import pendulum.version
import pickle
import sys

print("Python version:", sys.version)
print("Pendulum version:", pendulum.version.VERSION)

now = pendulum.now()
print(now, now.timezone)
pickled = pickle.dumps(now)
pickle.loads(pickled)
```

It raises an error (but it works fine with W10 Python installation):
```
Python version: 3.6.3 (default, Oct  4 2017, 02:55:45) [GCC 5.4.0 20160609]
Pendulum version: 1.3.2
2017-12-11T20:31:49.750107+01:00 <Timezone []>
Traceback (most recent call last):
  File "test.py", line 12, in <module>
    pickle.loads(pickled)
  File "/mnt/c/Users/delgan/Desktop/project/env/lib/python3.6/site-packages/pendulum/pendulum.py", line 155, in __init__
    self._tz = self._safe_create_datetime_zone(tzinfo)
  File "/mnt/c/Users/delgan/Desktop/project/env/lib/python3.6/site-packages/pendulum/pendulum.py", line 82, in _safe_create_datetime_zone
    return cls._timezone(obj)
  File "/mnt/c/Users/delgan/Desktop/project/env/lib/python3.6/site-packages/pendulum/pendulum.py", line 107, in _timezone
    return Timezone.load(zone)
  File "/mnt/c/Users/delgan/Desktop/project/env/lib/python3.6/site-packages/pendulum/tz/timezone.py", line 90, in load
    utc_transition_times) = Loader.load(name)
  File "/mnt/c/Users/delgan/Desktop/project/env/lib/python3.6/site-packages/pendulum/tz/loader.py", line 33, in load
    with tz_file(name) as f:
  File "/mnt/c/Users/delgan/Desktop/project/env/lib/python3.6/site-packages/pytzdata/__init__.py", line 32, in tz_file
    filepath = tz_path(name)
  File "/mnt/c/Users/delgan/Desktop/project/env/lib/python3.6/site-packages/pytzdata/__init__.py", line 62, in tz_path
    raise ValueError('Invalid timezone')
ValueError: Invalid timezone
```

As you can see, the timezone is empty, which causes an exception equivalent to `pendulum.now(tz='')`. Yet, the `now()` worked fine because the time contains `+01:00`.

Do you have any idea where the bug might come from?

Comments:

Patch:
diff --git a/pendulum/pendulum.py b/pendulum/pendulum.py
index cbbf94a..6cca7f6 100644
--- a/pendulum/pendulum.py
+++ b/pendulum/pendulum.py
@@ -1980,16 +1980,10 @@ class Pendulum(Date, datetime.datetime):
         return(self, )
 
     def _getstate(self, protocol=3):
-        tz = self.timezone_name
-
-        # Fix for fixed timezones not being properly unpickled
-        if isinstance(self.tz, FixedTimezone):
-            tz = self.offset_hours
-
         return (
             self.year, self.month, self.day,
             self.hour, self.minute, self.second, self.microsecond,
-            tz,
+            self.tzinfo,
             self.fold
         )
 
diff --git a/pendulum/tz/timezone.py b/pendulum/tz/timezone.py
index cb520de..416b352 100644
--- a/pendulum/tz/timezone.py
+++ b/pendulum/tz/timezone.py
@@ -512,7 +512,7 @@ class FixedTimezone(Timezone):
         return (dt + self._tzinfo.adjusted_offset).replace(tzinfo=self._tzinfo)
 
     def __getinitargs__(self):
-        return self._offset
+        return (self._offset, )
 
 
 class _UTC(FixedTimezone):


Test patch:
diff --git a/tests/pendulum_tests/test_behavior.py b/tests/pendulum_tests/test_behavior.py
index 12a1285..76d90ed 100644
--- a/tests/pendulum_tests/test_behavior.py
+++ b/tests/pendulum_tests/test_behavior.py
@@ -6,6 +6,7 @@ from copy import deepcopy
 from datetime import datetime, date, time, timedelta
 from pendulum import Pendulum, timezone
 from pendulum.tz.timezone import Timezone
+from pendulum.tz.loader import Loader
 from .. import AbstractTestCase
 
 
@@ -101,6 +102,14 @@ class BehaviorTest(AbstractTestCase):
 
         self.assertEqual(dt1, dt2)
 
+    def test_pickle_with_empty_tzinfo_name(self):
+        empty_timezone = Timezone('', *Loader.load('Europe/Paris'))
+        dt1 = Pendulum(2016, 8, 27, 12, 34, 56, 123456, empty_timezone)
+        s = pickle.dumps(dt1)
+        dt2 = pickle.loads(s)
+
+        self.assertEqual(dt1, dt2)
+
     def test_proper_dst(self):
         dt = pendulum.create(1941, 7, 1, tz='Europe/Amsterdam')