Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix UnicodeDecodeError v2.13.1 #306

Merged
merged 3 commits into from
Sep 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
emoji
=====

v2.13.1 (2024-09-21)
-----
* Read JSON files in binary mode to avoid UnicodeDecodeError #305

v2.13.0 (2024-09-19)
-----
* Use JSON files to store the database of emoji
Expand Down
2 changes: 2 additions & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,5 @@ include README.rst
include CHANGES.md
include utils/testutils.py
recursive-include tests *.py
include emoji/unicode_codes/emoji.json
recursive-include emoji/unicode_codes emoji_*.json
2 changes: 1 addition & 1 deletion emoji/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
'LANGUAGES',
]

__version__ = '2.13.0'
__version__ = '2.13.1'
__author__ = 'Taehoon Kim, Kevin Wurster'
__email__ = 'carpedm20@gmail.com'
# and wursterk@gmail.com, tahir.jalilov@gmail.com
Expand Down
6 changes: 4 additions & 2 deletions emoji/unicode_codes/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,9 @@ def __missing__(self, key: str) -> str:
def _load_default_from_json():
global EMOJI_DATA
global _loaded_keys
with open(Path(__file__).with_name('emoji.json')) as f:

file = Path(__file__).with_name('emoji.json')
with open(file, 'rb') as f:
EMOJI_DATA = dict(json.load(f, object_pairs_hook=EmojiDataDict)) # type: ignore
_loaded_keys = list(_DEFAULT_KEYS)

Expand All @@ -93,7 +95,7 @@ def load_from_json(key: str):
raise NotImplementedError('Language not supported', key)

file = Path(__file__).with_name(f'emoji_{key}.json')
with open(file) as f:
with open(file, 'rb') as f:
for emj, value in json.load(f).items():
EMOJI_DATA[emj][key] = value # type: ignore

Expand Down