[med-svn] [Git][med-team/python-pairix][master] Avoid tests failing under Python 3.10
Andreas Tille (@tille)
gitlab at salsa.debian.org
Sat Nov 20 05:35:00 GMT 2021
Andreas Tille pushed to branch master at Debian Med / python-pairix
Commits:
711250c1 by Andreas Tille at 2021-11-20T06:34:46+01:00
Avoid tests failing under Python 3.10
- - - - -
3 changed files:
- debian/changelog
- + debian/patches/python3.10
- + debian/patches/series
Changes:
=====================================
debian/changelog
=====================================
@@ -1,3 +1,10 @@
+python-pairix (0.3.7-4.1) UNRELEASED; urgency=medium
+
+ * Non-maintainer upload.
+ * Patch: Avoid tests failing under Python 3.10. (Closes: #999381)
+
+ -- Stefano Rivera <stefanor at debian.org> Fri, 19 Nov 2021 22:21:23 -0400
+
python-pairix (0.3.7-4) unstable; urgency=medium
* Fix watchfile to detect new versions on github
=====================================
debian/patches/python3.10
=====================================
@@ -0,0 +1,330 @@
+Description: Avoid a Python3.10 regression in iterating GzipFiles
+ Open the file with a context manager, so we're holding onto a reference to it,
+ for the lifetime of the iteration.
+ This avoids hitting https://bugs.python.org/issue45475 which affects
+ python3.10 3.10.0-4 in Debian.
+
+Bug-Debian: https://bugs.debian.org/999381
+Bug-cpython: https://bugs.python.org/issue45475
+Forwarded: https://github.com/4dn-dcic/pairix/pull/71
+Author: Stefano Rivera <stefanor at debian.org>
+--- a/test/test_oldindex.py
++++ b/test/test_oldindex.py
+@@ -36,45 +36,48 @@
+ def get_header(filename, meta_char='#'):
+ """Read gzipped file and retrieve lines beginning with '#'."""
+ retval = []
+- for line in gzip.open(filename):
+- try:
+- line = line.decode('utf-8')
+- except AttributeError:
+- pass
+- if line.startswith(meta_char):
+- retval.append(line.rstrip())
++ with gzip.open(filename) as f:
++ for line in f:
++ try:
++ line = line.decode('utf-8')
++ except AttributeError:
++ pass
++ if line.startswith(meta_char):
++ retval.append(line.rstrip())
+ return retval
+
+
+ def get_chromsize(filename):
+ """Read gzipped file and retrieve chromsize."""
+ retval = []
+- for line in gzip.open(filename):
+- try:
+- line = line.decode('utf-8')
+- except AttributeError:
+- pass
+- if line.startswith('#chromsize: '):
+- fields = line.rstrip().split('\s+')
+- chrname = fields[1]
+- chrsize = fields[2]
+- retval.append([chrname, chrsize])
++ with gzip.open(filename) as f:
++ for line in f:
++ try:
++ line = line.decode('utf-8')
++ except AttributeError:
++ pass
++ if line.startswith('#chromsize: '):
++ fields = line.rstrip().split('\s+')
++ chrname = fields[1]
++ chrsize = fields[2]
++ retval.append([chrname, chrsize])
+ return retval
+
+
+ def read_vcf(filename):
+ """Read a VCF file and return a list of [chrom, start, end] items."""
+ retval = []
+- for line in gzip.open(filename):
+- try:
+- line = line.decode('utf-8')
+- except AttributeError:
+- pass
+- fields = line.rstrip().split('\t')
+- chrom = fields[0]
+- start = fields[1]
+- end = fields[1]
+- retval.append([chrom, start, end])
++ with gzip.open(filename) as f:
++ for line in f:
++ try:
++ line = line.decode('utf-8')
++ except AttributeError:
++ pass
++ fields = line.rstrip().split('\t')
++ chrom = fields[0]
++ start = fields[1]
++ end = fields[1]
++ retval.append([chrom, start, end])
+ return retval
+
+
+@@ -83,20 +86,21 @@
+ or undetermined. Do this by testing string values of """
+ is_juicer = False
+ is_4DN = False
+- for line in gzip.open(filename):
+- try:
+- line = line.decode('utf-8')
+- except AttributeError:
+- pass
+- fields = line.rstrip().split(delimiter)
+- if len(fields)>=6 and is_str(fields[2]) and is_str(fields[6]):
+- is_juicer = True
+- if is_str(fields[2]) and is_str(fields[4]):
+- is_4DN = True
+- if not is_juicer and is_4DN:
+- return '4DN'
+- elif is_juicer:
+- return 'juicer'
++ with gzip.open(filename) as f:
++ for line in f:
++ try:
++ line = line.decode('utf-8')
++ except AttributeError:
++ pass
++ fields = line.rstrip().split(delimiter)
++ if len(fields)>=6 and is_str(fields[2]) and is_str(fields[6]):
++ is_juicer = True
++ if is_str(fields[2]) and is_str(fields[4]):
++ is_4DN = True
++ if not is_juicer and is_4DN:
++ return '4DN'
++ elif is_juicer:
++ return 'juicer'
+ return 'undetermined'
+
+
+@@ -115,25 +119,26 @@
+ if file_type == 'undetermined':
+ return []
+ retval = []
+- for line in gzip.open(filename):
+- try:
+- line = line.decode('utf-8')
+- except AttributeError:
+- pass
+- if line.startswith('#'):
+- continue
+- fields = line.rstrip().split(delimiter)
+- if file_type == 'juicer':
+- chrom1 = fields[1]
+- start1 = fields[2]
+- chrom2 = fields[5]
+- start2 = fields[6]
+- elif file_type == '4DN':
+- chrom1 = fields[1]
+- start1 = fields[2]
+- chrom2 = fields[3]
+- start2 = fields[4]
+- retval.append([chrom1, start1, start1, chrom2, start2, start2])
++ with gzip.open(filename) as f:
++ for line in f:
++ try:
++ line = line.decode('utf-8')
++ except AttributeError:
++ pass
++ if line.startswith('#'):
++ continue
++ fields = line.rstrip().split(delimiter)
++ if file_type == 'juicer':
++ chrom1 = fields[1]
++ start1 = fields[2]
++ chrom2 = fields[5]
++ start2 = fields[6]
++ elif file_type == '4DN':
++ chrom1 = fields[1]
++ start1 = fields[2]
++ chrom2 = fields[3]
++ start2 = fields[4]
++ retval.append([chrom1, start1, start1, chrom2, start2, start2])
+ return retval
+
+
+--- a/test/test_oldindex2.py
++++ b/test/test_oldindex2.py
+@@ -35,45 +35,48 @@
+ def get_header(filename, meta_char='#'):
+ """Read gzipped file and retrieve lines beginning with '#'."""
+ retval = []
+- for line in gzip.open(filename):
+- try:
+- line = line.decode('utf-8')
+- except AttributeError:
+- pass
+- if line.startswith(meta_char):
+- retval.append(line.rstrip())
++ with gzip.open(filename) as f:
++ for line in f:
++ try:
++ line = line.decode('utf-8')
++ except AttributeError:
++ pass
++ if line.startswith(meta_char):
++ retval.append(line.rstrip())
+ return retval
+
+
+ def get_chromsize(filename):
+ """Read gzipped file and retrieve chromsize."""
+ retval = []
+- for line in gzip.open(filename):
+- try:
+- line = line.decode('utf-8')
+- except AttributeError:
+- pass
+- if line.startswith('#chromsize: '):
+- fields = line.rstrip().split('\s+')
+- chrname = fields[1]
+- chrsize = fields[2]
+- retval.append([chrname, chrsize])
++ with gzip.open(filename) as f:
++ for line in f:
++ try:
++ line = line.decode('utf-8')
++ except AttributeError:
++ pass
++ if line.startswith('#chromsize: '):
++ fields = line.rstrip().split('\s+')
++ chrname = fields[1]
++ chrsize = fields[2]
++ retval.append([chrname, chrsize])
+ return retval
+
+
+ def read_vcf(filename):
+ """Read a VCF file and return a list of [chrom, start, end] items."""
+ retval = []
+- for line in gzip.open(filename):
+- try:
+- line = line.decode('utf-8')
+- except AttributeError:
+- pass
+- fields = line.rstrip().split('\t')
+- chrom = fields[0]
+- start = fields[1]
+- end = fields[1]
+- retval.append([chrom, start, end])
++ with gzip.open(filename) as f:
++ for line in f:
++ try:
++ line = line.decode('utf-8')
++ except AttributeError:
++ pass
++ fields = line.rstrip().split('\t')
++ chrom = fields[0]
++ start = fields[1]
++ end = fields[1]
++ retval.append([chrom, start, end])
+ return retval
+
+
+@@ -82,20 +85,21 @@
+ or undetermined. Do this by testing string values of """
+ is_juicer = False
+ is_4DN = False
+- for line in gzip.open(filename):
+- try:
+- line = line.decode('utf-8')
+- except AttributeError:
+- pass
+- fields = line.rstrip().split(delimiter)
+- if len(fields)>=6 and is_str(fields[2]) and is_str(fields[6]):
+- is_juicer = True
+- if is_str(fields[2]) and is_str(fields[4]):
+- is_4DN = True
+- if not is_juicer and is_4DN:
+- return '4DN'
+- elif is_juicer:
+- return 'juicer'
++ with gzip.open(filename) as f:
++ for line in f:
++ try:
++ line = line.decode('utf-8')
++ except AttributeError:
++ pass
++ fields = line.rstrip().split(delimiter)
++ if len(fields)>=6 and is_str(fields[2]) and is_str(fields[6]):
++ is_juicer = True
++ if is_str(fields[2]) and is_str(fields[4]):
++ is_4DN = True
++ if not is_juicer and is_4DN:
++ return '4DN'
++ elif is_juicer:
++ return 'juicer'
+ return 'undetermined'
+
+
+@@ -114,25 +118,26 @@
+ if file_type == 'undetermined':
+ return []
+ retval = []
+- for line in gzip.open(filename):
+- try:
+- line = line.decode('utf-8')
+- except AttributeError:
+- pass
+- if line.startswith('#'):
+- continue
+- fields = line.rstrip().split(delimiter)
+- if file_type == 'juicer':
+- chrom1 = fields[1]
+- start1 = fields[2]
+- chrom2 = fields[5]
+- start2 = fields[6]
+- elif file_type == '4DN':
+- chrom1 = fields[1]
+- start1 = fields[2]
+- chrom2 = fields[3]
+- start2 = fields[4]
+- retval.append([chrom1, start1, start1, chrom2, start2, start2])
++ with gzip.open(filename) as f:
++ for line in f:
++ try:
++ line = line.decode('utf-8')
++ except AttributeError:
++ pass
++ if line.startswith('#'):
++ continue
++ fields = line.rstrip().split(delimiter)
++ if file_type == 'juicer':
++ chrom1 = fields[1]
++ start1 = fields[2]
++ chrom2 = fields[5]
++ start2 = fields[6]
++ elif file_type == '4DN':
++ chrom1 = fields[1]
++ start1 = fields[2]
++ chrom2 = fields[3]
++ start2 = fields[4]
++ retval.append([chrom1, start1, start1, chrom2, start2, start2])
+ return retval
+
+
=====================================
debian/patches/series
=====================================
@@ -0,0 +1 @@
+python3.10
View it on GitLab: https://salsa.debian.org/med-team/python-pairix/-/commit/711250c1ad03893164840eebd9c2a26c173d2310
--
View it on GitLab: https://salsa.debian.org/med-team/python-pairix/-/commit/711250c1ad03893164840eebd9c2a26c173d2310
You're receiving this email because of your account on salsa.debian.org.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://alioth-lists.debian.net/pipermail/debian-med-commit/attachments/20211120/4eccf1f1/attachment-0001.htm>
More information about the debian-med-commit
mailing list