Python Problems

From Official Kodi Wiki
Revision as of 15:22, 11 January 2022 by Fbacher (talk | contribs) (Created page with "This page is meant to document Python issues of general interest to Kodi addon developers. == datetime.strptime == There is an old Python bug (https://bugs.python.org/issue274...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

This page is meant to document Python issues of general interest to Kodi addon developers.

datetime.strptime

There is an old Python bug (https://bugs.python.org/issue27400) which ONLY impacts embedded python applications, such as the Kodi Python environment. The issue is that datetime.strptime is only initialized once per process and not every time the embedded environment is reinitialized. This causes datetime.strptime to return None and perhaps other strange behavior.

One option is for you to replace every reference to datetime.strptime to use a strptime_patch attached to this page. This is less voodoo, but there is always the possibility that some library code uses strptime and there will still be potential for incorrect results or a Kodi crash (script.module.youtube.dl crashed Kodi for a while).

The other option is to monkey-patch datetime.strptime so that any user of the python runtime will use it. It is voodoo like, but that is why Python supports Monkey patching.

This patch simply replaces datetime.strptime with time.strptime. They are nearly identical in function. For more information, see the attached patch.