Skip to content

Commit

Permalink
🐛 remove SyntaxError in split
Browse files Browse the repository at this point in the history
  • Loading branch information
RF-Tar-Railt committed Aug 6, 2024
1 parent 4a77cd3 commit d9b48f1
Show file tree
Hide file tree
Showing 3 changed files with 1 addition and 14 deletions.
6 changes: 0 additions & 6 deletions src/tarina/_string_c.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,6 @@ def split(text: str, separates: tuple[str, ...], crlf: bool = True) -> list[str]
Returns:
List[str]: 切割后的字符串, 可能含有空格
Raises:
SyntaxError: 未闭合的引号
"""
...

Expand All @@ -23,8 +20,5 @@ def split_once(text: str, separates: tuple[str, ...], crlf: bool = True) -> tupl
crlf (bool): 是否去除 \n\r,默认为 True
Returns:
Tuple[str, str]: 切割后的字符串, 可能含有空格
Raises:
SyntaxError: 未闭合的引号
"""
...
4 changes: 0 additions & 4 deletions src/tarina/_string_c.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,6 @@ def split(str text, tuple separates, char crlf=True):
else:
PyList_Append(result, ch)
escape = 0
if quotation != 0:
raise SyntaxError(f"Unterminated string: {text!r}")
if PyUnicode_GET_LENGTH(result) == 0:
return []
return PyUnicode_Split(PyUnicode_Join('', result), '\1', -1)
Expand Down Expand Up @@ -99,6 +97,4 @@ def split_once(str text, tuple separates, char crlf=True):
else:
PyList_Append(out_text, ch)
escape = 0
if quotation != 0:
raise SyntaxError(f"Unterminated string: {text!r}")
return PyUnicode_Join('', out_text), text[index:]
5 changes: 1 addition & 4 deletions src/tarina/_string_py.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ def split_once(text: str, separates: tuple[str, ...], crlf: bool = True):
text (str): 要切割的字符串
separates (tuple[str, ...]): 切割符.
crlf (bool): 是否去除 \n\r,默认为 True
Returns:
Tuple[str, str]: 切割后的字符串, 可能含有空格
"""
Expand Down Expand Up @@ -40,8 +41,6 @@ def split_once(text: str, separates: tuple[str, ...], crlf: bool = True):
else:
out_text += char
escape = False
if quotation:
raise SyntaxError(f"Unterminated string: {text!r}")
return out_text, text[index:]


Expand Down Expand Up @@ -77,6 +76,4 @@ def split(text: str, separates: tuple[str, ...], crlf: bool = True):
else:
result += char
escape = False
if quotation:
raise SyntaxError(f"Unterminated string: {text!r}")
return result.split("\0") if result else []

0 comments on commit d9b48f1

Please sign in to comment.