[Fixed in Ren'Py 6.15] lists are not of type list

Discuss how to use the Ren'Py engine to create visual novels and story-based games. New releases are announced in this section.
Forum rules
This is the right place for Ren'Py help. Please ask one question per thread, use a descriptive subject like 'NotFound error in option.rpy' , and include all the relevant information - especially any relevant code and traceback messages. Use the code tag to format scripts.
Post Reply
Message
Author
User avatar
Ayutac
Regular
Posts: 150
Joined: Thu Oct 18, 2012 2:23 pm
Projects: Pokémon Dating Sim
Organization: A Breeze Of Science
Deviantart: Ubro
Location: Mayence, Germany
Contact:

[Fixed in Ren'Py 6.15] lists are not of type list

#1 Post by Ayutac » Sat Feb 02, 2013 12:26 pm

Hey there, check out this code:

Code: Select all

label start:
    
    python:
        chars = [0, 1]
        chars = 1 * chars
        chars.append(3)
        narrator(str(type(chars)))
        if isinstance(chars, list):
            narrator("instance list")
        if type(chars) == list:
            narrator("type list")
The code doesn't jump in any condition but the first narrator returns:

Code: Select all

<type 'list'>
What's wrong, how can I check for a list?

I'm especially sad about this because I rewrote my core code for three days and now I can't go on with the debugging.
(And yes, I actually do type checks in python.)
Last edited by Ayutac on Sat Feb 09, 2013 10:46 am, edited 2 times in total.
Up next: An original, open source, text-based Dating Sim. Stay tuned ;)

Kinsman
Regular
Posts: 130
Joined: Sun Jul 26, 2009 7:07 pm
Location: Fredericton, NB, Canada
Contact:

Re: lists are not of type list )-;

#2 Post by Kinsman » Sat Feb 02, 2013 1:56 pm

If you remove the line

Code: Select all

chars = 1 * chars
you'll find that Ren'py reports chars as being a "RevertableList", but then every type check will work successfully.

I think Ren'Py is adding wrappers to the standard types in order to give them the ability to rollback. The wrapper is almost perfect, but the operation of multiplying the list by an integer fell through the cracks, changing the RevertableList into an ordinary list, and confusing Ren'Py.

Let PyTom know about the problem with multiplying lists, and if you need to multiply, use a loop and multiply each item.
Flash To Ren'Py Exporter
See the Cookbook thread

User avatar
Ayutac
Regular
Posts: 150
Joined: Thu Oct 18, 2012 2:23 pm
Projects: Pokémon Dating Sim
Organization: A Breeze Of Science
Deviantart: Ubro
Location: Mayence, Germany
Contact:

Re: lists are not of type list )-;

#3 Post by Ayutac » Sat Feb 02, 2013 3:31 pm

Kinsman wrote:and if you need to multiply, use a loop and multiply each item.
would be an option, as well as using tuples because my methods accept them too. Tuples have no renpy-specific type, they are just of type 'tuple'.

I wonder more why the type check for a normal list doesn't work at all. I just checked the isinstance-if with a python console (python 2.7.3), but that works just fine. My Ren'Py is up to date.
Up next: An original, open source, text-based Dating Sim. Stay tuned ;)

User avatar
PyTom
Ren'Py Creator
Posts: 15893
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: lists are not of type list (Ren'Py bug?)

#4 Post by PyTom » Fri Feb 08, 2013 11:42 pm

This is fixed in this commit, which will be in 6.15.

https://github.com/renpy/renpy/commit/8 ... ea50f2f94b
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
Ayutac
Regular
Posts: 150
Joined: Thu Oct 18, 2012 2:23 pm
Projects: Pokémon Dating Sim
Organization: A Breeze Of Science
Deviantart: Ubro
Location: Mayence, Germany
Contact:

Re: lists are not of type list (Ren'Py bug?)

#5 Post by Ayutac » Sat Feb 09, 2013 2:19 am

Thank you very much!
Up next: An original, open source, text-based Dating Sim. Stay tuned ;)

Post Reply

Who is online

Users browsing this forum: Google [Bot], _ticlock_