clj-python / clj-python/libpython-clj

as-jvm failed for a returned list

未关闭
#269 3 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

主要语言
Clojure
星标
1.2k
派生
74
PR 合并指标
30 天内没有已合并 PR

描述

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.

贡献指南

打开贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

调研方向

首先使用 libpython-clj、py/as-list 和 Cheshire 的 json/generate-string,根据报告中的 snippet 重现该问题,然后将返回的列表与正常工作的 map 情况进行比较。Issue 中链接的演示仓库包含额外的重现上下文。完成的标准是确定列表为何以错误的形式到达 Cheshire,并确认返回的列表可以编码为 JSON,而不会出现报告中的 ClassCastException。

由索引模型根据 Issue 内容生成。

评估

技术栈
clojure, python
领域
backend
Issue 类型
缺陷
难度
3/5
预计耗时
1-2 天
活跃度
停滞
描述清晰度
基本清楚
新手友好度
42/100

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。