Skip to content

Commit

Permalink
Merge pull request #7953 from udim/pickler
Browse files Browse the repository at this point in the history
[BEAM-1251] Fix Python 3 compatibility bug in pickler.py
  • Loading branch information
charlesccychen committed Feb 28, 2019
2 parents a679d98 + 46a70a8 commit 7ddf735
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions sdks/python/apache_beam/internal/pickler.py
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,17 @@ def new_save_module_dict(pickler, obj):
obj_id = id(obj)
if not known_module_dicts or '__file__' in obj or '__package__' in obj:
if obj_id not in known_module_dicts:
# Trigger loading of lazily loaded modules (such as pytest vendored
# modules).
# This first pass over sys.modules needs to iterate on a copy of
# sys.modules since lazy loading modifies the dictionary, hence the use
# of list().
for m in list(sys.modules.values()):
try:
_ = m.__dict__
except AttributeError:
pass

for m in sys.modules.values():
try:
if (m
Expand Down

0 comments on commit 7ddf735

Please sign in to comment.