]> git.ipfire.org Git - thirdparty/psycopg.git/commitdiff
feat: expose used_gssapi attribute to the public API 1140/head
authorDaniele Varrazzo <daniele.varrazzo@gmail.com>
Tue, 26 Aug 2025 02:16:25 +0000 (04:16 +0200)
committerDaniele Varrazzo <daniele.varrazzo@gmail.com>
Tue, 26 Aug 2025 13:02:15 +0000 (15:02 +0200)
Already implemented in 3.1.10, but kept as internal implementation.

Fix #1138

docs/api/objects.rst
docs/api/pq.rst
docs/news.rst
psycopg/psycopg/_capabilities.py
psycopg/psycopg/pq/pq_ctypes.py
tests/test_capabilities.py

index 5f6e2902e73539536ce9a080b2b3f00baaa831e8..fb9714e3bbfa5d04202664dc68513718d0f61351 100644 (file)
@@ -150,6 +150,10 @@ Libpq capabilities information
     .. automethod:: has_hostaddr
     .. automethod:: has_pipeline
     .. automethod:: has_set_trace_flags
+    .. automethod:: has_used_gssapi
+
+        .. versionadded:: 3.3
+
     .. automethod:: has_cancel_safe
 
         .. note::
index cb500eff70f1f11d6fafe7457e45577283e6c3df..6b74a33fea8a47eb471c4b168791ca9259540b28 100644 (file)
@@ -91,6 +91,9 @@ Objects wrapping libpq structures and functions
     .. automethod:: get_cancel
     .. autoattribute:: needs_password
     .. autoattribute:: used_password
+    .. autoattribute:: used_gssapi
+
+        .. versionadded:: 3.3
 
     .. automethod:: encrypt_password
 
index 4b7584e845d7c33f5ba9163784b5f48be873e2c9..973f62307e122b4c5c556e453352244f471179f0 100644 (file)
@@ -13,13 +13,23 @@ Future releases
 Psycopg 3.3.0 (unreleased)
 ^^^^^^^^^^^^^^^^^^^^^^^^^^
 
+.. rubric:: New top-level features
+
 - Cursors are now iterators, not only iterables. This means you can call
   ``next(cur)`` to fetch the next row (:ticket:`#1064`).
-- Drop support for Python 3.8 (:ticket:`#976`) and 3.9 (:ticket:`#1056`).
 - Add `Cursor.results()` to iterate over the result sets of the queries
   executed though `~Cursor.executemany()` or `~Cursor.execute()`
   (:ticket:`#1080`).
 
+.. rubric:: New libpq wrapper features
+
+- Add `pq.PGconn.used_gssapi` attribute and `Capabilities.has_used_gssapi()`
+  function (:ticket:`#1138`).
+
+.. rubric:: Other changes
+
+- Drop support for Python 3.8 (:ticket:`#976`) and 3.9 (:ticket:`#1056`).
+
 
 Psycopg 3.2.10 (unreleased)
 ^^^^^^^^^^^^^^^^^^^^^^^^^^^
index b5427cb4a3304ab9ae82caff1e1ffafa54776a2d..49aef12f8f9b0d0147b9f4230ff01e9b8cb6ecef 100644 (file)
@@ -46,6 +46,13 @@ class Capabilities:
         """
         return self._has_feature("PGconn.set_trace_flags()", 140000, check=check)
 
+    def has_used_gssapi(self, check: bool = False) -> bool:
+        """Check if the `pq.PGconn.used_gssapi` attribute is implemented.
+
+        The feature requires libpq 16.0 or greater.
+        """
+        return self._has_feature("PGconn.used_gssapi", 160000, check=check)
+
     def has_cancel_safe(self, check: bool = False) -> bool:
         """Check if the `Connection.cancel_safe()` method is implemented.
 
index 059f0ae45b88a7eb317f204625267ae41375b949..686df557ec28fecd1f21ec397fbb8701c253fd0a 100644 (file)
@@ -270,6 +270,10 @@ class PGconn:
 
     @property
     def used_gssapi(self) -> bool:
+        """True if the connection authentication method used GSSAPI.
+
+        See :pq:`PQconnectionUsedGSSAPI` for details.
+        """
         return bool(impl.PQconnectionUsedGSSAPI(self._pgconn_ptr))
 
     @property
index 674a083c208e1c3a079adc02ac24209cd527fc63..f58471a15065defb7bb8707edba1b33d3db533ce 100644 (file)
@@ -15,6 +15,7 @@ caps = [
     ("has_hostaddr", "Connection.info.hostaddr", 12),
     ("has_pipeline", "Connection.pipeline()", 14),
     ("has_set_trace_flags", "PGconn.set_trace_flags()", 14),
+    ("has_used_gssapi", "PGconn.used_gssapi", 16),
     ("has_cancel_safe", "Connection.cancel_safe()", 17),
     ("has_stream_chunked", "Cursor.stream() with 'size' parameter greater than 1", 17),
     ("has_send_close_prepared", "PGconn.send_close_prepared()", 17),