[issue38860] GenericPyCData_new does not invoke new or init

2019-11-19 Thread Justin Capella


New submission from Justin Capella :

When subclassing the ctypes.Structure class, __new__ and __init__ are not 
invoked when using the inherited classmethod from_buffer_copy to create the 
object.

I think this is because tp_alloc is ultimately used by GenericPyCData_new when 
creating the object using the from_buffer_copy classmethod inherited from 
_CData.

https://github.com/python/cpython/blob/be143ec99674ba38c5811f34cdb85ef39c2dc8f8/Modules/_ctypes/_ctypes.c#L3202

Expected behavior: creation of Structure subclass object would invoke __new__ 
and possibly __init__.

--
components: ctypes
files: ctypesnew.py
messages: 357022
nosy: b1tninja
priority: normal
severity: normal
status: open
title: GenericPyCData_new does not invoke new or init
type: behavior
versions: Python 2.7, Python 3.5, Python 3.6, Python 3.7, Python 3.8, Python 3.9
Added file: https://bugs.python.org/file48723/ctypesnew.py

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



[issue38576] CVE-2019-18348: CRLF injection via the host part of the url passed to urlopen()

2019-11-20 Thread Justin Capella

Justin Capella  added the comment:

Can't see the specifics of that "restricted" redhat bug, but this was 
interesting bug and I wanted to ask if perhaps the domain in such cases should 
be IDN / punycoded ://xn--n28h.ws/ for example is ://💩.la

--
nosy: +b1tninja

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



[issue38860] GenericPyCData_new does not invoke new or init

2019-12-11 Thread Justin Capella


Justin Capella  added the comment:

It might make sense that CSimpleData types do not call init, which makes sense 
for _fields_ but it doesn't make sense to offer subclassing (of Structure) and 
not use the subclass, instead creating a type of the same name.

That test case is bugged, missing an underscore... The git blame wasn't 
"available" for that particular test but I would argue that it's testing for 
undocumented behavior :p

I wanted to be able to do assertions/initialization, I'm sure other people have 
expected from_buffer(_copy) et al would act as a class method, returning an 
instance of the subclass.

More generally, I think that GenericPyCData_new should not "tp_alloc"... What's 
_new about that?

My guess is there was at some level desire to "optimize" ctypes. If that does 
turn out to be the case I'd hope for a "unsimple" CData and ask that Structure 
be an instance of that.

Either way docs reflecting the behavior to Structure would be nice, I just hope 
it includes "prior to version" :p thanks for taking a look

--

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



[issue38860] GenericPyCData_new does not invoke new or init

2020-01-22 Thread Justin Capella


Justin Capella  added the comment:

Becca were you still interested in this issue? 

Anyone agree the unit test seems to have a bug if that is intended behavior?

Is there a better forum for discussion about design/behavior, maybe the more 
generic issue of GenericPyCData_new using tp_alloc instead of tp_new

--

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