From ba286114c350c5afdb47e0e01bf0dd4f15edbfe0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9rome=20Perrin?= <jerome@nexedi.com> Date: Wed, 18 Jan 2023 15:55:07 +0100 Subject: [PATCH] DateTimePatch: keep exceptions as class attributes We have code depending on these attributes, they were used in pattern like this: ```py try: DateTime(user_input) except DateTime.DateError: error("invalid date") ``` so it's safer to keep the attributes for now, since we are already patching a lot --- product/ERP5Type/patches/DateTimePatch.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/product/ERP5Type/patches/DateTimePatch.py b/product/ERP5Type/patches/DateTimePatch.py index afc8d69ef9..67a33d2cb8 100644 --- a/product/ERP5Type/patches/DateTimePatch.py +++ b/product/ERP5Type/patches/DateTimePatch.py @@ -278,3 +278,11 @@ def DateTime_parse(self, st, datefmt=getDefaultDateFormat()): DateTimeKlass._parse = DateTime_parse + +# DateTime 3 removed exceptions as class attributes (since +# zopefoundation/DateTime commit 8114618 ), but we have some code expecting +# these attributes, so undo this patch for convenience. +DateTimeKlass.DateTimeError = DateTimeError +DateTimeKlass.SyntaxError = SyntaxError +DateTimeKlass.DateError = DateError +DateTimeKlass.TimeError = TimeError -- 2.30.9