Ticket #351 (closed task: fixed)

Opened 3 months ago

Last modified 2 months ago

Change all exception raises to be Python 3.0 compliant

Reported by: nick Owned by: nick
Priority: trivial Milestone: Python 3000
Component: Remoting Version: 0.3.1
Keywords: Cc:

Description

Python 3.0 demands that exceptions be raised with the following syntax:

ValueError('writable stream expected')

whereas Python < 3.0 allows the above syntax as well as:

ValueError, 'writable stream expected'

Refactor the code to be Python 3.0 compliant.

Change History

comment:1 Changed 3 months ago by nick

A quick grep comes up with quite a few:

Error: Failed to load processor shell
No macro or processor named 'shell' found

comment:2 Changed 3 months ago by nick

A quick grep comes up with quite a few:

egrep "^[ ]*raise [^,(]*," * -R | grep -v svn
pyamf/__init__.py:            raise TypeError, "klass must be a class type"
pyamf/__init__.py:                raise TypeError, "%s.__readamf__ must be callable" % (
pyamf/__init__.py:                raise TypeError, "%s.__writeamf__ must be callable" % (
pyamf/__init__.py:                raise TypeError, "attr_func must be callable"
pyamf/__init__.py:                raise ValueError, "attrs keyword must be specified for static classes"
pyamf/__init__.py:            raise TypeError, 'invalid class type %r' % self.klass
pyamf/__init__.py:            raise TypeError, "context must be of type %s.%s" % (
pyamf/__init__.py:            raise DecodeError, "Unsupported ActionScript type 0x%02x" % type
pyamf/__init__.py:            raise TypeError, "context must be of type %s.%s" % (
pyamf/__init__.py:        raise TypeError, "klass must be callable"
pyamf/__init__.py:        raise ValueError, "klass %s already registered" % klass
pyamf/__init__.py:        raise ValueError, "alias '%s' already registered" % alias
pyamf/__init__.py:        raise UnknownClassAlias, "Unknown alias %s" % alias
pyamf/__init__.py:        raise TypeError, "loader must be callable"
pyamf/__init__.py:        raise ValueError, "loader has already been registered"
pyamf/__init__.py:        raise LookupError, "loader not found"
pyamf/__init__.py:        raise ImportError, "Unable to import empty module"
pyamf/__init__.py:            raise TypeError, "Expecting class type or ClassAlias from loader"
pyamf/__init__.py:    raise UnknownClassAlias, "Unknown alias %s" % alias
pyamf/__init__.py:    raise UnknownClassAlias, "Unknown alias %s" % klass
pyamf/__init__.py:    raise ValueError, "Unknown encoding %s" % encoding
pyamf/__init__.py:    raise ValueError, "Unknown encoding %s" % encoding
pyamf/__init__.py:    raise ValueError, "Unknown encoding %s" % encoding
pyamf/__init__.py:        raise UnknownClassAlias, alias
pyamf/__init__.py:            raise TypeError, "Unable to add '%r' as a custom type (expected a class or callable)" % type_
pyamf/__init__.py:        raise KeyError, 'Type %r already exists' % type_
pyamf/__init__.py:    raise KeyError, "Unknown type %r" % type_
pyamf/__init__.py:        raise TypeError, "klass must be a class type"
pyamf/__init__.py:        raise TypeError, 'error classes must subclass the __builtin__.Exception class'
pyamf/__init__.py:        raise ValueError, 'Code %s is already registered' % code
pyamf/__init__.py:            raise ValueError, 'Code %s is not registered' % klass
pyamf/__init__.py:            raise ValueError, 'Class %s is not registered' % klass
pyamf/__init__.py:        raise TypeError, "Invalid type, expected class or string"
pyamf/amf0.py:                raise pyamf.EncodeError, "Unable to encode '%r'" % (data,)
pyamf/amf3.py:                raise pyamf.UnknownClassAlias, 'Anonymous class definitions do not have class aliases'
pyamf/amf3.py:            raise pyamf.DecodeError, "Unknown AMF3 type 0x%02x at %d" % (type, self.stream.tell() - 1)
pyamf/amf3.py:            raise pyamf.EncodeError, "Decoding an object in amf3 tagged as amf0 only is not allowed"
pyamf/amf3.py:            raise pyamf.DecodeError, "Unknown object encoding"
pyamf/amf3.py:                raise ValueError, "Non int/str key value found in dict"
pyamf/amf3.py:                raise pyamf.EncodeError, "dicts cannot contain empty string keys"
pyamf/amf3.py:                    raise pyamf.EncodeError, 'Unable to determine object attributes'
pyamf/amf3.py:                raise pyamf.EncodeError, "Encoding an object in amf3 tagged as amf0 only"
pyamf/amf3.py:        raise ValueError, "Out of range"
pyamf/remoting/__init__.py:        raise TypeError, "Unknown message type"
pyamf/remoting/__init__.py:        raise RuntimeError, "Unable to fully consume the buffer"
pyamf/remoting/amf3.py:            raise ServerCallFailed, "Unknown request: %s" % ro_request
pyamf/remoting/amf3.py:            raise ServerCallFailed, "Authorization is not supported in RemoteObject"
pyamf/remoting/amf3.py:            raise ServerCallFailed, "Unknown Command operation %s" % ro_request.operation
pyamf/remoting/client/__init__.py:            raise AttributeError, "'RequestWrapper' object has no attribute 'result'"
pyamf/remoting/client/__init__.py:            raise ValueError, 'Unknown scheme'
pyamf/remoting/client/__init__.py:            raise TypeError, 'string type required'
pyamf/remoting/client/__init__.py:        raise LookupError, "request %s not found" % id_
pyamf/remoting/client/__init__.py:        raise LookupError, "request not found"
pyamf/remoting/client/__init__.py:                raise remoting.RemotingError, "HTTP Gateway reported status %d %s" % (
pyamf/remoting/client/__init__.py:            raise remoting.RemotingError, "HTTP Gateway reported status %d" % (
pyamf/remoting/client/__init__.py:            raise remoting.RemotingError, "Incorrect MIME type received. (got: %s)" % content_type
pyamf/remoting/gateway/__init__.py:                raise InvalidServiceMethodError, \
pyamf/remoting/gateway/__init__.py:                raise UnknownServiceMethodError, \
pyamf/remoting/gateway/__init__.py:                raise InvalidServiceMethodError, \
pyamf/remoting/gateway/__init__.py:            raise UnknownServiceMethodError, \
pyamf/remoting/gateway/__init__.py:            raise TypeError, "dict type required for services"
pyamf/remoting/gateway/__init__.py:            raise TypeError, "service cannot be a scalar value"
pyamf/remoting/gateway/__init__.py:            raise TypeError, "service must be callable, a module, or an object"
pyamf/remoting/gateway/__init__.py:            raise remoting.RemotingError, "Service %s already exists" % name
pyamf/remoting/gateway/__init__.py:            raise NameError, "Service %s not found" % str(service)
pyamf/remoting/gateway/__init__.py:        raise RuntimeError, "Something went wrong ..."
pyamf/remoting/gateway/__init__.py:        raise UnknownServiceError, "Unknown service %s" % target
pyamf/remoting/gateway/__init__.py:        raise TypeError, "func must be callable"
pyamf/remoting/gateway/__init__.py:        raise TypeError, "authenticator must be callable"
pyamf/remoting/gateway/__init__.py:        raise TypeError, "func must be callable"
pyamf/remoting/gateway/__init__.py:        raise TypeError, "func must be callable"
pyamf/remoting/gateway/__init__.py:        raise TypeError, "preprocessor must be callable"
pyamf/sol.py:        raise pyamf.DecodeError, 'Unknown SOL version in header'
pyamf/sol.py:        raise pyamf.DecodeError, 'Inconsistent stream header length'
pyamf/sol.py:        raise pyamf.DecodeError, 'Invalid signature'
pyamf/sol.py:        raise pyamf.DecodeError, 'Invalid padding read'
pyamf/sol.py:            raise pyamf.DecodeError, 'Missing padding byte'
pyamf/sol.py:        raise ValueError, 'readable stream expected'
pyamf/sol.py:        raise ValueError, 'writable stream expected'
pyamf/tests/test_gateway.py:            raise TypeError, "unknown type"
pyamf/tests/test_gateway.py:            raise TypeError, "unknown type"
pyamf/util/__init__.py:            raise TypeError, "Unable to coerce buf->StringIO"
pyamf/util/__init__.py:                raise NameError, "Inconsistent hierarchy"
pyamf/util/__init__.py:        raise TypeError, 'class type expected'
pyamf/util/imports.py:        raise ImportError, 'No module named %s' % subname
pyamf/util/imports.py:                raise ImportError, 'No module name %d' % modname

comment:3 Changed 3 months ago by nick

  • status changed from new to accepted

comment:4 Changed 3 months ago by nick

  • keywords review added
  • owner changed from nick to thijs
  • status changed from accepted to assigned

Ready for review in r1643.

comment:5 Changed 3 months ago by thijs

  • keywords review removed
  • owner changed from thijs to nick

Added some doc changes in r1647

comment:6 Changed 3 months ago by nick

  • status changed from assigned to closed
  • resolution set to fixed

Merged in r1648.

comment:7 Changed 2 months ago by thijs

  • milestone changed from 0.4 to Python 3000
Note: See TracTickets for help on using tickets.