[Checkins] [zopefoundation/zope.testbrowser] 6e3311: Fix ``mechRepr`` on controls to always return a na...

GitHub noreply at github.com
Mon Oct 16 19:09:08 CEST 2017


  Branch: refs/heads/fix-mechRepr
  Home:   https://github.com/zopefoundation/zope.testbrowser
  Commit: 6e33115168c318be445f61d63ba5726c018369f7
      https://github.com/zopefoundation/zope.testbrowser/commit/6e33115168c318be445f61d63ba5726c018369f7
  Author: Marius Gedminas <marius at gedmin.as>
  Date:   2017-10-16 (Mon, 16 Oct 2017)

  Changed paths:
    M CHANGES.rst
    M src/zope/testbrowser/browser.py
    M src/zope/testbrowser/tests/test_browser.py

  Log Message:
  -----------
  Fix ``mechRepr`` on controls to always return a native str.

The error scenario is the following:

* A page contains a submit control whose value contains a non-ASCII character.
* There is also a select with options or a text input field.
* browser.getControl() is used to select a _not_ existing control.
* TestBrowser tries to render the list of possible controls using the mechRepr of the controls.
* The previous step fails with a UnicodeDecodeError when joining the mechRepr values of the controls because the ones of select option (aka item) and text field are unicode while the one of the submit control is str but contains a non-ASCII char.

As the scenario described above requires the mechRepr to be of the same type I decided to adapt the two remaining control classes which returned unicode to the str approach used by of the majority of the controls.




More information about the checkins mailing list