1. cherrypy
  2. CherryPy

Pull requests

#4 Merged
Repository
pigmej
Branch
default
Repository
cherrypy
Branch
cherrypy-3.2.x

Fixed incorrect __import__ that causes double initialization of package when using cherryd

Author
  1. Jędrzej Nowak
Reviewers
Description

Incorrect import line causes double initialization of package:

Example output of object id + thread name: 140507633963184 <_MainThread(MainThread, started 140507634476832)> 140507633963200 <_MainThread(MainThread, started 140507634476832)>

Source code to demonstrate it: https://bitbucket.org/pigmej/cherrypy/downloads/TestApp.tar.gz

I'm requesting pull to 3.2.x but the default requires it also.

  • Learn about pull requests

Comments (3)

  1. Jason R. Coombs

    Three things:

    1. http://bugs.python.org/issue2090#msg80987 suggests that the correct solution is to get mod from sys.modules.
    2. The changeset doesn't remove the comment which specifically indicates that the [''] is important.
    3. The changeset changes the behavior to not grab the tail module, so if modulePath is 'foo.bar', mod will be 'foo' and not 'foo.bar'.

    I suggest instead the patch should maintain the same behavior but use the recommended technique to get the tail module.