[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#748195: python-socksipy: Exceptions take only one parameter, don't give 2!



Package: python-socksipy
Version: 1.0-1
Severity: minor
Tags: patch

Dear Maintainer,

When a connection can't be established an exception is raised.

This is good.

But exception __init__ take only one argument, and there are some places
in the code where 2 are given, resulting in TypeError exception being
raised, insteed of Socks5Error or simmilar.This is quite unfriendly, and
obviously not what was intended by the author.

Traceback (most recent call last):
(...)
  File "/usr/lib/python2.7/dist-packages/socks.py", line 369, in connect
    self.__negotiatesocks5(destpair[0],destpair[1])
  File "/usr/lib/python2.7/dist-packages/socks.py", line 236, in
__negotiatesocks5
    raise Socks5Error(ord(resp[1]),_generalerrors[ord(resp[1])])
TypeError: __init__() takes exactly 2 arguments (3 given)

Attached is a patch.

After patching, the proper exception is raised:

Traceback (most recent call last):
(...)
  File "/usr/lib/python2.7/dist-packages/socks.py", line 369, in connect
    self.__negotiatesocks5(destpair[0],destpair[1])
  File "/usr/lib/python2.7/dist-packages/socks.py", line 236, in
__negotiatesocks5
    raise Socks5Error((ord(resp[1]),_generalerrors[ord(resp[1])]))
socks.Socks5Error: (4, 'bad proxy type')

Thank you for maintaining that package :)


-- System Information:
Debian Release: 7.5
  APT prefers stable
  APT policy: (500, 'stable')
Architecture: amd64 (x86_64)

Kernel: Linux 3.2.0-4-amd64 (SMP w/1 CPU core)
Locale: LANG=en_GB.UTF-8, LC_CTYPE=en_GB.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash

Versions of packages python-socksipy depends on:
ii  python          2.7.3-4+deb7u1
ii  python-central  0.6.17

python-socksipy recommends no packages.

python-socksipy suggests no packages.

-- no debconf information
--- /usr/lib/python2.7/dist-packages/socks.py.orig	2006-10-25 22:19:26.000000000 +0200
+++ /usr/lib/python2.7/dist-packages/socks.py	2014-05-15 10:44:49.000000000 +0200
@@ -196,7 +196,7 @@
 			if authstat[1] != "\x00":
 				# Authentication failed
 				self.close()
-				raise Socks5AuthError,((3,_socks5autherrors[3]))
+				raise Socks5AuthError((3,_socks5autherrors[3]))
 			# Authentication succeeded
 		else:
 			# Reaching here is always bad
@@ -233,9 +233,9 @@
 			# Connection failed
 			self.close()
 			if ord(resp[1])<=8:
-				raise Socks5Error(ord(resp[1]),_generalerrors[ord(resp[1])])
+				raise Socks5Error((ord(resp[1]),_generalerrors[ord(resp[1])]))
 			else:
-				raise Socks5Error(9,_generalerrors[9])
+				raise Socks5Error((9,_generalerrors[9]))
 		# Get the bound address/port
 		elif resp[3] == "\x01":
 			boundaddr = self.__recvall(4)

Reply to: