Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PyPy3 7.2.0 test failure: #675

Closed
mgorny opened this issue Nov 24, 2019 · 1 comment
Closed

PyPy3 7.2.0 test failure: #675

mgorny opened this issue Nov 24, 2019 · 1 comment

Comments

@mgorny
Copy link
Contributor

mgorny commented Nov 24, 2019

Overview Description

Tests are failing with PyPy3 7.2.0.

Steps to Reproduce

  1. Install PyPy3 7.2.0
  2. tox -e pypy3

Actual Results

==================================================================== FAILURES =====================================================================
___________________________________________________________ test_format_current_moment ____________________________________________________________

monkeypatch = <_pytest.monkeypatch.MonkeyPatch object at 0x00007fa3a03ccf00>

    def test_format_current_moment(monkeypatch):
        import datetime as datetime_module
        frozen_instant = datetime.utcnow()
    
        class frozen_datetime(datetime):
    
            @classmethod
            def utcnow(cls):
                return frozen_instant
    
        # Freeze time! Well, some of it anyway.
        monkeypatch.setattr(datetime_module, "datetime", frozen_datetime)
>       assert dates.format_datetime(locale="en_US") == dates.format_datetime(frozen_instant, locale="en_US")

tests/test_dates.py:775: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
babel/dates.py:728: in format_datetime
    datetime = _ensure_datetime_tzinfo(_get_datetime(datetime), tzinfo)
babel/dates.py:110: in _get_datetime
    return datetime_.utcnow()
/usr/lib/pypy3.6/lib-python/3/datetime.py:1535: in utcnow
    return cls.utcfromtimestamp(t)
/usr/lib/pypy3.6/lib-python/3/datetime.py:1523: in utcfromtimestamp
    return cls._fromtimestamp(t, True, None)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

cls = <class 'datetime.datetime'>, t = 1574616833.0, utc = True, tz = None

    @classmethod
    def _fromtimestamp(cls, t, utc, tz):
        """Construct a datetime from a POSIX timestamp (like time.time()).
    
        A timezone info object may be passed in as well.
        """
        frac, t = _math.modf(t)
        us = round(frac * 1e6)
        if us >= 1000000:
            t += 1
            us -= 1000000
        elif us < 0:
            t -= 1
            us += 1000000
    
        converter = _time.gmtime if utc else _time.localtime
        y, m, d, hh, mm, ss, weekday, jday, dst = converter(t)
        ss = min(ss, 59)    # clamp out leap seconds if the platform has them
        result = cls(y, m, d, hh, mm, ss, us, tz)
        if tz is None:
            # As of version 2015f max fold in IANA database is
            # 23 hours at 1969-09-30 13:00:00 in Kwajalein.
            # Let's probe 24 hours in the past to detect a transition:
            max_fold_seconds = 24 * 3600
    
            # On Windows localtime_s throws an OSError for negative values,
            # thus we can't perform fold detection for values of time less
            # than the max time fold. See comments in _datetimemodule's
            # version of this method for more details.
            if t < max_fold_seconds and sys.platform.startswith("win"):
                return result
    
            y, m, d, hh, mm, ss = converter(t - max_fold_seconds)[:6]
            probe1 = cls(y, m, d, hh, mm, ss, us, tz)
>           trans = result - probe1 - timedelta(0, max_fold_seconds)
E           TypeError: unsupported operand type(s) for -: 'datetime' and 'datetime'

/usr/lib/pypy3.6/lib-python/3/datetime.py:1500: TypeError
================================================================ warnings summary =================================================================
babel/numbers.py::babel.numbers.format_number
babel/support.py::babel.support.Format.number
tests/test_numbers.py::test_format_number
tests/test_support.py::test_format_number
  /tmp/babel/babel/numbers.py:352: DeprecationWarning: Use babel.numbers.format_decimal() instead.
    warnings.warn('Use babel.numbers.format_decimal() instead.', DeprecationWarning)

babel/support.py::babel.support.Format.timedelta
tests/test_support.py::test_format_timedelta
  /tmp/babel/babel/dates.py:916: DeprecationWarning: "medium" value for format param of format_timedelta is deprecated. Use "long" instead
    category=DeprecationWarning)

-- Docs: https://docs.pytest.org/en/latest/warnings.html
=============================================== 1 failed, 3005 passed, 6 warnings in 68.81 seconds ================================================

Expected Results

Passing tests, surprisingly.

Reproducibility

Always. Tested on 2.7.0 & master.

Additional Information:

$ pypy3 --version
Python 3.6.9 (5da45ced70e515f94686be0df47c59abd1348ebc, Nov 02 2019, 07:59:26)
[PyPy 7.2.0 with GCC 9.2.0]
@akx
Copy link
Member

akx commented Jan 27, 2022

This was resolved in 9a9d3c6 (#754).

@akx akx closed this as completed Jan 27, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants