File tree Expand file tree Collapse file tree 4 files changed +15
-2
lines changed
src/libpython_clj2/python Expand file tree Collapse file tree 4 files changed +15
-2
lines changed Original file line number Diff line number Diff line change 11# Time for a ChangeLog!
22
3+ ## 2.00-beta-19
4+ * [ issue 126] ( https://github.com/clj-python/libpython-clj/issues/126 ) - Python maps sometimes fail to destructure.
5+
36## 2.00-beta-18
47 * Additional fix for 162 to allow booleans to be considered primitives and be output inline.
58 * Experimental fix for [ issue 164] ( https://github.com/clj-python/libpython-clj/issues/164 ) - Unsigned int64 fails with
Original file line number Diff line number Diff line change 11{:paths [" src" ]
22 :deps {org.clojure/clojure {:mvn/version " 1.10.2" :scope " provided" }
3- cnuernber/dtype-next {:mvn/version " 7.13 " }
3+ cnuernber/dtype-next {:mvn/version " 8.00 " }
44 net.java.dev.jna/jna {:mvn/version " 5.7.0" }
55 org.clojure/data.json {:mvn/version " 1.0.0" }}
66
Original file line number Diff line number Diff line change 310310 iterator-seq
311311 set)))
312312 (get [this obj-key]
313- (py-call " __getitem__" obj-key))
313+ ; ;Specifically return nil to match java map expectations
314+ ; ;and thus allow destructuring.
315+ (when (py-call " __contains__" obj-key)
316+ (py-call " __getitem__" obj-key)))
314317 (getOrDefault [item obj-key obj-default-value]
315318 (if (.containsKey item obj-key)
316319 (.get item obj-key)
Original file line number Diff line number Diff line change @@ -407,6 +407,13 @@ class Foo:
407407 (is (= 8 (py/call-attr py-data " __len__" )))))
408408
409409
410+ (deftest python-as-jvm-destructuring
411+ (let [py-dict (py/->python {:a 1 })
412+ jvm-py-dict (py/as-jvm py-dict)
413+ {:keys [a b]} jvm-py-dict]
414+ (is (nil? b))))
415+
416+
410417(comment
411418 (require '[libpython-clj.require :refer [require-python]])
412419
You can’t perform that action at this time.
0 commit comments