fix some gpg handling like TypeError: 'NamedFile' object is not iterable#60
Open
josch wants to merge 6 commits into
Open
fix some gpg handling like TypeError: 'NamedFile' object is not iterable#60josch wants to merge 6 commits into
josch wants to merge 6 commits into
Conversation
Otherwise, when attempting to read an invalid bmapfile, the exception
handler throws an exception itself:
Traceback (most recent call last):
File "/usr/lib/python3/dist-packages/bmaptool/BmapCopy.py", line 400, in _parse_bmap
self._xml = ElementTree.parse(self._f_bmap)
~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^
File "/usr/lib/python3.13/xml/etree/ElementTree.py", line 1210, in parse
tree.parse(source, parser)
~~~~~~~~~~^^^^^^^^^^^^^^^^
File "/usr/lib/python3.13/xml/etree/ElementTree.py", line 573, in parse
self._root = parser._parse_whole(source)
~~~~~~~~~~~~~~~~~~~^^^^^^^^
xml.etree.ElementTree.ParseError: mismatched tag: line 106, column 2
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/bin/bmaptool", line 8, in <module>
sys.exit(main())
~~~~^^
File "/usr/lib/python3/dist-packages/bmaptool/CLI.py", line 947, in main
args.func(args)
~~~~~~~~~^^^^^^
File "/usr/lib/python3/dist-packages/bmaptool/CLI.py", line 637, in copy_command
writer = BmapCopy.BmapCopy(image_obj, dest_obj, bmap_obj, image_size)
File "/usr/lib/python3/dist-packages/bmaptool/BmapCopy.py", line 286, in __init__
self._parse_bmap()
~~~~~~~~~~~~~~~~^^
File "/usr/lib/python3/dist-packages/bmaptool/BmapCopy.py", line 405, in _parse_bmap
for num, line in enumerate(self._f_bmap):
~~~~~~~~~^^^^^^^^^^^^^^
TypeError: 'NamedFile' object is not iterable
…ached On very large input, this stalls for a long time unnecessarily. Since this is handling input which is invalid XML it is likely something completely different, including multi gigabyte binary files.
Without decoding, the line remains binary type which means that it is printed to the user as b"..." and newlines appear as \n instead of as real line breaks.
Otherwise, this will finish successfully even though it wrote out nothing: $ echo foobar > test.gz $ bmaptool copy --nobmap test.gz out.img bmaptool: info: no bmap given, copy entire image to 'out.img' gzip: stdin: not in gzip format bmaptool: info: synchronizing 'out.img' bmaptool: info: copying time: 0.0s, copying speed 0 bytes/sec $ stat -c %s out.img 0
Otherwise, even with --no-sig-verify, the user will get: bmaptool: ERROR: Cannot verify GPG signature without GPG
e047269 to
67695cf
Compare
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
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.
When accidentally attempting to download a image and bmap file from gitlab without access privileges me and @mntmn ran into a couple of problems which are fixed in this MR: