opnk.py: fix warning with python3.12. v1 PROPOSED

Étienne Mollier: 1
 opnk.py: fix warning with python3.12.

 1 files changed, 1 insertions(+), 1 deletions(-)
I think the correct way to fix this would have been to convert it
into a raw string, so that no escape sequences would be interpreted:


Hi Paul,

Paul Wise, on 2024-03-23:
Export patchset (mbox)
How do I use this?

Copy & paste the following snippet into your terminal to import this patchset into git:

curl -s https://lists.sr.ht/~lioploum/offpunk-devel/patches/49706/mbox | git am -3
Learn more about email & git

[PATCH] opnk.py: fix warning with python3.12. Export this patch

As initially identified by Paul Wise in [Debian Bug#1064209], opnk.py
experiences the following warning when running under python3.12:

	$ python3.12 opnk.py gemini://ploum.net >/dev/null
	/home/emollier/debian/forward-upstream/offpunk/opnk.py:52: SyntaxWarning: invalid escape sequence '\%'
	  less_prompt = "page %%d/%%D- lines %%lb/%%L - %%Pb\%%"

This is due to the interpretation of escape sequences being less
relaxed in the new Python interpreter version.  Doubling the backslash
is one way to resolve this issue.

[Debian Bug#1064209]: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1064209

Signed-off-by: Étienne Mollier <emollier@debian.org>
 opnk.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/opnk.py b/opnk.py
index 615a5d2..9cf86ef 100755
--- a/opnk.py
+++ b/opnk.py
@@ -49,7 +49,7 @@ else:
# are there on purpose (surch in asciiart)
#--incsearch : incremental search starting rev581
def less_cmd(file, histfile=None,cat=False,grep=None):
    less_prompt = "page %%d/%%D- lines %%lb/%%L - %%Pb\%%"
    less_prompt = "page %%d/%%D- lines %%lb/%%L - %%Pb\\%%"
    if less_version >= 581:
        less_base = "less --incsearch --save-marks -~ -XRfWiS -P \"%s\""%less_prompt
    elif less_version >= 572:
Thanks a lot for the patch. Commited.