You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mxnet.apache.org by gi...@git.apache.org on 2017/08/31 04:04:20 UTC

[GitHub] szha commented on a change in pull request #7667: forbid setattr type changes and enable block replacement

szha commented on a change in pull request #7667: forbid setattr type changes and enable block replacement
URL: https://github.com/apache/incubator-mxnet/pull/7667#discussion_r136241899
 
 

 ##########
 File path: python/mxnet/gluon/block.py
 ##########
 @@ -172,9 +172,23 @@ def __repr__(self):
 
     def __setattr__(self, name, value):
         """Registers parameters."""
+
+        if hasattr(self, name):
+            existing = getattr(self, name)
+            if not name.startswith('_') and not isinstance(value, type(existing)):
+                raise TypeError('Changing attribute type for {name} from {type1} to {type2}' \
 
 Review comment:
   Existing attribute value can be NoneType and later changes to Block or Parameter. Should this be allowed?
 
----------------------------------------------------------------
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:
users@infra.apache.org


With regards,
Apache Git Services