D5046: hgdemandimport: adjust imports to reflect vendored module

2020-01-24 Thread baymax (Baymax, Your Personal Patch-care Companion)
This revision now requires changes to proceed.
baymax added a comment.
baymax requested changes to this revision.


  There seems to have been no activities on this Diff for the past 3 Months.
  
  By policy, we are automatically moving it out of the `need-review` state.
  
  Please, move it back to `need-review` without hesitation if this diff should 
still be discussed.
  
  :baymax:need-review-idle:

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST ACTION
  https://phab.mercurial-scm.org/D5046/new/

REVISION DETAIL
  https://phab.mercurial-scm.org/D5046

To: indygreg, #hg-reviewers, baymax
Cc: mjpieters, mercurial-devel
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


D5046: hgdemandimport: adjust imports to reflect vendored module

2018-10-13 Thread indygreg (Gregory Szorc)
indygreg created this revision.
Herald added subscribers: mercurial-devel, mjpieters.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  The "token" module is renamed in our local copy. Import it appropriately.
  
  This angered test-check-module-imports due to attempting relative import of
  stdlib module and direct symbol imports. We suppress that check on this file
  since it is mostly 3rd party code.

REPOSITORY
  rHG Mercurial

REVISION DETAIL
  https://phab.mercurial-scm.org/D5046

AFFECTED FILES
  hgdemandimport/py3token.py
  hgdemandimport/py3tokenize.py
  tests/test-check-module-imports.t

CHANGE DETAILS

diff --git a/tests/test-check-module-imports.t 
b/tests/test-check-module-imports.t
--- a/tests/test-check-module-imports.t
+++ b/tests/test-check-module-imports.t
@@ -25,6 +25,7 @@
   > -X contrib/win32/hgwebdir_wsgi.py \
   > -X doc/gendoc.py \
   > -X doc/hgmanpage.py \
+  > -X hgdemandimport/py3tokenize.py \
   > -X i18n/posplit \
   > -X mercurial/thirdparty \
   > -X tests/hypothesishelpers.py \
diff --git a/hgdemandimport/py3tokenize.py b/hgdemandimport/py3tokenize.py
--- a/hgdemandimport/py3tokenize.py
+++ b/hgdemandimport/py3tokenize.py
@@ -59,6 +59,10 @@
 # * Removed generate_tokens().
 # * Removed open().
 # * Removed module docstring.
+# * Adjusted for relative imports.
+# * absolute_import added.
+
+from __future__ import absolute_import
 
 __author__ = 'Ka-Ping Yee '
 __credits__ = ('GvR, ESR, Tim Peters, Thomas Wouters, Fred Drake, '
@@ -69,15 +73,15 @@
 from itertools import chain
 import itertools as _itertools
 import re
-from token import *
+from .py3token import *
 
 cookie_re = re.compile(r'^[ \t\f]*#.*?coding[:=][ \t]*([-\w.]+)', re.ASCII)
 blank_re = re.compile(br'^[ \t\f]*(?:[#\r\n]|$)', re.ASCII)
 
-import token
-__all__ = token.__all__ + ["tokenize", "detect_encoding",
-   "untokenize", "TokenInfo"]
-del token
+from . import py3token
+__all__ = py3token.__all__ + ["tokenize", "detect_encoding",
+  "untokenize", "TokenInfo"]
+del py3token
 
 EXACT_TOKEN_TYPES = {
 '(':   LPAR,
diff --git a/hgdemandimport/py3token.py b/hgdemandimport/py3token.py
--- a/hgdemandimport/py3token.py
+++ b/hgdemandimport/py3token.py
@@ -56,9 +56,12 @@
 # Changes from official Python source code:
 #
 # * _main() and related functionality removed.
+# * absolute_import added.
 
 """Token constants (from "token.h")."""
 
+from __future__ import absolute_import
+
 __all__ = ['tok_name', 'ISTERMINAL', 'ISNONTERMINAL', 'ISEOF']
 
 #  This file is automatically generated; please don't muck it up!



To: indygreg, #hg-reviewers
Cc: mjpieters, mercurial-devel
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel