Skip to content

Commit

Permalink
Ensure that we don't overlook errors in first PyObject_RichCompareBoo…
Browse files Browse the repository at this point in the history
…l call.

Python 3.5 turns such cases into SystemErrors.

See: https://bugs.python.org/issue23571

Fixes #15.
  • Loading branch information
Jim Fulton committed Nov 8, 2015
1 parent 6c415d5 commit da74acf
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 4 deletions.
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ python:
- 3.2
- 3.3
- 3.4
- 3.5
- pypy
- pypy3
install:
Expand Down
8 changes: 6 additions & 2 deletions BTrees/_compat.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,15 @@
#define TEXT_FROM_STRING PyUnicode_FromString
#define TEXT_FORMAT PyUnicode_Format

/* Note that the second comparison is skipped if the first comparison returns:
1 -> There was no error and the answer is -1
-1 -> There was an error, which the caller will detect with PyError_Occurred.
*/
#define COMPARE(lhs, rhs) \
PyObject_RichCompareBool((lhs), (rhs), Py_LT) > 0 ? -1 : \
PyObject_RichCompareBool((lhs), (rhs), Py_LT) != 0 ? -1 : \
(PyObject_RichCompareBool((lhs), (rhs), Py_EQ) > 0 ? 0 : 1)


#else

#define INTERN PyString_InternFromString
Expand Down
4 changes: 2 additions & 2 deletions CHANGES.rst
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
``BTrees`` Changelog
====================

4.1.5 (unreleased)
4.2.0 (unreleased)
------------------

- TBD
- Python 3.5 support.

4.1.4 (2015-06-02)
------------------
Expand Down
1 change: 1 addition & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ def BTreeExtension(family):
'Programming Language :: Python :: 3.2',
'Programming Language :: Python :: 3.3',
'Programming Language :: Python :: 3.4',
'Programming Language :: Python :: 3.5',
"Programming Language :: Python :: Implementation :: CPython",
"Programming Language :: Python :: Implementation :: PyPy",
"Framework :: ZODB",
Expand Down

0 comments on commit da74acf

Please sign in to comment.