Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove unicodecsv from dependency for Python 3+ #31

Open
rschiang opened this issue Sep 1, 2021 · 2 comments
Open

Remove unicodecsv from dependency for Python 3+ #31

rschiang opened this issue Sep 1, 2021 · 2 comments

Comments

@rschiang
Copy link
Contributor

rschiang commented Sep 1, 2021

Currently, new installations in a clean virtualenv on Python 3.9.7 would result in the following error:

    File "/private/var/folders/…/zipcodetw/builder.py", line 23, in build
      dir_.load_chp_csv(csv_f)
    File "/private/var/folders/…/zipcodetw/util.py", line 317, in method_wrapper
      retval = method(self, *args, **kargs)
    File "/private/var/folders/…/zipcodetw/util.py", line 340, in load_chp_csv
      for row in csv.reader(lines_iter):
    File "/Users/…/zipcode_test/venv/lib/python3.9/site-packages/unicodecsv/py3.py", line 55, in __next__
      return self.reader.__next__()
    File "/Users/…/zipcode_test/venv/lib/python3.9/site-packages/unicodecsv/py3.py", line 51, in <genexpr>
      f = (bs.decode(encoding, errors=errors) for bs in f)
  AttributeError: 'str' object has no attribute 'decode'
  ----------------------------------------

Running pip remove unicodecsv && python -m zipcodetw.builder fixed the issue.

It appears that unicodecsv has been abandoned as in jdunck/python-unicodecsv#92, and thus no further maintenance are done for the package.

We could either:

  • drop the support for Python 2.7,
  • use the suggested csv backport from Python 3, or
  • specify unicodecsv as our dependency only when Python version < 3 as shown in PEP 0508.

The last one should be the easiest mitigation. Please let me know if a PR is preferred over issues.

@hugovk
Copy link

hugovk commented Sep 5, 2021

Python 2.7 has been end-of-life for nearly 2 years and many projects are no longer supporting it.

If you don't have an urgent need, I suggest dropping it too, it should make things much easier to maintain.

@moskytw
Copy link
Owner

moskytw commented Sep 9, 2021

@rschiang Thanks a lot. I have no preference among the suggested solutions and a PR is welcome.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants