Blame SOURCES/0103-curl-7.59.0-python3.patch

b35f73
From bdba7b54224814055185513de1e7ff6619031553 Mon Sep 17 00:00:00 2001
b35f73
From: Kamil Dudka <kdudka@redhat.com>
b35f73
Date: Thu, 15 Mar 2018 13:21:40 +0100
b35f73
Subject: [PATCH 1/2] tests/http_pipe.py: migrate to Python 3
b35f73
b35f73
---
b35f73
 tests/http_pipe.py | 4 ++--
b35f73
 tests/runtests.pl  | 2 +-
b35f73
 2 files changed, 3 insertions(+), 3 deletions(-)
b35f73
b35f73
diff --git a/tests/http_pipe.py b/tests/http_pipe.py
b35f73
index bc32173..75ac165 100755
b35f73
--- a/tests/http_pipe.py
b35f73
+++ b/tests/http_pipe.py
b35f73
@@ -383,13 +383,13 @@ class PipelineRequestHandler(socketserver.BaseRequestHandler):
b35f73
           self.request.setblocking(True)
b35f73
           if not new_data:
b35f73
             return
b35f73
-          new_requests = self._request_parser.ParseAdditionalData(new_data)
b35f73
+          new_requests = self._request_parser.ParseAdditionalData(new_data.decode('utf8'))
b35f73
           self._response_builder.QueueRequests(
b35f73
               new_requests, self._request_parser.were_all_requests_http_1_1)
b35f73
           self._num_queued += len(new_requests)
b35f73
           self._last_queued_time = time.time()
b35f73
         elif fileno in wlist:
b35f73
-          num_bytes_sent = self.request.send(self._send_buffer[0:4096])
b35f73
+          num_bytes_sent = self.request.send(self._send_buffer[0:4096].encode('utf8'))
b35f73
           self._send_buffer = self._send_buffer[num_bytes_sent:]
b35f73
           time.sleep(0.05)
b35f73
 
b35f73
diff --git a/tests/runtests.pl b/tests/runtests.pl
b35f73
index d6aa5ca..4d395ef 100755
b35f73
--- a/tests/runtests.pl
b35f73
+++ b/tests/runtests.pl
b35f73
@@ -1439,7 +1439,7 @@ sub runhttpserver {
b35f73
     elsif($alt eq "pipe") {
b35f73
         # basically the same, but another ID
b35f73
         $idnum = 3;
b35f73
-        $exe = "python $srcdir/http_pipe.py";
b35f73
+        $exe = "python3 $srcdir/http_pipe.py";
b35f73
         $verbose_flag .= "1 ";
b35f73
     }
b35f73
     elsif($alt eq "unix") {
b35f73
-- 
b35f73
2.14.3
b35f73
b35f73
b35f73
From 3c4c7340e455b7256c0786759422f34ec3e2d440 Mon Sep 17 00:00:00 2001
b35f73
From: Kamil Dudka <kdudka@redhat.com>
b35f73
Date: Thu, 15 Mar 2018 14:49:56 +0100
b35f73
Subject: [PATCH 2/2] tests/{negtelnet,smb}server.py: migrate to Python 3
b35f73
b35f73
Unfortunately, smbserver.py does not work with Python 3 because
b35f73
there is no 'impacket' module available for Python 3:
b35f73
b35f73
https://github.com/CoreSecurity/impacket/issues/61
b35f73
---
b35f73
 tests/negtelnetserver.py | 12 ++++++------
b35f73
 tests/smbserver.py       |  4 ++--
b35f73
 2 files changed, 8 insertions(+), 8 deletions(-)
b35f73
b35f73
diff --git a/tests/negtelnetserver.py b/tests/negtelnetserver.py
b35f73
index 8cfd409..72ee771 100755
b35f73
--- a/tests/negtelnetserver.py
b35f73
+++ b/tests/negtelnetserver.py
b35f73
@@ -23,7 +23,7 @@ IDENT = "NTEL"
b35f73
 
b35f73
 # The strings that indicate the test framework is checking our aliveness
b35f73
 VERIFIED_REQ = b"verifiedserver"
b35f73
-VERIFIED_RSP = b"WE ROOLZ: {pid}"
b35f73
+VERIFIED_RSP = "WE ROOLZ: {pid}"
b35f73
 
b35f73
 
b35f73
 def telnetserver(options):
b35f73
@@ -34,7 +34,7 @@ def telnetserver(options):
b35f73
     if options.pidfile:
b35f73
         pid = os.getpid()
b35f73
         with open(options.pidfile, "w") as f:
b35f73
-            f.write(b"{0}".format(pid))
b35f73
+            f.write("{0}".format(pid))
b35f73
 
b35f73
     local_bind = (HOST, options.port)
b35f73
     log.info("Listening on %s", local_bind)
b35f73
@@ -73,11 +73,11 @@ class NegotiatingTelnetHandler(socketserver.BaseRequestHandler):
b35f73
                 response_data = VERIFIED_RSP.format(pid=os.getpid())
b35f73
             else:
b35f73
                 log.debug("Received normal request - echoing back")
b35f73
-                response_data = data.strip()
b35f73
+                response_data = data.decode('utf8').strip()
b35f73
 
b35f73
             if response_data:
b35f73
                 log.debug("Sending %r", response_data)
b35f73
-                self.request.sendall(response_data)
b35f73
+                self.request.sendall(response_data.encode('utf8'))
b35f73
 
b35f73
         except IOError:
b35f73
             log.exception("IOError hit during request")
b35f73
@@ -132,7 +132,7 @@ class Negotiator(object):
b35f73
         return buffer
b35f73
 
b35f73
     def byte_to_int(self, byte):
b35f73
-        return struct.unpack(b'B', byte)[0]
b35f73
+        return int(byte)
b35f73
 
b35f73
     def no_neg(self, byte, byte_int, buffer):
b35f73
         # Not negotiating anything thus far. Check to see if we
b35f73
@@ -197,7 +197,7 @@ class Negotiator(object):
b35f73
         self.tcp.sendall(packed_message)
b35f73
 
b35f73
     def pack(self, arr):
b35f73
-        return struct.pack(b'{0}B'.format(len(arr)), *arr)
b35f73
+        return struct.pack('{0}B'.format(len(arr)), *arr)
b35f73
 
b35f73
     def send_iac(self, arr):
b35f73
         message = [NegTokens.IAC]
b35f73
diff --git a/tests/smbserver.py b/tests/smbserver.py
b35f73
index 195ae39..b09cd44 100755
b35f73
--- a/tests/smbserver.py
b35f73
+++ b/tests/smbserver.py
b35f73
@@ -24,7 +24,7 @@
b35f73
 from __future__ import (absolute_import, division, print_function)
b35f73
 # unicode_literals)
b35f73
 import argparse
b35f73
-import ConfigParser
b35f73
+import configparser
b35f73
 import os
b35f73
 import sys
b35f73
 import logging
b35f73
@@ -58,7 +58,7 @@ def smbserver(options):
b35f73
             f.write("{0}".format(pid))
b35f73
 
b35f73
     # Here we write a mini config for the server
b35f73
-    smb_config = ConfigParser.ConfigParser()
b35f73
+    smb_config = configparser.ConfigParser()
b35f73
     smb_config.add_section("global")
b35f73
     smb_config.set("global", "server_name", "SERVICE")
b35f73
     smb_config.set("global", "server_os", "UNIX")
b35f73
-- 
b35f73
2.14.3
b35f73