Skip to content
Snippets Groups Projects

[fix] #366 : Remove TyperError-inducing call to DuniterError

Merged atrax requested to merge atrax/silkaj:366_wrong_call_dunitererror into dev

Remove an unnecessary and TypeError-inducing call to DuniterError in silkaj.wot

Close #366 (closed)

Merge request reports

Loading
Loading

Activity

Filter activity
  • Approvals
  • Assignees & reviewers
  • Comments (from bots)
  • Comments (from users)
  • Commits & branches
  • Edits
  • Labels
  • Lock status
  • Mentions
  • Merge request status
  • Tracking
  • added Bug Web of Trust labels

  • atrax added 1 commit

    added 1 commit

    Compare with previous version

  • atrax added 1 commit

    added 1 commit

    Compare with previous version

  • atrax added 1 commit

    added 1 commit

    Compare with previous version

  • I think it is nice that errors get raised when they should. (NB: I am relatively new to coding, I have not seriously managed errors for now)

    Here we have two different errors :

    • DuniterError : is not a member -> I think this is useful.
    • TypeError : DuniterError is not subscriptable. -> this is a bug.

    For this last, we may change the code to :

        try:
            return await client(wot.identity_of, pubkey_uid)
        except DuniterError as e:
            raise e
        except ValueError as e:
            pass

    I saw you are doing this for #300 (closed), I looked at your branch 300_balance_display_uid. I think this particular change should be part of the MR for #300 (closed).

    I would advise you to use is_member() instead of identity_of(). is_member() will catch the error and return False, which is more or less what you want.

    I would like to know what @moul thinks about it.

  • I think it is nice that errors get raised when they should. (NB: I am relatively new to coding, I have not seriously managed errors for now)

    That's the way to go. Your example doesn't change the core logic, but it might be valuable for other contributors working with identity_of while still fixing the bug.

    I saw you are doing this for #300 (closed), I looked at your branch 300_balance_display_uid. I think this particular change should be part of the MR for #300 (closed).

    I can include it there.

    I would advise you to use is_member() instead of identity_of(). is_member() will catch the error and return False, which is more or less what you want.

    Gonna check that.

  • Moul changed milestone to %0.9.0

    changed milestone to %0.9.0

  • Sorry for the time I needed to check this one.

    @atrax, did you check whether it's not breaking any features built on top of wot.identity_of()?

  • Moul approved this merge request

    approved this merge request

  • Moul assigned to @moul

    assigned to @moul

  • Moul requested review from @moul

    requested review from @moul

  • @moul Sorry I was very busy the last few weeks.

    Exceptions are handled properly with each wot.identity_of() call, except in command.list_blocks(). Otherwise the except block doesn't specify any specific exception whenever wot.identity_of() is called, which explains why this bug wasn't an issue so far.

    I'm gonna wrap it up properly with a try/except block in command.list_blocks(). I just need to figure out what is expected in case there is no identity attached to the pubkey.

  • atrax added 11 commits

    added 11 commits

    Compare with previous version

  • Since only members can issue blocks, this change doesn't affect command.list_blocks(). It's also caught in tx_history.generate_header(), wot.is_member(), wot.identities_from_pubkeys(), wot.id_pubkey_correspondence().

    It doesn't break anything in current code, yet it fixes how this exception is handled. For me it's good so far.

  • I was discovering the try/catch exception and added this mess.

    Thanks for checking. Approved. Feel free to merge once you get an approval from one of us.

  • Moul assigned to @atrax and unassigned @moul

    assigned to @atrax and unassigned @moul

  • merged

Please register or sign in to reply
Loading