Skip to contentSkip to conversation

cooker: Drop sre_constants usage

PATCH New Richard Purdie 1 participant 1 message Jun 8, 2022

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 cooker: Drop sre_constants usage

As reported by Martin Jansa <[email protected]>:

bitbake/lib/bb/cooker.py:16: DeprecationWarning: module 'sre_constants' is deprecated
import sre_constants

it's deprecated since 3.11 with:

https://github.com/python/cpython/issues/91308

The correct replacement for our usage is re.error so use that instead.

---
 lib/bb/cooker.py | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)
lib/bb/cooker.py +2 -3
index 701e49339a..77ddd440a2 100644
@@ -13,7 +13,6 @@ import sys, os, glob, os.path, re, time
 import itertools
 import logging
 import multiprocessing
-import sre_constants
 import threading
 from io import StringIO, UnsupportedOperation
 from contextlib import closing
@@ -1926,7 +1925,7 @@ class CookerCollectFiles(object):
                 try:
                     re.compile(mask)
                     bbmasks.append(mask)
-                except sre_constants.error:
+                except re.error:
                     collectlog.critical("BBMASK contains an invalid regular expression, ignoring: %s" % mask)
 
             # Then validate the combined regular expressions. This should never
@@ -1934,7 +1933,7 @@ class CookerCollectFiles(object):
             bbmask = "|".join(bbmasks)
             try:
                 bbmask_compiled = re.compile(bbmask)
-            except sre_constants.error:
+            except re.error:
                 collectlog.critical("BBMASK is not a valid regular expression, ignoring: %s" % bbmask)
                 bbmask = None
 
Signature · 1 line
2.34.1