mirror of https://github.com/zulip/zulip.git
python: Fix __dict__ mutation abuse.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
This commit is contained in:
parent
b45484573e
commit
5e1ebf2861
|
@ -173,12 +173,11 @@ def generate_and_save_stripe_fixture(
|
|||
stripe_object = mocked_function(*args, **kwargs)
|
||||
except stripe.error.StripeError as e:
|
||||
with open(fixture_path, "w") as f:
|
||||
error_dict = e.__dict__
|
||||
error_dict["headers"] = dict(error_dict["headers"])
|
||||
error_dict = {**vars(e), "headers": dict(e.headers)}
|
||||
f.write(
|
||||
json.dumps(error_dict, indent=2, separators=(",", ": "), sort_keys=True) + "\n"
|
||||
)
|
||||
raise e
|
||||
raise
|
||||
with open(fixture_path, "w") as f:
|
||||
if stripe_object is not None:
|
||||
f.write(str(stripe_object) + "\n")
|
||||
|
|
|
@ -50,7 +50,7 @@ Usage examples:
|
|||
for realm in realms:
|
||||
# Start with just all the fields on the object, which is
|
||||
# hacky but doesn't require any work to maintain.
|
||||
realm_dict = realm.__dict__
|
||||
realm_dict = vars(realm).copy()
|
||||
# Remove a field that is confusingly useless
|
||||
del realm_dict["_state"]
|
||||
# Fix the one bitfield to display useful data
|
||||
|
|
Loading…
Reference in New Issue