Author: Matti Picus <matti.pi...@gmail.com> Branch: py3.6 Changeset: r96088:1c7aea3d0597 Date: 2019-02-19 11:35 +0200 http://bitbucket.org/pypy/pypy/changeset/1c7aea3d0597/
Log: merge default into py3.6 diff --git a/pypy/module/cpyext/cdatetime.py b/pypy/module/cpyext/cdatetime.py --- a/pypy/module/cpyext/cdatetime.py +++ b/pypy/module/cpyext/cdatetime.py @@ -296,25 +296,41 @@ def PyDateTime_DATE_GET_HOUR(space, w_obj): """Return the hour, as an int from 0 through 23. """ - return space.int_w(space.getattr(w_obj, space.newtext("hour"))) + # w_obj must be a datetime.timedate object. However, I've seen libraries + # call this macro with a datetime.date object. I think it returns + # nonsense in CPython, but it doesn't crash. We'll just return zero + # in case there is no field 'hour'. + try: + return space.int_w(space.getattr(w_obj, space.newtext("hour"))) + except OperationError: + return 0 @cpython_api([rffi.VOIDP], rffi.INT_real, error=CANNOT_FAIL) def PyDateTime_DATE_GET_MINUTE(space, w_obj): """Return the minute, as an int from 0 through 59. """ - return space.int_w(space.getattr(w_obj, space.newtext("minute"))) + try: + return space.int_w(space.getattr(w_obj, space.newtext("minute"))) + except OperationError: + return 0 # see comments in PyDateTime_DATE_GET_HOUR @cpython_api([rffi.VOIDP], rffi.INT_real, error=CANNOT_FAIL) def PyDateTime_DATE_GET_SECOND(space, w_obj): """Return the second, as an int from 0 through 59. """ - return space.int_w(space.getattr(w_obj, space.newtext("second"))) + try: + return space.int_w(space.getattr(w_obj, space.newtext("second"))) + except OperationError: + return 0 # see comments in PyDateTime_DATE_GET_HOUR @cpython_api([rffi.VOIDP], rffi.INT_real, error=CANNOT_FAIL) def PyDateTime_DATE_GET_MICROSECOND(space, w_obj): """Return the microsecond, as an int from 0 through 999999. """ - return space.int_w(space.getattr(w_obj, space.newtext("microsecond"))) + try: + return space.int_w(space.getattr(w_obj, space.newtext("microsecond"))) + except OperationError: + return 0 # see comments in PyDateTime_DATE_GET_HOUR @cpython_api([rffi.VOIDP], rffi.INT_real, error=CANNOT_FAIL) def PyDateTime_TIME_GET_HOUR(space, w_obj): diff --git a/pypy/module/test_lib_pypy/README.txt b/pypy/module/test_lib_pypy/README.txt --- a/pypy/module/test_lib_pypy/README.txt +++ b/pypy/module/test_lib_pypy/README.txt @@ -5,3 +5,5 @@ Note that if you run it with a PyPy from elsewhere, it will not pick up the changes to lib-python and lib_pypy. + +DEPRECATED: put tests in ./extra_tests instead! diff --git a/rpython/rlib/rutf8.py b/rpython/rlib/rutf8.py --- a/rpython/rlib/rutf8.py +++ b/rpython/rlib/rutf8.py @@ -89,7 +89,7 @@ builder.append(chr((0x80 | ((code >> 6) & 0x3f)))) builder.append(chr((0x80 | (code & 0x3f)))) return - raise ValueError + raise ValueError('character U+%x is not in range [U+0000; U+10ffff]' % code) @dont_inline def _nonascii_unichr_as_utf8_append_nosurrogates(builder, code): _______________________________________________ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit