Skip to content

Conversation

@Eddy114514
Copy link
Collaborator

Add a wrapper in base64.py that wrap b64encode, b32encode, b16encode, encodebytes, allowing them to warn user the behavior difference between python2 and python3. Methods' name are listed in the warning message.

warning is as following:
image

Add test functions in test_base64.py to test whether warning messages shows up.

Copy link
Collaborator

@nanjekyejoannah nanjekyejoannah left a comment

Choose a reason for hiding this comment

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

Main points: Use Py3kWarning Exception and don't prepend Pygrate2

Lib/base64.py Outdated

_WARAP_FUNC = ["b64encode", "b32encode", "b16encode", "encodebytes"]
for _name in _WARAP_FUNC:
if _name in __all__:
Copy link
Member

Choose a reason for hiding this comment

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

Are there situations in which _name couldn't be in __all__? I think these functions are always available, on all platforms?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

In order to solve this compactivity issue, would using globals() instead of __all__ be a good solution to it?
`

for _name in ["b64encode", "b32encode", "b16encode", "encodebytes"]:
    if _name in globals():
       globals()[_name] = _warn_encode(globals()[_name], _name)

`

Copy link
Member

Choose a reason for hiding this comment

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

@Eddy114514 Still wondering about this one.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@ltratt After checking with documentations, I think "b64/b32/b16encode" exists in both 2.6 and 3.x, but I should remove encodebytes as it doesn't exist in python 2.

After removing it, I think it is suitable to remove the if-statement

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@ltratt Hi, I am wondering if my new implementation resolve the concern. thanks

@ltratt
Copy link
Member

ltratt commented Sep 12, 2025

@Eddy114514 If you could ping me when you've made updates, it'll help me review them quicker (otherwise I won't notice). Reviewing now.

@Eddy114514
Copy link
Collaborator Author

@Eddy114514 If you could ping me when you've made updates, it'll help me review them quicker (otherwise I won't notice). Reviewing now.

@ltratt Understood, thanks for pointing it out, I will make sure to ping you with updates going forward, sorry about it.

Copy link
Collaborator Author

@Eddy114514 Eddy114514 left a comment

Choose a reason for hiding this comment

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

add more test cases to cover b32,16 in test_base64

Lib/base64.py Outdated

_WARAP_FUNC = ["b64encode", "b32encode", "b16encode", "encodebytes"]
for _name in _WARAP_FUNC:
if _name in __all__:
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

In order to solve this compactivity issue, would using globals() instead of __all__ be a good solution to it?
`

for _name in ["b64encode", "b32encode", "b16encode", "encodebytes"]:
    if _name in globals():
       globals()[_name] = _warn_encode(globals()[_name], _name)

`

Lib/base64.py Outdated

_WARAP_FUNC = ["b64encode", "b32encode", "b16encode", "encodebytes"]
for _name in _WARAP_FUNC:
if _name in __all__:
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@ltratt After checking with documentations, I think "b64/b32/b16encode" exists in both 2.6 and 3.x, but I should remove encodebytes as it doesn't exist in python 2.

After removing it, I think it is suitable to remove the if-statement

@ltratt
Copy link
Member

ltratt commented Sep 24, 2025

Please squash. [Note: this doesn't mean you have to squash things down to a single commit, though you can if you want! It does mean that I'd like you to squash down to what you consider a sensible number of commits. More details of this process at https://ykjit.github.io/yk/contributing/prs.html]

@Eddy114514
Copy link
Collaborator Author

Please squash. [Note: this doesn't mean you have to squash things down to a single commit, though you can if you want! It does mean that I'd like you to squash down to what you consider a sensible number of commits. More details of this process at https://ykjit.github.io/yk/contributing/prs.html]

@ltratt Thank you for your instruction, I have squash my commits

@ltratt ltratt enabled auto-merge September 25, 2025 11:15
@ltratt ltratt added this pull request to the merge queue Sep 25, 2025
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Sep 25, 2025
@ltratt
Copy link
Member

ltratt commented Sep 25, 2025

Hmm, I'm not quite sure why that C code isn't building anymore. It's not directly related to this PR, but it will block it being merged. @Eddy114514 are you able to replicate this issue locally?

@Eddy114514
Copy link
Collaborator Author

Eddy114514 commented Sep 25, 2025

Hmm, I'm not quite sure why that C code isn't building anymore. It's not directly related to this PR, but it will block it being merged. @Eddy114514 are you able to replicate this issue locally?

@ltratt I am unable to replicate this issue locally, I can successfully build and run pygrate 2 (and test) locally by following steps (make distclean, ./configure, make -j). However it do will throw some warning and note during "make -j". As following:
image

@ltratt
Copy link
Member

ltratt commented Sep 25, 2025

This might be because we're using a new Debian in CI. Will confirm in the morning with luck!

@ltratt ltratt added this pull request to the merge queue Sep 26, 2025
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Sep 26, 2025
@ltratt
Copy link
Member

ltratt commented Sep 26, 2025

OK, that failure is a genuine error with this PR I think. @Eddy114514 hopefully you can see the builbot log above.

@Eddy114514
Copy link
Collaborator Author

OK, that failure is a genuine error with this PR I think. @Eddy114514 hopefully you can see the builbot log above.

@ltratt thanks for checking, after checking the log I figured out the problem. My test cases in test_base64 assume python will run with -3 flag such that it will check warnings. I will remove them and only those in py3kwarn

@Eddy114514
Copy link
Collaborator Author

@ltratt I have squashed my change, the failed test file in log is test_base64, I tested again (for it and for all) in local. I think it should be ready to merge. Thank you for your help.

@ltratt
Copy link
Member

ltratt commented Sep 26, 2025

Please squash.

@Eddy114514
Copy link
Collaborator Author

Please squash.

@ltratt squashed to 1 now.

@ltratt ltratt added this pull request to the merge queue Sep 26, 2025
Merged via the queue into softdevteam:migration with commit f029068 Sep 26, 2025
2 checks 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.

3 participants