clj-python / clj-python/libpython-clj
as-jvm failed for a returned list
Nobody has claimed this yet.
- Dominant language
- Clojure
- Stars
- 1.2k
- Forks
- 74
- PR merge metrics
- No merged PRs in 30d
Description
Hi,
I experienced an issue while I was using libpython-clj to encode the returned list as json via cheshire, it threw an exception with this snippet:
(println "Just something interesting from Python:"
(-> (py/py. simple a_list)
py/as-list
json/generate-string))
The exception:
Execution error (ClassCastException) at cheshire.generate/generate$fn (generate.clj:135).
class java.lang.String cannot be cast to class java.util.Map$Entry (java.lang.String and java.util.Map$Entry are in module java.base of loader 'bootstrap')
And it worked fine for a map.
I've created a demo repo for this: https://github.com/whatacold/libpython-clj-as-jvm-issue, hopefully I've put all necessary info there.
Was there something I was missing? Thanks.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the issue from the reported snippet using libpython-clj, py/as-list, and Cheshire's json/generate-string, then compare the returned list with the working map case. The demo repository linked in the issue contains the additional reproduction context. Done means identifying why the list reaches Cheshire in the wrong form and confirming that the returned list can be encoded as JSON without the reported ClassCastException.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- clojure, python
- Domain
- backend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100