{"action":"closed","issue":{"url":"https://api.github.com/repos/google/protobuf/issues/919","labels_url":"https://api.github.com/repos/google/protobuf/issues/919/labels{/name}","comments_url":"https://api.github.com/repos/google/protobuf/issues/919/comments","events_url":"https://api.github.com/repos/google/protobuf/issues/919/events","html_url":"https://github.com/google/protobuf/issues/919","id":113990946,"number":919,"title":"Python - `clear_when_set_to_default` behavior","user":{"login":"mhahn","id":704593,"avatar_url":"https://avatars.githubusercontent.com/u/704593?v=3","gravatar_id":"","url":"https://api.github.com/users/mhahn","html_url":"https://github.com/mhahn","followers_url":"https://api.github.com/users/mhahn/followers","following_url":"https://api.github.com/users/mhahn/following{/other_user}","gists_url":"https://api.github.com/users/mhahn/gists{/gist_id}","starred_url":"https://api.github.com/users/mhahn/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mhahn/subscriptions","organizations_url":"https://api.github.com/users/mhahn/orgs","repos_url":"https://api.github.com/users/mhahn/repos","events_url":"https://api.github.com/users/mhahn/events{/privacy}","received_events_url":"https://api.github.com/users/mhahn/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":5,"created_at":"2015-10-29T06:37:15Z","updated_at":"2015-11-03T03:41:40Z","closed_at":"2015-11-03T03:41:40Z","body":"I'm curious about the behavior of `clear_when_set_to_default` when setting the value of a non-repeated, scalar field.\r\n\r\nI understand that in proto3, default values have been dropped from being specified in the message, but I don't see why the value would be cleared if it was explicitly set to something in the code.\r\n\r\nMy interpretation of `ListFields` is that it's a list of all the fields that have been set. Now that seems to no longer be the case.\r\n\r\nsay I have something like the following proto:\r\n\r\n```\r\nsyntax = \"proto3\";\r\n\r\nenum ContactMethodType {\r\n    CELL_PHONE = 0;\r\n    EMAIL = 1;\r\n}\r\n\r\nmessage ContactMethod {\r\n    ContactMethodType contact_method_type = 1;\r\n    string value = 2;\r\n}\r\n```\r\n\r\nwhich results in the following behavior:\r\n```\r\ncontact_method = ContactMethod(value=2, contact_method_type=0)\r\n# ListFields() will only return 1 field since we're using the default\r\nassert len(contact_method.ListFields(), 1)\r\ncontact_method.contact_method_type = 1\r\n# ListFields() will now return 2 fields since we're no longer using the default\r\nassert len(contact_method.ListFields(), 2)\r\n# setting back to 0 will clear the field\r\ncontact_method.contact_method_type = 0\r\nassert len(conact_method.ListFields(), 1)\r\n```\r\n\r\nthat seems overly aggressive to me. what is the new definition of `ListFields`? \r\n\r\nI came across this because I use: https://github.com/benhodgson/protobuf-to-dict/blob/master/src/protobuf_to_dict.py#L42, which no longer generates a dictionary with enum values if they're set to the default.\r\n\r\nIf this is the desired behavior, is there another way to list all of the message field types so I could construct the dictionary (with default enum values included)?\r\n\r\nThe only way I can see from the message is iterating over all attributes that are lowercase and don't start with a \"_\"."}}