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 1
1
# Time for a ChangeLog!
2
2
3
+ ## 2.00-beta-19
4
+ * [ issue 126] ( https://github.com/clj-python/libpython-clj/issues/126 ) - Python maps sometimes fail to destructure.
5
+
3
6
## 2.00-beta-18
4
7
* Additional fix for 162 to allow booleans to be considered primitives and be output inline.
5
8
* 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 1
1
{:paths [" src" ]
2
2
: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 " }
4
4
net.java.dev.jna/jna {:mvn/version " 5.7.0" }
5
5
org.clojure/data.json {:mvn/version " 1.0.0" }}
6
6
Original file line number Diff line number Diff line change 310
310
iterator-seq
311
311
set)))
312
312
(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)))
314
317
(getOrDefault [item obj-key obj-default-value]
315
318
(if (.containsKey item obj-key)
316
319
(.get item obj-key)
Original file line number Diff line number Diff line change @@ -407,6 +407,13 @@ class Foo:
407
407
(is (= 8 (py/call-attr py-data " __len__" )))))
408
408
409
409
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
+
410
417
(comment
411
418
(require '[libpython-clj.require :refer [require-python]])
412
419
You can’t perform that action at this time.
0 commit comments