transaction.commit() unicode problem with exceptions [transaction-1.3.0, py2.7.3]

Bug #1073651 reported by Sebastian Hanula
24
This bug affects 4 people
Affects Status Importance Assigned to Milestone
ZODB
New
Undecided
Unassigned

Bug Description

Hi,

transaction._transaction.Transaction.saveAndGetCommitishError() has problem
with logging unicode traceback stack to self._failure_traceback fileobj which
is io.BytesIO in py2.x (defined in transaction.compat)

I get the following exception - TypeError: 'unicode' does not have the buffer interface.
Replacing BytesIO with StringIO.StringIO fixed the problem.

Here's full traceback:

/home/seba/dev/rrr/env/local/lib/python2.7/site-packages/transaction/_manager.pyc in commit(self)
    105 """ See ITransactionManager.
    106 """
--> 107 return self.get().commit()
    108
    109 def abort(self):

/home/seba/dev/rrr/env/local/lib/python2.7/site-packages/transaction/_transaction.pyc in commit(self)
    350 tb = None
    351 try:
--> 352 t, v, tb = self._saveAndGetCommitishError()
    353 self._callAfterCommitHooks(status=False)
    354 reraise(t, v, tb)

/home/seba/dev/rrr/env/local/lib/python2.7/site-packages/transaction/_transaction.pyc in _saveAndGetCommitishError(self)
    372 t, v, tb = sys.exc_info()
    373 # Record how we got into commit().
--> 374 traceback.print_stack(sys._getframe(1), None, ft)
    375 # Append the stack entries from here down to the exception.
    376 traceback.print_tb(tb, None, ft)

/usr/lib/python2.7/traceback.pyc in print_stack(f, limit, file)
    267 except ZeroDivisionError:
    268 f = sys.exc_info()[2].tb_frame.f_back
--> 269 print_list(extract_stack(f, limit), file)
    270
    271 def format_stack(f=None, limit=None):

/usr/lib/python2.7/traceback.pyc in print_list(extracted_list, file)
     23 ' File "%s", line %d, in %s' % (filename,lineno,name))
     24 if line:
---> 25 _print(file, ' %s' % line.strip())
     26
     27 def format_list(extracted_list):

/usr/lib/python2.7/traceback.pyc in _print(file, str, terminator)
     11
     12 def _print(file, str='', terminator='\n'):
---> 13 file.write(str+terminator)
     14
     15

TypeError: 'unicode' does not have the buffer interface

Revision history for this message
Pedro Ferreira (pferreir) wrote :

I'm having the exact same issue.

Revision history for this message
Sebastian Hanula (sebastian-hanula) wrote :

# Workaround for transaction.commit() unicode bug
# https://bugs.launchpad.net/zodb/+bug/1073651
import StringIO
import transaction._transaction
transaction._transaction.StringIO = StringIO.StringIO

This workaround helps. Cheers.

Revision history for this message
Dias Karbayev (dyus1983) wrote :

Same issue for me:
TypeError: 'unicode' does not have the buffer interface

StringIO solution didn't work for me. When I use it, i get:
TypeError: can't pickle StringIO objects

Sometimes, when i don't use ipython notebook (only ipython), i also get:
TypeError: can't pickle file objects

Help!

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.