Unicode errors when creating a new operator-framework charm.

Open
#577 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
55/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Stale
Tech stack
python
Domain
cli, tooling

Research direction

Start in charmtools/templates/operator_python/template.py, especially _template_file, and reproduce the failure with charm create using the operator-framework template. Check the Cheetah template loading shown in the traceback; done means creating the charm directory succeeds when the template contains the reported non-ASCII text.

Written by the indexing model from the issue text.

Description

Checklist

  • Confirmed this is an issue with charm-tools, not charmstore-client
  • Provide versions of tools used
  • Described the feature or ways to replicate the issue

What version am I running?

I ran the following command: snap info charm and got the following ouput:

name:      charm
summary:   charm and charm-tools
publisher: Canonical✓
contact:   https://discourse.juju.is/c/charming
license:   unset
description: |
  charmstore-client and charm-tools
commands:
  - charm
snap-id:      2Rryoc2ylScfbFl4eQtpntHD9iuZuMvt
tracking:     stable
refresh-date: today at 01:03 AEST
channels:
  stable:    2.7.7 2020-07-20 (502) 117MB classic
  candidate: 2.7.7 2020-07-20 (502) 117MB classic
  beta:      2.7.7 2020-07-20 (502) 117MB classic
  edge:      2.7.7 2020-07-20 (502) 117MB classic
installed:   2.7.7            (502) 117MB classic

I am using: Arch Linux

Issue/Feature

I expect/expected the following

Successfully creating a new charm dir for operator framework

What I got
/var/lib/snapd/snap/charm/502/bin/wrappers/charm: line 8: warning: setlocale: LC_ALL: cannot change locale (C.UTF-8): No such file or directory
/bin/sh: warning: setlocale: LC_ALL: cannot change locale (C.UTF-8)
INFO: Generating charm for test1 in ./test1
INFO: No test1 in apt cache; creating an empty charm instead.
User-friendly name for this charm: test1
Developer contact email: [email protected]
Developer name: tlm
URL where bugs can be filed for this Charm: github.com
Cloning into '/tmp/tmpmzvy_wcg'...
warning: templates not found /snap/charm/502/share/git-core/templates
remote: Enumerating objects: 104, done.
remote: Counting objects: 100% (104/104), done.
remote: Compressing objects: 100% (57/57), done.
remote: Total 104 (delta 35), reused 98 (delta 30), pack-reused 0
Receiving objects: 100% (104/104), 14.95 KiB | 14.95 MiB/s, done.
Resolving deltas: 100% (35/35), done.
/bin/sh: warning: setlocale: LC_ALL: cannot change locale (C.UTF-8)
Traceback (most recent call last):
  File "/snap/charm/502/bin/charm-create", line 33, in <module>
    sys.exit(load_entry_point('charm-tools==2.7.7', 'console_scripts', 'charm-create')())
  File "/snap/charm/502/lib/python3.6/site-packages/charmtools/create.py", line 98, in main
    generator.create_charm()
  File "/snap/charm/502/lib/python3.6/site-packages/charmtools/generators/generator.py", line 82, in create_charm
    self.plugin.create_charm(user_config, tempdir)
  File "/snap/charm/502/lib/python3.6/site-packages/charmtools/templates/operator_python/template.py", line 74, in create_charm
    self._template_file(config, path.join(root, outfile))
  File "/snap/charm/502/lib/python3.6/site-packages/charmtools/templates/operator_python/template.py", line 90, in _template_file
    template = Template(file=outfile, searchList=(config))
  File "/snap/charm/502/lib/python3.6/site-packages/Cheetah/Template.py", line 1281, in __init__
    self._compile(source, file, compilerSettings=compilerSettings)
  File "/snap/charm/502/lib/python3.6/site-packages/Cheetah/Template.py", line 1573, in _compile
    keepRefToGeneratedCode=True)
  File "/snap/charm/502/lib/python3.6/site-packages/Cheetah/Template.py", line 752, in compile
    settings=(compilerSettings or {}))
  File "/snap/charm/502/lib/python3.6/site-packages/Cheetah/Compiler.py", line 1551, in __init__
    source = f.read()
  File "/snap/charm/502/usr/lib/python3.6/encodings/ascii.py", line 26, in decode
    return codecs.ascii_decode(input, self.errors)[0]
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc2 in position 79: ordinal not in range(128)
Dominant language
Python
Stars
44
Forks
65
PR merge metrics
No merged PRs in 30d

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from juju/charm-tools

All issues in juju/charm-tools

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.