ERP5Type/patches/Restricted: allow pytz exceptions
When using the public API of pandas (which is partially allowed in restricted python), it can happen that this public API raises the error 'pytz.NonExistentTimeError' [1]. Users should be allowed to import and therefore catch this exception. Before this patch we could only do: >>> try: ... ts.tz_localize(tz) ... except Exception: ... ... After this patch we can do; >>> try: ... ts.tz_localize(tz) ... except pytz.NonExistentTimeError: ... ... pytz delivers more exceptions which are all equally harmless. We can therefore in the same patch also allow them, as they may be useful for similar cases. This patch also comes with tests which ensure that the allowed exceptions can be imported into restricted python and also a test to ensure no other objects in the pytz namespace can be used. --- [1] https://pandas.pydata.org/pandas-docs/version/2.0.3/reference/api/pandas.Series.tz_localize.html /reviewed-by @jerome /reviewed-on !1802
Showing
Please register or sign in to comment