Fixes #469 - Prevented rst crash with only-space strings (#470)

Thanks nexone for the report.
This commit is contained in:
Claude Paroz
2020-06-15 07:42:51 +02:00
committed by GitHub
parent 985c3d98b0
commit ce79e44d14
3 changed files with 9 additions and 1 deletions
+6
View File
@@ -1,5 +1,11 @@
# History # History
## Unreleased
### Bugfixes
- Prevented crash in rst export with only-space strings (#469).
## 2.0.0 (2020-05-16) ## 2.0.0 (2020-05-16)
### Breaking changes ### Breaking changes
+1 -1
View File
@@ -24,7 +24,7 @@ def _max_word_len(text):
>>> _max_word_len('Python Module for Tabular Datasets') >>> _max_word_len('Python Module for Tabular Datasets')
8 8
""" """
return max(len(word) for word in text.split()) if text else 0 return max([len(word) for word in text.split()], default=0) if text else 0
class ReSTFormat: class ReSTFormat:
+2
View File
@@ -659,6 +659,7 @@ class RSTTests(BaseTestCase):
data.headers = self.headers data.headers = self.headers
data.append(self.john) data.append(self.john)
data.append(('Wendy', '', 43)) data.append(('Wendy', '', 43))
data.append(('Esther', ' ', 31))
self.assertEqual( self.assertEqual(
data.export('rst'), data.export('rst'),
'========== ========= ===\n' '========== ========= ===\n'
@@ -666,6 +667,7 @@ class RSTTests(BaseTestCase):
'========== ========= ===\n' '========== ========= ===\n'
'John Adams 90 \n' 'John Adams 90 \n'
'Wendy 43 \n' 'Wendy 43 \n'
'Esther 31 \n'
'========== ========= ===' '========== ========= ==='
) )