Bug 13886 - Invalid python syntax when bytecompiling python files
Summary: Invalid python syntax when bytecompiling python files
Status: RESOLVED FIXED
Alias: None
Product: Samba 4.1 and newer
Classification: Unclassified
Component: Python (show other bugs)
Version: 4.9.5
Hardware: All All
: P5 normal (vote)
Target Milestone: ---
Assignee: Karolin Seeger
QA Contact: Samba QA Contact
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2019-04-04 17:47 UTC by alex.braunegg
Modified: 2019-05-21 09:30 UTC (History)
1 user (show)

See Also:


Attachments
patch for dns test in python 2.6 (1.03 KB, patch)
2019-04-04 20:49 UTC, Douglas Bagnall
npower: review+
Details

Note You need to log in before you can comment on or make changes to this bug.
Description alex.braunegg 2019-04-04 17:47:53 UTC
When compiling and generating RPM files I have noticed the following in the build logs:

+ /usr/lib/rpm/check-buildroot
+ /usr/lib/rpm/redhat/brp-compress
+ /usr/lib/rpm/redhat/brp-strip-static-archive /usr/bin/strip
+ /usr/lib/rpm/redhat/brp-strip-comment-note /usr/bin/strip /usr/bin/objdump
+ /usr/lib/rpm/brp-python-bytecompile /usr/bin/python
Bytecompiling .py files below /builddir/build/BUILDROOT/samba-4.9.5-1.el6.x86_64/usr/lib64/python2.6 using /usr/bin/python2.6
Compiling /builddir/build/BUILDROOT/samba-4.9.5-1.el6.x86_64/usr/lib64/python2.6/site-packages/samba/emulate/traffic.py ...
SyntaxError: ('invalid syntax', ('/usr/lib64/python2.6/site-packages/samba/emulate/traffic.py', 82, 27, 'SKIPPED_PROTOCOLS = {"smb", "smb2", "browser", "smb_netlogon"}\n'))
Compiling /builddir/build/BUILDROOT/samba-4.9.5-1.el6.x86_64/usr/lib64/python2.6/site-packages/samba/graph.py ...
SyntaxError: ('invalid syntax', ('/usr/lib64/python2.6/site-packages/samba/graph.py', 91, 43, "                if len(c) > 1 or c == {'*'}:\n"))
Compiling /builddir/build/BUILDROOT/samba-4.9.5-1.el6.x86_64/usr/lib64/python2.6/site-packages/samba/tests/dns.py ...
SyntaxError: ('invalid syntax', ('/usr/lib64/python2.6/site-packages/samba/tests/dns.py', 1184, 55, '        return {zone_prop_ids[p.id].lower(): p.data for p in props}\n'))
Compiling /builddir/build/BUILDROOT/samba-4.9.5-1.el6.x86_64/usr/lib64/python2.6/site-packages/samba/tests/emulate/traffic.py ...
SyntaxError: ('invalid syntax', ('/usr/lib64/python2.6/site-packages/samba/tests/emulate/traffic.py', 83, 34, '        ngrams = {k: sorted(v) for k, v in model.ngrams.items()}\n'))
Compiling /builddir/build/BUILDROOT/samba-4.9.5-1.el6.x86_64/usr/lib64/python2.6/site-packages/samba/emulate/traffic.py ...
SyntaxError: ('invalid syntax', ('/usr/lib64/python2.6/site-packages/samba/emulate/traffic.py', 82, 27, 'SKIPPED_PROTOCOLS = {"smb", "smb2", "browser", "smb_netlogon"}\n'))
Compiling /builddir/build/BUILDROOT/samba-4.9.5-1.el6.x86_64/usr/lib64/python2.6/site-packages/samba/graph.py ...
SyntaxError: ('invalid syntax', ('/usr/lib64/python2.6/site-packages/samba/graph.py', 91, 43, "                if len(c) > 1 or c == {'*'}:\n"))
Compiling /builddir/build/BUILDROOT/samba-4.9.5-1.el6.x86_64/usr/lib64/python2.6/site-packages/samba/tests/dns.py ...
SyntaxError: ('invalid syntax', ('/usr/lib64/python2.6/site-packages/samba/tests/dns.py', 1184, 55, '        return {zone_prop_ids[p.id].lower(): p.data for p in props}\n'))
Compiling /builddir/build/BUILDROOT/samba-4.9.5-1.el6.x86_64/usr/lib64/python2.6/site-packages/samba/tests/emulate/traffic.py ...
SyntaxError: ('invalid syntax', ('/usr/lib64/python2.6/site-packages/samba/tests/emulate/traffic.py', 83, 34, '        ngrams = {k: sorted(v) for k, v in model.ngrams.items()}\n'))
Bytecompiling .py files below /builddir/build/BUILDROOT/samba-4.9.5-1.el6.x86_64/usr/lib/debug/usr/lib64/python2.6 using /usr/bin/python2.6
Comment 1 Douglas Bagnall 2019-04-04 20:44:14 UTC
Thanks.

The 2.6 incompatibilities in samba/emulate/traffic.py are sort of deliberate, because that code is not run as part of Samba and we have focussed on 3.x compatibility in writing it. I would say WONTFIX on those ones, and their tests.

The 4.9 patch attached to https://bugzilla.samba.org/show_bug.cgi?id=13837 will fix the samba/graph.py one. (on the list I erroneously said the patch was in the latest 4.9 -- actually it will be in the *next* 4.9).

I think that leaves this one:

Compiling /builddir/build/BUILDROOT/samba-4.9.5-1.el6.x86_64/usr/lib64/python2.6/site-packages/samba/tests/dns.py ...
SyntaxError: ('invalid syntax', ('/usr/lib64/python2.6/site-packages/samba/tests/dns.py', 1184, 55, '        return {zone_prop_ids[p.id].lower(): p.data for p in props}\n'))

and the ones in bug 13882 and bug 13837.
Comment 2 Douglas Bagnall 2019-04-04 20:49:35 UTC
Created attachment 15047 [details]
patch for dns test in python 2.6

Note, there may also be python 2.6 incompatibilities that don't manifest as syntax errors. For example the bug 13837 patches convert a use of collections.Counter to collections.defaultdict, because Counter wasn't around in 2.6. This is not a problem until runtime when the symbol needs to be resolved.
Comment 3 Douglas Bagnall 2019-04-18 04:32:21 UTC
I think this needs to go in 4.9 and 4.10.
Comment 4 Douglas Bagnall 2019-04-18 04:34:47 UTC
(In reply to Douglas Bagnall from comment #3)

and not in master, I should have said.
Comment 5 Karolin Seeger 2019-05-16 10:05:39 UTC
(In reply to Douglas Bagnall from comment #4)
Pushed to autobuild-v4-{10,9}-test.
Comment 6 Karolin Seeger 2019-05-21 09:30:37 UTC
(In reply to Karolin Seeger from comment #5)
Pushed to both branches.
Closing out bug report.

Thanks!