Skip to content

Commit 52ba1d8

Browse files
committed
base64 the continuation token to be a string and not bytes
1 parent 98ed170 commit 52ba1d8

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

sdk/core/azure-core/azure/core/polling/_poller.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
# IN THE SOFTWARE.
2424
#
2525
# --------------------------------------------------------------------------
26+
import base64
2627
import threading
2728
import uuid
2829
try:
@@ -119,7 +120,7 @@ def resource(self):
119120
def get_continuation_token(self):
120121
# type() -> str
121122
import pickle
122-
return pickle.dumps(self._initial_response)
123+
return base64.b64encode(pickle.dumps(self._initial_response)).decode('ascii')
123124

124125
@classmethod
125126
def from_continuation_token(cls, continuation_token, **kwargs):
@@ -129,7 +130,7 @@ def from_continuation_token(cls, continuation_token, **kwargs):
129130
except KeyError:
130131
raise ValueError("Need kwarg 'deserialization_callback' to be recreated from continuation_token")
131132
import pickle
132-
initial_response = pickle.loads(continuation_token)
133+
initial_response = pickle.loads(base64.b64decode(continuation_token))
133134
return None, initial_response, deserialization_callback
134135

135136

sdk/core/azure-core/azure/core/polling/base_polling.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
#
2525
# --------------------------------------------------------------------------
2626
import abc
27+
import base64
2728
import json
2829
from typing import TYPE_CHECKING, Optional, Any, Union
2930

@@ -450,7 +451,7 @@ def initialize(self, client, initial_response, deserialization_callback):
450451
def get_continuation_token(self):
451452
# type() -> str
452453
import pickle
453-
return pickle.dumps(self._initial_response)
454+
return base64.b64encode(pickle.dumps(self._initial_response)).decode('ascii')
454455

455456
@classmethod
456457
def from_continuation_token(cls, continuation_token, **kwargs):
@@ -466,7 +467,7 @@ def from_continuation_token(cls, continuation_token, **kwargs):
466467
raise ValueError("Need kwarg 'deserialization_callback' to be recreated from continuation_token")
467468

468469
import pickle
469-
initial_response = pickle.loads(continuation_token)
470+
initial_response = pickle.loads(base64.b64decode(continuation_token))
470471
# Restore the transport in the context
471472
initial_response.context.transport = client._pipeline._transport # pylint: disable=protected-access
472473
return client, initial_response, deserialization_callback

0 commit comments

Comments
 (0)