The Solidity compiler accepts pragma strings like ^0.5.00; (double zero), while py-solc-x raises an exception. Thus, source files with such a line compile with solc, but fail when processed with solcx.
$ python3.8
Python 3.8.0 (default, Nov 27 2019, 00:26:49)
[GCC 7.4.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import solcx
>>> solcx.set_solc_version_pragma('pragma solidity ^0.5.00;')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/salzer/tmp/venv/lib/python3.8/site-packages/solcx/install.py", line 262, in set_solc_version_pragma
version = _select_pragma_version(pragma_string, get_installed_solc_versions())
File "/home/salzer/tmp/venv/lib/python3.8/site-packages/solcx/install.py", line 230, in _select_pragma_version
spec = SimpleSpec(*(i[0] for i in comparator_regex.findall(comparator_set)))
File "/home/salzer/tmp/venv/lib/python3.8/site-packages/semantic_version/base.py", line 618, in __init__
self.clause = self._parse_to_clause(expression)
File "/home/salzer/tmp/venv/lib/python3.8/site-packages/semantic_version/base.py", line 1014, in _parse_to_clause
return cls.Parser.parse(expression)
File "/home/salzer/tmp/venv/lib/python3.8/site-packages/semantic_version/base.py", line 1034, in parse
raise ValueError("Invalid simple block %r" % block)
ValueError: Invalid simple block '^0.5.00'
How can it be fixed?
Maybe preprocess the pragma string by removing leading zeros?
Environment information
py-solc-x
Version: 1.1.1What was wrong?
The Solidity compiler accepts pragma strings like
^0.5.00;
(double zero), whilepy-solc-x
raises an exception. Thus, source files with such a line compile withsolc
, but fail when processed withsolcx
.How can it be fixed?
Maybe preprocess the pragma string by removing leading zeros?