Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NaN values are not working when simplejson >= 3.19.0 is used #469

Open
2 of 3 tasks
andreasmueller92 opened this issue Apr 19, 2024 · 0 comments
Open
2 of 3 tasks

Comments

@andreasmueller92
Copy link

I have

  • Tested with the latest release
  • Tested with the current master branch
  • Searched for similar existing issues

Expected behaviour

NaN values should be allowed for upload when using simplejson

Actual behaviour

[...]
  File "<software-path>/lib/python3.11/site-packages/simplejson/encoder.py", line 379, in iterencode
    return _iterencode(o, 0)
           ^^^^^^^^^^^^^^^^^
ValueError: Out of range float values are not JSON compliant

Steps to reproduce the behaviour

  1. Have simplejson >= 3.19.0 available on the system
  2. pysolr.Solr(<SOLR_URL>).add([{'key': float('nan')}])

Reason

In version 3.19.0, simplejson deciced to change the default value for allow_nan to False for simplejson.dumps (Ctrl+F The default for allow_nan), which is used in pysolr 3.9.0 and simplejson.JSONEncoder (Ctrl+F 3.19.0: This default), used in pysolr 3.10 betas.

When not using simplejson but the default Python-JSON (which is done when simplejson is not available), this is not an issue, as NaN is allowed by default. This should be consistent across the different en-/decoders.

Possible solution

Explicitly set allow_nan=True when using simplejson

Configuration

  • Operating system version:
  • Search engine version:
  • Python version: 3.11.3
  • pysolr version: 3.9.0
  • simplejson version: 3.19.1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant