diff --git a/53.patch b/53.patch new file mode 100644 index 0000000..ddea2f2 --- /dev/null +++ b/53.patch @@ -0,0 +1,73 @@ +From 9653f31e388a07ce0430bdcde5177ba04733100a Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Lubom=C3=ADr=20Sedl=C3=A1=C5=99?= +Date: Wed, 8 Jan 2020 09:36:55 +0100 +Subject: [PATCH] Fix deprecated calls for Python 3.9 + +The array methods fromstring/tostring have been deprecated since Python +3.2. Python 3.9 removes them completely. + +This was discovered when trying to build gitdb package for Fedora 33. +https://bugzilla.redhat.com/show_bug.cgi?id=1788660 +--- + gitdb/pack.py | 11 ++++++++++- + gitdb/test/lib.py | 11 ++++++++++- + 2 files changed, 20 insertions(+), 2 deletions(-) + +diff --git a/gitdb/pack.py b/gitdb/pack.py +index 115d943..832a913 100644 +--- a/gitdb/pack.py ++++ b/gitdb/pack.py +@@ -247,6 +247,15 @@ def write(self, pack_sha, write): + return sha + + ++def _frombytes(a, s): ++ """Since Python 3.2 fromstring() is just an alias for frombytes() and is ++ deprecated. Python 3.9 drops the alias.""" ++ if sys.version_info.major < 3: ++ a.fromstring(s) ++ else: ++ a.frombytes(s) ++ ++ + class PackIndexFile(LazyMixin): + + """A pack index provides offsets into the corresponding pack, allowing to find +@@ -410,7 +419,7 @@ def offsets(self): + if self._version == 2: + # read stream to array, convert to tuple + a = array.array('I') # 4 byte unsigned int, long are 8 byte on 64 bit it appears +- a.fromstring(buffer(self._cursor.map(), self._pack_offset, self._pack_64_offset - self._pack_offset)) ++ _frombytes(a, buffer(self._cursor.map(), self._pack_offset, self._pack_64_offset - self._pack_offset)) + + # networkbyteorder to something array likes more + if sys.byteorder == 'little': +diff --git a/gitdb/test/lib.py b/gitdb/test/lib.py +index ab1842d..68e71f2 100644 +--- a/gitdb/test/lib.py ++++ b/gitdb/test/lib.py +@@ -147,6 +147,15 @@ def copy_files_globbed(source_glob, target_dir, hard_link_ok=False): + # END for each file to copy + + ++def _tobytes(a): ++ """Since Python 3.2 tostring() is deprecated and an alias for tobytes(). ++ Python 3.9 drops the alias.""" ++ if sys.version_info.major < 3: ++ return a.tostring() ++ else: ++ return a.tobytes() ++ ++ + def make_bytes(size_in_bytes, randomize=False): + """:return: string with given size in bytes + :param randomize: try to produce a very random stream""" +@@ -157,7 +166,7 @@ def make_bytes(size_in_bytes, randomize=False): + random.shuffle(producer) + # END randomize + a = array('i', producer) +- return a.tostring() ++ return _tobytes(a) + + + def make_object(type, data):