[prev in list] [next in list] [prev in thread] [next in thread] 

List:       pykde
Subject:    Wrong context detected by pylupdate
From:       Giuseppe Corbelli <corbelligiuseppe () mesdan ! it>
Date:       2020-06-24 9:59:34
Message-ID: b0f7fc14-2dd6-a130-b7d1-75dfaa78a1ad () mesdan ! it
[Download RAW message or body]

Hi all
I found that under rather common circumstances pylupdate uses the wrong 
context while generating TS files. I did not investigate much but I 
expect trouble since the Qt tr() implementation uses 
QMetaObject::className which is of course different.
Please see the attached test case and TS output.

pylupdate5 v5.15.0
Python 3.5.4
Linux, if it matters.

Yes, I know that Qt6 is on its way and pylupdate will be revamped. I 
already found a workaround (do not define nested class) so it's no big 
deal for me right now but maybe it's worth considering.

Thanks
-- 
Giuseppe Corbelli

["pylupdate_test.py" (pylupdate_test.py)]

from PyQt5.QtCore import QObject, QCoreApplication


class A(QObject):

    class B(QObject):
        pass

    def some_method(self):
        self.tr("axs")

["pylupdate_test.ts" (pylupdate_test.ts)]

<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE TS><TS version="2.0">
<context>
    <name>@default</name>
</context>
<context>
    <name>B</name>
    <message>
        <location filename="pylupdate_test.py" line="19"/>
        <source>axs</source>
        <translation type="unfinished"></translation>
    </message>
</context>
</TS>


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic