This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author mdmullins
Recipients mdmullins
Date 2010-01-06.10:29:11
SpamBayes Score 2.4169766e-10
Marked as misclassified No
Message-id <1262773754.82.0.67564143033.issue7644@psf.upfronthosting.co.za>
In-reply-to
Content
When using NNTP.body(id,file) I get the following repeatable error:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "nntplib.py", line 436, in body
    return self.artcmd('BODY {0}'.format(id), file)
  File "nntplib.py", line 410, in artcmd
    resp, list = self.longcmd(line, file)
  File "nntplib.py", line 267, in longcmd
    return self.getlongresp(file)
  File "nntplib.py", line 249, in getlongresp
    file.write(line + b'\n')
  File "/usr/lib/python3.0/io.py", line 1478, in write
    s.__class__.__name__)
TypeError: can't write bytes to text stream


But by simply changing the line

    openedFile = file = open(file, "w")

...to...

    openedFile = file = open(file, "wb")

...in the following code:

    def getlongresp(self, file=None):
        """Internal: get a response plus following text from the server.
        Raise various errors if the response indicates an error."""

        openedFile = None
        try:
            # If a string was passed then open a file with that name
            if isinstance(file, str):
                openedFile = file = open(file, "wb")

...it seems to fix the problem. I discovered this in 3.0, but downloading and inspecting the source for 3.1 shows the same problem.

MDMullins
History
Date User Action Args
2010-01-06 10:29:15mdmullinssetrecipients: + mdmullins
2010-01-06 10:29:14mdmullinssetmessageid: <1262773754.82.0.67564143033.issue7644@psf.upfronthosting.co.za>
2010-01-06 10:29:13mdmullinslinkissue7644 messages
2010-01-06 10:29:12mdmullinscreate