Page MenuHomePhabricator

Depth limit for circular-dependent category
Closed, ResolvedPublic

Description

When using CategorizedPageGenerator or SubCategoriesPageGenerator, the recursive option for a circular-dependent category causes python error.

How about to make a max_depth option and/or preventing re-visiting the same category??

This is an example error message.

Traceback (most recent call last):
  File "/usr/lib/python3.4/inspect.py", line 971, in getfullargspec
    skip_bound_arg=False)
  File "/usr/lib/python3.4/inspect.py", line 1917, in _signature_internal
    return Signature.from_function(obj)
  File "/usr/lib/python3.4/inspect.py", line 2450, in from_function
    __validate_parameters__=is_duck_function)
  File "/usr/lib/python3.4/inspect.py", line 2366, in __init__
    for param in parameters))
  File "/usr/lib/python3.4/collections/__init__.py", line 56, in __init__
    self.__update(*args, **kwds)
  File "/usr/lib/python3.4/_collections_abc.py", line 576, in update
    if isinstance(other, Mapping):
  File "/usr/lib/python3.4/abc.py", line 188, in __instancecheck__
    subclass in cls._abc_negative_cache):
  File "/usr/lib/python3.4/_weakrefset.py", line 75, in __contains__
    return wr in self.data
RuntimeError: maximum recursion depth exceeded in comparison

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "check_descent.py", line 55, in check_descent
    for page in gen:
  File "/mnt/nfs/labstore-secondary-tools-project/chobot/src/pywikibot-core.new/pywikibot/pagegenerators.py", line 1364, in SubCategoriesPageGenerator
    total=total, content=content):
  File "/mnt/nfs/labstore-secondary-tools-project/chobot/src/pywikibot-core.new/pywikibot/page.py", line 2778, in subcategories
    recurse, total=total, content=content):
  File "/mnt/nfs/labstore-secondary-tools-project/chobot/src/pywikibot-core.new/pywikibot/page.py", line 2778, in subcategories
    recurse, total=total, content=content):
... (repeat).............................................................
  File "/mnt/nfs/labstore-secondary-tools-project/chobot/src/pywikibot-core.new/pywikibot/page.py", line 2768, in subcategories
    self, member_type='subcat', total=total, content=content):
  File "/mnt/nfs/labstore-secondary-tools-project/chobot/src/pywikibot-core.new/pywikibot/tools/__init__.py", line 1474, in wrapper
    return obj(*__args, **__kw)
  File "/mnt/nfs/labstore-secondary-tools-project/chobot/src/pywikibot-core.new/pywikibot/site.py", line 3939, in categorymembers
    total=total, g_content=content, **cmargs)
  File "/mnt/nfs/labstore-secondary-tools-project/chobot/src/pywikibot-core.new/pywikibot/tools/__init__.py", line 1474, in wrapper
    return obj(*__args, **__kw)
  File "/mnt/nfs/labstore-secondary-tools-project/chobot/src/pywikibot-core.new/pywikibot/site.py", line 1956, in _generator
    gen = gen_class(type_arg, **req_args)
  File "/mnt/nfs/labstore-secondary-tools-project/chobot/src/pywikibot-core.new/pywikibot/data/api.py", line 2892, in __init__
    kwargs = self._clean_kwargs(kwargs)
  File "/mnt/nfs/labstore-secondary-tools-project/chobot/src/pywikibot-core.new/pywikibot/data/api.py", line 2370, in _clean_kwargs
    kwargs = self.request_class.clean_kwargs(kwargs)
  File "/mnt/nfs/labstore-secondary-tools-project/chobot/src/pywikibot-core.new/pywikibot/data/api.py", line 1518, in clean_kwargs
    args |= set(getargspec(super_cls.__init__)[0])
  File "/usr/lib/python3.4/inspect.py", line 928, in getargspec
    getfullargspec(func)
  File "/usr/lib/python3.4/inspect.py", line 977, in getfullargspec
    raise TypeError('unsupported callable') from ex
TypeError: unsupported callable

Event Timeline

Framawiki renamed this task from depth limit for to Depth limit for circular-dependent category.Dec 26 2017, 8:03 AM
Framawiki updated the task description. (Show Details)
Framawiki subscribed.
Xqt triaged this task as High priority.Jan 7 2018, 12:07 PM
ChongDae claimed this task.

I find that "recurse" option can handle the depth limit. Close this request.

from page.py:

@param recurse: if not False or 0, also iterate subcategories of
    subcategories. If an int, limit recursion to this number of
    levels. (Example: recurse=1 will iterate direct subcats and
    first-level sub-sub-cats, but no deeper.)
@type recurse: int or bool