New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Configuration error with Python 3.5 keywordargs #1382

Closed
bb-migration opened this Issue Oct 3, 2015 · 10 comments

Comments

1 participant
@bb-migration

bb-migration commented Oct 3, 2015

Originally reported by: Florijan Hamzic (Bitbucket: florijanh, GitHub: Unknown)


I am using VirtualHost dispatcher in config file but with python 3.5 this doesn't work:

[/]
request.dispatch = cherrypy.dispatch.VirtualHost(
**{
'bay.de:9111': '/Web',
})

#!python

[03/Oct/2015:16:28:06] ENGINE Waiting for child threads to terminate...
[03/Oct/2015:16:28:06] ENGINE Re-spawning /home/cin/dev/b01/starter.py
Traceback (most recent call last):
  File "/usr/lib/python3.5/site-packages/cherrypy/lib/reprconf.py", line 218, in as_dict
    value = unrepr(value)
  File "/usr/lib/python3.5/site-packages/cherrypy/lib/reprconf.py", line 477, in unrepr
    return b.build(obj)
  File "/usr/lib/python3.5/site-packages/cherrypy/lib/reprconf.py", line 360, in build
    return m(o)
  File "/usr/lib/python3.5/site-packages/cherrypy/lib/reprconf.py", line 388, in build_Call
    if o.starargs is None:
AttributeError: 'Call' object has no attribute 'starargs'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/cin/dev/b01/starter.py", line 16, in <module>
    mainApp = cherrypy.tree.mount(Main(), "/", config="global.conf")
  File "/usr/lib/python3.5/site-packages/cherrypy/_cptree.py", line 224, in mount
    app.merge(config)
  File "/usr/lib/python3.5/site-packages/cherrypy/_cptree.py", line 98, in merge
    _cpconfig.merge(self.config, config)
  File "/usr/lib/python3.5/site-packages/cherrypy/_cpconfig.py", line 139, in merge
    for section, value_map in reprconf.as_dict(other).items():
  File "/usr/lib/python3.5/site-packages/cherrypy/lib/reprconf.py", line 51, in as_dict
    config = Parser().dict_from_file(config)
  File "/usr/lib/python3.5/site-packages/cherrypy/lib/reprconf.py", line 233, in dict_from_file
    return self.as_dict()
  File "/usr/lib/python3.5/site-packages/cherrypy/lib/reprconf.py", line 224, in as_dict
    raise ValueError(msg, x.__class__.__name__, x.args)
ValueError: ('Config error in section: \'/\', option: \'request.dispatch\', value: "cherrypy.dispatch.VirtualHost(\\n**{\\n\'bay.de:9111\': \'/Web\',\\n})". Config values must be valid Python.', 'AttributeError', ("'Call' object has no attribute 'starargs'",))

To work around it is possible to set the dispatch right in the python code.


@bb-migration

This comment has been minimized.

Show comment
Hide comment
@bb-migration

bb-migration Oct 3, 2015

Original comment by Joel Rivera (Bitbucket: cyraxjoe, GitHub: cyraxjoe):


Interesting... In Python 3.5 the _ast.Call fields are no longer the same, they really mean it that _ on the module name. I'll take a closer look later on.

bb-migration commented Oct 3, 2015

Original comment by Joel Rivera (Bitbucket: cyraxjoe, GitHub: cyraxjoe):


Interesting... In Python 3.5 the _ast.Call fields are no longer the same, they really mean it that _ on the module name. I'll take a closer look later on.

@bb-migration

This comment has been minimized.

Show comment
Hide comment
@bb-migration

bb-migration Nov 11, 2015

Original comment by Robert Kuska (Bitbucket: xkuska, GitHub: Unknown):


Hi, is there any update with Python3.5 support?

bb-migration commented Nov 11, 2015

Original comment by Robert Kuska (Bitbucket: xkuska, GitHub: Unknown):


Hi, is there any update with Python3.5 support?

@bb-migration

This comment has been minimized.

Show comment
Hide comment
@bb-migration

bb-migration Jan 2, 2016

Original comment by emmanuel_blot (Bitbucket: emmanuel_blot, GitHub: Unknown):


Any idea on how to work around this issue? Does it mean that for now, CherryPy cannot work with Python 3.5+? Thanks.

bb-migration commented Jan 2, 2016

Original comment by emmanuel_blot (Bitbucket: emmanuel_blot, GitHub: Unknown):


Any idea on how to work around this issue? Does it mean that for now, CherryPy cannot work with Python 3.5+? Thanks.

@bb-migration

This comment has been minimized.

Show comment
Hide comment
@bb-migration

bb-migration Jan 7, 2016

Original comment by Imran Hendley (Bitbucket: ihendley, GitHub: ihendley):


I was able to work around the issue by defining the configuration directly in a python dictionary, instead of trying to parse it from a text file. For example:

#!python

        conf = {
            'global': {
                'server.socket_host': '0.0.0.0',
                'server.socket_port': 8000
            },
            '/': {
                'request.dispatch': cherrypy.dispatch.MethodDispatcher(),
            },
        }

        cherrypy.quickstart(root, '/', conf)

bb-migration commented Jan 7, 2016

Original comment by Imran Hendley (Bitbucket: ihendley, GitHub: ihendley):


I was able to work around the issue by defining the configuration directly in a python dictionary, instead of trying to parse it from a text file. For example:

#!python

        conf = {
            'global': {
                'server.socket_host': '0.0.0.0',
                'server.socket_port': 8000
            },
            '/': {
                'request.dispatch': cherrypy.dispatch.MethodDispatcher(),
            },
        }

        cherrypy.quickstart(root, '/', conf)
@bb-migration

This comment has been minimized.

Show comment
Hide comment
@bb-migration

bb-migration Jan 31, 2016

Original comment by Florijan Hamzic (Bitbucket: florijanh, GitHub: Unknown):


If you don't want to work around by adding all your config into python code you can also do this:

#!python

from cherrypy._cpconfig import reprconf
...
conf = reprconf.Parser().dict_from_file("yourconfi.conf")
cherrypy.quickstart(root, '/', conf)

bb-migration commented Jan 31, 2016

Original comment by Florijan Hamzic (Bitbucket: florijanh, GitHub: Unknown):


If you don't want to work around by adding all your config into python code you can also do this:

#!python

from cherrypy._cpconfig import reprconf
...
conf = reprconf.Parser().dict_from_file("yourconfi.conf")
cherrypy.quickstart(root, '/', conf)
@bb-migration

This comment has been minimized.

Show comment
Hide comment
@bb-migration

bb-migration Feb 19, 2016

Original comment by Anonymous:


Hi, do you need any help with issue?

bb-migration commented Feb 19, 2016

Original comment by Anonymous:


Hi, do you need any help with issue?

@bb-migration

This comment has been minimized.

Show comment
Hide comment
@bb-migration

bb-migration Feb 19, 2016

Original comment by Joel Rivera (Bitbucket: cyraxjoe, GitHub: cyraxjoe):


Hello @torsava, the pull request #120 address this issue. If you have time to review it and better yet add a test to verify it would be great.

bb-migration commented Feb 19, 2016

Original comment by Joel Rivera (Bitbucket: cyraxjoe, GitHub: cyraxjoe):


Hello @torsava, the pull request #120 address this issue. If you have time to review it and better yet add a test to verify it would be great.

@bb-migration

This comment has been minimized.

Show comment
Hide comment
@bb-migration

bb-migration Feb 24, 2016

Original comment by Anonymous:


Hi @cyraxjoe, I believe there already is a test for this. The cherrypy fedora package fails to build against python 3.5 because the tests currently throw 3 errors, the first of which tracebacks to the same problem as in this issue.

See buildlog: https://kojipkgs.fedoraproject.org//work/tasks/9421/12879421/build.log

Section:
ERROR: test suite for <class 'cherrypy.test.test_config.ConfigTests'>

I've created a patch from the pull request #120, I've applied it to the package, and now the error is gone.
[Though the other two errors remain, I have yet to track them down.]

New buildlog: https://kojipkgs.fedoraproject.org//work/tasks/5632/13115632/build.log

bb-migration commented Feb 24, 2016

Original comment by Anonymous:


Hi @cyraxjoe, I believe there already is a test for this. The cherrypy fedora package fails to build against python 3.5 because the tests currently throw 3 errors, the first of which tracebacks to the same problem as in this issue.

See buildlog: https://kojipkgs.fedoraproject.org//work/tasks/9421/12879421/build.log

Section:
ERROR: test suite for <class 'cherrypy.test.test_config.ConfigTests'>

I've created a patch from the pull request #120, I've applied it to the package, and now the error is gone.
[Though the other two errors remain, I have yet to track them down.]

New buildlog: https://kojipkgs.fedoraproject.org//work/tasks/5632/13115632/build.log

@bb-migration

This comment has been minimized.

Show comment
Hide comment
@bb-migration

bb-migration Feb 26, 2016

Original comment by Anonymous:


EDIT: Since I'm not the main fedora packager for cherrypy I didn't at first realize it was building an older version of CherryPy. So apologies and here are the updated buildlogs:

Building 5.0.1 without the patch: https://kojipkgs.fedoraproject.org//work/tasks/6148/13136148/build.log

Reporter's error is reproduced, see section "ERROR: test suite for <class 'cherrypy.test.test_config.ConfigTests'>".

Building 5.0.1 with patch from pull request #120: https://kojipkgs.fedoraproject.org//work/tasks/6169/13136169/build.log

Error goes away without issue.

Note that the second error in the patched build is caused by issue #1406 which has yet to be resolved.

bb-migration commented Feb 26, 2016

Original comment by Anonymous:


EDIT: Since I'm not the main fedora packager for cherrypy I didn't at first realize it was building an older version of CherryPy. So apologies and here are the updated buildlogs:

Building 5.0.1 without the patch: https://kojipkgs.fedoraproject.org//work/tasks/6148/13136148/build.log

Reporter's error is reproduced, see section "ERROR: test suite for <class 'cherrypy.test.test_config.ConfigTests'>".

Building 5.0.1 with patch from pull request #120: https://kojipkgs.fedoraproject.org//work/tasks/6169/13136169/build.log

Error goes away without issue.

Note that the second error in the patched build is caused by issue #1406 which has yet to be resolved.

@bb-migration

This comment has been minimized.

Show comment
Hide comment
@bb-migration

bb-migration Mar 2, 2016

Original comment by Joel Rivera (Bitbucket: cyraxjoe, GitHub: cyraxjoe):


Fix bug #1382 for Python 3.5 keyword args.

bb-migration commented Mar 2, 2016

Original comment by Joel Rivera (Bitbucket: cyraxjoe, GitHub: cyraxjoe):


Fix bug #1382 for Python 3.5 keyword args.

jaraco pushed a commit that referenced this issue Apr 30, 2016

workaround for issue #1382, python 3.5 _ast.Call signature rudimentar…
…ily implemented

--HG--
branch : 1282-ast-call-signature

jaraco pushed a commit that referenced this issue Apr 30, 2016

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment