Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 75b7df1

Browse filesBrowse files
authored
fix(async): parsing query response with two-bytes UTF-8 character (influxdata#518)
1 parent ddb0f77 commit 75b7df1
Copy full SHA for 75b7df1

File tree

Expand file treeCollapse file tree

3 files changed

+25
-1
lines changed
Filter options
Expand file treeCollapse file tree

3 files changed

+25
-1
lines changed

‎CHANGELOG.md

Copy file name to clipboardExpand all lines: CHANGELOG.md
+1Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66
### Bug Fixes
77
1. [#512](https://github.com/influxdata/influxdb-client-python/pull/512): Exception propagation for asynchronous `QueryApi` [async/await]
8+
1. [#518](https://github.com/influxdata/influxdb-client-python/pull/518): Parsing query response with two-bytes UTF-8 character [async/await]
89

910
## 1.33.0 [2022-09-29]
1011

‎influxdb_client/client/flux_csv_parser.py

Copy file name to clipboardExpand all lines: influxdb_client/client/flux_csv_parser.py
+5-1Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -384,6 +384,10 @@ def _print_profiler_info(self, flux_record: FluxRecord):
384384
class _StreamReaderToWithAsyncRead:
385385
def __init__(self, response):
386386
self.response = response
387+
self.decoder = codecs.getincrementaldecoder(_UTF_8_encoding)()
387388

388389
async def read(self, size: int) -> str:
389-
return (await self.response.read(size)).decode(_UTF_8_encoding)
390+
raw_bytes = (await self.response.read(size))
391+
if not raw_bytes:
392+
return self.decoder.decode(b'', final=True)
393+
return self.decoder.decode(raw_bytes, final=False)

‎tests/test_InfluxDBClientAsync.py

Copy file name to clipboardExpand all lines: tests/test_InfluxDBClientAsync.py
+19Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -383,6 +383,25 @@ async def test_query_exception_propagation(self):
383383
await self.client.query_api().query("buckets()", "my-org")
384384
self.assertEqual("unauthorized access", e.value.message)
385385

386+
@async_test
387+
@aioresponses()
388+
async def test_parse_utf8_two_bytes_character(self, mocked):
389+
await self.client.close()
390+
self.client = InfluxDBClientAsync("http://localhost")
391+
392+
body = '''#group,false,false,false,false,true,true,true
393+
#datatype,string,long,dateTime:RFC3339,string,string,string,string
394+
#default,_result,,,,,,
395+
,result,table,_time,_value,_field,_measurement,type
396+
'''
397+
for i in range(1000):
398+
body += f",,0,2022-10-13T12:28:31.{i}Z,ÂÂÂ,value,async,error\n"
399+
400+
mocked.post('http://localhost/api/v2/query?org=my-org', status=200, body=body)
401+
402+
data_frame = await self.client.query_api().query_data_frame("from()", "my-org")
403+
self.assertEqual(1000, len(data_frame))
404+
386405
async def _prepare_data(self, measurement: str):
387406
_point1 = Point(measurement).tag("location", "Prague").field("temperature", 25.3)
388407
_point2 = Point(measurement).tag("location", "New York").field("temperature", 24.3)

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.