Skip to content

Fix %-interpolation error - #251

Open
me-and wants to merge 1 commit into
OfflineIMAP:masterfrom
me-and:error-error
Open

Fix %-interpolation error#251
me-and wants to merge 1 commit into
OfflineIMAP:masterfrom
me-and:error-error

Conversation

@me-and

@me-and me-and commented Jun 18, 2026

Copy link
Copy Markdown
Contributor

9c352d7 (Always pass an exception as first argument of ui.error,
2026-04-01) rearranged some of the arguments to ui.error in
folder/IMAP.py, but while it removed one of the %-interpolation
entries in the string to be interpolated, it didn't remove the argument
in the interpolation tuple. This leads to errors like the below:

  File "offlineimap/folder/IMAP.py", line 863, in _fetch_from_imap
    "While fetching msg %r in folder %r."
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    " Query: %s Retrying (%d/%d)" % (
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~
        e, uids, self.name, query,
        ~~~~~~~~~~~~~~~~~~~~~~~~~~
        retry_num - fails_left, retry_num))
        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
TypeError: %d format: a real number is required, not str

Remove the argument from the interpolation tuple that has now been
removed from the string, so the tuple parameters and string contents
match again.

Signed-off-by: Adam Dinwoodie adam@dinwoodie.org

This PR

  • I've read the DCO.
  • I've read the Coding Guidelines
  • The relevant informations about the changes stands in the commit message, not here in the message of the pull request.
  • Code changes follow the style of the files they change.
  • Code is tested (provide details).

Additional information

Tested by applying the patch and re-running. I now get the expected error message:

ERROR: While fetching msg '15788' in folder 'To/PD'. Query: (X-GM-LABELS BODY.PEEK[]) Retrying (1/2)

9c352d7 (Always pass an exception as first argument of ui.error,
2026-04-01) rearranged some of the arguments to `ui.error` in
`folder/IMAP.py`, but while it removed one of the %-interpolation
entries in the string to be interpolated, it didn't remove the argument
in the interpolation tuple.  This leads to errors like the below:

      File "offlineimap/folder/IMAP.py", line 863, in _fetch_from_imap
        "While fetching msg %r in folder %r."
        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        " Query: %s Retrying (%d/%d)" % (
        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~
            e, uids, self.name, query,
            ~~~~~~~~~~~~~~~~~~~~~~~~~~
            retry_num - fails_left, retry_num))
            ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    TypeError: %d format: a real number is required, not str

Remove the argument from the interpolation tuple that has now been
removed from the string, so the tuple parameters and string contents
match again.

Signed-off-by: Adam Dinwoodie <adam@dinwoodie.org>
me-and added a commit to me-and/nixcfg that referenced this pull request Jun 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant