Skip to content

GitLab

  • Menu
Projects Groups Snippets
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • pypy pypy
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 668
    • Issues 668
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 14
    • Merge requests 14
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Monitor
    • Monitor
    • Incidents
  • Packages & Registries
    • Packages & Registries
    • Container Registry
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • PyPy
  • pypypypy
  • Issues
  • #3555

Closed
Open
Created Sep 16, 2021 by Michał Górny@mgornyDeveloper

PyPy3.8: __repr__ of namedtuple subclass with __iter__ (e.g. importlib.metadata.EntryPoint) causes infinite recursion

Trivial reproducer (based on reducing importlib.metadata.EntryPoint):

import collections


class EntryPoint(
        collections.namedtuple('EntryPointBase', 'name value group')):

    def __iter__(self):
        return iter((self.name, self))


print(repr(EntryPoint('a', 'b', 'c')))
$ python3.8 repro.py 
EntryPoint(name='a', value='b', group='c')
$ pypy3 repro.py 
Traceback (most recent call last):
  File "repro.py", line 14, in <module>
    print(repr(EntryPoint('a', 'b', 'c')))
  File "/usr/lib/pypy3.8/collections/__init__.py", line 421, in __repr__
    return self.__class__.__name__ + repr_fmt % self
  File "/usr/lib/pypy3.8/collections/__init__.py", line 421, in __repr__
    return self.__class__.__name__ + repr_fmt % self
  File "/usr/lib/pypy3.8/collections/__init__.py", line 421, in __repr__
    return self.__class__.__name__ + repr_fmt % self
  [Previous line repeated 887 more times]
  File "repro.py", line 11, in __iter__
    return iter((self.name, self))
RecursionError: maximum recursion depth exceeded

It seems that for some reason this is using __iter__ on PyPy3.8 but not on CPython.

Edited Sep 17, 2021 by Michał Górny
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information
Assignee
Assign to
Time tracking