Skip to content

Commit

Permalink
Internal changes.
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 627188953
  • Loading branch information
protobuf-github-bot authored and copybara-github committed Apr 22, 2024
1 parent eaee04d commit 1a7aa2c
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions python/google/protobuf/runtime_version.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,10 @@ class VersionError(Exception):
"""Exception class for version violation."""


def _ReportVersionError(msg):
raise VersionError(msg)


def ValidateProtobufRuntimeVersion(
gen_domain, gen_major, gen_minor, gen_patch, gen_suffix, location
):
Expand Down Expand Up @@ -76,28 +80,28 @@ def ValidateProtobufRuntimeVersion(
)

if gen_domain != DOMAIN:
raise VersionError(
_ReportVersionError(
'Detected mismatched Protobuf Gencode/Runtime domains when loading'
f' {location}: gencode {gen_domain.name} runtime {DOMAIN.name}.'
' Cross-domain usage of Protobuf is not supported.'
)

if gen_major != MAJOR:
raise VersionError(
_ReportVersionError(
'Detected mismatched Protobuf Gencode/Runtime major versions when'
f' loading {location}: gencode {gen_version} runtime {version}.'
f' Same major version is required. {error_prompt}'
)

if MINOR < gen_minor or (MINOR == gen_minor and PATCH < gen_patch):
raise VersionError(
_ReportVersionError(
'Detected incompatible Protobuf Gencode/Runtime versions when loading'
f' {location}: gencode {gen_version} runtime {version}. Runtime version'
f' cannot be older than the linked gencode version. {error_prompt}'
)

if gen_suffix != SUFFIX:
raise VersionError(
_ReportVersionError(
'Detected mismatched Protobuf Gencode/Runtime version suffixes when'
f' loading {location}: gencode {gen_version} runtime {version}.'
f' Version suffixes must be the same. {error_prompt}'
Expand Down

0 comments on commit 1a7aa2c

Please sign in to comment.