#1 Remove encoding parameter for json.loads for Python 3.9 compatibility
Merged 4 years ago by jonny. Opened 4 years ago by pviktori.
rpms/ pviktori/python-libnacl bz1796024  into  master

file added
+39
@@ -0,0 +1,39 @@ 

+ From 53c1576b21b53156fc30d357b40c88c7eefb50de Mon Sep 17 00:00:00 2001

+ From: Karthikeyan Singaravelan <tir.karthi@gmail.com>

+ Date: Thu, 30 Jan 2020 22:22:58 +0530

+ Subject: [PATCH] Remove encoding parameter json.loads for Python 3.9

+  compatibility.

+ 

+ ---

+  libnacl/utils.py | 7 +++++--

+  1 file changed, 5 insertions(+), 2 deletions(-)

+ 

+ diff --git a/libnacl/utils.py b/libnacl/utils.py

+ index 412d518..e06e078 100644

+ --- a/libnacl/utils.py

+ +++ b/libnacl/utils.py

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

+  # -*- coding: utf-8 -*-

+  

+  import struct

+ +import sys

+  import time

+  

+  # Import nacl libs

+ @@ -31,7 +32,10 @@ def load_key(path_or_file, serial='json'):

+              key_data = msgpack.load(stream)

+          elif serial == 'json':

+              import json

+ -            key_data = json.loads(stream.read(), encoding='UTF-8')

+ +            if sys.version_info[0] >= 3:

+ +                key_data = json.loads(stream.read())

+ +            else:

+ +                key_data = json.loads(stream.read(), encoding='UTF-8')

+      finally:

+          if stream != path_or_file:

+              stream.close()

+ @@ -95,4 +99,3 @@ def time_nonce():

+      '''

+      nonce = rand_nonce()

+      return (struct.pack('=d', time.time()) + nonce)[:len(nonce)]

+ -

file modified
+9 -2
@@ -2,13 +2,17 @@ 

  

  Name:           python-%{srcname}

  Version:        1.7.1

- Release:        2%{?dist}

+ Release:        3%{?dist}

  Summary:        Python bindings for libsodium based on ctypes

  

  License:        ASL 2.0

  URL:            https://libnacl.readthedocs.org/

  Source0:        %{pypi_source}

  

+ # Remove encoding parameter json.loads for Python 3.9 compatibility.

+ # Merged upstream: https://github.com/saltstack/libnacl/pull/121

+ Patch121:       pr121.patch

+ 

  BuildArch:      noarch

  BuildRequires:  libsodium

  
@@ -33,7 +37,7 @@ 

  

  

  %prep

- %autosetup -n %{srcname}-%{version}

+ %autosetup -p1 -n %{srcname}-%{version}

  rm -rf %{srcname}.egg-info

  

  %build
@@ -54,6 +58,9 @@ 

  %{python3_sitelib}/%{srcname}/

  

  %changelog

+ * Wed Apr 01 2020 Petr Viktorin <pviktori@redhat.com> - 1.7.1-3

+ - Remove encoding parameter json.loads for Python 3.9 compatibility

+ 

  * Thu Jan 30 2020 Fedora Release Engineering <releng@fedoraproject.org> - 1.7.1-2

  - Rebuilt for https://fedoraproject.org/wiki/Fedora_32_Mass_Rebuild