[egenix-users] mx.TextTools - pickling bug with UnicodeTagTable?

M.-A. Lemburg mal at egenix.com
Thu Aug 2 18:55:40 CEST 2007


On 2007-08-02 17:52, Frank McIngvale wrote:
> On 8/2/07, M.-A. Lemburg <mal at egenix.com> wrote:
>> On 2007-08-02 17:08, Frank McIngvale wrote:
>>> Hi, there seems to be a bug in pickling tag tables:
>>>
>>> This works fine:
>>>
>>> tags = (
>>>     (None, Is, 'a'),
>>>     )
>>>
>>> t = TagTable(tags)
>>> print type(t)
>>> s = pickle.dumps(t)
>>> print pickle.loads(s)
>>>
>>> But this crashes ...
>>>
>>> tags = (
>>>     (None, Is, u'\u03a3'),
>>>     )
>>>
>>> t = UnicodeTagTable(tags)
>>> print type(t)
>>> s = pickle.dumps(t)
>>> print pickle.loads(s)
>> On which platform do you get this ?
> 
> 
> WinXP with:
> "Python 2.5.1 (r251:54863, Apr 18 2007, 08:51:08) [MSC v.1310 32 bit
> (Intel)] on win32"
> 
> mx.__version__ = '3.0'
> 
> Unfortunately there is no message from Python, just a popup box that says
> the program crashed.

Thanks. I can replicate the problem on Linux x64 as well. The fix is
easy:

--- mxTextTools.c       (revision 22704)
+++ mxTextTools.c       (working copy)
@@ -2654,7 +2654,7 @@

  onError:
     if (own_args) {
-       Py_DECREF(args);
+       Py_XDECREF(args);
     }
     return -1;
 }

Which then lets the error message get through:

Traceback (most recent call last):
  File "testPickleSegFault.py", line 24, in ?
    print pickle.loads(s)
  File "/usr/local/python-2.4-ucs2/lib/python2.4/pickle.py", line 1394,
in loads
    return Unpickler(file).load()
  File "/usr/local/python-2.4-ucs2/lib/python2.4/pickle.py", line 872,
in load
    dispatch[key](self)
  File "/usr/local/python-2.4-ucs2/lib/python2.4/pickle.py", line 1153,
in load_reduce
    value = func(*args)
  File "/home/lemburg/projects/mx/TextTools/__init__.py", line 17, in _TT
    return TagTable(definition)
TypeError: tag table entry 0: conversion from Unicode to string failed

I've never tried to pickle tag tables before :-) What's the use
case for this ?

-- 
Marc-Andre Lemburg
eGenix.com

Professional Python Services directly from the Source  (#1, Aug 02 2007)
>>> Python/Zope Consulting and Support ...        http://www.egenix.com/
>>> mxODBC.Zope.Database.Adapter ...             http://zope.egenix.com/
>>> mxODBC, mxDateTime, mxTextTools ...        http://python.egenix.com/
________________________________________________________________________

:::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,MacOSX for free ! ::::


   eGenix.com Software, Skills and Services GmbH  Pastor-Loeh-Str.48
    D-40764 Langenfeld, Germany. CEO Dipl.-Math. Marc-Andre Lemburg
           Registered at Amtsgericht Duesseldorf: HRB 46611



More information about the egenix-users mailing list