Skip to content

Commit

Permalink
Win py27 issue (#13595)
Browse files Browse the repository at this point in the history
* change to the processor to check for BOM at the beginning

* changes to serialize and deserialize to be consistent with py2/3 strings/unicode types. new recordings for all that, changes to tests for everything, and a bug in sas file

* forgot to add a unicode explicitly, re-recorded some tests because of that
  • Loading branch information
seankane-msft authored Sep 5, 2020
1 parent 83ec2c4 commit 6553796
Show file tree
Hide file tree
Showing 175 changed files with 4,940 additions and 4,173 deletions.
11 changes: 11 additions & 0 deletions sdk/tables/azure-data-tables/azure/data/tables/_deserialize.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,8 @@ def _from_entity_datetime(value):
def _from_entity_guid(value):
return UUID(value)

def _from_entity_str(value):
return EntityProperty(value=value, type=EdmType.STRING)

_EDM_TYPES = [EdmType.BINARY, EdmType.INT64, EdmType.GUID, EdmType.DATETIME,
EdmType.STRING, EdmType.INT32, EdmType.DOUBLE, EdmType.BOOLEAN]
Expand All @@ -103,6 +105,7 @@ def _from_entity_guid(value):
EdmType.DOUBLE: float,
EdmType.DATETIME: _from_entity_datetime,
EdmType.GUID: _from_entity_guid,
EdmType.STRING: _from_entity_str
}


Expand Down Expand Up @@ -162,6 +165,14 @@ def _convert_to_entity(entry_element):
if type(value) is int and mtype is None: # pylint:disable=C0123
mtype = EdmType.INT32

# Add type for String, keeps
try:
if type(value) is unicode and mtype is None: # pylint:disable=C0123
mtype = EdmType.STRING
except NameError:
if type(value) is str and mtype is None: # pylint:disable=C0123
mtype = EdmType.STRING

# no type info, property should parse automatically
if not mtype:
entity[name] = value
Expand Down
15 changes: 12 additions & 3 deletions sdk/tables/azure-data-tables/azure/data/tables/_serialize.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ def _to_entity_int(value):


def _to_entity_str(value):
return None, value
return EdmType.STRING, value


def _to_entity_none(value): # pylint:disable=W0613
Expand All @@ -159,10 +159,19 @@ def _to_entity_none(value): # pylint:disable=W0613
bool: _to_entity_bool,
datetime: _to_entity_datetime,
float: _to_entity_float,
str: _to_entity_str,
bytes: _to_entity_binary,
UUID: _to_entity_guid
}
try:
_PYTHON_TO_ENTITY_CONVERSIONS.update({
unicode: _to_entity_str,
str: _to_entity_binary,
long: _to_entity_int32,
})
except NameError:
_PYTHON_TO_ENTITY_CONVERSIONS.update({
str: _to_entity_str,
bytes: _to_entity_binary,
})

# Conversion from Edm type to a function which returns a tuple of the
# type string and content string.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ class _TableQueryStringConstants(QueryStringConstants):
class _TableSharedAccessHelper(_SharedAccessHelper):

def __init__(self):
super().__init__()
super(_TableSharedAccessHelper, self).__init__()
self.query_dict = {}

def add_table_access_ranges(self, table_name, start_pk, start_rk,
Expand Down
Loading

0 comments on commit 6553796

Please sign in to comment.