Skip to content

Commit

Permalink
Merge pull request #7583 from haberman/sync-stage
Browse files Browse the repository at this point in the history
Integrate from Piper for C++, Java, and Python
  • Loading branch information
haberman committed Jun 2, 2020
2 parents e492e5a + 8d93bc1 commit c0b79c5
Show file tree
Hide file tree
Showing 43 changed files with 387 additions and 2,172 deletions.
5 changes: 5 additions & 0 deletions CHANGES.txt
@@ -1,10 +1,15 @@
Unreleased Changes

C++:
* Removed deprecated unsafe arena string accessors
* Enabled heterogeneous lookup for std::string keys in maps.
* Improved the randomness of map ordering.
* Removed implicit conversion from StringPiece to std::string
* Fix use-after-destroy bug when the Map is allocated in the arena.
* Improved the randomness of proto map ordering

Python:
* Reject lowercase t for Timestamp json format. Fixes a conformance test.
* Improved the error message when AttributeError is returned from __getattr__
in EnumTypeWrapper.

Expand Down
20 changes: 0 additions & 20 deletions cmake/README.md
Expand Up @@ -343,23 +343,3 @@ unique, so there should be no problem with this, but MSVC prints warning
nevertheless. So, we disable it. Unfortunately, this warning will also be
produced when compiling code which merely uses protocol buffers, meaning you
may have to disable it in your code too.

Cross-compiling
===============

When cross-compiling you will need to disable building the tests which are ON
by default. You can do so by specifying the following flags when configuring
your build:

-Dprotobuf_BUILD_TESTS=OFF

Alternatively you can compile (or download) 'protoc' for your host machine
prior to configuring your target build. To specify an existing 'protoc' binary
for your build, specify the following flag:

-DWITH_PROTOC=<path to your protoc binary>

You can also save compilation time by disabling building 'protoc' for your
target build:

-Dprotobuf_BUILD_PROTOC_BINARIES=OFF
1 change: 0 additions & 1 deletion conformance/failure_list_python.txt
Expand Up @@ -28,4 +28,3 @@ Required.Proto3.JsonInput.DoubleFieldTooSmall
Required.Proto3.JsonInput.FloatFieldTooLarge
Required.Proto3.JsonInput.FloatFieldTooSmall
Required.Proto3.JsonInput.RepeatedFieldWrongElementTypeExpectingIntegersGotBool
Required.Proto3.JsonInput.TimestampJsonInputLowercaseT
1 change: 0 additions & 1 deletion conformance/failure_list_python_cpp.txt
Expand Up @@ -19,4 +19,3 @@ Required.Proto3.JsonInput.DoubleFieldTooSmall
Required.Proto3.JsonInput.FloatFieldTooLarge
Required.Proto3.JsonInput.FloatFieldTooSmall
Required.Proto3.JsonInput.RepeatedFieldWrongElementTypeExpectingIntegersGotBool
Required.Proto3.JsonInput.TimestampJsonInputLowercaseT
6 changes: 3 additions & 3 deletions js/message.js
Expand Up @@ -417,7 +417,7 @@ jspb.Message.EMPTY_LIST_SENTINEL_ = goog.DEBUG && Object.freeze ?
*/
jspb.Message.isArray_ = function(o) {
return jspb.Message.ASSUME_LOCAL_ARRAYS ? o instanceof Array :
goog.isArray(o);
Array.isArray(o);
};

/**
Expand Down Expand Up @@ -1433,7 +1433,7 @@ jspb.Message.prototype.syncMapFields_ = function() {
if (this.wrappers_) {
for (var fieldNumber in this.wrappers_) {
var val = this.wrappers_[fieldNumber];
if (goog.isArray(val)) {
if (Array.isArray(val)) {
for (var i = 0; i < val.length; i++) {
if (val[i]) {
val[i].toArray();
Expand Down Expand Up @@ -1823,7 +1823,7 @@ jspb.Message.copyInto = function(fromMessage, toMessage) {
*/
jspb.Message.clone_ = function(obj) {
var o;
if (goog.isArray(obj)) {
if (Array.isArray(obj)) {
// Allocate array of correct size.
var clonedArray = new Array(obj.length);
// Use array iteration where possible because it is faster than for-in.
Expand Down
11 changes: 9 additions & 2 deletions python/google/protobuf/internal/json_format_test.py
Expand Up @@ -269,7 +269,6 @@ def testExtensionSerializationDictMatchesProto3SpecMore(self):
}
self.assertEqual(expected_dict, message_dict)


def testExtensionSerializationJsonMatchesProto3Spec(self):
"""See go/proto3-json-spec for spec.
"""
Expand All @@ -295,7 +294,6 @@ def testExtensionSerializationJsonMatchesProto3Spec(self):
'}}') % (ext1_text, ext2_text)
self.assertEqual(json.loads(golden_text), json.loads(message_text))


def testJsonEscapeString(self):
message = json_format_proto3_pb2.TestMessage()
if sys.version_info[0] < 3:
Expand Down Expand Up @@ -1036,6 +1034,15 @@ def testInvalidTimestamp(self):
OverflowError,
'date value out of range',
json_format.MessageToJson, message)
# Lower case t does not accept.
text = '{"value": "0001-01-01t00:00:00Z"}'
with self.assertRaises(json_format.ParseError) as e:
json_format.Parse(text, message)
self.assertEqual(
'Failed to parse value field: '
'time data \'0001-01-01t00:00:00\' does not match format '
'\'%Y-%m-%dT%H:%M:%S\', lowercase \'t\' is not accepted.',
str(e.exception))

def testInvalidOneof(self):
message = json_format_proto3_pb2.TestOneof()
Expand Down
4 changes: 4 additions & 0 deletions python/google/protobuf/internal/well_known_types.py
Expand Up @@ -160,6 +160,10 @@ def FromJsonString(self, value):
else:
second_value = time_value[:point_position]
nano_value = time_value[point_position + 1:]
if 't' in second_value:
raise ValueError(
'time data \'{0}\' does not match format \'%Y-%m-%dT%H:%M:%S\', '
'lowercase \'t\' is not accepted'.format(second_value))
date_object = datetime.strptime(second_value, _TIMESTAMPFOMAT)
td = date_object - datetime(1970, 1, 1)
seconds = td.seconds + td.days * _SECONDS_PER_DAY
Expand Down
56 changes: 0 additions & 56 deletions src/google/protobuf/any.pb.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit c0b79c5

Please sign in to comment.