plone / Products.CMFPlone

The core of the Plone content management system
https://plone.org
GNU General Public License v2.0
246 stars 186 forks source link

Creating content with non ASCII characters in title fails #2468

Closed tomgross closed 2 years ago

tomgross commented 6 years ago

BUG/PROBLEM REPORT (OR OTHER COMMON ISSUE)

What I did:

Call api.content.create(container=self.portal, type='Folder', title='äöü') in a unittest or elsewhere.

What I expect to happen:

A content item is created.

What actually happened:

An exception is raised:

Error in test test_follow_us_get_contents (fhnw.contentwidgets.tests.test_wi_066_follow_us.TestFollowUsTile)
Traceback (most recent call last):
  File "/usr/local/Cellar/python@2/2.7.15_1/Frameworks/Python.framework/Versions/2.7/lib/python2.7/unittest/case.py", line 320, in run
    self.setUp()
  File "/Users/tom.schneider/PycharmProjects/buildout-www.fhnw.ch/src/fhnw.contentwidgets/src/fhnw/contentwidgets/tests/test_wi_066_follow_us.py", line 25, in setUp
    self.parent = api.content.create(container=self.portal, type='Folder', title='Parent-äöü')
  File "<decorator-gen-9>", line 2, in create
  File "/Users/tom.schneider/.buildout/eggs/plone.api-1.8.3-py2.7.egg/plone/api/validation.py", line 77, in wrapped
    return function(*args, **kwargs)
  File "<decorator-gen-8>", line 2, in create
  File "/Users/tom.schneider/.buildout/eggs/plone.api-1.8.3-py2.7.egg/plone/api/validation.py", line 149, in wrapped
    return function(*args, **kwargs)
  File "/Users/tom.schneider/.buildout/eggs/plone.api-1.8.3-py2.7.egg/plone/api/content.py", line 119, in create
    new_id = chooser.chooseName(derived_id, content)
  File "/Users/tom.schneider/.buildout/eggs/plone.app.content-3.5.3-py2.7.egg/plone/app/content/namechooser.py", line 49, in chooseName
    name = name.encode('utf-8')
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 7: ordinal not in range(128)

What version of Plone/ Addons I am using:

Plone 5.1.3-pending (with plone.app.content 3.5.3 and plone.api 1.8.3)

The error is not present in Plone 5.1.2 (with plone.app.content 3.5.2)

The error was introduced here: https://github.com/plone/plone.app.content/commit/0f3fdb0028b632e5e4c6d577f30a1a1ea4b3fd15#diff-50a2c141772added5c7f2ff64d7819c5R48

davisagli commented 2 years ago

This looks like it was a Python 2.7-specific issue