Uploaded image for project: 'Beam'
  1. Beam
  2. BEAM-4036

Pickler enters infinite recursion with self-referential classes

Details

    • Bug
    • Status: Open
    • P3
    • Resolution: Unresolved
    • None
    • None
    • sdk-py-core
    • None

    Description

      The pickler recurses infinitely and dies with maximum recursion limit exceeded when a module contains a self-referential class (or any class which is part of a cycle).

      Here's a minimal example: 

      class RecursiveClass(object):
       SELF_TYPE = None
      
       def __init__(self, datum)
         self.datum = 'RecursiveClass:%s' % datum
      
      RecursiveClass.SELF_TYPE = RecursiveClass
      

      If this is in a module, then the pickler will enter the infinite recursion when trying to pickle any nested class in that module.
       

      An actual example is with typing.Type, which is part of a cycle typing.Type -> type -> object -> typing.Type. If a module contains an attribute that refers to typing.Type, such as a type alias, it will trigger this bug.

      Attachments

        Issue Links

          Activity

            People

              Unassigned Unassigned
              chuanyu Chuan Yu Foo
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:

                Time Tracking

                  Estimated:
                  Original Estimate - Not Specified
                  Not Specified
                  Remaining:
                  Remaining Estimate - 0h
                  0h
                  Logged:
                  Time Spent - 1h 10m
                  1h 10m