Patchwork readlink.py: use absolute_import, print_function

login
register
mail settings
Submitter roby roby
Date March 25, 2016, 4:58 a.m.
Message ID <CAJYcaSMnOT-DOYHqZCmHfkeyt4hgz_SMYhLnxcFCY5dw88G_WQ@mail.gmail.com>
Download mbox | patch
Permalink /patch/14067/
State Changes Requested
Headers show

Comments

roby roby - March 25, 2016, 4:58 a.m.
# HG changeset patch
# User Robert Stanca <robert.stanca7@gmail.com>
# Date 1458881547 -7200
#      Fri Mar 25 06:52:27 2016 +0200
# Node ID 4d056674733ef697f08301412ce8a07504484184
# Parent  a6146f7e27f8a9875c34d746d7dc87b74dac1c6d
readlink.py: use absolute_import, print_function
Gregory Szorc - March 26, 2016, 5:33 p.m.
On Thu, Mar 24, 2016 at 9:58 PM, roby roby <robert.stanca7@gmail.com> wrote:

> # HG changeset patch
> # User Robert Stanca <robert.stanca7@gmail.com>
> # Date 1458881547 -7200
> #      Fri Mar 25 06:52:27 2016 +0200
> # Node ID 4d056674733ef697f08301412ce8a07504484184
> # Parent  a6146f7e27f8a9875c34d746d7dc87b74dac1c6d
> readlink.py: use absolute_import, print_function
>
> diff -r a6146f7e27f8 -r 4d056674733e tests/readlink.py
> --- a/tests/readlink.py    Fri Mar 25 06:47:34 2016 +0200
> +++ b/tests/readlink.py    Fri Mar 25 06:52:27 2016 +0200
> @@ -1,13 +1,16 @@
>  #!/usr/bin/env python
>
> -import errno, os, sys
> +from __future__ import absolute_import , print_function
> +import errno
> +import os
> +import sys
>
>  for f in sys.argv[1:]:
>      try:
> -        print f, '->', os.readlink(f)
> +        print (f, '->', os.readlink(f))
>      except OSError as err:
>          if err.errno != errno.EINVAL:
>              raise
> -        print f, 'not a symlink'
> +        print (f, 'not a symlink')
>

There should be no space between "print" and "(".


>
>  sys.exit(0)
> diff -r a6146f7e27f8 -r 4d056674733e tests/test-check-py3-compat.t
> --- a/tests/test-check-py3-compat.t    Fri Mar 25 06:47:34 2016 +0200
> +++ b/tests/test-check-py3-compat.t    Fri Mar 25 06:52:27 2016 +0200
> @@ -52,8 +52,6 @@
>    tests/md5sum.py not using absolute_import
>    tests/mockblackbox.py not using absolute_import
>    tests/printenv.py not using absolute_import
> -  tests/readlink.py not using absolute_import
> -  tests/readlink.py requires print_function
>    tests/revlog-formatv0.py not using absolute_import
>    tests/run-tests.py not using absolute_import
>    tests/seq.py not using absolute_import
>
>
 There is a new section at the bottom of this test that contains some
redundant entries if a file cannot be parsed as valid Python 3 (this
happens when the "print" statement is used for example). So you'll need to
update that section when adding print functions.

You'll need to have Python 3.5 installed and do `run-tests.py
--with-python3=path/to/python3.5` to get this section to execute when you
run test-check-py3-compat.t.

Patch

diff -r a6146f7e27f8 -r 4d056674733e tests/readlink.py
--- a/tests/readlink.py    Fri Mar 25 06:47:34 2016 +0200
+++ b/tests/readlink.py    Fri Mar 25 06:52:27 2016 +0200
@@ -1,13 +1,16 @@ 
 #!/usr/bin/env python

-import errno, os, sys
+from __future__ import absolute_import , print_function
+import errno
+import os
+import sys

 for f in sys.argv[1:]:
     try:
-        print f, '->', os.readlink(f)
+        print (f, '->', os.readlink(f))
     except OSError as err:
         if err.errno != errno.EINVAL:
             raise
-        print f, 'not a symlink'
+        print (f, 'not a symlink')

 sys.exit(0)
diff -r a6146f7e27f8 -r 4d056674733e tests/test-check-py3-compat.t
--- a/tests/test-check-py3-compat.t    Fri Mar 25 06:47:34 2016 +0200
+++ b/tests/test-check-py3-compat.t    Fri Mar 25 06:52:27 2016 +0200
@@ -52,8 +52,6 @@ 
   tests/md5sum.py not using absolute_import
   tests/mockblackbox.py not using absolute_import
   tests/printenv.py not using absolute_import
-  tests/readlink.py not using absolute_import
-  tests/readlink.py requires print_function
   tests/revlog-formatv0.py not using absolute_import
   tests/run-tests.py not using absolute_import
   tests/seq.py not using absolute_import