Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Tom Tromey <tom@tromey.com>
To: Matthieu Longo <matthieu.longo@arm.com>
Cc: Tom Tromey <tom@tromey.com>,  gdb-patches@sourceware.org
Subject: Re: [PATCH v2 4/6] gdb: new setters and getters for __dict__, and attributes
Date: Thu, 29 Jan 2026 07:45:11 -0700	[thread overview]
Message-ID: <87bjic1nrc.fsf@tromey.com> (raw)
In-Reply-To: <2fa36bd8-5d84-4432-a6c7-77837f5dc850@arm.com> (Matthieu Longo's message of "Thu, 29 Jan 2026 10:42:52 +0000")

>>>>> "Matthieu" == Matthieu Longo <matthieu.longo@arm.com> writes:

Matthieu> What about this ?

Matthieu>   value = PyDict_GetItemWithError (dict.get (), attr);
Matthieu>   if (value != nullptr)
Matthieu>     return Py_NewRef (value);

Matthieu>   /* If PyDict_GetItemWithError() returns NULL because an error occurred, it
Matthieu>      sets an exception.  Propagate it by returning NULL.  */
Matthieu>   if (PyErr_Occurred () != nullptr)
Matthieu>     return nullptr;

Matthieu>   /* If the key is not found, PyDict_GetItemWithError() returns NULL without
Matthieu>      setting an exception.  Failing to set one here would later result in:
Matthieu>        <class 'SystemError'>: error return without exception set
Matthieu>      Therefore, we must explicitly raise an AttributeError in this case.  */
Matthieu>   PyErr_Format (PyExc_AttributeError,
Matthieu> 		"'%s' object has no attribute '%s'",
Matthieu> 		Py_TYPE (self)->tp_name,
Matthieu> 		PyUnicode_AsUTF8AndSize (attr, nullptr));
Matthieu>   return nullptr;

Looks good.  If that was my only comment (I already forgot) then this is
OK.

Approved-By: Tom Tromey <tom@tromey.com>

thank you,
Tom

  reply	other threads:[~2026-01-29 14:48 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-01-28 12:02 Matthieu Longo
2026-01-28 18:00 ` Tom Tromey
2026-01-29 10:42   ` Matthieu Longo
2026-01-29 14:45     ` Tom Tromey [this message]
  -- strict thread matches above, loose matches on Subject: below --
2026-01-27 17:02 [PATCH v2 0/6] gdb: minor fixes for Python limited C API support Matthieu Longo
2026-01-27 17:02 ` [PATCH v2 4/6] gdb: new setters and getters for __dict__, and attributes Matthieu Longo
2026-01-27 19:06   ` Tom Tromey
2026-01-28 11:57     ` Matthieu Longo
2026-01-28 17:43     ` Matthieu Longo
2026-01-28 17:51       ` Tom Tromey

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87bjic1nrc.fsf@tromey.com \
    --to=tom@tromey.com \
    --cc=gdb-patches@sourceware.org \
    --cc=matthieu.longo@arm.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox