#6946 (weather says ValueError: unconverted data remains: AM)
by Luc Saffre · in Developers
Kokkuvõte
Request a weather forecast
Traceback (most recent call last):
File "/usr/local/lino/lino_local/stewards/env/lib/python3.13/site-packages/lino/modlib/linod/mixins.py", line 174, in start_task
await sync_to_async(self.run_task)(ar)
File "/usr/local/lino/lino_local/stewards/env/lib/python3.13/site-packages/asgiref/sync.py", line 526, in __call__
ret = await asyncio.shield(exec_coro)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3.13/concurrent/futures/thread.py", line 59, in run
result = self.fn(*self.args, **self.kwargs)
File "/usr/local/lino/lino_local/stewards/env/lib/python3.13/site-packages/asgiref/sync.py", line 581, in thread_handler
return func(*args, **kwargs)
File "/usr/local/lino/lino_local/stewards/env/lib/python3.13/site-packages/asgiref/sync.py", line 508, in func
return context.run(run_child)
~~~~~~~~~~~^^^^^^^^^^^
File "/usr/local/lino/lino_local/stewards/env/lib/python3.13/site-packages/asgiref/sync.py", line 506, in run_child
return child()
File "/usr/local/lino/lino_local/stewards/env/lib/python3.13/site-packages/lino/modlib/linod/models.py", line 27, in run_task
return self.procedure.run(ar)
~~~~~~~~~~~~~~~~~~^^^^
File "/usr/local/lino/lino_local/stewards/env/lib/python3.13/site-packages/lino/modlib/linod/choicelists.py", line 55, in run
return self.func(ar)
~~~~~~~~~^^^^
File "/usr/local/lino/lino_local/stewards/env/lib/python3.13/site-packages/lino_xl/lib/weather/models.py", line 163, in get_weather_forecasts
fc = async_to_sync(aget_weather_forecasts)(ar)
File "/usr/local/lino/lino_local/stewards/env/lib/python3.13/site-packages/asgiref/sync.py", line 332, in __call__
return call_result.result()
~~~~~~~~~~~~~~~~~~^^
File "/usr/lib/python3.13/concurrent/futures/_base.py", line 449, in result
return self.__get_result()
~~~~~~~~~~~~~~~~~^^
File "/usr/lib/python3.13/concurrent/futures/_base.py", line 401, in __get_result
raise self._exception
File "/usr/local/lino/lino_local/stewards/env/lib/python3.13/site-packages/asgiref/sync.py", line 372, in main_wrap
result = await awaitable
^^^^^^^^^^^^^^^
File "/usr/local/lino/lino_local/stewards/env/lib/python3.13/site-packages/lino_xl/lib/weather/models.py", line 184, in aget_weather_forecasts
return await client.get(dd.plugins.weather.place_name) # DailyForecast
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lino/lino_local/stewards/env/lib/python3.13/site-packages/python_weather/client.py", line 185, in get
return Forecast(await resp.json(content_type='text/plain'), unit, locale)
File "/usr/local/lino/lino_local/stewards/env/lib/python3.13/site-packages/python_weather/forecast.py", line 262, in __init__
datetime.strptime(current['observation_time'], '%I:%M %p').time(),
~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3.13/_strptime.py", line 673, in _strptime_datetime
tt, fraction, gmtoff_fraction = _strptime(data_string, format)
~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3.13/_strptime.py", line 455, in _strptime
raise ValueError("unconverted data remains: %s" %
data_string[found.end():])
ValueError: unconverted data remains: AM
Children
Kommentaarid
- 3 nädalat, 2 päeva ago by Luc Saffre about #6946 (weather says ValueError: unconverted data remains: AM) : I created a separate ticket for this: #7032.
- 1 kuu, 1 nädal ago by Luc Saffre about #6946 (weather says ValueError: unconverted data remains: AM) : I reported a new ticket: github.com/null8626/python-weather/issues/79
- 1 kuu, 1 nädal ago by Luc Saffre about #6946 (weather says ValueError: unconverted data remains: AM) : The doctest passes on GitLab under py313. In other words, I still can't reproduce the "ValueError: hour must be in 0..23". I'm giving up for now since there is a satisfying workaround: to not set the weather.locale plugin setting.
- 1 kuu, 1 nädal ago by Luc Saffre in reply to Luc Saffre about #6946 (weather says ValueError: unconverted data remains: AM) : I wrote a doctest for this in the book, in order to test it under Python 3.13.
- 1 kuu, 1 nädal ago by Luc Saffre in reply to Luc Saffre about #6946 (weather says ValueError: unconverted data remains: AM) : But I didn't yet manage to reproduce that failure in a simple script.
- 1 kuu, 1 nädal ago by Luc Saffre about #6946 (weather says ValueError: unconverted data remains: AM) (2 replies) : Oops, after upgrading the stewards site I have a new traceback:
Request a weather forecast
Traceback (most recent call last): File "/usr/local/lino/lino_local/stewards/env/lib/python3.13/site-packages/lino/modlib/linod/mixins.py", line 174, in start_task await sync_to_async(self.run_task)(ar) File "/usr/local/lino/lino_local/stewards/env/lib/python3.13/site-packages/asgiref/sync.py", line 526, in __call_... - 1 kuu, 1 nädal ago by Luc Saffre about #6946 (weather says ValueError: unconverted data remains: AM) : The author of python-weather released a fixed version to pypi. I should be able to reactivate the site_locale setting when I upgrade python-weather
- 1 kuu, 1 nädal ago by Luc Saffre about #6946 (weather says ValueError: unconverted data remains: AM) : I now removed the site_local = "be_fr" in their settings.py and the error disappeared. I don't remember why the site_locale setting was used... the removal doesn't seem to disturb.
- 1 kuu, 1 nädal ago by Luc Saffre about #6946 (weather says ValueError: unconverted data remains: AM) : It happens only when I also have the Python locale set to 'fr_BE.UTF-8'. Here is how I reproduced the problem (I also had to replace single quotes by double quotes in the json file for the following script to work):
import json import python_weather from python_weather.forecast import Forecast from ... - 2 kuud, 1 nädal ago by Luc Saffre about #6946 (weather says ValueError: unconverted data remains: AM) : Next step would be to search these files for timestamps that don't parse.
- 2 kuud, 1 nädal ago by Luc Saffre about #6946 (weather says ValueError: unconverted data remains: AM) : I locally modified python-weather to write the data into a json file instead of into the system log. /usr/local/lino/lino_local/stewards/env/lib/python3.13/site-packages/python_weather/forecast.py
from django.conf import settings from django.utils import timezone from json import dumps
And in the F... - 2 kuud, 3 nädalat ago by Luc Saffre about #6946 (weather says ValueError: unconverted data remains: AM) : I got python-weather to log the json dict of every incoming request to the Lino logger before parsing it. But that's not enough: the dict is very big, even with pprint some lines are longer than a terminal line, so I would not be able to easily copy and report that data. Next step todo: have python-...
- 2 kuud, 3 nädalat ago by Luc Saffre about #6946 (weather says ValueError: unconverted data remains: AM) : I submitted an issue on the python-weather project page on GitHub: github.com/null8626/python-weather/issues/75
- 2 kuud, 3 nädalat ago by Luc Saffre about #6946 (weather says ValueError: unconverted data remains: AM) : Workaround: nano /usr/local/lino/lino_local/stewards/env/lib/python3.13/site-packages/python_weather/forecast.py and then from dateutils import parser and in line 262, replace: datetime.strptime(current['observation_time'], '%I:%M %p').time(), by: parser.parse(current['observation_time'])...
- 2 kuud, 3 nädalat ago by Luc Saffre about #6946 (weather says ValueError: unconverted data remains: AM) : Created new Ticket #6946 (weather says ValueError: unconverted data remains: AM).