D3536: json: reject unicode on py2 as well

yuja (Yuya Nishihara) phabricator at mercurial-scm.org
Sat May 12 02:52:38 EDT 2018

yuja added a comment.

  > - elif isinstance(obj, str):
  > - # This branch is unreachable on Python 2, because bytes == str
  > - # and we'll return in the next-earlier block in the elif
  > - # ladder. On Python 3, this helps us catch bugs before they
  > - # hurt someone. +    elif isinstance(obj, (str, pycompat.unicode)): +        # On Python 2, we'll only get here if obj is unicode, because +        # str == bytes, so str is handled above.
  Doh, I never thought we already had pycompat.unicode to be imported
  automagically by the code transformer, and it's unavailable on Python 2!
  Since we'll eventually ditch the transformer, we'll have to add
  `unicode = __builtin__.unicode` to the py2 side of pycompat.
  Nit: `(str,` can be removed as `pycompat.unicode` is `str` on Python 3.

  rHG Mercurial


To: martinvonz, #hg-reviewers, indygreg
Cc: yuja, indygreg, mercurial-devel

More information about the Mercurial-devel mailing list