8000 [NetBSD] float formatting change between Python 3.11 and 3.12? · Issue #128005 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content
[NetBSD] float formatting change between Python 3.11 and 3.12? #128005
Closed as not planned
@0-wiz-0

Description

@0-wiz-0

Bug report

Bug description:

While looking at a ntpsec test failure, I looked at the Python self tests and noticed that some are failing on NetBSD 10/amd64.
I extraced and minimized one test case based on test_format:

#!/usr/bin/env python


def testformat(formatstr, args, output=None, limit=None):
    result = formatstr % args
    if output and limit is None and result != output:
        raise AssertionError("%r %% %r == %r != %r" %
                             (formatstr, args, result, output))
    # when 'limit' is specified, it determines how many characters
    # must match exactly; lengths must always match.
    # ex: limit=5, '12345678' matches '12345___'
    # (mainly for floating-point format tests for which an exact match
    # can't be guaranteed due to rounding and representation errors)
    elif output and limit is not None and (
            len(result) != len(output) or result[:limit] != output[:limit]):
        print("%s %% %s == %s != %s" %
              (repr(formatstr), repr(args), repr(result), repr(output)))


testformat(b"%a", (3.14,), b"3.14")

This test fails with Python 3.13.1 and Python 3.12.8:

Traceback (most recent call last):
  File "/home/wiz/./bin/test-format.py", line 20, in <module>
    testformat(b"%a", (3.14,), b"3.14")
    ~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/wiz/./bin/test-format.py", line 7, in testformat
    raise AssertionError("%r %% %r == %r != %r" %
                         (formatstr, args, result, output))
AssertionError: b'%a' % (3.1400000000000001,) == b'3.1400000000000001' != b'3.14'

but works fine with Python 3.10.15 and 3.11.11 in the same environment.
(All software compiled from pkgsrc in case it matters.)

Initially I suspected a bug in NetBSD's printf of float handling, but since this works with Python 3.11.11 I'm not sure any longer.

CPython versions tested on:

3.10, 3.11, 3.12, 3.13

Operating systems tested on:

Other

Metadata

Metadata

Assignees

No one assigned

    Labels

    testsTests in the Lib/test dirtype-bugAn unexpected behavior, bug, or error

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0