Commit graph

30 commits

Author SHA1 Message Date
Protobuf Team Bot
ad6a7e8b64 Check return values and handle alloc failures in python
PiperOrigin-RevId: 955022274
2026-07-27 22:11:16 -07:00
Runze Wang
52e82c810c Emit future warning when mutating GetOptions() in OSS
PiperOrigin-RevId: 946657065
2026-07-12 13:41:24 -07:00
Runze Wang
3d31b0f786 Fix memory leak in PyUpb_Descriptor_GetExtensionRanges
PyTuple_Pack increments the reference count of its arguments. When PyTuple_Pack(2, start, end) was passed directly to PyList_SetItem, the start and end PyLong objects were leaked on every call.

Store the tuple created by PyTuple_Pack and DECREF start and end before inserting into the list.

PiperOrigin-RevId: 937601625
2026-06-24 15:49:13 -07:00
Runze Wang
12baad3caa internal change
PiperOrigin-RevId: 922907524
2026-05-28 12:21:38 -07:00
Runze Wang
403d429eab [py/upb] Make GetOptions() return immutable options for scalar type. UPB will raise a TypeError when options returned GetOptions() by is mutated.
PiperOrigin-RevId: 918559519
2026-05-20 11:33:26 -07:00
Mikita Belahlazau
4f076d951f Add metadata annotations for generated Python protobuf symbols.
The pyi generator now includes Kythe annotations for:
*   Extension field constants (e.g., `EXTENSION_FIELD`).
*   Field number constants (e.g., `STRING_FIELD_FIELD_NUMBER`).
*   `Create` methods in generated Stubby client classes.

These annotations allow the Python indexer to link these generated symbols back to their definitions in the `.proto` files.

PiperOrigin-RevId: 852971617
2026-01-06 16:05:56 -08:00
Protobuf Team Bot
ae67a4c195 Internal version update.
PiperOrigin-RevId: 852733884
2026-01-06 05:27:44 -08:00
Jie Luo
0a8ff55518 Breaking change: Remove deprecated FieldDescriptor.label
https://protobuf.dev/news/2025-09-19/#python-remove-apis

PiperOrigin-RevId: 836922631
2025-11-25 21:02:16 -08:00
Protobuf Team Bot
64a76e68e0 Add Python deprecation warnings for Descriptor Label.
PiperOrigin-RevId: 781862421
2025-07-11 00:26:48 -07:00
Aaron Jacobs
080801bd75 Automated rollback of commit 2471bd804a.
PiperOrigin-RevId: 776010222
2025-06-26 00:12:01 -07:00
Protobuf Team Bot
2471bd804a Add Python deprecation warnings for Descriptor Label.
PiperOrigin-RevId: 775966280
2025-06-25 21:24:40 -07:00
Aaron Jacobs
ac4a50be6c Add Python deprecation warnings for Descriptor Label. Also, minimize calls to Label within Protobuf.
PiperOrigin-RevId: 756720481
2025-05-09 05:15:24 -07:00
Protobuf Team Bot
4f2ccc207d Add Python deprecation warnings for Descriptor Label. Also, minimize calls to Label within Protobuf.
PiperOrigin-RevId: 756631443
2025-05-09 00:09:00 -07:00
Mike Kruskal
879e06d388 Automated rollback of commit 5bd7d02ed8.
PiperOrigin-RevId: 740194500
2025-03-24 22:10:02 -07:00
Protobuf Team Bot
5bd7d02ed8 Deprecate Descriptor Label. As an alternative, add helper methods for checking whether a field is required or repeated.
This is for C++, Java, and Python.

PiperOrigin-RevId: 740152256
2025-03-24 19:12:18 -07:00
Jie Luo
4214ee72ef Add has_options to ServiceDescriptor and MethodDescriptor in UPB python and cpp python to match with other descriptors and pure python
PiperOrigin-RevId: 714950915
2025-01-13 06:56:21 -08:00
Geoffry Song
5752b2d07b [python] Remove semicolon after PyObject_HEAD (#16123)
`PyObject_HEAD` already expands to a field with a semicolon; the extra semicolon is unnecessary, and makes some compilers unhappy.

Closes #16123

COPYBARA_INTEGRATE_REVIEW=https://github.com/protocolbuffers/protobuf/pull/16123 from goffrie:pyobject_head 947438678f
PiperOrigin-RevId: 700735003
2024-11-27 10:08:21 -08:00
Mike Kruskal
4c923285a3 Fix packed reflection handling bug in edition 2023.
This is a very narrow edge case where touching a packed extension via generated APIs first, and then doing so reflectively will trigger a DCHECK.  Otherwise, reflective APIs will work but not use packed encoding for the extension.  This was likely a pre-existing bug dating back to proto3, where it would only be visible on custom options (the only extensions allowed in proto3).

To help qualify this and uncover similar issues, unittest.proto was migrated to editions.  This turned up some other minor issues in DebugString and python.

PiperOrigin-RevId: 675785611
2024-09-17 18:41:26 -07:00
Mike Kruskal
9a020c4a7b Unify behavior of deprecated_legacy_json_field_conflicts across upb and syntax.
This disables all checks of json_name for upb and protoc under both proto2 and proto3.  This option is deprecated that will be removed in future versions, and is only meant as a temporary solution.  This also fixes a latent bug in the calculation of camelcase name in Python/upb.

Fixes #12525

PiperOrigin-RevId: 603158026
2024-01-31 14:21:54 -08:00
Mike Kruskal
3acd85e0a9 Remove edition getter from python descriptor APIs
We've never released these, so this is not a breaking change.

PiperOrigin-RevId: 596007719
2024-01-05 09:01:37 -08:00
Eric Salo
b997cb6d8d upb: add a non-void typedef for upb_Message
PiperOrigin-RevId: 592863926
2023-12-21 08:12:16 -08:00
Mike Kruskal
fd40c87bef Breaking change: Remove deprecated syntax accessor.
This has been replaced by edition and feature getters.  Any code depending on syntax will likely be broken by editions files, and should be migrated to the finer-grained feature helpers.

PiperOrigin-RevId: 589866745
2023-12-11 10:30:26 -08:00
Joshua Haberman
c05b320d9c Fixed a bug where FileDescriptor maps like message_types_by_name could return descriptors from other files.
Fixes: https://github.com/protocolbuffers/protobuf/issues/13740
PiperOrigin-RevId: 587135054
2023-12-01 15:12:41 -08:00
Protobuf Team Bot
0fab773c1d Update remainder of upb to new short license style.
PiperOrigin-RevId: 584116886
2023-11-20 13:43:32 -08:00
Mike Kruskal
c23d5333c3 Expose editions in Python/upb.
This also fixes a few minor bugs in the editions implementation that were caught in python/conformance tests, and adds a new SetFeatureSetDefaults API to the def pool for consistency with C++ and other python implementations.

PiperOrigin-RevId: 581384108
2023-11-10 15:20:41 -08:00
Protobuf Team Bot
e32d0948e7 Properly untrack Python GC objects during deallocation.
Add PyObject_GC_UnTrack() in deallocation functions for Python types that
have PyTPFLAGS_HAVE_GC set, either explicitly or by inheriting from a type
with GC set. Not untracking before clearing instance data introduces
potential race conditions (if GC happens to run between the partial clearing
and the actual deallocation) and produces a warning under Python 3.11.

(The warning then triggered an assertion failure, which only showed up when
building in Py_DEBUG mode; this therefor also fixes that assertion failure.)

PiperOrigin-RevId: 579827001
2023-11-06 06:44:56 -08:00
Jie Luo
c508a40f40 Raise warnings for python syntax usages
PiperOrigin-RevId: 579344748
2023-11-03 17:17:00 -07:00
Jie Luo
8c8cbc43a7 Add client_streaming and server_streaming in MethodDescriptor for upb python
PiperOrigin-RevId: 573268712
2023-10-13 11:12:41 -07:00
Eric Salo
5b6543edb5 upb: first attempt at implementing name mangling for minitable symbols
PiperOrigin-RevId: 571636273
2023-10-07 16:29:19 -07:00
Adam Cozzette
501ececd39 Reorganize upb file structure
This change moves almost everything in the `upb/` directory up one level, so
that for example `upb/upb/generated_code_support.h` becomes just
`upb/generated_code_support.h`. The only exceptions I made to this were that I
left `upb/cmake` and `upb/BUILD` where they are, mostly because that avoids
conflict with other files and the current locations seem reasonable for now.

The `python/` directory is a little bit of a challenge because we had to merge
the existing directory there with `upb/python/`. I made `upb/python/BUILD` into
the BUILD file for the merged directory, and it effectively loads the contents
of the other BUILD file via `python/build_targets.bzl`, but I plan to clean
this up soon.

PiperOrigin-RevId: 568651768
2023-09-26 14:38:35 -07:00
Renamed from upb/python/descriptor.c (Browse further)