#3653 Replace PyString_FromString() with PyUnicode_FromString()
Closed: Invalid 6 years ago Opened 6 years ago by sbose.

PyString_FromString() is not available in python3 anymore and we still have 2 places where it is used:

$ grep -n -r PyString_FromString ../src/*
../src/python/pysss.c:811:                    PyString_FromString(gr->gr_name)
../src/util/sss_python.c:42:        docobj = PyString_FromString(doc);

Metadata Update from @fidencio:
- Issue assigned to fidencio

6 years ago

Sumit, there's actually just one place where it's problematic (src/util/sss_python.c:42), the other one has a if-else to decide whether to use PyUnicode_FromString() or PyString_FromString() depending on the python version.

I've just mimic'ed the code there and opened a pull-request with the fix.

PR: https://github.com/SSSD/sssd/pull/526

Metadata Update from @fidencio:
- Custom field patch adjusted to on

6 years ago

@sbose,
I assume this ticket was opened as a reaction to koshei and this scratch build
https://koji.fedoraproject.org/koji/taskinfo?taskID=25386355

The title of issue is not ideal because it describe solution and not the issue :-)
Anyway, I spot one important think in build.log which should be fixed anyway.

The configure time detection of function PyErr_NewExceptionWithDoc is twice in output.

checking for python2... yes
checking for python2... /usr/bin/python2
checking for python3... yes
checking for python3... /usr/bin/python3
checking whether /usr/bin/python2 version is >= 2.6... yes
checking for /usr/bin/python2 version... 2.7
checking for /usr/bin/python2 platform... linux2
checking for /usr/bin/python2 script directory... ${prefix}/lib/python2.7/site-packages
checking for /usr/bin/python2 extension module directory... ${exec_prefix}/lib64/python2.7/site-packages
checking for python2.7-config... /usr/bin/python2.7-config
checking for headers required to compile python extensions... found
checking for PyErr_NewExceptionWithDoc... no
checking whether /usr/bin/python3 version is >= 3.3... yes
checking for /usr/bin/python3 version... 3.6
checking for /usr/bin/python3 platform... linux
checking for /usr/bin/python3 script directory... ${prefix}/lib/python3.6/site-packages
checking for /usr/bin/python3 extension module directory... ${exec_prefix}/lib64/python3.6/site-packages
checking for python3.6-config... /usr/bin/python3.6-config
checking for headers required to compile python extensions... found
checking for PyErr_NewExceptionWithDoc... (cached) no

But as we can see the 2nd value was cached. It was not a problem with python-2.7 + python-3.x because the function was already properly detected for python2. But it would not work with python-2.6 + python3.x which fedora/debian never had as a default for python2 and python3.

There are few ways how to fix it. Either have two separate detections of PyErr_NewExceptionWithDoc with different name of macros with existing function (HAVE_PY2ERR_NEWEXCEPTIONWITHDOC, HAVE_PY3ERR_NEWEXCEPTIONWITHDOC) or drop configure time detection of function and rely on version of python in python-header files.

As pointed by @lslebodn on the PR was wrong and I'm removing the patch flag.

I won't assign the bug to myself as I'm going for PTO and just coming back on Tuesday. If it's not solved by then, I'll assign it to myself and work on it.

Thanks for the detailed explanation, @lslebodn. By the way, feel free to adapt the bug title to a more appropriate one.

Metadata Update from @fidencio:
- Custom field patch reset (from on)

6 years ago

@lslebodn, yes it was about koshei and rawhide builds are back to normal, so I guess it was the glibc issue causing the detection to fail.

About the cache result, I think it would prefer a detection with different macro names. I've opened https://pagure.io/SSSD/sssd/issue/3656 with your comment to track it and will close this one.

Metadata Update from @sbose:
- Custom field patch reset (from false)

6 years ago

Metadata Update from @sbose:
- Custom field patch reset (from false)
- Issue close_status updated to: Invalid
- Issue status updated to: Closed (was: Open)

6 years ago

SSSD is moving from Pagure to Github. This means that new issues and pull requests
will be accepted only in SSSD's github repository.

This issue has been cloned to Github and is available here:
- https://github.com/SSSD/sssd/issues/4673

If you want to receive further updates on the issue, please navigate to the github issue
and click on subscribe button.

Thank you for understanding. We apologize for all inconvenience.

Login to comment on this ticket.

Metadata