Skip to content

Error when using unicode for transformation name #41

@oppianmatt

Description

@oppianmatt

When calling some of the api's like transform to get the transform details. It does a check to see if you passed a string or a dict representing a transform.

Problem is if you are using unicode and you pass a unicode transform name it fails here:

def transformation_string(transformation):
    return transformation if isinstance(transformation, str) else cloudinary.utils.generate_transformation_string(**transformation)[0]

Note when I call the api to get the list of transformation names they come back in unicode so if you use the name from the api it will fail.

A hack is to convert it to str before calling back into the api, but with unicode becoming the norm we shouldn't have to do that.

example code showing error:

In [10]: transformations = cloudinary.api.transformations()

In [11]: transformations['transformations'][0]['name']
Out[11]: u'a_exif,fl_progressive.force_strip/c_fill,h_50,w_66/jpg'

In [12]: cloudinary.api.transformation(transformations['transformations'][0]['name'])
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-12-3f3d30faa965> in <module>()
----> 1 cloudinary.api.transformation(transformations['transformations'][0]['name'])

.../venv/lib/python2.7/site-packages/cloudinary/api.pyc in transformation(transformation, **options)
    128
    129 def transformation(transformation, **options):
--> 130     uri = ["transformations", transformation_string(transformation)]
    131     return call_api("get", uri, only(options, "max_results"), **options)
    132

.../venv/lib/python2.7/site-packages/cloudinary/api.pyc in transformation_string(transformation)
    240
    241 def transformation_string(transformation):
--> 242     return transformation if isinstance(transformation, str) else cloudinary.utils.generate_transformation_string(**transformation)[0]
    243

TypeError: generate_transformation_string() argument after ** must be a mapping, not unicode

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions