protoc-gen-validate
protoc-gen-validate copied to clipboard
Python 3.13 support
When using Python 3.13, following exception is raised:
Traceback (most recent call last):
File "/Users/gnuletik/Library/Caches/pypoetry/virtualenvs/myapp-sb5BZtsM-py3.13/lib/python3.13/site-packages/protoc_gen_validate/validator.py", line 219, in _validate_all_inner
return generate_validate_all
^^^^^^^^^^^^^^^^^^^^^
NameError: name 'generate_validate_all' is not defined
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/Users/gnuletik/Library/Caches/pypoetry/virtualenvs/myapp-sb5BZtsM-py3.13/lib/python3.13/site-packages/mylib/run.py", line 46, in run
exit_code = run_exit(
handler,
...<3 lines>...
logger,
)
File "/Users/gnuletik/Library/Caches/pypoetry/virtualenvs/myapp-sb5BZtsM-py3.13/lib/python3.13/site-packages/mylib/run.py", line 108, in run_exit
validate_all(init_resp)
~~~~~~~~~~~~^^^^^^^^^^^
File "/Users/gnuletik/Library/Caches/pypoetry/virtualenvs/myapp-sb5BZtsM-py3.13/lib/python3.13/site-packages/protoc_gen_validate/validator.py", line 230, in validate_all
err = _validate_all(proto_message)
File "/Users/gnuletik/Library/Caches/pypoetry/virtualenvs/myapp-sb5BZtsM-py3.13/lib/python3.13/site-packages/protoc_gen_validate/validator.py", line 225, in _validate_all
return _validate_all_inner(ValidatingMessage(proto_message))(proto_message)
~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/gnuletik/Library/Caches/pypoetry/virtualenvs/myapp-sb5BZtsM-py3.13/lib/python3.13/site-packages/protoc_gen_validate/validator.py", line 221, in _validate_all_inner
return locals()['generate_validate_all']
~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^
KeyError: 'generate_validate_all'
Similarly running into
@lru_cache()
def _validate_inner(proto_message: Message):
func = file_template(proto_message)
global printer
printer += func + "\n"
exec(func)
try:
return generate_validate
except NameError:
> return locals()['generate_validate']
E KeyError: 'generate_validate'
I imagine this is related: https://docs.python.org/3/whatsnew/3.13.html#pep667-porting-notes-py
Are there any updates about this?
Is there a workaround for this given it's been a few months since the issue was reported?