python-holidays
python-holidays copied to clipboard
Can't pickle the result of `country_holidays`
Currently, on Linux it isn't possible to pickle the result of calling country_holidays
.
Code to reproduce:
import pickle
import holidays
def main():
jp_holidays = holidays.country_holidays("JP")
result = pickle.dumps(jp_holidays)
if __name__ == "__main__":
main()
The error: _pickle.PicklingError: Can't pickle <function func at 0x7f9098a8dd30>: attribute lookup func on __main__ failed
.
It fails not on all countries. For example, it works for US
and UK
.
The error starts from version 0.22
(on 0.22
it is slightly different).
The problem can be fixed by using dill
, but may be it is possible to adjust the code to work with native pickle
.
Thanks for reporting this. I guess i18n related code might be the culprit. I suggest using the workaround you found until the issue is fixed.
Sorry for the inconvenience.
@Mr-Geekman On current beta 0.26 that code produce no error, so I would advise you to wait for next release and check with it. The release is planned for early June.
@Mr-Geekman On current beta 0.26 that code produce no error, so I would advise you to wait for next release and check with it. The release is planned for early June.
Hmmm, can't confirm that after a brief look...
Yes, it seems pickle can't process holidays with language other than default. :-(