Author: cito
Date: Wed Dec 30 16:56:42 2015
New Revision: 680

Log:
Remove the deprecated tty parameter and attribute

This parameter has been ignored by PostgreSQL since version 7.4.

Modified:
   branches/4.x/docs/pg.rst
   trunk/docs/pg.rst
   trunk/docs/pgdb.rst
   trunk/module/pgdb.py
   trunk/module/pgmodule.c
   trunk/module/tests/test_classic_connection.py
   trunk/module/tests/test_classic_dbwrapper.py
   trunk/module/tests/test_classic_functions.py

Modified: branches/4.x/docs/pg.rst
==============================================================================
--- branches/4.x/docs/pg.rst    Wed Dec 30 16:31:47 2015        (r679)
+++ branches/4.x/docs/pg.rst    Wed Dec 30 16:56:42 2015        (r680)
@@ -189,7 +189,7 @@
 
 This method returns the current default debug terminal specification, or
 ``None`` if the environment variables should be used. Environment variables
-won't be looked up.
+won't be looked up. Note that this is ignored in newer PostgreSQL versions.
 
 .. function:: set_deftty(terminal)
 
@@ -204,6 +204,7 @@
 This methods sets the default debug terminal value for new connections.
 If ``None`` is supplied as parameter, environment variables will be used
 in future connections. It returns the previous setting for default terminal.
+Note that this is ignored in newer PostgreSQL versions.
 
 get/set_defbase -- default database name [DV]
 ---------------------------------------------

Modified: trunk/docs/pg.rst
==============================================================================
--- trunk/docs/pg.rst   Wed Dec 30 16:31:47 2015        (r679)
+++ trunk/docs/pg.rst   Wed Dec 30 16:56:42 2015        (r680)
@@ -51,7 +51,7 @@
 connect -- Open a PostgreSQL connection
 ---------------------------------------
 
-.. function:: connect([dbname], [host], [port], [opt], [tty], [user], [passwd])
+.. function:: connect([dbname], [host], [port], [opt], [user], [passwd])
 
     Open a :mod:`pg` connection
 
@@ -63,8 +63,6 @@
     :type port: int
     :param opt: connection options (*None* = :data:`defopt`)
     :type opt: str or None
-    :param tty: debug terminal (*None* = :data:`deftty`)
-    :type tty: str or None
     :param user: PostgreSQL user (*None* = :data:`defuser`)
     :type user: str or None
     :param passwd: password for user (*None* = :data:`defpasswd`)
@@ -176,35 +174,6 @@
 If ``None`` is supplied as parameter, environment variables will be used in
 future connections. It returns the previous setting for default options.
 
-get/set_deftty -- default debug tty [DV]
-----------------------------------------
-
-.. function:: get_deftty()
-
-    Get the default debug terminal
-
-    :returns: the current default debug terminal specification
-    :rtype: str or None
-    :raises TypeError: too many arguments
-
-This method returns the current default debug terminal specification, or
-``None`` if the environment variables should be used. Environment variables
-won't be looked up.
-
-.. function:: set_deftty(terminal)
-
-    Set the default debug terminal
-
-    :param terminal: the new default debug terminal
-    :type terminal: str or None
-    :returns: the previous default debug terminal specification
-    :rtype: str or None
-    :raises TypeError: bad argument type, or too many arguments
-
-This methods sets the default debug terminal value for new connections.
-If ``None`` is supplied as parameter, environment variables will be used
-in future connections. It returns the previous setting for default terminal.
-
 get/set_defbase -- default database name [DV]
 ---------------------------------------------
 
@@ -840,10 +809,6 @@
 
    the connection options (str)
 
-.. attribute:: Connection.tty
-
-   the connection debug terminal (str)
-
 .. attribute:: Connection.user
 
     user name on the database system (str)

Modified: trunk/docs/pgdb.rst
==============================================================================
--- trunk/docs/pgdb.rst Wed Dec 30 16:31:47 2015        (r679)
+++ trunk/docs/pgdb.rst Wed Dec 30 16:56:42 2015        (r680)
@@ -54,12 +54,11 @@
 This function takes parameters specifying how to connect to a PostgreSQL
 database and returns a :class:`Connection` object using these parameters.
 If specified, the *dsn* parameter must be a string with the format
-``'host:base:user:passwd:opt:tty'``. All of the parts specified in the *dsn*
+``'host:base:user:passwd:opt'``. All of the parts specified in the *dsn*
 are optional. You can also specify the parameters individually using keyword
 arguments, which always take precedence. The *host* can also contain a port
 if specified in the format ``'host:port'``. In the *opt* part of the *dsn*
-you can pass command-line options to the server, the *tty* part is used to
-send server debug output.
+you can pass command-line options to the server.
 
 Example::
 

Modified: trunk/module/pgdb.py
==============================================================================
--- trunk/module/pgdb.py        Wed Dec 30 16:31:47 2015        (r679)
+++ trunk/module/pgdb.py        Wed Dec 30 16:56:42 2015        (r680)
@@ -19,7 +19,7 @@
 Basic usage:
 
     pgdb.connect(connect_string) # open a connection
-    # connect_string = 'host:database:user:password:opt:tty'
+    # connect_string = 'host:database:user:password:opt'
     # All parts are optional. You may also pass host through
     # password as keyword arguments. To pass a port,
     # pass it in the host keyword parameter:
@@ -566,7 +566,6 @@
     dbuser = ""
     dbpasswd = ""
     dbopt = ""
-    dbtty = ""
     try:
         params = dsn.split(":")
         dbhost = params[0]
@@ -574,7 +573,6 @@
         dbuser = params[2]
         dbpasswd = params[3]
         dbopt = params[4]
-        dbtty = params[5]
     except (AttributeError, IndexError, TypeError):
         pass
 
@@ -600,8 +598,7 @@
         dbuser = None
 
     # open the connection
-    cnx = _connect_(dbbase, dbhost, dbport, dbopt,
-        dbtty, dbuser, dbpasswd)
+    cnx = _connect_(dbbase, dbhost, dbport, dbopt, dbuser, dbpasswd)
     return Connection(cnx)
 
 

Modified: trunk/module/pgmodule.c
==============================================================================
--- trunk/module/pgmodule.c     Wed Dec 30 16:31:47 2015        (r679)
+++ trunk/module/pgmodule.c     Wed Dec 30 16:56:42 2015        (r680)
@@ -100,7 +100,6 @@
 static PyObject *pg_default_host;      /* default database host */
 static PyObject *pg_default_base;      /* default database name */
 static PyObject *pg_default_opt;       /* default connection options */
-static PyObject *pg_default_tty;       /* default debug tty */
 static PyObject *pg_default_port;      /* default connection port */
 static PyObject *pg_default_user;      /* default username */
 static PyObject *pg_default_passwd;    /* default password */
@@ -2307,8 +2306,8 @@
        PyObject *attrs;
 
        attrs = PyObject_Dir(PyObject_Type((PyObject *)self));
-       PyObject_CallMethod(attrs, "extend", "[ssssssssss]",
-               "host", "port", "db", "options", "tty", "error", "status", 
"user",
+       PyObject_CallMethod(attrs, "extend", "[sssssssss]",
+               "host", "port", "db", "options", "error", "status", "user",
                "protocol_version", "server_version");
 
        return attrs;
@@ -2405,10 +2404,6 @@
        if (!strcmp(name, "options"))
                return PyStr_FromString(PQoptions(self->cnx));
 
-       /* selected postgres tty */
-       if (!strcmp(name, "tty"))
-               return PyStr_FromString(PQtty(self->cnx));
-
        /* error (status) message */
        if (!strcmp(name, "error"))
                return PyStr_FromString(PQerrorMessage(self->cnx));
@@ -3169,18 +3164,17 @@
 
 /* connects to a database */
 static char pgConnect__doc__[] =
-"connect(dbname, host, port, opt, tty) -- connect to a PostgreSQL database "
+"connect(dbname, host, port, opt) -- connect to a PostgreSQL database "
 "using specified parameters (optionals, keywords aware).";
 
 static PyObject *
 pgConnect(PyObject *self, PyObject *args, PyObject *dict)
 {
        static const char *kwlist[] = {"dbname", "host", "port", "opt",
-       "tty", "user", "passwd", NULL};
+       "user", "passwd", NULL};
 
        char       *pghost,
                           *pgopt,
-                          *pgtty,
                           *pgdbname,
                           *pguser,
                           *pgpasswd;
@@ -3188,7 +3182,7 @@
        char            port_buffer[20];
        connObject   *npgobj;
 
-       pghost = pgopt = pgtty = pgdbname = pguser = pgpasswd = NULL;
+       pghost = pgopt = pgdbname = pguser = pgpasswd = NULL;
        pgport = -1;
 
        /*
@@ -3197,8 +3191,8 @@
         * don't declare kwlist as const char *kwlist[] then it complains when
         * I try to assign all those constant strings to it.
         */
-       if (!PyArg_ParseTupleAndKeywords(args, dict, "|zzizzzz", (char **) 
kwlist,
-               &pgdbname, &pghost, &pgport, &pgopt, &pgtty, &pguser, 
&pgpasswd))
+       if (!PyArg_ParseTupleAndKeywords(args, dict, "|zzizzz", (char **) 
kwlist,
+               &pgdbname, &pghost, &pgport, &pgopt, &pguser, &pgpasswd))
                return NULL;
 
 #ifdef DEFAULT_VARS
@@ -3212,9 +3206,6 @@
        if ((!pgopt) && (pg_default_opt != Py_None))
                pgopt = PyBytes_AsString(pg_default_opt);
 
-       if ((!pgtty) && (pg_default_tty != Py_None))
-               pgtty = PyBytes_AsString(pg_default_tty);
-
        if ((!pgdbname) && (pg_default_base != Py_None))
                pgdbname = PyBytes_AsString(pg_default_base);
 
@@ -3245,7 +3236,7 @@
        Py_BEGIN_ALLOW_THREADS
 #endif
        npgobj->cnx = PQsetdbLogin(pghost, pgport == -1 ? NULL : port_buffer,
-               pgopt, pgtty, pgdbname, pguser, pgpasswd);
+               pgopt, NULL, pgdbname, pguser, pgpasswd);
 #ifdef PQsetdbLoginIsThreadSafe
        Py_END_ALLOW_THREADS
 #endif
@@ -4423,58 +4414,6 @@
        return old;
 }
 
-/* gets default tty */
-static char pgGetDefTTY__doc__[] =
-"get_deftty() -- return default database debug terminal.";
-
-static PyObject *
-pgGetDefTTY(PyObject *self, PyObject *args)
-{
-       /* checks args */
-       if (!PyArg_ParseTuple(args, ""))
-       {
-               PyErr_SetString(PyExc_TypeError,
-                       "method get_deftty() takes no parameter.");
-               return NULL;
-       }
-
-       Py_XINCREF(pg_default_tty);
-       return pg_default_tty;
-}
-
-/* sets default tty */
-static char pgSetDefTTY__doc__[] =
-"set_deftty(string) -- set default database debug terminal. "
-"Return previous value.";
-
-static PyObject *
-pgSetDefTTY(PyObject *self, PyObject *args)
-{
-       char       *temp = NULL;
-       PyObject   *old;
-
-       /* gets arguments */
-       if (!PyArg_ParseTuple(args, "z", &temp))
-       {
-               PyErr_SetString(PyExc_TypeError,
-                       "set_deftty(name), with name (string/None).");
-               return NULL;
-       }
-
-       /* adjusts value */
-       old = pg_default_tty;
-
-       if (temp)
-               pg_default_tty = PyStr_FromString(temp);
-       else
-       {
-               Py_INCREF(Py_None);
-               pg_default_tty = Py_None;
-       }
-
-       return old;
-}
-
 /* gets default username */
 static char pgGetDefUser__doc__[] =
 "get_defuser() -- return default database username.";
@@ -4642,8 +4581,6 @@
        {"set_defbase", pgSetDefBase, METH_VARARGS, pgSetDefBase__doc__},
        {"get_defopt", pgGetDefOpt, METH_VARARGS, pgGetDefOpt__doc__},
        {"set_defopt", pgSetDefOpt, METH_VARARGS, pgSetDefOpt__doc__},
-       {"get_deftty", pgGetDefTTY, METH_VARARGS, pgGetDefTTY__doc__},
-       {"set_deftty", pgSetDefTTY, METH_VARARGS, pgSetDefTTY__doc__},
        {"get_defport", pgGetDefPort, METH_VARARGS, pgGetDefPort__doc__},
        {"set_defport", pgSetDefPort, METH_VARARGS, pgSetDefPort__doc__},
        {"get_defuser", pgGetDefUser, METH_VARARGS, pgGetDefUser__doc__},
@@ -4774,8 +4711,6 @@
        Py_INCREF(Py_None);
        pg_default_port = Py_None;
        Py_INCREF(Py_None);
-       pg_default_tty = Py_None;
-       Py_INCREF(Py_None);
        pg_default_user = Py_None;
        Py_INCREF(Py_None);
        pg_default_passwd = Py_None;

Modified: trunk/module/tests/test_classic_connection.py
==============================================================================
--- trunk/module/tests/test_classic_connection.py       Wed Dec 30 16:31:47 
2015        (r679)
+++ trunk/module/tests/test_classic_connection.py       Wed Dec 30 16:56:42 
2015        (r680)
@@ -115,7 +115,7 @@
 
     def testAllConnectAttributes(self):
         attributes = '''db error host options port
-            protocol_version server_version status tty user'''.split()
+            protocol_version server_version status user'''.split()
         connection_attributes = [a for a in dir(self.connection)
             if not a.startswith('__') and not self.is_method(a)]
         self.assertEqual(attributes, connection_attributes)
@@ -167,11 +167,6 @@
         self.assertIsInstance(self.connection.status, int)
         self.assertEqual(self.connection.status, status_ok)
 
-    def testAttributeTty(self):
-        def_tty = ''
-        self.assertIsInstance(self.connection.tty, str)
-        self.assertEqual(self.connection.tty, def_tty)
-
     def testAttributeUser(self):
         no_user = 'Deprecated facility'
         user = self.connection.user

Modified: trunk/module/tests/test_classic_dbwrapper.py
==============================================================================
--- trunk/module/tests/test_classic_dbwrapper.py        Wed Dec 30 16:31:47 
2015        (r679)
+++ trunk/module/tests/test_classic_dbwrapper.py        Wed Dec 30 16:56:42 
2015        (r680)
@@ -130,7 +130,6 @@
             'start',
             'status',
             'transaction',
-            'tty',
             'unescape_bytea',
             'update',
             'use_regtypes',
@@ -191,13 +190,6 @@
         self.assertEqual(status, status_ok)
         self.assertEqual(status, self.db.db.status)
 
-    def testAttributeTty(self):
-        def_tty = ''
-        tty = self.db.tty
-        self.assertIsInstance(tty, str)
-        self.assertEqual(tty, def_tty)
-        self.assertEqual(tty, self.db.db.tty)
-
     def testAttributeUser(self):
         no_user = 'Deprecated facility'
         user = self.db.user

Modified: trunk/module/tests/test_classic_functions.py
==============================================================================
--- trunk/module/tests/test_classic_functions.py        Wed Dec 30 16:31:47 
2015        (r679)
+++ trunk/module/tests/test_classic_functions.py        Wed Dec 30 16:56:42 
2015        (r680)
@@ -247,14 +247,6 @@
         pg.set_defopt(d0)
         self.assertEqual(pg.get_defopt(), d0)
 
-    def testDefTty(self):
-        d0 = pg.get_deftty()
-        d1 = 'pgtesttty'
-        pg.set_deftty(d1)
-        self.assertEqual(pg.get_deftty(), d1)
-        pg.set_deftty(d0)
-        self.assertEqual(pg.get_deftty(), d0)
-
     def testDefBase(self):
         d0 = pg.get_defbase()
         d1 = 'pgtestdb'
_______________________________________________
PyGreSQL mailing list
[email protected]
https://mail.vex.net/mailman/listinfo.cgi/pygresql

Reply via email to