Skip to contentSkip to conversation

b4 ty unicode crash

DISCUSSION Mark Brown 2 participants 4 messages Dec 28, 2020 – Dec 29, 2020

lore
Share & tools
lore

Mark Brown

author
#0 lore raw

Hi,

When I run b4 ty and it finds what looks like:

https://lore.kernel.org/r/[email protected]

I get a traceback:

Generating 4 thank-you letters
Traceback (most recent call last):
File "/home/broonie/git/b4/b4/command.py", line 236, in <module>

    cmd()
  File "/home/broonie/git/b4/b4/command.py", line 219, in cmd
    cmdargs.func(cmdargs)
  File "/home/broonie/git/b4/b4/command.py", line 61, in cmd_ty
    b4.ty.main(cmdargs)
  File "/home/broonie/git/b4/b4/ty.py", line 638, in main
    auto_thankanator(cmdargs)
  File "/home/broonie/git/b4/b4/ty.py", line 392, in auto_thankanator
    send_messages(applied, cmdargs.gitdir, cmdargs.outdir, wantbranch, since=cmdargs.since)
  File "/home/broonie/git/b4/b4/ty.py", line 429, in send_messages
    msg = generate_am_thanks(gitdir, jsondata, branch, since)
  File "/home/broonie/git/b4/b4/ty.py", line 351, in generate_am_thanks
    msg = make_reply(thanks_template, jsondata)
  File "/home/broonie/git/b4/b4/ty.py", line 96, in make_reply
    msg['Cc'] = b4.format_addrs(allcc)

File "/home/broonie/git/b4/b4/__init__.py", line 2382, in format_addrs
addrs.add(email.utils.formataddr((LoreMessage.clean_header(pair[0]), LoreMessage.clean_header(pair[1]))))
File "/usr/lib/python3.7/email/utils.py", line 91, in formataddr
address.encode('ascii')
UnicodeEncodeError: 'ascii' codec can't encode characters in position 22-24: ordinal not in range(128)

#1 lore raw
Quoted 7 lines · Mark Brown

Hi,

When I run b4 ty and it finds what looks like:

   https://lore.kernel.org/r/[email protected]

I get a traceback:

Urgh, this uncovered a bug in Python:

In [5]: from email import utils

In [6]: utils.getaddresses(['foo <[email protected]>'])
Out[6]: [('foo', '[email protected]')]

In [7]: utils.getaddresses(['Shuming [范書銘] <[email protected]>']) Out[7]:
[('', 'Shuming'),
('', ''),
('', '范書銘'),
('', ''),
('', '[email protected]')]

It crashes when it tries to treat "范書銘" as an email address.

Quoted 3 lines

File "/usr/lib/python3.7/email/utils.py", line 91, in formataddr
address.encode('ascii')
UnicodeEncodeError: 'ascii' codec can't encode characters in position 22-24: ordinal not in range(128)

I'm not sure how to tackle this yet, but I'll try to figure it out.

Thanks for the report.

-K

#2 lore raw
In reply to Mark Brown
Quoted 7 lines · Mark Brown

Hi,

When I run b4 ty and it finds what looks like:

   https://lore.kernel.org/r/[email protected]

I get a traceback:

I have an attempted fix for this in master/stable-0.6.y, but it will only apply to future series you fetch with "b4 am", not any existing tracking files in ~/.local/share/b4. It's not a perfect fix, since the underlying Python bug is still there, but the changes should avoid hitting it in most cases.

-K

author
#3 lore raw
Quoted 4 lines · Konstantin Ryabitsev

I have an attempted fix for this in master/stable-0.6.y, but it will only apply to future series you fetch with "b4 am", not any existing tracking files in ~/.local/share/b4. It's not a perfect fix, since the underlying Python bug is still there, but the changes should avoid hitting it in most cases.

Great, thanks! I'll let you know if I run into anything.