python-networkx fails to build with Python 3.9.0a4. def test_write_read_attribute_numeric_type_graphml(self): from xml.etree.ElementTree import parse G = self.attribute_numeric_type_graph fh = io.BytesIO() self.writer(G, fh, infer_numeric_types=True) fh.seek(0) H = nx.read_graphml(fh) fh.seek(0) assert_nodes_equal(G.nodes(), H.nodes()) assert_edges_equal(G.edges(), H.edges()) assert_edges_equal(G.edges(data=True), H.edges(data=True)) self.attribute_numeric_type_fh.seek(0) xml = parse(fh) # Children are the key elements, and the graph element > children = xml.getroot().getchildren() E AttributeError: 'xml.etree.ElementTree.Element' object has no attribute 'getchildren' See https://docs.python.org/3.9/whatsnew/3.9.html#removed "Methods getchildren() and getiterator() in the ElementTree module have been removed. They were deprecated in Python 3.2. Use functions list() and iter() instead. The xml.etree.cElementTree module has been removed." (There are also other failing tests.) For the build logs, see: https://copr-be.cloud.fedoraproject.org/results/@python/python3.9/fedora-rawhide-x86_64/01297168-python-networkx/ For all our attempts to build python-networkx with Python 3.9, see: https://copr.fedorainfracloud.org/coprs/g/python/python3.9/package/python-networkx/ Testing and mass rebuild of packages is happening in copr. You can follow these instructions to test locally in mock if your package builds with Python 3.9: https://copr.fedorainfracloud.org/coprs/g/python/python3.9/ Let us know here if you have any questions. Python 3.9 will be included in Fedora 33. To make that update smoother, we're building Fedora packages with early pre-releases of Python 3.9. A build failure prevents us from testing all dependent packages (transitive [Build]Requires), so if this package is required a lot, it's important for us to get it fixed soon. We'd appreciate help from the people who know this package best, but if you don't want to work on this now, let us know so we can try to work around it on our side.
This error can be fixed by just removing the ".getchildren()" from the end of the line. But the next error perplexes me. Follow the bouncing ball: - The first line of networkx.generators.tests.test_community.test_gaussian_random_partition_graph is "G = nx.gaussian_random_partition_graph(100, 10, 10, 0.3, 0.01)" - Note the decorator on networkx.generators.tests.community.gaussian_random_partition_graph: @py_random_state(6) def gaussian_random_partition_graph(n, s, v, p_in, p_out, directed=False, seed=None): - The decorator is defined in networkx.utils.decorators, at the bottom of the file. Minus comments, it is this: def py_random_state(random_state_index): @decorator def _random_state(func, *args, **kwargs): try: random_state_arg = args[random_state_index] except TypeError: raise nx.NetworkXError("random_state_index must be an integer") except IndexError: raise nx.NetworkXError("random_state_index is incorrect") random_state = create_py_random_state(random_state_arg) new_args = list(args) new_args[random_state_index] = random_state return func(*new_args, **kwargs) return _random_state - Because we called gaussian_random_partition_graph with 5 arguments, seed is None when the decorator function is called, so random_state_arg is set to None inside the try block. Therefore, we call create_py_random_state(None). - I can call create_py_random_state(None) from an interactive python session, and get a valid random state object in return (likewise with every integer I have tried). But that isn't what happens when the decorator is used: Traceback (most recent call last): File "<stdin>", line 1, in <module> File "</usr/lib/python3.9/site-packages/decorator.py:decorator-gen-40>", line 2, in gaussian_random_partition_graph File "/builddir/build/BUILD/networkx-networkx-2.4/networkx/utils/decorators.py", line 464, in _random_state return func(*new_args, **kwargs) File "/builddir/build/BUILD/networkx-networkx-2.4/networkx/generators/community.py", line 391, in gaussian_random_partition_graph return random_partition_graph(sizes, p_in, p_out, directed, seed) File "</usr/lib/python3.9/site-packages/decorator.py:decorator-gen-36>", line 2, in random_partition_graph File "/builddir/build/BUILD/networkx-networkx-2.4/networkx/utils/decorators.py", line 459, in _random_state random_state = create_py_random_state(random_state_arg) File "/builddir/build/BUILD/networkx-networkx-2.4/networkx/utils/misc.py", line 442, in create_py_random_state return random.Random(random_state) File "/usr/lib64/python3.9/random.py", line 100, in __init__ self.seed(x) File "/usr/lib64/python3.9/random.py", line 163, in seed super().seed(a) TypeError: descriptor '__abs__' of 'int' object needs an argument Here I am lost. I don't know what int object we are talking about, where __abs__ came from, or what on earth is going wrong.
Mind blown. I'd report to upstream, WDYT?
No, wait, I got it! NetworkX upstream swapped the order of two arguments. At the end of gaussian_random_partition_graph is this call: return random_partition_graph(sizes, p_in, p_out, directed, seed) but check out the order the arguments are *supposed* to be in: @py_random_state(3) def random_partition_graph(sizes, p_in, p_out, seed=None, directed=False): And the decorator points to the argument that is passed False, instead of the one that is passed None. The fact that passing False in as the seed value causes such a weird error probably is a python bug, though. Okay, two bugs to report then. I'll get on that.
Good catch. $ python3.8 Python 3.8.2 ... >>> import random >>> random.Random(0) <random.Random object at 0x563a969554d0> >>> random.Random(False) <random.Random object at 0x563a96955ed0> $ python3.9 Python 3.9.0a4 ... >>> import random >>> random.Random(0) <random.Random object at 0x564b239d3710> >>> random.Random(False) Traceback (most recent call last): File "<stdin>", line 1, in <module> File "/usr/lib64/python3.9/random.py", line 100, in __init__ self.seed(x) File "/usr/lib64/python3.9/random.py", line 163, in seed super().seed(a) TypeError: descriptor '__abs__' of 'int' object needs an argument
Possibly related to https://bugs.python.org/issue32554 https://github.com/python/cpython/pull/15382 Deprecate hashing arbitrary types in random.seed() Victor, take a look please?
Pull request to fix the reversed args: https://github.com/networkx/networkx/pull/3861 Weird error resulting from random.Random(False): https://bugs.python.org/issue39918
Oh, and *now* bugzilla tells me that you made 2 comments, Miro. If that python.org issue I just filed is redundant, please do go ahead and close it.
Definitively relevant, thanks for filing it.
FEDORA-2020-4897777416 has been submitted as an update to Fedora 32. https://bodhi.fedoraproject.org/updates/FEDORA-2020-4897777416
I proposed a fix: https://github.com/python/cpython/pull/18897
python-networkx-2.4-3.fc32 has been pushed to the Fedora 32 testing repository. If problems still persist, please make note of it in this bug report. See https://fedoraproject.org/wiki/QA:Updates_Testing for instructions on how to install test updates. You can provide feedback for this update here: https://bodhi.fedoraproject.org/updates/FEDORA-2020-4897777416
python-networkx-2.4-3.fc32 has been pushed to the Fedora 32 stable repository. If problems still persist, please make note of it in this bug report.