<html><head><meta http-equiv="content-type" content="text/html; charset=utf-8"></head><body dir="auto"><div></div><div><br></div><div><br>On May 16, 2016, at 08:27, timeless <<a href="mailto:timeless@gmail.com">timeless@gmail.com</a>> wrote:<br><br></div><blockquote type="cite"><div><p dir="ltr">From my work I think we had some actual iteritems functions, I'd expect this to do the wrong things for those cases.</p></div></blockquote><div>Right. We could also implement items() on our custom classes to conform with the Python 3 API.</div><br><blockquote type="cite"><div>
<div class="gmail_quote">On May 16, 2016 12:03 AM, "Gregory Szorc" <<a href="mailto:gregory.szorc@gmail.com">gregory.szorc@gmail.com</a>> wrote:<br type="attribution"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"># HG changeset patch<br>
# User Gregory Szorc <<a href="mailto:gregory.szorc@gmail.com">gregory.szorc@gmail.com</a>><br>
# Date 1463371090 25200<br>
#      Sun May 15 20:58:10 2016 -0700<br>
# Node ID 7e5fd80296fec5acd073b166b8c26d3b2ee3d01b<br>
# Parent  effc44c0ec7440fabb134a076e974ca478d89e11<br>
mercurial: rewrite "iteritems" to "items"<br>
<br>
This is extremely hacky. We should probably verify the token<br>
before is an OP token with value ".". But it does result<br>
in not encountering an iteritems run-time failure!<br>
<br>
This change demonstrates we can pave over some Python 2/3<br>
differences using on-the-fly source transformations without<br>
"contaminating" the original source code to be Python 3<br>
aware.<br>
<br>
With this change, we fail on some attribute access in mail.py.<br>
<br>
diff --git a/mercurial/__init__.py b/mercurial/__init__.py<br>
--- a/mercurial/__init__.py<br>
+++ b/mercurial/__init__.py<br>
@@ -197,16 +197,23 @@ if sys.version_info[0] >= 3:<br>
                 return t<br>
<br>
             if s[0] not in ("'", '"'):<br>
                 return t<br>
<br>
             # String literal. Prefix to make a b'' string.<br>
             return tokenize.TokenInfo(t.type, 'b%s' % s, t.start, t.end, t.line)<br>
<br>
+        if t.type == token.NAME:<br>
+            if t.string == 'iteritems':<br>
+                return tokenize.TokenInfo(t.type, 'items', t.start, t.end,<br>
+                                          t.line)<br>
+<br>
+            return t<br>
+<br>
         return t<br>
<br>
     class hgloader(importlib.machinery.SourceFileLoader):<br>
         """Custom module loader that transforms source code.<br>
<br>
         When the source code is converted to code, we first transform<br>
         string literals to byte literals using the tokenize API.<br>
         """<br>
_______________________________________________<br>
Mercurial-devel mailing list<br>
<a href="mailto:Mercurial-devel@mercurial-scm.org">Mercurial-devel@mercurial-scm.org</a><br>
<a href="https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel" rel="noreferrer" target="_blank">https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel</a><br>
</blockquote></div>
</div></blockquote></body></html>