Skip to content

Commit

Permalink
Revert "Test the Python C JSON extension"
Browse files Browse the repository at this point in the history
This reverts commit a7be68a
and a subsequent commit 4617d1f.
There are too many issues with these patches. It's better to revert
them for now and make a separate fixed versions later if needed.

List of issues (maybe not full):

1. 'make clean' removes entire 'python' directory.

2. Fully broken Travis-CI testsuite build:
    building 'ovs._json' extension
    creating build/temp.linux-x86_64-2.7
    error: could not create 'build/temp.linux-x86_64-2.7': \
           Permission denied
    https://travis-ci.org/openvswitch/ovs/jobs/440693765

3. Broken local testsuite build on Ubuntu 18.04:
    running build_ext
    building 'ovs._json' extension
    creating build/temp.linux-x86_64-3.6
    creating build/temp.linux-x86_64-3.6/ovs
    <...>
    /usr/bin/ld: .libs/libopenvswitch.a(util.o): \
        relocation R_X86_64_TPOFF32 against `var.7749' can not be \
        used when making a shared object; recompile with -fPIC
    <...>
    collect2: error: ld returned 1 exit status

4. Fedora build failure because of 'setuptools' ('distutils')
   hard dependency on 'redhat-rpm-config' package:
    building 'ovs._json' extension
    <...>
    gcc: error: <...>/redhat-hardened-cc1: No such file or directory

5. Looks like 'setuptools' also could download and install
   unwanted python modules during package build.

Signed-off-by: Ilya Maximets <[email protected]>
Signed-off-by: Ben Pfaff <[email protected]>
  • Loading branch information
igsilya authored and blp committed Oct 15, 2018
1 parent efc93e6 commit e670355
Show file tree
Hide file tree
Showing 9 changed files with 84 additions and 206 deletions.
11 changes: 0 additions & 11 deletions python/automake.mk
Original file line number Diff line number Diff line change
Expand Up @@ -92,17 +92,6 @@ python-sdist: $(srcdir)/python/ovs/version.py $(ovs_pyfiles) python/ovs/dirs.py

pypi-upload: $(srcdir)/python/ovs/version.py $(ovs_pyfiles) python/ovs/dirs.py
(cd python/ && $(PYTHON) setup.py sdist upload)

ALL_LOCAL += python-build
python-build:$(lib_LTLIBRARIES)
(cd $(srcdir)/python/ && $(PYTHON) setup.py build_py -d $(abs_top_builddir)/python && $(PYTHON) setup.py build_ext -b $(abs_top_builddir)/python -I$(abs_top_srcdir)/include:$(abs_top_builddir)/include -L$(abs_top_builddir)/lib/.libs)
if HAVE_PYTHON3
(cd $(srcdir)/python/ && $(PYTHON3) setup.py build_py -d $(abs_top_builddir)/python && $(PYTHON3) setup.py build_ext -b $(abs_top_builddir)/python -I$(abs_top_srcdir)/include:$(abs_top_builddir)/include -L$(abs_top_builddir)/lib/.libs)

CLEAN_LOCAL += python-clean
python-clean:
rm -rf $(abs_top_builddir)/python
endif
else
ovs-install-data-local:
@:
Expand Down
10 changes: 4 additions & 6 deletions python/ovs/json.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,10 @@

import six

PARSER_C = 'C'
PARSER_PY = 'PYTHON'
try:
import ovs._json
PARSER = PARSER_C
except ImportError:
PARSER = PARSER_PY
pass

__pychecker__ = 'no-stringiter'

Expand Down Expand Up @@ -94,9 +91,10 @@ class Parser(object):
MAX_HEIGHT = 1000

def __new__(cls, *args, **kwargs):
if PARSER == PARSER_C:
try:
return ovs._json.Parser(*args, **kwargs)
return super(Parser, cls).__new__(cls)
except NameError:
return super(Parser, cls).__new__(cls)

def __init__(self, check_trailer=False):
self.check_trailer = check_trailer
Expand Down
9 changes: 2 additions & 7 deletions python/ovs/jsonrpc.py
Original file line number Diff line number Diff line change
Expand Up @@ -272,8 +272,7 @@ def recv(self):
# data, so we convert it here as soon as possible.
if data and not error:
try:
if six.PY3 or ovs.json.PARSER == ovs.json.PARSER_PY:
data = decoder.decode(data)
data = decoder.decode(data)
except UnicodeError:
error = errno.EILSEQ
if error:
Expand All @@ -299,11 +298,7 @@ def recv(self):
else:
if self.parser is None:
self.parser = ovs.json.Parser()
if six.PY3 and ovs.json.PARSER == ovs.json.PARSER_C:
self.input = self.input.encode('utf-8')[
self.parser.feed(self.input):].decode()
else:
self.input = self.input[self.parser.feed(self.input):]
self.input = self.input[self.parser.feed(self.input):]
if self.parser.is_done():
msg = self.__process_msg()
if msg:
Expand Down
4 changes: 1 addition & 3 deletions tests/atlocal.in
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,8 @@ if test x"$PYTHON3" = x; then
export PYTHONCOERCECLOCALE
fi

PYTHONPATH=$abs_top_builddir/python:$abs_top_builddir/tests:$PYTHONPATH
PYTHONPATH=$abs_top_srcdir/python:$abs_top_builddir/tests:$PYTHONPATH
export PYTHONPATH
LD_LIBRARY_PATH=$abs_top_builddir/lib/.libs
export LD_LIBRARY_PATH

PYTHONIOENCODING=utf_8
export PYTHONIOENCODING
Expand Down
35 changes: 14 additions & 21 deletions tests/json.at
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,15 @@ m4_define([JSON_CHECK_POSITIVE_C],
AT_CLEANUP])

# JSON_CHECK_POSITIVE_PY(TITLE, INPUT, OUTPUT, TEST-JSON-ARGS,
# PYTHON-CHCEK, PYTHON-BIN, JSON-PARSER = python)
# PYTHON-CHCEK, PYTHON-BIN)
#
m4_define([JSON_CHECK_POSITIVE_PY],
[AT_SETUP([$1])
AT_KEYWORDS([json positive Python])
AT_SKIP_IF([test $5 = no])
AT_SKIP_IF([test $7 = C && ! $6 -c "import ovs._json" 2>/dev/null])
AT_CHECK([printf %s "AS_ESCAPE([$2])" > input])
AT_CAPTURE_FILE([input])
AT_CHECK([$6 $srcdir/test-json.py -j m4_default([$7], python) $4 input], [0], [stdout], [])
AT_CHECK([$6 $srcdir/test-json.py $4 input], [0], [stdout], [])
AT_CHECK([cat stdout], [0], [$3
])
AT_CLEANUP])
Expand All @@ -38,17 +37,16 @@ m4_define([JSON_CHECK_POSITIVE_UCS4PY],

m4_define([JSON_CHECK_POSITIVE],
[JSON_CHECK_POSITIVE_C([$1 - C], [$2], [$3], [$4])
JSON_CHECK_POSITIVE_PY23([$1], [$2], [$3], [$4])])
JSON_CHECK_POSITIVE_PY([$1 - Python2], [$2], [$3], [$4],
[$HAVE_PYTHON2], [$PYTHON2])
JSON_CHECK_POSITIVE_PY([$1 - Python3], [$2], [$3], [$4],
[$HAVE_PYTHON3], [$PYTHON3])])

m4_define([JSON_CHECK_POSITIVE_PY23],
[JSON_CHECK_POSITIVE_PY([$1 - Python2(pyjson)], [$2], [$3], [$4],
[JSON_CHECK_POSITIVE_PY([$1 - Python2], [$2], [$3], [$4],
[$HAVE_PYTHON2], [$PYTHON2])
JSON_CHECK_POSITIVE_PY([$1 - Python2(cjson)], [$2], [$3], [$4],
[$HAVE_PYTHON2], [$PYTHON2], C)
JSON_CHECK_POSITIVE_PY([$1 - Python3(pyjson)], [$2], [$3], [$4],
[$HAVE_PYTHON3], [$PYTHON3])
JSON_CHECK_POSITIVE_PY([$1 - Python3(cjson)], [$2], [$3], [$4],
[$HAVE_PYTHON3], [$PYTHON3], C)])
JSON_CHECK_POSITIVE_PY([$1 - Python3], [$2], [$3], [$4],
[$HAVE_PYTHON3], [$PYTHON3])])

m4_define([JSON_CHECK_NEGATIVE_C],
[AT_SETUP([$1])
Expand All @@ -61,30 +59,25 @@ m4_define([JSON_CHECK_NEGATIVE_C],
AT_CLEANUP])

# JSON_CHECK_NEGATIVE_PY(TITLE, INPUT, OUTPUT, TEST-JSON-ARGS,
# PYTHON-CHCEK, PYTHON-BIN, JSON_PARSER = python)
# PYTHON-CHCEK, PYTHON-BIN)
#
m4_define([JSON_CHECK_NEGATIVE_PY],
[AT_SETUP([$1])
AT_KEYWORDS([json negative Python])
AT_SKIP_IF([test $5 = no])
AT_SKIP_IF([test $7 = C && ! $6 -c "import ovs._json" 2>/dev/null])
AT_CHECK([printf %s "AS_ESCAPE([$2])" > input])
AT_CAPTURE_FILE([input])
AT_CHECK([$6 $srcdir/test-json.py -j m4_default([$7], python) $4 input], [1], [stdout], [])
AT_CHECK([$6 $srcdir/test-json.py $4 input], [1], [stdout], [])
AT_CHECK([[sed 's/^error: [^:]*:/error:/' < stdout]], [0], [$3
])
AT_CLEANUP])

m4_define([JSON_CHECK_NEGATIVE],
[JSON_CHECK_NEGATIVE_C([$1 - C], [$2], [$3], [$4])
JSON_CHECK_NEGATIVE_PY([$1 - Python2(pyjson)], [$2], [$3], [$4],
JSON_CHECK_NEGATIVE_PY([$1 - Python2], [$2], [$3], [$4],
[$HAVE_PYTHON2], [$PYTHON2])
JSON_CHECK_NEGATIVE_PY([$1 - Python2(cjson)], [$2], [$3], [$4],
[$HAVE_PYTHON2], [$PYTHON2], C)
JSON_CHECK_NEGATIVE_PY([$1 - Python3(pyjson)], [$2], [$3], [$4],
[$HAVE_PYTHON3], [$PYTHON3])
JSON_CHECK_NEGATIVE_PY([$1 - Python3(cjson)], [$2], [$3], [$4],
[$HAVE_PYTHON3], [$PYTHON3], C)])
JSON_CHECK_NEGATIVE_PY([$1 - Python3], [$2], [$3], [$4],
[$HAVE_PYTHON3], [$PYTHON3])])

AT_BANNER([JSON -- arrays])

Expand Down
Loading

0 comments on commit e670355

Please sign in to comment.