Bug on loading modules / Bug on loading pyc/pyo from game

In this forum we discuss the future of Ren'Py, both bug fixes and longer-term development. Pre-releases are announced and discussed here.
Post Reply
Message
Author
User avatar
Enerccio
Miko-Class Veteran
Posts: 616
Joined: Thu Oct 26, 2006 4:23 pm
Projects: My Teacher; Songs of Araiah; Something new; Possible Cross Bomber?
Location: Slovakia, Kosice
Contact:

Bug on loading modules / Bug on loading pyc/pyo from game

#1 Post by Enerccio » Sat Mar 17, 2012 10:18 pm

When using python code in renpy game, all modules in a package which is then places in the game directory must use package.module expression when importing, even if its local import. This is not how should importing work at all...

Moreover, only .py files will get loaded from game directory, not pyo nor pyc. So fix is to move them to renpy/ directory, but there, the importing is correct and package.module imports do not work anymore.

I think the need for package.module whenever the py files are used in game directory is a bug. And not working with pyc/pyo is bug as well.
Image
http://www.bishojo.tk is technically ONLINE!
Songs of Araiah promo: http://www.youtube.com/watch?v=CalchucuoDU

User avatar
PyTom
Ren'Py Creator
Posts: 15497
Joined: Mon Feb 02, 2004 10:58 am
Completed: Moonlight Walks
Projects: Ren'Py
IRC Nick: renpytom
Github: renpytom
itch: renpytom
Location: Kings Park, NY
Contact:

Re: Bug on loading modules / Bug on loading pyc/pyo from gam

#2 Post by PyTom » Sun Mar 18, 2012 8:55 pm

Enerccio wrote:When using python code in renpy game, all modules in a package which is then places in the game directory must use package.module expression when importing, even if its local import. This is not how should importing work at all...
Do you have an example of how I can repeat this?
Moreover, only .py files will get loaded from game directory, not pyo nor pyc. So fix is to move them to renpy/ directory, but there, the importing is correct and package.module imports do not work anymore.
You really shouldn't distribute game code as a pyo or pyc file. If your game is run under a newer version of Ren'Py (for example, a version that uses Python 2.7), it will stop working if it can't recompile the pyo or pyc files.
Supporting creators since 2004
(When was the last time you backed up your game?)
"Do good work." - Virgil Ivan "Gus" Grissom
"Silly and fun things are important." - Elon Musk
Software > Drama • https://www.patreon.com/renpytom

User avatar
Enerccio
Miko-Class Veteran
Posts: 616
Joined: Thu Oct 26, 2006 4:23 pm
Projects: My Teacher; Songs of Araiah; Something new; Possible Cross Bomber?
Location: Slovakia, Kosice
Contact:

Re: Bug on loading modules / Bug on loading pyc/pyo from gam

#3 Post by Enerccio » Wed Mar 21, 2012 1:40 pm

Hmm, found another bug, at least for me, if I want to load empty .py file, I get error on this line:

Code: Select all

        source = load(filename).read().decode("utf8")
        if source[0] == u'\ufeff':
(loader.py 474)
Obviously, since empty file has no text, and having empty __init__.py is very common


PyTom wrote:
Enerccio wrote:
Moreover, only .py files will get loaded from game directory, not pyo nor pyc. So fix is to move them to renpy/ directory, but there, the importing is correct and package.module imports do not work anymore.
You really shouldn't distribute game code as a pyo or pyc file. If your game is run under a newer version of Ren'Py (for example, a version that uses Python 2.7), it will stop working if it can't recompile the pyo or pyc files.
Why is that an issue? Obviously we are not gonna store pyc files, we are only going to use them for the release. And people should not update renpy on their games as far as I know.
Attachments
f.rar
This wont work
(41.64 KiB) Downloaded 38 times
Image
http://www.bishojo.tk is technically ONLINE!
Songs of Araiah promo: http://www.youtube.com/watch?v=CalchucuoDU

User avatar
Enerccio
Miko-Class Veteran
Posts: 616
Joined: Thu Oct 26, 2006 4:23 pm
Projects: My Teacher; Songs of Araiah; Something new; Possible Cross Bomber?
Location: Slovakia, Kosice
Contact:

Re: Bug on loading modules / Bug on loading pyc/pyo from gam

#4 Post by Enerccio » Mon Dec 05, 2016 6:33 am

This is still not fixed?
Image
http://www.bishojo.tk is technically ONLINE!
Songs of Araiah promo: http://www.youtube.com/watch?v=CalchucuoDU

User avatar
PyTom
Ren'Py Creator
Posts: 15497
Joined: Mon Feb 02, 2004 10:58 am
Completed: Moonlight Walks
Projects: Ren'Py
IRC Nick: renpytom
Github: renpytom
itch: renpytom
Location: Kings Park, NY
Contact:

Re: Bug on loading modules / Bug on loading pyc/pyo from gam

#5 Post by PyTom » Mon Dec 05, 2016 9:23 pm

Relative imports should work, although absolute imports are preferred. And the \xfeff code only works for non-empty files.

We only support .py files, and not .pyc/.pyo files. This is because the version of Python bundled with Ren'Py can change, and that can cause compatibility problems with older bytecode files. To avoid this, Ren'Py only loads .pys.
Supporting creators since 2004
(When was the last time you backed up your game?)
"Do good work." - Virgil Ivan "Gus" Grissom
"Silly and fun things are important." - Elon Musk
Software > Drama • https://www.patreon.com/renpytom

User avatar
Enerccio
Miko-Class Veteran
Posts: 616
Joined: Thu Oct 26, 2006 4:23 pm
Projects: My Teacher; Songs of Araiah; Something new; Possible Cross Bomber?
Location: Slovakia, Kosice
Contact:

Re: Bug on loading modules / Bug on loading pyc/pyo from gam

#6 Post by Enerccio » Tue Dec 06, 2016 1:30 am

That makes no sense, if so, why do you support reading rpyc files? It's same deal (or are they completely backwards compatible?). User should not change version of python for a released game. Not only that, but loading pyo (and pyo only, not pyc) works if I move the library from game into root, which again makes no sense. Why not just read pyo from everywhere. Btw I am talking about custom library not renpy code. Also, in what world would make sense to change python from already released game?
Image
http://www.bishojo.tk is technically ONLINE!
Songs of Araiah promo: http://www.youtube.com/watch?v=CalchucuoDU

Post Reply

Who is online

Users browsing this forum: No registered users