pwncollege / dojo

Infrastructure powering pwn.college dojo
https://pwn.college
BSD 2-Clause "Simplified" License
264 stars 76 forks source link

Invalid string escape #449

Open Scoder12 opened 1 week ago

Scoder12 commented 1 week ago

My editor just caught this while working on the code:

https://github.com/pwncollege/dojo/blob/3878ec0320c953d3e9f7d058f97318d7c79c04ec/dojo_plugin/api/v1/docker.py#L62

Shouldn't this be an r" string?

adamdoupe commented 6 days ago

why would it need to be an r string? IIRC that applies different syntaxes to make some regex string escapes better, but there's nothing invalid here.

Scoder12 commented 6 days ago

It works fine now, but it's deprecated and will cause a syntax error in the future

$ python -Wd -c 'print("\s")'
<string>:1: DeprecationWarning: invalid escape sequence '\s'
\s
adamdoupe commented 6 days ago

Fascinating and (imo) stupid: they should never break working code.

From https://docs.python.org/3/reference/lexical_analysis.html#string-and-bytes-literals

Changed in version 3.6: Unrecognized escape sequences produce a [DeprecationWarning](https://docs.python.org/3/library/exceptions.html#DeprecationWarning).

Changed in version 3.12: Unrecognized escape sequences produce a [SyntaxWarning](https://docs.python.org/3/library/exceptions.html#SyntaxWarning). In a future Python version they will be eventually a [SyntaxError](https://docs.python.org/3/library/exceptions.html#SyntaxError).

Good catch @Scoder12 feel free to make a PR :)

Scoder12 commented 6 days ago

Will be fixed as part of #439