py2docfx 0.1.20rc2196756__py3-none-any.whl → 0.1.20rc2245107__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (107) hide show
  1. py2docfx/venv/basevenv/Lib/site-packages/charset_normalizer/api.py +3 -2
  2. py2docfx/venv/basevenv/Lib/site-packages/charset_normalizer/legacy.py +17 -1
  3. py2docfx/venv/basevenv/Lib/site-packages/charset_normalizer/version.py +1 -1
  4. py2docfx/venv/basevenv/Lib/site-packages/requests/__version__.py +2 -2
  5. py2docfx/venv/basevenv/Lib/site-packages/requests/adapters.py +17 -40
  6. py2docfx/venv/basevenv/Lib/site-packages/requests/sessions.py +1 -1
  7. py2docfx/venv/venv1/Lib/site-packages/azure/core/_version.py +1 -1
  8. py2docfx/venv/venv1/Lib/site-packages/azure/core/pipeline/policies/_authentication.py +21 -9
  9. py2docfx/venv/venv1/Lib/site-packages/azure/core/pipeline/policies/_authentication_async.py +21 -9
  10. py2docfx/venv/venv1/Lib/site-packages/azure/core/pipeline/policies/_retry.py +1 -1
  11. py2docfx/venv/venv1/Lib/site-packages/azure/identity/_bearer_token_provider.py +1 -1
  12. py2docfx/venv/venv1/Lib/site-packages/azure/identity/_credentials/authorization_code.py +1 -1
  13. py2docfx/venv/venv1/Lib/site-packages/azure/identity/_credentials/azd_cli.py +82 -17
  14. py2docfx/venv/venv1/Lib/site-packages/azure/identity/_credentials/azure_cli.py +28 -5
  15. py2docfx/venv/venv1/Lib/site-packages/azure/identity/_credentials/azure_powershell.py +28 -4
  16. py2docfx/venv/venv1/Lib/site-packages/azure/identity/_credentials/broker.py +79 -0
  17. py2docfx/venv/venv1/Lib/site-packages/azure/identity/_credentials/chained.py +9 -3
  18. py2docfx/venv/venv1/Lib/site-packages/azure/identity/_credentials/default.py +153 -53
  19. py2docfx/venv/venv1/Lib/site-packages/azure/identity/_credentials/imds.py +25 -1
  20. py2docfx/venv/venv1/Lib/site-packages/azure/identity/_credentials/shared_cache.py +12 -5
  21. py2docfx/venv/venv1/Lib/site-packages/azure/identity/_credentials/vscode.py +163 -144
  22. py2docfx/venv/venv1/Lib/site-packages/azure/identity/_credentials/workload_identity.py +23 -12
  23. py2docfx/venv/venv1/Lib/site-packages/azure/identity/_internal/__init__.py +4 -0
  24. py2docfx/venv/venv1/Lib/site-packages/azure/identity/_internal/interactive.py +14 -2
  25. py2docfx/venv/venv1/Lib/site-packages/azure/identity/_internal/pipeline.py +4 -2
  26. py2docfx/venv/venv1/Lib/site-packages/azure/identity/_internal/utils.py +96 -0
  27. py2docfx/venv/venv1/Lib/site-packages/azure/identity/_version.py +1 -1
  28. py2docfx/venv/venv1/Lib/site-packages/azure/identity/aio/_bearer_token_provider.py +3 -3
  29. py2docfx/venv/venv1/Lib/site-packages/azure/identity/aio/_credentials/authorization_code.py +1 -1
  30. py2docfx/venv/venv1/Lib/site-packages/azure/identity/aio/_credentials/azd_cli.py +32 -13
  31. py2docfx/venv/venv1/Lib/site-packages/azure/identity/aio/_credentials/azure_cli.py +26 -5
  32. py2docfx/venv/venv1/Lib/site-packages/azure/identity/aio/_credentials/azure_powershell.py +13 -2
  33. py2docfx/venv/venv1/Lib/site-packages/azure/identity/aio/_credentials/chained.py +1 -1
  34. py2docfx/venv/venv1/Lib/site-packages/azure/identity/aio/_credentials/default.py +120 -55
  35. py2docfx/venv/venv1/Lib/site-packages/azure/identity/aio/_credentials/imds.py +27 -1
  36. py2docfx/venv/venv1/Lib/site-packages/azure/identity/aio/_credentials/on_behalf_of.py +1 -1
  37. py2docfx/venv/venv1/Lib/site-packages/azure/identity/aio/_credentials/shared_cache.py +12 -5
  38. py2docfx/venv/venv1/Lib/site-packages/azure/identity/aio/_credentials/vscode.py +15 -67
  39. py2docfx/venv/venv1/Lib/site-packages/azure/identity/aio/_credentials/workload_identity.py +17 -13
  40. py2docfx/venv/venv1/Lib/site-packages/cffi/__init__.py +2 -2
  41. py2docfx/venv/venv1/Lib/site-packages/cffi/cparser.py +1 -1
  42. py2docfx/venv/venv1/Lib/site-packages/cffi/recompiler.py +5 -5
  43. py2docfx/venv/venv1/Lib/site-packages/cffi/setuptools_ext.py +13 -0
  44. py2docfx/venv/venv1/Lib/site-packages/cffi/vengine_cpy.py +3 -0
  45. py2docfx/venv/venv1/Lib/site-packages/charset_normalizer/api.py +3 -2
  46. py2docfx/venv/venv1/Lib/site-packages/charset_normalizer/legacy.py +17 -1
  47. py2docfx/venv/venv1/Lib/site-packages/charset_normalizer/version.py +1 -1
  48. py2docfx/venv/venv1/Lib/site-packages/cryptography/__about__.py +1 -1
  49. py2docfx/venv/venv1/Lib/site-packages/cryptography/__init__.py +0 -13
  50. py2docfx/venv/venv1/Lib/site-packages/cryptography/hazmat/_oid.py +8 -0
  51. py2docfx/venv/venv1/Lib/site-packages/cryptography/hazmat/asn1/__init__.py +10 -0
  52. py2docfx/venv/venv1/Lib/site-packages/cryptography/hazmat/asn1/asn1.py +116 -0
  53. py2docfx/venv/venv1/Lib/site-packages/cryptography/hazmat/backends/openssl/backend.py +3 -9
  54. py2docfx/venv/venv1/Lib/site-packages/cryptography/hazmat/bindings/_rust/declarative_asn1.pyi +32 -0
  55. py2docfx/venv/venv1/Lib/site-packages/cryptography/hazmat/bindings/_rust/openssl/kdf.pyi +23 -0
  56. py2docfx/venv/venv1/Lib/site-packages/cryptography/hazmat/bindings/_rust/x509.pyi +1 -13
  57. py2docfx/venv/venv1/Lib/site-packages/cryptography/hazmat/bindings/openssl/_conditional.py +16 -0
  58. py2docfx/venv/venv1/Lib/site-packages/cryptography/hazmat/bindings/openssl/binding.py +16 -1
  59. py2docfx/venv/venv1/Lib/site-packages/cryptography/hazmat/primitives/asymmetric/padding.py +0 -2
  60. py2docfx/venv/venv1/Lib/site-packages/cryptography/hazmat/primitives/asymmetric/rsa.py +8 -0
  61. py2docfx/venv/venv1/Lib/site-packages/cryptography/hazmat/primitives/ciphers/algorithms.py +0 -47
  62. py2docfx/venv/venv1/Lib/site-packages/cryptography/hazmat/primitives/kdf/hkdf.py +6 -91
  63. py2docfx/venv/venv1/Lib/site-packages/cryptography/hazmat/primitives/kdf/kbkdf.py +1 -3
  64. py2docfx/venv/venv1/Lib/site-packages/cryptography/hazmat/primitives/serialization/ssh.py +1 -1
  65. py2docfx/venv/venv1/Lib/site-packages/cryptography/utils.py +0 -2
  66. py2docfx/venv/venv1/Lib/site-packages/cryptography/x509/name.py +2 -3
  67. py2docfx/venv/venv1/Lib/site-packages/google/protobuf/__init__.py +1 -1
  68. py2docfx/venv/venv1/Lib/site-packages/google/protobuf/any_pb2.py +2 -2
  69. py2docfx/venv/venv1/Lib/site-packages/google/protobuf/api_pb2.py +12 -8
  70. py2docfx/venv/venv1/Lib/site-packages/google/protobuf/compiler/plugin_pb2.py +2 -2
  71. py2docfx/venv/venv1/Lib/site-packages/google/protobuf/descriptor.py +398 -246
  72. py2docfx/venv/venv1/Lib/site-packages/google/protobuf/descriptor_pb2.py +74 -72
  73. py2docfx/venv/venv1/Lib/site-packages/google/protobuf/descriptor_pool.py +5 -4
  74. py2docfx/venv/venv1/Lib/site-packages/google/protobuf/duration_pb2.py +2 -2
  75. py2docfx/venv/venv1/Lib/site-packages/google/protobuf/empty_pb2.py +2 -2
  76. py2docfx/venv/venv1/Lib/site-packages/google/protobuf/field_mask_pb2.py +2 -2
  77. py2docfx/venv/venv1/Lib/site-packages/google/protobuf/internal/api_implementation.py +0 -6
  78. py2docfx/venv/venv1/Lib/site-packages/google/protobuf/internal/extension_dict.py +3 -3
  79. py2docfx/venv/venv1/Lib/site-packages/google/protobuf/internal/field_mask.py +3 -3
  80. py2docfx/venv/venv1/Lib/site-packages/google/protobuf/internal/python_edition_defaults.py +1 -1
  81. py2docfx/venv/venv1/Lib/site-packages/google/protobuf/internal/python_message.py +10 -2
  82. py2docfx/venv/venv1/Lib/site-packages/google/protobuf/internal/type_checkers.py +47 -5
  83. py2docfx/venv/venv1/Lib/site-packages/google/protobuf/json_format.py +55 -32
  84. py2docfx/venv/venv1/Lib/site-packages/google/protobuf/runtime_version.py +6 -26
  85. py2docfx/venv/venv1/Lib/site-packages/google/protobuf/source_context_pb2.py +2 -2
  86. py2docfx/venv/venv1/Lib/site-packages/google/protobuf/struct_pb2.py +2 -2
  87. py2docfx/venv/venv1/Lib/site-packages/google/protobuf/text_format.py +30 -19
  88. py2docfx/venv/venv1/Lib/site-packages/google/protobuf/timestamp_pb2.py +2 -2
  89. py2docfx/venv/venv1/Lib/site-packages/google/protobuf/type_pb2.py +2 -2
  90. py2docfx/venv/venv1/Lib/site-packages/google/protobuf/wrappers_pb2.py +2 -2
  91. py2docfx/venv/venv1/Lib/site-packages/pycparser/__init__.py +1 -1
  92. py2docfx/venv/venv1/Lib/site-packages/pycparser/c_generator.py +1 -1
  93. py2docfx/venv/venv1/Lib/site-packages/pycparser/c_lexer.py +14 -0
  94. py2docfx/venv/venv1/Lib/site-packages/pycparser/c_parser.py +30 -7
  95. py2docfx/venv/venv1/Lib/site-packages/pycparser/lextab.py +1 -1
  96. py2docfx/venv/venv1/Lib/site-packages/pycparser/yacctab.py +132 -127
  97. py2docfx/venv/venv1/Lib/site-packages/requests/__version__.py +2 -2
  98. py2docfx/venv/venv1/Lib/site-packages/requests/adapters.py +17 -40
  99. py2docfx/venv/venv1/Lib/site-packages/requests/sessions.py +1 -1
  100. py2docfx/venv/venv1/Lib/site-packages/typing_extensions.py +91 -18
  101. {py2docfx-0.1.20rc2196756.dist-info → py2docfx-0.1.20rc2245107.dist-info}/METADATA +1 -1
  102. {py2docfx-0.1.20rc2196756.dist-info → py2docfx-0.1.20rc2245107.dist-info}/RECORD +104 -103
  103. py2docfx/venv/venv1/Lib/site-packages/azure/identity/_internal/linux_vscode_adapter.py +0 -100
  104. py2docfx/venv/venv1/Lib/site-packages/azure/identity/_internal/macos_vscode_adapter.py +0 -34
  105. py2docfx/venv/venv1/Lib/site-packages/azure/identity/_internal/win_vscode_adapter.py +0 -77
  106. {py2docfx-0.1.20rc2196756.dist-info → py2docfx-0.1.20rc2245107.dist-info}/WHEEL +0 -0
  107. {py2docfx-0.1.20rc2196756.dist-info → py2docfx-0.1.20rc2245107.dist-info}/top_level.txt +0 -0
@@ -22,16 +22,20 @@ TYPE_TO_DESERIALIZE_METHOD: A dictionary with field types and deserialization
22
22
 
23
23
  __author__ = 'robinson@google.com (Will Robinson)'
24
24
 
25
- import struct
26
25
  import numbers
26
+ import struct
27
+ import warnings
27
28
 
29
+ from google.protobuf import descriptor
28
30
  from google.protobuf.internal import decoder
29
31
  from google.protobuf.internal import encoder
30
32
  from google.protobuf.internal import wire_format
31
- from google.protobuf import descriptor
32
33
 
33
34
  _FieldDescriptor = descriptor.FieldDescriptor
34
-
35
+ # TODO: Remove this warning count after 34.0
36
+ # Assign bool to int/enum warnings will print 100 times at most which should
37
+ # be enough for users to notice and do not cause timeout.
38
+ _BoolWarningCount = 100
35
39
 
36
40
  def TruncateToFourByteFloat(original):
37
41
  return struct.unpack('<f', struct.pack('<f', original))[0]
@@ -113,12 +117,21 @@ class BoolValueChecker(object):
113
117
  """Type checker used for bool fields."""
114
118
 
115
119
  def CheckValue(self, proposed_value):
116
- if not hasattr(proposed_value, '__index__') or (
117
- type(proposed_value).__module__ == 'numpy' and
120
+ if not hasattr(proposed_value, '__index__'):
121
+ # Under NumPy 2.3, numpy.bool does not have an __index__ method.
122
+ if (type(proposed_value).__module__ == 'numpy' and
123
+ type(proposed_value).__name__ == 'bool'):
124
+ return bool(proposed_value)
125
+ message = ('%.1024r has type %s, but expected one of: %s' %
126
+ (proposed_value, type(proposed_value), (bool, int)))
127
+ raise TypeError(message)
128
+
129
+ if (type(proposed_value).__module__ == 'numpy' and
118
130
  type(proposed_value).__name__ == 'ndarray'):
119
131
  message = ('%.1024r has type %s, but expected one of: %s' %
120
132
  (proposed_value, type(proposed_value), (bool, int)))
121
133
  raise TypeError(message)
134
+
122
135
  return bool(proposed_value)
123
136
 
124
137
  def DefaultValue(self):
@@ -132,6 +145,21 @@ class IntValueChecker(object):
132
145
  """Checker used for integer fields. Performs type-check and range check."""
133
146
 
134
147
  def CheckValue(self, proposed_value):
148
+ global _BoolWarningCount
149
+ if type(proposed_value) == bool and _BoolWarningCount > 0:
150
+ _BoolWarningCount -= 1
151
+ message = (
152
+ '%.1024r has type %s, but expected one of: %s. This warning '
153
+ 'will turn into error in 7.34.0, please fix it before that.'
154
+ % (
155
+ proposed_value,
156
+ type(proposed_value),
157
+ (int,),
158
+ )
159
+ )
160
+ # TODO: Raise errors in 2026 Q1 release
161
+ warnings.warn(message)
162
+
135
163
  if not hasattr(proposed_value, '__index__') or (
136
164
  type(proposed_value).__module__ == 'numpy' and
137
165
  type(proposed_value).__name__ == 'ndarray'):
@@ -158,6 +186,20 @@ class EnumValueChecker(object):
158
186
  self._enum_type = enum_type
159
187
 
160
188
  def CheckValue(self, proposed_value):
189
+ global _BoolWarningCount
190
+ if type(proposed_value) == bool and _BoolWarningCount > 0:
191
+ _BoolWarningCount -= 1
192
+ message = (
193
+ '%.1024r has type %s, but expected one of: %s. This warning '
194
+ 'will turn into error in 7.34.0, please fix it before that.'
195
+ % (
196
+ proposed_value,
197
+ type(proposed_value),
198
+ (int,),
199
+ )
200
+ )
201
+ # TODO: Raise errors in 2026 Q1 release
202
+ warnings.warn(message)
161
203
  if not isinstance(proposed_value, numbers.Integral):
162
204
  message = ('%.1024r has type %s, but expected one of: %s' %
163
205
  (proposed_value, type(proposed_value), (int,)))
@@ -26,6 +26,7 @@ import json
26
26
  import math
27
27
  from operator import methodcaller
28
28
  import re
29
+ import warnings
29
30
 
30
31
  from google.protobuf import descriptor
31
32
  from google.protobuf import message_factory
@@ -72,6 +73,7 @@ class ParseError(Error):
72
73
 
73
74
  class EnumStringValueParseError(ParseError):
74
75
  """Thrown if unknown string enum value is encountered.
76
+
75
77
  This exception is suppressed if ignore_unknown_fields is set.
76
78
  """
77
79
 
@@ -91,10 +93,10 @@ def MessageToJson(
91
93
 
92
94
  Args:
93
95
  message: The protocol buffers message instance to serialize.
94
- always_print_fields_with_no_presence: If True, fields without
95
- presence (implicit presence scalars, repeated fields, and map fields) will
96
- always be serialized. Any field that supports presence is not affected by
97
- this option (including singular message fields and oneof fields).
96
+ always_print_fields_with_no_presence: If True, fields without presence
97
+ (implicit presence scalars, repeated fields, and map fields) will always
98
+ be serialized. Any field that supports presence is not affected by this
99
+ option (including singular message fields and oneof fields).
98
100
  preserving_proto_field_name: If True, use the original proto field names as
99
101
  defined in the .proto file. If False, convert the field names to
100
102
  lowerCamelCase.
@@ -105,7 +107,8 @@ def MessageToJson(
105
107
  use_integers_for_enums: If true, print integers instead of enum names.
106
108
  descriptor_pool: A Descriptor Pool for resolving types. If None use the
107
109
  default.
108
- float_precision: If set, use this to specify float field valid digits.
110
+ float_precision: Deprecated. If set, use this to specify float field valid
111
+ digits.
109
112
  ensure_ascii: If True, strings with non-ASCII characters are escaped. If
110
113
  False, Unicode strings are returned unchanged.
111
114
 
@@ -117,7 +120,7 @@ def MessageToJson(
117
120
  use_integers_for_enums,
118
121
  descriptor_pool,
119
122
  float_precision,
120
- always_print_fields_with_no_presence
123
+ always_print_fields_with_no_presence,
121
124
  )
122
125
  return printer.ToJsonString(message, indent, sort_keys, ensure_ascii)
123
126
 
@@ -136,17 +139,18 @@ def MessageToDict(
136
139
 
137
140
  Args:
138
141
  message: The protocol buffers message instance to serialize.
139
- always_print_fields_with_no_presence: If True, fields without
140
- presence (implicit presence scalars, repeated fields, and map fields) will
141
- always be serialized. Any field that supports presence is not affected by
142
- this option (including singular message fields and oneof fields).
142
+ always_print_fields_with_no_presence: If True, fields without presence
143
+ (implicit presence scalars, repeated fields, and map fields) will always
144
+ be serialized. Any field that supports presence is not affected by this
145
+ option (including singular message fields and oneof fields).
143
146
  preserving_proto_field_name: If True, use the original proto field names as
144
147
  defined in the .proto file. If False, convert the field names to
145
148
  lowerCamelCase.
146
149
  use_integers_for_enums: If true, print integers instead of enum names.
147
150
  descriptor_pool: A Descriptor Pool for resolving types. If None use the
148
151
  default.
149
- float_precision: If set, use this to specify float field valid digits.
152
+ float_precision: Deprecated. If set, use this to specify float field valid
153
+ digits.
150
154
 
151
155
  Returns:
152
156
  A dict representation of the protocol buffer message.
@@ -188,6 +192,11 @@ class _Printer(object):
188
192
  self.use_integers_for_enums = use_integers_for_enums
189
193
  self.descriptor_pool = descriptor_pool
190
194
  if float_precision:
195
+ warnings.warn(
196
+ 'float_precision option is deprecated for json_format. '
197
+ 'This will turn into error in 7.34.0, please remove it '
198
+ 'before that.'
199
+ )
191
200
  self.float_format = '.{}g'.format(float_precision)
192
201
  else:
193
202
  self.float_format = None
@@ -233,7 +242,7 @@ class _Printer(object):
233
242
  recorded_key = str(key)
234
243
  js_map[recorded_key] = self._FieldToJsonObject(v_field, value[key])
235
244
  js[name] = js_map
236
- elif field.label == descriptor.FieldDescriptor.LABEL_REPEATED:
245
+ elif field.is_repeated:
237
246
  # Convert a repeated field.
238
247
  js[name] = [self._FieldToJsonObject(field, k) for k in value]
239
248
  elif field.is_extension:
@@ -251,10 +260,7 @@ class _Printer(object):
251
260
 
252
261
  # always_print_fields_with_no_presence doesn't apply to
253
262
  # any field which supports presence.
254
- if (
255
- self.always_print_fields_with_no_presence
256
- and field.has_presence
257
- ):
263
+ if self.always_print_fields_with_no_presence and field.has_presence:
258
264
  continue
259
265
 
260
266
  if self.preserving_proto_field_name:
@@ -266,7 +272,7 @@ class _Printer(object):
266
272
  continue
267
273
  if _IsMapEntry(field):
268
274
  js[name] = {}
269
- elif field.label == descriptor.FieldDescriptor.LABEL_REPEATED:
275
+ elif field.is_repeated:
270
276
  js[name] = []
271
277
  else:
272
278
  js[name] = self._FieldToJsonObject(field, field.default_value)
@@ -636,7 +642,7 @@ class _Parser(object):
636
642
  self._ConvertMapFieldValue(
637
643
  value, message, field, '{0}.{1}'.format(path, name)
638
644
  )
639
- elif field.label == descriptor.FieldDescriptor.LABEL_REPEATED:
645
+ elif field.is_repeated:
640
646
  message.ClearField(field.name)
641
647
  if not isinstance(value, _LIST_LIKE):
642
648
  raise ParseError(
@@ -674,7 +680,8 @@ class _Parser(object):
674
680
  )
675
681
  )
676
682
  self._ConvertAndAppendScalar(
677
- message, field, item, '{0}.{1}[{2}]'.format(path, name, index))
683
+ message, field, item, '{0}.{1}[{2}]'.format(path, name, index)
684
+ )
678
685
  elif field.cpp_type == descriptor.FieldDescriptor.CPPTYPE_MESSAGE:
679
686
  if field.is_extension:
680
687
  sub_message = message.Extensions[field]
@@ -684,9 +691,13 @@ class _Parser(object):
684
691
  self.ConvertMessage(value, sub_message, '{0}.{1}'.format(path, name))
685
692
  else:
686
693
  if field.is_extension:
687
- self._ConvertAndSetScalarExtension(message, field, value, '{0}.{1}'.format(path, name))
694
+ self._ConvertAndSetScalarExtension(
695
+ message, field, value, '{0}.{1}'.format(path, name)
696
+ )
688
697
  else:
689
- self._ConvertAndSetScalar(message, field, value, '{0}.{1}'.format(path, name))
698
+ self._ConvertAndSetScalar(
699
+ message, field, value, '{0}.{1}'.format(path, name)
700
+ )
690
701
  except ParseError as e:
691
702
  if field and field.containing_oneof is None:
692
703
  raise ParseError(
@@ -801,7 +812,9 @@ class _Parser(object):
801
812
  def _ConvertWrapperMessage(self, value, message, path):
802
813
  """Convert a JSON representation into Wrapper message."""
803
814
  field = message.DESCRIPTOR.fields_by_name['value']
804
- self._ConvertAndSetScalar(message, field, value, path='{0}.value'.format(path))
815
+ self._ConvertAndSetScalar(
816
+ message, field, value, path='{0}.value'.format(path)
817
+ )
805
818
 
806
819
  def _ConvertMapFieldValue(self, value, message, field, path):
807
820
  """Convert map field value for a message map field.
@@ -839,13 +852,17 @@ class _Parser(object):
839
852
  field,
840
853
  key_value,
841
854
  value[key],
842
- path='{0}[{1}]'.format(path, key_value))
855
+ path='{0}[{1}]'.format(path, key_value),
856
+ )
843
857
 
844
- def _ConvertAndSetScalarExtension(self, message, extension_field, js_value, path):
858
+ def _ConvertAndSetScalarExtension(
859
+ self, message, extension_field, js_value, path
860
+ ):
845
861
  """Convert scalar from js_value and assign it to message.Extensions[extension_field]."""
846
862
  try:
847
863
  message.Extensions[extension_field] = _ConvertScalarFieldValue(
848
- js_value, extension_field, path)
864
+ js_value, extension_field, path
865
+ )
849
866
  except EnumStringValueParseError:
850
867
  if not self.ignore_unknown_fields:
851
868
  raise
@@ -854,9 +871,8 @@ class _Parser(object):
854
871
  """Convert scalar from js_value and assign it to message.field."""
855
872
  try:
856
873
  setattr(
857
- message,
858
- field.name,
859
- _ConvertScalarFieldValue(js_value, field, path))
874
+ message, field.name, _ConvertScalarFieldValue(js_value, field, path)
875
+ )
860
876
  except EnumStringValueParseError:
861
877
  if not self.ignore_unknown_fields:
862
878
  raise
@@ -865,16 +881,23 @@ class _Parser(object):
865
881
  """Convert scalar from js_value and append it to message.repeated_field."""
866
882
  try:
867
883
  getattr(message, repeated_field.name).append(
868
- _ConvertScalarFieldValue(js_value, repeated_field, path))
884
+ _ConvertScalarFieldValue(js_value, repeated_field, path)
885
+ )
869
886
  except EnumStringValueParseError:
870
887
  if not self.ignore_unknown_fields:
871
888
  raise
872
889
 
873
- def _ConvertAndSetScalarToMapKey(self, message, map_field, converted_key, js_value, path):
890
+ def _ConvertAndSetScalarToMapKey(
891
+ self, message, map_field, converted_key, js_value, path
892
+ ):
874
893
  """Convert scalar from 'js_value' and add it to message.map_field[converted_key]."""
875
894
  try:
876
- getattr(message, map_field.name)[converted_key] = _ConvertScalarFieldValue(
877
- js_value, map_field.message_type.fields_by_name['value'], path,
895
+ getattr(message, map_field.name)[converted_key] = (
896
+ _ConvertScalarFieldValue(
897
+ js_value,
898
+ map_field.message_type.fields_by_name['value'],
899
+ path,
900
+ )
878
901
  )
879
902
  except EnumStringValueParseError:
880
903
  if not self.ignore_unknown_fields:
@@ -28,7 +28,7 @@ class Domain(Enum):
28
28
  # These OSS versions are not stripped to avoid merging conflicts.
29
29
  OSS_DOMAIN = Domain.PUBLIC
30
30
  OSS_MAJOR = 6
31
- OSS_MINOR = 31
31
+ OSS_MINOR = 32
32
32
  OSS_PATCH = 1
33
33
  OSS_SUFFIX = ''
34
34
 
@@ -92,33 +92,13 @@ def ValidateProtobufRuntimeVersion(
92
92
  ' Cross-domain usage of Protobuf is not supported.'
93
93
  )
94
94
 
95
- if gen_major != MAJOR:
96
- if gen_major == MAJOR - 1:
97
- if _warning_count < _MAX_WARNING_COUNT:
98
- warnings.warn(
99
- 'Protobuf gencode version %s is exactly one major version older'
100
- ' than the runtime version %s at %s. Please update the gencode to'
101
- ' avoid compatibility violations in the next runtime release.'
102
- % (gen_version, version, location)
103
- )
104
- _warning_count += 1
105
- else:
106
- _ReportVersionError(
107
- 'Detected mismatched Protobuf Gencode/Runtime major versions when'
108
- f' loading {location}: gencode {gen_version} runtime {version}.'
109
- f' Same major version is required. {error_prompt}'
110
- )
111
-
112
- if MINOR < gen_minor or (MINOR == gen_minor and PATCH < gen_patch):
95
+ if (
96
+ MAJOR < gen_major
97
+ or (MAJOR == gen_major and MINOR < gen_minor)
98
+ or (MAJOR == gen_major and MINOR == gen_minor and PATCH < gen_patch)
99
+ ):
113
100
  _ReportVersionError(
114
101
  'Detected incompatible Protobuf Gencode/Runtime versions when loading'
115
102
  f' {location}: gencode {gen_version} runtime {version}. Runtime version'
116
103
  f' cannot be older than the linked gencode version. {error_prompt}'
117
104
  )
118
-
119
- if gen_suffix != SUFFIX:
120
- _ReportVersionError(
121
- 'Detected mismatched Protobuf Gencode/Runtime version suffixes when'
122
- f' loading {location}: gencode {gen_version} runtime {version}.'
123
- f' Version suffixes must be the same. {error_prompt}'
124
- )
@@ -2,7 +2,7 @@
2
2
  # Generated by the protocol buffer compiler. DO NOT EDIT!
3
3
  # NO CHECKED-IN PROTOBUF GENCODE
4
4
  # source: google/protobuf/source_context.proto
5
- # Protobuf Python Version: 6.31.1
5
+ # Protobuf Python Version: 6.32.1
6
6
  """Generated protocol buffer code."""
7
7
  from google.protobuf import descriptor as _descriptor
8
8
  from google.protobuf import descriptor_pool as _descriptor_pool
@@ -12,7 +12,7 @@ from google.protobuf.internal import builder as _builder
12
12
  _runtime_version.ValidateProtobufRuntimeVersion(
13
13
  _runtime_version.Domain.PUBLIC,
14
14
  6,
15
- 31,
15
+ 32,
16
16
  1,
17
17
  '',
18
18
  'google/protobuf/source_context.proto'
@@ -2,7 +2,7 @@
2
2
  # Generated by the protocol buffer compiler. DO NOT EDIT!
3
3
  # NO CHECKED-IN PROTOBUF GENCODE
4
4
  # source: google/protobuf/struct.proto
5
- # Protobuf Python Version: 6.31.1
5
+ # Protobuf Python Version: 6.32.1
6
6
  """Generated protocol buffer code."""
7
7
  from google.protobuf import descriptor as _descriptor
8
8
  from google.protobuf import descriptor_pool as _descriptor_pool
@@ -12,7 +12,7 @@ from google.protobuf.internal import builder as _builder
12
12
  _runtime_version.ValidateProtobufRuntimeVersion(
13
13
  _runtime_version.Domain.PUBLIC,
14
14
  6,
15
- 31,
15
+ 32,
16
16
  1,
17
17
  '',
18
18
  'google/protobuf/struct.proto'
@@ -25,6 +25,7 @@ import encodings.unicode_escape # pylint: disable=unused-import
25
25
  import io
26
26
  import math
27
27
  import re
28
+ import warnings
28
29
 
29
30
  from google.protobuf.internal import decoder
30
31
  from google.protobuf.internal import type_checkers
@@ -126,13 +127,13 @@ def MessageToString(
126
127
  will be printed at the end of the message and their relative order is
127
128
  determined by the extension number. By default, use the field number
128
129
  order.
129
- float_format (str): If set, use this to specify float field formatting
130
- (per the "Format Specification Mini-Language"); otherwise, shortest float
131
- that has same value in wire will be printed. Also affect double field
132
- if double_format is not set but float_format is set.
133
- double_format (str): If set, use this to specify double field formatting
134
- (per the "Format Specification Mini-Language"); if it is not set but
135
- float_format is set, use float_format. Otherwise, use ``str()``
130
+ float_format (str): Deprecated. If set, use this to specify float field
131
+ formatting (per the "Format Specification Mini-Language"); otherwise,
132
+ shortest float that has same value in wire will be printed. Also affect
133
+ double field if double_format is not set but float_format is set.
134
+ double_format (str): Deprecated. If set, use this to specify double field
135
+ formatting (per the "Format Specification Mini-Language"); if it is not
136
+ set but float_format is set, use float_format. Otherwise, use ``str()``
136
137
  use_field_number: If True, print field numbers instead of names.
137
138
  descriptor_pool (DescriptorPool): Descriptor pool used to resolve Any types.
138
139
  indent (int): The initial indent level, in terms of spaces, for pretty
@@ -391,13 +392,13 @@ class _Printer(object):
391
392
  use_index_order: If True, print fields of a proto message using the order
392
393
  defined in source code instead of the field number. By default, use the
393
394
  field number order.
394
- float_format: If set, use this to specify float field formatting
395
- (per the "Format Specification Mini-Language"); otherwise, shortest
396
- float that has same value in wire will be printed. Also affect double
397
- field if double_format is not set but float_format is set.
398
- double_format: If set, use this to specify double field formatting
399
- (per the "Format Specification Mini-Language"); if it is not set but
400
- float_format is set, use float_format. Otherwise, str() is used.
395
+ float_format: Deprecated. If set, use this to specify float field
396
+ formatting (per the "Format Specification Mini-Language"); otherwise,
397
+ shortest float that has same value in wire will be printed. Also affect
398
+ double field if double_format is not set but float_format is set.
399
+ double_format: Deprecated. If set, use this to specify double field
400
+ formatting (per the "Format Specification Mini-Language"); if it is not
401
+ set but float_format is set, use float_format. Otherwise, str() is used.
401
402
  use_field_number: If True, print field numbers instead of names.
402
403
  descriptor_pool: A DescriptorPool used to resolve Any types.
403
404
  message_formatter: A function(message, indent, as_one_line): unicode|None
@@ -416,6 +417,10 @@ class _Printer(object):
416
417
  self.use_index_order = use_index_order
417
418
  self.float_format = float_format
418
419
  if double_format is not None:
420
+ warnings.warn(
421
+ 'double_format is deprecated for text_format. This will '
422
+ 'turn into error in 7.34.0, please remove it before that.'
423
+ )
419
424
  self.double_format = double_format
420
425
  else:
421
426
  self.double_format = float_format
@@ -477,7 +482,7 @@ class _Printer(object):
477
482
  # TODO: refactor and optimize if this becomes an issue.
478
483
  entry_submsg = value.GetEntryClass()(key=key, value=value[key])
479
484
  self.PrintField(field, entry_submsg)
480
- elif field.label == descriptor.FieldDescriptor.LABEL_REPEATED:
485
+ elif field.is_repeated:
481
486
  if (self.use_short_repeated_primitives
482
487
  and field.cpp_type != descriptor.FieldDescriptor.CPPTYPE_MESSAGE
483
488
  and field.cpp_type != descriptor.FieldDescriptor.CPPTYPE_STRING):
@@ -557,7 +562,8 @@ class _Printer(object):
557
562
  out.write('[')
558
563
  if (field.containing_type.GetOptions().message_set_wire_format and
559
564
  field.type == descriptor.FieldDescriptor.TYPE_MESSAGE and
560
- field.label == descriptor.FieldDescriptor.LABEL_OPTIONAL):
565
+ not field.is_required and
566
+ not field.is_repeated):
561
567
  out.write(field.message_type.full_name)
562
568
  else:
563
569
  out.write(field.full_name)
@@ -651,6 +657,11 @@ class _Printer(object):
651
657
  out.write('false')
652
658
  elif field.cpp_type == descriptor.FieldDescriptor.CPPTYPE_FLOAT:
653
659
  if self.float_format is not None:
660
+ warnings.warn(
661
+ 'float_format is deprecated for text_format. This '
662
+ 'will turn into error in 7.34.0, please remove it '
663
+ 'before that.'
664
+ )
654
665
  out.write('{1:{0}}'.format(self.float_format, value))
655
666
  else:
656
667
  if math.isnan(value):
@@ -998,7 +1009,7 @@ class _Parser(object):
998
1009
  field.full_name)
999
1010
  merger = self._MergeScalarField
1000
1011
 
1001
- if (field.label == descriptor.FieldDescriptor.LABEL_REPEATED and
1012
+ if (field.is_repeated and
1002
1013
  tokenizer.TryConsume('[')):
1003
1014
  # Short repeated format, e.g. "foo: [1, 2, 3]"
1004
1015
  if not tokenizer.TryConsume(']'):
@@ -1061,7 +1072,7 @@ class _Parser(object):
1061
1072
  tokenizer.Consume('{')
1062
1073
  end_token = '}'
1063
1074
 
1064
- if field.label == descriptor.FieldDescriptor.LABEL_REPEATED:
1075
+ if field.is_repeated:
1065
1076
  if field.is_extension:
1066
1077
  sub_message = message.Extensions[field].add()
1067
1078
  elif is_map_entry:
@@ -1143,7 +1154,7 @@ class _Parser(object):
1143
1154
  else:
1144
1155
  raise RuntimeError('Unknown field type %d' % field.type)
1145
1156
 
1146
- if field.label == descriptor.FieldDescriptor.LABEL_REPEATED:
1157
+ if field.is_repeated:
1147
1158
  if field.is_extension:
1148
1159
  message.Extensions[field].append(value)
1149
1160
  else:
@@ -2,7 +2,7 @@
2
2
  # Generated by the protocol buffer compiler. DO NOT EDIT!
3
3
  # NO CHECKED-IN PROTOBUF GENCODE
4
4
  # source: google/protobuf/timestamp.proto
5
- # Protobuf Python Version: 6.31.1
5
+ # Protobuf Python Version: 6.32.1
6
6
  """Generated protocol buffer code."""
7
7
  from google.protobuf import descriptor as _descriptor
8
8
  from google.protobuf import descriptor_pool as _descriptor_pool
@@ -12,7 +12,7 @@ from google.protobuf.internal import builder as _builder
12
12
  _runtime_version.ValidateProtobufRuntimeVersion(
13
13
  _runtime_version.Domain.PUBLIC,
14
14
  6,
15
- 31,
15
+ 32,
16
16
  1,
17
17
  '',
18
18
  'google/protobuf/timestamp.proto'
@@ -2,7 +2,7 @@
2
2
  # Generated by the protocol buffer compiler. DO NOT EDIT!
3
3
  # NO CHECKED-IN PROTOBUF GENCODE
4
4
  # source: google/protobuf/type.proto
5
- # Protobuf Python Version: 6.31.1
5
+ # Protobuf Python Version: 6.32.1
6
6
  """Generated protocol buffer code."""
7
7
  from google.protobuf import descriptor as _descriptor
8
8
  from google.protobuf import descriptor_pool as _descriptor_pool
@@ -12,7 +12,7 @@ from google.protobuf.internal import builder as _builder
12
12
  _runtime_version.ValidateProtobufRuntimeVersion(
13
13
  _runtime_version.Domain.PUBLIC,
14
14
  6,
15
- 31,
15
+ 32,
16
16
  1,
17
17
  '',
18
18
  'google/protobuf/type.proto'
@@ -2,7 +2,7 @@
2
2
  # Generated by the protocol buffer compiler. DO NOT EDIT!
3
3
  # NO CHECKED-IN PROTOBUF GENCODE
4
4
  # source: google/protobuf/wrappers.proto
5
- # Protobuf Python Version: 6.31.1
5
+ # Protobuf Python Version: 6.32.1
6
6
  """Generated protocol buffer code."""
7
7
  from google.protobuf import descriptor as _descriptor
8
8
  from google.protobuf import descriptor_pool as _descriptor_pool
@@ -12,7 +12,7 @@ from google.protobuf.internal import builder as _builder
12
12
  _runtime_version.ValidateProtobufRuntimeVersion(
13
13
  _runtime_version.Domain.PUBLIC,
14
14
  6,
15
- 31,
15
+ 32,
16
16
  1,
17
17
  '',
18
18
  'google/protobuf/wrappers.proto'
@@ -8,7 +8,7 @@
8
8
  # License: BSD
9
9
  #-----------------------------------------------------------------
10
10
  __all__ = ['c_lexer', 'c_parser', 'c_ast']
11
- __version__ = '2.22'
11
+ __version__ = '2.23'
12
12
 
13
13
  import io
14
14
  from subprocess import check_output
@@ -133,7 +133,7 @@ class CGenerator(object):
133
133
  def _visit_expr(self, n):
134
134
  if isinstance(n, c_ast.InitList):
135
135
  return '{' + self.visit(n) + '}'
136
- elif isinstance(n, c_ast.ExprList):
136
+ elif isinstance(n, (c_ast.ExprList, c_ast.Compound)):
137
137
  return '(' + self.visit(n) + ')'
138
138
  else:
139
139
  return self.visit(n)
@@ -209,6 +209,10 @@ class CLexer(object):
209
209
 
210
210
  bad_octal_constant = '0[0-7]*[89]'
211
211
 
212
+ # comments are not supported
213
+ unsupported_c_style_comment = r'\/\*'
214
+ unsupported_cxx_style_comment = r'\/\/'
215
+
212
216
  # character constants (K&R2: A.2.5.2)
213
217
  # Note: a-zA-Z and '.-~^_!=&;,' are allowed as escape chars to support #line
214
218
  # directives with Windows paths as filenames (..\..\dir\file)
@@ -475,6 +479,16 @@ class CLexer(object):
475
479
  msg = "Invalid octal constant"
476
480
  self._error(msg, t)
477
481
 
482
+ @TOKEN(unsupported_c_style_comment)
483
+ def t_UNSUPPORTED_C_STYLE_COMMENT(self, t):
484
+ msg = "Comments are not supported, see https://github.com/eliben/pycparser#3using."
485
+ self._error(msg, t)
486
+
487
+ @TOKEN(unsupported_cxx_style_comment)
488
+ def t_UNSUPPORTED_CXX_STYLE_COMMENT(self, t):
489
+ msg = "Comments are not supported, see https://github.com/eliben/pycparser#3using."
490
+ self._error(msg, t)
491
+
478
492
  @TOKEN(octal_constant)
479
493
  def t_INT_CONST_OCT(self, t):
480
494
  return t