Skip to content

Commit f0dbedd

Browse files
jared mauchjared mauch
authored andcommitted
Squashed divergence period: Python 3 migration and fixes
This commit combines all work done during the divergence period from cpanel/main, from the divergence point (b00d5ae) through the convergence point where cpanel fixes were merged in (5f2368e). Includes: - Python 2 to Python 3 migration work - Pickle protocol handling fixes - Encoding and string handling improvements - Bug fixes and compatibility improvements - Configuration and build system updates Original commits: 720 commits from b00d5ae to 5f2368e
1 parent b00d5ae commit f0dbedd

1,136 files changed

Lines changed: 128331 additions & 57767 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.gitignore

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
mailman.po~
2+
Mailman/Archiver/Makefile
3+
Mailman/Bouncers/Makefile
4+
Mailman/Cgi/Makefile
5+
Mailman/Commands/Makefile
6+
Mailman/Defaults.py
7+
Mailman/Gui/Makefile
8+
Mailman/Handlers/Makefile
9+
Mailman/Logging/Makefile
10+
Mailman/MTA/Makefile
11+
Mailman/Makefile
12+
Mailman/Queue/Makefile
13+
Mailman/__pycache__/
14+
Mailman/mm_cfg.py.dist
15+
Makefile
16+
bin/Makefile
17+
build/
18+
config.log
19+
config.status
20+
cron/Makefile
21+
cron/crontab.in
22+
messages/Makefile
23+
messages/ar/LC_MESSAGES/mailman.mo
24+
messages/ast/LC_MESSAGES/mailman.mo
25+
messages/ca/LC_MESSAGES/mailman.mo
26+
messages/cs/LC_MESSAGES/mailman.mo
27+
messages/da/LC_MESSAGES/mailman.mo
28+
messages/de/LC_MESSAGES/mailman.mo
29+
messages/el/LC_MESSAGES/mailman.mo
30+
messages/eo/LC_MESSAGES/mailman.mo
31+
messages/es/LC_MESSAGES/mailman.mo
32+
messages/et/LC_MESSAGES/mailman.mo
33+
messages/eu/LC_MESSAGES/mailman.mo
34+
messages/fa/LC_MESSAGES/mailman.mo
35+
messages/fi/LC_MESSAGES/mailman.mo
36+
messages/fr/LC_MESSAGES/mailman.mo
37+
messages/gl/LC_MESSAGES/mailman.mo
38+
messages/he/LC_MESSAGES/mailman.mo
39+
messages/hr/LC_MESSAGES/mailman.mo
40+
messages/hu/LC_MESSAGES/mailman.mo
41+
messages/ia/LC_MESSAGES/mailman.mo
42+
messages/it/LC_MESSAGES/mailman.mo
43+
messages/ja/LC_MESSAGES/mailman.mo
44+
messages/ko/LC_MESSAGES/mailman.mo
45+
messages/lt/LC_MESSAGES/mailman.mo
46+
messages/nl/LC_MESSAGES/mailman.mo
47+
messages/no/LC_MESSAGES/mailman.mo
48+
messages/pl/LC_MESSAGES/mailman.mo
49+
messages/pt/LC_MESSAGES/mailman.mo
50+
messages/pt_BR/LC_MESSAGES/mailman.mo
51+
messages/ro/LC_MESSAGES/mailman.mo
52+
messages/ru/LC_MESSAGES/mailman.mo
53+
messages/sk/LC_MESSAGES/mailman.mo
54+
messages/sl/LC_MESSAGES/mailman.mo
55+
messages/sr/LC_MESSAGES/mailman.mo
56+
messages/sv/LC_MESSAGES/mailman.mo
57+
messages/tr/LC_MESSAGES/mailman.mo
58+
messages/uk/LC_MESSAGES/mailman.mo
59+
messages/vi/LC_MESSAGES/mailman.mo
60+
messages/zh_CN/LC_MESSAGES/mailman.mo
61+
messages/zh_TW/LC_MESSAGES/mailman.mo
62+
misc/Makefile
63+
misc/mailman
64+
misc/paths.py
65+
scripts/Makefile
66+
src/Makefile
67+
src/admin
68+
src/admindb
69+
src/common.o
70+
src/confirm
71+
src/create
72+
src/edithtml
73+
src/listinfo
74+
src/mailman
75+
src/options
76+
src/private
77+
src/rmlist
78+
src/roster
79+
src/subscribe
80+
src/vsnprintf.o
81+
templates/Makefile
82+
tests/Makefile
83+
tests/bounces/Makefile
84+
tests/msgs/Makefile

Mailman/Archiver/Archiver.py

Lines changed: 32 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -88,21 +88,17 @@ def InitVars(self):
8888
# symbolic links.
8989
omask = os.umask(0)
9090
try:
91-
try:
92-
os.mkdir(self.archive_dir()+'.mbox', 0o02775)
93-
except OSError as e:
94-
if e.errno != errno.EEXIST: raise
95-
# We also create an empty pipermail archive directory into
96-
# which we'll drop an empty index.html file into. This is so
97-
# that lists that have not yet received a posting have
98-
# /something/ as their index.html, and don't just get a 404.
99-
try:
100-
os.mkdir(self.archive_dir(), 0o02775)
101-
except OSError as e:
102-
if e.errno != errno.EEXIST: raise
91+
# Create mbox directory with proper permissions
92+
mbox_dir = self.archive_dir() + '.mbox'
93+
os.makedirs(mbox_dir, mode=0o02775, exist_ok=True)
94+
95+
# Create archive directory with proper permissions
96+
archive_dir = self.archive_dir()
97+
os.makedirs(archive_dir, mode=0o02775, exist_ok=True)
98+
10399
# See if there's an index.html file there already and if not,
104100
# write in the empty archive notice.
105-
indexfile = os.path.join(self.archive_dir(), 'index.html')
101+
indexfile = os.path.join(archive_dir, 'index.html')
106102
fp = None
107103
try:
108104
fp = open(indexfile)
@@ -136,8 +132,7 @@ def GetBaseArchiveURL(self):
136132
if self.archive_private:
137133
return url
138134
else:
139-
hostname = re.match('[^:]*://([^/]*)/.*', url).group(1)\
140-
or mm_cfg.DEFAULT_URL_HOST
135+
hostname = re.match(r'[^:]*://([^/]*)/.*', url, re.IGNORECASE).group(1)
141136
url = mm_cfg.PUBLIC_ARCHIVE_URL % {
142137
'listname': self.internal_name(),
143138
'hostname': hostname
@@ -174,12 +169,17 @@ def ExternalArchive(self, ar, txt):
174169
'hostname': self.host_name,
175170
})
176171
cmd = ar % d
177-
extarch = os.popen(cmd, 'w')
178-
extarch.write(txt)
172+
try:
173+
with os.popen(cmd, 'w') as extarch:
174+
extarch.write(txt)
175+
except OSError as e:
176+
syslog('error', 'Failed to execute external archiver: %s\nError: %s',
177+
cmd, str(e))
178+
return
179179
status = extarch.close()
180180
if status:
181-
syslog('error', 'external archiver non-zero exit status: %d\n',
182-
(status & 0xff00) >> 8)
181+
syslog('error', 'External archiver non-zero exit status: %d\nCommand: %s',
182+
(status & 0xff00) >> 8, cmd)
183183

184184
#
185185
# archiving in real time this is called from list.post(msg)
@@ -193,7 +193,14 @@ def ArchiveMail(self, msg):
193193
# We don't need an extra archiver lock here because we know the list
194194
# itself must be locked.
195195
if mm_cfg.ARCHIVE_TO_MBOX in (1, 2):
196-
self.__archive_to_mbox(msg)
196+
try:
197+
mbox = self.__archive_file(self.ArchiveFileName())
198+
mbox.AppendMessage(msg)
199+
mbox.fp.close()
200+
except IOError as msg:
201+
syslog('error', 'Archive file access failure:\n\t%s %s',
202+
self.ArchiveFileName(), msg)
203+
raise
197204
if mm_cfg.ARCHIVE_TO_MBOX == 1:
198205
# Archive to mbox only.
199206
return
@@ -206,12 +213,11 @@ def ArchiveMail(self, msg):
206213
self.ExternalArchive(mm_cfg.PRIVATE_EXTERNAL_ARCHIVER, txt)
207214
else:
208215
# use the internal archiver
209-
f = StringIO(txt)
210-
from . import HyperArch
211-
h = HyperArch.HyperArchive(self)
212-
h.processUnixMailbox(f)
213-
h.close()
214-
f.close()
216+
with StringIO(txt) as f:
217+
from . import HyperArch
218+
h = HyperArch.HyperArchive(self)
219+
h.processUnixMailbox(f)
220+
h.close()
215221

216222
#
217223
# called from MailList.MailList.Save()

0 commit comments

Comments
 (0)