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

Fix: Invalid escape sequences #1352

Merged
merged 1 commit into from
Nov 4, 2022
Merged

Fix: Invalid escape sequences #1352

merged 1 commit into from
Nov 4, 2022

Conversation

buhtz
Copy link
Member

@buhtz buhtz commented Nov 4, 2022

This fix DeprecationWarnings about invalid escape sequences. Most of that warnings are caught when running pytest. That warnings will become serious errors in future Python versions.

This where the warnings. Sorry for providing a screenshot instead of plain text but I still have problems copy & past from a Windows terminal window running ssh client and tmux.
image

Of course, I checked all problems and what that strings really need to do.
Most of the warnings are about \$ which I modified to \\$. It is like escaping and escape. Sounds wired but it is intended to be that way. Because that string is handed over (via subprocess.Popen()) to a shell command (ssh) which need to receive a string containing an escape.

Comment on lines -1408 to +1413
head += 'TMP=\$(mktemp -d); ' #create temp dir used for delete files with rsync
head += 'test -z \\\"\$TMP\\\" && exit 1; ' #make sure $TMP dir was created
head += 'test -n \\\"\$(ls \$TMP)\\\" && exit 1; ' #make sure $TMP is empty
# create temp dir used for delete files with rsync
head += 'TMP=\\$(mktemp -d); '
# make sure $TMP dir was created
head += 'test -z \\\"\\$TMP\\\" && exit 1; '
# make sure $TMP is empty
head += 'test -n \\\"\\$(ls \\$TMP)\\\" && exit 1; '
Copy link
Member Author

@buhtz buhtz Nov 4, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry the diff here is hard to see.
In all three lines the \$ was modified to \\$.

Comment on lines -1637 to +1640
m = re.match(b'^.*?\s+\d+\s+\d+\s+(\d+)\s+\d+%', line, re.M)
m = re.match(r'^.*?\s+\d+\s+\d+\s+(\d+)\s+\d+%', line.decode(), re.M)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The output from shell was catched as binary instead of a string. No need for that.
Converted that to a real string (via .decode()) and run a raw regex string (via r'') on it.

@what-the-diff
Copy link

what-the-diff bot commented Nov 4, 2022

ATTENTION: That content is auto-generated by a stupid algorithm. Some of that information's and links are not valid, wrong and missleading. It was just a test.

@buhtz
Copy link
Member Author

buhtz commented Nov 4, 2022

Sorry I couldn't resists. Just read that heise-Article about a GPT-3 based algorithm generate summary text from code diffs for PRs. I see no value in such a tool even if it would work 100% perfect. I just played a bit arround.

@aryoda
Copy link
Contributor

aryoda commented Nov 4, 2022

@buhtzz If you want you could also fix a few more "invalid escape sequence" warning candidates in:

  • settingsdialog.py: 855 and 861
  • create-manpage-backintime-config.py#166

Edit: These code lines are not covered by unit test so you don't see the warnings

@buhtz
Copy link
Member Author

buhtz commented Nov 4, 2022

@buhtzz If you want you could also fix a few more "invalid escape sequence" warning candidates

Good idea. In a short test I can find much more via flake8. I will cover this in the next PR.

@aryoda
Copy link
Contributor

aryoda commented Nov 4, 2022

@buhtzz If you want you could also fix a few more "invalid escape sequence" warning candidates

Good idea. In a short test I can find much more via flake8. I will cover this in the next PR.

That's fine, no urgent need so far.

@aryoda aryoda merged commit 2121c60 into bit-team:master Nov 4, 2022
@buhtz buhtz deleted the fix/invalide_escapes branch November 12, 2022 12:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants