SyntaxWarnings with Python3.12

Bug #2029480 reported by zdohnal
68
This bug affects 12 people
Affects Status Importance Assigned to Milestone
HPLIP
Confirmed
Undecided
Unassigned
bleachbit (Ubuntu)
Fix Released
Undecided
Unassigned
hplip (Ubuntu)
Fix Released
Undecided
Unassigned
libreoffice (Ubuntu)
New
Undecided
Unassigned
rhythmbox (Ubuntu)
New
Undecided
Unassigned

Bug Description

Fedora 39 uses Python 3.12 by default, which generates many SyntaxWarnings when running hplip scripts.

Most warnings are due regular expressions in strings, so making them raw fixes the issue.

The patch is attached.

Tags: patch
Revision history for this message
zdohnal (zdohnal) wrote :
Revision history for this message
Till Kamppeter (till-kamppeter) wrote :

@zdohnal, thanks a lot for the patch, I have applied it now (with slight adjustments) to the Ubuntu package, fixing bug #2054869.

Changed in hplip (Ubuntu):
status: New → Fix Committed
Changed in hplip:
status: New → Confirmed
Revision history for this message
Ubuntu Foundations Team Bug Bot (crichton) wrote :

The attachment "Proposed patch" seems to be a patch. If it isn't, please remove the "patch" flag from the attachment, remove the "patch" tag, and if you are a member of the ~ubuntu-reviewers, unsubscribe the team.

[This is an automated message performed by a Launchpad user owned by ~brian-murray, for any issues please contact him.]

tags: added: patch
Revision history for this message
zdohnal (zdohnal) wrote :

Till,

in case there is an issue within my patch which made you do the adjustments, would you mind sharing them here? Upstream can apply them later together with all changes.

Revision history for this message
Till Kamppeter (till-kamppeter) wrote :

This is the patch adapted to the actual Ubuntu/Debian package of HPLIP, as used in the hplip 3.23.12+dfsg0-0ubuntu2 release for Noble.

The adaptations were most probably needed because, before applying this patch ~80 other patches got applied to the original source code of HPLIP.

Especially the transition from "is not" to "!=" seems already done.

Revision history for this message
Launchpad Janitor (janitor) wrote :

This bug was fixed in the package hplip - 3.23.12+dfsg0-0ubuntu4

---------------
hplip (3.23.12+dfsg0-0ubuntu4) noble; urgency=medium

  * Fix FTBFS on armhf due to implicit functions

 -- Simon Chopin <email address hidden> Fri, 22 Mar 2024 15:40:13 +0100

Changed in hplip (Ubuntu):
status: Fix Committed → Fix Released
Revision history for this message
fprietog (fprietog) wrote (last edit ):

I'm sorry but the related fix seem to be not complete: during upgrade from 23.10.1 mantic to 24.04 noble it updates hplip-data 3.23.12+dfsg0-0ubuntu5 from previous 3.22.10+dfsg0-2ubuntu1 and it doesn't generate SyntaxWarnings... but a few moments later, then during python3 (3.12.3-0ubuntu1) configuration:

Configurando python3 (3.12.3-0ubuntu1) ...
running python rtupdate hooks for python3.12...
...
/usr/share/hplip/base/imagesize.py:186: SyntaxWarning: invalid escape sequence '\#'
  re.compile('\#define\s+\S+\s+\d+') : ('image/x-xbitmap', xbmsize),
/usr/share/hplip/base/imagesize.py:187: SyntaxWarning: invalid escape sequence '\/'
  re.compile('\/\* XPM \*\/') : ('image/x-xpixmap', xpmsize),
/usr/share/hplip/base/imagesize.py:189: SyntaxWarning: invalid escape sequence '\*'
  re.compile('^II\*\x00') : ('image/tiff', tiffsize),
/usr/share/hplip/fax/ledmfax.py:46: SyntaxWarning: invalid escape sequence '\d'
  http_result_pat = re.compile(b"""HTTP/\d.\d\s(\d+)""", re.I)
...
running python post-rtupdate hooks for python3.12...

You can also reinstall hplip-data using apt and ending in the same problem:

# apt install --reinstall hplip-data
Leyendo lista de paquetes... Hecho
Creando árbol de dependencias... Hecho
Leyendo la información de estado... Hecho
0 actualizados, 0 nuevos se instalarán, 1 reinstalados, 0 para eliminar y 0 no actualizados.
Se necesita descargar 6.467 kB de archivos.
Se utilizarán 0 B de espacio de disco adicional después de esta operación.
Des:1 http://ports.ubuntu.com/ubuntu-ports noble/main arm64 hplip-data all 3.23.12+dfsg0-0ubuntu5 [6.467 kB]
Descargados 6.467 kB en 1s (8.035 kB/s)
(Leyendo la base de datos ... 221724 ficheros o directorios instalados actualmente.)
Preparando para desempaquetar .../hplip-data_3.23.12+dfsg0-0ubuntu5_all.deb ...
Desempaquetando hplip-data (3.23.12+dfsg0-0ubuntu5) sobre (3.23.12+dfsg0-0ubuntu5) ...
Configurando hplip-data (3.23.12+dfsg0-0ubuntu5) ...
/usr/share/hplip/base/imagesize.py:186: SyntaxWarning: invalid escape sequence '\#'
  re.compile('\#define\s+\S+\s+\d+') : ('image/x-xbitmap', xbmsize),
/usr/share/hplip/base/imagesize.py:187: SyntaxWarning: invalid escape sequence '\/'
  re.compile('\/\* XPM \*\/') : ('image/x-xpixmap', xpmsize),
/usr/share/hplip/base/imagesize.py:189: SyntaxWarning: invalid escape sequence '\*'
  re.compile('^II\*\x00') : ('image/tiff', tiffsize),
/usr/share/hplip/fax/ledmfax.py:46: SyntaxWarning: invalid escape sequence '\d'
  http_result_pat = re.compile(b"""HTTP/\d.\d\s(\d+)""", re.I)

Revision history for this message
Nathan Teodosio (nteodosio) wrote :
Changed in hplip (Ubuntu):
status: Fix Released → Confirmed
Revision history for this message
Jeremy Bícha (jbicha) wrote :

The patch from comment #8 has been updated and uploaded to oracular-proposed. I have unsubscribed ubuntu-sponsors. Please feel free to resubscribe if you have something else that needs to be sponsored.

Changed in hplip (Ubuntu):
status: Confirmed → Fix Committed
Revision history for this message
Launchpad Janitor (janitor) wrote :

This bug was fixed in the package hplip - 3.24.4+dfsg0-0ubuntu3

---------------
hplip (3.24.4+dfsg0-0ubuntu3) oracular; urgency=low

  [ Nathan Pratta Teodosio ]
  * debian/patches/0089-correct-invalid-escapes.patch: Fixed further
    invalid escapes, upstream seems still not aware of the problem
    (LP: #2029480, LP: #2054869).

 -- Till Kamppeter <email address hidden> Wed, 14 Aug 2024 19:02:08 +0200

Changed in hplip (Ubuntu):
status: Fix Committed → Fix Released
Revision history for this message
Francisco Gonzalez (fgonza1971) wrote :

Hello, I'm having same error but with another package reported in here but with packages bleachbit and rhythmbox because updating the packages today with Python 3.12.

https://ubuntuforums.org/showthread.php?t=2500273&p=14202717#post14202717

Regards

Fran

Revision history for this message
JK (janne-kankaala) wrote :
Download full text (5.8 KiB)

I confirm that this affects several packages. On my machine problems started 8/28.

---
running python rtupdate hooks for python3.12...
usr/share/bleachbit/bleachbit/Action.py:42: SyntaxWarning: invalid escape sequence '\['
  return re.search('[?*\[\]]', s) is not None
/usr/share/bleachbit/bleachbit/Cleaner.py:402: SyntaxWarning: invalid escape sequence '\W'
  '$LocalAppData\\Microsoft\\Windows\WER\\ReportQueue\\*\\*',
/usr/share/bleachbit/bleachbit/Cleaner.py:419: SyntaxWarning: invalid escape sequence '\F'
  '$windir\\Microsoft.NET\Framework\*\*.log',
/usr/share/bleachbit/bleachbit/Cleaner.py:432: SyntaxWarning: invalid escape sequence '\E'
  '$windir\\system32\\LogFiles\\WMI\\RTBackup\EtwRT.*etl',
/usr/share/bleachbit/bleachbit/Memory.py:67: SyntaxWarning: invalid escape sequence '\w'
  ret = re.search('^swapoff (\w* )?(/[\w/.-]+)$', swapoff)
/usr/share/bleachbit/bleachbit/Memory.py:159: SyntaxWarning: invalid escape sequence '\s'
  if not re.search('Filename\s+Type\s+Size', line):
/usr/share/bleachbit/bleachbit/Memory.py:162: SyntaxWarning: invalid escape sequence '\s'
  ret = re.search("%s\s+\w+\s+([0-9]+)\s" % device, line)
/usr/share/bleachbit/bleachbit/Unix.py:67: SyntaxWarning: invalid escape sequence '\.'
  """Adds a filter consisting of a prefix and a postfix
/usr/share/bleachbit/bleachbit/Unix.py:652: SyntaxWarning: invalid escape sequence '\.'
  paths = re.findall('/[/a-z\.\*]+', stdout)
/usr/share/bleachbit/bleachbit/Unix.py:720: SyntaxWarning: invalid escape sequence '\d'
  cregex = re.compile("Freed space: ([\d.]+[\s]+[BkMG])")
/usr/share/bleachbit/bleachbit/Windows.py:21: SyntaxWarning: invalid escape sequence '\S'
  """
/usr/share/bleachbit/bleachbit/Windows.py:141: SyntaxWarning: invalid escape sequence '\ '
  msg = _('The file python3.dll was found in c:\ or c:\dlls, which indicates a possible attempt at DLL search-order hijacking.')
/usr/share/bleachbit/bleachbit/Windows.py:157: SyntaxWarning: invalid escape sequence '\g'
  for fn in glob.glob(os.path.expandvars('%TEMP%\gdbus-nonce-file-*')):
/usr/lib/x86_64-linux-gnu/gedit/plugins/externaltools/library.py:212: SyntaxWarning: invalid escape sequence '\-'
  RE_KEY = re.compile('^([a-zA-Z_][a-zA-Z0-9_.\-]*)(\[([a-zA-Z_@]+)\])?$')
/usr/lib/x86_64-linux-gnu/gedit/plugins/snippets/substitutionparser.py:162: SyntaxWarning: invalid escape sequence '\s'
  match = re.match('\\\\?%s\s*' % self.REG_GROUP, tokens)
/usr/share/hplip/base/imagesize.py:186: SyntaxWarning: invalid escape sequence '\#'
  re.compile('\#define\s+\S+\s+\d+') : ('image/x-xbitmap', xbmsize),
/usr/share/hplip/base/imagesize.py:187: SyntaxWarning: invalid escape sequence '\/'
  re.compile('\/\* XPM \*\/') : ('image/x-xpixmap', xpmsize),
/usr/share/hplip/base/imagesize.py:189: SyntaxWarning: invalid escape sequence '\*'
  re.compile('^II\*\x00') : ('image/tiff', tiffsize),
/usr/share/hplip/fax/ledmfax.py:46: SyntaxWarning: invalid escape sequence '\d'
  http_result_pat = re.compile(b"""HTTP/\d.\d\s(\d+)""", re.I)
/usr/lib/rhythmbox/plugins/alternative-toolbar/alttoolbar_plugins.py:171: SyntaxWarning: invalid escape sequence '\('
  translation = re.sub('\(..\)', '', translation, flags=...

Read more...

Revision history for this message
corrado venturini (corradoventu) wrote :

also on libreoffice
Setting up python3-uno (4:24.8.0-0ubuntu1) ...
/usr/lib/libreoffice/program/officehelper.py:94: SyntaxWarning: invalid escape sequence '\P'
  """Bootstrap PyUNO Runtime.
Setting up libreoffice-calc (4:24.8.0-0ubuntu1) ...

Revision history for this message
Christophe Diot (krostif25) wrote :
Download full text (4.8 KiB)

after
sudo apt update && sudo apt upgrade
Atteint :1 http://fr.archive.ubuntu.com/ubuntu noble InRelease
Atteint :2 http://fr.archive.ubuntu.com/ubuntu noble-updates InRelease
Atteint :3 http://fr.archive.ubuntu.com/ubuntu noble-backports InRelease
Atteint :4 http://security.ubuntu.com/ubuntu noble-security InRelease
Atteint :5 https://dl.google.com/linux/chrome/deb stable InRelease
Atteint :6 https://ppa.launchpadcontent.net/tomtomtom/woeusb/ubuntu noble InRelease
Atteint :7 https://ppa.launchpadcontent.net/yannubuntu/boot-repair/ubuntu noble InRelease
Lecture des listes de paquets... Fait
Construction de l'arbre des dépendances... Fait
Lecture des informations d'état... Fait
Tous les paquets sont à jour.
Lecture des listes de paquets... Fait
Construction de l'arbre des dépendances... Fait
Lecture des informations d'état... Fait
Calcul de la mise à jour... Fait
Get more security updates through Ubuntu Pro with 'esm-apps' enabled:
  libcjson1 libavdevice60 ffmpeg libpostproc57 libavcodec60 libavutil58
  libswscale7 libswresample4 libavformat60 libavfilter9
Learn more about Ubuntu Pro at https://ubuntu.com/pro
0 mis à jour, 0 nouvellement installés, 0 à enlever et 0 non mis à jour.
3 partiellement installés ou enlevés.
Après cette opération, 0 o d'espace disque supplémentaires seront utilisés.
Souhaitez-vous continuer ? [O/n] o
Paramétrage de python3 (3.12.3-0ubuntu2) ...
running python rtupdate hooks for python3.12...
/usr/share/hplip/base/imagesize.py:186: SyntaxWarning: invalid escape sequence '\#'
  re.compile('\#define\s+\S+\s+\d+') : ('image/x-xbitmap', xbmsize),
/usr/share/hplip/base/imagesize.py:187: SyntaxWarning: invalid escape sequence '\/'
  re.compile('\/\* XPM \*\/') : ('image/x-xpixmap', xpmsize),
/usr/share/hplip/base/imagesize.py:189: SyntaxWarning: invalid escape sequence '\*'
  re.compile('^II\*\x00') : ('image/tiff', tiffsize),
/usr/share/hplip/fax/ledmfax.py:46: SyntaxWarning: invalid escape sequence '\d'
  http_result_pat = re.compile(b"""HTTP/\d.\d\s(\d+)""", re.I)
Traceback (most recent call last):
  File "/usr/bin/py3clean", line 210, in <module>
    main()
  File "/usr/bin/py3clean", line 196, in main
    pfiles = set(dpf.from_package(options.package))
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/share/python3/debpython/files.py", line 55, in from_package
    raise Exception("cannot get content of %s" % package_name)
Exception: cannot get content of inkscape
error running python rtupdate hook inkscape
Traceback (most recent call last):
  File "/usr/bin/py3clean", line 210, in <module>
    main()
  File "/usr/bin/py3clean", line 196, in main
    pfiles = set(dpf.from_package(options.package))
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^...

Read more...

Revision history for this message
Andrew Ziem (ahziem1) wrote :

BleachBit 4.6.1 beta has fixed for the syntax warning

Revision history for this message
Fantu (fantonifabio) wrote :

BleachBit 4.6.0-4 fixed it and as bugfix only revision I think is acceptable for Ubuntu 24.10 now in feature freeze. There is an Ubuntu developer that want to sync it?

Changed in bleachbit (Ubuntu):
status: New → Confirmed
Revision history for this message
Till Kamppeter (till-kamppeter) wrote :

Done. Synced BleachBit 4.6.0-4 right now, thanks for investigating.

Changed in bleachbit (Ubuntu):
status: Confirmed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.