[pcre-dev] Python2-to-Python3 problem

Αρχική Σελίδα
Delete this message
Συντάκτης: ph10
Ημερομηνία:  
Προς: pcre-dev
Αντικείμενο: [pcre-dev] Python2-to-Python3 problem
Are there any Python experts on this list? There are two Python scripts
that are used for generating Unicode tables for PCRE. They were
contributed by a user some time ago and were in Python2. I have managed
to hack them from time to time (e.g. for adding new Unicode scripts).

Now I'm slowly working on the new PCRE API (aka PCRE2) and I figured
these scripts should be converted to Python3. I used the 2to3 converter,
and on the maint/GenerateUtt.py script it worked flawlessly. However,
for the maint/MultiStage2.py script, it didn't. Python3 complained about
the line

chardata = map(string.strip, line.split(';'))

as apparently the 'strip' function is no more. I solved this by using
line.replace to remove spaces and then line.split. Then it grumbled
about an xc3 byte in one of the data files. Luckily, only yesterday I
had the identical problem running a new version of Gramps (a
genealogical program) and had discovered (via the Gramps community) that
the fix was to add encoding='utf-8' to the open function.

But now I am stuck, so that's why I'm asking if there's anyone on this
list who can help. The error message is:

  File "./MultiStage2.py", line 477, in <module>
    print_records(records, record_size)
  File "./MultiStage2.py", line 285, in print_records
    records.sort(None, lambda x: x[1])
TypeError: an integer is required (got type function)


Anybody got any ideas?

Philip

--
Philip Hazel