From cf447e0c43b44bc6d33344dc20945f7250e889bb Mon Sep 17 00:00:00 2001 From: peter Date: Mon, 21 Aug 2023 18:42:34 -0400 Subject: [PATCH] avoid extra function call --- src/google/appengine/ext/ndb/model.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/google/appengine/ext/ndb/model.py b/src/google/appengine/ext/ndb/model.py index 541643b..9ccf0aa 100755 --- a/src/google/appengine/ext/ndb/model.py +++ b/src/google/appengine/ext/ndb/model.py @@ -2741,9 +2741,10 @@ def _db_get_value(self, v, p): sval = modelclass._from_pb(pb) elif meaning != entity_pb2.Property.BYTESTRING: try: - decoded = sval.decode('ascii') - if meaning == entity_pb2.Property.TEXT: - sval = six.ensure_str(decoded, encoding='ascii') + if six.PY2: + sval.decode('ascii') + elif meaning == entity_pb2.Property.TEXT: + sval = sval.decode('ascii') except UnicodeDecodeError: try: sval = six.text_type(sval.decode('utf-8'))