zopefoundation / Products.PluggableAuthService

Pluggable Zope authentication / authorization framework
Other
9 stars 18 forks source link

Error adding ConfiguredPAS on Zope5.2.1 #98

Closed gpzope closed 3 years ago

gpzope commented 3 years ago

What I did:

Try to add a ConfiguresPASS on new Zope5.2.1 instance on MacOS 10.13.6 Python 3.7.7 via ZMI, it generates the following error:

 ERROR [Zope.SiteErrorLog:252][waitress-2] 1623152909.9372760.5106680831995953 http://localhost:8080/testFolder/manage_addProduct/PluggableAuthService/addConfiguredPAS
Traceback (innermost last):
  Module ZPublisher.WSGIPublisher, line 167, in transaction_pubevents
  Module ZPublisher.WSGIPublisher, line 376, in publish_module
  Module ZPublisher.WSGIPublisher, line 279, in publish
  Module ZPublisher.mapply, line 85, in mapply
  Module ZPublisher.WSGIPublisher, line 68, in call_object
  Module Products.PluggableAuthService.PluggableAuthService, line 1411, in addConfiguredPAS
  Module Products.GenericSetup.tool, line 405, in runAllImportStepsFromProfile
   - __traceback_info__: profile-PluggableAuthService:simple
  Module Products.GenericSetup.tool, line 1483, in _runImportStepsFromContext
  Module Products.GenericSetup.tool, line 1295, in _doRunImportStep
   - __traceback_info__: contents
  Module Products.PluggableAuthService.exportimport, line 29, in importPAS
  Module Products.GenericSetup.content, line 159, in import_
TypeError: initial_value must be str or None, not bytes
2021-06-08 13:48:29 ERROR [waitress:404][waitress-2] Exception while serving /testFolder/manage_addProduct/PluggableAuthService/addConfiguredPAS
Traceback (most recent call last):
  File "/Applications/zope521bo/eggs/waitress-2.0.0-py3.7.egg/waitress/channel.py", line 397, in service
    task.service()
  File "/Applications/zope521bo/eggs/waitress-2.0.0-py3.7.egg/waitress/task.py", line 168, in service
    self.execute()
  File "/Applications/zope521bo/eggs/waitress-2.0.0-py3.7.egg/waitress/task.py", line 434, in execute
    app_iter = self.channel.server.application(environ, start_response)
  File "/Applications/zope521bo/eggs/Zope-5.2.1-py3.7.egg/ZPublisher/httpexceptions.py", line 30, in __call__
    return self.application(environ, start_response)
  File "/Applications/zope521bo/eggs/Paste-3.5.0-py3.7.egg/paste/translogger.py", line 69, in __call__
    return self.application(environ, replacement_start_response)
  File "/Applications/zope521bo/eggs/Zope-5.2.1-py3.7.egg/ZPublisher/WSGIPublisher.py", line 376, in publish_module
    response = _publish(request, new_mod_info)
  File "/Applications/zope521bo/eggs/Zope-5.2.1-py3.7.egg/ZPublisher/WSGIPublisher.py", line 279, in publish
    bind=1)
  File "/Applications/zope521bo/eggs/Zope-5.2.1-py3.7.egg/ZPublisher/mapply.py", line 85, in mapply
    return debug(object, args, context)
  File "/Applications/zope521bo/eggs/Zope-5.2.1-py3.7.egg/ZPublisher/WSGIPublisher.py", line 68, in call_object
    return obj(*args)
  File "/Applications/zope521bo/eggs/Products.PluggableAuthService-2.6.2-py3.7.egg/Products/PluggableAuthService/PluggableAuthService.py", line 1411, in addConfiguredPAS
    tool.runAllImportStepsFromProfile('profile-%s' % base_profile)
  File "/Applications/zope521bo/eggs/Products.GenericSetup-2.1.1-py3.7.egg/Products/GenericSetup/tool.py", line 405, in runAllImportStepsFromProfile
    dependency_strategy=dependency_strategy)
  File "/Applications/zope521bo/eggs/Products.GenericSetup-2.1.1-py3.7.egg/Products/GenericSetup/tool.py", line 1483, in _runImportStepsFromContext
    message = self._doRunImportStep(step, context)
  File "/Applications/zope521bo/eggs/Products.GenericSetup-2.1.1-py3.7.egg/Products/GenericSetup/tool.py", line 1295, in _doRunImportStep
    return handler(context)
  File "/Applications/zope521bo/eggs/Products.PluggableAuthService-2.6.2-py3.7.egg/Products/PluggableAuthService/exportimport.py", line 29, in importPAS
    IFilesystemImporter(context.getSite()).import_(context, 'PAS', True)
  File "/Applications/zope521bo/eggs/Products.GenericSetup-2.1.1-py3.7.egg/Products/GenericSetup/content.py", line 159, in import_
    stream = cStringIO(objects)
TypeError: initial_value must be str or None, not bytes
d-maurer commented 3 years ago

gpzope wrote at 2021-6-8 04:57 -0700:

What I did:

Try to add a ConfiguresPASS on new Zope5.2.1 instance on MacOS 10.13.6 Python 3.7.7 via ZMI, it generates the following error: ERROR [Zope.SiteErrorLog:252][waitress-2] 1623152909.9372760.5106680831995953 http://localhost:8080/testFolder/manage_addProduct/PluggableAuthService/addConfiguredPAS Traceback (innermost last): ... Module Products.PluggableAuthService.exportimport, line 29, in importPAS Module Products.GenericSetup.content, line 159, in import_ TypeError: initial_value must be str or None, not bytes

This is almost surely a Python 3 incompatibility -- likely resolved in other packages supporting GenericSetup.

dataflake commented 3 years ago

As Dieter points out, the issue is not in this package but in Products.GenericSetup. It attempts to read import data from the file system and does so in explicit binary mode. Then it wants to put the extracted binary string into an instance of six.moves.cStringIO, which is io.StringIO under Python 3 and thus unable to use binary data. This issue must have existed for a long time.

d-maurer commented 3 years ago

Jens Vagelpohl wrote at 2021-6-8 07:46 -0700:

As Dieter points out, the issue is not in this package but in Products.GenericSetup. It attempts to read import data from the file system and does so in explicit binary mode. Then it wants to put the extracted binary string into an instance of six.moves.cStringIO, which is io.StringIO under Python 3 and thus unable to use binary data. This issue must have existed for a long time.

Products.GenericSetup is actively used by Plone. Potentially, a new version will solve the problem.

dataflake commented 3 years ago

The fix will be tracked in https://github.com/zopefoundation/Products.GenericSetup/issues/107, this is essentially a duplicate.