diff options
author | Abseil Team <absl-team@google.com> | 2021-02-12 12:31:03 -0800 |
---|---|---|
committer | Copybara-Service <copybara-worker@google.com> | 2021-02-12 12:31:30 -0800 |
commit | 73b4b0f5e3e52caa7c026c3742e4abd6a52dffc8 (patch) | |
tree | a707ff59c9e54c7b75270c717fecd8d280013ee9 /absl/flags/_argument_parser.py | |
parent | 2444faee6d820c024c26380f60aa5e12fdf4b3a4 (diff) | |
download | absl-py-73b4b0f5e3e52caa7c026c3742e4abd6a52dffc8.tar.gz |
Fix CsvListSerializer to honor its list_sep parameter.
PiperOrigin-RevId: 357245847
Change-Id: I7637199f61f23e78646720ad406f539c89962fe3
Diffstat (limited to 'absl/flags/_argument_parser.py')
-rw-r--r-- | absl/flags/_argument_parser.py | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/absl/flags/_argument_parser.py b/absl/flags/_argument_parser.py index a706191..3d316ab 100644 --- a/absl/flags/_argument_parser.py +++ b/absl/flags/_argument_parser.py @@ -499,12 +499,14 @@ class CsvListSerializer(ArgumentSerializer): if six.PY2: # In Python2 csv.writer doesn't accept unicode, so we convert to UTF-8. output = io.BytesIO() - csv.writer(output).writerow([unicode(x).encode('utf-8') for x in value]) + writer = csv.writer(output, delimiter=self.list_sep) + writer.writerow([unicode(x).encode('utf-8') for x in value]) # pylint: disable=undefined-variable serialized_value = output.getvalue().decode('utf-8').strip() else: # In Python3 csv.writer expects a text stream. output = io.StringIO() - csv.writer(output).writerow([str(x) for x in value]) + writer = csv.writer(output, delimiter=self.list_sep) + writer.writerow([str(x) for x in value]) serialized_value = output.getvalue().strip() # We need the returned value to be pure ascii or Unicodes so that |