Re: [Django] #35630: `django.utils.formats.sanitize_strftime_format()` no longer works correctly with Python 3.13.0b4

2024-08-28 Thread Django
#35630: `django.utils.formats.sanitize_strftime_format()` no longer works 
correctly
with Python 3.13.0b4
--+--
 Reporter:  Michał Górny  |Owner:  (none)
 Type:  Bug   |   Status:  closed
Component:  Utilities |  Version:  dev
 Severity:  Normal|   Resolution:  duplicate
 Keywords:| Triage Stage:  Unreviewed
Has patch:  0 |  Needs documentation:  0
  Needs tests:  0 |  Patch needs improvement:  0
Easy pickings:  0 |UI/UX:  0
--+--
Comment (by Natalia Bidart):

 This was nicely reverted and fixed in Python:
 https://github.com/python/cpython/pull/122436/
-- 
Ticket URL: 
Django 
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-updates+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/010701919924f336-13e90bd7-8878-4e17-89b4-f7ac04d9add5-00%40eu-central-1.amazonses.com.


Re: [Django] #35630: `django.utils.formats.sanitize_strftime_format()` no longer works correctly with Python 3.13.0b4

2024-07-25 Thread Django
#35630: `django.utils.formats.sanitize_strftime_format()` no longer works 
correctly
with Python 3.13.0b4
--+--
 Reporter:  Michał Górny  |Owner:  (none)
 Type:  Bug   |   Status:  closed
Component:  Utilities |  Version:  dev
 Severity:  Normal|   Resolution:  duplicate
 Keywords:| Triage Stage:  Unreviewed
Has patch:  0 |  Needs documentation:  0
  Needs tests:  0 |  Patch needs improvement:  0
Easy pickings:  0 |UI/UX:  0
--+--
Changes (by Sarah Boyce):

 * resolution:   => duplicate
 * status:  new => closed

Comment:

 Thank you for drawing this to our attention Michal
 I'm going to link this up to #34900 which tracks adding Python 3.13
 support 👍
-- 
Ticket URL: 
Django 
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-updates+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/01070190e9b88e6e-2fd22395-590c-48b0-8bb6-83c72b29f1ee-00%40eu-central-1.amazonses.com.


[Django] #35630: `django.utils.formats.sanitize_strftime_format()` no longer works correctly with Python 3.13.0b4

2024-07-25 Thread Django
#35630: `django.utils.formats.sanitize_strftime_format()` no longer works 
correctly
with Python 3.13.0b4
--+--
 Reporter:  Michał Górny  | Type:  Bug
   Status:  new   |Component:  Utilities
  Version:  dev   | Severity:  Normal
 Keywords:| Triage Stage:  Unreviewed
Has patch:  0 |  Needs documentation:  0
  Needs tests:  0 |  Patch needs improvement:  0
Easy pickings:  0 |UI/UX:  0
--+--
 Python 3.13.0b4 includes a change to
 [https://github.com/python/cpython/issues/120713 add zero-padding to `%y`
 and `%Y` `strftime()` formats]. However, padding is not added to `%C` or
 `%F` formats.

 The current logic in django assumes that if `%Y` is padded, then no
 padding needs to be added:

 {{{
 if datetime.date(1, 1, 1).strftime("%Y") == "0001":
 return fmt
 }}}
 
https://github.com/django/django/blob/0e94f292cda632153f2b3d9a9037eb0141ae9c2e/django/utils/formats.py#L266

 This misfires on 3.13.0b4, stopping django from adding the padding to `%C`
 and `%F` formats.

 I've filed [https://github.com/python/cpython/issues/122272 a bug to
 CPython upstream about this inconsistent behavior].

 This is causing the following test failures:

 {{{
 ==
 FAIL: test_sanitize_strftime_format
 (i18n.tests.FormattingTests.test_sanitize_strftime_format) (year=1,
 fmt='%C')
 --
 Traceback (most recent call last):
   File "/tmp/django/tests/i18n/tests.py", line 1195, in
 test_sanitize_strftime_format
 self.assertEqual(dt.strftime(fmt), expected)
 
 AssertionError: '0' != '00'
 - 0
 + 00
 ? +


 ==
 FAIL: test_sanitize_strftime_format
 (i18n.tests.FormattingTests.test_sanitize_strftime_format) (year=1,
 fmt='%F')
 --
 Traceback (most recent call last):
   File "/tmp/django/tests/i18n/tests.py", line 1195, in
 test_sanitize_strftime_format
 self.assertEqual(dt.strftime(fmt), expected)
 
 AssertionError: '1-01-01' != '0001-01-01'
 - 1-01-01
 + 0001-01-01
 ? +++


 ==
 FAIL: test_sanitize_strftime_format
 (i18n.tests.FormattingTests.test_sanitize_strftime_format) (year=99,
 fmt='%C')
 --
 Traceback (most recent call last):
   File "/tmp/django/tests/i18n/tests.py", line 1195, in
 test_sanitize_strftime_format
 self.assertEqual(dt.strftime(fmt), expected)
 
 AssertionError: '0' != '00'
 - 0
 + 00
 ? +


 ==
 FAIL: test_sanitize_strftime_format
 (i18n.tests.FormattingTests.test_sanitize_strftime_format) (year=99,
 fmt='%F')
 --
 Traceback (most recent call last):
   File "/tmp/django/tests/i18n/tests.py", line 1195, in
 test_sanitize_strftime_format
 self.assertEqual(dt.strftime(fmt), expected)
 
 AssertionError: '99-01-01' != '0099-01-01'
 - 99-01-01
 + 0099-01-01
 ? ++


 ==
 FAIL: test_sanitize_strftime_format
 (i18n.tests.FormattingTests.test_sanitize_strftime_format) (year=999,
 fmt='%C')
 --
 Traceback (most recent call last):
   File "/tmp/django/tests/i18n/tests.py", line 1195, in
 test_sanitize_strftime_format
 self.assertEqual(dt.strftime(fmt), expected)
 
 AssertionError: '9' != '09'
 - 9
 + 09
 ? +


 ==
 FAIL: test_sanitize_strftime_format
 (i18n.tests.FormattingTests.test_sanitize_strftime_format) (year=999,
 fmt='%F')
 --
 Traceback (most recent call last):
   File "/tmp/django/tests/i18n/tests.py", line 1195, in
 test_sanitize_strftime_format
 self.assertEqual(dt.strftime(fmt), expected)
 
 AssertionError: '999-01-01' != '0999-01-01'
 - 999-01-01
 + 0999-01-01
 ? +


 ==
 FAIL: test_sanitize_strftime_format_with_escaped_percent
 (i18n.tests.FormattingTests.test_sanitize_strftime_format_with_escaped_percent)
 (year=1, fmt='%%%C')
 --