From 63925e0e0db7abed296ecf520c7269a2101dd738 Mon Sep 17 00:00:00 2001 From: Jonathan Metzman Date: Wed, 20 Jan 2021 12:59:11 -0800 Subject: match behavior of removeprefix --- infra/utils.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/infra/utils.py b/infra/utils.py index d8ade389..fe5dd873 100644 --- a/infra/utils.py +++ b/infra/utils.py @@ -163,4 +163,9 @@ def gs_url_to_https(url): def remove_prefix(string, prefix): """Returns |string| without the leading substring |prefix|.""" - return string[len(prefix):] + # Match behavior of removeprefix from python3.9: + # https://www.python.org/dev/peps/pep-0616/ + if string.startswith(prefix): + return string[len(prefix):] + + return string -- cgit v1.2.3