[issue34752] warnings.warn fails silently with unicode input

Karthikeyan Singaravelan report at bugs.python.org
Mon Sep 24 08:38:00 EDT 2018


Karthikeyan Singaravelan <tir.karthi at gmail.com> added the comment:

Since Nick had some issue on adding a message to the issue I am adding the email sent to me as a message below : 


(sorry I can't see how to post a reply message on the bugs page, I'm still new to this)

anyhow here's what I wanted to post:

Thanks for finding the bug!
Maybe a preferable behaviour would be to split the error types
 - an IOError could still pass (I'm really not sure what the ideal treatment in that case is
 - a Unicode error would still print a warning but it would be something like a generic 'warning: non-standard text found in warning text so only printing this' (I'm sure there's something better sounding / more consistent with other warnings but I don't know them that well)

so the code would look something like:
except (UnicodeError):
    message = "non-standard text found in warning text so only printing this"
    file.write(formatwarning(message, category, filename, lineno, line))
except (IOError):
        pass # the file (probably stderr) is invalid - this warning
 gets lost.



but I'm not sure if an IOError inside the UnicodeError handling would still be caught (?)

anyhow I'm not sure how standard/appropriate a generic warning would be within the broader context of python (?) I think for us we'll probably just bite the bullet and switch to python3 to avoid this kind of thing since we'll potentially have a lot of unicode messages in the near future.

thanks again,
Nick Parslow

----------

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue34752>
_______________________________________


More information about the Python-bugs-list mailing list