Skip to contentSkip to conversation

Python 3.10 again: _Py_fopen deprecated

Cocci Richard W.M. Jones 3 participants 4 messages Jan 5, 2021 – Jan 9, 2021

lore
Share & tools
lore
#0 lore raw

Firstly a gentle reminder that there's a patch waiting to be applied:
https://systeme.lip6.fr/pipermail/cocci/2020-November/thread.html#8398

Different from that patch, but still related to Python 3.10, we've got another bug report here:
https://bugzilla.redhat.com/show_bug.cgi?id=1912931

This time _Py_fopen has been deprecated, replaced by _Py_wfopen or _Py_fopen_obj. It's unclear which is better. The two functions are documented here:
https://github.com/python/cpython/blob/master/Python/fileutils.c#L1418

What I don't understand from the pyxml code is why we use these internal Python functions at all, instead of calling regular C functions like fopen etc. In fact it seems like for Python 2 we did call fopen ...

Rich.

Signature · 10 lines
Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones
Read my programming and virtualization blog: http://rwmj.wordpress.com
Fedora Windows cross-compiler. Compile Windows programs, test, and
build Windows installers. Over 100 libraries supported.
http://fedoraproject.org/wiki/MinGW

_______________________________________________
Cocci mailing list
[email protected]
https://systeme.lip6.fr/mailman/listinfo/cocci
#1 lore raw
Quoted 12 lines · Richard W.M. Jones

Firstly a gentle reminder that there's a patch waiting to be applied:
https://systeme.lip6.fr/pipermail/cocci/2020-November/thread.html#8398

Different from that patch, but still related to Python 3.10, we've got another bug report here:
https://bugzilla.redhat.com/show_bug.cgi?id=1912931

This time _Py_fopen has been deprecated, replaced by _Py_wfopen or _Py_fopen_obj. It's unclear which is better. The two functions are documented here:
https://github.com/python/cpython/blob/master/Python/fileutils.c#L1418

Quoted 4 lines

What I don't understand from the pyxml code is why we use these internal Python functions at all, instead of calling regular C functions like fopen etc. In fact it seems like for Python 2 we did call fopen ...

Everything should be up to date now on github. Thanks for your help. Thierry will contact you directly about the choice of fopen.

julia

Quoted 10 lines

Rich.

--
Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones
Read my programming and virtualization blog: http://rwmj.wordpress.com
Fedora Windows cross-compiler. Compile Windows programs, test, and build Windows installers. Over 100 libraries supported.
http://fedoraproject.org/wiki/MinGW

Quoted 5 lines

_______________________________________________
Cocci mailing list
[email protected]
https://systeme.lip6.fr/mailman/listinfo/cocci

_______________________________________________
Cocci mailing list
[email protected]
https://systeme.lip6.fr/mailman/listinfo/cocci

#2 lore raw

Hi, Richard.

Thank you very much for your two successive reports about incompatibilities between pyml and Python 3.10. They should have been fixed now.

Richard:

Quoted 4 lines
Quoted 4 lines

What I don't understand from the pyxml code is why we use these internal Python functions at all, instead of calling regular C functions like fopen etc. In fact it seems like for Python 2 we did call fopen ...

Indeed, for Python 2, there is a fallback to fopen since Py_fopen is not available. When Py_fopen or Py_wfopen are available, we prefer to use them because they handle the Windows special case.

Best regards.

Signature · 3 lines
Thierry.

Julia Lawall :
Quoted 39 lines · Richard W.M. Jones
Quoted 13 lines

Firstly a gentle reminder that there's a patch waiting to be applied:
https://systeme.lip6.fr/pipermail/cocci/2020-November/thread.html#8398

Different from that patch, but still related to Python 3.10, we've got another bug report here:
https://bugzilla.redhat.com/show_bug.cgi?id=1912931

This time _Py_fopen has been deprecated, replaced by _Py_wfopen or _Py_fopen_obj. It's unclear which is better. The two functions are documented here:
https://github.com/python/cpython/blob/master/Python/fileutils.c#L1418

Quoted 4 lines

What I don't understand from the pyxml code is why we use these internal Python functions at all, instead of calling regular C functions like fopen etc. In fact it seems like for Python 2 we did call fopen ...

Everything should be up to date now on github. Thanks for your help. Thierry will contact you directly about the choice of fopen.

julia

Quoted 10 lines

Rich.

--
Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones
Read my programming and virtualization blog: http://rwmj.wordpress.com
Fedora Windows cross-compiler. Compile Windows programs, test, and build Windows installers. Over 100 libraries supported.
http://fedoraproject.org/wiki/MinGW

Quoted 5 lines

_______________________________________________
Cocci mailing list
[email protected]
https://systeme.lip6.fr/mailman/listinfo/cocci

Quoted 4 lines

_______________________________________________
Cocci mailing list
[email protected]
https://systeme.lip6.fr/mailman/listinfo/cocci

_______________________________________________
Cocci mailing list
[email protected]
https://systeme.lip6.fr/mailman/listinfo/cocci

#3 lore raw
Quoted 7 lines · Thierry Martinez

Hi, Richard.

Thank you very much for your two successive reports about incompatibilities between pyml and Python 3.10. They should have been fixed now.

Richard:

Quoted 8 lines
Quoted 4 lines
Quoted 4 lines

What I don't understand from the pyxml code is why we use these internal Python functions at all, instead of calling regular C functions like fopen etc. In fact it seems like for Python 2 we did call fopen ...

Indeed, for Python 2, there is a fallback to fopen since Py_fopen is not available. When Py_fopen or Py_wfopen are available, we prefer to use them because they handle the Windows special case.

Oh I see, that makes sense.

Rich.

Quoted 48 lines

Best regards.

Signature · 3 lines
Thierry.

Julia Lawall :
Quoted 43 lines · Richard W.M. Jones
Quoted 13 lines

Firstly a gentle reminder that there's a patch waiting to be applied:
https://systeme.lip6.fr/pipermail/cocci/2020-November/thread.html#8398

Different from that patch, but still related to Python 3.10, we've got another bug report here:
https://bugzilla.redhat.com/show_bug.cgi?id=1912931

This time _Py_fopen has been deprecated, replaced by _Py_wfopen or _Py_fopen_obj. It's unclear which is better. The two functions are documented here:
https://github.com/python/cpython/blob/master/Python/fileutils.c#L1418

Quoted 4 lines

What I don't understand from the pyxml code is why we use these internal Python functions at all, instead of calling regular C functions like fopen etc. In fact it seems like for Python 2 we did call fopen ...

Everything should be up to date now on github. Thanks for your help. Thierry will contact you directly about the choice of fopen.

julia

Quoted 10 lines

Rich.

--
Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones
Read my programming and virtualization blog: http://rwmj.wordpress.com
Fedora Windows cross-compiler. Compile Windows programs, test, and build Windows installers. Over 100 libraries supported.
http://fedoraproject.org/wiki/MinGW

Quoted 5 lines

_______________________________________________
Cocci mailing list
[email protected]
https://systeme.lip6.fr/mailman/listinfo/cocci

_______________________________________________
Cocci mailing list
[email protected]
https://systeme.lip6.fr/mailman/listinfo/cocci

Signature · 10 lines
Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones
Read my programming and virtualization blog: http://rwmj.wordpress.com
virt-p2v converts physical machines to virtual machines.  Boot with a
live CD or over the network (PXE) and turn machines into KVM guests.
http://libguestfs.org/virt-v2v

_______________________________________________
Cocci mailing list
[email protected]
https://systeme.lip6.fr/mailman/listinfo/cocci