fix: Exclude special char failed

pull/15734/head
feng 2025-07-16 14:15:32 +08:00 committed by Bryan
parent e6a1662780
commit 4d22c0722b
1 changed files with 1 additions and 2 deletions

View File

@ -48,7 +48,6 @@ def random_string(
char_list = []
if lower:
lower_chars = remove_exclude_char(string.ascii_lowercase, exclude_chars)
if not lower_chars:
raise ValueError('After excluding characters, no lowercase letters are available.')
@ -78,7 +77,7 @@ def random_string(
if not special_chars:
raise ValueError('After excluding characters, no special characters are available.')
symbol_num = length // 16 + 1
seq = random_replace_char(seq, symbols, symbol_num)
seq = random_replace_char(seq, special_chars, symbol_num)
secret_chars += seq
secrets.SystemRandom().shuffle(secret_chars)