Skip to content

Commit

Permalink
project_loader: handle invalid unicode chars (canonical#1941)
Browse files Browse the repository at this point in the history
Note that the exception is currently raised with valid and invalid unicode chbaracters due to the upstream bug pyyaml#25. But we'll want to handle the error cleanly even if the upstream issue is fixed.

This branch adds a patch to the PyYAML used by the Snapcraft snap to handle the unicode code points erroneously flagged as invalid, such as the hankey emoji. A Snapcraft snap built from this PR will successfully validate a summary or description making use of the hankey emoji.

New test cases:

    tests.unit.project_loader.test_config.test_invalid_yaml_invalid_unicode_chars
    tests.integration.general.test_global_properties

Note: The integration level test for the PyYAML work-around is skipped unless testing with a snap or Debian package (ie. SNAPCRAFT_FROM_SNAP=1 is set or SNAPCRAFT_FROM_DEB=1 is set), both of which are patched. I verified with a snap from the branch, and running the tests in a virtual environment respectively.

LP: #1737571
  • Loading branch information
kalikiana authored and sergiusens committed Feb 27, 2018
1 parent 729be3e commit c7bd1bc
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions snapcraft.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,12 @@ apps:
completer: snapcraft-completion

parts:
ctypes:
source: ctypes_override
patches:
source: patches
plugin: dump
prime:
- -ctypes_init.diff
- -pyyaml-support-high-codepoints.diff
bash-completion:
source: debian
plugin: dump
Expand Down Expand Up @@ -48,6 +49,7 @@ parts:
TRIPLET_PATH="$SNAPCRAFT_PART_INSTALL/usr/lib/$(gcc -print-multiarch)"
LIBSODIUM=$(readlink -n $TRIPLET_PATH/libsodium.so.18)
ln -s $LIBSODIUM $TRIPLET_PATH/libsodium.so
patch -d $SNAPCRAFT_PART_INSTALL/lib/python3.6/site-packages -p1 < $SNAPCRAFT_STAGE/pyyaml-support-high-codepoints.diff
after: [python, apt]
patchelf:
source: https://github.com/NixOS/patchelf
Expand All @@ -65,7 +67,7 @@ parts:
- -usr/include
install: |
patch $SNAPCRAFT_PART_INSTALL/usr/lib/python3.6/ctypes/__init__.py $SNAPCRAFT_STAGE/ctypes_init.diff
after: [ctypes]
after: [patches]
apt:
source: https://github.com/Debian/apt
source-type: git
Expand Down

0 comments on commit c7bd1bc

Please sign in to comment.