Skip to contentSkip to conversation

cooker: avoid DeprecationWarning with python-3.11

PATCH In review Martin Jansa 3 participants 3 messages Jun 8, 2022

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 cooker: avoid DeprecationWarning with python-3.11

* fixes:
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

---
 lib/bb/cooker.py | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
lib/bb/cooker.py +4 -1
index 6da9291f..e417d0e1 100644
@@ -13,7 +13,10 @@ import sys, os, glob, os.path, re, time
 import itertools
 import logging
 import multiprocessing
-import sre_constants
+if sys.version_info >= (3, 11):
+    import re._constants as sre_constants
+else:
+    import sre_constants
 import threading
 from io import StringIO, UnsupportedOperation
 from contextlib import closing
Signature · 1 line
2.35.1
#1 lore raw

Neither the old or the new is a documented item, so I believe it is better to eliminate the use entirely?

Alex

Quoted 41 lines · Martin Jansa

* fixes:
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

---
 lib/bb/cooker.py | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
lib/bb/cooker.py +4 -2
index 6da9291f..e417d0e1 100644
@@ -13,7 +13,10 @@ import sys, os, glob, os.path, re, time
 import itertools
 import logging
 import multiprocessing
-import sre_constants
+if sys.version_info >= (3, 11):
+    import re._constants as sre_constants
+else:
+    import sre_constants
 import threading
 from io import StringIO, UnsupportedOperation
 from contextlib import closing
--

2.35.1

-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group.
View/Reply Online (#13739): https://lists.openembedded.org/g/bitbake-devel/message/13739
Mute This Topic: https://lists.openembedded.org/mt/91619426/1686489
Group Owner: [email protected]
Unsubscribe: https://lists.openembedded.org/g/bitbake-devel/unsub [[email protected]]
-=-=-=-=-=-=-=-=-=-=-=-

#2 lore raw
In reply to Martin Jansa
Quoted 18 lines · Martin Jansa

* fixes:
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

---
 lib/bb/cooker.py | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
lib/bb/cooker.py +0 -0
index 6da9291f..e417d0e1 100644
@@ -13,7 +13,10 @@ import sys, os, glob, os.path, re, time
 import itertools

lib/bb/cooker.py import sys, os, glob, os.path, re, time · line 22

Quoted 10 lines
lib/bb/cooker.py +4 -1
 import logging
 import multiprocessing
-import sre_constants
+if sys.version_info >= (3, 11):
+    import re._constants as sre_constants
+else:
+    import sre_constants
 import threading
 from io import StringIO, UnsupportedOperation
 from contextlib import closing

Looking at the code we only ever use sre_constants.error and this should really be re.error in modern python as far as I can tell so that change may be easier ?

Cheers,

Richard