Literals which are unquoted strings not being verified for JSON syntax
まだ誰も着手していません。
評価
調査の方向性
提供された Python スクリプトと jmespath.search() のエントリポイントから始め、実装がリテラル式をどのように処理しているかを、リンク先の JMESPath literal-expressions 仕様と比較してください。引用符で囲まれていないリテラルの内容が構文エラーになることが必須かどうかを確認し、wat、3、および `{"foo": bar}” のようなケースで動作を検証してください。
索引モデルが issue の本文から書いたものです。
説明
My understanding based on the specification is that the content of a literal expression, i.e. the text between backticks, is supposed to be a valid JSON expression, otherwise it should be reported as a syntax error. The Python implementation seems to be treating them as strings instead, though. For example, this is accepted as a valid JMESPath expression:
thing == `wat`
even though I would think it should cause an error. Is this an actual bug in the Python implementation, or have I been misunderstanding the spec? (In the latter case I'd argue that the spec is misleading about this to the point of it being a documentation bug, but that's a separate issue.)
Here's a short script that demonstrates the error:
import jmespath, json, sys
literal_json = 'wat'
expression = f"thing == `{literal_json}`"
document = {"thing": "wat"}
try:
r = json.loads(literal_json)
except Exception as e:
print(f"json: parse error: {e.__class__.__name__}")
else:
print("json: no parse error")
print(f" result: {r!r}")
try:
r = jmespath.search(expression, document)
except Exception as e:
print(f"jmespath: parse error: {e.__class__.__name__}")
else:
print("jmespath: no parse error")
print(f" result: {r!r}")
It prints out the following:
$ python test-jmespath.py
json: parse error: JSONDecodeError
jmespath: no parse error
result: True
I would expect to see the jmespath part of the output be the same as the json part of the output, i.e. some kind of parsing error. And if I try other kinds of values, I do indeed get consistent results. For example, replacing the literal_json assignment line with literal_json = '3' gives
$ python test-jmespath.py
json: no parse error
result: 3
jmespath: no parse error
result: False
and if I replace it with literal_json = '{"foo": bar}' I get
$ python test-jmespath.py
json: parse error: JSONDecodeError
jmespath: parse error: LexerError
- 主要言語
- Python
- スター
- 2.5k
- フォーク
- 231
- PR マージ指標
- 30日以内にマージされた PR はありません
環境構築
このプロジェクトには開発コンテナ、Dockerfile、コントリビューションガイドがありません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
jmespath/jmespath.py のほかの issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 65/100
jmespath/jmespath.py#401 ·
-
floor() and ceil() raise OverflowError / ValueError on Infinity and NaN対応中かも @guocn が 49 日前に担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
jmespath/jmespath.py#381 ·
-
Lexer gives quoted identifiers an `end` that is the token length, not its end offset対応中かも @chiliec が 50 日前に担当しました。 オープン
難易度 1/5 1時間未満 初心者へのやさしさ 20/100
jmespath/jmespath.py#380 ·
-
sdist is missing `tests/__init__.py`対応中かも @deepakganesh78 が 127 日前に担当しました。 オープンbug
難易度 2/5 1〜3時間 初心者へのやさしさ 38/100
jmespath/jmespath.py#341 · コメント 1 件 ·
-
Different behavior on merge function between the JS lib and the Python lib再び着手できるかも このイシューのプルリクエストはマージされずにクローズされました。 オープン
難易度 4/5 3〜5日 初心者へのやさしさ 42/100
jmespath/jmespath.py#329 · コメント 1 件 ·
jmespath/jmespath.py の issue をすべて見る
似ている issue
-
bug TAG: unit tests
難易度 2/5 1〜3時間 初心者へのやさしさ 65/100
learningequality/ricecooker#898 ·
-
task
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
freelawproject/litigant-portal#1285 ·
メンテナーはふだん 2 日以内に返信
-
least_squares returns a nonfinite objective for an invalid initial residual対応中かも @sylvesterkaczmarek が今日担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
google-deepmind/mujoco#4023 ·
メンテナーはふだん 11 日以内に返信
-
Five Australian birds: Red-capped Parrot, Red-winged Fairywren, Gilbert’s Honeyeater, Western Spinebill, Western Wattlebird対応中かも このイシューにリンクされたプルリクエストがオープン中、またはマージ済みです。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 66/100
arnegiacomo/fugleramme#427 ·
メンテナーはふだん 1 日以内に返信
-
MONDO's zebu and cat Arnold-Chiari terms are is_a a dog disease (monarch-initiative/mondo#10939)オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
NCATSTranslator/Babel#1317 ·
メンテナーはふだん 2 日以内に返信