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 1gC6bI-0008W4-Fj for psycopg@arkaria.postgresql.org; Mon, 15 Oct 2018 17:24:16 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1gC6bF-00085W-Cu for psycopg@arkaria.postgresql.org; Mon, 15 Oct 2018 17:24:13 +0000 Received: from makus.postgresql.org ([2001:4800:1501:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1gC6bF-00085O-4o for psycopg@lists.postgresql.org; Mon, 15 Oct 2018 17:24:13 +0000 Received: from mail-lj1-x233.google.com ([2a00:1450:4864:20::233]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1gC6bC-0005By-Dh for psycopg@lists.postgresql.org; Mon, 15 Oct 2018 17:24:11 +0000 Received: by mail-lj1-x233.google.com with SMTP id 63-v6so18250841ljs.4 for ; Mon, 15 Oct 2018 10:24:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to; bh=j4h+6QfoPlMxYIxQXc1InobsqMuvnTlOg9/nu2xR040=; b=UszLOIkgJsCRUtVTOPggdCkQ/Xczd415fLyAw1IhRvZ1QLUHBiXNoNsbGLfcSwqWtQ IFy9iQunjik86fmRPyefPhcZifpdaJfJu8CiotrjjzEyW7JXUX6PNVwYqa+9SOuDTzgo cEHGbrfgXAsrvnWVZ8KqB6bDmvMPFGiq5hBIsPrQBmupFkY8iagWUNalwkp+TBkEz3cN fvvX2G3rZMOOVM7TEDeqIAE+2KwBMFGYXySlXwkOUX7l+bn+5/lFn0G2gyesZWr1DidF oBuqlgI1YQ3htUjxQKt1gYHpi98zazgq3+43v5xyFJOkQ5hHP1Y4RicMTPgIfE8xeH3y +hLQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to; bh=j4h+6QfoPlMxYIxQXc1InobsqMuvnTlOg9/nu2xR040=; b=VnwBTMZapf8cHYAoNGm9lwQ8mzOu3SOpyJmQ98Ww6QnWQ5HUUrDB91jxWdmBVBI+I/ CY3HjnuJbH5y6WOD53uRQz77fiI9M2z1cEArqmlTtUXa1BElqmj0tSVg/RFnGwH4LDwR 27PV018oIT+6NVVEZ8LlrmBWRfK2XKE5pkCtrMP73jnM7cOTfDdFp9Vl9LYYwb9wjRSI wZpNfhpPPrZ0DzM1F8J1uWaN3UsC4E/vnlbGqoa/H1HVlHUb4qfkKN9UDs4jCZR4zyeM R48m8Gv1evQpDimWcRUpRoAw5kkWn+mivtN/JWhYdtjmNd2Vv3sPE5mc1qkRZa4CUNJo kBLA== X-Gm-Message-State: ABuFfogort5K1CxzEv/LikHzj4vj4JHYqP2aUjlS68eaftNacMm5ulI9 X7yaWSjIpn1nQKK8UkZA9srcNKhSRB8Q+aaWpPqnOA== X-Google-Smtp-Source: ACcGV61pMZde2QwKLhjY9mzS83f4sJ8hfrDKGDhptMcqzXcW7je7YwhL2OxVM062S0kGvYMZje/35t0OFw93ZbN68uk= X-Received: by 2002:a2e:9a4d:: with SMTP id k13-v6mr11501043ljj.17.1539624248582; Mon, 15 Oct 2018 10:24:08 -0700 (PDT) MIME-Version: 1.0 References: <20181015121154.GC2008@hermes.hilbert.loc> In-Reply-To: <20181015121154.GC2008@hermes.hilbert.loc> From: Daniele Varrazzo Date: Mon, 15 Oct 2018 18:23:57 +0100 Message-ID: Subject: Re: Feature branches merged to master for 2.8 release To: psycopg@lists.postgresql.org, psycopg@postgresql.org Content-Type: text/plain; charset="UTF-8" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk 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. -- Daniele