def unpickler(zone, utcoffset=None, dstoffset=None, tzname=None):
<EOL>tz = pytz.timezone(zone)<EOL>if utcoffset is None:<EOL><INDENT>return tz<EOL><DEDENT>utcoffset = memorized_timedelta(utcoffset)<EOL>dstoffset = memorized_timedelta(dstoffset)<EOL>try:<EOL><INDENT>return tz._tzinfos[(utcoffset, dstoffset, tzname)]<EOL><DEDENT>except KeyError:<EOL><INDENT>pass<EOL><DEDENT>for localized_tz in list(tz._tzinfos.values()):<EOL><INDENT>if (localized_tz._utcoffset == utcoffset<EOL>and localized_tz._dst == dstoffset):<EOL><INDENT>return localized_tz<EOL><DEDENT><DEDENT>inf = (utcoffset, dstoffset, tzname)<EOL>tz._tzinfos[inf] = tz.__class__(inf, tz._tzinfos)<EOL>return tz._tzinfos[inf]<EOL>
Factory function for unpickling pytz tzinfo instances.

    This is shared for both StaticTzInfo and DstTzInfo instances, because
    database changes could cause a zones implementation to switch between
    these two base classes and we can't break pickles on a pytz version
    upgrade.