classification
Title: strftime fails on HP-UX
Type: behavior Stage:
Components: Library (Lib) Versions: Python 3.7
process
Status: open Resolution:
Dependencies: Superseder:
Assigned To: Nosy List: michael-o, terry.reedy
Priority: normal Keywords:

Created on 2018-08-14 12:36 by michael-o, last changed 2018-08-18 18:55 by michael-o.

Messages (4)
msg323512 - (view) Author: Michael Osipov (michael-o) * Date: 2018-08-14 12:36
strftime() fails on HP-UX. It is mapped to wcsftime(3). It has a quirk on HP-UX that is does not conform to POSIX. To enable POSIX compat one has to do (excerpt from manpage):
> APPLICATION USAGE
>       The "Unix Standards Only" prototype of wcsftime() is available to
>       applications if they are:
>            a. c99 conformant.
> 
>            b. Compiled with -D_XOPEN_SOURCE macro with a value >=500.
> 
>            c. Compiled with -D_POSIX_C_SOURCE macro with a value >= 200112.
> 
>       Also the application must be compiled with the environment variable
>       UNIX_STD set to the value 98 or above and exported.

b and c are satasfied according to config.log. Let's get to a). The manpage of aCC says:
>  EXTERNAL INFLUENCES
>     Environment Variables
>       [...]
>       UNIX95 or UNIX_STD specify the XPG4 behavior for c89(1) and c99(1).
>       -D_XOPEN_UNIX is also set.  UNIX_STD must be set to 1995, 1998 or
>       2003.  Both these variables cause an appropriate object file to be
>       linked into executables in order to customize libc to match ISO/IEC
>       9899:1990/Amendment 1:1995 (1995) and the C++ and C99 Standards for
>       the various wide char (1998) or other C99 libc functions (2003).
>       NOTE: 2003 is only available on HP-UX 11.31.

So one must at least do "export UNIX_STD=1998".

I am quite certain that other parts of Python are affected too.

The safest bet would be actually to test wcsftime at configure time wether the output is fine and have this env var set in the Makefile, unfortunately, this will only work for GNU make. Alternatively, a warning at the very end of the configure run has to be printed to export this env var.

If done, test_strftime and test_teststrptime will pass flawlessly.
msg323513 - (view) Author: Michael Osipov (michael-o) * Date: 2018-08-14 12:39
The worst thing about wcsftime(3) is that it silently fails by not writing to output buffer. timemodule.c allocates more and more memory and then gives up.
msg323680 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2018-08-17 22:12
Same comment as for #34401.
msg323728 - (view) Author: Michael Osipov (michael-o) * Date: 2018-08-18 18:55
Thanks changed appropriately. I here also have a PR idea I will try on Monday. It won't be idiotproof, but someone will likely comment on it and provide more input.

I am willing to provide even more patches, but am currently stuck with https://github.com/python/cpython/pull/8786 and juggle with "git stash" to make Python actually compile on HP-UX. This is cumbersome.
History
Date User Action Args
2018-08-18 18:55:23michael-osettype: crash -> behavior
messages: + msg323728
title: [SOLUTION] strftime fails on HP-UX -> strftime fails on HP-UX
2018-08-17 22:12:47terry.reedysetnosy: + terry.reedy
messages: + msg323680
2018-08-14 12:39:30michael-osetmessages: + msg323513
2018-08-14 12:36:57michael-ocreate