Skip to content

Commit 61f4eea

Browse files
Protocol Buffer TeamLogofile
authored andcommitted
Project import generated by Copybara.
PiperOrigin-RevId: 598824953 Change-Id: I0478cf318232b10bf71bf0c7f05ec426c1aa232e
1 parent d2c52f6 commit 61f4eea

File tree

8 files changed

+330
-81
lines changed

8 files changed

+330
-81
lines changed

content/editions/overview.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -216,8 +216,8 @@ apply when no setting is made within the same scope (field, enum value). Any
216216
features not explicitly set conform to the behavior defined in the edition
217217
version used for the .proto file.
218218

219-
The following code sample shows some features being set at the file, message,
220-
and enum level. The settings are in the highlighted lines:
219+
The following code sample shows some features being set at the file, field, and
220+
enum level. The settings are in the highlighted lines:
221221

222222
```proto {highlight="lines:3,7,16"}
223223
edition = "2023";

content/news/2024-01-05.md

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
+++
2+
title = "Changes announced January 5, 2024"
3+
linkTitle = "January 5, 2024"
4+
toc_hide = "true"
5+
description = "Changes announced for Protocol Buffers on January 5, 2024."
6+
type = "docs"
7+
+++
8+
9+
This topic covers breaking changes in Ruby and Python in the 26.x line.
10+
11+
## Ruby Breaking Changes
12+
13+
### Freeze Is Now Recursive in Ruby
14+
15+
Starting in the 26.x line, when freeze is applied it will be applied
16+
recursively, affecting all sub-messages, maps, and repeated fields.
17+
18+
## Python Breaking Changes
19+
20+
### Removing Deprecated APIs
21+
22+
In the 26.x release, the following deprecated APIs will be removed:
23+
24+
* [`AddFileDescriptor`](https://googleapis.dev/python/protobuf/latest/google/protobuf/descriptor_pool.html#google.protobuf.descriptor_pool.DescriptorPool.AddFileDescriptor)
25+
* [`AddDescriptor`](https://googleapis.dev/python/protobuf/latest/google/protobuf/descriptor_pool.html#google.protobuf.descriptor_pool.DescriptorPool.AddDescriptor)
26+
* [`AddEnumDescriptor`](https://googleapis.dev/python/protobuf/latest/google/protobuf/descriptor_pool.html#google.protobuf.descriptor_pool.DescriptorPool.AddEnumDescriptor)
27+
* [`AddExtensionDescriptor`](https://googleapis.dev/python/protobuf/latest/google/protobuf/descriptor_pool.html#google.protobuf.descriptor_pool.DescriptorPool.AddExtensionDescriptor)
28+
* [`AddServiceDescriptor`](https://googleapis.dev/python/protobuf/latest/google/protobuf/descriptor_pool.html#google.protobuf.descriptor_pool.DescriptorPool.AddServiceDescriptor)
29+
30+
### Rejecting Extend Repeated Field with None Iterable
31+
32+
Starting in the 26.x release, extending repeated fields with a `None` iterable
33+
will be rejected (it will raise a `TypeError`). For example,
34+
`m.repeated_int32.extend(None)` will be rejected.
35+
36+
### Removing RegisterExtension in message class
37+
38+
Starting in the 26.x release,
39+
[`RegisterExtension`](https://googleapis.dev/python/protobuf/latest/google/protobuf/descriptor_pb2.html#google.protobuf.descriptor_pb2.DescriptorProto.ExtensionRange.RegisterExtension)
40+
will be removed. You can access extensions in Python using the `Extensions`
41+
property on message objects.
42+
43+
This affects both pure Python and the C++ implementation of Python, but not upb
44+
Python.

content/news/_index.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ no_list = "true"
99
News topics provide information about past events and changes with Protocol
1010
Buffers, and plans for upcoming changes.
1111

12+
* [January 5, 2024](/news/2024-01-05) - Breaking
13+
changes in the 26.x line for Ruby and Python
1214
* [December 27, 2023](/news/2023-12-27) - Breaking
1315
changes in the 26.x line for Ruby, PHP, Python, and upb
1416
* [December 13, 2023](/news/2023-12-13) - Breaking

content/programming-guides/proto2.md

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -863,9 +863,9 @@ the following rules:
863863
* For `string`, `bytes`, and message fields, `optional` is compatible with
864864
`repeated`. Given serialized data of a repeated field as input, clients that
865865
expect this field to be `optional` will take the last input value if it's a
866-
primitive type field or merge all input elements if it's a message type
867-
field. Note that this is **not** generally safe for numeric types, including
868-
bools and enums. Repeated fields of numeric types can be serialized in the
866+
scalar type field or merge all input elements if it's a message type field.
867+
Note that this is **not** generally safe for numeric types, including bools
868+
and enums. Repeated fields of numeric types can be serialized in the
869869
[packed](/programming-guides/encoding#packed) format,
870870
which will not be parsed correctly when an `optional` field is expected.
871871
* Changing a default value is generally OK, as long as you remember that
@@ -998,7 +998,9 @@ message UserContent {
998998
full_name: ".kittens.kitten_videos",
999999
type: ".kittens.Video",
10001000
repeated: true
1001-
}
1001+
},
1002+
// Ensures all field numbers in this extension range are declarations.
1003+
verification = DECLARATION
10021004
];
10031005
}
10041006
```
@@ -1777,7 +1779,7 @@ value.
17771779
<td>Wrapper types</td>
17781780
<td>various types</td>
17791781
<td><code>2, "2", "foo", true, "true", null, 0, ...</code></td>
1780-
<td>Wrappers use the same representation in JSON as the wrapped primitive
1782+
<td>Wrappers use the same representation in JSON as the wrapped scalar
17811783
type, except that <code>null</code> is allowed and preserved during data
17821784
conversion and transfer.
17831785
</td>
@@ -2016,6 +2018,13 @@ enum Data {
20162018
}
20172019
```
20182020

2021+
The C++ code to read the `string_name` option might look something like this:
2022+
2023+
```cpp
2024+
const absl::string_view foo = proto2::GetEnumDescriptor<Data>()
2025+
->FindValueByName("DATA_DISPLAY")->options().GetExtension(string_name);
2026+
```
2027+
20192028
See [Custom Options](#customoptions) to see how to apply custom options to enum
20202029
values and to fields.
20212030

content/reference/java/java-proto-names.md

Lines changed: 0 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -70,51 +70,3 @@ will be placed in a separate `.java` file. This makes it much easier to move
7070
messages from one `.proto` file to another. There is also an outer Java class
7171
generated for the `.proto` file itself. (The legend above explains how this
7272
outer class name is generated.)
73-
74-
## Mutable API Message Names { #mutable-api-message-names }
75-
76-
The names for protos generated by the Java mutable API are outlined in the
77-
following sections.
78-
79-
{{% alert title="Note" color="note" %}}
80-
Java mutable API names will be generated only when the
81-
`java_mutable_proto_library` target is built.
82-
{{% /alert %}}
83-
84-
{{% alert title="Warning" color="warning" %}} Java
85-
proto1 is deprecated. go/java-proto1-deprecation describes when proto1 API is
86-
still generated. Users should avoid proto1 and use proto2 api.
87-
{{% /alert %}}
88-
89-
### Proto2 Message Names { #proto2-message-names }
90-
91-
java_api_version | (java_multiple_files, java_multiple_files_mutable_package) | java_package | java_outer_classname | java_alt_api_package | Proto2 Mutable message name
92-
:--------------: | :--------------------------------------------------------: | ------------ | -------------------- | -------------------- | ---------------------------
93-
\- | (true, defined) | - | - | - | `$java_multiple_files_mutable_package.$message`
94-
1 | !(true, defined) | Undefined | Undefined | Undefined | `com.google.protos.$package.proto2api.Mutable$Filename.$message`
95-
1 | !(true, defined) | Undefined | Undefined | Defined | `$java_alt_api_package.Mutable$Filename.$message`
96-
1 | !(true, defined) | Undefined | Defined | Undefined | `com.google.protos.$package.proto2api.Mutable$java_outer_classname.$message`
97-
1 | !(true, defined) | Undefined | Defined | Defined | `$java_alt_api_package.Mutable$java_outer_classname.$message`
98-
1 | !(true, defined) | Defined | Undefined | Undefined | `$java_package.proto2api.Mutable$Filename.$message`
99-
1 | !(true, defined) | Defined | Undefined | Defined | `$java_alt_api_package.Mutable$Filename.$message`
100-
1 | !(true, defined) | Defined | Defined | Undefined | `$java_package.proto2api.Mutable$java_outer_classname.$message`
101-
1 | !(true, defined) | Defined | Defined | Defined | `$java_alt_api_package.Mutable$java_outer_classname.$message`
102-
2 | !(true, defined) | Undefined | Undefined | - | `com.google.protos.$package.Mutable$Filename.$message`
103-
2 | !(true, defined) | Undefined | Defined | - | `com.google.protos.$package..Mutable$java_outer_classname.$message`
104-
2 | !(true, defined) | Defined | Undefined | - | `$java_package.Mutable$Filename.$message`
105-
2 | !(true, defined) | Defined | Defined | - | `$java_package.Mutable$java_outer_classname.$message`
106-
107-
**Legend**
108-
109-
* \- means either setting or not setting the option will not change the
110-
generated full message name.
111-
* `$message` is the actual name of the proto message.
112-
* All other `$names` are the values of the corresponding proto2 file options
113-
defined in the proto file.
114-
115-
### Proto1 Message Names { #proto1-message-names }
116-
117-
{{% alert title="Warning" color="warning" %}} Java
118-
proto1 is deprecated. go/java-proto1-deprecation describes when proto1 API is
119-
still generated and describes its message names. Users should avoid proto1 and
120-
use the proto2 api. {{% /alert %}}

content/reference/protobuf/proto2-spec.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -53,16 +53,16 @@ groupName = capitalLetter { letter | decimalDigit | "_" }
5353

5454
```
5555
intLit = decimalLit | octalLit | hexLit
56-
decimalLit = ( "1" ... "9" ) { decimalDigit }
57-
octalLit = "0" { octalDigit }
58-
hexLit = "0" ( "x" | "X" ) hexDigit { hexDigit }
56+
decimalLit = [-] ( "1" ... "9" ) { decimalDigit }
57+
octalLit = [-] "0" { octalDigit }
58+
hexLit = [-] "0" ( "x" | "X" ) hexDigit { hexDigit }
5959
```
6060

6161
### Floating-point Literals
6262

6363
```
64-
floatLit = ( decimals "." [ decimals ] [ exponent ] | decimals exponent | "."decimals [ exponent ] ) | "inf" | "nan"
65-
decimals = decimalDigit { decimalDigit }
64+
floatLit = [-] ( decimals "." [ decimals ] [ exponent ] | decimals exponent | "."decimals [ exponent ] ) | "inf" | "nan"
65+
decimals = [-] decimalDigit { decimalDigit }
6666
exponent = ( "e" | "E" ) [ "+" | "-" ] decimals
6767
```
6868

content/reference/protobuf/proto3-spec.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -50,16 +50,16 @@ enumType = [ "." ] { ident "." } enumName
5050

5151
```
5252
intLit = decimalLit | octalLit | hexLit
53-
decimalLit = ( "1" ... "9" ) { decimalDigit }
54-
octalLit = "0" { octalDigit }
55-
hexLit = "0" ( "x" | "X" ) hexDigit { hexDigit }
53+
decimalLit = [-] ( "1" ... "9" ) { decimalDigit }
54+
octalLit = [-] "0" { octalDigit }
55+
hexLit = [-] "0" ( "x" | "X" ) hexDigit { hexDigit }
5656
```
5757

5858
### Floating-point Literals
5959

6060
```
61-
floatLit = ( decimals "." [ decimals ] [ exponent ] | decimals exponent | "."decimals [ exponent ] ) | "inf" | "nan"
62-
decimals = decimalDigit { decimalDigit }
61+
floatLit = [-] ( decimals "." [ decimals ] [ exponent ] | decimals exponent | "."decimals [ exponent ] ) | "inf" | "nan"
62+
decimals = [-] decimalDigit { decimalDigit }
6363
exponent = ( "e" | "E" ) [ "+" | "-" ] decimals
6464
```
6565

0 commit comments

Comments
 (0)