Sync from Piper @443569271
PROTOBUF_SYNC_PIPER
diff --git a/CHANGES.txt b/CHANGES.txt
index 0c0f63b..8d7f98a 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -1,3 +1,8 @@
+Unreleased Changes (C++/Java/Python/PHP/Objective-C/C#/Ruby/JavaScript)
+
+ Compiler
+ * Require package names to be less than 512 bytes in length
+
2022-04-05 version 3.20.1 (C++/Java/Python/PHP/Objective-C/C#/Ruby/JavaScript)
PHP
diff --git a/protobuf_deps.bzl b/protobuf_deps.bzl
index de5d536..38d13ff 100644
--- a/protobuf_deps.bzl
+++ b/protobuf_deps.bzl
@@ -30,10 +30,10 @@
if not native.existing_rule("com_google_absl"):
# Abseil LTS from November 2021
http_archive(
- name = "com_google_absl",
- sha256 = "b4e20d9e752a75c10636675691b1e9c2698e0764cb404987d0ffa77223041c19",
- urls = ["https://github.com/abseil/abseil-cpp/archive/215105818dfde3174fe799600bb0f3cae233d0bf.zip"],
- strip_prefix = "abseil-cpp-215105818dfde3174fe799600bb0f3cae233d0bf",
+ name = "com_google_absl",
+ sha256 = "b4e20d9e752a75c10636675691b1e9c2698e0764cb404987d0ffa77223041c19",
+ urls = ["https://github.com/abseil/abseil-cpp/archive/215105818dfde3174fe799600bb0f3cae233d0bf.zip"],
+ strip_prefix = "abseil-cpp-215105818dfde3174fe799600bb0f3cae233d0bf",
)
if not native.existing_rule("zlib"):
@@ -88,10 +88,10 @@
http_archive(
name = "rules_pkg",
urls = [
- "https://mirror.bazel.build/github.com/bazelbuild/rules_pkg/releases/download/0.5.1/rules_pkg-0.5.1.tar.gz",
- "https://github.com/bazelbuild/rules_pkg/releases/download/0.5.1/rules_pkg-0.5.1.tar.gz",
+ "https://mirror.bazel.build/github.com/bazelbuild/rules_pkg/releases/download/0.7.0/rules_pkg-0.7.0.tar.gz",
+ "https://github.com/bazelbuild/rules_pkg/releases/download/0.7.0/rules_pkg-0.7.0.tar.gz",
],
- sha256 = "a89e203d3cf264e564fcb96b6e06dd70bc0557356eb48400ce4b5d97c2c3720d",
+ sha256 = "8a298e832762eda1830597d64fe7db58178aa84cd5926d76d5b744d6558941c2",
)
if not native.existing_rule("io_bazel_rules_kotlin"):
diff --git a/python/google/protobuf/internal/api_implementation.py b/python/google/protobuf/internal/api_implementation.py
index 96dd096..7458648 100644
--- a/python/google/protobuf/internal/api_implementation.py
+++ b/python/google/protobuf/internal/api_implementation.py
@@ -59,10 +59,25 @@
pass # Unspecified by compiler flags.
+def _CanImport(mod_name):
+ try:
+ mod = importlib.import_module(mod_name)
+ # Work around a known issue in the classic bootstrap .par import hook.
+ if not mod:
+ raise ImportError(mod_name + ' import succeeded but was None')
+ return True
+ except ImportError:
+ return False
if _implementation_type is None:
- _implementation_type = 'python'
+ if _CanImport('google._upb._message'):
+ _implementation_type = 'upb'
+ elif _CanImport('google.protobuf.pyext._message'):
+ _implementation_type = 'cpp'
+ else:
+ _implementation_type = 'python'
+
# This environment variable can be used to switch to a certain implementation
# of the Python API, overriding the compile-time constants in the
@@ -98,7 +113,7 @@
if _implementation_type == 'upb':
try:
# pylint: disable=g-import-not-at-top
- from google.protobuf.pyext import _upb_message as _message
+ from google._upb import _message
_c_module = _message
del _message
except ImportError: