Ticket #239 (closed defect: fixed)
|Reported by:||robertwb||Owned by:||robertwb, hoyt|
On Mar 16, 2009, at 8:15 PM, Hoyt Koepke wrote: Hello, When upgrading the last cython, it seems that loading the lexicon pickle failed. I think I had an incompatible version around somewhere. Anyway, the error I got was this: Compiling module Cython.Plex.Scanners ... ERROR: ('__init__() takes at least 2 arguments (1 given)', <class 'Cython.Plex.Lexicons.Lexicon'>, ()) Extension module compilation failed, using plain Python implementation running install The error occurred while unpickling the lexicon. Under this condition, it seemed like a good idea to just regenerate the pickle file if there's an error loading it. This is what the following patch does: # HG changeset patch # User Hoyt Koepke firstname.lastname@example.org # Date 1237259414 25200 # Node ID 2ec368843599a624c88fa76735824bb7c1c3ede4 # Parent 137b3d0a0c601f810e36df7530734848cb9bb425 Made lexicon unpickling more robust; on error it regenerates it. diff -r 137b3d0a0c60 -r 2ec368843599 Cython/Compiler/Scanning.py --- a/Cython/Compiler/Scanning.py Mon Mar 16 21:33:46 2009 +0100 +++ b/Cython/Compiler/Scanning.py Mon Mar 16 20:10:14 2009 -0700 @@ -102,7 +103,14 @@ if notify_lexicon_unpickling: t0 = time() print("Unpickling lexicon...") - lexicon = pickle.load(f) + + try: + lexicon = pickle.load(f) + except Exception, e: + print "WARNING: Exception while loading lexicon pickle, regenerating" + print e + lexicon = None + f.close() if notify_lexicon_unpickling: t1 = time() -- Hoyt
Note: See TracTickets for help on using tickets.