Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update/Fixup string encoding to for Python3 and fix UTF-8 for Python2 too #28

Conversation

bernhardkaindl
Copy link
Collaborator

Update/Fixup string encoding to for Python3 while not breaking Python2

Tested as the first commit which keeps Python2 working, while have (seemingly) working Python3

Status: pylint --py3k has 3 TODOs left to fix, but this is the first version which works for Python3 as well! 🥇

Use the Files tab for the review which squashes the commits, or just review commit 2 and commit 4 (links below):
-> Commit 2 and 4 fully override commit 1 and 3, so they cancel/replace commit 1 and 3.

Commit 1: Remove the use of 'unicode'

Commit 2: Fixup commit 1: Update commit "Remove the use of 'unicode'" to unbreak Python2

Commit 3: Py3-only: Change str encoding from Python2 to only support Python3

Commit 4: Fixup commit 3: Update commit Py3-only: Change str encoding to unbreak Python2

Commit 5: Remove 'unicode-builtin' from the pylint --py3k TODO list

qinz0822 and others added 5 commits December 7, 2023 14:08
'unicode' is not available in python3, so remove the use of it. And for
python3 'bytes' string might need to be converted to a regular string

Signed-off-by: Qin Zhang (张琴) <[email protected]>
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 <[email protected]>
Signed-off-by: Qin Zhang (张琴) <[email protected]>
XSConsoleLang.py Outdated Show resolved Hide resolved
@bernhardkaindl bernhardkaindl changed the title Update/Fixup string encoding to for Python3 while not breaking Python2 Update/Fixup string encoding to for Python3 and fix UTF-8 for Python2 too Dec 8, 2023
@bernhardkaindl
Copy link
Collaborator Author

Testcase for convert_anything_to_str() added, and international chars are working in Python2 now!

Copy link

@edwintorok edwintorok left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks

@bernhardkaindl bernhardkaindl merged commit 889435c into xapi-project:master Dec 8, 2023
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants