| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
Sorry, something went wrong.
…d to default function
…d to default function
…d to default function
…d to default function
|
Based on #2857. Added test, Python implementation, docs. |
Sorry, something went wrong.
|
@etrepum, could you please look at this? What are your thoughts about this matter, is it worth to do? |
Sorry, something went wrong.
|
This does catch some possible errors, but there are plenty of other ways to run into similar issues if you're not careful. For example: >>> json.dumps(..., default=lambda x: [lambda x: x])
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/opt/homebrew/Cellar/python@3.11/3.11.6_1/Frameworks/Python.framework/Versions/3.11/lib/python3.11/json/__init__.py", line 238, in dumps
**kw).encode(obj)
^^^^^^^^^^^
File "/opt/homebrew/Cellar/python@3.11/3.11.6_1/Frameworks/Python.framework/Versions/3.11/lib/python3.11/json/encoder.py", line 200, in encode
chunks = self.iterencode(o, _one_shot=True)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/homebrew/Cellar/python@3.11/3.11.6_1/Frameworks/Python.framework/Versions/3.11/lib/python3.11/json/encoder.py", line 258, in iterencode
return _iterencode(o, 0)
^^^^^^^^^^^^^^^^^
RecursionError: maximum recursion depth exceeded while encoding a JSON objectPerhaps a general purpose "solution" would be to catch the RecursionError and re-raise with more useful context about the value that was being serialized? |
Sorry, something went wrong.
| Back | FazBrowse Home | New Git URL |
Co-authored-by: Siddharth Velankar svelankar@users.noreply.github.com
📚 Documentation preview 📚: https://cpython-previews--113458.org.readthedocs.build/