Skip to content

Commit

Permalink
Py3-only: Change str encoding from Python2 to only support Python3
Browse files Browse the repository at this point in the history
Note by Bernhard: As per the agreement with Andrew in xapi-project#18, we shall
keep master py2-compatible and py3-only changes go to a py3 branch:

Andrew wrote:
> However, master needs to remain atomically py2 or py3 compatible,
> and not a mix of fixes which leaves it broken in both. [...]
> please keep all commits which break compatibility with py2 in a
> separate single PR so it can be merged all in one go.
> The final commit on the py3 branch should [...]
Reference:
xapi-project#18 (comment)

Therefore, I'll squash this commit with the next commit for fixing
it up keep master py2-compatible, at least until all py3 checks and
a complete manual test was done by QA.

Original commit message by Qin Zhang (张琴):
Remove the use of 'encode' as it's used to turn a Unicode string into a regular string in Python2

Final Remarks by Bernhard, for completeleness:
- This commit also adds conversion from curses input bytes to str.
- Rebased to apply on the current master branch.

Co-authored-by: Bernhard Kaindl <bernhard.kaindl@cloud.com>
Signed-off-by: Qin Zhang (张琴) <qin.zhang@citrix.com>
  • Loading branch information
qinz0822 and bernhardkaindl committed Dec 7, 2023
1 parent 05b27be commit d15d32b
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
6 changes: 3 additions & 3 deletions XSConsoleCurses.py
Original file line number Diff line number Diff line change
Expand Up @@ -278,11 +278,11 @@ def Snapshot(self):
if self.title != "":
retVal.append(self.title)
if self.hasBox:
for i in range(1, self.ySize-1):
retVal.append(self.win.instr(i, 1, self.xSize-2))
for i in range(1, self.ySize - 1):
retVal.append(self.win.instr(i, 1, self.xSize - 2).decode('utf-8'))
else:
for i in range(self.ySize):
retVal.append(self.win.instr(i, 0, self.xSize))
retVal.append(self.win.instr(i, 0, self.xSize).decode('utf-8'))

return retVal

Expand Down
6 changes: 3 additions & 3 deletions plugins-base/XSFeatureSRCommon.py
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ def UpdateFieldsINITIAL(self):
pane.ResetFields()

sr = HotAccessor().sr[self.srHandle]
srName = sr.name_label(None).encode('utf-8')
srName = sr.name_label(None)
if srName is None:
pane.AddTitleField(Lang("The Virtual Machine is no longer present"))
else:
Expand All @@ -226,7 +226,7 @@ def UpdateFieldsCONFIRM(self):
pane.ResetFields()

sr = HotAccessor().sr[self.srHandle]
srName = sr.name_label(None).encode('utf-8')
srName = sr.name_label(None)
if srName is None:
pane.AddTitleField(Lang("The Storage Repository is no longer present"))
else:
Expand Down Expand Up @@ -282,7 +282,7 @@ def Commit(self):
Layout.Inst().PopDialogue()

operationName = SRUtils.OperationName(self.operation)
srName = HotAccessor().sr[self.srHandle].name_label(Lang('<Unknown>')).encode('utf-8')
srName = HotAccessor().sr[self.srHandle].name_label(Lang('<Unknown>'))
messagePrefix = operationName + Lang(' operation on ') + srName + ' '
Layout.Inst().TransientBanner(messagePrefix+Lang('in progress...'))
try:
Expand Down
6 changes: 3 additions & 3 deletions plugins-base/XSFeatureVMCommon.py
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ def UpdateFieldsINITIAL(self):
pane.ResetFields()

vm = HotAccessor().guest_vm[self.vmHandle]
vmName = vm.name_label(None).encode('utf-8')
vmName = vm.name_label(None)
if vmName is None:
pane.AddTitleField(Lang("The Virtual Machine is no longer present"))
else:
Expand All @@ -190,7 +190,7 @@ def UpdateFieldsCONFIRM(self):
pane.ResetFields()

vm = HotAccessor().vm[self.vmHandle]
vmName = vm.name_label(None).encode('utf-8')
vmName = vm.name_label(None)
if vmName is None:
pane.AddTitleField(Lang("The Virtual Machine is no longer present"))
else:
Expand Down Expand Up @@ -252,7 +252,7 @@ def Commit(self):
Layout.Inst().PopDialogue()

operationName = VMUtils.OperationName(self.operation)
vmName = HotAccessor().guest_vm[self.vmHandle].name_label(Lang('<Unknown>')).encode('utf-8')
vmName = HotAccessor().guest_vm[self.vmHandle].name_label(Lang('<Unknown>'))
messagePrefix = operationName + Lang(' operation on ') + vmName + ' '
try:
task = VMUtils.AsyncOperation(self.operation, self.vmHandle, *self.opParams)
Expand Down

0 comments on commit d15d32b

Please sign in to comment.