From nobody Mon Aug 19 14:35:45 2024 X-Original-To: bugs@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4WnZry1ytKz5T7yk for ; Mon, 19 Aug 2024 14:35:46 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R11" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4WnZrx42cMz4tgY for ; Mon, 19 Aug 2024 14:35:45 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1724078145; a=rsa-sha256; cv=none; b=mA3fr/jrFq4uiYccPJE73SM+KgbU9ubG2ra/L4TWdh1off77QNymoxBDMa0+E1pqHV6ROy 7TUzQwySjgdoXuTGnlhva/3UhmKnuaMnpw4ND+jhem/g9Wqo8aJjvZF+jnPLQcaBK2UNce GaTyIoLkpI2GgAr9Znhe32K0UrB69jwaeZbNyUlRCxvbIP9VP6VWWnVHyIYzKFgkdJhQkO HDr4dztmyqwLYSA7WFF51IyhM3fTkKzEfYuas1MuxHvItbfQOzDxbOWilePvilMZEzizG0 UKcOI3rUV2G11uIdtUZb3UEmAjvkYgDS8pie8j74Yu9YeIW00wAFEYGT7WXu8A== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1724078145; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=opdbzRXC+n4Is1dkM1sm/Uu+ONXJT0Br6Yp0AO1FJyg=; b=pnRiAHINAZWyMKHDqEbnhoLMzDd1jsSPG7R6T781kIvgUVWkZgiLcYtP/6Nu4DCRvqx+oh Tm1BtQpFpk60UrQkk6YuWVDkpBCBZR7Le35yfDuY2U/Hi7ENuxNmh8AfhqIgbRAU2wqqnQ Q/xouBN1cASTi1aaia48FdEimKhw0XW82S+hSzwTnmaQbS5MDZQuOXfmdUFSY452l4thzx 4RepoHci2AxaDOuqMRSLasJj5eFjR8YoFxnlnkGkm15pU+wMu8nNz4F2BaHuHVgaRYVPbE gZY1m3DrKhKPVWxZy6TtZQ046NZx22NqmISUYtMuqMXYTZzGz0hKTTCnzOG7hA== Received: from kenobi.freebsd.org (kenobi.freebsd.org [IPv6:2610:1c1:1:606c::50:1d]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4WnZrx3W10zLKX for ; Mon, 19 Aug 2024 14:35:45 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) Received: from kenobi.freebsd.org ([127.0.1.5]) by kenobi.freebsd.org (8.15.2/8.15.2) with ESMTP id 47JEZjhI048518 for ; Mon, 19 Aug 2024 14:35:45 GMT (envelope-from bugzilla-noreply@freebsd.org) Received: (from www@localhost) by kenobi.freebsd.org (8.15.2/8.15.2/Submit) id 47JEZjiU048510 for bugs@FreeBSD.org; Mon, 19 Aug 2024 14:35:45 GMT (envelope-from bugzilla-noreply@freebsd.org) X-Authentication-Warning: kenobi.freebsd.org: www set sender to bugzilla-noreply@freebsd.org using -f From: bugzilla-noreply@freebsd.org To: bugs@FreeBSD.org Subject: [Bug 280922] Change 46c599340f187db577b9212ab18022f3c7380c68 fixes one case (localtime / gmtime -> strftime('%s'), but breaks another Date: Mon, 19 Aug 2024 14:35:45 +0000 X-Bugzilla-Reason: AssignedTo X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: Base System X-Bugzilla-Component: bin X-Bugzilla-Version: 14.1-STABLE X-Bugzilla-Keywords: X-Bugzilla-Severity: Affects Many People X-Bugzilla-Who: vlad.shabanov@gmail.com X-Bugzilla-Status: New X-Bugzilla-Resolution: X-Bugzilla-Priority: --- X-Bugzilla-Assigned-To: bugs@FreeBSD.org X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: https://bugs.freebsd.org/bugzilla/ Auto-Submitted: auto-generated List-Id: Bug reports List-Archive: https://lists.freebsd.org/archives/freebsd-bugs List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-freebsd-bugs@FreeBSD.org MIME-Version: 1.0 https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=3D280922 --- Comment #3 from Vladislav Shabanov --- (In reply to Dag-Erling Sm=C3=B8rgrav from comment #2) Thank you for reply. First of all, the current implementation of libc will produce completely wr= ong result when someone initializes only standard fields: struct tm x; x.tm_hour =3D 1; x.tm_min =3D 2; x.tm_sec =3D 3; x.tm_mday =3D 4; x.tm_mon =3D 6; x.tm_year =3D 106; x.tm_isdst =3D -1; strftime(....) This is because tm_gmtoff can get any value. In my first test, I got ~10 ye= ars shift just because follow the C reference. That's why most portable code does some equivalent of bzero(&x), including Python. Python, like many other big codebases, is tolerant to added, but un= used fields. Certainly, Python does bzero. Secondly, there is no way change Python to adopt it to new behaviour of strftime: the time and timetouple API is standard, nobody will add extra fi= elds to it, because it will break a lot of Python code. Furthermore, it's imposs= ible to fix the problem at Python level (restore tm_gmtoff), because it lost earlier, when datetime is converted to timetouple.=20 To sum up, now we have implementation with two problems: 1) it gives absolutely wrong result with badly written program initializing only documented fields (I mean, in POSIX standard) and leaves tm_gmtoff initialized. I sure that there are a lot of code written in last 50 years d= oing so. 2) It changes assumption that the unpacked struct tm is treated as local ti= me, which is mentioned in manual, and gives unexpected result when someone construct struct tm manually without the knowledge of tm_gmtoff. The proposed patch solves only the second problem. Maybe, it makes sence to change (t->tm_gmtoff || t->tm_zone) to (t->tm_gmtoff && t->tm_zone) to fix both cases. Anyway, this patch keeps your original problem solved, because gmtime and localtime fills both tm_gmtoff and tm_zone and new behaviour breaks less existing code. --=20 You are receiving this mail because: You are the assignee for the bug.=