Skip to content
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
ghost opened this issue Oct 3, 2015 · 10 comments
Closed

Configuration error with Python 3.5 keywordargs #1382

ghost opened this issue Oct 3, 2015 · 10 comments
Projects

Comments

@ghost
Copy link

@ghost ghost 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.


@ghost
Copy link
Author

@ghost ghost 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.

@ghost
Copy link
Author

@ghost ghost commented Nov 11, 2015

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


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

@ghost
Copy link
Author

@ghost ghost 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.

@ghost
Copy link
Author

@ghost ghost 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)
@ghost
Copy link
Author

@ghost ghost 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)
@ghost
Copy link
Author

@ghost ghost commented Feb 19, 2016

Original comment by Anonymous:


Hi, do you need any help with issue?

@ghost
Copy link
Author

@ghost ghost 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.

@ghost
Copy link
Author

@ghost ghost 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

@ghost
Copy link
Author

@ghost ghost 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.

@ghost
Copy link
Author

@ghost ghost commented Mar 2, 2016

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


Fix bug #1382 for Python 3.5 keyword args.

@ghost ghost added major bug CherryPy code labels Apr 30, 2016
@ghost ghost closed this Apr 30, 2016
jaraco pushed a commit that referenced this issue Apr 30, 2016
…ily implemented

--HG--
branch : 1282-ast-call-signature
jaraco pushed a commit that referenced this issue Apr 30, 2016
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Bugs
Fixed
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
0 participants
You can’t perform that action at this time.