Author: futatuki
Date: Sun Jan 17 13:16:59 2021
New Revision: 1885600

URL: http://svn.apache.org/viewvc?rev=1885600&view=rev
Log:
Follow up to r1884427, r1885557: mailer.py: Fix mixture of bytes/str.

* tools/hook-scripts/mailer/mailer.py
  (): Rename imported function urllib.parse.quote from urlib_parse_quote to
   _url_quote.
  (remove_leading_slashes): Treat path as a bytes, if it is not None.
  (Commit.__init__): Fix the case that SVN_PROP_REVISION_LOG property is NULL.
  (DiffURLSelections._get_url): Use renamed urllib.parse.quote function and
   'if' expression for readability.
  (generate_content): Set data.log as s str.
  (TextCommitRenderer.render): Treat data.log as a str.

Modified:
    subversion/trunk/tools/hook-scripts/mailer/mailer.py

Modified: subversion/trunk/tools/hook-scripts/mailer/mailer.py
URL: 
http://svn.apache.org/viewvc/subversion/trunk/tools/hook-scripts/mailer/mailer.py?rev=1885600&r1=1885599&r2=1885600&view=diff
==============================================================================
--- subversion/trunk/tools/hook-scripts/mailer/mailer.py (original)
+++ subversion/trunk/tools/hook-scripts/mailer/mailer.py Sun Jan 17 13:16:59 
2021
@@ -47,7 +47,7 @@
 import os
 import sys
 import configparser
-from urllib.parse import quote as urllib_parse_quote
+from urllib.parse import quote as _url_quote
 import time
 import subprocess
 from io import BytesIO
@@ -120,7 +120,7 @@ def main(pool, cmd, config_fname, repos_
 
 
 def remove_leading_slashes(path):
-  while path and path[0] == '/':
+  while path and path[0:1] == b'/':
     path = path[1:]
   return path
 
@@ -431,8 +431,8 @@ class Commit(Messenger):
 
     self.changelist = sorted(editor.get_changes().items())
 
-    log = repos.get_rev_prop(svn.core.SVN_PROP_REVISION_LOG) or ''
-    log = log.decode('utf-8')
+    log = (repos.get_rev_prop(svn.core.SVN_PROP_REVISION_LOG)
+           or b'').decode('utf-8')
 
     # collect the set of groups and the unique sets of params for the options
     self.groups = { }
@@ -708,9 +708,9 @@ class DiffURLSelections:
     # parameters for the configuration module, otherwise we may get
     # KeyError exceptions.
     params = self.params.copy()
-    params['path'] = change.path and urllib_parse_quote(change.path) or None
-    params['base_path'] = change.base_path and 
urllib_parse_quote(change.base_path) \
-                          or None
+    params['path'] = _url_quote(change.path) if change.path else None
+    params['base_path'] = (_url_quote(change.base_path)  
+                           if change.base_path else None)
     params['rev'] = repos_rev
     params['base_rev'] = change.base_rev
 
@@ -764,7 +764,8 @@ def generate_content(renderer, cfg, repo
     author=repos.author,
     date=date,
     rev=repos.rev,
-    log=repos.get_rev_prop(svn.core.SVN_PROP_REVISION_LOG) or '',
+    log=(repos.get_rev_prop(svn.core.SVN_PROP_REVISION_LOG)
+         or b'').decode('utf-8'),
     commit_url=commit_url,
     added_data=generate_list('A', changelist, paths, True),
     replaced_data=generate_list('R', changelist, paths, True),
@@ -1110,7 +1111,7 @@ class TextCommitRenderer:
     else:
       w('\n')
 
-    w('Log:\n%s\n\n' % data.log.strip().decode('utf-8'))
+    w('Log:\n%s\n\n' % data.log.strip())
 
     # print summary sections
     self._render_list('Added', data.added_data)


Reply via email to