make Python test script compatible with Python2 and Python3

Signed-off-by: yixiangzhike <yixiangzhike007@163.com>
This commit is contained in:
yixiangzhike 2022-10-19 18:03:00 +08:00
parent 0cdb3b0f93
commit 83a38b8e22
2 changed files with 47 additions and 1 deletions

View File

@ -0,0 +1,37 @@
From 6a6f22d6e99c973bf2f9f400d52370107ae9396b Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?H=C3=A5vard?= <havard.f.aasen@pfft.no>
Date: Thu, 26 May 2022 21:26:55 +0000
Subject: [PATCH] Make Python test script compatible with Python 2 and Python
3. (#35)
The shebang line is still restricting it to Python 2.
Removed end-of-line whitespace as well.
---
bindings/python/test/capng-test.py | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/bindings/python/test/capng-test.py b/bindings/python/test/capng-test.py
index 6688e77..e6350ec 100755
--- a/bindings/python/test/capng-test.py
+++ b/bindings/python/test/capng-test.py
@@ -14,7 +14,7 @@ try:
with open('/proc/sys/kernel/cap_last_cap', 'r') as f:
last = int(f.readline())
except IOError as e:
- print "Error opening /proc/sys/kernel/cap_last_cap: {0}".format(e.strerror)
+ print("Error opening /proc/sys/kernel/cap_last_cap: {0}".format(e.strerror))
print("Doing basic bit tests...")
capng.capng_clear(capng.CAPNG_SELECT_BOTH)
@@ -49,7 +49,7 @@ for i in range(last+1):
if capng.capng_have_capabilities(capng.CAPNG_SELECT_CAPS) != capng.CAPNG_PARTIAL:
print("Failed have capabilities test 1")
sys.exit(1)
-
+
capng.capng_fill(capng.CAPNG_SELECT_BOTH)
rc = capng.capng_update(capng.CAPNG_DROP, capng.CAPNG_EFFECTIVE, i)
if rc:
--
2.27.0

View File

@ -3,10 +3,13 @@
Summary: Libcap-ng is a library used for posix capabilities programming
Name: libcap-ng
Version: 0.8.2
Release: 1
Release: 2
License: LGPLv2+ and GPLv2+
URL: http://people.redhat.com/sgrubb/libcap-ng
Source0: https://people.redhat.com/sgrubb/libcap-ng/%{name}-%{version}.tar.gz
Patch1: backport-Make-Python-test-script-compatible-with-Python2-and-Python3.patch
BuildRequires: gcc, kernel-headers >= 2.6.11, libattr-devel
Provides: %{name}-utils = %{version}-%{release}
Obsoletes: %{name}-utils < %{version}-%{release}
@ -96,6 +99,12 @@ make check
%attr(0644,root,root) %{_mandir}/man8/*
%changelog
* Wed Oct 19 2022 yixiangzhike <yixiangzhike007@163.com> - 0.8.2-2
- Type:bugfix
- ID:NA
- SUG:NA
- DESC:make Python test script compatible with Python2 and Python3
* Fri Dec 24 2021 yixiangzhike <yixiangzhike007@163.com> - 0.8.2-1
- Type:enhancement
- ID:NA