Received: from malur.postgresql.org ([2a02:16a8:dc51::56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1gC6n9-0000kG-DX for psycopg@arkaria.postgresql.org; Mon, 15 Oct 2018 17:36:31 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1gC6n7-0004Rs-TL for psycopg@arkaria.postgresql.org; Mon, 15 Oct 2018 17:36:29 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1gC6n7-0004Rl-OX for psycopg@lists.postgresql.org; Mon, 15 Oct 2018 17:36:29 +0000 Received: from mail.dndg.it ([178.32.136.2]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1gC6n4-0007rq-AA for psycopg@lists.postgresql.org; Mon, 15 Oct 2018 17:36:29 +0000 Received: from [10.94.33.108] (93-50-194-114.ip153.fastwebnet.it [93.50.194.114]) by mail.dndg.it (Postfix) with ESMTPSA id 2485AA02C4 for ; Mon, 15 Oct 2018 17:41:54 +0000 (UTC) Subject: Re: Feature branches merged to master for 2.8 release To: psycopg@lists.postgresql.org References: <20181015121154.GC2008@hermes.hilbert.loc> From: Federico Di Gregorio Organization: DNDG srl Message-ID: Date: Mon, 15 Oct 2018 19:36:24 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.9.1 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: it-IT Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-1.0 required=5.0 tests=ALL_TRUSTED,SURBL_BLOCKED, URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.0 X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on mail List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On 10/15/2018 07:23 PM, Daniele Varrazzo wrote: > On Mon, Oct 15, 2018 at 1:12 PM Karsten Hilbert wrote: >> On Mon, Oct 15, 2018 at 12:48:04PM +0100, Daniele Varrazzo wrote: >> >>> - the new 'errors' module. About it I have a doubt: we convert >>> postgres error messages [2] from lower_case to CamelCase because the >>> latter is the convention for Python class, but maybe leaving as they >>> are makes more sense? Easier to google for them or grep for them in >>> the postgres sources maybe? >> Since there is no Right or Wrong here, the "best" option >> might be to offer both: >> >> Raise whatever is Right for Python (that is, CamelCase) >> >> raise PostgresSpecificError >> >> but support catching lower case, too: >> >> class postgres_specific_error(PostgresSpecificError): >> pass >> >> try: >> something() >> except postgres_specific_error: >> print('lower case') >> >> For the lower case one I would exactly copy what's used by >> PostgreSQL itself. >> >> Make sense ? > I think it's responsible to make a decision. Having two names to refer > to a thing is confusing. One of the two would be the "blessed" one - > the one appearing in the tracebacks. And if a traceback says that > 'unique_violation' was raised, it would be weird to solve it by > writing a handler for 'UniqueViolation'. > > Plus, that module defines already 232 classes (as of Postgres 11): I > wouldn't like doubling their number. I'm pondering whether to write it > as a C module instead of Python but I'm not overly fussed by that. > > So I'd say lower_case or CamelCase, not both. Python exceptions are CamelCase in 99% of the cases (pun intended). Lets not have every single Python programmer out there hate us because we decided to import a database backend convention into a programming laguage. federico -- Federico Di Gregorio federico.digregorio@dndg.it DNDG srl http://dndg.it Una nazionale senza neanche una nazione. -- macchinavapore