zopefoundation / z3c.form

An advanced form and widget framework for Zope 3
Other
9 stars 39 forks source link

Fixed possible UnicodeDecodeError in setup.py on Python 3.6. [3.x] #98

Closed mauritsvanrees closed 3 years ago

mauritsvanrees commented 3 years ago

Put the long description in setup.cfg, without replacing characters. See this error on Plone Jenkins, https://jenkins.plone.org/job/plone-5.2-python-3.6/1058/console

Develop: '/home/jenkins/workspace/plone-5.2-python-3.6/src/z3c.form'
Traceback (most recent call last):
  File "/tmp/tmps_fh_how", line 14, in <module>
    exec(compile(f.read(), '/home/jenkins/workspace/plone-5.2-python-3.6/src/z3c.form/setup.py', 'exec'))
  File "/home/jenkins/workspace/plone-5.2-python-3.6/src/z3c.form/setup.py", line 61, in <module>
    'util.txt',
  File "/home/jenkins/workspace/plone-5.2-python-3.6/src/z3c.form/setup.py", line 46, in <listcomp>
    for name in ('README.txt',
  File "/home/jenkins/workspace/plone-5.2-python-3.6/src/z3c.form/setup.py", line 22, in read
    text = f.read()
  File "/home/jenkins/shiningpanda/jobs/65a48de5/virtualenvs/d41d8cd9/lib/python3.6/encodings/ascii.py", line 26, in decode
    return codecs.ascii_decode(input, self.errors)[0]
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 752: ordinal not in range(128)
While:
  Installing.
  Processing develop directory '/home/jenkins/workspace/plone-5.2-python-3.6/src/z3c.form'.

I have seen it go wrong for more packages the last couple of months. Locally I see no problem with Python 3.6, so it could be a problem only on one Jenkins node. But if it happens there, it might happen for other users too.

See another package where I initially fixed it by hacking something in setup.py, and then replaced it with setup.cfg in this commit: https://github.com/plone/Products.CMFPlacefulWorkflow/commit/eda6670f50436d2dea426a389563df1223760978

Difference in output is very little, but seems an improvement:

$ diff orig new
9948c9948
<   >>> id = util.createId(u'&#196;ndern')
---
>   >>> id = util.createId(u'Ändern')
9967c9967
<   >>> id = util.createCSSId(u'&#1593;&#1614;&#1585;&#1614;')
---
>   >>> id = util.createCSSId(u'عَرَ')

Or with screen shots.


Old:

Screenshot 2020-09-04 at 09 47 26

New:

Screenshot 2020-09-04 at 09 48 56

The new text is the same as the text that is actually in the file that we include: https://github.com/zopefoundation/z3c.form/blob/3.7.0/src/z3c/form/util.txt#L29-L57

mauritsvanrees commented 3 years ago

I wondered if the same would be needed for master, but since version 4.0.0 the documentation is hosted at https://z3cform.readthedocs.io instead of on PyPI. The remaining long description on master currently contains only ascii, so no special measures are necessary yet.