msg154778 - (view) |
Author: Antoine Pitrou (pitrou) *  |
Date: 2012-03-02 16:25 |
>>> marshal.loads('T') True >>> marshal.loads(b'T') True Contrast with: >>> marshal.load(io.BytesIO(b'T')) True >>> marshal.load(io.StringIO('T')) Traceback (most recent call last): File "", line 1, in TypeError: f.read() returned not bytes but str |
|
|
msg154809 - (view) |
Author: Guilherme Gonçalves (guilherme-pg) |
Date: 2012-03-02 23:49 |
The attached patch attempts to solve the issue. It makes sure marshal.loads only accepts objects conforming to the buffer protocol, updates the documentation for the method accordingly, adds a test case and updates existing test cases that rely on this issue. Please excuse any obvious mistakes in the patch, this is my first contribution and I'll be glad to iterate until it's good. |
|
|
msg154816 - (view) |
Author: Antoine Pitrou (pitrou) *  |
Date: 2012-03-03 00:59 |
Thank you. The patch looks almost perfect, just one nit: apparently you changed the documentation for marshal.dumps. Is that intended? |
|
|
msg154818 - (view) |
Author: Guilherme Gonçalves (guilherme-pg) |
Date: 2012-03-03 01:18 |
Oops, sorry, that was unintended. I uploaded a new version of the patch with the correct documentation update, making it explicit that loads() expects a bytes object. |
|
|
msg154819 - (view) |
Author: Antoine Pitrou (pitrou) *  |
Date: 2012-03-03 01:31 |
Thank you! What is your full name, for credits? |
|
|
msg154820 - (view) |
Author: Guilherme Gonçalves (guilherme-pg) |
Date: 2012-03-03 01:36 |
Guilherme Gonçalves <guilherme.p.gonc@gmail.com> Thanks for the quick review. |
|
|
msg154821 - (view) |
Author: Roundup Robot (python-dev)  |
Date: 2012-03-03 01:44 |
New changeset 4966907d3661 by Antoine Pitrou in branch '3.2': Issue #14177: marshal.loads() now raises TypeError when given an unicode string. http://hg.python.org/cpython/rev/4966907d3661 New changeset e67b3a9bd2dc by Antoine Pitrou in branch 'default': - Issue #14177: marshal.loads() now raises TypeError when given an unicode http://hg.python.org/cpython/rev/e67b3a9bd2dc |
|
|
msg154822 - (view) |
Author: Antoine Pitrou (pitrou) *  |
Date: 2012-03-03 01:47 |
I've committed the patch in 3.2 and 3.3. |
|
|