Project

General

Profile

Bug #39919

compat ancien PicklableUpload vs bytes

Added by Frédéric Péters about 1 month ago. Updated about 1 month ago.

Status:
Solution déployée
Priority:
Normal
Target version:
-
Start date:
16 Feb 2020
Due date:
% Done:

0%

Patch proposed:
Yes
Planning:
No

Description


Exception:
  type = '<class 'TypeError'>', value = 'initial_value must be str or None, not bytes'

Stack trace (most recent call first):
  File "/usr/lib/python3/dist-packages/wcs/qommon/form.py", line 850, in __setstate__
   848         if hasattr(self, 'data'):
   849             # backward compatibility with older w.c.s. version
>  850             self.fp = StringIO(self.data)
   851             del self.data
   852

  locals:
     dict = {'data': b'\xff\xd8\xff\xe1\x00jExif\x00\x00MM\x00*\x00\x00\x00\x08\x00\x04\x01\x00\x00\x04\x00\x00\x00\x01\x00\x00\x10

(je trouve curieux qu'on passe encore par ce code)

0001-misc-use-bytes-in-compatibility-with-older-Picklable.patch View (1.16 KB) Frédéric Péters, 16 Feb 2020 10:59 AM

0001-portfolio-don-t-use-PicklableUpload-internals-39919.patch View (3.02 KB) Frédéric Péters, 16 Feb 2020 03:15 PM

Associated revisions

Revision fd2c6896 (diff)
Added by Frédéric Péters about 1 month ago

misc: use bytes in compatibility with older PicklableUpload (#39919)

Revision 5e796a27 (diff)
Added by Frédéric Péters about 1 month ago

portfolio: don't use PicklableUpload internals (#39919)

History

#1 Updated by Frédéric Péters about 1 month ago

#2 Updated by Benjamin Dauvergne about 1 month ago

Frédéric Péters a écrit :

[...]

(je trouve curieux qu'on passe encore par ce code)

Ça vient de portfolio :

   File "/usr/lib/python3/dist-packages/wcs/portfolio.py", line 138, in pick
   136             download = PicklableUpload(name, content_type='application/pdf')
   137             download.__setstate__({
>  138                 'data': document,
   139             })
   140             tempfile = get_session().add_tempfile(download)

Il faudrait peut-être ajouter cela à ton patch :

diff --git wcs/portfolio.py wcs/portfolio.py
index db56259a..a60a81c6 100644
--- wcs/portfolio.py
+++ wcs/portfolio.py
@@ -134,9 +134,7 @@ class FargoDirectory(Directory):
             name = urllib.unquote(path[-1])
             from .qommon.form import PicklableUpload
             download = PicklableUpload(name, content_type='application/pdf')
-            download.__setstate__({
-                'data': document,
-            })
+            download.receive([document])
             tempfile = get_session().add_tempfile(download)
             return self.set_token(tempfile.get('token'), name)
         else:

#3 Updated by Frédéric Péters about 1 month ago

Patch supplémentaire, pour utiliser .receive() et tester ce bout.

#4 Updated by Benjamin Dauvergne about 1 month ago

  • Status changed from Solution proposée to Solution validée

#5 Updated by Frédéric Péters about 1 month ago

  • Status changed from Solution validée to Résolu (à déployer)
commit 5e796a278984afaaa82ddd0bd88d0afb550a9feb
Author: Frédéric Péters <fpeters@entrouvert.com>
Date:   Sun Feb 16 15:10:55 2020 +0100

    portfolio: don't use PicklableUpload internals (#39919)

commit fd2c689626ab4c30a1306097bee918c15b8c01d2
Author: Frédéric Péters <fpeters@entrouvert.com>
Date:   Sun Feb 16 10:59:14 2020 +0100

    misc: use bytes in compatibility with older PicklableUpload (#39919)

#6 Updated by Frédéric Péters about 1 month ago

  • Status changed from Résolu (à déployer) to Solution déployée

Also available in: Atom PDF