[devel] python.req error

Vitaly Kuznetsov vitty на altlinux.org
Сб Окт 21 09:32:15 MSK 2017


On Sat, Oct 21, 2017 at 8:12 AM, Антон Мидюков <midyukov-anton на ya.ru> wrote:
> Подскажите, пожалуйста, что не понравилось в синтаксисе python.req:
>
> python.req: ERROR:
> /usr/src/tmp/Uranium-buildroot/usr/lib/uranium/plugins/LocalFileOutputDevice/LocalFileOutputDevice.py:
> invalid syntax (line 159)
> Traceback (most recent call last):
>   File "/usr/lib/rpm/python.req.py", line 230, in <module>
>     lis = parser.suite('\n'.join(lines)+'\n').tolist(line_info=1)
>   File "<string>", line 159
>     raise
> OutputDeviceError.PermissionDeniedError(catalog.i18nc("@info:status Don't
> translate the XML tags <filename>!", "Permission denied when trying to save
> <filename>{0}</filename>").format(file_name)) from e
> ^
> SyntaxError: invalid syntax
>

raise ... from - это конструкция Python3:
$ python2
Python 2.7.13 (default, Sep  5 2017, 08:53:59)
[GCC 7.1.1 20170622 (Red Hat 7.1.1-3)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> try:
...     1/0
... except:
...     raise RuntimeError("Something bad happened") from None
  File "<stdin>", line 4
    raise RuntimeError("Something bad happened") from None
                                                    ^
SyntaxError: invalid syntax

$ python3
Python 3.6.2 (default, Oct  2 2017, 16:51:32)
[GCC 7.2.1 20170915 (Red Hat 7.2.1-2)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> try:
...     1/0
... except:
...    raise RuntimeError("Something bad happened") from None
...
Traceback (most recent call last):
  File "<stdin>", line 4, in <module>
RuntimeError: Something bad happened

https://docs.python.org/3/reference/simple_stmts.html#raise
https://docs.python.org/2.7/reference/simple_stmts.html#raise


Подробная информация о списке рассылки Devel