Bug 163190 - [pyuno] SyntaxWarning: invalid escape sequence '\P'
Summary: [pyuno] SyntaxWarning: invalid escape sequence '\P'
Status: RESOLVED FIXED
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: sdk (show other bugs)
Version:
(earliest affected)
24.8.0.0 alpha0+
Hardware: All All
: low minor
Assignee: Julien Nabet
URL:
Whiteboard: target:25.2.0 target:24.8.3
Keywords: bibisectNotNeeded, regression
Depends on:
Blocks:
 
Reported: 2024-09-28 11:09 UTC by Rene Engelhard
Modified: 2024-09-30 08:13 UTC (History)
1 user (show)

See Also:
Crash report or crash signature:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Rene Engelhard 2024-09-28 11:09:58 UTC
Hi, see http://bugs.debian.org/1082775.

Installing python3-uno gives

Setting up python3-uno (4:24.8.1-2) ...
/usr/lib/libreoffice/program/officehelper.py:94: SyntaxWarning: invalid escape sequence '\P'
  """Bootstrap PyUNO Runtime.

probably thrown by 

#!/bin/sh
set -e

# Automatically added by dh_python3
if command -v py3compile >/dev/null 2>&1; then
        py3compile -p python3-uno:amd64 
fi
if command -v pypy3compile >/dev/null 2>&1; then
        pypy3compile -p python3-uno:amd64  || true
fi

# End automatically added section

# Automatically added by dh_python3
if command -v py3compile >/dev/null 2>&1; then
        py3compile -p python3-uno:amd64 /usr/lib/libreoffice/program -V 3.12
fi
if command -v pypy3compile >/dev/null 2>&1; then
        pypy3compile -p python3-uno:amd64 /usr/lib/libreoffice/program -V 3.12 || true
fi

# End automatically added section

which the Debian package helpers add automatically for public modules. "import uno" doesn't warn, but maybe when it gets actually used?

Anyways:

This is due to this comment in officehelper.py:

    """Bootstrap PyUNO Runtime.
    The soffice process is started opening a named pipe of random name,
    then the local context is used to access the pipe. This function
    directly returns the remote component context, from whereon you can
    get the ServiceManager by calling getServiceManager() on the
    returned object.
    Examples:
    i.  Start LO as a service, get its remote component context
        import officehelper
        ctx = officehelper.bootstrap()
        # your code goes here
    ii. Wait longer for LO to start, request context multiples times
      + Report processing in console
        import officehelper as oh
        ctx = oh.bootstrap(delays=(5,10,15,20),report=print)  # wait 5, 10, 15 and 20 sec.
        # your code goes here
    iii. Use a specific LibreOffice copy
        from officehelper import bootstrap
        ctx = bootstrap(soffice=r"USB:\PortableApps\libO-7.6\App\libreoffice\program\soffice.exe")
        # your code goes here
    """

which is line 94... (cf. https://git.libreoffice.org/core/+/refs/tags/libreoffice-24.8.2.1/pyuno/source/officehelper.py) and which was added in https://git.libreoffice.org/core/+/d8978a8c4ffabd6b36a691fd3e2df68563808234

The Problem is the Windows Path in iii. and the \P in \PortableApps.. Maybe that example should be converted into UNIX paths to avoid that \P which is interpreted as a escape sqeuence by python.
Comment 1 Rene Engelhard 2024-09-28 11:14:00 UTC
"Maybe that example should be converted into UNIX paths"

I'll probably do it in the packaging. Though ideally this minor thing also could be fixed upstream ;)
Comment 2 Rene Engelhard 2024-09-28 11:15:37 UTC
adding regression keyword since the warning was not there befoe the pyuno rework up to 24.8
Comment 3 Julien Nabet 2024-09-28 11:43:34 UTC
On pc Debian testing x86-64 with master sources updated today, I confirm the pb.

$ python3 ./pyuno/source/officehelper.py
/home/julien/lo/libreoffice/./pyuno/source/officehelper.py:101: SyntaxWarning: invalid escape sequence '\P'
Comment 4 Julien Nabet 2024-09-28 11:45:54 UTC
Patch submitted here:
https://gerrit.libreoffice.org/c/core/+/174108
Comment 5 Commit Notification 2024-09-29 18:17:26 UTC
Julien Nabet committed a patch related to this issue.
It has been pushed to "master":

https://git.libreoffice.org/core/commit/bda6201f811836c1ef2696b516b8999e268878e9

tdf#163190: [pyuno] SyntaxWarning: invalid escape sequence '\P'

It will be available in 25.2.0.

The patch should be included in the daily builds available at
https://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
https://wiki.documentfoundation.org/Testing_Daily_Builds

Affected users are encouraged to test the fix and report feedback.
Comment 6 Julien Nabet 2024-09-29 18:20:33 UTC
Cherry-pick for 24.8 waiting for review here:
https://gerrit.libreoffice.org/c/core/+/174014
Comment 7 Commit Notification 2024-09-30 08:13:18 UTC
Julien Nabet committed a patch related to this issue.
It has been pushed to "libreoffice-24-8":

https://git.libreoffice.org/core/commit/452696d3775e0bbf867fc7476373a184c7fc098c

tdf#163190: [pyuno] SyntaxWarning: invalid escape sequence '\P'

It will be available in 24.8.3.

The patch should be included in the daily builds available at
https://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
https://wiki.documentfoundation.org/Testing_Daily_Builds

Affected users are encouraged to test the fix and report feedback.