Skip to content

NDB_PY2_UNPICKLE_COMPAT? #103

Description

@pnico

There is an env var being checked in a couple places that I don't see mentioned outside the code:

class PickleProperty(BlobProperty):
...
  def _from_base_type(self, value):
    try:
      return pickle.loads(value)
    except UnicodeDecodeError:
      if int(os.environ.get('NDB_PY2_UNPICKLE_COMPAT', '0')):
        return pickle.loads(value, encoding='bytes')
      raise
class Key(object):
...
  def __new__(cls, *_args, **kwargs):
  ...
    if int(os.environ.get('NDB_PY2_UNPICKLE_COMPAT', '0')):
      kwargs = {six.ensure_str(k): v for (k, v) in kwargs.items()}

Should we set this, is it set for us, should we avoid it?
I'm running into some assorted pickle-related issues which had me looking at this (not-so-)recent change, and it's a bit tricky to figure out if it's better to try more "global" sorts of fixes or just site-specific workarounds to avoid dealing with messier problems.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions