xonsh / lazyasd

Lazy & self-destructive tools for speeding up module imports
http://xon.sh
BSD 3-Clause "New" or "Revised" License
52 stars 8 forks source link

LazyObject in dictionaries don't serialize #16

Open con-f-use opened 2 years ago

con-f-use commented 2 years ago

image

@scopatz @gforsyth

json.dumps({"key": LazyObject(lambda: "nope", {}, 'lo')})  # TypeError: Object of type str is not JSON serializable

Gives the confusing (pun) error message of TypeError: Object of type str is not JSON serializable. Yes it is, Mr. Python, Sir!

Not sure but maybe the __hash__ method must be passed through or something. One might think about pickle and __get_state__, too.