Kosmorro / kosmorro

A program to calculate your ephemerides.
https://kosmorro.space
GNU Affero General Public License v3.0
60 stars 7 forks source link

Kosmorro throws an exception for the 08-11-2022 with JSON #241

Closed SpeedCode210 closed 2 years ago

SpeedCode210 commented 2 years ago

I have searched for an opened issue and didn't find my bug

Version of Kosmorro

0.10

Version of Python

3.10

Operating system

Linux

Installation source

PyPI

Bug description

Hello, kosmorro throws an exception when running it for 2022-11-08 with JSON format because of a LunarEclipse that can't be serialized to JSON

[raouf@dhcppc9 ~]$ kosmorro -f json -lat 36 -lon 5 -d 2022-11-08
Traceback (most recent call last):
  File "/home/raouf/.local/bin/kosmorro", line 24, in <module>
    sys.exit(main())
  File "/home/raouf/.local/lib/python3.10/site-packages/_kosmorro/main.py", line 124, in main
    print(output)
  File "/home/raouf/.local/lib/python3.10/site-packages/_kosmorro/dumper.py", line 80, in __str__
    return self.to_string()
  File "/home/raouf/.local/lib/python3.10/site-packages/_kosmorro/dumper.py", line 93, in to_string
    return json.dumps(
  File "/usr/lib64/python3.10/json/__init__.py", line 238, in dumps
    **kw).encode(obj)
  File "/usr/lib64/python3.10/json/encoder.py", line 201, in encode
    chunks = list(chunks)
  File "/usr/lib64/python3.10/json/encoder.py", line 431, in _iterencode
    yield from _iterencode_dict(o, _current_indent_level)
  File "/usr/lib64/python3.10/json/encoder.py", line 405, in _iterencode_dict
    yield from chunks
  File "/usr/lib64/python3.10/json/encoder.py", line 325, in _iterencode_list
    yield from chunks
  File "/usr/lib64/python3.10/json/encoder.py", line 405, in _iterencode_dict
    yield from chunks
  File "/usr/lib64/python3.10/json/encoder.py", line 405, in _iterencode_dict
    yield from chunks
  File "/usr/lib64/python3.10/json/encoder.py", line 438, in _iterencode
    o = _default(o)
  File "/usr/lib64/python3.10/json/encoder.py", line 179, in default
    raise TypeError(f'Object of type {o.__class__.__name__} '
TypeError: Object of type LunarEclipseType is not JSON serializable
Deuchnord commented 2 years ago

The primary issue is actually that Kosmorro was trying JSON for some events provided by Kosmorrolib, but that should be supported on next version of Kosmorro. Thanks for reporting this :)