From: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
---|---|
To: | Dmitry Dolgov <9erthalion6(at)gmail(dot)com> |
Cc: | exclusion(at)gmail(dot)com, pgsql-bugs(at)lists(dot)postgresql(dot)org |
Subject: | Re: BUG #17908: plpython_to_hstore() crashes with a non-dict argument |
Date: | 2023-04-27 14:46:29 |
Message-ID: | 1113609.1682606789@sss.pgh.pa.us |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-bugs |
Dmitry Dolgov <9erthalion6(at)gmail(dot)com> writes:
>> On Tue, Apr 25, 2023 at 01:00:02PM +0000, PG Bug reporting form wrote:
>> As noted in https://bugs.python.org/issue5945, the behaviour of
>> PyMapping_Check() changed in Python 3, so it can't be used anymore to
>> differentiate real dictionaries from strings or alike.
> Thanks for finding this! That's indeed very annoying.
Yuck.
> After a quick
> investigation looks like a proposed solution from [1] is to use
> PyType_HasFeature with Py_TPFLAGS_MAPPING:
> - if (!PyMapping_Check(dict))
> + dict_type = Py_TYPE(dict);
> + if (!PyType_HasFeature(dict_type, Py_TPFLAGS_MAPPING))
> But this flag is available only starting from Python 3.10, so not
> backward compatible :(
Yeah, doesn't sound hugely workable; I don't think we can require 3.10
yet. The issue5945 discussion suggested
>>> And recommend `PyMapping_Check() && !PySequence_Check()` for true mapping test?
I haven't verified this but will go test it shortly. If it's true,
it would explain why our other uses of PyMapping_Check haven't
failed, because (whether by chance or not I dunno) they are not
reached if PySequence_Check is true.
regards, tom lane
From | Date | Subject | |
---|---|---|---|
Next Message | PG Bug reporting form | 2023-04-27 14:59:30 | BUG #17911: Database or JDBC Driver Provides Incorrect Type |
Previous Message | Daniel Gustafsson | 2023-04-27 14:22:08 | Re: pg_basebackup: errors on macOS on directories with ".DS_Store" files |