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

Replacing deprecated alias tostring with tobytes #43

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

guzmud
Copy link

@guzmud guzmud commented Sep 6, 2021

Tostring is now (python 3.9) a deprecated alias for tobytes. Since peframe requires python 3.6 (according to README) and tobytes has been introduced in python 3.2, there is no loss from removing the use of the alias in this project while upgrading python compatibility to 3.9 eventually.

Disclosure: I haven't fully tested it, you may want to build and run in a python 3.9 docker before merging, or set-up some automated tests using github actions. Can help on that if you want.

Tostring is now (python 3.9) a deprecated alias for tobytes. Since peframe requires python 3.6 and tobytes being introduced in python 3.2, there is no loss from removing the use of the alias.
@gleeda
Copy link

gleeda commented Nov 2, 2021

I had the same issue and was about to issue a pull request. It might be good to make it more universal by first checking if you have the tostring attribute, and if not, then calling tobytes:

if (hasattr('delta', 'tostring')):
    return delta.tostring()[:-key_len]
return delta.tobytes()[:-key_len]

@guelfoweb
Copy link
Owner

thanks @gleeda I'll look better

@fr0gger
Copy link

fr0gger commented Nov 15, 2021

Just tested it as well and it works perfectly with python3.9, thanks for the fix! :)

@guzmud
Copy link
Author

guzmud commented Jan 17, 2022

Checking for tostring, as @gleeda suggested (no offense, nice suggestion imo), would be worth it if it was expected to be able to run for python version below 3.2. I'm not sure there wouldn't be any other compatibility issue, but that would help to avoid breaking some monkey patching in other projects or whatnot. Do you want the PR to be edited with that on my side @guelfoweb ?

@twpZero
Copy link

twpZero commented May 10, 2022

Confirmed that it fixes AttributeError: 'array.array' object has no attribute 'tostring' in peframe/modules/features.py on python 3.10 as well.

@fabian-z
Copy link

fabian-z commented Jun 19, 2023

I can confirm this fixes the AttributeError for Python 3.11.3.
Also compatibility should be no problem since the rename to tobyte was in place since Python v3.2 and peframe README specifies python >= 3.6.6. See Python array doc. According to release notes, this will break starting Python 3.9 (removal of deprecated alias).

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.

7 participants