[Monetdb-developers] [Monetdb-checkins] clients/src/python/monetdb mapi.py, May2009, 1.4.2.4, 1.4.2.5 mapi25.py, May2009, 1.1.2.4, 1.1.2.5

Stefan Manegold Stefan.Manegold at cwi.nl
Sat Jun 13 13:28:28 CEST 2009


On Fri, Jun 12, 2009 at 01:23:36PM +0000, Gijs Molenaar wrote:
> Update of /cvsroot/monetdb/clients/src/python/monetdb
> In directory 23jxhf1.ch3.sourceforge.com:/tmp/cvs-serv13219/monetdb
> 
> Modified Files:
>       Tag: May2009
> 	mapi.py mapi25.py 
> Log Message:
> 
> * Fixed python3.0 errors. Please also run the tests with python3 when you
>   commit something

Just for info:
None of the machines in our testing pool runs/provides Python3.0 (as
default), yet; nightly testing uses Python 2.4, 2.5, 2.6.

Stefan

> * Unicode/UTF-8 should be working now, except for a small python3 problem
> 
> * python2.6 uses the mapi25.py now, since this is easier to manage.
>   mapi25.py will be renamed in the future
> 
> * added unicode and UTF-8 test
> 
> 
> U mapi.py
> Index: mapi.py
> ===================================================================
> RCS file: /cvsroot/monetdb/clients/src/python/monetdb/mapi.py,v
> retrieving revision 1.4.2.4
> retrieving revision 1.4.2.5
> diff -u -d -r1.4.2.4 -r1.4.2.5
> --- mapi.py	29 May 2009 12:01:20 -0000	1.4.2.4
> +++ mapi.py	12 Jun 2009 13:23:34 -0000	1.4.2.5
> @@ -130,7 +130,7 @@
>          logging.debug("II: executing command %s" % operation)
>  
>          if self.state != STATE_READY:
> -            raise(ProgrammingError, "Not connected")
> +            raise ProgrammingError("Not connected")
>  
>          self.__putblock(operation)
>          response = self.__getblock()
> @@ -154,24 +154,19 @@
>  
>          if protocol == '9':
>              algo = challenges[5]
> +            import hashlib
>              if algo == 'SHA512':
> -                import hashlib
> -                password = hashlib.sha512(password).hexdigest()
> +                password = hashlib.sha512(password.encode()).hexdigest()
>              elif algo == 'SHA384':
> -                import hashlib
> -                password = hashlib.sha384(password).hexdigest()
> +                password = hashlib.sha384(password.encode()).hexdigest()
>              elif algo == 'SHA256':
> -                import hashlib
> -                password = hashlib.sha256(password).hexdigest()
> +                password = hashlib.sha256(password.encode()).hexdigest()
>              elif algo == 'SHA224':
> -                import hashlib
> -                password = hashlib.sha224(password).hexdigest()
> +                password = hashlib.sha224(password.encode()).hexdigest()
>              elif algo == 'SHA1':
> -                import hashlib
> -                password = hashlib.sha1(password).hexdigest()
> +                password = hashlib.sha1(password.encode()).hexdigest()
>              elif algo == 'MD5':
> -                import hashlib
> -                password = hashlib.md5(password).hexdigest()
> +                password = hashlib.md5(password.encode()).hexdigest()
>              else:
>                  raise NotSupportedError("The %s hash algorithm is not supported" % algo)
>          elif protocol != "8":
> @@ -187,8 +182,8 @@
>          elif "MD5" in h:
>              import hashlib
>              m = hashlib.md5()
> -            m.update(password)
> -            m.update(salt)
> +            m.update(password.encode())
> +            m.update(salt.encode())
>              pwhash = "{MD5}" + m.hexdigest()
>          elif "crypt" in h:
>              import crypt
> @@ -212,28 +207,29 @@
>              if length > 0:
>                  result_bytes.write(self.__getbytes(length))
>  
> -        result = result_bytes.getvalue().decode()
> +        result = result_bytes.getvalue()
>          logging.debug("RX: %s" % result)
> -        return result
> +        return result.decode()
>  
>  
>      def __getbytes(self, bytes):
>          """Read an amount of bytes from the socket"""
>          try:
>              return self.socket.recv(bytes)
> -        except socket.error(errorStr):
> -            raise OperationalError(errorStr[1])
> +        except socket.error as error_str:
> +            raise OperationalError(error_str)
>  
>  
>      def __putblock(self, block):
>          """ wrap the line in mapi format and put it into the socket """
>          pos = 0
>          last = 0
> +        logging.debug("TX: %s" % block)
>          while not last:
> -            data = block[pos:MAX_PACKAGE_LENGTH]
> +            data = block[pos:MAX_PACKAGE_LENGTH].encode()
>              if len(data) < MAX_PACKAGE_LENGTH:
>                  last = 1
>              flag = struct.pack( '<h', ( len(data) << 1 ) + last )
>              self.socket.send(flag)
> -            self.socket.send(bytes(data.encode()))
> +            self.socket.send(data)
>              pos += len(data)
> 
> U mapi25.py
> Index: mapi25.py
> ===================================================================
> RCS file: /cvsroot/monetdb/clients/src/python/monetdb/mapi25.py,v
> retrieving revision 1.1.2.4
> retrieving revision 1.1.2.5
> diff -u -d -r1.1.2.4 -r1.1.2.5
> --- mapi25.py	29 May 2009 12:01:21 -0000	1.1.2.4
> +++ mapi25.py	12 Jun 2009 13:23:34 -0000	1.1.2.5
> @@ -191,8 +191,8 @@
>          elif "MD5" in h:
>              import hashlib
>              m = hashlib.md5()
> -            m.update(password)
> -            m.update(salt)
> +            m.update(password.encode())
> +            m.update(salt.encode())
>              pwhash = "{MD5}" + m.hexdigest()
>          elif "crypt" in h:
>              import crypt
> 
> 
> ------------------------------------------------------------------------------
> Crystal Reports - New Free Runtime and 30 Day Trial
> Check out the new simplified licensing option that enables unlimited
> royalty-free distribution of the report engine for externally facing 
> server and web deployment.
> http://p.sf.net/sfu/businessobjects
> _______________________________________________
> Monetdb-checkins mailing list
> Monetdb-checkins at lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/monetdb-checkins
> 
> 

-- 
| Dr. Stefan Manegold | mailto:Stefan.Manegold at cwi.nl |
| CWI,  P.O.Box 94079 | http://www.cwi.nl/~manegold/  |
| 1090 GB Amsterdam   | Tel.: +31 (20) 592-4212       |
| The Netherlands     | Fax : +31 (20) 592-4312       |




More information about the developers-list mailing list