Ticket #239 (closed defect: fixed)

Opened 5 years ago

Last modified 5 years ago

lexicon unpickling

Reported by: robertwb Owned by: robertwb, hoyt
Priority: major Milestone: 0.11.1
Component: Packaging Keywords:
Cc:

Description

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 hoytak@gmail.com
# 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

Change History

Changed 5 years ago by dagss

  • milestone changed from 0.10.1 to 0.11.1

Changed 5 years ago by robertwb

  • owner changed from hoyt to robertwb, hoyt

Changed 5 years ago by robertwb

  • status changed from new to closed
  • resolution set to fixed
Note: See TracTickets for help on using tickets.