diff options
author | Paul Ganssle <paul@ganssle.io> | 2020-08-14 02:38:30 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-08-14 02:38:30 (GMT) |
commit | 87d8287865e5c9f137f6b5cf8c34c2c509eb5e9d (patch) | |
tree | a7608fbc662266616e4955df41f75857c43edfca | |
parent | e55de68be3e5b977a17d3c0ac9805b0feff8fedc (diff) | |
download | cpython-87d8287865e5c9f137f6b5cf8c34c2c509eb5e9d.zip cpython-87d8287865e5c9f137f6b5cf8c34c2c509eb5e9d.tar.gz cpython-87d8287865e5c9f137f6b5cf8c34c2c509eb5e9d.tar.bz2 |
bpo-41025: Fix subclassing for zoneinfo.ZoneInfo (GH-20965)
Prior to this change, attempting to subclass the C implementation of
zoneinfo.ZoneInfo gave the following error:
TypeError: unbound method ZoneInfo.__init_subclass__() needs an argument
https://bugs.python.org/issue41025
-rw-r--r-- | Lib/test/test_zoneinfo/test_zoneinfo.py | 4 | ||||
-rw-r--r-- | Misc/NEWS.d/next/Library/2020-06-18-10-34-59.bpo-41025.elf_nz.rst | 2 | ||||
-rw-r--r-- | Modules/_zoneinfo.c | 2 |
3 files changed, 5 insertions, 3 deletions
diff --git a/Lib/test/test_zoneinfo/test_zoneinfo.py b/Lib/test/test_zoneinfo/test_zoneinfo.py index d16e0d2..a9375fd 100644 --- a/Lib/test/test_zoneinfo/test_zoneinfo.py +++ b/Lib/test/test_zoneinfo/test_zoneinfo.py @@ -463,7 +463,7 @@ class CZoneInfoDatetimeSubclassTest(DatetimeSubclassMixin, CZoneInfoTest): pass -class ZoneInfoTestSubclass(ZoneInfoTest): +class ZoneInfoSubclassTest(ZoneInfoTest): @classmethod def setUpClass(cls): super().setUpClass() @@ -484,7 +484,7 @@ class ZoneInfoTestSubclass(ZoneInfoTest): self.assertIsInstance(sub_obj, self.klass) -class CZoneInfoTestSubclass(ZoneInfoTest): +class CZoneInfoSubclassTest(ZoneInfoSubclassTest): module = c_zoneinfo diff --git a/Misc/NEWS.d/next/Library/2020-06-18-10-34-59.bpo-41025.elf_nz.rst b/Misc/NEWS.d/next/Library/2020-06-18-10-34-59.bpo-41025.elf_nz.rst new file mode 100644 index 0000000..21e184d --- /dev/null +++ b/Misc/NEWS.d/next/Library/2020-06-18-10-34-59.bpo-41025.elf_nz.rst @@ -0,0 +1,2 @@ +Fixed an issue preventing the C implementation of :class:`zoneinfo.ZoneInfo` +from being subclassed. diff --git a/Modules/_zoneinfo.c b/Modules/_zoneinfo.c index bee84cb..12b3969 100644 --- a/Modules/_zoneinfo.c +++ b/Modules/_zoneinfo.c @@ -2557,7 +2557,7 @@ static PyMethodDef zoneinfo_methods[] = { {"_unpickle", (PyCFunction)zoneinfo__unpickle, METH_VARARGS | METH_CLASS, PyDoc_STR("Private method used in unpickling.")}, {"__init_subclass__", (PyCFunction)(void (*)(void))zoneinfo_init_subclass, - METH_VARARGS | METH_KEYWORDS, + METH_VARARGS | METH_KEYWORDS | METH_CLASS, PyDoc_STR("Function to initialize subclasses.")}, {NULL} /* Sentinel */ }; |