Skip to content

[3.10] Fix compiler warning for misleading guarding in the tkinter (GH-26244)#26251

Merged
pablogsal merged 1 commit intopython:3.10from
miss-islington:backport-95d0471-3.10
May 19, 2021
Merged

[3.10] Fix compiler warning for misleading guarding in the tkinter (GH-26244)#26251
pablogsal merged 1 commit intopython:3.10from
miss-islington:backport-95d0471-3.10

Conversation

@miss-islington
Copy link
Copy Markdown
Contributor

The newest gcc emmits this warning:

/Modules/_tkinter.c:272:9: warning: this ‘if’ clause does not guard... [-Wmisleading-indentation]
  272 |         if(tcl_lock)PyThread_acquire_lock(tcl_lock, 1); tcl_tstate = tstate; }
      |         ^~
/Modules/_tkinter.c:2869:5: note: in expansion of macro ‘LEAVE_PYTHON’
 2869 |     LEAVE_PYTHON
      |     ^~~~~~~~~~~~
/Modules/_tkinter.c:243:5: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the ‘if’
  243 |     (*(PyThreadState**)Tcl_GetThreadData(&state_key, sizeof(PyThreadState*)))
      |     ^
/Modules/_tkinter.c:272:57: note: in expansion of macro ‘tcl_tstate’
  272 |         if(tcl_lock)PyThread_acquire_lock(tcl_lock, 1); tcl_tstate = tstate; }
      |                                                         ^~~~~~~~~~
/Modules/_tkinter.c:2869:5: note: in expansion of macro ‘LEAVE_PYTHON’
 2869 |     LEAVE_PYTHON

that's because the macro packs together two statements at the same level
as the "if". The warning is misleading but is very noisy so it makes
sense to fix it.
(cherry picked from commit 95d0471)

Co-authored-by: Pablo Galindo Pablogsal@gmail.com

…-26244)

The newest gcc emmits this warning:

```
/Modules/_tkinter.c:272:9: warning: this ‘if’ clause does not guard... [-Wmisleading-indentation]
  272 |         if(tcl_lock)PyThread_acquire_lock(tcl_lock, 1); tcl_tstate = tstate; }
      |         ^~
/Modules/_tkinter.c:2869:5: note: in expansion of macro ‘LEAVE_PYTHON’
 2869 |     LEAVE_PYTHON
      |     ^~~~~~~~~~~~
/Modules/_tkinter.c:243:5: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the ‘if’
  243 |     (*(PyThreadState**)Tcl_GetThreadData(&state_key, sizeof(PyThreadState*)))
      |     ^
/Modules/_tkinter.c:272:57: note: in expansion of macro ‘tcl_tstate’
  272 |         if(tcl_lock)PyThread_acquire_lock(tcl_lock, 1); tcl_tstate = tstate; }
      |                                                         ^~~~~~~~~~
/Modules/_tkinter.c:2869:5: note: in expansion of macro ‘LEAVE_PYTHON’
 2869 |     LEAVE_PYTHON

```

that's because the macro packs together two statements at the same level
as the "if". The warning is misleading but is very noisy so it makes
sense to fix it.
(cherry picked from commit 95d0471)

Co-authored-by: Pablo Galindo <Pablogsal@gmail.com>
@miss-islington
Copy link
Copy Markdown
Contributor Author

@pablogsal: Status check is done, and it's a failure ❌ .

@miss-islington
Copy link
Copy Markdown
Contributor Author

@pablogsal: Status check is done, and it's a failure ❌ .

@pablogsal pablogsal merged commit 46f96f0 into python:3.10 May 19, 2021
@miss-islington miss-islington deleted the backport-95d0471-3.10 branch May 19, 2021 18:47
@miss-islington
Copy link
Copy Markdown
Contributor Author

@pablogsal: Status check is done, and it's a success ✅ .

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants