This has come up in some testing related stuff I've been working on... Opening as a WIP because a lot of stuff fails as a result and trying to decide if it's worth fixing or if I should ignore it...
Currently:
CScript(["hello", "world"]) != CScript(["hello"]) + CScript(["world"])
CScript(["hello"]) + CScript(["world"]) == CScript(["hello", "\x06\x05world") == CScript(["hello", CScript(["world"]))
It doesn't seem like there's a way to reach CScript(["hello", "world"]) other than by chaining the iterators together, which is clunky.
This patch redefines addition of scripts such that:
CScript(["hello", "world"]) == CScript(["hello"]) + CScript(["world"])
CScript(["hello"]) + CScript(["world"]) != (CScript(["hello", "\x06\x05world") == CScript(["hello", CScript(["world"])))
Note that adding a raw bytes to a CScript preserves the old behavior, e.g., CScript(["hello"]) + "world" == CScript(["hello", "world"]).
An alternative to this is to get rid of the nested parameter to __coerce_instance and always leave CScript as concatenative -- e.g., CScript([a,CScript([b])]) == CScript([a,b]) == CScript([a]) + CScript([a,b]) and you have to coerce to bytes first to get a push. This breaks fewer tests, but seems a bit more subtle?