[issue40673] urllib.request.URLopener raises different exceptions based on implementation detail

2020-05-18 Thread Petter S
Petter S added the comment: I see. Perhaps that is the resolution then. -- ___ Python tracker <https://bugs.python.org/issue40673> ___ ___ Python-bugs-list m

[issue40673] urllib.request.URLopener raises different exceptions based on implementation detail

2020-05-18 Thread Petter S
Petter S added the comment: I can fix this, but it does not have high priority. -- ___ Python tracker <https://bugs.python.org/issue40673> ___ ___ Python-bug

[issue35907] [security][CVE-2019-9948] Unnecessary URL scheme exists to allow local_file:// reading file in urllib

2020-05-18 Thread Petter S
Petter S added the comment: OK: https://bugs.python.org/issue40673 -- ___ Python tracker <https://bugs.python.org/issue35907> ___ ___ Python-bugs-list mailin

[issue40673] urllib.request.URLopener raises different exceptions based on implementation detail

2020-05-18 Thread Petter S
Change by Petter S : -- title: UrlOpener raises different exceptions based on implementation detail -> urllib.request.URLopener raises different exceptions based on implementation detail ___ Python tracker <https://bugs.python.org/issu

[issue40673] UrlOpener raises different exceptions based on implementation detail

2020-05-18 Thread Petter S
New submission from Petter S : The following code crashes with TypeError: URLopener().open("unknown_proxy://test") the expected behavior is an OSError, which is normally raised for unknown protocols. This implementation of directly calling a method called "unknown_proxy"

[issue35907] [security][CVE-2019-9948] Unnecessary URL scheme exists to allow local_file:// reading file in urllib

2020-05-04 Thread Petter S
Petter S added the comment: The solution is incomplete because it fixes just this single security issue, not the inherent fragility of this file. If, in the future someone happens to add another method starting with open to this class, we are at risk of having the same problem again. As

[issue35907] [security][CVE-2019-9948] Unnecessary URL scheme exists to allow local_file:// reading file in urllib

2020-05-03 Thread Petter S
Petter S added the comment: We should whitelist the protocols. The current solution with `getattr` is really fragile. For example, this crashes with a `TypeError`: `URLopener().open("unknown_proxy://test")` -- nosy: +Petter S ___ Pyth

[issue27682] wsgiref BaseHandler / SimpleHandler can raise additional errors when handling an error

2019-07-22 Thread Petter S
Petter S added the comment: No it is not fixed in Django, but I verified that adding ConnectionAbortedError on this line https://github.com/django/django/blob/c6581a40be3bb4c1e13861f0adbb3fe01f09107f/django/core/servers/basehttp.py#L55 fixes the error

[issue27682] wsgiref BaseHandler / SimpleHandler can raise additional errors when handling an error

2019-07-22 Thread Petter S
Petter S added the comment: Could potentially already be fixed in Django: https://github.com/django/django/commit/7785e03ba89aafbd949191f126361fb9103cb980#diff-f6d1c75ec606389da5af6558bf57f171L51 -- ___ Python tracker <https://bugs.python.

[issue27682] wsgiref BaseHandler / SimpleHandler can raise additional errors when handling an error

2019-07-22 Thread Petter S
Petter S added the comment: The following message can still appear in the log when running the Django development server: Exception happened during processing of request from ('127.0.0.1', 50713) Traceback (most recent call last): File &q

[issue27682] wsgiref BaseHandler / SimpleHandler can raise additional errors when handling an error

2019-06-02 Thread Petter S
Change by Petter S : -- pull_requests: +13630 pull_request: https://github.com/python/cpython/pull/13748 ___ Python tracker <https://bugs.python.org/issue27

[issue35047] Better error messages in unittest.mock

2019-06-02 Thread Petter S
Change by Petter S : -- pull_requests: +13628 pull_request: https://github.com/python/cpython/pull/13746 ___ Python tracker <https://bugs.python.org/issue35

[issue27682] wsgiref BaseHandler / SimpleHandler can raise additional errors when handling an error

2019-04-04 Thread Petter S
Petter S added the comment: The pull request solves this problem, but the discussion over there is really slow. -- ___ Python tracker <https://bugs.python.org/issue27

[issue35656] More matchers in unittest.mock

2019-01-11 Thread Petter S
Petter S added the comment: I am of the opposite opinion. :-) > if I know roughly what the float should be why would I not want to test it > for exactness? When testing algorithms, it is often the case that the answer should be mathematically exactly 2, but due to floating

[issue35656] More matchers in unittest.mock

2019-01-09 Thread Petter S
Petter S added the comment: Agreed! The code above was a quick example. There are also functions in the standard library for approximate float matching that the "real" code would use. -- ___ Python tracker <https://bugs.python.o

[issue35656] More matchers in unittest.mock

2019-01-08 Thread Petter S
Petter S added the comment: Yes, something like this: class APPROXIMATE: """Takes a floating point number and implements approximate equality.""" def __init__(self, value): self.value = value def __eq__(self, other):

[issue35656] More matchers in unittest.mock

2019-01-04 Thread Petter S
New submission from Petter S : The ``ANY`` object in ``unittest.mock`` is also pretty useful when verifying dicts in tests: self.assertEqual(result, { "message": "Hi!", "code": 0, "id": mock.ANY }) Then it does

[issue27682] wsgiref BaseHandler / SimpleHandler can raise additional errors when handling an error

2018-11-04 Thread Petter S
Petter S added the comment: > I think this is what Petter is trying to do in > <https://github.com/python/cpython/pull/9713>. That's right. -- ___ Python tracker <https://bugs.p

[issue27682] wsgiref BaseHandler / SimpleHandler can raise additional errors when handling an error

2018-11-04 Thread Petter S
Change by Petter S : -- keywords: +patch pull_requests: +9624 stage: test needed -> patch review ___ Python tracker <https://bugs.python.org/issue27682> ___ _

[issue32972] unittest.TestCase coroutine support

2018-10-30 Thread Petter S
Petter S added the comment: As far as I am concerned, the discussion can continue in this issue. I still think a reasonable first step is to add a run hook to the regular TestCase class, like in PR 6051. But building consensus is a bit tricky

[issue34547] Wsgiref server does not handle closed connections gracefully

2018-10-27 Thread Petter S
Change by Petter S : -- pull_requests: +9475 ___ Python tracker <https://bugs.python.org/issue34547> ___ ___ Python-bugs-list mailing list Unsubscribe:

[issue34547] Wsgiref server does not handle closed connections gracefully

2018-10-25 Thread Petter S
Change by Petter S : -- pull_requests: -9438 ___ Python tracker <https://bugs.python.org/issue34547> ___ ___ Python-bugs-list mailing list Unsubscribe:

[issue34547] Wsgiref server does not handle closed connections gracefully

2018-10-25 Thread Petter S
Change by Petter S : -- pull_requests: -9437 ___ Python tracker <https://bugs.python.org/issue34547> ___ ___ Python-bugs-list mailing list Unsubscribe:

[issue34547] Wsgiref server does not handle closed connections gracefully

2018-10-25 Thread Petter S
Change by Petter S : -- pull_requests: +9437 ___ Python tracker <https://bugs.python.org/issue34547> ___ ___ Python-bugs-list mailing list Unsubscribe:

[issue34547] Wsgiref server does not handle closed connections gracefully

2018-10-25 Thread Petter S
Change by Petter S : -- pull_requests: +9437, 9438 ___ Python tracker <https://bugs.python.org/issue34547> ___ ___ Python-bugs-list mailing list Unsubscribe:

[issue34547] Wsgiref server does not handle closed connections gracefully

2018-10-25 Thread Petter S
Change by Petter S : -- pull_requests: -9419 ___ Python tracker <https://bugs.python.org/issue34547> ___ ___ Python-bugs-list mailing list Unsubscribe:

[issue35047] Better error messages in unittest.mock

2018-10-25 Thread Petter S
Change by Petter S : -- keywords: +patch pull_requests: +9420 stage: -> patch review ___ Python tracker <https://bugs.python.org/issue35047> ___ ___ Python-

[issue34547] Wsgiref server does not handle closed connections gracefully

2018-10-25 Thread Petter S
Change by Petter S : -- pull_requests: +9419 ___ Python tracker <https://bugs.python.org/issue34547> ___ ___ Python-bugs-list mailing list Unsubscribe:

[issue35047] Better error messages in unittest.mock

2018-10-24 Thread Petter S
Petter S added the comment: (The example above should have been "m.assert_has_calls([mock.call(3)])" but it does not affect my point.) -- ___ Python tracker <https://bugs.python.o

[issue35047] Better error messages in unittest.mock

2018-10-24 Thread Petter S
Petter S added the comment: Sure, consider the following code: from unittest import mock m = mock.Mock() m(1, 3) m("Test", data=[42]) When I call m.assert_not_called() I get the following error message: AssertionError: Expected 'mock' to not have been called. Call

[issue35047] Better error messages un unittest.mock

2018-10-23 Thread Petter S
New submission from Petter S : When developing unit tests with `unittest.mock`, it is common to see error messages like this: AssertionError: Expected 'info' to not have been called. Called 3 times. It would be really helpful if those 3 calls were listed in the assertion er

[issue27682] wsgiref: Windows Error 10053, ConnectionAbortedError: [WinError 10053] An established connection was aborted by the software in your host machine

2018-10-12 Thread Petter S
Petter S added the comment: The Github pull request https://github.com/python/cpython/pull/9713 addresses this. -- nosy: +Petter S ___ Python tracker <https://bugs.python.org/issue27

[issue34547] Wsgiref server does not handle closed connections gracefully

2018-10-05 Thread Petter S
Change by Petter S : -- keywords: +patch pull_requests: +9096 stage: -> patch review ___ Python tracker <https://bugs.python.org/issue34547> ___ ___ Python-

[issue34547] Wsgiref server does not handle closed connections gracefully

2018-08-30 Thread Petter S
New submission from Petter S : The server in the wsgiref module is actually used a lot. For example, it is the server Django uses for development. A very common thing that happens during Django development is that the web browser closes the connection for some reason. Then very long stack

[issue34547] Wsgiref server does not handle closed connections gracefully

2018-08-30 Thread Petter S
Change by Petter S : -- type: -> enhancement ___ Python tracker <https://bugs.python.org/issue34547> ___ ___ Python-bugs-list mailing list Unsubscrib

[issue33965] [Windows WSL] Fatal Python error: _Py_InitializeMainInterpreter: can't initialize time, after year 2038

2018-08-30 Thread Petter S
Petter S added the comment: I am updating this bug since someone may find it. The problem lies with WSL. After having my computer running for many days, this is the result of the uptime command: $ uptime 11:23:19 up -24855 days, -3:-14, 0 users, load average: 0.52, 0.58, 0.59 Restarting

[issue33965] [Windows WSL] Fatal Python error: _Py_InitializeMainInterpreter: can't initialize time, after year 2038

2018-07-12 Thread Petter S
Petter S added the comment: Makes sense. I fail to reproduce it myself. :-( -- ___ Python tracker <https://bugs.python.org/issue33965> ___ ___ Python-bugs-list m

[issue25155] Windows: datetime.datetime.now() raises an OverflowError for date after year 2038

2018-06-26 Thread Petter S
Petter S added the comment: I also compiled Python myself on WSL. The bug seemed to appear after computer had been running for a while. Before that, the interpreters were working normally. And after rebooting the problem disappeared

[issue25155] Windows: datetime.datetime.now() raises an OverflowError for date after year 2038

2018-06-25 Thread Petter S
Petter S added the comment: I get this error when starting the interpreter in Windows subsystem for Linux (WSL). I am using Python 2.7.15rc1 $ python --version Python 2.7.15rc1 $ python Fatal Python error: _Py_InitializeMainInterpreter: can't initialize

[issue25155] Windows: datetime.datetime.now() raises an OverflowError for date after year 2038

2018-06-25 Thread Petter S
Petter S added the comment: For Python 3: $ python3 --version Python 3.7.0b3 $ python3 Fatal Python error: _Py_InitializeMainInterpreter: can't initialize time OverflowError: timestamp too large to convert to C _PyTime_t Current thread 0x7f0232c21080 (most recent call first): Ab

[issue32972] unittest.TestCase coroutine support

2018-03-12 Thread Petter S
Petter S added the comment: Personally, I think John's PR is fine. (but the test class could arguably live in asyncio) I like that setUp, tearDown and test methods all can be async. But if setUp and tearDown should never be async as Yury commented above, they don't need runners. Th

[issue32972] unittest.TestCase coroutine support

2018-03-12 Thread Petter S
Petter S added the comment: John: inspect.iscoroutinefunction(meth) does not work if the method is decorated with e.g. unittest.mock.patch. -- ___ Python tracker <https://bugs.python.org/issue32

[issue32972] unittest.TestCase coroutine support

2018-03-10 Thread Petter S
Change by Petter S : -- keywords: +patch pull_requests: +5812 stage: -> patch review ___ Python tracker <https://bugs.python.org/issue32972> ___ ___ Python-

[issue32972] unittest.TestCase coroutine support

2018-03-08 Thread Petter S
Petter S added the comment: > 1. Do we need support for async versions of setUp, setUpClass, etc? In my > opinion: yes. I completely agree. I would imagine many or most real-world tests requiring async setUp. There is also the question on how a custom loop etc. can be used in the uni

[issue32972] unittest.TestCase coroutine support

2018-03-08 Thread Petter S
Petter S added the comment: > No, it shouldn't break them if you wrap async methods carefully. > Here's a metaclass that I wrote recently doing just that That code does not seem to work for me: https://gist.github.com/PetterS/f684095a09fd1d8164a4d8b28ce3932d I get "Runt

[issue32972] unittest.TestCase coroutine support

2018-03-06 Thread Petter S
Petter S added the comment: > Also, I personally subclassed TestCase in many of my projects specifically to > add async support. To do that you have to use a metaclass to scan class' > namespace for 'async def' functions. Doesn't that break when, for example, te

[issue32972] unittest.TestCase coroutine support

2018-03-06 Thread Petter S
Petter S added the comment: It's good to see others with the same idea as me. I just wrote https://github.com/python/cpython/pull/6005/commits/4d7e1837f235687c875e985e97701609fc1ac458 . In my opinion, there is no need for another test class. I completely agree with Zachary Ware tha

[issue32992] unittest: Automatically run coroutines in a loop

2018-03-06 Thread Petter S
Change by Petter S : -- keywords: +patch pull_requests: +5770 stage: -> patch review ___ Python tracker <https://bugs.python.org/issue32992> ___ ___ Python-