Skip to content

Commit

Permalink
Trac #34211: Fix bug due to a call to SSLContext() in src/sage/graphs…
Browse files Browse the repository at this point in the history
…/isgci.py

{{{
sage: graph_classes._download_db()
------------------------------------------------------------------------
---
NameError                                 Traceback (most recent call
last)
<ipython-input-1-3914f28ce325> in <module>
----> 1 graph_classes._download_db()

/home/dcoudert/sage/local/var/lib/sage/venv-python3.10/lib64/python3.10
/site-packages/sage/graphs/isgci.py in _download_db(self)
    829         import tempfile
    830         u = urlopen('https://www.graphclasses.org/data.zip',
--> 831                     context=SSLContext())
    832         with tempfile.NamedTemporaryFile(suffix=".zip") as f:
    833             f.write(u.read())

NameError: name 'SSLContext' is not defined
}}}

This bug was fixed in #33771, replacing the call to `SSLContext()` in
`src/sage/graphs/isgci.py` with a call to `default_context()`, but this
changes has been reverted in #33829.

----
Dependency on #34079 since it modifies this file.

URL: https://trac.sagemath.org/34211
Reported by: dcoudert
Ticket author(s): David Coudert
Reviewer(s): Dima Pasechnik
  • Loading branch information
Release Manager committed Aug 28, 2022
2 parents e96e201 + 2302af6 commit ea2758f
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 58 deletions.
6 changes: 3 additions & 3 deletions build/pkgs/configure/checksums.ini
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
tarball=configure-VERSION.tar.gz
sha1=901e5c9e8a79b5c68df39b889e8b4698fd230faa
md5=91edef000fa263a8614786c634487b02
cksum=208681990
sha1=5e524f1afff2888475c49f1652efc292b3a4c7b6
md5=c3859fac3716ac64800f176c54389089
cksum=3271526260
2 changes: 1 addition & 1 deletion build/pkgs/configure/package-version.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
461a23c8a43375d7902f3723c313729b2effd62d
02cbc86624701318edfee6cd1c2f59c226f4a588
70 changes: 16 additions & 54 deletions src/sage/graphs/isgci.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,30 +55,13 @@
-------------------------
id : gc_32
name : chordal
type : base
<BLANKLINE>
...
Problems :
-----------
3-Colourability : Linear
Clique : Polynomial
Clique cover : Polynomial
Cliquewidth : Unbounded
Cliquewidth expression : NP-complete
Colourability : Linear
Cutwidth : NP-complete
Domination : NP-complete
Feedback vertex set : Polynomial
Hamiltonian cycle : NP-complete
Hamiltonian path : NP-complete
Independent set : Linear
Maximum bisection : Unknown
Maximum cut : NP-complete
Minimum bisection : Unknown
Recognition : Linear
Treewidth : Polynomial
Weighted clique : Polynomial
Weighted feedback vertex set : Unknown
Weighted independent set : Linear
...
It is possible to obtain the complete list of the classes stored in ISGCI by
calling the :meth:`~GraphClasses.show_all` method (beware -- long output)::
Expand Down Expand Up @@ -637,30 +620,15 @@ def description(self):
-------------------------
id : gc_32
name : chordal
type : base
<BLANKLINE>
...
Problems :
-----------
3-Colourability : Linear
Clique : Polynomial
Clique cover : Polynomial
Cliquewidth : Unbounded
Cliquewidth expression : NP-complete
Colourability : Linear
Cutwidth : NP-complete
Domination : NP-complete
Feedback vertex set : Polynomial
Hamiltonian cycle : NP-complete
Hamiltonian path : NP-complete
Independent set : Linear
Maximum bisection : Unknown
Maximum cut : NP-complete
Minimum bisection : Unknown
...
Recognition : Linear
Treewidth : Polynomial
Weighted clique : Polynomial
Weighted feedback vertex set : Unknown
Weighted independent set : Linear
...
"""
classes = GraphClasses().classes()
cls = classes[self._gc_id]
Expand Down Expand Up @@ -737,7 +705,7 @@ def classes(self):
sage: type(t)
<... 'dict'>
sage: sorted(t["gc_151"].keys())
['id', 'name', 'problem', 'type']
['id', 'name',... 'problem',... 'type']
sage: t["gc_151"]['name']
'cograph'
sage: t["gc_151"]['problem']['Clique']
Expand Down Expand Up @@ -780,16 +748,14 @@ def smallgraphs(self):
EXAMPLES::
sage: t = graph_classes.smallgraphs()
sage: t
{'2C_4': Graph on 8 vertices,
'2K_2': Graph on 4 vertices,
'2K_3': Graph on 6 vertices,
'2K_3 + e': Graph on 6 vertices,
'2K_4': Graph on 8 vertices,
'2P_3': Graph on 6 vertices,
...
sage: t['2C_4']
Graph on 8 vertices
sage: t['2K_3 + e']
Graph on 6 vertices
sage: t['fish']
Graph on 6 vertices
sage: t['bull']
Graph on 5 vertices
"""
self._get_ISGCI()
return self.smallgraphs()
Expand Down Expand Up @@ -827,11 +793,11 @@ def _download_db(self):
EXAMPLES::
sage: graph_classes._download_db() # Not tested -- requires internet
sage: graph_classes._download_db() # optional - internet
"""
import tempfile
u = urlopen('https://www.graphclasses.org/data.zip',
context=SSLContext())
context=default_context())
with tempfile.NamedTemporaryFile(suffix=".zip") as f:
f.write(u.read())
z = zipfile.ZipFile(f.name)
Expand All @@ -858,7 +824,6 @@ def _parse_db(self, directory):
sage: graph_classes._parse_db(GRAPHS_DATA_DIR)
"""
import xml.etree.cElementTree as ET
import os.path
from sage.graphs.graph import Graph

xml_file = os.path.join(GRAPHS_DATA_DIR, _XML_FILE)
Expand Down Expand Up @@ -903,7 +868,7 @@ def update_db(self):
EXAMPLES::
sage: graph_classes.update_db() # Not tested -- requires internet
sage: graph_classes.update_db() # optional - internet
"""
self._download_db()

Expand Down Expand Up @@ -935,8 +900,6 @@ def _get_ISGCI(self):
sage: graph_classes._get_ISGCI() # long time (4s on sage.math, 2012)
"""

import os.path
from sage.misc.misc import SAGE_DB

try:
Expand Down Expand Up @@ -1039,12 +1002,11 @@ def _XML_to_dict(root):
EXAMPLES::
sage: graph_classes.Perfect.description() # indirect doctest
sage: graph_classes.Perfect.description() # indirect doctest
Class of graphs : Perfect
-------------------------
id : gc_56
name : perfect
type : base
...
"""
ans = root.attrib.copy()
Expand Down

0 comments on commit ea2758f

Please sign in to comment.