frida / frida-website

Frida's website
MIT License
83 stars 190 forks source link

example.py:19: DeprecationWarning: Script.exports will become asynchronous in the future, use the explicit Script.exports_sync instead #267

Open smcpeak opened 7 months ago

smcpeak commented 7 months ago

Following the instructions at https://frida.re/docs/installation/ , when I run example.py, it prints a mysterious deprecation warning:

$ python3 example.py
/home/scott/wrk/learn/frida/example/example.py:19: DeprecationWarning: Script.exports will become asynchronous in the future, use the explicit Script.exports_sync instead
  print([m["name"] for m in script.exports.enumerate_modules()])
['cat', 'linux-vdso.so.1', 'libc-2.31.so', 'ld-2.31.so', 'libpthread-2.31.so', 'libdl-2.31.so', 'librt-2.31.so', 'libm-2.31.so']

Googling the error message only yields one hit for that specific error, which is the source code at https://github.com/frida/frida-python/blob/main/frida/core.py that prints it.

Although not immediately obvious, I found I could fix the warning by changing exports to exports_sync:

print([m["name"] for m in script.exports_sync.enumerate_modules()])

I suggest updating the example on the website to do likewise.

I also suggest clarifying the warning to make it more obvious how to fix it, for example:

DeprecationWarning: The 'exports' method is deprecated, use 'exports_sync' instead.

I think this warning is clearer because it avoids the confusion of Script versus script, omits the unnecessary explanation about why it is deprecated (the user likely does not care, and the two names imply the rationale anyway), and omits unnecessarily saying "explicit", which at first I thought might be referring to some new Python syntax (like the explicit keyword in C++).

Frida version: 16.1.11 Python version: 3.9.13 (built from source) OS: Linux Mint 20.1 Frida obtained via pip3 install frida-tools.