Skip to content

Commit 25bc259

Browse files
committed
update checkdbs
1 parent d2173b4 commit 25bc259

1 file changed

Lines changed: 8 additions & 24 deletions

File tree

cron/checkdbs

Lines changed: 8 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ def main():
114114

115115

116116
def pending_requests(mlist):
117-
# Must return a byte string
117+
# Must return a string
118118
lcset = Utils.GetCharSet(mlist.preferred_language)
119119
pending = []
120120
first = 1
@@ -124,8 +124,8 @@ def pending_requests(mlist):
124124
first = 0
125125
when, addr, fullname, passwd, digest, lang = mlist.GetRecord(id)
126126
if fullname:
127-
if isinstance(fullname, str):
128-
fullname = fullname.encode(lcset, 'replace')
127+
if isinstance(fullname, bytes):
128+
fullname = fullname.decode(lcset, 'replace')
129129
fullname = ' (%s)' % fullname
130130
pending.append(' %s%s %s' % (addr, fullname, time.ctime(when)))
131131
first = 1
@@ -143,34 +143,18 @@ def pending_requests(mlist):
143143
info = mlist.GetRecord(id)
144144
when, sender, subject, reason, text, msgdata = mlist.GetRecord(id)
145145
subject = Utils.oneline(subject, lcset)
146+
if isinstance(subject, bytes):
147+
subject = subject.decode(lcset, 'replace')
146148
date = time.ctime(when)
147149
reason = _(reason)
148150
pending.append(_("""\
149151
From: %(sender)s on %(date)s
150152
Subject: %(subject)s
151153
Cause: %(reason)s"""))
152154
pending.append('')
153-
# Coerce all items in pending to a Unicode so we can join them
154-
upending = []
155-
charset = Utils.GetCharSet(mlist.preferred_language)
156-
for s in pending:
157-
if isinstance(s, str):
158-
upending.append(s)
159-
else:
160-
upending.append(str(s, charset, 'replace'))
161-
# Make sure that the text we return from here can be encoded to a byte
162-
# string in the charset of the list's language. This could fail if for
163-
# example, the request was pended while the list's language was French,
164-
# but then it was changed to English before checkdbs ran.
165-
text = u'\n'.join(upending)
166-
charset = Charset(Utils.GetCharSet(mlist.preferred_language))
167-
incodec = charset.input_codec or 'ascii'
168-
outcodec = charset.output_codec or 'ascii'
169-
if isinstance(text, str):
170-
return text.encode(outcodec, 'replace')
171-
# Be sure this is a byte string encodeable in the list's charset
172-
utext = str(text, incodec, 'replace')
173-
return utext.encode(outcodec, 'replace')
155+
156+
# Join all lines with newlines and return as a string
157+
return '\n'.join(pending)
174158

175159
def auto_discard(mlist):
176160
# Discard old held messages

0 commit comments

Comments
 (0)