[SOLVED] Pickling error

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
Thundy
Regular
Posts: 88
Joined: Tue Dec 05, 2017 9:08 am
Contact:

[SOLVED] Pickling error

#1 Post by Thundy »

Hey alll. someone got this error whilst testing my game. Never seen this one before

Code: Select all

I'm sorry, but an uncaught exception occurred.

While running game code:
File "renpy/common/00action_file.rpy", line 361, in __call__
renpy.save(fn, extra_info=save_name)
PicklingError: Can't pickle : attribute lookup __builtin__.function failed

-- Full Traceback ------------------------------------------------------------

Full traceback:
File "renpy/common/_layout/screen_load_save.rpym", line 35, in script
$ ui.interact()
File "C:\Users\alessandro\Downloads\games\Deeper-0.0.38_Public-pc\renpy\ast.py", line 848, in execute
renpy.python.py_exec_bytecode(self.code.bytecode, self.hide, store=self.store)
File "C:\Users\alessandro\Downloads\games\Deeper-0.0.38_Public-pc\renpy\python.py", line 1812, in py_exec_bytecode
exec bytecode in globals, locals
File "renpy/common/_layout/screen_load_save.rpym", line 35, in
$ ui.interact()
File "C:\Users\alessandro\Downloads\games\Deeper-0.0.38_Public-pc\renpy\ui.py", line 287, in interact
rv = renpy.game.interface.interact(roll_forward=roll_forward, **kwargs)
File "C:\Users\alessandro\Downloads\games\Deeper-0.0.38_Public-pc\renpy\display\core.py", line 2624, in interact
repeat, rv = self.interact_core(preloads=preloads, trans_pause=trans_pause, **kwargs)
File "C:\Users\alessandro\Downloads\games\Deeper-0.0.38_Public-pc\renpy\display\core.py", line 3417, in interact_core
rv = root_widget.event(ev, x, y, 0)
File "C:\Users\alessandro\Downloads\games\Deeper-0.0.38_Public-pc\renpy\display\layout.py", line 986, in event
rv = i.event(ev, x - xo, y - yo, cst)
File "C:\Users\alessandro\Downloads\games\Deeper-0.0.38_Public-pc\renpy\display\transition.py", line 45, in event
return self.new_widget.event(ev, x, y, st) # E1101
File "C:\Users\alessandro\Downloads\games\Deeper-0.0.38_Public-pc\renpy\display\layout.py", line 986, in event
rv = i.event(ev, x - xo, y - yo, cst)
File "C:\Users\alessandro\Downloads\games\Deeper-0.0.38_Public-pc\renpy\display\layout.py", line 986, in event
rv = i.event(ev, x - xo, y - yo, cst)
File "C:\Users\alessandro\Downloads\games\Deeper-0.0.38_Public-pc\renpy\display\screen.py", line 667, in event
rv = self.child.event(ev, x, y, st)
File "C:\Users\alessandro\Downloads\games\Deeper-0.0.38_Public-pc\renpy\display\layout.py", line 986, in event
rv = i.event(ev, x - xo, y - yo, cst)
File "C:\Users\alessandro\Downloads\games\Deeper-0.0.38_Public-pc\renpy\display\layout.py", line 239, in event
rv = d.event(ev, x - xo, y - yo, st)
File "C:\Users\alessandro\Downloads\games\Deeper-0.0.38_Public-pc\renpy\display\layout.py", line 986, in event
rv = i.event(ev, x - xo, y - yo, cst)
File "C:\Users\alessandro\Downloads\games\Deeper-0.0.38_Public-pc\renpy\display\layout.py", line 239, in event
rv = d.event(ev, x - xo, y - yo, st)
File "C:\Users\alessandro\Downloads\games\Deeper-0.0.38_Public-pc\renpy\display\layout.py", line 986, in event
rv = i.event(ev, x - xo, y - yo, cst)
File "C:\Users\alessandro\Downloads\games\Deeper-0.0.38_Public-pc\renpy\display\layout.py", line 239, in event
rv = d.event(ev, x - xo, y - yo, st)
File "C:\Users\alessandro\Downloads\games\Deeper-0.0.38_Public-pc\renpy\display\behavior.py", line 897, in event
return handle_click(self.clicked)
File "C:\Users\alessandro\Downloads\games\Deeper-0.0.38_Public-pc\renpy\display\behavior.py", line 832, in handle_click
rv = run(action)
File "C:\Users\alessandro\Downloads\games\Deeper-0.0.38_Public-pc\renpy\display\behavior.py", line 306, in run
return action(*args, **kwargs)
File "renpy/common/00action_file.rpy", line 361, in __call__
renpy.save(fn, extra_info=save_name)
File "C:\Users\alessandro\Downloads\games\Deeper-0.0.38_Public-pc\renpy\loadsave.py", line 402, in save
dump((roots, renpy.game.log), logf)
File "C:\Users\alessandro\Downloads\games\Deeper-0.0.38_Public-pc\renpy\loadsave.py", line 46, in dump
cPickle.dump(o, f, cPickle.HIGHEST_PROTOCOL)
PicklingError: Can't pickle : attribute lookup __builtin__.function failed

Windows-8-6.2.9200
Ren'Py 6.99.14.1.3218
Deeper 0.0.38_Public
Fri Apr 13 21:13:17 2018
Any ideas?
Last edited by Thundy on Sat Apr 14, 2018 2:47 am, edited 1 time in total.

User avatar
Remix
Eileen-Class Veteran
Posts: 1628
Joined: Tue May 30, 2017 6:10 am
Completed: None... yet (as I'm still looking for an artist)
Projects: An un-named anime based trainer game
Contact:

Re: Pickling error

#2 Post by Remix »

A tricky one to trace if it only occurs on one machine and not all. As a preliminary check:

Have you defined any new python Classes in your game or import any external libraries? Do all those classes inherit from object?
Are you manipulating the store anywhere and do all the items placed in it support __setstate__ if needed?

As guesswork from the traceback too; Are you overloading the name 'function' anywhere? (as a variable, function, method or class attribute)
Frameworks & Scriptlets:

Thundy
Regular
Posts: 88
Joined: Tue Dec 05, 2017 9:08 am
Contact:

Re: Pickling error

#3 Post by Thundy »

Hi Remix. I have a lot of classes but all inherit from object. I do import a couple of libraries such as OS. I will post the code for my class declarations in the morning if it is any use.

User avatar
Remix
Eileen-Class Veteran
Posts: 1628
Joined: Tue May 30, 2017 6:10 am
Completed: None... yet (as I'm still looking for an artist)
Projects: An un-named anime based trainer game
Contact:

Re: Pickling error

#4 Post by Remix »

os, sys, subprocess, io are all basically part of renpy (along with the extras detailed in renpy/bootstrap) and should not cause problems unless a saved variable or attribute directly references them.

Can you replicate the error on your own system?
Does setting:

Code: Select all

init python:
    config.use_cpickle = False
solve it? (or at least provide a better traceback?)
Frameworks & Scriptlets:

Thundy
Regular
Posts: 88
Joined: Tue Dec 05, 2017 9:08 am
Contact:

Re: Pickling error

#5 Post by Thundy »

Hi remix

so here is the new traceback.

Code: Select all

[code]
I'm sorry, but an uncaught exception occurred.

While running game code:
  File "renpy/common/00action_file.rpy", line 361, in __call__
    renpy.save(fn, extra_info=save_name)
PicklingError: Can't pickle <function pretyName at 0x06D798B0>: it's not the same object as store.pretyName

-- Full Traceback ------------------------------------------------------------

Full traceback:
  File "renpy/common/_layout/screen_load_save.rpym", line 35, in script
    $ ui.interact()
  File "D:\Development\Renpy\renpy-6.99.13-sdk\renpy\ast.py", line 848, in execute
    renpy.python.py_exec_bytecode(self.code.bytecode, self.hide, store=self.store)
  File "D:\Development\Renpy\renpy-6.99.13-sdk\renpy\python.py", line 1812, in py_exec_bytecode
    exec bytecode in globals, locals
  File "renpy/common/_layout/screen_load_save.rpym", line 35, in <module>
    $ ui.interact()
  File "D:\Development\Renpy\renpy-6.99.13-sdk\renpy\ui.py", line 287, in interact
    rv = renpy.game.interface.interact(roll_forward=roll_forward, **kwargs)
  File "D:\Development\Renpy\renpy-6.99.13-sdk\renpy\display\core.py", line 2624, in interact
    repeat, rv = self.interact_core(preloads=preloads, trans_pause=trans_pause, **kwargs)
  File "D:\Development\Renpy\renpy-6.99.13-sdk\renpy\display\core.py", line 3417, in interact_core
    rv = root_widget.event(ev, x, y, 0)
  File "D:\Development\Renpy\renpy-6.99.13-sdk\renpy\display\layout.py", line 986, in event
    rv = i.event(ev, x - xo, y - yo, cst)
  File "D:\Development\Renpy\renpy-6.99.13-sdk\renpy\display\transition.py", line 45, in event
    return self.new_widget.event(ev, x, y, st)  # E1101
  File "D:\Development\Renpy\renpy-6.99.13-sdk\renpy\display\layout.py", line 986, in event
    rv = i.event(ev, x - xo, y - yo, cst)
  File "D:\Development\Renpy\renpy-6.99.13-sdk\renpy\display\layout.py", line 986, in event
    rv = i.event(ev, x - xo, y - yo, cst)
  File "D:\Development\Renpy\renpy-6.99.13-sdk\renpy\display\screen.py", line 667, in event
    rv = self.child.event(ev, x, y, st)
  File "D:\Development\Renpy\renpy-6.99.13-sdk\renpy\display\layout.py", line 986, in event
    rv = i.event(ev, x - xo, y - yo, cst)
  File "D:\Development\Renpy\renpy-6.99.13-sdk\renpy\display\layout.py", line 239, in event
    rv = d.event(ev, x - xo, y - yo, st)
  File "D:\Development\Renpy\renpy-6.99.13-sdk\renpy\display\layout.py", line 986, in event
    rv = i.event(ev, x - xo, y - yo, cst)
  File "D:\Development\Renpy\renpy-6.99.13-sdk\renpy\display\layout.py", line 986, in event
    rv = i.event(ev, x - xo, y - yo, cst)
  File "D:\Development\Renpy\renpy-6.99.13-sdk\renpy\display\behavior.py", line 897, in event
    return handle_click(self.clicked)
  File "D:\Development\Renpy\renpy-6.99.13-sdk\renpy\display\behavior.py", line 832, in handle_click
    rv = run(action)
  File "D:\Development\Renpy\renpy-6.99.13-sdk\renpy\display\behavior.py", line 299, in run
    new_rv = run(i, *args, **kwargs)
  File "D:\Development\Renpy\renpy-6.99.13-sdk\renpy\display\behavior.py", line 306, in run
    return action(*args, **kwargs)
  File "renpy/common/00action_file.rpy", line 361, in __call__
    renpy.save(fn, extra_info=save_name)
  File "D:\Development\Renpy\renpy-6.99.13-sdk\renpy\loadsave.py", line 402, in save
    dump((roots, renpy.game.log), logf)
  File "D:\Development\Renpy\renpy-6.99.13-sdk\renpy\loadsave.py", line 48, in dump
    pickle.dump(o, f, pickle.HIGHEST_PROTOCOL)
  File "/home/tom/ab/x64lucid-deps/install/lib/python2.7/pickle.py", line 1370, in dump
  File "/home/tom/ab/x64lucid-deps/install/lib/python2.7/pickle.py", line 224, in dump
  File "/home/tom/ab/x64lucid-deps/install/lib/python2.7/pickle.py", line 286, in save
  File "/home/tom/ab/x64lucid-deps/install/lib/python2.7/pickle.py", line 548, in save_tuple
  File "/home/tom/ab/x64lucid-deps/install/lib/python2.7/pickle.py", line 331, in save
  File "/home/tom/ab/x64lucid-deps/install/lib/python2.7/pickle.py", line 419, in save_reduce
  File "/home/tom/ab/x64lucid-deps/install/lib/python2.7/pickle.py", line 286, in save
  File "/home/tom/ab/x64lucid-deps/install/lib/python2.7/pickle.py", line 649, in save_dict
  File "/home/tom/ab/x64lucid-deps/install/lib/python2.7/pickle.py", line 681, in _batch_setitems
  File "/home/tom/ab/x64lucid-deps/install/lib/python2.7/pickle.py", line 286, in save
  File "/home/tom/ab/x64lucid-deps/install/lib/python2.7/pickle.py", line 600, in save_list
  File "/home/tom/ab/x64lucid-deps/install/lib/python2.7/pickle.py", line 633, in _batch_appends
  File "/home/tom/ab/x64lucid-deps/install/lib/python2.7/pickle.py", line 331, in save
  File "/home/tom/ab/x64lucid-deps/install/lib/python2.7/pickle.py", line 419, in save_reduce
  File "/home/tom/ab/x64lucid-deps/install/lib/python2.7/pickle.py", line 286, in save
  File "/home/tom/ab/x64lucid-deps/install/lib/python2.7/pickle.py", line 649, in save_dict
  File "/home/tom/ab/x64lucid-deps/install/lib/python2.7/pickle.py", line 681, in _batch_setitems
  File "/home/tom/ab/x64lucid-deps/install/lib/python2.7/pickle.py", line 286, in save
  File "/home/tom/ab/x64lucid-deps/install/lib/python2.7/pickle.py", line 649, in save_dict
  File "/home/tom/ab/x64lucid-deps/install/lib/python2.7/pickle.py", line 681, in _batch_setitems
  File "/home/tom/ab/x64lucid-deps/install/lib/python2.7/pickle.py", line 286, in save
  File "/home/tom/ab/x64lucid-deps/install/lib/python2.7/pickle.py", line 649, in save_dict
  File "/home/tom/ab/x64lucid-deps/install/lib/python2.7/pickle.py", line 681, in _batch_setitems
  File "/home/tom/ab/x64lucid-deps/install/lib/python2.7/pickle.py", line 286, in save
  File "/home/tom/ab/x64lucid-deps/install/lib/python2.7/pickle.py", line 753, in save_global
PicklingError: Can't pickle <function pretyName at 0x06D798B0>: it's not the same object as store.pretyName

Windows-8-6.2.9200
Ren'Py 6.99.14.1.3218
Deeper 0.0.38_Patron
Sat Apr 14 07:20:54 2018
[/code]

Thundy
Regular
Posts: 88
Joined: Tue Dec 05, 2017 9:08 am
Contact:

Re: Pickling error

#6 Post by Thundy »

I discovered the issue once i had my epiphany. I had defined a function called PrettyName (which i renamed pretyName during fault finding) which i inadvertantly called during parsing my xml file as a variable. Silly me!

User avatar
Remix
Eileen-Class Veteran
Posts: 1628
Joined: Tue May 30, 2017 6:10 am
Completed: None... yet (as I'm still looking for an artist)
Projects: An un-named anime based trainer game
Contact:

Re: [SOLVED] Pickling error

#7 Post by Remix »

Well done on fixing it. The cPickle False traceback is a lot more useful I see :)
Frameworks & Scriptlets:

Post Reply

Who is online

Users browsing this forum: Imperf3kt