SyntaxWarning: invalid escape sequence '\s'
I have latest Rundeck OSS 5.8.0 running in a Windows Server 2019 VM, Python version installed 3.13.1 and latest py-winrm-plugin v.2.1.3.
When i execute a Powershell script i made i get SyntaxWarning: invalid escape sequence '\s' in the output.
The script:
if (Get-Service -Name "@option.servizio@") {
$arrService = Get-Service -Name "@option.servizio@"
Restart-Service -Name "@option.servizio@"
write-host 'Restarting service @option.servizio@'
Start-Sleep -seconds 10
$arrService.Refresh()
if ($arrService.Status -eq 'Running')
{
Write-Host '@option.servizio@ is now running'
} else {
Write-Host '@option.servizio@ is stopped, notifying...'
exit 1
}
} else {
Write-Host "@option.servizio@ service doesn't exists."
}
the option servizio has the following list of allowed values: NETA Schedulatore Amministratore Service,NETABollengWrapperService,Neta Etl Service,NETA Reports Service,NETA OutputFile Service
The output:
C:\rundeck\libext\cache\py-winrm-plugin-2.1.3\common.py:35: SyntaxWarning: invalid escape sequence '\s' regexpMultipleAbsolutePath = re.compile(''[a-zA-Z]:\\.\s[a-zA-Z]:\\.') #at least two absolute paths C:\rundeck\libext\cache\py-winrm-plugin-2.1.3\common.py:39: SyntaxWarning: invalid escape sequence '\s' regexpPathAndOption = re.compile(''[a-zA-Z]:\\.\s/.+') C:\rundeck\libext\cache\py-winrm-plugin-2.1.3\common.py:43: SyntaxWarning: invalid escape sequence '\s' regexpPathAndOptionUnix = re.compile(''[a-zA-Z]:\\.\s-.+') C:\rundeck\libext\cache\py-winrm-plugin-2.1.3\common.py:47: SyntaxWarning: invalid escape sequence '\s' regexPathRequireQuotes = re.compile(''[a-zA-Z]:\\.*\s') Riavvio servizio NETABollengWrapperService NETABollengWrapperService è ora in esecuzione
However the job complete OK and the script does what i expect.
Yes, I had the same issue. Python 3.13 is stricter about how backslashes are interpreted within regular string literals. The patch below fixes the problem
--- ./contents/common.py.dist<->2024-01-11 21:30:02.000000000 +0000
+++ ./contents/common.py<------>2025-06-25 04:15:06.346840361 +0000
@@ -32,19 +32,19 @@
.
def isAPathThatRequiresDoubleQuotes(candidate):
#first check that this is not multiple paths, e.g. 'C:\windows C:\tmp...'
- regexpMultipleAbsolutePath = re.compile('\'[a-zA-Z]:\\\\.*\s[a-zA-Z]:\\\\.*') #at least two absolute paths
+ regexpMultipleAbsolutePath = re.compile(r'\'[a-zA-Z]:\\\\.*\s[a-zA-Z]:\\\\.*') #at least two absolute paths
if regexpMultipleAbsolutePath.match(candidate): return False
.
#verify if this is a path with no options after, windows style. e.g. 'C:\Windows /w...'
- regexpPathAndOption = re.compile('\'[a-zA-Z]:\\\\.*\s/.+')
+ regexpPathAndOption = re.compile(r'\'[a-zA-Z]:\\\\.*\s/.+')
if regexpPathAndOption.match(candidate): return False
.
#verify if this is a path with no options after, unix style. e.g. 'C:\Windows -v'
- regexpPathAndOptionUnix = re.compile('\'[a-zA-Z]:\\\\.*\s-.+')
+ regexpPathAndOptionUnix = re.compile(r'\'[a-zA-Z]:\\\\.*\s-.+')
if regexpPathAndOptionUnix.match(candidate): return False
.
#finally, check if this is a single path, with single quotes, and requires to be put between double quotes.e.g. 'C:\Program Files'
- regexPathRequireQuotes = re.compile('\'[a-zA-Z]:\\\\.*\s')
+ regexPathRequireQuotes = re.compile(r'\'[a-zA-Z]:\\\\.*\s')
if regexPathRequireQuotes.match(candidate):
return True
else:
Confirmed the suggested fix (using r to interpret the regex as raw string literal) addresses the problem on Ubuntu 24.04 (python 3.12).
Sorry we missed this. If it's still a problem please open a new Issue with current Rundeck version details, and a deeper description of how this can be repeated.