bokeh: DatePicker errors on input from Chrome on Windows 8.1

Using Chrome 52 on Windows 8.1, I find that DatePicker throws an error on any value chosen from the dropdown calendar. For same Chrome version on Mac OS X, I find that it always works.

I am using bokeh 0.12.0-1.

I have a bokeh server with the following code in app/main.py:

from bokeh.io import curdoc
from bokeh.models import DatePicker

curdoc().add_root(DatePicker())

and run with the command

bokeh serve --log-level debug app

The exception is:

2016-08-16 15:16:51,365 error handling message Message 'PATCH-DOC' (revision 1): ValueError('Unknown string format',)
2016-08-16 15:16:51,365   message header {'msgid': '8B5BE6EBF7044F8793268769745D6C7A', 'msgtype': 'PATCH-DOC'} content {'events': [{'new': 'Mon Aug 01 2016 00:00:00 GMT-0400 (Eastern Daylight Time)', 'model': {'type': 'DatePicker', 'id': '5f8ecfc4-a06e-428f-b21d-6ed1a34cefff'}, 'attr': 'value', 'kind': 'ModelChanged'}], 'references': []}
Traceback (most recent call last):
  File "/Users/rheineke/anaconda/lib/python3.5/site-packages/bokeh/server/protocol/server_handler.py", line 38, in handle
    work = yield handler(message, connection)
  File "/Users/rheineke/anaconda/lib/python3.5/site-packages/tornado/gen.py", line 1008, in run
    value = future.result()
  File "/Users/rheineke/anaconda/lib/python3.5/site-packages/tornado/concurrent.py", line 232, in result
    raise_exc_info(self._exc_info)
  File "<string>", line 3, in raise_exc_info
  File "/Users/rheineke/anaconda/lib/python3.5/site-packages/tornado/gen.py", line 1017, in run
    yielded = self.gen.send(value)
  File "/Users/rheineke/anaconda/lib/python3.5/site-packages/bokeh/server/session.py", line 45, in _needs_document_lock_wrapper
    result = yield yield_for_all_futures(func(self, *args, **kwargs))
  File "/Users/rheineke/anaconda/lib/python3.5/site-packages/bokeh/server/session.py", line 217, in _handle_patch
    message.apply_to_document(self.document)
  File "/Users/rheineke/anaconda/lib/python3.5/site-packages/bokeh/server/protocol/messages/patch_doc.py", line 92, in apply_to_document
    doc.apply_json_patch(self.content)
  File "/Users/rheineke/anaconda/lib/python3.5/site-packages/bokeh/document.py", line 955, in apply_json_patch
    patched_obj.set_from_json(attr, value, models=references)
  File "/Users/rheineke/anaconda/lib/python3.5/site-packages/bokeh/core/properties.py", line 735, in set_from_json
    prop.set_from_json(self, json, models)
  File "/Users/rheineke/anaconda/lib/python3.5/site-packages/bokeh/core/properties.py", line 371, in set_from_json
    models)
  File "/Users/rheineke/anaconda/lib/python3.5/site-packages/bokeh/core/properties.py", line 323, in set_from_json
    return self.__set__(obj, json)
  File "/Users/rheineke/anaconda/lib/python3.5/site-packages/bokeh/core/properties.py", line 455, in __set__
    value = self.descriptor.prepare_value(obj.__class__, self.name, value)
  File "/Users/rheineke/anaconda/lib/python3.5/site-packages/bokeh/core/properties.py", line 274, in prepare_value
    value = self.transform(value)
  File "/Users/rheineke/anaconda/lib/python3.5/site-packages/bokeh/core/properties.py", line 1529, in transform
    value = dateutil.parser.parse(value).date()
  File "/Users/rheineke/anaconda/lib/python3.5/site-packages/dateutil/parser.py", line 1164, in parse
    return DEFAULTPARSER.parse(timestr, **kwargs)
  File "/Users/rheineke/anaconda/lib/python3.5/site-packages/dateutil/parser.py", line 555, in parse
    raise ValueError("Unknown string format")

About this issue

  • Original URL
  • State: closed
  • Created 8 years ago
  • Comments: 26 (13 by maintainers)

Commits related to this issue

Most upvoted comments

@bryevdv I can confirm the findings of @artur-scholz. The problem is in date_picker.coffee.

  _on_select: (date) =>
    @model.value = date.toString()
    @change_input()

Resulting on win10/IE to: "‘Sun Sep 24 2017 00:00:00 GMT+0200 (Mitteleuropäische Sommerzeit)’ Fix is easy.

  _on_select: (date) =>
    @model.value = date.toISOString()
    @change_input()

Resulting to: “2017-09-22T22:00:00.00Z”

The former cannot be parsed by dateutil:

>>> value = dateutil.parser.parse('Sun Sep 24 2017 00:00:00 GMT+0200 (Mitteleuropäische Sommerzeit)')
Traceback (most recent call last):
  File "/home/volker/workspace/eprofile/lib/python3.5/site-packages/python_dateutil-2.6.1-py3.5.egg/dateutil/parser.py", line 559, in parse
    raise ValueError("Unknown string format")
ValueError: Unknown string format

The later can be parsed.

>>> dateutil.parser.parse('2017-09-22T22:00:00.00Z')
datetime.datetime(2017, 9, 22, 22, 0, tzinfo=tzutc())

@bryevdv Shall I create a PR?