[projects/pld-builder.new] util: drop python 2 fallbacks
arekm
arekm at pld-linux.org
Wed Aug 12 11:46:51 CEST 2026
commit 55863d2afd4442f4f961e176df4d79d495da3655
Author: Arkadiusz Miśkiewicz <arekm at maven.pl>
Date: Wed Aug 12 11:03:37 2026 +0200
util: drop python 2 fallbacks
The unicode type checks and the no-uuid-module path are unreachable on
python 3.
PLD_Builder/util.py | 25 +++++--------------------
1 file changed, 5 insertions(+), 20 deletions(-)
---
diff --git a/PLD_Builder/util.py b/PLD_Builder/util.py
index e771c32..1f27885 100644
--- a/PLD_Builder/util.py
+++ b/PLD_Builder/util.py
@@ -4,25 +4,10 @@ import re
import sys
import os
import codecs
+from uuid import uuid4
-def uuid_python():
- return str(uuid_random())
-
-def uuid_external():
- f = os.popen("uuidgen 2>&1")
- u = f.read().strip()
- f.close()
- if len(u) != 36:
- raise Exception("uuid: fatal, cannot generate uuid: %s" % u)
- return u
-
-# uuid module available in python >= 2.5
-try:
- from uuid import uuid4 as uuid_random
-except ImportError:
- uuid = uuid_external
-else:
- uuid = uuid_python
+def uuid():
+ return str(uuid4())
def msg(m):
sys.stderr.write(m)
@@ -86,7 +71,7 @@ def cmp_to_key(mycmp):
def to_bytes(s):
if type(s) is bytes:
return s
- elif type(s) is str or (sys.version_info[0] < 3 and type(s) is unicode):
+ elif type(s) is str:
return codecs.encode(s, 'utf-8')
else:
raise TypeError("Expected bytes or string, but got %s." % type(s))
@@ -94,7 +79,7 @@ def to_bytes(s):
def to_str(s):
if type(s) is bytes:
return codecs.decode(s, 'utf-8')
- elif type(s) is str or (sys.version_info[0] < 3 and type(s) is unicode):
+ elif type(s) is str:
return s
else:
raise TypeError("Expected bytes or string, but got %s." % type(s))
================================================================
---- gitweb:
http://git.pld-linux.org/gitweb.cgi/projects/pld-builder.new.git/commitdiff/44916a7a9112928736ec2b65b4fa58a90bc5828c
More information about the pld-cvs-commit
mailing list