[New-bugs-announce] [issue46587] datetime and time tests use non-portal "%4Y" format

Christian Heimes report at bugs.python.org
Sun Jan 30 10:14:48 EST 2022


New submission from Christian Heimes <lists at cheimes.de>:

Several test cases for datetime and time modules use the non-standard and non-portal width prefix for strftime:

>>> datetime.date(42, 1, 1).strftime("%4Y")
'0042'

According to man strftime(3) https://man7.org/linux/man-pages/man3/strftime.3.html the width field is glibc-specific extension:

> Glibc provides some extensions for conversion specifications.
> (These extensions are not specified in POSIX.1-2001, but a few
> other systems provide similar features.)  Between the '%'
> character and the conversion specifier character, an optional
> flag and field width may be specified.

The width field is not supported by Emscripten, which only implements POSIX.1-2001 compatible date and time formatting: https://github.com/emscripten-core/emscripten/blob/3.1.2/src/library.js#L735

Python 3.11.0a4+ (heads/main-dirty:b1a3446, Jan 25 2022, 10:19:07) [Clang 14.0.0 (https://github.com/llvm/llvm-project f142c45f1e494f8dbdcc1bcf1412 on emscripten
Type "help", "copyright", "credits" or "license" for more information.
>>> import datetime
>>> datetime.date(42, 1, 1).strftime("%4Y")
'%4Y'

Also see bpo-13305

----------
components: Tests
messages: 412157
nosy: christian.heimes
priority: normal
severity: normal
status: open
title: datetime and time tests use non-portal "%4Y" format
type: behavior
versions: Python 3.10, Python 3.11, Python 3.9

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue46587>
_______________________________________


More information about the New-bugs-announce mailing list