Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SyntaxWarnings "invalid escape sequence" in S3Uri.py and FileLists.py #1374

Closed
TurtleWilly opened this issue Apr 13, 2024 · 2 comments · Fixed by #1370
Closed

SyntaxWarnings "invalid escape sequence" in S3Uri.py and FileLists.py #1374

TurtleWilly opened this issue Apr 13, 2024 · 2 comments · Fixed by #1370
Milestone

Comments

@TurtleWilly
Copy link

I do encounter a heap of warnings (yes, I zipapp'ed s3cmd) which suggest proper bugs:

$ ./s3cmd.pyz --version
/Volumes/Temporary/s3cmd/./s3cmd.pyz/S3/S3Uri.py:122: SyntaxWarning: invalid escape sequence '\.'
/Volumes/Temporary/s3cmd/./s3cmd.pyz/S3/S3Uri.py:170: SyntaxWarning: invalid escape sequence '\w'
/Volumes/Temporary/s3cmd/./s3cmd.pyz/S3/S3Uri.py:122: SyntaxWarning: invalid escape sequence '\.'
/Volumes/Temporary/s3cmd/./s3cmd.pyz/S3/S3Uri.py:170: SyntaxWarning: invalid escape sequence '\w'
/Volumes/Temporary/s3cmd/./s3cmd.pyz/S3/FileLists.py:525: SyntaxWarning: invalid escape sequence '\*'
/Volumes/Temporary/s3cmd/./s3cmd.pyz/S3/FileLists.py:525: SyntaxWarning: invalid escape sequence '\*'
s3cmd version 2.4.0

The reported regex strings should be prefixed with "r" to become raw strings (like r".*\..*") or the backslashes need to be double escaped (like ".*\\..*"). I recommend the first option.

Note that a simple backslash triggers string escaping only (like "\n" or "\e", f.ex.), but what you are trying to achieve there is to escape characters from the regex (e.g. "." for a literal dot character and not "any character") or use special regex sequences (like "\w").

@TurtleWilly
Copy link
Author

I just found out that there is already a fix in the queue: #1370

@fviard fviard added this to the 2.4.1 milestone Sep 10, 2024
@fviard
Copy link
Contributor

fviard commented Sep 10, 2024

Fixed with the merge of #1370 .

@fviard fviard closed this as completed Sep 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants