bufbuild / protoc-gen-validate

Protocol Buffer Validation - Being replaced by github.com/bufbuild/protovalidate
https://github.com/bufbuild/protovalidate
Apache License 2.0
3.81k stars 580 forks source link

Python 3.13 support #1173

Open gnuletik opened 1 month ago

gnuletik commented 1 month ago

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'
edgarrmondragon commented 1 month ago

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'
stefanvanburen commented 1 month ago

I imagine this is related: https://docs.python.org/3/whatsnew/3.13.html#pep667-porting-notes-py

edgarrmondragon commented 2 weeks ago

Are there any updates about this?