[egenix-users] 'dict' not defined in mx/TextTools/TextTools.py line 381

M.-A. Lemburg mal at lemburg.com
Sun Jul 20 17:35:51 CEST 2003


Joel Rosdahl wrote:
> Hi,
> 
> Igor Stroh reported the following to the Debian bugtracking system:
> 
> 
>>here's the error I get when calling tagdict() from
>>mx/TextTools/TextTools.py:
>>
>>File "/usr/lib/python2.1/site-packages/mx/TextTools/TextTools.py", line 381, in tagdict
>>    tagdict(text,dict,pfx+'.',s)
>>    NameError: global name 'dict' is not defined
>>
>>it seems like it's merely a typo...
> 
> 
> I think this patch fixes the problem:
> 
> --- mx/TextTools/TextTools.py~	2001-12-12 13:05:28.000000000 +0100
> +++ mx/TextTools/TextTools.py	2003-06-15 10:46:41.000000000 +0200
> @@ -373,12 +373,7 @@
>      if not rc:
>          return (rc,None,next)
>      d = {}
> -    tagdict = _tagdict
> -    for o,l,r,s in taglist:
> -        pfx = str(o)
> -        d[pfx] = text[l:r]
> -        if s:
> -            tagdict(text,dict,pfx+'.',s)
> +    _tagdict(text,d,'',taglist)
>      return (rc,d,next)

It does, but also adds another function call for (less common)
cases where you don't have recursive tag tables.

The only change needed is:

-            tagdict(text,dict,pfx+'.',s)
+            tagdict(text,d,pfx+'.',s)

(dict -> d)

>  def invset(chars):
> 
>         Regards,
>         Joel
> 

-- 
Marc-Andre Lemburg
eGenix.com

Professional Python Software directly from the Source  (#1, Jul 20 2003)
 >>> Python/Zope Products & Consulting ...         http://www.egenix.com/
 >>> mxODBC, mxDateTime, mxTextTools ...        http://python.egenix.com/
________________________________________________________________________
2003-07-01: Released mxODBC.Zope.DA for FreeBSD             1.0.6 beta 1



More information about the egenix-users mailing list