r47320 - porting
hawkowl-TA+aISz0psMTMxyoc4vAAJOcrHinNvQL0E9HWUfgJXw@public.gmane.org Mon, 25 Apr 2016 21:27:07 -0600 (MDT)
| Newsgroups | gmane.comp.python.twisted.commits |
|---|---|
| Message-ID | <[email protected]> |
Author: hawkowl
Date: Mon Apr 25 21:27:02 2016
New Revision: 47320
Added:
branches/adbapi-py3-8303/twisted/topfiles/8303.feature
Modified:
branches/adbapi-py3-8303/twisted/enterprise/adbapi.py
branches/adbapi-py3-8303/twisted/python/dist3.py
branches/adbapi-py3-8303/twisted/test/test_adbapi.py
Log:
porting
Modified: branches/adbapi-py3-8303/twisted/enterprise/adbapi.py
==============================================================================
--- branches/adbapi-py3-8303/twisted/enterprise/adbapi.py (original)
+++ branches/adbapi-py3-8303/twisted/enterprise/adbapi.py Mon Apr 25 21:27:02 2016
@@ -6,10 +6,13 @@
An asynchronous mapping to U{DB-API 2.0<http://www.python.org/topics/database/DatabaseAPI-2.0.html>}.
"""
+from __future__ import absolute_import, division
+
import sys
from twisted.internet import threads
from twisted.python import reflect, log
+from twisted.python._oldstyle import _oldStyle
class ConnectionLost(Exception):
@@ -75,6 +78,8 @@
return getattr(self._connection, name)
+
+@_oldStyle
class Transaction:
"""A lightweight wrapper for a DB-API 'cursor' object.
@@ -122,6 +127,8 @@
return getattr(self._cursor, name)
+
+@_oldStyle
class ConnectionPool:
"""
Represent a pool of connections to a DB-API 2.0 compliant database.
@@ -226,9 +233,12 @@
# these are optional so import them here
from twisted.python import threadpool
- import thread
+ try:
+ from thread import get_ident
+ except ImportError:
+ from threading import get_ident
- self.threadID = thread.get_ident
+ self.threadID = get_ident
self.threadpool = threadpool.ThreadPool(self.min, self.max)
self.startID = self._reactor.callWhenRunning(self._start)
@@ -285,13 +295,13 @@
result = func(conn, *args, **kw)
conn.commit()
return result
- except:
+ except Exception as e:
excType, excValue, excTraceback = sys.exc_info()
try:
conn.rollback()
except:
log.err(None, "Rollback failed")
- raise excType, excValue, excTraceback
+ raise e
def runInteraction(self, interaction, *args, **kw):
@@ -446,13 +456,13 @@
trans.close()
conn.commit()
return result
- except:
+ except Exception as e:
excType, excValue, excTraceback = sys.exc_info()
try:
conn.rollback()
except:
log.err(None, "Rollback failed")
- raise excType, excValue, excTraceback
+ raise e
def _runQuery(self, trans, *args, **kw):
Modified: branches/adbapi-py3-8303/twisted/python/dist3.py
==============================================================================
--- branches/adbapi-py3-8303/twisted/python/dist3.py (original)
+++ branches/adbapi-py3-8303/twisted/python/dist3.py Mon Apr 25 21:27:02 2016
@@ -63,6 +63,8 @@
"twisted.cred.portal",
"twisted.cred.strcred",
"twisted.cred.test.__init__",
+ "twisted.enterprise.__init__",
+ "twisted.enterprise.adbapi",
"twisted.internet.__init__",
"twisted.internet._baseprocess",
"twisted.internet._glibbase",
@@ -357,6 +359,7 @@
"twisted.python.test.test_versions",
"twisted.python.test.test_zippath",
"twisted.test.test_abstract",
+ "twisted.test.test_adbapi",
"twisted.test.test_amp",
"twisted.test.test_application",
"twisted.test.test_compat",
Modified: branches/adbapi-py3-8303/twisted/test/test_adbapi.py
==============================================================================
--- branches/adbapi-py3-8303/twisted/test/test_adbapi.py (original)
+++ branches/adbapi-py3-8303/twisted/test/test_adbapi.py Mon Apr 25 21:27:02 2016
@@ -2,14 +2,15 @@
# See LICENSE for details.
"""
-Tests for twisted.enterprise.adbapi.
+Tests for L{twisted.enterprise.adbapi}.
"""
-from twisted.trial import unittest
+from __future__ import absolute_import, division
import os
import stat
+from twisted.trial import unittest
from twisted.enterprise.adbapi import ConnectionPool, ConnectionLost
from twisted.enterprise.adbapi import Connection, Transaction
from twisted.internet import reactor, defer, interfaces