Closed marinelay closed 5 months ago
Thanks for the report. We usually deal with those by implicitly converting string arguments to bytes and only use bytes internally. There is misc.need_bytes
for this. Would you be willing to propose a pull request to fix this?
Sure!
As I understand your comment, you use bytes internally, so you're asking me to ensure that bytes can be used without errors as well. If I've misunderstood, please let me know.
Additionally, I looked up misc.need_bytes
, but I found only util.packing._need_bytes
function.
I think it is a function that replaces str to bytes, whereas we need the opposite functionality for this issue.
Hence, I will use util.packing._need_text
or util.packing._decode
to solve this issue.
If the above is okay, I'll write PR for you!
https://github.com/Gallopsled/pwntools/blob/5981c7290dd5190733c1f2e9ccf08633869f8b31/pwnlib/context/__init__.py#L1007-L1039
In the code, it seems that
Context.log_file
allows bytes type (at line 1034), but it raisesTypeError: a bytes-like object is required, not 'str'
at line 1036 in Python 3.x.I think it makes sense to either delete bytes type or cast it to string type. If bytes is for Python 2.x, then it would be nice to replace it to str (because str and bytes are same in Python 2.x).
It is simplified code raising TypeError:
Thank you!