Esri / ArcREST

python package for REST API (AGS, AGOL, webmap JSON, etc..)
Apache License 2.0
192 stars 155 forks source link

NameError: name 'unicode' is not defined (when adding attachment to feature layer) #262

Closed apulverizer closed 8 years ago

apulverizer commented 8 years ago

ArcRest or ArcRestHelper

ArcRest

Version or date of download

3.5.6 (6/3/16)

Bug or Enhancement

A NameError exception is thrown when attempting to convert the dictionary returned by a post request to unicode. This occurs when attempting to add an attachment to a feature layer, and possibly in other areas. Unicode objects don't exist in Python 3.

 File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/arcrest/agol/services.py", line 1461, in addAttachment 
     return self._unicode_convert(res) 
   File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/arcrest/_abstract/abstract.py", line 267, in _unicode_convert 
     return {self._unicode_convert(key): self._unicode_convert(value) for key, value in obj.items()} 
   File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/arcrest/_abstract/abstract.py", line 267, in <dictcomp> 
     return {self._unicode_convert(key): self._unicode_convert(value) for key, value in obj.items()} 
   File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/arcrest/_abstract/abstract.py", line 267, in _unicode_convert 
     return {self._unicode_convert(key): self._unicode_convert(value) for key, value in obj.items()} 
   File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/arcrest/_abstract/abstract.py", line 267, in <dictcomp> 
     return {self._unicode_convert(key): self._unicode_convert(value) for key, value in obj.items()} 
   File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/arcrest/_abstract/abstract.py", line 270, in _unicode_convert 
     elif isinstance(obj, unicode): 
 NameError: name 'unicode' is not defined 

Repo Steps or Enhancement details

  1. Authenticate with AGOL and get an arcrest.agol.services.FeatureLayer that support attachments.
  2. Call "addAttachment" method of the feature layer with an appropriate objectID and file.

Works as expected in Python 2.7

achapkowski commented 8 years ago

@apulverizer I'll take a look.

MikeMillerGIS commented 8 years ago

could we use a six.text_type for this?

achapkowski commented 8 years ago

@MikeMillerGIS I think that would fix it

MikeMillerGIS commented 8 years ago

@apulverizer can you try this fix out

apulverizer commented 8 years ago

@MikeMillerGIS It works for both Python 2 and 3 now. Thanks!