Bug 1556707

Summary: Compiler.Compiler() raises AttributeError: 'NoneType' object has no attribute 'get'
Product: [Fedora] Fedora Reporter: Dan Callaghan <dcallagh>
Component: python-cheetahAssignee: Marek Skalický <mskalick>
Status: CLOSED ERRATA QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 28CC: mikeb, mskalick
Target Milestone: ---   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: python-cheetah-3.1.0-1.fc28 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2018-03-30 13:10:47 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On:    
Bug Blocks: 1555584    

Description Dan Callaghan 2018-03-15 06:14:04 UTC
Description of problem:
Found this indirectly through TurboGears test suite (it FTBFS, bug 1555584) which uses turbocheetah which calls Compiler.Compiler():

Traceback (most recent call last):
  File "/usr/lib/python2.7/site-packages/CherryPy-2.3.0-py2.7.egg/cherrypy/_cphttptools.py", line 121, in _run
    self.main()
  File "/usr/lib/python2.7/site-packages/CherryPy-2.3.0-py2.7.egg/cherrypy/_cphttptools.py", line 264, in main
    body = page_handler(*virtual_path, **self.params)
  File "<string>", line 3, in with_json_via_accept
  File "/builddir/build/BUILD/TurboGears-1.1.3/turbogears/controllers.py", line 384, in <lambda>
    expose = lambda func, *args, **kw: func(*args, **kw)
  File "<string>", line 3, in with_json_via_accept
  File "/builddir/build/BUILD/TurboGears-1.1.3/turbogears/controllers.py", line 384, in <lambda>
    expose = lambda func, *args, **kw: func(*args, **kw)
  File "<string>", line 3, in with_json_via_accept
  File "/builddir/build/BUILD/TurboGears-1.1.3/turbogears/controllers.py", line 361, in expose
    *args, **kw)
  File "<generated code>", line 0, in run_with_transaction
  File "/usr/lib/python2.7/site-packages/peak/rules/core.py", line 153, in __call__
    return self.body(*args, **kw)
  File "/builddir/build/BUILD/TurboGears-1.1.3/turbogears/database.py", line 458, in sa_rwt
    retval = func(*args, **kw)
  File "<generated code>", line 0, in _expose
  File "/usr/lib/python2.7/site-packages/peak/rules/core.py", line 153, in __call__
    return self.body(*args, **kw)
  File "/builddir/build/BUILD/TurboGears-1.1.3/turbogears/controllers.py", line 390, in <lambda>
    fragment, options, args, kw)))
  File "/builddir/build/BUILD/TurboGears-1.1.3/turbogears/controllers.py", line 451, in _execute_func
    fragment, **options)
  File "/builddir/build/BUILD/TurboGears-1.1.3/turbogears/controllers.py", line 100, in _process_output
    headers=headers, fragment=fragment, **options)
  File "/builddir/build/BUILD/TurboGears-1.1.3/turbogears/view/base.py", line 203, in render
    return engine.render(**kw)
  File "/usr/lib/python2.7/site-packages/turbocheetah/cheetahsupport.py", line 103, in render
    tempclass = self.load_template(template)
  File "/usr/lib/python2.7/site-packages/turbocheetah/cheetahsupport.py", line 83, in load_template
    mod = _compile_template(package, basename, tfile)
  File "/usr/lib/python2.7/site-packages/turbocheetah/cheetahsupport.py", line 16, in _compile_template
    code = str(Compiler.Compiler(file=tfile, mainClassName=basename))
  File "/usr/lib64/python2.7/site-packages/Cheetah/Compiler.py", line 1544, in __init__
    encoding = settings.get('encoding')
AttributeError: 'NoneType' object has no attribute 'get'

Version-Release number of selected component (if applicable):
python2-cheetah-3.0.0-20.fc29.x86_64

How reproducible:
easily

Steps to Reproduce:
1. python -c "import Cheetah.Compiler; Cheetah.Compiler.Compiler(file='/dev/null')"

Actual results:
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/usr/lib64/python2.7/site-packages/Cheetah/Compiler.py", line 1544, in __init__
    encoding = settings.get('encoding')
AttributeError: 'NoneType' object has no attribute 'get'

Expected results:
/usr/lib64/python2.7/site-packages/Cheetah/Compiler.py:1555: UserWarning: You supplied an empty string for the source!
  warnings.warn("You supplied an empty string for the source!", )

Additional info:
Seems to have regressed in 3.0.0 in this commit:
https://github.com/CheetahTemplate3/cheetah3/commit/1f3e4ed66a343f21f6171e42b7222b5189a1fdce
and then fixed in this commit in 3.0.1:
https://github.com/CheetahTemplate3/cheetah3/commit/050bb8a8cfd002e5b811e1864b5d41fee6a1591e

Comment 1 Fedora Update System 2018-03-20 15:17:07 UTC
python-cheetah-3.1.0-1.fc28 has been submitted as an update to Fedora 28. https://bodhi.fedoraproject.org/updates/FEDORA-2018-9fa5bcb8b4

Comment 2 Dan Callaghan 2018-03-20 22:49:00 UTC
Thanks, this fixed the Turbogears build.

Comment 3 Fedora Update System 2018-03-21 14:13:18 UTC
python-cheetah-3.1.0-1.fc28 has been pushed to the Fedora 28 testing repository. If problems still persist, please make note of it in this bug report.
See https://fedoraproject.org/wiki/QA:Updates_Testing for
instructions on how to install test updates.
You can provide feedback for this update here: https://bodhi.fedoraproject.org/updates/FEDORA-2018-9fa5bcb8b4

Comment 4 Fedora Update System 2018-03-30 13:10:47 UTC
python-cheetah-3.1.0-1.fc28 has been pushed to the Fedora 28 stable repository. If problems still persist, please make note of it in this bug report.