Skip to content
This repository was archived by the owner on Aug 30, 2024. It is now read-only.

Commit a988a28

Browse files
madmazeMatthiasLeeIBM
authored andcommitted
non-UTF8 chars (like \u2013) in your map/reduce will make the ddoc fetch puke (#299)
* if for some reason you have non-UTF8 chars in your ddocs (like: \u2013) _Code.__new__ will puke. to fix this I just added encoding to UTF8 before creating the UTF8 string to be returned * fixed for non-string
1 parent 84d6af5 commit a988a28

File tree

2 files changed

+3
-0
lines changed

2 files changed

+3
-0
lines changed

CHANGES.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
2.5.0 (Unreleased)
22
==================
3+
- [FIXED] Fixed crash caused by non-UTF8 chars in ddocs
34
- [FIXED] Fixed ``TypeError`` when setting revision limits on Python>=3.6.
45
- [FIXED] Fixed the ``exists()`` double check on ``client.py`` and ``database.py``.
56
- [FIXED] Fixed Cloudant exception code 409 with 412 when creating a database that already exists.

src/cloudant/_common_util.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -283,6 +283,8 @@ class _Code(str):
283283
codifying map and reduce Javascript content.
284284
"""
285285
def __new__(cls, code):
286+
if isinstance(code, unicode):
287+
return str.__new__(cls, code.encode('utf8'))
286288
return str.__new__(cls, code)
287289

288290
class InfiniteSession(Session):

0 commit comments

Comments
 (0)