Skip to content

Commit fba6d9e

Browse files
authored
Remove call to removeprefix to fix python 3.8 (#253)
In `stream.py` we were using `removeprefix`, which was introduced in Python 3.9. This breaks compatibility with Python 3.8, which I believe we still want to support. This PR provides exact same functionality but without the call to that function. Previously, we were `.lstrip()`-ing here, but I assume @mattt switched to `removeprefix` for a reason, so I didn't use that (as it would get rid of any and all whitespace, as opposed to a single space as we do here).
1 parent 43f75c7 commit fba6d9e

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

replicate/stream.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ def decode(self, line: str) -> Optional[ServerSentEvent]:
114114
return None
115115

116116
fieldname, _, value = line.partition(":")
117-
value = value.removeprefix(" ")
117+
value = value[1:] if value.startswith(" ") else value
118118

119119
if fieldname == "event":
120120
if event := ServerSentEvent.EventType(value):

0 commit comments

Comments
 (0)