# Buggy code
def __get__(self, instance, instance_type):
    try:
        return super(ChannelField, self).__get__(instance, instance_type)
    except AttributeError:
        try:
            url = instance.url
            return self.unbox(instance, instance_type, Channel(url))
        except AttributeError:
            return Channel(None)


# Traceback (ValidationError)
conda install /scratch/xxx/anaconda/pkgs/conda-build-3.2.0-py27_0.tar.bz2
An unexpected error has occurred.
Please consider posting the following information to the
conda GitHub issue tracker at:

https://github.com/conda/conda/issues



Current conda install:

platform : linux-64
conda version : 4.3.25
conda is private : False
conda-env version : 4.3.25
conda-build version : 3.1.3
python version : 2.7.13.final.0
requests version : 2.14.2
root environment : /scratch/xxx/anaconda  (writable)
default environment : /scratch/xxx/anaconda
envs directories : /scratch/xxx/conda-envs
/scratch/xxx/anaconda/envs
/home/xxx/.conda/envs
package cache : /scratch/xxx/anaconda/pkgs
/home/xxx/.conda/pkgs
channel URLs : file:///scratch/xxx/conda-bld/linux-64
file:///scratch/xxx/conda-bld/noarch
https://repo.continuum.io/pkgs/free/linux-64
https://repo.continuum.io/pkgs/free/noarch
https://repo.continuum.io/pkgs/r/linux-64
https://repo.continuum.io/pkgs/r/noarch
https://repo.continuum.io/pkgs/pro/linux-64
https://repo.continuum.io/pkgs/pro/noarch
https://conda.anaconda.org/conda-forge/linux-64
https://conda.anaconda.org/conda-forge/noarch
config file : /home/xxx/.condarc
netrc file : None
offline mode : False
user-agent : conda/4.3.25 requests/2.14.2 CPython/2.7.13 Linux/2.6.18-422.el5 Red Hat Enterprise Linux Server/5.11 glibc/2.5
UID:GID : 7679:107679

`$ /scratch/xxx/anaconda/bin/conda install /scratch/xxx/anaconda/pkgs/conda-build-3.2.0-py27_0.tar.bz2`


Traceback (most recent call last):
File "/scratch/xxx/anaconda/lib/python2.7/site-packages/conda/exceptions.py", line 640, in conda_exception_handler
return_value = func(*args, **kwargs)
File "/scratch/xxx/anaconda/lib/python2.7/site-packages/conda/cli/main.py", line 140, in _main
exit_code = args.func(args, p)
File "/scratch/xxx/anaconda/lib/python2.7/site-packages/conda/cli/main_install.py", line 80, in execute
install(args, parser, 'install')
File "/scratch/xxx/anaconda/lib/python2.7/site-packages/conda/cli/install.py", line 210, in install
explicit(args_packages, prefix, verbose=not context.quiet)
File "/scratch/xxx/anaconda/lib/python2.7/site-packages/conda/misc.py", line 110, in explicit
execute_actions(actions, index, verbose=verbose)
File "/scratch/xxx/anaconda/lib/python2.7/site-packages/conda/plan.py", line 830, in execute_actions
execute_instructions(plan, index, verbose)
File "/scratch/xxx/anaconda/lib/python2.7/site-packages/conda/instructions.py", line 247, in execute_instructions
cmd(state, arg)
File "/scratch/xxx/anaconda/lib/python2.7/site-packages/conda/instructions.py", line 107, in UNLINKLINKTRANSACTION_CMD
txn = UnlinkLinkTransaction.create_from_dists(index, prefix, unlink_dists, link_dists)
File "/scratch/xxx/anaconda/lib/python2.7/site-packages/conda/core/link.py", line 125, in create_from_dists
for dist, pkg_dir in zip(link_dists, pkg_dirs_to_link))
File "/scratch/xxx/anaconda/lib/python2.7/site-packages/conda/core/link.py", line 125, in <genexpr>
for dist, pkg_dir in zip(link_dists, pkg_dirs_to_link))
File "/scratch/xxx/anaconda/lib/python2.7/site-packages/conda/gateways/disk/read.py", line 95, in read_package_info
paths_data=paths_data,
File "/scratch/xxx/anaconda/lib/python2.7/site-packages/conda/_vendor/auxlib/entity.py", line 702, in __call__
instance = super(EntityType, cls).__call__(*args, **kwargs)
File "/scratch/xxx/anaconda/lib/python2.7/site-packages/conda/_vendor/auxlib/entity.py", line 719, in __init__
setattr(self, key, kwargs[key])
File "/scratch/xxx/anaconda/lib/python2.7/site-packages/conda/_vendor/auxlib/entity.py", line 831, in __setattr__
super(ImmutableEntity, self).__setattr__(attribute, value)
File "/scratch/xxx/anaconda/lib/python2.7/site-packages/conda/_vendor/auxlib/entity.py", line 424, in __set__
instance.__dict__[self.name] = self.validate(instance, self.box(instance, val))
File "/scratch/xxx/anaconda/lib/python2.7/site-packages/conda/_vendor/auxlib/entity.py", line 465, in validate
raise ValidationError(getattr(self, 'name', 'undefined name'), val)
ValidationError: Value for url cannot be None.

# Fixed code
def __get__(self, instance, instance_type):
    try:
        return super(ChannelField, self).__get__(instance, instance_type)
    except AttributeError:
        url = instance.url
        return self.unbox(instance, instance_type, Channel(url))