This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Title: _bsddb: else misleadingly indented
Type: Stage: resolved
Components: Extension Modules Versions: Python 2.7
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: jcea, serhiy.storchaka, vstinner
Priority: normal Keywords:

Created on 2017-05-03 12:04 by vstinner, last changed 2022-04-11 14:58 by admin. This issue is now closed.

Pull Requests
URL Status Linked Edit
PR 1428 merged vstinner, 2017-05-03 12:07
Messages (5)
msg292890 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2017-05-03 12:04
building '_bsddb' extension
gcc -pthread -fPIC -fno-strict-aliasing -O0 -g -O0 -Wall -Wstrict-prototypes -I/usr/include -I. -IInclude -I./Include -I/usr/local/include -I/home/haypo/prog/python/2.7/Include -I/home/haypo/prog/python/2.7 -c /home/haypo/prog/python/2.7/Modules/_bsddb.c -o build/temp.linux-x86_64-2.7-pydebug/home/haypo/prog/python/2.7/Modules/_bsddb.o
/home/haypo/prog/python/2.7/Modules/_bsddb.c: Dans la fonction « newDBObject »:
/home/haypo/prog/python/2.7/Modules/_bsddb.c:936:5: attention : this « else » clause does not guard... [-Wmisleading-indentation]
/home/haypo/prog/python/2.7/Modules/_bsddb.c:938:9: note : ...this statement, but the latter is misleadingly indented as if it is guarded by the « else »
         self->moduleFlags.cursorSetReturnsNone = DEFAULT_CURSOR_SET_RETURNS_NONE;
gcc -pthread -shared build/temp.linux-x86_64-2.7-pydebug/home/haypo/prog/python/2.7/Modules/_bsddb.o -L/usr/lib64 -L/usr/local/lib -Wl,-R/usr/lib64 -ldb-5.3 -o build/lib.linux-x86_64-2.7-pydebug/

I agree that the indentation is surprising and looks like a bug.

    if (self->myenvobj)
        self->moduleFlags = self->myenvobj->moduleFlags;
        self->moduleFlags.getReturnsNone = DEFAULT_GET_RETURNS_NONE;
        self->moduleFlags.cursorSetReturnsNone = DEFAULT_CURSOR_SET_RETURNS_NONE;

Attached PR only don't set cursorSetReturnsNone to DEFAULT_CURSOR_SET_RETURNS_NONE anymore if self->myenvobj is set.
msg292892 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2017-05-03 12:09
The second line in the else block was added... 14 years ago (!) by this commit:

commit 455d46f0d921337405ebd3a098c210f3614ae77c
Author: Gregory P. Smith <>
Date:   Wed Jul 9 04:45:59 2003 +0000

    bsddb 4.1.6:
     * Extended DB & DBEnv set_get_returns_none functionality to take a
       "level" instead of a boolean flag.  The boolean 0 and 1 values still
       have the same effect.  A value of 2 extends the "return None instead
       of raising an exception" behaviour to the DBCursor set methods.
       This will become the default behaviour in pybsddb 4.2.
     * Fixed a typo in DBCursor.join_item method that made it crash instead
       of returning a value.  Obviously nobody uses it.  Wrote a test case
       for join and join_item.
msg292908 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2017-05-03 15:46
It looks to me that the valid combinations of getReturnsNone and cursorSetReturnsNone flags are 00, 10 and 11. But this suspicious code allows to get 01. It looks as a bug to me.
msg292909 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2017-05-03 16:04
New changeset 2c27731901003cbcc64056fe9db725abe8484616 by Victor Stinner in branch '2.7':
bpo-30257: _bsddb: Fix newDBObject() (#1428)
msg292918 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2017-05-03 16:31
I don't understand well the consequence of the change, so I didn't document it in Misc/NEWS :-)
Date User Action Args
2022-04-11 14:58:46adminsetgithub: 74443
2017-05-05 08:30:16vstinnersetstatus: open -> closed
resolution: fixed
stage: resolved
2017-05-03 16:31:05vstinnersetmessages: + msg292918
2017-05-03 16:04:22vstinnersetmessages: + msg292909
2017-05-03 15:46:35serhiy.storchakasetnosy: + serhiy.storchaka
messages: + msg292908
2017-05-03 15:16:29gregory.p.smithsetnosy: + jcea, - gregory.p.smith
2017-05-03 12:46:52martin.panterlinkissue28149 superseder
2017-05-03 12:10:55vstinnersetnosy: + gregory.p.smith
2017-05-03 12:09:09vstinnersetmessages: + msg292892
2017-05-03 12:07:13vstinnersetpull_requests: + pull_request1533
2017-05-03 12:04:41vstinnercreate