v2.3 fails to parse a valid python file
Metadata
Current evaluation
No evaluation has been recorded for this issue yet.
Issue body
When building the [opensearch charm](https://github.com/canonical/opensearch-operator) on charmcraft 2.3, it now fails to parse a file named [helper_charm.py](https://github.com/canonical/opensearch-operator/blob/main/lib/charms/opensearch/v0/helper_charm.py).
Here's the interesting part of the stacktrace:
```
2023-05-10 15:09:31.249 :: 2023-05-10 14:09:30.900 Packing the charm.
2023-05-10 15:09:31.249 :: 2023-05-10 14:09:30.900 Reading '/root/project/metadata.yaml'
2023-05-10 15:09:31.249 :: 2023-05-10 14:09:30.903 Validating metadata format
2023-05-10 15:09:31.249 :: 2023-05-10 14:09:30.909 Building for 'bases[0]' as host matches 'build-on[0]'.
2023-05-10 15:09:31.249 :: 2023-05-10 14:09:30.909 Building for 'bases[0][0]'.
2023-05-10 15:09:31.249 :: 2023-05-10 14:09:30.909 Building charm in '/root'
2023-05-10 15:09:31.249 :: 2023-05-10 14:09:30.926 Failed to parse Python library 'lib/charms/opensearch/v0/helper_charm.py'
2023-05-10 15:09:40.008 Failed to build charm for bases index '0'.
2023-05-10 15:09:40.011 Traceback (most recent call last):
2023-05-10 15:09:40.011 File "/snap/charmcraft/1349/lib/charmcraft/commands/build.py", line 388, in pack_charm_in_instance
2023-05-10 15:09:40.011 instance.execute_run(cmd, check=True, cwd=instance_output_dir)
2023-05-10 15:09:40.011 File "/snap/charmcraft/1349/lib/craft_providers/lxd/lxd_instance.py", line 289, in execute_run
2023-05-10 15:09:40.011 return self.lxc.exec(
2023-05-10 15:09:40.011 File "/snap/charmcraft/1349/lib/craft_providers/lxd/lxc.py", line 371, in exec
2023-05-10 15:09:40.011 return runner(final_cmd, **kwargs) # pylint: disable=subprocess-run-check
2023-05-10 15:09:40.011 File "/snap/charmcraft/1349/usr/lib/python3.8/subprocess.py", line 516, in run
2023-05-10 15:09:40.011 raise CalledProcessError(retcode, process.args,
2023-05-10 15:09:40.011 subprocess.CalledProcessError: Command '['lxc', '--project', 'charmcraft', 'exec', 'local:charmcraft-opensearch-35655756-0-0-amd64', '--cwd', '/root/project', '--', 'env', 'PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/snap/bin', 'CHARMCRAFT_MANAGED_MODE=1', 'charmcraft', 'pack', '--bases-index', '0', '--verbosity=brief']' returned non-zero exit status 1.
```
To reproduce, just build the `main` branch of the [opensearch charm](https://github.com/canonical/opensearch-operator) with charmcraft v2.3.
Evaluation history
No evaluation history available.