Skip to content

Commit 6c97889

Browse files
author
Release Manager
committed
gh-40063: avoid using bytes_to_str in combinat using instead the builtin decode method of bytes ### 📝 Checklist - [x] The title is concise and informative. - [x] The description explains in detail what this PR is about. URL: #40063 Reported by: Frédéric Chapoton Reviewer(s): David Coudert
2 parents 8c35ad8 + 8f68714 commit 6c97889

File tree

2 files changed

+3
-8
lines changed

2 files changed

+3
-8
lines changed

src/sage/combinat/designs/covering_design.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,6 @@
5454
from sage.arith.misc import binomial
5555
from sage.combinat.combination import Combinations
5656
from sage.combinat.designs.incidence_structures import IncidenceStructure
57-
from sage.cpython.string import bytes_to_str
5857

5958

6059
def schonheim(v, k, t):
@@ -520,11 +519,8 @@ def best_known_covering_design_www(v, k, t, verbose=False):
520519
if verbose:
521520
print("Looking up the bounds at %s" % url)
522521

523-
f = urlopen(url, context=default_context())
524-
try:
525-
s = bytes_to_str(f.read())
526-
finally:
527-
f.close()
522+
with urlopen(url, context=default_context()) as f:
523+
s = f.read().decode()
528524

529525
if 'covering not in database' in s: # not found
530526
str = "no (%d, %d, %d) covering design in database\n" % (v, k, t)

src/sage/combinat/matrices/hadamard_matrix.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,6 @@
9090
skew_supplementary_difference_set,
9191
complementary_difference_sets)
9292
from sage.combinat.t_sequences import T_sequences_smallcases
93-
from sage.cpython.string import bytes_to_str
9493
from sage.rings.integer_ring import ZZ
9594
from sage.rings.polynomial.polynomial_ring_constructor import PolynomialRing
9695
from sage.matrix.constructor import (block_matrix,
@@ -1964,7 +1963,7 @@ def hadamard_matrix_www(url_file, comments=False):
19641963
rws = []
19651964
url = "http://neilsloane.com/hadamard/" + url_file
19661965
with urlopen(url) as f:
1967-
s = [bytes_to_str(line) for line in f.readlines()]
1966+
s = [line.decode() for line in f.readlines()]
19681967
for i in range(n):
19691968
line = s[i]
19701969
rws.append([1 if line[j] == "+" else -1 for j in range(n)])

0 commit comments

Comments
 (0)