Page MenuHomePhabricator

category_graph.py does not use correct string format for DOT-string
Closed, ResolvedPublicBUG REPORT

Description

Steps to replicate the issue:

  1. Run the example pwb.py -v category_graph -from as provided by the category_graph.py docstring.

What happens?:

  1. Notice that a TypeError exception occurs with message NoneType is not subscriptable" on line 93.

Full Traceback:

Exception has occurred: TypeError
'NoneType' object is not subscriptable
  File "C:\git\core\scripts\category_graph.py", line 93, in __init__
    self.dot = pydot.graph_from_dot_data(f'digraph {style}')[0]
               ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^
  File "C:\git\core\scripts\category_graph.py", line 208, in <module>
    bot = CategoryGraphBot(ap, args)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\git\core\pywikibot\scripts\wrapper.py", line 147, in run_python_file
    exec(compile(source, filename, 'exec', dont_inherit=True),
  File "C:\git\core\pywikibot\scripts\wrapper.py", line 484, in execute
    run_python_file(filename, script_args, module)
  File "C:\git\core\pywikibot\scripts\wrapper.py", line 497, in main
    if not execute():
           ^^^^^^^^^
  File "C:\git\core\pywikibot\scripts\wrapper.py", line 513, in <module>
    main()
  File "C:\git\core\pwb.py", line 35, in main
    runpy.run_path(str(path), run_name='__main__')
  File "C:\git\core\pwb.py", line 39, in <module>
    sys.exit(main())
             ^^^^^^
TypeError: 'NoneType' object is not subscriptable

What should have happened instead?:

  • pwb.py -v category_graph -from should run without an exception.

Software version:

  • pywikibot core master, commit ae36e848115e6beac1df2a0b72ee149e5adc86b4

Notes:

The DOT-string is missing exterior curly braces. See pydot Input -> 2.

Proposed Solution:

Wrap the DOT-string in category_graph.py in curly braces.

Event Timeline

Change 956089 had a related patch set uploaded (by Enag2000; author: Enag2000):

[pywikibot/core@master] Wrapped DOT-string in curly braces in argument passed to pydot.graph_from_dot_data().

https://gerrit.wikimedia.org/r/956089

Didn't realize that including the exact commit number automatically adds a mention to other tasks. When documenting the version of pywikibot that a bug occured on, is just "pywikibot core master" or similar acceptable?

Change 956098 had a related patch set uploaded (by Enag2000; author: Enag2000):

[pywikibot/core@master] Wrapped DOT-string in curly braces in argument passed to pydot.graph_from_dot_data().

https://gerrit.wikimedia.org/r/956098

Accidentally submitted for review twice. My mistake. I just looked at the Gerrit/Tutorial on MediaWiki and understand the correct process now.

Change 956089 abandoned by Xqt:

[pywikibot/core@master] Wrapped DOT-string in curly braces in argument passed to pydot.graph_from_dot_data().

Reason:

duplicate solution

https://gerrit.wikimedia.org/r/956089

Change 956098 merged by jenkins-bot:

[pywikibot/core@master] Wrap DOT-string in curly braces in category_graph.py

https://gerrit.wikimedia.org/r/956098

Code review complete. Jenkins build succeeded and change merged. Moving to "Resolved".