Skip to content

Commit 1b14050

Browse files
committed
Fix missing % interpolation in print(C_('...(var)s...'),) calls
check_perms and Mailman/MTA/Postfix.py both had Python 2-style print C_('...') % locals(), statements where the migration to Python 3 dropped the % locals() substitution, leaving literal %(varname)s in error output. Also fix two bare print -> print() in Postfix.py.
1 parent 898bbd0 commit 1b14050

2 files changed

Lines changed: 12 additions & 12 deletions

File tree

Mailman/MTA/Postfix.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -442,12 +442,12 @@ def checkperms(state):
442442
if stat and (stat[ST_MODE] & targetmode) != targetmode:
443443
state.ERRORS += 1
444444
octmode = oct(stat[ST_MODE])
445-
print(C_('%(file)s permissions must be 0664 (got %(octmode)s)'),)
445+
print(C_('%(file)s permissions must be 0664 (got %(octmode)s)') % locals())
446446
if state.FIX:
447447
print(C_('(fixing)'))
448448
os.chmod(file, stat[ST_MODE] | targetmode)
449449
else:
450-
print
450+
print()
451451
# Make sure the corresponding .db files are owned by the Mailman user.
452452
# We don't need to check the group ownership of the file, since
453453
# check_perms checks this itself.
@@ -481,7 +481,7 @@ def checkperms(state):
481481
if stat and (stat[ST_MODE] & targetmode) != targetmode:
482482
state.ERRORS += 1
483483
octmode = oct(stat[ST_MODE])
484-
print(C_('%(dbfile)s permissions must be 0664 (got %(octmode)s)'),)
484+
print(C_('%(dbfile)s permissions must be 0664 (got %(octmode)s)') % locals())
485485
if state.FIX:
486486
print(C_('(fixing)'))
487487
os.chmod(dbfile, stat[ST_MODE] | targetmode)

bin/check_perms

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ def checkwalk(arg, dirname, names):
141141
octperms = oct(targetperms)
142142
if S_ISDIR(mode) and (mode & targetperms) != targetperms:
143143
arg.ERRORS += 1
144-
print(C_('directory permissions must be %(octperms)s: %(path)s'),)
144+
print(C_('directory permissions must be %(octperms)s: %(path)s') % locals())
145145
if STATE.FIX:
146146
print(C_('(fixing)'))
147147
os.chmod(path, mode | targetperms)
@@ -150,7 +150,7 @@ def checkwalk(arg, dirname, names):
150150
elif os.path.splitext(path)[1] in ('.py', '.pyc', '.pyo'):
151151
octperms = oct(PYFILEPERMS)
152152
if mode & PYFILEPERMS != PYFILEPERMS:
153-
print(C_('source perms must be %(octperms)s: %(path)s'),)
153+
print(C_('source perms must be %(octperms)s: %(path)s') % locals())
154154
arg.ERRORS += 1
155155
if STATE.FIX:
156156
print(C_('(fixing)'))
@@ -161,7 +161,7 @@ def checkwalk(arg, dirname, names):
161161
# Article files must be group writeable
162162
octperms = oct(ARTICLEFILEPERMS)
163163
if mode & ARTICLEFILEPERMS != ARTICLEFILEPERMS:
164-
print(C_('article db files must be %(octperms)s: %(path)s'),)
164+
print(C_('article db files must be %(octperms)s: %(path)s') % locals())
165165
arg.ERRORS += 1
166166
if STATE.FIX:
167167
print(C_('(fixing)'))
@@ -187,7 +187,7 @@ def checkall():
187187
continue
188188
if (mode & DIRPERMS) != DIRPERMS:
189189
STATE.ERRORS += 1
190-
print(C_('directory must be at least 02775: %(d)s'),)
190+
print(C_('directory must be at least 02775: %(d)s') % locals())
191191
if STATE.FIX:
192192
print(C_('(fixing)'))
193193
os.chmod(d, mode | DIRPERMS)
@@ -204,7 +204,7 @@ def checkarchives():
204204
mode = statmode(private)
205205
if mode & S_IROTH:
206206
STATE.ERRORS += 1
207-
print(C_('%(private)s must not be other-readable'),)
207+
print(C_('%(private)s must not be other-readable') % locals())
208208
if STATE.FIX:
209209
print(C_('(fixing)'))
210210
os.chmod(private, mode & ~S_IROTH)
@@ -253,7 +253,7 @@ def checkarchivedbs():
253253
continue
254254
if mode & S_IRWXO:
255255
STATE.ERRORS += 1
256-
print(C_('%(dbdir)s "other" perms must be 000'),)
256+
print(C_('%(dbdir)s "other" perms must be 000') % locals())
257257
if STATE.FIX:
258258
print(C_('(fixing)'))
259259
os.chmod(dbdir, mode & ~S_IRWXO)
@@ -272,7 +272,7 @@ def checkcgi():
272272
mode = statmode(path)
273273
if mode & S_IXGRP and not mode & S_ISGID:
274274
STATE.ERRORS += 1
275-
print(C_('%(path)s must be set-gid'),)
275+
print(C_('%(path)s must be set-gid') % locals())
276276
if STATE.FIX:
277277
print(C_('(fixing)'))
278278
os.chmod(path, mode | S_ISGID)
@@ -286,7 +286,7 @@ def checkmail():
286286
mode = statmode(wrapper)
287287
if not mode & S_ISGID:
288288
STATE.ERRORS += 1
289-
print(C_('%(wrapper)s must be set-gid'),)
289+
print(C_('%(wrapper)s must be set-gid') % locals())
290290
if STATE.FIX:
291291
print(C_('(fixing)'))
292292
os.chmod(wrapper, mode | S_ISGID)
@@ -346,7 +346,7 @@ def checkdata():
346346
continue
347347
if (mode & targetmode) != targetmode:
348348
STATE.ERRORS += 1
349-
print(C_('file permissions must be at least 660: %(path)s'),)
349+
print(C_('file permissions must be at least 660: %(path)s') % locals())
350350
if STATE.FIX:
351351
print(C_('(fixing)'))
352352
os.chmod(path, mode | targetmode)

0 commit comments

Comments
 (0)