@buherator IDA and Ghidra specifically, or in a script (shell) also? They might handle state differently
@buherator It should definitely truncate. This is _very_ strange.
https://docs.python.org/3/library/functions.html#open
@buherator shouldn't happen, can you provide a reproducible example?
if i do
def write_to(path, s):
with open(path, "w") as fd:
fd.write(s)
write_to("/tmp/a", "hello ")
write_to("/tmp/a", "world")
And run it, i do see "world" only in the output file. Is that different from what you are doing?
Hi my friend
plz can you quote and donate to help my family plz help me 🙏🙏🙏🙏
@buherator @tmr232 @nieldk @tshirtman possibly so; it sounds like the root cause is reuse of the same list over multiple object instantiations, one way or another.
The classic python error in this form is functions like:
def f(items=[]):
providing an empty list as the default for the items parameter. But that list is made at function definition time, and gets reused on every call where the default is used.
I'd be happy to help debug your real code if you'd like. Mastadon a terrible place for such a conversionation though. Email, slack, discord?
@cs @buherator @tmr232 @nieldk i concur, very common bug in Python code, everyone has to be bitten once to learn this lesson.
Using a mutable default value is generally a mistake in python.
It makes sense once you understand that the python signature is a line of code evaluated when the module is imported, and that the value stored as default is an object created at that time, not every time the function is called.
@buherator @cs @nieldk @tshirtman might be worth giving Ruff and mypy a go. They catch _a lot_ of those gotchas. Here specifically - https://docs.astral.sh/ruff/rules/mutable-argument-default/