bear / parsedatetime

Parse human-readable date/time strings
Apache License 2.0
694 stars 105 forks source link

parsedatetime.Calendar() is broken in Python 2.7 #246

Open bmw opened 4 years ago

bmw commented 4 years ago

I've reproduced it on other systems, but on Ubuntu 18.04 with Python 2.7.17:

$ virtualenv -p python2 venv
.Running virtualenv with interpreter /usr/bin/python2
New python executable in /tmp/tmp.QhBu6ZeQC4/venv/bin/python2
 Also creating executable in /tmp/tmp.QhBu6ZeQC4/venv/bin/python
.Installing setuptools, pkg_resources, pip, wheel.../venv/bin/activatedone.
$ . ./venv/bin/activate
$ pip install parsedatetime
DEPRECATION: Python 2.7 reached the end of its life on January 1st, 2020. Please upgrade your Python as Python 2.7 is no longer maintained. pip 21.0 will drop support for Python 2.7 in January 2021. More details about Python 2 support in pip, can be found at https://pip.pypa.io/en/latest/development/release-process/#python-2-support
Collecting parsedatetime
  Downloading parsedatetime-2.6.tar.gz (60 kB) 
     |████████████████████████████████| 60 kB 7.8 MB/s 
Building wheels for collected packages: parsedatetime
  Building wheel for parsedatetime (setup.py) ... done
  Created wheel for parsedatetime: filename=parsedatetime-2.6-py2-none-any.whl size=42548 sha256=01153f5e5803e6668f31d09c6eb5395ce8919b81be08c657ddf6980f4f9c42ff
  Stored in directory: /home/bmw/.cache/pip/wheels/be/c8/34/61dee0758e18e0d545f6cb9c055980aefde80bc4c9569067ee
Successfully built parsedatetime
Installing collected packages: parsedatetime
Successfully installed parsedatetime-2.6
$ python -c 'import parsedatetime; parsedatetime.Calendar()' 
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/tmp/tmp.QhBu6ZeQC4/venv/local/lib/python2.7/site-packages/parsedatetime/__init__.py", line 270, in __init__
    self.ptc = Constants()
  File "/tmp/tmp.QhBu6ZeQC4/venv/local/lib/python2.7/site-packages/parsedatetime/__init__.py", line 2381, in __init__
    self.locale = get_icu(self.localeID)
  File "/tmp/tmp.QhBu6ZeQC4/venv/local/lib/python2.7/site-packages/parsedatetime/pdt_locales/icu.py", line 56, in get_icu
    result['icu'] = icu = pyicu.Locale(locale)
AttributeError: 'module' object has no attribute 'Locale'
$

I'm assuming Python 2.7 is still supported by parsedatetime because I couldn't find anything stating Python 2.7 has been dropped and there is a Python 2 wheel.

spier commented 4 years ago

I can confirm that I am seeing the same issue:

AttributeError: 'module' object has no attribute 'Locale'

I my case I am seeing it while using csvkit, which is using parsedatetime. I filed an issue there to track the impact https://github.com/wireservice/csvkit/issues/1081.

tonyg commented 4 years ago

This is the same bug as #245. The commit that introduced the fault is 18837504778c0dd41ae412bdf86eb81b1be7cdd7.

mvhconsult commented 4 years ago

But.. this is Python 2.7. Most devs would drop support for it as there are only a few months left before it really dies.