[ 
https://issues.apache.org/jira/browse/BEAM-4036?focusedWorklogId=89208&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-89208
 ]

ASF GitHub Bot logged work on BEAM-4036:
----------------------------------------

                Author: ASF GitHub Bot
            Created on: 10/Apr/18 00:54
            Start Date: 10/Apr/18 00:54
    Worklog Time Spent: 10m 
      Work Description: aaltay commented on a change in pull request #5072: 
[BEAM-4036] Fix pickling for "recursive" classes.
URL: https://github.com/apache/beam/pull/5072#discussion_r180270969
 
 

 ##########
 File path: sdks/python/apache_beam/internal/pickler.py
 ##########
 @@ -48,7 +48,12 @@ def _is_nested_class(cls):
 def _find_containing_class(nested_class):
   """Finds containing class of a nestec class passed as argument."""
 
+  seen = {}
 
 Review comment:
   You could use a set instead. Such as:
   
   ```
   seen = set()
   ...
   if outer in seen:
     return
   seen.add(outer)
   ```

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


Issue Time Tracking
-------------------

    Worklog Id:     (was: 89208)
    Time Spent: 0.5h  (was: 20m)

> Pickler enters infinite recursion with self-referential classes
> ---------------------------------------------------------------
>
>                 Key: BEAM-4036
>                 URL: https://issues.apache.org/jira/browse/BEAM-4036
>             Project: Beam
>          Issue Type: Bug
>          Components: sdk-py-core
>            Reporter: Chuan Yu Foo
>            Assignee: Ahmet Altay
>            Priority: Major
>          Time Spent: 0.5h
>  Remaining Estimate: 0h
>
> 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: 
> {code}
> class RecursiveClass(object):
>  SELF_TYPE = None
>  def __init__(self, datum)
>    self.datum = 'RecursiveClass:%s' % datum
> RecursiveClass.SELF_TYPE = RecursiveClass
> {code}
> 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.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Reply via email to