Skip to content

Throwing ConnectionErrors instead of BrokenPipeErrors - #65

Closed
speendo wants to merge 13 commits into
Mic92:masterfrom
speendo:master
Closed

speendo wants to merge 13 commits into
Mic92:masterfrom
speendo:master

Conversation

@speendo

@speendo speendo commented Jan 13, 2016

Copy link
Copy Markdown

This should close
#64

I described all changes in the README (and more technical in comments in the code).

@Mic92

Mic92 commented Jan 14, 2016

Copy link
Copy Markdown
Owner

Hi, thanks for your work to fix this.
Usually changes of the README should not be part of the pull request. Especially since your actual commit fixing the bug also contains Readme changes, which should not be merged back into the project.
So this will break python 3.2, which is probably ok,
if there is not other easy way around it, but this have to be documented

@speendo

speendo commented Jan 14, 2016

Copy link
Copy Markdown
Author

Sorry, this is my first pull request :) didn't know how to do it. I reverted the README.rst to its original state.

I didn't know about the problem in Python 3.2 before the Travis checks on github. I think it wouldn't be too difficult to make it also work in Python 3.2. I would only have to find out which Exception is thrown in Python 3.2 and maybe add another condition for Python 3.2

But I got a bit of a problem with that - on my system (Debian Stretch) there are no packages for Python 3.2 anymore... how to find it out?

Another way would be to catch OSError instead which was present in Python 3.2 already. But I cannot guarantee that this wouldn't break something else...

@speendo

speendo commented Jan 27, 2016

Copy link
Copy Markdown
Author

Hi!

I don't know if you got a notification for this message so I post something else again ;-)

I tried to take care of Python 3.2 and I think "the skeleton" should be alright. However, there's still an issue with Python 3.2 - the travis output says

    except socket.error as e:

TypeError: catching classes that do not inherit from BaseException is not allowed

I cannot follow this issue, as there is a socket.error in Python 3.2... Does this maybe have something to do with the test and not the code? See line 338:

@unittest.skipIf(sys.version_info < (3, 0),
                     "Automatic decoding/encoding from the socket is only "
                     "available in Python 3")

Maybe this should be Python 3.3 not Python 3.0?

Do you have an opinion to that?

@speendo

speendo commented Jan 31, 2016

Copy link
Copy Markdown
Author

Hi!

I updated the code to catch socket.error instead of BrokenPipeError or any other exceptions.

Why did I do this?

  • For Python >= 3.3 we decided to catch OSError which has ConnectionError as child class (BrokenPipeError is a child class of ConnectionError)
  • In Python >= 3.3 socket.error is an alias for OSError
  • In Python < 3.3 i caught socket.error before, so I could remove the "python-version-switch"
  • As socket.error is deprecated in Python 3.5, I left the whole "switch-code" commented in the file in case socket.error is removed in the future.

Remaining problems

As you can see, the travis checks don't work anymore - they fail with the message

TypeError: catching classes that do not inherit from BaseException is not allowed

The reason for that is that the check mocks the socket-class, and therefore the socket-exceptions don't inherit from BaseException anymore. Find more on that here: http://stackoverflow.com/a/31873937/263589

Although I tried for a couple of hours, I couldn't get my head around the mock-library. Can you help me on that?

@makefu

makefu commented Feb 12, 2018

Copy link
Copy Markdown

Hey Ho, just wanted to check back what is blocking the PR. Any chance to get the changes merged?

@Mic92

Mic92 commented Feb 20, 2018

Copy link
Copy Markdown
Owner

merged in #92

@Mic92 Mic92 closed this Feb 20, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants