Skip to content

cgitb with Py3: TypeError: 'str' does not support the buffer interface #66934

Closed

Description

@wrohdewald
BPO 22745
Nosy @amauryfa, @bitdancer
Files
  • cgibug.py
  • Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

    Show more details

    GitHub fields:

    assignee = None
    closed_at = <Date 2014-10-28.04:30:46.251>
    created_at = <Date 2014-10-27.18:41:35.007>
    labels = ['invalid', 'library', 'type-crash']
    title = "cgitb with Py3: TypeError: 'str' does not support the buffer interface"
    updated_at = <Date 2014-10-28.04:30:46.250>
    user = 'https://bugs.python.org/wrohdewald'

    bugs.python.org fields:

    activity = <Date 2014-10-28.04:30:46.250>
    actor = 'wrohdewald'
    assignee = 'none'
    closed = True
    closed_date = <Date 2014-10-28.04:30:46.251>
    closer = 'wrohdewald'
    components = ['Library (Lib)']
    creation = <Date 2014-10-27.18:41:35.007>
    creator = 'wrohdewald'
    dependencies = []
    files = ['37043']
    hgrepos = []
    issue_num = 22745
    keywords = []
    message_count = 4.0
    messages = ['230083', '230094', '230098', '230118']
    nosy_count = 3.0
    nosy_names = ['amaury.forgeotdarc', 'r.david.murray', 'wrohdewald']
    pr_nums = []
    priority = 'normal'
    resolution = 'not a bug'
    stage = None
    status = 'closed'
    superseder = None
    type = 'crash'
    url = 'https://bugs.python.org/issue22745'
    versions = ['Python 3.4']

    Activity

    1. wrohdewald commented on Oct 27, 2014

      wrohdewaldmannequin
      MannequinAuthor

      The attached script works with Python2.7. With Python3.4, it produces

      Traceback (most recent call last):
        File "/usr/lib/python3.4/cgitb.py", line 268, in __call__
          self.handle((etype, evalue, etb))
        File "cgibug.py", line 12, in handle
          cgitb.Hook.handle(self, info)
        File "/usr/lib/python3.4/cgitb.py", line 273, in handle
          self.file.write(reset())
      TypeError: 'str' does not support the buffer interface

      When replacing the file mode 'wb' with 'w', it produces this failure:
      File "/usr/lib/python3.4/cgitb.py", line 288, in handle
      self.file.write(doc + '\n')
      TypeError: can't concat bytes to str

      The script works as expected with Python2.7 with both file modes.

    2. added
      stdlib
      type-crash
      on Oct 27, 2014
    3. amauryfa commented on Oct 27, 2014

      @amauryfa
      Contributor

      html is text, so the file mode should be 'w'.
      But I don't reproduce the behavior with Python version v3.4.2.
      Which version are you using exactly?

    4. bitdancer commented on Oct 27, 2014

      @bitdancer
      Member

      I don't think what html is is relevant here. Hook is going to be dealing with strings, though, so 'w' is indeed correct.

      The script works fine for me as well. (Also tested it on 3.3.2 since I had it laying around, so it's not a recent bugfix).

    5. wrohdewald commented on Oct 28, 2014

      wrohdewaldmannequin
      MannequinAuthor

      This now works with mode 'w' and after reinstalling the packages. My Python is 3.4.0 (ubuntu).

    6. transferred this issue fromon Apr 10, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

    Metadata

    Metadata

    Assignees

    No one assigned

      Labels

      stdlibtype-crash

      Projects

      No projects

        Milestone

        No milestone

        Relationships

        None yet

        Development

        No branches or pull requests

        Issue actions