<div dir="ltr"><div class="gmail_default" style="font-family:georgia,serif"><font size="2">A couple of ideas here:<br></font></div><div class="gmail_default" style="font-family:georgia,serif"><font size="2"><a href="https://stackoverflow.com/questions/54047757/unpickle-binary-file-to-text/54048296#54048296">https://stackoverflow.com/questions/54047757/unpickle-binary-file-to-text/54048296#54048296</a></font></div><div class="gmail_default" style="font-family:georgia,serif"><font size="2">Maybe you could take it from there? <br></font></div><div class="gmail_default" style="font-family:georgia,serif;font-size:large"><font size="2">Tom</font><br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Tue, Oct 26, 2021 at 6:12 PM RoadrunnerWMC <<a href="mailto:roadrunnerwmc@gmail.com">roadrunnerwmc@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr">(Just adding this to the mailing list, if you don't mind)<br><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">---------- Forwarded message ---------<br>From: <strong class="gmail_sendername" dir="auto">Nicola Raffo</strong> <span dir="auto"><<a href="mailto:nicola.raffo@rulex.ai" target="_blank">nicola.raffo@rulex.ai</a>></span><br>Date: Tue, Oct 26, 2021 at 11:15 AM<br>Subject: Re: PyQt from py27 to py38<br>To: RoadrunnerWMC <<a href="mailto:roadrunnerwmc@gmail.com" target="_blank">roadrunnerwmc@gmail.com</a>><br></div><br><br>




<div dir="ltr">
<div style="font-family:Calibri,Arial,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
Similar scenario here, I have to deal with some data stored with pickled PyQt4 objects. The pickletools method can be useful to "read" the pickled data, but I need a conversion from PyQt4 to PyQt5 data in order to be able to load the data in Python 3.8 and
 whitout a proper method to do it I can't depickle data in Python 3.8.</div>
<div style="font-family:Calibri,Arial,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
<br>
</div>
<div style="font-family:Calibri,Arial,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
Another idea could be to use the previous version of the code which still uses python 2.7 and to store them in another format, but this could take a long time.</div>
<div style="font-family:Calibri,Arial,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
<br>
</div>
<div style="font-family:Calibri,Arial,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
What I need is a tool that allows me to automatically read and open these data in Python 3.8</div>
<div id="gmail-m_-5768338421949475074m_-7604932747331470930m_7624132110726387732appendonsend"></div>
<hr style="display:inline-block;width:98%">
<div id="gmail-m_-5768338421949475074m_-7604932747331470930m_7624132110726387732divRplyFwdMsg" dir="ltr"><font style="font-size:11pt" face="Calibri, sans-serif" color="#000000"><b>From:</b> RoadrunnerWMC <<a href="mailto:roadrunnerwmc@gmail.com" target="_blank">roadrunnerwmc@gmail.com</a>><br>
<b>Sent:</b> 26 October 2021 17:06<br>
<b>To:</b> Florian Bruhin <<a href="mailto:me@the-compiler.org" target="_blank">me@the-compiler.org</a>><br>
<b>Cc:</b> <a href="mailto:pyqt@riverbankcomputing.com" target="_blank">pyqt@riverbankcomputing.com</a> <<a href="mailto:pyqt@riverbankcomputing.com" target="_blank">pyqt@riverbankcomputing.com</a>><br>
<b>Subject:</b> Re: PyQt from py27 to py38</font>
<div> </div>
</div>
<div>
<div dir="ltr">The pickletools method is at least doable for relatively simple pickles -- I have an application that does exactly that because another developer made the less-than-wise decision to store pickled PyQt4 objects in user data files a long time ago,
 and now I have to support reading them forever. The main downside is that you have to make a lot of assumptions about the structure of the pickle data, ones which technically don't
<i>need</i> to always be true, but <i>should</i> nevertheless be safe if your users are all using CPython and not manually messing with the generated pickle data for some reason.
<div><br>
</div>
<div>There is another option, too, which is to make a minimal fake "PyQt4" interface (just a few nearly-empty class stubs) and have pickle load using that. I chose the pickletools method because of the additional security benefits of avoiding using <font face="monospace">pickle.loads()</font>
 on untrusted user data files.</div>
</div>
<br>
<div>
<div dir="ltr">On Tue, Oct 26, 2021 at 8:58 AM Florian Bruhin <<a href="mailto:me@the-compiler.org" target="_blank">me@the-compiler.org</a>> wrote:<br>
</div>
<blockquote style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
On Tue, Oct 26, 2021 at 11:47:40AM +0200, Florian Bruhin wrote:<br>
> The harder way is to somehow coerce pickle into giving you the "raw"<br>
> data without the PyQt object involved...<br>
<br>
I just learned there's 'pickletools' in the stdlib:<br>
<a href="https://nam12.safelinks.protection.outlook.com/?url=https%3A%2F%2Fdocs.python.org%2F3%2Flibrary%2Fpickletools.html&data=04%7C01%7Cnicola.raffo%40rulex.ai%7C74001822c1bd4a9803f308d998924bf9%7Ccb4c9caf154d430fade0c36c8af22d19%7C0%7C0%7C637708576448192165%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=rJY1OaBWAhzGQtPg9t%2BFsHUBVfL%2BkWiOBv%2BdLUt%2Bung%3D&reserved=0" rel="noreferrer" target="_blank">https://docs.python.org/3/library/pickletools.html</a><br>
<br>
Using that, you could inspect the pickle manually and pick the data out<br>
of it somehow. Given how pickles are structured, not exactly<br>
straightfoward either, though.<br>
<br>
Florian<br>
<br>
-- <br>
            <a href="mailto:me@the-compiler.org" target="_blank">me@the-compiler.org</a> |
<a href="https://nam12.safelinks.protection.outlook.com/?url=https%3A%2F%2Fwww.qutebrowser.org%2F&data=04%7C01%7Cnicola.raffo%40rulex.ai%7C74001822c1bd4a9803f308d998924bf9%7Ccb4c9caf154d430fade0c36c8af22d19%7C0%7C0%7C637708576448202160%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=Gishrgq9fMSZxHWbgd%2FhzjSkxSYMHBh4l%2BK%2BxtigbaM%3D&reserved=0" rel="noreferrer" target="_blank">
https://www.qutebrowser.org</a> <br>
       <a href="https://nam12.safelinks.protection.outlook.com/?url=https%3A%2F%2Fbruhin.software%2F&data=04%7C01%7Cnicola.raffo%40rulex.ai%7C74001822c1bd4a9803f308d998924bf9%7Ccb4c9caf154d430fade0c36c8af22d19%7C0%7C0%7C637708576448202160%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=frNp1rYRFTIQJvfh5osGkE9sfYeFiMPNdza%2FzNPXlBg%3D&reserved=0" rel="noreferrer" target="_blank">https://bruhin.software/</a>
 | <a href="https://nam12.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fsponsors%2FThe-Compiler%2F&data=04%7C01%7Cnicola.raffo%40rulex.ai%7C74001822c1bd4a9803f308d998924bf9%7Ccb4c9caf154d430fade0c36c8af22d19%7C0%7C0%7C637708576448212149%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=zbjyjeolMxleTkjhEHnJTNjEx1FQh9fDhtpESSh8MOw%3D&reserved=0" rel="noreferrer" target="_blank">
https://github.com/sponsors/The-Compiler/</a><br>
       GPG: 916E B0C8 FD55 A072 | <a href="https://nam12.safelinks.protection.outlook.com/?url=https%3A%2F%2Fthe-compiler.org%2Fpubkey.asc&data=04%7C01%7Cnicola.raffo%40rulex.ai%7C74001822c1bd4a9803f308d998924bf9%7Ccb4c9caf154d430fade0c36c8af22d19%7C0%7C0%7C637708576448212149%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=SBE0XKDRP9mesVkx8UdAHWikuyV25ppqc8BnQvFQPEA%3D&reserved=0" rel="noreferrer" target="_blank">
https://the-compiler.org/pubkey.asc</a><br>
             I love long mails! | <a href="https://nam12.safelinks.protection.outlook.com/?url=https%3A%2F%2Femail.is-not-s.ms%2F&data=04%7C01%7Cnicola.raffo%40rulex.ai%7C74001822c1bd4a9803f308d998924bf9%7Ccb4c9caf154d430fade0c36c8af22d19%7C0%7C0%7C637708576448222143%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=k1E7hVrZc0t%2B19DwXHNbXD2MPc3eJ%2FzGdcR7EluTJE0%3D&reserved=0" rel="noreferrer" target="_blank">
https://email.is-not-s.ms/</a><br>
</blockquote>
</div>
</div>
<p style="margin:0px 0px 0px 10px;font-size:10pt;font-family:"Verdana"">--</p>
<p style="margin:3px 0px 0px 10px;font-size:10pt;font-family:"Verdana""><strong>Nicola Raffo</strong></p>
<p style="margin:3px 0px 0px 10px;font-size:10pt;font-family:"Verdana"">Senior Product Development Specialist</p>
<p style="margin:10px 0px 0px 10px;font-size:18pt;font-family:"Verdana""><a href="https://rulex.ai" style="text-decoration:none" target="_blank"><span style="color:rgb(0,115,198);font-weight:bold">Rule</span><span style="color:rgb(101,217,142);font-weight:bold">X</span></a></p>
<p style="margin:10px 0px 0px 10px;font-size:7.5pt;font-family:"Verdana"">+39 010 8050 190<br>
</p>
<p style="margin:3px 0px 0px 10px;font-size:7.5pt;font-family:"Verdana""><a></a></p>
<p style="margin:10px 0px 0px 10px;font-size:7.5pt;width:400px;text-align:justify;font-family:"Verdana"">
PLEASE NOTE: This e-mail and any attachments may be confidential or privileged and is intended solely for the addressee(s). Do not share or use without Rulex's approval. If received in error, please contact the sender and delete the email and any attachments.</p>

</div>

</div></div>
</blockquote></div>