[issue45127] Code objects can contain unmarshallable objects

2021-09-07 Thread Hai Shi


Change by Hai Shi :


--
nosy: +shihai1991

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue45127] Code objects can contain unmarshallable objects

2021-09-07 Thread Diego Ramirez


Change by Diego Ramirez :


--
nosy: +DiddiLeija

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue45127] Code objects can contain unmarshallable objects

2021-09-07 Thread Filipe Laíns

Change by Filipe Laíns :


--
nosy: +FFY00

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue45127] Code objects can contain unmarshallable objects

2021-09-07 Thread Petr Viktorin


Petr Viktorin  added the comment:

See also bpo-42839

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue45127] Code objects can contain unmarshallable objects

2021-09-07 Thread Petr Viktorin


Petr Viktorin  added the comment:

How to fix this? I guess:

* co_filename should be converted to an actual str, or reject subclasses with 
an exception
* for co_consts, the [marshal docs] could be updated to add code objects to 
"containers". The [code docs] already say co_consts "is a tuple containing the 
literals"; if someone's putting in non-literals they're voiding the warranty.

And so on for all other fields of code objects.

[marshal docs]: https://docs.python.org/3/library/marshal.html
[code docs]: https://docs.python.org/3.9/reference/datamodel.html#index-55

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue45127] Code objects can contain unmarshallable objects

2021-09-07 Thread Petr Viktorin


Change by Petr Viktorin :


Added file: https://bugs.python.org/file50269/reproducer_compileall.py

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue45127] Code objects can contain unmarshallable objects

2021-09-07 Thread Petr Viktorin


New submission from Petr Viktorin :

The `replace` method of `code` allows setting e.g.
* co_filename to a subclass of str
* co_consts to an arbitrary tuple
and possibly more weird cases.

This makes code objects unmarshallable.

One way to create such a code object is to call `compileall.compile_file` with 
a str subclass as path. See the attached reproducers.

This hit pip, see: https://github.com/pypa/pip/pull/10358#issuecomment-914320728

--
files: reproducer_replace.py
messages: 401277
nosy: petr.viktorin
priority: normal
severity: normal
status: open
title: Code objects can contain unmarshallable objects
Added file: https://bugs.python.org/file50268/reproducer_replace.py

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com