Esri / arcgis-python-api

Documentation and samples for ArcGIS API for Python
https://developers.arcgis.com/python/
Apache License 2.0
1.89k stars 1.1k forks source link

Diacritics in an ArcGIS Survey 123 Form result in a failure during cloning #1761

Closed shane-pienaar-gbs closed 3 months ago

shane-pienaar-gbs commented 8 months ago

Describe the bug During clone_items() of an ArcGIS Survey123 Form, if a question has any diacritics like macrons (e.g. the ā in Māori) cloning fails.

To Reproduce Steps to reproduce the behavior:

Publish a Survey to ArcGIS Portal, with a question containing diacritics. Clone the Form using the normal ArcGIS Python API workflow.

error: _ItemCreateException: ("Failed to create Form X: Failed to updateX: 'charmap' codec can't decode byte 0x81 in position 18347: character maps to ", <Item title:"X" type:Form owner:admin>)

Expected behavior The Form should clone.

NOTE: If I monkey patch the ArcGIS Python API as follows, cloning works as expected. ..\site-packages\arcgis\_impl\common_clone.py#L5279 elif path.lower() == "form.json": with open(os.path.join(zip_dir, path), "r", encoding="utf8") as file: form_json = file.read()

Platform (please complete the following information):

Additional context None at this time

shane-pienaar-gbs commented 5 months ago

@nparavicini7. FYI, at ArcGIS Python API 2.3.0 a similar issue now occurs at line common_clone.py#L5313: with open(os.path.join(zip_dir, path), "w") as file: need to be changed to with open(os.path.join(zip_dir, path), "w", encoding="utf8") as file: to get diacritics to work