Commit graph

15 commits

Author SHA1 Message Date
Jie Luo
059dc7ed32 Fix NULL byte handling issue in Python Protobuf find symbols in pool
PiperOrigin-RevId: 882122977
2026-03-11 11:54:48 -07:00
Jie Luo
f10c1de25f Protobuf Python UPB Free Threading support.
Add obj_cache lock to pass current free threading tests on python upb.

PiperOrigin-RevId: 864903528
2026-02-03 09:04:20 -08:00
Oleh Prypin
46061cb99d Prevent crashes when creating objects during interpreter shutdown
(The crashes happen only since Python 3.13)

In particular:

* Skip adding to the weak map if `Py_IsFinalizing()` is true. Calling `PyUpb_WeakMap_Add` may be caused by user code that creates protos inside `__del__`!

* `PyUpb_DescriptorPool_Get` and subsequently `PyUpb_ObjCache_Get` may *also* be called if users cause `PyUpb_RepeatedContainer_GetOrCreateWrapper` to be called. So make it nullable and skip the assertion if currently shutting down.

This follows a prior attempted fix d57d2708b3 but expands the scope of it.

PiperOrigin-RevId: 856589514
2026-01-15 03:45:00 -08:00
Joshua Haberman
2504a29b3d Fixed several cases of implicit bool->pointer conversion.
We had several cases where we were returning `false` in a function that returns `PyObject*`.  These need to be `return NULL` instead.

PiperOrigin-RevId: 840760349
2025-12-05 09:35:37 -08:00
Jie Luo
49d9e2dca5 Change proto_api work with custom pool for upb and pure python.
PiperOrigin-RevId: 761644107
2025-05-21 13:23:14 -07:00
Jie Luo
9fd28d969e Check with fallback descriptorDB for FindExtensionByNumber()/FindAllExtensions in UPB python pool.
PiperOrigin-RevId: 740001906
2025-03-24 11:04:44 -07: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
Eric Salo
3d21bc26c9 upb: define kUpb_CompareOption_IncludeUnknownFields flag for upb_Message_IsEqual()
PiperOrigin-RevId: 622335300
2024-04-05 18:44:54 -07:00
Eric Salo
e1a19ba8bb upb: add 'options' arg to upb_Message_IsEqual()
PiperOrigin-RevId: 614707625
2024-03-11 10:16:13 -07:00
Eric Salo
c69ed472cd upb: implement minitable-based field iterators
PiperOrigin-RevId: 605718863
2024-02-09 13:39:18 -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
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
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_pool.c (Browse further)