Code Monkey home page Code Monkey logo

Comments (10)

CensoredUsername avatar CensoredUsername commented on August 9, 2024 1

Should be in dev now.

from unrpyc.

CensoredUsername avatar CensoredUsername commented on August 9, 2024

Ah, I have an idea what the issue is, I'll look at it.

from unrpyc.

madeddy avatar madeddy commented on August 9, 2024

Very good.
I checked pickle_Pickler and the supposedly missing method is there. Same in the c module, as far as my understanding there goes. I draw a blank with this. If you have it, i would appreciate a short explanation.

from unrpyc.

CensoredUsername avatar CensoredUsername commented on August 9, 2024

The one in the c module is only an internal c function. It doesn't export it as a method on the Pickler object. That's why you don't see it.

>>> _pickle.Pickler.save_global
AttributeError: type object '_pickle.Pickler' has no attribute 'save_global'

Outside of that, calling it with a pack kwarg is an internal py2 thing that we shouldn't be doing to begin with as well.

I think the fixed code would be:

    def save_global(self, obj, name=None, pack=struct.pack):
        if isinstance(obj, FakeClassType):
            if PY2:
                self.write(pickle.GLOBAL + obj.__module__ + '\n' + obj.__name__ + '\n')
            elif self.proto >= 4:
                self.save(obj.__module__)
                self.save(obj.__name__)
                self.write(pickle.STACK_GLOBAL)
            else:
                self.write(pickle.GLOBAL +
                    (obj.__module__ + '\n' + obj.__name__ + '\n').decode("utf-8")
                )
            self.memoize(obj)
            return

        super().save_global(obj, name)

Please try that out, as I was unable to reproduce the error (likely needs your branch on tl works).

from unrpyc.

madeddy avatar madeddy commented on August 9, 2024

likely needs your branch on tl works

Ah no. I tested with a clean version of current dev and master. Now with just the two fixes from above:

Error while decompiling /home/olli/.xlib/RPG/_test/OurBrightDays-0.1.3-pc/game/tl/english/scripts/00parts/01arrival/03script/script.rpyc:
Traceback (most recent call last):
File "/home/olli/Code/Git/unrpyc/unrpyc.py", line 218, in worker
return extract_translations(filename, args.language)
File "/home/olli/Code/Git/unrpyc/unrpyc.py", line 177, in extract_translations
return pickle_safe_dumps(translator.dialogue), translator.strings
File "/home/olli/Code/Git/unrpyc/decompiler/renpycompat.py", line 168, in pickle_safe_dumps
return magic.safe_dumps(buffer)
File "/home/olli/Code/Git/unrpyc/decompiler/magic.py", line 639, in safe_dumps
SafePickler(file, protocol).dump(obj)
File "/usr/lib/python3.10/pickle.py", line 487, in dump
self.save(obj)
File "/usr/lib/python3.10/pickle.py", line 560, in save
f(self, obj)  # Call unbound method with explicit self
File "/usr/lib/python3.10/pickle.py", line 972, in save_dict
self._batch_setitems(obj.items())
File "/usr/lib/python3.10/pickle.py", line 998, in _batch_setitems
save(v)
File "/usr/lib/python3.10/pickle.py", line 560, in save
f(self, obj)  # Call unbound method with explicit self
File "/usr/lib/python3.10/pickle.py", line 932, in save_list
self._batch_appends(obj)
File "/usr/lib/python3.10/pickle.py", line 959, in _batch_appends
save(tmp[0])
File "/usr/lib/python3.10/pickle.py", line 603, in save
self.save_reduce(obj=obj, *rv)
File "/usr/lib/python3.10/pickle.py", line 717, in save_reduce
save(state)
File "/usr/lib/python3.10/pickle.py", line 560, in save
f(self, obj)  # Call unbound method with explicit self
File "/usr/lib/python3.10/pickle.py", line 972, in save_dict
self._batch_setitems(obj.items())
File "/usr/lib/python3.10/pickle.py", line 998, in _batch_setitems
save(v)
File "/usr/lib/python3.10/pickle.py", line 603, in save
self.save_reduce(obj=obj, *rv)
File "/usr/lib/python3.10/pickle.py", line 717, in save_reduce
save(state)
File "/usr/lib/python3.10/pickle.py", line 560, in save
f(self, obj)  # Call unbound method with explicit self
File "/usr/lib/python3.10/pickle.py", line 972, in save_dict
self._batch_setitems(obj.items())
File "/usr/lib/python3.10/pickle.py", line 998, in _batch_setitems
save(v)
File "/usr/lib/python3.10/pickle.py", line 603, in save
self.save_reduce(obj=obj, *rv)
File "/usr/lib/python3.10/pickle.py", line 691, in save_reduce
save(func)
File "/usr/lib/python3.10/pickle.py", line 560, in save
f(self, obj)  # Call unbound method with explicit self
File "/usr/lib/python3.10/pickle.py", line 1129, in save_type
return self.save_global(obj)
File "/home/olli/Code/Git/unrpyc/decompiler/magic.py", line 555, in save_global
super().save_global(obj, name)
File "/usr/lib/python3.10/pickle.py", line 1071, in save_global
raise PicklingError(
_pickle.PicklingError: Can't pickle <class '__builtin__.oldset'>: it's not found as __builtin__.oldset

Edit: I tested with two other games with translations(no others for renpy8 in my stash) and NO errors at all. With the new fixes AND without. Strange. Could it be a issue with this one game?

from unrpyc.

CensoredUsername avatar CensoredUsername commented on August 9, 2024

Huh. I tested it with the files you posted and couldn't reproduce the error to begin with (that said, the errors were fairly obvious when I looked at it).

_pickle.PicklingError: Can't pickle <class 'builtin.oldset'>: it's not found as builtin.oldset

Oh bloody hell, need to add a reduce impl to oldset/oldfrozenset as well.

from unrpyc.

CensoredUsername avatar CensoredUsername commented on August 9, 2024

Does this fix it (in renpycompat.py):

class oldset(set):
    __module__ = "__builtin__"

    def __reduce__(self):
        cls, args, state = super().__reduce__()
        return (set, args, state)
class oldfrozenset(frozenset):
    __module__ = "__builtin__"

    def __reduce__(self):
        cls, args, state = super().__reduce__()
        return (frozenset, args, state)

from unrpyc.

madeddy avatar madeddy commented on August 9, 2024

Looks like that did it. Thanks!
Will test some with it like this and get back to you here.

Edit:Packed your fixes in a branch. Removed also the pack parameter from save_global as i figured its unneeded.
dev-magic_savepickler_fix

from unrpyc.

CensoredUsername avatar CensoredUsername commented on August 9, 2024

Removed also the pack parameter from save_global as i figured its unneeded.

It's in there due to python 2, where that is the signature of the method it's overriding. Strangely nothing there uses it either, but it can't hurt for compat to keep it in.

from unrpyc.

madeddy avatar madeddy commented on August 9, 2024

Yes, i figured. With unneeded i meant py3 and i thought we need maybe a version switch for the diff py versions, as py3 does not have the pack para anymore.

from unrpyc.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.