Issue 30257: _bsddb: else misleadingly indented (original) (raw)

This issue has been migrated to GitHub: https://github.com/python/cpython/issues/74443

classification

Title: _bsddb: else misleadingly indented
Type: Stage: resolved
Components: Extension Modules Versions: Python 2.7

process

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] else ^~~~ /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/_bsddb.so I agree that the indentation is surprising and looks like a bug. if (self->myenvobj) self->moduleFlags = self->myenvobj->moduleFlags; else 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 <greg@mad-scientist.com> 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) https://github.com/python/cpython/commit/2c27731901003cbcc64056fe9db725abe8484616
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 :-)
History
Date User Action Args
2022-04-11 14:58:46 admin set github: 74443
2017-05-05 08:30:16 vstinner set status: open -> closedresolution: fixedstage: resolved
2017-05-03 16:31:05 vstinner set messages: +
2017-05-03 16:04:22 vstinner set messages: +
2017-05-03 15:46:35 serhiy.storchaka set nosy: + serhiy.storchakamessages: +
2017-05-03 15:16:29 gregory.p.smith set nosy: + jcea, - gregory.p.smith
2017-05-03 12:46:52 martin.panter link issue28149 superseder
2017-05-03 12:10:55 vstinner set nosy: + gregory.p.smith
2017-05-03 12:09:09 vstinner set messages: +
2017-05-03 12:07:13 vstinner set pull_requests: + <pull%5Frequest1533>
2017-05-03 12:04:41 vstinner create