Skip to content

Commit

Permalink
Removing "U" flag as it is removed from Python3.11!
Browse files Browse the repository at this point in the history
"U" flag was deprecated since Python3.3 but has been removed from Python3.11. This "universal newline" mode is by default enabled whenever a file is opened in text mode.
For reference : https://docs.python.org/3/whatsnew/3.11.html
Signed-off-by: Anushree Mathur <[email protected]>
  • Loading branch information
Anushree-Mathur committed Jan 16, 2024
1 parent 69a6f01 commit 82e02e2
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions libvirt/tests/src/virsh_cmd/domain/virsh_emulatorpin.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import os
import logging as log
import random
import sys

from avocado.utils import cpu
from avocado.utils import process
Expand Down Expand Up @@ -28,7 +29,12 @@ def get_emulatorpin_from_cgroup(params, test):
:raises: test.error if an error happens
"""
vm = params.get("vm")

# U flag was deprecated since Python3.3
# and got removed in Python3.11 . It is by default enabled.
if sys.version_info >= (3, 11):
flag = "r"
else:
flag = "rU"
cg_obj = libvirt_cgroup.CgroupTest(vm.get_pid())
cpuset_path = cg_obj.get_cgroup_path("cpuset")
if cg_obj.is_cgroup_v2_enabled():
Expand All @@ -38,7 +44,7 @@ def get_emulatorpin_from_cgroup(params, test):
cpuset_file = os.path.join(cpuset_path, "cpuset.cpus")

try:
with open(cpuset_file, "rU") as f_emulatorpin_params:
with open(cpuset_file, flag) as f_emulatorpin_params:
emulatorpin_params_from_cgroup = f_emulatorpin_params.readline()
return emulatorpin_params_from_cgroup
except IOError:
Expand Down

0 comments on commit 82e02e2

Please sign in to comment.