Skip to content

Checking for python version for the open_binary and files calls#373

Open
TedyonGit wants to merge 1 commit into
K0lb3:masterfrom
TedyonGit:patch-2
Open

Checking for python version for the open_binary and files calls#373
TedyonGit wants to merge 1 commit into
K0lb3:masterfrom
TedyonGit:patch-2

Conversation

@TedyonGit

Copy link
Copy Markdown

I just wanted to fix the warning "DeprecationWarning".
So i just added a check for python version. If the python version is >= 3.9, then is going to use files call.
If not, is going to fallback to open_binary.

Is not much, but i hope it helps :D

@K0lb3

K0lb3 commented Jun 13, 2026

Copy link
Copy Markdown
Owner

Thanks,
and sorry for the late response.

I think that there was a reason I didn't implement this, but I can't recall it anymore.
Maybe I also simply did something wrong at that time, so let's see if the tests pass across different python versions and systems.

Comment thread UnityPy/helpers/Tpk.py
def init():
with open_binary("UnityPy.resources", "lzma.tpk") as f:
data = f.read()
try:

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Instead of try/except,
sys.version_info >= (3, 9)
would be a better option

@K0lb3

K0lb3 commented Jun 13, 2026

Copy link
Copy Markdown
Owner

^ tests failed due to a ruff formatting check

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.

2 participants