Skip to content

Commit e17e8c5

Browse files
authored
support charset_normalizer (Azure#21520)
* support charset_normalizer * update * update
1 parent b6f32aa commit e17e8c5

File tree

2 files changed

+9
-9
lines changed

2 files changed

+9
-9
lines changed

sdk/core/azure-core/CHANGELOG.md

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,13 @@
11
# Release History
22

3-
## 1.19.1 (Unreleased)
4-
5-
### Features Added
6-
7-
### Breaking Changes
3+
## 1.19.1 (2021-11-01)
84

95
### Bugs Fixed
106

117
- respect text encoding specified in argument (thanks to @ryohji for the contribution) #20796
128
- Fix "coroutine x.read() was never awaited" warning from `ContentDecodePolicy` #21318
139
- fix type check for `data` input to `azure.core.rest` for python 2.7 users #21341
10+
- use `charset_normalizer` if `chardet` is not installed to migrate aiohttp 3.8.0 changes.
1411

1512
### Other Changes
1613

sdk/core/azure-core/azure/core/pipeline/transport/_aiohttp.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,6 @@
2828
Any, Optional, AsyncIterator as AsyncIteratorType, TYPE_CHECKING, overload
2929
)
3030
from collections.abc import AsyncIterator
31-
try:
32-
import cchardet as chardet
33-
except ImportError: # pragma: no cover
34-
import chardet # type: ignore
3531

3632
import logging
3733
import asyncio
@@ -373,6 +369,13 @@ def text(self, encoding: Optional[str] = None) -> str:
373369
"Cannot guess the encoding of a not yet read body"
374370
)
375371
else:
372+
try:
373+
import cchardet as chardet
374+
except ImportError: # pragma: no cover
375+
try:
376+
import chardet # type: ignore
377+
except ImportError: # pragma: no cover
378+
import charset_normalizer as chardet # type: ignore[no-redef]
376379
encoding = chardet.detect(body)["encoding"]
377380
if encoding == "utf-8" or encoding is None:
378381
encoding = "utf-8-sig"

0 commit comments

Comments
 (0)