Menu

missing argv variable in sys module

Help
Tonka
2017-04-24
2019-03-03
  • Tonka

    Tonka - 2017-04-24

    Hey,

    is it normal that i have no argv variable in the sys module (argv is removed inqcoreapp because python has it's own argeument handling in the sys module)?
    If not, does anybody know how that could happen?

    example:

    import sys
    print(sys.argv) # <== get a non existing error here
    

    Thanks in advance
    Tonka

     
  • Florian Link

    Florian Link - 2017-04-24

    Since Python is embedded, you have to take care of this yourself if you want to have sys.argv:

    /* Define sys.argv. It is up to the application if you
    want this; you can also leave it undefined (since the Python
    code is generally not a main program it has no business
    touching sys.argv...)

       If the third argument is true, sys.path is modified to include
       either the directory containing the script named by argv[0], or
       the current working directory.  This can be risky; if you run
       an application embedding Python in a directory controlled by
       someone else, attackers could put a Trojan-horse module in the
       directory (say, a file named os.py) that your application would
       then import and run.
    */
    PySys_SetArgvEx(argc, argv, 0);
    
     
  • Tonka

    Tonka - 2017-04-24

    Ok. Good to know. Do you know a good way to convert qapp.arguments() to wchar** ?

     
  • Tonka

    Tonka - 2017-04-24

    Hm, i always get PyThreadState_Get: no current thread after PySys_SetArgvEx

     
  • Tonka

    Tonka - 2017-04-26

    My fault, link to the wrong python-lib. Works perfect

     
  • Jian Wang

    Jian Wang - 2019-03-03

    Hi, can you upload your code which are used to convert qapp.arguments() to wchar please ? I entered http://doc.qt.io/qt-5/qstring.html#toWCharArray but I can‘t understand what should I do.So sad......

     

    Last edit: Jian Wang 2019-03-04

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.