-
Notifications
You must be signed in to change notification settings - Fork 12
Python3 compatibility #5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
c33650a
to
9c4f251
Compare
929a02f
to
f63453e
Compare
4ad6bd1
to
40b691d
Compare
4852871
to
eaedd24
Compare
Caught by extended test. Signed-off-by: Yann Dirson <[email protected]>
Signed-off-by: Yann Dirson <[email protected]>
Signed-off-by: Yann Dirson <[email protected]>
This goes away in python3. Signed-off-by: Yann Dirson <[email protected]>
Signed-off-by: Yann Dirson <[email protected]>
Signed-off-by: Yann Dirson <[email protected]>
FIXME: I'm quite unsure why xcp.xmlunwrap would want to use bytes and not unicode strings, but the encode/decode calls make it quite clear it wants to work with bytes. That makes the API painful to use in python3.
Signed-off-by: Yann Dirson <[email protected]>
Signed-off-by: Yann Dirson <[email protected]>
Really hackish in case the code gets used. Caught/tested using non-included test_cpiofile.py derived from cpython's test_tarfile.py Signed-off-by: Yann Dirson <[email protected]>
hashlib came with python 2.5, and old md5 module disappears in 3.0 Signed-off-by: Yann Dirson <[email protected]>
* yd/improve-test-coverage: cpiofile: flag known issue in apparently-unused code Coverage: add a test for Bootloader.newDefault Coverage: test_cpio: add a test for CpioFileCompat xcp.net.biosname: remove dead code Coverage: test_biosdevname: add a test of all_devices_all_names() tests: remove unused imports, direct test execution coverage: new test_environ: parse a sample "xensource-inventory" Coverage: new tests for xcp.accessor and xcp.repository xcp.bootloader: relax format strings for serial config Coverage: new test_bootloader Coverage: new test_xmlunwrap from snippet in xmlunwrap.py Coverage: new test_cmd from snippet in cmd.py Coverage: test_pci: new test from snippet in pci.py Coverage: test_cpio: exercise "extractall()" and check its output Coverage: test_cpio: recursive add to archive Signed-off-by: Yann Dirson <[email protected]>
* futurize-pass-1: Futurize pylint complements: whitespace in expressions Futurize pylint complements: "print" continuation indentations, line lengths Futurize fixes: remove now-unused imports Un-futurize: replace future.utils.raise_ with six.raise_from Futurize fixes: use "raise" not "raise_" when not reraising Futurize fixes: fix broken indentations Futurize fixes: drop now-duplicated test Futurize: first pass, using -wn1 Prepare for futurize pass: fix "except" clause Signed-off-by: Yann Dirson <[email protected]>
* futurize-pass-2: (29 commits) xcp: get rid of useless blackslash line continuations xcp.cpiofile: fix bad indentation Futurize pylint complements: whitespace in expressions Futurize pylint complements: "print" continuation indentations, line lengths Futurize pylint complements: xcp.repository: locally disable too-few-public-methods Futurize pylint complements: xcp.repository: honor singleton-comparison convention Futurize pylint complements: Avoid useless ".keys()" when enumerating dicts Futurize pylint complements: xcp.accessor: avoid redefining "file" builtin Futurize pylint complements: test_cpio: mark unused import as expected Futurize pylint complements: disable warnings triggered by "import future" Futurize pylint complements: xcp.accessor: bring consistency to "openAddress" arguments Futurize cleanups: cleanup duplicated imports Futurize cleanups: line-wrapping fixes Futurize cleanups: xcp.net.ifrename.logic: simplify nested comprehensions Futurize cleanups: use list comprehension not `list(map())` or `list(filter())` Futurize fixes: use generator comprehensions when list ones are not needed Apply all fixes from `2to3 -f filter` that are useful even when suboptimal Apply fixes from `2to3 -f map` that are useful even when suboptimal futurize: convert "iteritems()" to "items()", all negligible perf impact 2to3: rename "next" methods to "__next__", use six.Iterator for portability ... Signed-off-by: Yann Dirson <[email protected]>
* testcpio-py3: cpiofile: hack support for text IO to archive member cpiofile: catch use of non-binary streams early cpiofile: revert overeager tar->cpio substitution on "target" cpiofile: revert unnecessary deviations from original tarfile.py test_cpio: remove unused import (pylint on python3) cpio: fix check for xz file magic ignoring the 6th byte test_cpio: check xz magic, not just the flags test_cpio: expect different xz flags depending on python version test_cpio: improve test readability test_cpio: avoid overwriting original archives with "archiveCreate()" test_cpio: generate reproducible archives test_cpio: add some docstrings Mark bytes literals and streams as such tests: use TestCase.assertRaises as context manager tests: avoid useless try/except test_cpio: use context manager for other "open" calls for consistency test_cpio: use context manager to avoid forgetting to close some files test_cpio: always use hashlib, came with python 2.5 Signed-off-by: Yann Dirson <[email protected]>
This is supposed to be just a module renaming to conform to PEP8, see https://docs.python.org/3/whatsnew/3.0.html#library-changes The SafeConfigParser class has been renamed to ConfigParser in Python 3.2, and backported as addon package. The `readfp` method now triggers a deprecation warning to replace it with `read_file`. FIXME: With python3 some Accessor implementations (e.g. FileAccessor) provide a text stream for repository config (and with python2 all implementations), while others (e.g. HTTPAccessor) provide a binary stream. But on python3 ConfigParser will bomb out if given a binary stream, so use a TextIOWrapper to access the config. This is a hack, which cannot be used when it is binary data which has to be read (see later commits), so I don't consider this commit to be correct in that respect.
Testing several accessor classes causes code duplication, which can be avoided with help from the `parametrized` package (unfortunately, `pytest` support cannot be used together with `unittest`). Not a big deal right now, but starts becoming painful when adding new tests or testing other Accessor classes. Signed-off-by: Yann Dirson <[email protected]>
This test uses the same kind of I/O (file copy) that prepare_host_upgrade.py does. FIXME: the copy cannot proceed this way in python3
This works properly for the http case, but FileAccessor provides us with a text fileobj handle, and `read()` gets a UTF-8 decoding error. FIXME: Accessor ctor requires a `mode` argument
Signed-off-by: Yann Dirson <[email protected]>
Signed-off-by: Yann Dirson <[email protected]>
Reported under python3 for members created on-the-fly in `setUp()` Signed-off-by: Yann Dirson <[email protected]>
With python3, pylint complains about `else: raise()` constructs. This rework avoids them and reduces cyclomatic complexity by using the error-out-first idiom. Signed-off-by: Yann Dirson <[email protected]>
diff-cover defaults to origin/main in new version, it seems. Signed-off-by: Yann Dirson <[email protected]>
* testsuite-driven-py3: CI: also run tests with python3 Pylint complements: avoid no-else-raise "refactor" issues Pylint complements: test_ifrename_logic: disable "no-member" warning Pylint complements: whitespace in expressions Pylint complements: honor len-as-condition convention WIP xcp.repository: switch from ConfigParser to configparser xcp.repository: switch from md5 to hashlib.md5 WIP python3: fix xmlunwrap and its test to align with the use of bytes cpiofile: migrate last "list.sort()" call still using a "cmp" argument test_cpio: ensure paths are handled as text ifrename: don't rely on dict ordering in tests test_dom0: mock "open()" in a python3-compatible way python3: use raw strings for regexps, fixes insufficient quoting xcp.net.ifrename.logic: use "logger.warning", "logger.warn" is deprecated python3: xcp.net.mac: use six.python_2_unicode_compatible for stringification Remove direct call's to file's constructor and replace them with calls to open() as ths is considered best practice. python3: use "six.ensure_binary" and "six.ensure_text" for str/bytes conversion python3: use six.string_types not version-dependant types Signed-off-by: Yann Dirson <[email protected]>
bernhardkaindl
added a commit
to rosslagerwall/python-libs
that referenced
this pull request
May 8, 2024
GitHub CI: Migrate CI to an Alpine container(GH removed Py27)
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This is quite a lot of individual changes, so some of them are thematically regrouped in "sub-branches" to make it easier to understand the mega-branch structure.
Each individual sub-branch will be submitted in its own PR.