Bug 127315 - Lightproof build fails with python 3.7
Summary: Lightproof build fails with python 3.7
Status: RESOLVED FIXED
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Linguistic (show other bugs)
Version:
(earliest affected)
unspecified
Hardware: All All
: medium major
Assignee: László Németh
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2019-09-03 17:23 UTC by Rene Engelhard
Modified: 2019-09-11 08:26 UTC (History)
3 users (show)

See Also:
Crash report or crash signature:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Rene Engelhard 2019-09-03 17:23:19 UTC
Hi,

back then I tried to get help with this, then I dropped the ball and never actually reported it. My bad.

(This caused lightproof to not released with Debian buster...)

Anywyays, see https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=917686. Since the upgrade to python3.7 the build of lightproof fails miserably:

--- snip ---
for cfg in `find src -name "*.cfg"`; do \
	python3 make.py $cfg; \
done
make.py:37: DeprecationWarning: The SafeConfigParser class has been renamed to ConfigParser in Python 3.2. This alias will be removed in future versions. Use ConfigParser directly instead.
  fArgs = cp.SafeConfigParser()
/usr/lib/python3.7/zipfile.py:1470: UserWarning: Duplicate name: 'META-INF/manifest.xml'
  return self._open_to_write(zinfo, force_zip64=force_zip64)
make.py:37: DeprecationWarning: The SafeConfigParser class has been renamed to ConfigParser in Python 3.2. This alias will be removed in future versions. Use ConfigParser directly instead.
  fArgs = cp.SafeConfigParser()
Traceback (most recent call last):
  File "/usr/lib/python3.7/sre_parse.py", line 1021, in parse_template
    this = chr(ESCAPES[this][1])
KeyError: '\\w'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "make.py", line 41, in <module>
    dist(i[:-4], fArgs._sections['args'])
  File "make.py", line 13, in dist
    code = pythonpath.lightproof_compile___implname__.c(f.read(), a['lang'])
  File "/data/rene/Debian/Pakete/LibreOffice/lightproof-1.6/pythonpath/lightproof_compile___implname__.py", line 270, in c
    item = mysplit(lines[i].strip(), i + 1, oldlinenums[lines[i]], debug)
  File "/data/rene/Debian/Pakete/LibreOffice/lightproof-1.6/pythonpath/lightproof_compile___implname__.py", line 104, in mysplit
    s1 = re.sub("[{]" + i + "}", repl[i], s1)
  File "/usr/lib/python3.7/re.py", line 192, in sub
    return _compile(pattern, flags).sub(repl, string, count)
  File "/usr/lib/python3.7/re.py", line 309, in _subx
    template = _compile_repl(template, pattern)
  File "/usr/lib/python3.7/re.py", line 300, in _compile_repl
    return sre_parse.parse_template(repl, pattern)
  File "/usr/lib/python3.7/sre_parse.py", line 1024, in parse_template
    raise s.error('bad escape %s' % this, len(this))
re.error: bad escape \w at position 20

missing config file or options: src/en/en.cfg
make.py:37: DeprecationWarning: The SafeConfigParser class has been renamed to ConfigParser in Python 3.2. This alias will be removed in future versions. Use ConfigParser directly instead.
  fArgs = cp.SafeConfigParser()
Traceback (most recent call last):
  File "/usr/lib/python3.7/sre_parse.py", line 1021, in parse_template
    this = chr(ESCAPES[this][1])
KeyError: '\\w'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "make.py", line 41, in <module>
    dist(i[:-4], fArgs._sections['args'])
  File "make.py", line 13, in dist
    code = pythonpath.lightproof_compile___implname__.c(f.read(), a['lang'])
  File "/data/rene/Debian/Pakete/LibreOffice/lightproof-1.6/pythonpath/lightproof_compile___implname__.py", line 270, in c
    item = mysplit(lines[i].strip(), i + 1, oldlinenums[lines[i]], debug)
  File "/data/rene/Debian/Pakete/LibreOffice/lightproof-1.6/pythonpath/lightproof_compile___implname__.py", line 104, in mysplit
    s1 = re.sub("[{]" + i + "}", repl[i], s1)
  File "/usr/lib/python3.7/re.py", line 192, in sub
    return _compile(pattern, flags).sub(repl, string, count)
  File "/usr/lib/python3.7/re.py", line 309, in _subx
    template = _compile_repl(template, pattern)
  File "/usr/lib/python3.7/re.py", line 300, in _compile_repl
    return sre_parse.parse_template(repl, pattern)
  File "/usr/lib/python3.7/sre_parse.py", line 1024, in parse_template
    raise s.error('bad escape %s' % this, len(this))
re.error: bad escape \w at position 6

missing config file or options: src/ru_RU/ru_RU.cfg
make.py:37: DeprecationWarning: The SafeConfigParser class has been renamed to ConfigParser in Python 3.2. This alias will be removed in future versions. Use ConfigParser directly instead.
  fArgs = cp.SafeConfigParser()
/data/rene/Debian/Pakete/LibreOffice/lightproof-1.6/pythonpath/lightproof_compile___implname__.py:170: FutureWarning: Possible nested set at position 5
  compr = re.compile(sc)
Traceback (most recent call last):
  File "/usr/lib/python3.7/sre_parse.py", line 1021, in parse_template
    this = chr(ESCAPES[this][1])
KeyError: '\\d'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "make.py", line 41, in <module>
    dist(i[:-4], fArgs._sections['args'])
  File "make.py", line 13, in dist
    code = pythonpath.lightproof_compile___implname__.c(f.read(), a['lang'])
  File "/data/rene/Debian/Pakete/LibreOffice/lightproof-1.6/pythonpath/lightproof_compile___implname__.py", line 270, in c
    item = mysplit(lines[i].strip(), i + 1, oldlinenums[lines[i]], debug)
  File "/data/rene/Debian/Pakete/LibreOffice/lightproof-1.6/pythonpath/lightproof_compile___implname__.py", line 104, in mysplit
    s1 = re.sub("[{]" + i + "}", repl[i], s1)
  File "/usr/lib/python3.7/re.py", line 192, in sub
    return _compile(pattern, flags).sub(repl, string, count)
  File "/usr/lib/python3.7/re.py", line 309, in _subx
    template = _compile_repl(template, pattern)
  File "/usr/lib/python3.7/re.py", line 300, in _compile_repl
    return sre_parse.parse_template(repl, pattern)
  File "/usr/lib/python3.7/sre_parse.py", line 1024, in parse_template
    raise s.error('bad escape %s' % this, len(this))
re.error: bad escape \d at position 9
--- snip ---

Regards,

Rene
Comment 1 Julien Nabet 2019-09-04 10:14:14 UTC
About, make.py:37: DeprecationWarning: The SafeConfigParser class has been renamed to ConfigParser in Python 3.2. This alias will be removed in future versions. Use ConfigParser directly instead.
  fArgs = cp.SafeConfigParser()
this straightforward patch is sufficient:
diff --git a/make.py b/make.py
index 6c8a7cd..0f1a27d 100644
--- a/make.py
+++ b/make.py
@@ -34,7 +34,7 @@ if len(sys.argv) == 1:
 eg. python make.py src/en/en.cfg""")
     sys.exit(0)

-fArgs = cp.SafeConfigParser()
+fArgs = cp.ConfigParser()
 for i in sys.argv[1:]:
     try:
         fArgs.read(i)


For the rest, it seems due to new behavior of Python 3.7, see
https://stackoverflow.com/questions/54330673/how-to-fix-error-bad-escape-u-at-position-0
So every \d, \w, \b, \t ... in src/<language>/<language>.dat should be escaped
to have \\d, \\w, etc.

For "en" part, it's sufficient.


For the others, there are still more issues to deal with.


(BTW, I created a thread about Languagetool and Lightproof, http://document-foundation-mail-archive.969070.n3.nabble.com/About-Languagetool-Lightproof-grammar-checker-td4266098.html, don't hesitate to comment)
Comment 2 Julien Nabet 2019-09-04 15:18:48 UTC
For Russian part, the same methods as for English part should finally work.

For Hungarian part, I've got this error after having applied these same methods:
Traceback (most recent call last):
  File "/cygdrive/c/BLP/libreoffice-lightproof/pythonpath/lightproof_compile___implname__.py", line 171, in mysplit
    compr = re.compile(sc)
  File "/usr/lib/python3.6/re.py", line 233, in compile
    return _compile(pattern, flags)
  File "/usr/lib/python3.6/re.py", line 301, in _compile
    p = sre_compile.compile(pattern, flags)
  File "/usr/lib/python3.6/sre_compile.py", line 566, in compile
    code = _code(p, flags)
  File "/usr/lib/python3.6/sre_compile.py", line 551, in _code
    _compile(code, p.data, flags)
  File "/usr/lib/python3.6/sre_compile.py", line 160, in _compile
    raise error("look-behind requires fixed-width pattern")
sre_constants.error: look-behind requires fixed-width pattern

I'm not expert enough in regexp to fix this :-(
Comment 3 Rene Engelhard 2019-09-04 15:22:44 UTC
Hi,

> About, make.py:37: DeprecationWarning: The SafeConfigParser class has been
> renamed to ConfigParser in Python 3.2. This alias will be removed in future
> versions. Use ConfigParser directly instead.
> [...]
> For the rest, it seems due to new behavior of Python 3.7, see
> https://stackoverflow.com/questions/54330673/how-to-fix-error-bad-escape-u- at-position-0
> So every \d, \w, \b, \t ... in src/<language>/<language>.dat should be escaped
> to have \\d, \\w, etc.
>
> For "en" part, it's sufficient.

Yes, so far we have been, too and then Hungarian came.. :)
Comment 4 Julien Nabet 2019-09-05 13:54:32 UTC
For Hungarian part, here's the part of dat file which triggers the error:
a [aA]
aword [aáeéiíoóöőuúüűAÁEÉIÍOÓÖŐUÚÜŰ]\\w*
^[aA] {aword} <- not re.match(r"(?i)i(ii?|[vx])$|Unicode$|Unix\\w*$", {aword}) and spell({aword}) -> az {aword} # Hibás névelő?
(?<!(\\d[.]|az) )\b{a} {aword} <- word(-1) and not re.match(r"(?i)i(ii?|[vx])$|Unicode$|Unix\\w*$", {aword}) and
        spell({aword}) -> {a}z {aword}|{aword} # Hibás vagy felesleges névelő?
Comment 5 Julien Nabet 2019-09-05 14:02:23 UTC
(In reply to Julien Nabet from comment #4)
> For Hungarian part, here's the part of dat file which triggers the error:
> a [aA]
> aword [aáeéiíoóöőuúüűAÁEÉIÍOÓÖŐUÚÜŰ]\\w*
> ^[aA] {aword} <- not re.match(r"(?i)i(ii?|[vx])$|Unicode$|Unix\\w*$",
> {aword}) and spell({aword}) -> az {aword} # Hibás névelő?
> (?<!(\\d[.]|az) )\b{a} {aword} <- word(-1) and not
> re.match(r"(?i)i(ii?|[vx])$|Unicode$|Unix\\w*$", {aword}) and
>         spell({aword}) -> {a}z {aword}|{aword} # Hibás vagy felesleges
> névelő?

Replacing "\\d" by "\d" here seems to make the whole part ok, at least no complaint.
So perhaps, we can't just use a replace all "\d" => "\\d", "\s" => "\\s", etc.
Comment 6 László Németh 2019-09-06 09:31:59 UTC
Rene, Julien, thanks for your checking, I am going to check it soon, too.
Comment 7 László Németh 2019-09-11 08:26:25 UTC
Fixed in lightproof master:

https://cgit.freedesktop.org/libreoffice/lightproof/commit/?id=c299ddd4b39395c5b2b0090fa627f05a89d387ee

I plan to fix the future warnings, too, in the near future.

Thanks for your help and report!