Skip to content

Commit 842f5d9

Browse files
authored
Merge pull request noironetworks#289 from noironetworks/none_desc
Add a guard to handle the description is None case
2 parents 0f64496 + bcddb1e commit 842f5d9

File tree

2 files changed

+4
-0
lines changed

2 files changed

+4
-0
lines changed

aim/tests/unit/test_utils.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@ def test_sanitize_display_name(self):
3939
utils.sanitize_display_name('some' * 15))
4040

4141
def test_sanitize_description(self):
42+
self.assertEqual(
43+
'', utils.sanitize_description(None))
4244
self.assertEqual(
4345
'_eF5\\!#$%()*,-./:;@ _{|}~?&+_',
4446
utils.sanitize_description('\'eF5\\!#$%()*,-./:;@ _{|}~?&+\"'))

aim/utils.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,5 +21,7 @@ def sanitize_display_name(display_name):
2121

2222

2323
def sanitize_description(description):
24+
if description is None:
25+
return ''
2426
return re.sub(r'[^a-zA-Z0-9\\!#$%()*,-./:;@ _{|}~?&+]',
2527
'_', description[:124])

0 commit comments

Comments
 (0)