Skip to content

Commit e10b25d

Browse files
r-barnesfacebook-github-bot
authored andcommitted
remove{suffix,prefix} replaces {l,r}strip in pytorch/text/torchtext/datasets/cc100.py +1
Summary: `x.lstrip("string")` is equivalent to `re.sub(r"[string]", "", x)`. This means that `"fbcode/fbcode_file".lstrip("fbcode/")` returns `_file`. This can easily be an unintended behaviour! Instead, as of Python 3.10, we should use `string.removeprefix` or `string.removesuffix`. This diff makes one or more such fixes that we believe are likely to be bugs. Please double-check before approving. Reviewed By: itamaro, zsol Differential Revision: D55386410 fbshipit-source-id: 903b7e2b6825bd6489e211b1837fa4a65d12ca91
1 parent 380af83 commit e10b25d

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

torchtext/datasets/cc100.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ def _filepath_fn(root, url, _=None):
138138

139139

140140
def _decompressed_filepath_fn(root, x):
141-
return os.path.join(root, os.path.basename(x).rstrip(".xz"))
141+
return os.path.join(root, os.path.basename(x).removesuffix(".xz"))
142142

143143

144144
def _modify_res(language_code, x):

0 commit comments

Comments
 (0)