Subject: mailman: File "/usr/lib/mailman/cron/cull_bad_shunt", line 77 SyntaxError with Python 3

From: Joe Pfeiffer <[email-masked]>
Date: Fri, 05 Jun 2020 08:56:57 -0600

Package: mailman
Version: 1:2.1.29-1+deb10u1
Severity: normal

Got the following this morning, after switching to Python 3:

From: [email-masked] (Cron Daemon)
To: [email-masked]
Subject: Cron <list@snowball> [ -x /usr/lib/mailman/cron/cull_bad_shunt ] && /usr/lib/mailman/cron/cull_bad_shunt
Date: Fri, 05 Jun 2020 04:30:01 -0600
Content-Type: text/plain; charset=UTF-8
X-Bogosity: Ham, tests=bogofilter, spamicity=0.000028, version=1.2.4

  File "/usr/lib/mailman/cron/cull_bad_shunt", line 77
    except getopt.error, msg:
                       ^
SyntaxError: invalid syntax

The issue appears to be that Python3 no longer accepts the comma in an
except block.

-- System Information:
Debian Release: bullseye/sid
  APT prefers testing
  APT policy: (700, 'testing'), (650, 'stable'), (600, 'unstable'), (550, 'experimental'), (500, 'oldstable')
Architecture: amd64 (x86_64)
Foreign Architectures: i386

Kernel: Linux 5.6.0-1-amd64 (SMP w/8 CPU cores)
Kernel taint flags: TAINT_OOT_MODULE, TAINT_UNSIGNED_MODULE
Locale: LANG=en_US.utf8, LC_CTYPE=en_US.utf8 (charmap=UTF-8), LANGUAGE=en_US.utf8 (charmap=UTF-8)
Shell: /bin/sh linked to /usr/bin/dash
Init: systemd (via /run/systemd/system)
LSM: AppArmor: enabled

Versions of packages mailman depends on:
ii  apache2 [httpd]        2.4.43-1
ii  cron [cron-daemon]     3.0pl1-136
ii  debconf [debconf-2.0]  1.5.74
ii  libc6                  2.30-4
ii  logrotate              3.16.0-3
ii  lsb-base               11.1.0
ii  python                 2.7.17-2
ii  python-dnspython       1.16.0-1
ii  ucf                    3.0038+nmu1

Versions of packages mailman recommends:
ii  exim4-daemon-light [mail-transport-agent]  4.93-15

Versions of packages mailman suggests:
pn  listadmin      <none>
ii  lynx           2.9.0dev.5-1
pn  mailman3-full  <none>
pn  spamassassin   <none>

-- debconf information excluded

---

From: Dominic Hargreaves <[email-masked]>
Date: Sun, 7 Jun 2020 15:52:55 +0100

> The issue appears to be that Python3 no longer accepts the comma in an

Mailman 2 will never support python 3 and it has been removed from
unstable and testing (see mailman3 for the future, but bear in mind it's
very much not a transparent upgrade). That said, as far as I can tell even
in unstable, /usr/bin/python is still pointing to /usr/bin/python2.7,
so you must have manually changed the link in /usr/bin/python behind
the packaging system's back?

It does appear to be a bug in this package that /usr/bin/python is used
(Python policy says that /usr/bin/python2 must be used if the
application requires a specific major version of python), but
in practical terms it doesn't appear need fixing since the default isn't
going to change in the stable releases.

I've attached a trivial patch for completeness (which I prepared before
I realised that there is no supported mechanism to actually switch
/usr/bin/python that I can see) in case it's of help. If you're manually
changing files in /usr/bin, you could of course just fix the scripts
to specify /usr/bin/python2 by hand, though I don't recommend this
approach.

Dominic
diff -Nru mailman-2.1.29/debian/rules mailman-2.1.29/debian/rules
--- mailman-2.1.29/debian/rules	2018-06-23 14:14:21.000000000 +0100
+++ mailman-2.1.29/debian/rules	2020-06-07 15:01:34.000000000 +0100
@@ -38,7 +38,8 @@
 		--with-groupname=list \
 		--with-mail-gid=daemon --with-cgi-gid=www-data \
 		--without-permcheck --with-mailhost=localhost \
-		--with-urlhost=localhost
+		--with-urlhost=localhost \
+		--with-python=/usr/bin/python2
 
 clean:
 	dh_testdir

---

From: Joe Pfeiffer <[email-masked]>
Date: Sun, 7 Jun 2020 11:30:55 -0600

Dominic Hargreaves writes:
>very much not a transparent upgrade).

Yeah, the amount of work I anticipate for the switch is why I've been
procrastinating.  I wasn't aware it had been removed from unstable and
testing; it sounds like I'm going to have to bite the bullet sooner
rather than later....

>That said, as far as I can tell even

At this point, update-alternatives lists python3 as the "auto"
alternative, so that appears to be the default (I'm nothing resembling
an expert on Debian policies or packaging, so it's entirely possible
I'm reading more into that than I should).

>to specify /usr/bin/python2 by hand, though I don't recommend this

That's what I've wound up doing (after filing the bug report, I found
several more scripts in mailman that also break with python3).
-- 
Joe Pfeiffer                                   575.525.2764 (H)
1440 Tierra del Sol Dr                         575.496.3501 (C)
Las Cruces, NM 88007-5548

---

From: Dominic Hargreaves <[email-masked]>
Date: Sun, 7 Jun 2020 20:06:22 +0100

> testing; it sounds like I'm going to have to bite the bullet sooner

Yep, I sympathise - I have the same issue (speaking as one of the
maintainers of alioth-lists.debian.net as well as some other installs.
(For the avoidance of doubt, I'm not the maintainer of the mailman
package.)

I believe it's already been determined that python 2 will not be shipped
with bullseye.

> I'm reading more into that than I should).

This confused me, since Python in Debian doesn't have alternatives set
up - but a quick web search reveals various people suggesting receipes
for setting this up by hand, so at a guess you must have done this,
aybe following something like this?

https://stackoverflow.com/questions/43062608/how-to-update-alternatives-to-python-3-without-breaking-apt

The default you're seeing is not a part of the Debian system.

I mention this merely as a clarification for future readers of the
bug report. Glad to see that you've managed to get things working
for yourself :)

Cheers
Dominic