You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
C-extension datetime.timezone is not acceptable as a base class; pure-Python version is #112451
changed the title [-]pure python datetime.timezone is not acceptable as a base class[/-][+]C-extension `datetime.timezone` is not acceptable as a base class[/+]on Nov 27, 2023
changed the title [-]C-extension `datetime.timezone` is not acceptable as a base class[/-][+]C-extension `datetime.timezone` is not acceptable as a base class; pure-Python version is[/+]on Nov 29, 2023
I think @abalkin would know better, but I think the no-subclassing behavior was deliberate. If that is the case we should probably fix it by preventing inheritance in the pure Python module.
I think @abalkin would know better, but I think the no-subclassing behavior was deliberate. If that is the case we should probably fix it by preventing inheritance in the pure Python module.
I'm fine with making them consistent in any way. Just let me know and I'll update my patch.
I think @abalkin would know better, but I think the no-subclassing behavior was deliberate. If that is the case we should probably fix it by preventing inheritance in the pure Python module.
As far as I'm aware, there are reasonable use cases for timezone subclasses, e.g. enums:
Activity
ngnpope commentedon Nov 27, 2023
Just to clarify: It is acceptable as a base class in Pure Python, but not in the C extension.
[-]pure python datetime.timezone is not acceptable as a base class[/-][+]C-extension `datetime.timezone` is not acceptable as a base class[/+]felixxm commentedon Nov 29, 2023
Working on patch
[-]C-extension `datetime.timezone` is not acceptable as a base class[/-][+]C-extension `datetime.timezone` is not acceptable as a base class; pure-Python version is[/+]pythongh-112451: Make C-extension datetime.timezone acceptable as a b…
pythongh-112451: Make C-extension datetime.timezone acceptable as a b…
pythongh-112451: Make C-extension datetime.timezone acceptable as a b…
pganssle commentedon Nov 29, 2023
I think @abalkin would know better, but I think the no-subclassing behavior was deliberate. If that is the case we should probably fix it by preventing inheritance in the pure Python module.
felixxm commentedon Nov 29, 2023
I'm fine with making them consistent in any way. Just let me know and I'll update my patch.
Refs #34986 -- Removed redundant CustomChoicesTests.test_timezone_uns…
felixxm commentedon Jan 12, 2024
As far as I'm aware, there are reasonable use cases for
timezonesubclasses, e.g. enums:7 remaining items
pythongh-112451: Make datetime.timezone not acceptable as a base class.
felixxm commentedon Jan 17, 2024
I've submitted a new PR to make both implementation consistent, #114190.
pythongh-112451: Prohibit subclassing of datetime.timezone.
pythongh-112451: Deprecate subclassing of pure-Python datetime.timezone.
pythongh-112451: Deprecate subclassing of pure-Python datetime.timezone.
pythongh-112451: Deprecate subclassing of pure-Python datetime.timezone.
pythongh-112451: Prohibit subclassing of datetime.timezone.
Merge branch 'main' into pythongh-112451-cannot
gh-112451: Prohibit subclassing of datetime.timezone. (#114190)
backport cpython fix to prevent subclassing datetime.timezone (python…
pythongh-112451: Prohibit subclassing of datetime.timezone. (python#1…
pythongh-112451: Prohibit subclassing of datetime.timezone. (python#1…