Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Lancelot SIX via Gdb-patches <gdb-patches@sourceware.org>
To: Simon Marchi <simon.marchi@polymtl.ca>
Cc: gdb-patches@sourceware.org
Subject: Re: [PATCH 1/5] gdb/python: handle saving user registers in a frame unwinder
Date: Mon, 7 Jun 2021 19:01:31 +0100	[thread overview]
Message-ID: <20210607180131.dtq5ejhffpigicue@Plymouth> (raw)
In-Reply-To: <b254d726-6dff-6b9d-a6aa-0023e9b26e69@polymtl.ca>

On Mon, Jun 07, 2021 at 01:20:33PM -0400, Simon Marchi wrote:
> On 2021-06-07 1:07 p.m., Lancelot SIX via Gdb-patches wrote:
> > Hi,
> > 
> > I just have a minor stylistic remark in the python code in the test:
> > 
> >> […]
> >> +
> >> +    def __call__(self, pending_frame):
> >> +        pc_desc = pending_frame.architecture().registers().find("pc")
> >> +        pc = pending_frame.read_register(pc_desc)
> >> +
> >> +        sp_desc = pending_frame.architecture().registers().find("sp")
> >> +        sp = pending_frame.read_register(sp_desc)
> >> +
> >> +        block = gdb.block_for_pc(int(pc))
> >> +        if block == None:
> > 
> > When looking for None, it is usually prefered to use 'is None' instead
> > of '== None'.  The result is the same unless there is a strange overload
> > of __eq__.
> > 
> > This pattern can also be seen in patch 3 and 4 of your series (patch 4
> > using both '==' and 'is' to check for None).
> 
> I agree, that's the convention in Python.  It is not in our coding
> standards, but I suggest using flake8 to check the Python code, it
> reports this (and much more):

Hi,

Actually, this is mentioned in the PEP-8[1][2], which states in the
“Programming Recommandations” section:

    Comparisons to singletons like None should always be done with is or
		is not, never the equality operators.

This leads me to an annex question. Given that I still lack a lot of
experience with the overall codebase, I tend to pick this kind of small
stylistic details more easily than design and logic problems.  I do not
always point out those I see when I read the ML, but I can totally
understand those isolated stylistic comments can be considered as noise.
If so, please let me know!

> 
> 
>     $ flake8 testsuite/gdb.python/py-unwind-user-regs.py
>     testsuite/gdb.python/py-unwind-user-regs.py:52:18: E711 comparison to None should be 'if cond is None:'
>     testsuite/gdb.python/py-unwind-user-regs.py:55:17: E711 comparison to None should be 'if cond is None:'

I am currently running the testsuite against a patch that fixes those I
found. I’ll try to post it later tonight.

Lancelot.

> 
> Simon

[1] https://www.python.org/dev/peps/pep-0008/#programming-recommendations
[2] https://sourceware.org/gdb/wiki/Internals%20GDB-Python-Coding-Standards

-- 
Lancelot SIX

  reply	other threads:[~2021-06-07 18:02 UTC|newest]

Thread overview: 48+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-05-29 20:57 [PATCH 0/5] Fix for an assertion when unwinding with inline frames Andrew Burgess
2021-05-29 20:57 ` [PATCH 1/5] gdb/python: handle saving user registers in a frame unwinder Andrew Burgess
2021-06-07 14:50   ` Tom Tromey
2021-06-07 16:10     ` Andrew Burgess
2021-06-07 20:38       ` Tom Tromey
2021-06-07 17:07   ` Lancelot SIX via Gdb-patches
2021-06-07 17:20     ` Simon Marchi via Gdb-patches
2021-06-07 18:01       ` Lancelot SIX via Gdb-patches [this message]
2021-06-07 18:09         ` Simon Marchi via Gdb-patches
2021-06-07 20:12         ` Andrew Burgess
2021-06-21 19:41   ` Andrew Burgess
2021-05-29 20:57 ` [PATCH 2/5] gdb/python: move PyLong_From* calls into py-utils.c Andrew Burgess
2021-06-07 14:53   ` Tom Tromey
2021-06-21 19:42     ` Andrew Burgess
2021-05-29 20:57 ` [PATCH 3/5] gdb/python: add PendingFrame.level and Frame.level methods Andrew Burgess
2021-05-30  5:55   ` Eli Zaretskii via Gdb-patches
2021-05-30 18:34   ` Andrew Burgess
2021-05-30 18:54     ` Eli Zaretskii via Gdb-patches
2021-06-07 14:57   ` Tom Tromey
2021-06-21 19:42   ` Andrew Burgess
2021-05-29 20:57 ` [PATCH 4/5] gdb: prevent an assertion when computing the frame_id for an inline frame Andrew Burgess
2021-05-29 20:57 ` [PATCH 5/5] gdb: remove VALUE_FRAME_ID Andrew Burgess
2021-06-21 19:46 ` [PATCHv2 0/2] Fix for an assertion when unwinding with inline frames Andrew Burgess
2021-06-21 19:46   ` [PATCHv2 1/2] gdb: prevent an assertion when computing the frame_id for an inline frame Andrew Burgess
2021-07-05 11:39     ` Pedro Alves
2021-07-05 14:14       ` Simon Marchi via Gdb-patches
2021-06-21 19:46   ` [PATCHv2 2/2] gdb: remove VALUE_FRAME_ID Andrew Burgess
2021-06-29 17:53     ` Simon Marchi via Gdb-patches
2021-06-30 15:18       ` Andrew Burgess
2021-07-05 14:22         ` Simon Marchi via Gdb-patches
2021-07-20  9:10   ` [PATCHv3 0/2] Fix for an assertion when unwinding with inline frames Andrew Burgess
2021-07-20  9:10     ` [PATCHv3 1/2] gdb: prevent an assertion when computing the frame_id for an inline frame Andrew Burgess
2021-07-20  9:10     ` [PATCHv3 2/2] gdb: remove VALUE_FRAME_ID Andrew Burgess
2021-07-20 21:59     ` [PATCHv3 0/2] Fix for an assertion when unwinding with inline frames Simon Marchi via Gdb-patches
2021-07-26 11:11       ` Andrew Burgess
2021-07-26 13:57         ` Simon Marchi via Gdb-patches
2021-07-27 10:06           ` Andrew Burgess
2021-07-27 10:10     ` [PATCHv4] gdb: prevent an assertion when computing the frame_id for an inline frame Andrew Burgess
2021-08-09 15:41       ` [PATCHv5] " Andrew Burgess
2021-08-23  9:41         ` Andrew Burgess
2021-08-23 10:26           ` Pedro Alves
2021-08-23 12:31             ` Andrew Burgess
2021-09-20 10:04               ` Andrew Burgess
2021-09-20 12:24         ` Pedro Alves
2021-09-21 13:52           ` Andrew Burgess
2021-09-21 13:54         ` [PATCHv6] " Andrew Burgess
2021-09-22 14:14           ` Simon Marchi via Gdb-patches
2021-09-22 16:46             ` Andrew Burgess

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210607180131.dtq5ejhffpigicue@Plymouth \
    --to=gdb-patches@sourceware.org \
    --cc=lsix@lancelotsix.com \
    --cc=simon.marchi@polymtl.ca \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox