[issue31285] a SystemError and an assertion failure in warnings.warn_explicit()

2017-09-30 Thread Serhiy Storchaka
Change by Serhiy Storchaka : -- resolution: -> fixed stage: patch review -> resolved status: open -> closed versions: +Python 2.7 ___ Python tracker ___ ___

[issue31285] a SystemError and an assertion failure in warnings.warn_explicit()

2017-09-30 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: New changeset 40d736bcf40c10aa5fc7d6cc305a6641afd3cd0e by Serhiy Storchaka (Oren Milman) in branch '2.7': [2.7] bpo-31285: Don't raise a SystemError in warnings.warn_explicit() in case __loader__.get_source() has a bad splitlines() method. (GH-3219) (#3823)

[issue31285] a SystemError and an assertion failure in warnings.warn_explicit()

2017-09-29 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: New changeset 66c2b9f13ef2197a5212fd58372173124df76467 by Serhiy Storchaka (Miss Islington (bot)) in branch '3.6': [3.6] bpo-31285: Remove splitlines identifier from Python/_warnings.c (GH-3803) (#3829) https://github.com/python/cpython/commit/66c2b9f13ef21

[issue31285] a SystemError and an assertion failure in warnings.warn_explicit()

2017-09-29 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: I just missed PR 3803. -- ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe:

[issue31285] a SystemError and an assertion failure in warnings.warn_explicit()

2017-09-29 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: New changeset 8b4ff53c440dfcde40fbeb02c5e666c85190528f by Serhiy Storchaka (Oren Milman) in branch 'master': bpo-31285: Remove splitlines identifier from Python/_warnings.c (#3803) https://github.com/python/cpython/commit/8b4ff53c440dfcde40fbeb02c5e666c85190

[issue31285] a SystemError and an assertion failure in warnings.warn_explicit()

2017-09-29 Thread Roundup Robot
Change by Roundup Robot : -- pull_requests: +3812 ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail

[issue31285] a SystemError and an assertion failure in warnings.warn_explicit()

2017-09-29 Thread Oren Milman
Change by Oren Milman : -- pull_requests: +3808 ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.p

[issue31285] a SystemError and an assertion failure in warnings.warn_explicit()

2017-09-29 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: I didn't check. I supposed that the other code can support unicode by implicitly converting it to str. But now I see that show_warning() uses PyString_AS_STRING() and therefore supports only str. I agree, using str.splitlines() would be correct solution. -

[issue31285] a SystemError and an assertion failure in warnings.warn_explicit()

2017-09-29 Thread Oren Milman
Oren Milman added the comment: But in case get_source() returned a unicode, is it likely that the splitlines() method of this unicode would return a 8-bit string? Currently show_warning() doesn't handle this scenario, as it assumes splitlines() returned an 8-bit string. Or do you think that s

[issue31285] a SystemError and an assertion failure in warnings.warn_explicit()

2017-09-28 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: What if get_source() returned a unicode string? Usually it returns 8-bit string, but in many cases unicode is accepted if str is expected, so you need to check this option too. -- ___ Python tracker

[issue31285] a SystemError and an assertion failure in warnings.warn_explicit()

2017-09-28 Thread Oren Milman
Oren Milman added the comment: oh, of course, checking that get_source() returned a string before passing it to str.splitlines() is not needed. -- ___ Python tracker ___ __

[issue31285] a SystemError and an assertion failure in warnings.warn_explicit()

2017-09-28 Thread Oren Milman
Oren Milman added the comment: Another thought - the existing code assumes that splitlines() returned a string. So maybe we could just check that get_source() returned a string, and then call the method str.splitlines() on it? -- ___ Python tracker

[issue31285] a SystemError and an assertion failure in warnings.warn_explicit()

2017-09-28 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: > In 2.7, PyUnicode_Splitlines() first does: > string = PyUnicode_FromObject(string); And it raises an exception if the string contains non-ASCII characters. It is better to avoid str<->unicode convertion as long as possible. And when do it for the output a

[issue31285] a SystemError and an assertion failure in warnings.warn_explicit()

2017-09-28 Thread Oren Milman
Oren Milman added the comment: In 2.7, PyUnicode_Splitlines() first does: string = PyUnicode_FromObject(string); So i thought that PyUnicode_Splitlines() would be fine with receiving a string. But now i realize that even in case i was right there, PyUnicode_Splitlines() returns a unicode, and

[issue31285] a SystemError and an assertion failure in warnings.warn_explicit()

2017-09-28 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: PyUnicode_Splitlines() cannot be used here in 2.7, because the source is likely a 8-bit string. Actually I'm not sure this issue is worth to be fixed in 2.7. The fix would be different from 3.x and more complex. -- versions: +Python 3.6 __

[issue31285] a SystemError and an assertion failure in warnings.warn_explicit()

2017-09-28 Thread Oren Milman
Change by Oren Milman : -- pull_requests: +3791 ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.p

[issue31285] a SystemError and an assertion failure in warnings.warn_explicit()

2017-09-28 Thread Oren Milman
Change by Oren Milman : -- pull_requests: +3789 ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.p

[issue31285] a SystemError and an assertion failure in warnings.warn_explicit()

2017-09-26 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: New changeset 90fe25a051bd8cf64d52be533c9b60cad9bdd7fb by Serhiy Storchaka in branch '3.6': [3.6] bpo-31285: Fix an assertion failure and a SystemError in warnings.warn_explicit. (GH-3219) (#3775) https://github.com/python/cpython/commit/90fe25a051bd8cf64d5

[issue31285] a SystemError and an assertion failure in warnings.warn_explicit()

2017-09-26 Thread Serhiy Storchaka
Changes by Serhiy Storchaka : -- keywords: +patch pull_requests: +3762 stage: -> patch review ___ Python tracker ___ ___ Python-bugs

[issue31285] a SystemError and an assertion failure in warnings.warn_explicit()

2017-09-24 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: New changeset 91fb0afe181986b48abfc6092dcca912b39de51d by Serhiy Storchaka (Oren Milman) in branch 'master': bpo-31285: Fix an assertion failure and a SystemError in warnings.warn_explicit. (#3219) https://github.com/python/cpython/commit/91fb0afe181986b48ab

[issue31285] a SystemError and an assertion failure in warnings.warn_explicit()

2017-08-28 Thread Oren Milman
Oren Milman added the comment: ISTM that your solution is better than mine, Serhiy, so I updated the PR. -- ___ Python tracker ___ ___

[issue31285] a SystemError and an assertion failure in warnings.warn_explicit()

2017-08-27 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: An alternative solution is using str.splitlines(source) instead of source.splitlines(). It raises a TypeError if the argument is not a text string and always returns a list of strings. According to the documentation get_source() must return a text string or

[issue31285] a SystemError and an assertion failure in warnings.warn_explicit()

2017-08-27 Thread Oren Milman
Changes by Oren Milman : -- pull_requests: +3259 ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.p

[issue31285] a SystemError and an assertion failure in warnings.warn_explicit()

2017-08-26 Thread Oren Milman
Oren Milman added the comment: on a second thought, BadSource could be a subclass of str, so maybe we should just check whether module_globals['__loader__'].get_source(module_globals['__name__']).splitlines()[lineno-1] is a str, and whether module_globals['__loader__'].get_source(module_globals['

[issue31285] a SystemError and an assertion failure in warnings.warn_explicit()

2017-08-26 Thread Oren Milman
New submission from Oren Milman: 1. the following causes an assertion failure in Python/_warnings.c in show_warning(): import warnings class BadLoader: def get_source(self, fullname): class BadSource: def splitlines(self): return [42] return BadSo