Skip to content

Reference hunting (python3 -m test -R 3:3) doesn't work if the _abc module is missing #80746

Closed

Description

@vstinner
BPO 36565
Nosy @vstinner
PRs
  • bpo-36565: Fix libregrtest for Python without builtin _abc #12733
  • [3.7] bpo-36565: Fix libregrtest for Python without builtin _abc (GH-12733) #12734
  • Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

    Show more details

    GitHub fields:

    assignee = None
    closed_at = <Date 2019-04-08.23:58:35.020>
    created_at = <Date 2019-04-08.16:56:30.382>
    labels = ['3.8', 'library']
    title = "Reference hunting (python3 -m test -R 3:3) doesn't work if the _abc module is missing"
    updated_at = <Date 2019-04-08.23:58:35.019>
    user = 'https://github.com/vstinner'

    bugs.python.org fields:

    activity = <Date 2019-04-08.23:58:35.019>
    actor = 'vstinner'
    assignee = 'none'
    closed = True
    closed_date = <Date 2019-04-08.23:58:35.020>
    closer = 'vstinner'
    components = ['Library (Lib)']
    creation = <Date 2019-04-08.16:56:30.382>
    creator = 'vstinner'
    dependencies = []
    files = []
    hgrepos = []
    issue_num = 36565
    keywords = ['patch']
    message_count = 3.0
    messages = ['339661', '339685', '339686']
    nosy_count = 1.0
    nosy_names = ['vstinner']
    pr_nums = ['12733', '12734']
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = None
    url = 'https://bugs.python.org/issue36565'
    versions = ['Python 3.8']

    Activity

    1. vstinner commented on Apr 8, 2019

      @vstinner
      MemberAuthor

      Disable the compilation of the built-in _abc module. For example, on Python 3.7 apply the following patch:

      diff --git a/Modules/Setup.dist b/Modules/Setup.dist
      index 8cc6bf0540..4015527b32 100644
      --- a/Modules/Setup.dist
      +++ b/Modules/Setup.dist
      @@ -114,7 +114,7 @@ _weakref _weakref.c                 # weak references
       _functools -DPy_BUILD_CORE _functoolsmodule.c   # Tools for working with functions and callable objects
       _operator _operator.c                  # operator.add() and similar goodies
       _collections _collectionsmodule.c      # Container types
      -_abc _abc.c                            # Abstract base classes
      +#_abc _abc.c                           # Abstract base classes
       itertools itertoolsmodule.c            # Functions creating iterators for efficient looping
       atexit atexitmodule.c                  # Register functions to be run at interpreter-shutdown
       _signal -DPy_BUILD_CORE signalmodule.c
      @@ -363,7 +363,8 @@ xxsubtype xxsubtype.c
       # Uncommenting the following line tells makesetup that all following modules
       # are not built (see above for more detail).
       #
      -#*disabled*
      +*disabled*
       #
       #_sqlite3 _tkinter _curses pyexpat
       #_codecs_jp _codecs_kr _codecs_tw unicodedata
      +_abc

      Recompile Python, check:

      $ ./python -c 'import _abc'
      ModuleNotFoundError: No module named '_abc'

      Run:

      $ ./python -u -m test -R 3:3 test_functools -m test_mro_conflicts 

      Error without _abc:

      test test_functools crashed -- Traceback (most recent call last):
        File "/home/vstinner/prog/python/3.7/Lib/test/libregrtest/runtest.py", line 180, in runtest_inner
          refleak = dash_R(the_module, test, test_runner, ns.huntrleaks)
        File "/home/vstinner/prog/python/3.7/Lib/test/libregrtest/refleak.py", line 71, in dash_R
          abcs)
        File "/home/vstinner/prog/python/3.7/Lib/test/libregrtest/refleak.py", line 148, in dash_R_cleanup
          obj.register(ref())
        File "/home/vstinner/prog/python/3.7/Lib/_py_abc.py", line 60, in register
          raise TypeError("Can only register classes")
      TypeError: Can only register classes

      With built-in _abc module, regrtest is fine.

      The problem comes from pure-Python reimplementation of abc._get_dump() in Lib/test/libregrtest/refleak.py:

          def _get_dump(cls):
              # For legacy Python version
              return (cls._abc_registry, cls._abc_cache,
                      cls._abc_negative_cache, cls._abc_negative_cache_version)

      The first item tuple must be a set of weak references. Currently, it's a weak set of strong references.

      Attached PR fix the issue.

    2. added
      stdlibStandard Library Python modules in the Lib/ directory
      on Apr 8, 2019
    3. vstinner commented on Apr 8, 2019

      @vstinner
      MemberAuthor

      New changeset 79b5d29 by Victor Stinner in branch 'master':
      bpo-36565: Fix libregrtest for Python without builtin _abc (GH-12733)
      79b5d29

    4. vstinner commented on Apr 8, 2019

      @vstinner
      MemberAuthor

      New changeset 2368d86 by Victor Stinner (Miss Islington (bot)) in branch '3.7':
      bpo-36565: Fix libregrtest for Python without builtin _abc (GH-12733) (GH-12734)
      2368d86

    5. transferred this issue fromon Apr 10, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

    Metadata

    Metadata

    Assignees

    No one assigned

      Labels

      3.8 (EOL)end of lifestdlibStandard Library Python modules in the Lib/ directory

      Projects

      No projects

        Milestone

        No milestone

        Relationships

        None yet

        Development

        No branches or pull requests

        Issue actions