#24 #1535596 and some clean up
Merged 6 years ago by churchyard. Opened 6 years ago by ishcherb.
rpms/ ishcherb/python3 rpmlint-issues-cleanup  into  master

@@ -1,16 +0,0 @@ 

- diff --git a/Lib/test/test_ssl.py b/Lib/test/test_ssl.py

- index d203cdd..c128dae 100644

- --- a/Lib/test/test_ssl.py

- +++ b/Lib/test/test_ssl.py

- @@ -3256,8 +3256,9 @@ if _have_threads:

-                  except ssl.SSLError as e:

-                      stats = e

-  

- -                if expected is None and IS_OPENSSL_1_1:

- -                    # OpenSSL 1.1.0 raises handshake error

- +                if (expected is None and IS_OPENSSL_1_1

- +                        and ssl.OPENSSL_VERSION_INFO < (1, 1, 0, 6)):

- +                    # OpenSSL 1.1.0 to 1.1.0e raises handshake error

-                      self.assertIsInstance(stats, ssl.SSLError)

-                  else:

-                      msg = "failed trying %s (s) and %s (c).\n" \

@@ -1,99 +0,0 @@ 

- diff --git a/Lib/test/test_asyncio/test_events.py b/Lib/test/test_asyncio/test_events.py

- index 492a84a2313..9746678607c 100644

- --- a/Lib/test/test_asyncio/test_events.py

- +++ b/Lib/test/test_asyncio/test_events.py

- @@ -1980,19 +1980,26 @@ def test_subprocess_terminate(self):

-  

-      @unittest.skipIf(sys.platform == 'win32', "Don't have SIGHUP")

-      def test_subprocess_send_signal(self):

- -        prog = os.path.join(os.path.dirname(__file__), 'echo.py')

- -

- -        connect = self.loop.subprocess_exec(

- -                        functools.partial(MySubprocessProtocol, self.loop),

- -                        sys.executable, prog)

- -        transp, proto = self.loop.run_until_complete(connect)

- -        self.assertIsInstance(proto, MySubprocessProtocol)

- -        self.loop.run_until_complete(proto.connected)

- -

- -        transp.send_signal(signal.SIGHUP)

- -        self.loop.run_until_complete(proto.completed)

- -        self.assertEqual(-signal.SIGHUP, proto.returncode)

- -        transp.close()

- +        # bpo-31034: Make sure that we get the default signal handler (killing

- +        # the process). The parent process may have decided to ignore SIGHUP,

- +        # and signal handlers are inherited.

- +        old_handler = signal.signal(signal.SIGHUP, signal.SIG_DFL)

- +        try:

- +            prog = os.path.join(os.path.dirname(__file__), 'echo.py')

- +

- +            connect = self.loop.subprocess_exec(

- +                            functools.partial(MySubprocessProtocol, self.loop),

- +                            sys.executable, prog)

- +            transp, proto = self.loop.run_until_complete(connect)

- +            self.assertIsInstance(proto, MySubprocessProtocol)

- +            self.loop.run_until_complete(proto.connected)

- +

- +            transp.send_signal(signal.SIGHUP)

- +            self.loop.run_until_complete(proto.completed)

- +            self.assertEqual(-signal.SIGHUP, proto.returncode)

- +            transp.close()

- +        finally:

- +            signal.signal(signal.SIGHUP, old_handler)

-  

-      def test_subprocess_stderr(self):

-          prog = os.path.join(os.path.dirname(__file__), 'echo2.py')

- diff --git a/Lib/test/test_asyncio/test_subprocess.py b/Lib/test/test_asyncio/test_subprocess.py

- index 2e14a8a9735..e8822c36698 100644

- --- a/Lib/test/test_asyncio/test_subprocess.py

- +++ b/Lib/test/test_asyncio/test_subprocess.py

- @@ -166,25 +166,32 @@ def test_terminate(self):

-  

-      @unittest.skipIf(sys.platform == 'win32', "Don't have SIGHUP")

-      def test_send_signal(self):

- -        code = 'import time; print("sleeping", flush=True); time.sleep(3600)'

- -        args = [sys.executable, '-c', code]

- -        create = asyncio.create_subprocess_exec(*args,

- -                                                stdout=subprocess.PIPE,

- -                                                loop=self.loop)

- -        proc = self.loop.run_until_complete(create)

- -

- -        @asyncio.coroutine

- -        def send_signal(proc):

- -            # basic synchronization to wait until the program is sleeping

- -            line = yield from proc.stdout.readline()

- -            self.assertEqual(line, b'sleeping\n')

- +        # bpo-31034: Make sure that we get the default signal handler (killing

- +        # the process). The parent process may have decided to ignore SIGHUP,

- +        # and signal handlers are inherited.

- +        old_handler = signal.signal(signal.SIGHUP, signal.SIG_DFL)

- +        try:

- +            code = 'import time; print("sleeping", flush=True); time.sleep(3600)'

- +            args = [sys.executable, '-c', code]

- +            create = asyncio.create_subprocess_exec(*args,

- +                                                    stdout=subprocess.PIPE,

- +                                                    loop=self.loop)

- +            proc = self.loop.run_until_complete(create)

-  

- -            proc.send_signal(signal.SIGHUP)

- -            returncode = (yield from proc.wait())

- -            return returncode

- -

- -        returncode = self.loop.run_until_complete(send_signal(proc))

- -        self.assertEqual(-signal.SIGHUP, returncode)

- +            @asyncio.coroutine

- +            def send_signal(proc):

- +                # basic synchronization to wait until the program is sleeping

- +                line = yield from proc.stdout.readline()

- +                self.assertEqual(line, b'sleeping\n')

- +

- +                proc.send_signal(signal.SIGHUP)

- +                returncode = (yield from proc.wait())

- +                return returncode

- +

- +            returncode = self.loop.run_until_complete(send_signal(proc))

- +            self.assertEqual(-signal.SIGHUP, returncode)

- +        finally:

- +            signal.signal(signal.SIGHUP, old_handler)

-  

-      def prepare_broken_pipe_test(self):

-          # buffer large enough to feed the whole pipe buffer

@@ -1,58 +0,0 @@ 

- From 8c2d4cf092c5f0335e7982392a33927579c4d512 Mon Sep 17 00:00:00 2001

- From: Dong-hee Na <donghee.na92@gmail.com>

- Date: Wed, 26 Jul 2017 21:11:25 +0900

- Subject: [PATCH] [3.6] bpo-30119: fix ftplib.FTP.putline() to throw an error

-  for a illegal command (#1214) (#2886)

- 

- ---

-  Lib/ftplib.py                                                     | 2 ++

-  Lib/test/test_ftplib.py                                           | 6 +++++-

-  Misc/NEWS.d/next/Library/2017-07-26-15-15-00.bpo-30119.DZ6C_S.rst | 2 ++

-  3 files changed, 9 insertions(+), 1 deletion(-)

-  create mode 100644 Misc/NEWS.d/next/Library/2017-07-26-15-15-00.bpo-30119.DZ6C_S.rst

- 

- diff --git a/Lib/ftplib.py b/Lib/ftplib.py

- index 8f36f537e8a..a02e595cb02 100644

- --- a/Lib/ftplib.py

- +++ b/Lib/ftplib.py

- @@ -186,6 +186,8 @@ def sanitize(self, s):

-  

-      # Internal: send one line to the server, appending CRLF

-      def putline(self, line):

- +        if '\r' in line or '\n' in line:

- +            raise ValueError('an illegal newline character should not be contained')

-          line = line + CRLF

-          if self.debugging > 1:

-              print('*put*', self.sanitize(line))

- diff --git a/Lib/test/test_ftplib.py b/Lib/test/test_ftplib.py

- index 12fabc5e8be..a561e9efa03 100644

- --- a/Lib/test/test_ftplib.py

- +++ b/Lib/test/test_ftplib.py

- @@ -484,6 +484,9 @@ def test_sanitize(self):

-          self.assertEqual(self.client.sanitize('PASS 12345'), repr('PASS *****'))

-  

-      def test_exceptions(self):

- +        self.assertRaises(ValueError, self.client.sendcmd, 'echo 40\r\n0')

- +        self.assertRaises(ValueError, self.client.sendcmd, 'echo 40\n0')

- +        self.assertRaises(ValueError, self.client.sendcmd, 'echo 40\r0')

-          self.assertRaises(ftplib.error_temp, self.client.sendcmd, 'echo 400')

-          self.assertRaises(ftplib.error_temp, self.client.sendcmd, 'echo 499')

-          self.assertRaises(ftplib.error_perm, self.client.sendcmd, 'echo 500')

- @@ -492,7 +495,8 @@ def test_exceptions(self):

-  

-      def test_all_errors(self):

-          exceptions = (ftplib.error_reply, ftplib.error_temp, ftplib.error_perm,

- -                      ftplib.error_proto, ftplib.Error, OSError, EOFError)

- +                      ftplib.error_proto, ftplib.Error, OSError,

- +                      EOFError)

-          for x in exceptions:

-              try:

-                  raise x('exception not included in all_errors set')

- diff --git a/Misc/NEWS.d/next/Library/2017-07-26-15-15-00.bpo-30119.DZ6C_S.rst b/Misc/NEWS.d/next/Library/2017-07-26-15-15-00.bpo-30119.DZ6C_S.rst

- new file mode 100644

- index 00000000000..a37d3703842

- --- /dev/null

- +++ b/Misc/NEWS.d/next/Library/2017-07-26-15-15-00.bpo-30119.DZ6C_S.rst

- @@ -0,0 +1,2 @@

- +ftplib.FTP.putline() now throws ValueError on commands that contains CR or

- +LF. Patch by Dong-hee Na.

@@ -1,6 +1,6 @@ 

  """Checks if all *.pyc and *.pyo files have later mtime than their *.py files."""

  

- import imp

+ import importlib.util

  import os

  import sys

  
@@ -37,16 +37,18 @@ 

  ]

  failed = 0

  

+ 

  def bytecode_expected(source):

      for f in not_compiled:

          if source.endswith(f):

              return False

      return True

  

+ 

  compiled = filter(lambda f: bytecode_expected(f), sys.argv[1:])

  for f in compiled:

      # check both pyo and pyc

-     to_check = map(lambda b: imp.cache_from_source(f, b), (True, False))

+     to_check = map(lambda b: importlib.util.cache_from_source(f, b), (True, False))

      f_mtime = os.path.getmtime(f)

      for c in to_check:

          c_mtime = os.path.getmtime(c)

file modified
+6 -9
@@ -127,7 +127,7 @@ 

  # has bytecode at:

  #   foo/__pycache__/bar.cpython-%%{pyshortver}.pyc

  #   foo/__pycache__/bar.cpython-%%{pyshortver}.opt-1.pyc

- #	foo/__pycache__/bar.cpython-%%{pyshortver}.opt-2.pyc

+ #   foo/__pycache__/bar.cpython-%%{pyshortver}.opt-2.pyc

  %global bytecode_suffixes .cpython-%{pyshortver}*.pyc

  

  # Python's configure script defines SOVERSION, and this is used in the Makefile
@@ -439,7 +439,7 @@ 

  # The description used both for the SRPM and the main `python3` subpackage:

  %description

  Python is an accessible, high-level, dynamically typed, interpreted programming

- language, designed with an emphasis on code readibility.

+ language, designed with an emphasis on code readability.

  It includes an extensive standard library, and has a vast ecosystem of

  third-party libraries.

  
@@ -591,7 +591,7 @@ 

  Summary: Debug version of the Python runtime

  

  # The debug build is an all-in-one package version of the regular build, and

- # shares the same .py/.pyc files and directories as the regular build.  Hence

+ # shares the same .py/.pyc files and directories as the regular build. Hence

  # we depend on all of the subpackages of the regular build:

  Requires: %{name}%{?_isa} = %{version}-%{release}

  Requires: %{name}-libs%{?_isa} = %{version}-%{release}
@@ -616,7 +616,7 @@ 

  The debug build shares installation directories with the standard Python

  runtime, so that .py and .pyc files can be shared.

  Compiled extension modules use a special ABI flag ("d") in the filename,

- so extensions for both verisons can co-exist in the same directory.

+ so extensions for both versions can co-exist in the same directory.

  %endif # with debug_build

  

  
@@ -819,7 +819,6 @@ 

    PyInstSoName=$2

    MoreCFlags=$3

    LDVersion=$4

-   Postfix=$5

  

    # Switch to the directory with this configuration's built files

    ConfDir=build/$ConfName
@@ -873,16 +872,14 @@ 

  InstallPython debug \

    %{py_INSTSONAME_debug} \

    -O0 \

-   %{LDVERSION_debug} \

-   -debug

+   %{LDVERSION_debug}

  %endif # with debug_build

  

  # Now the optimized build:

  InstallPython optimized \

    %{py_INSTSONAME_optimized} \

    "" \

-   %{LDVERSION_optimized} \

-   ""

+   %{LDVERSION_optimized}

  

  # Install directories for additional packages

  install -d -m 0755 %{buildroot}%{pylibdir}/site-packages/__pycache__