Repository: conda/conda-build

Issue:
The curious case of NoneType
**DISCLAIMER**: All characters appearing in this work are fictitious (maybe?). Any resemblance to real persons, living or dead, is purely coincidental (perhaps?).

Bob and Henry belong to two different teams in the same company. Henry works in the backend dev team. Bob works for the devtools team. It is Bob's responsibility to provide conda packages for all the software the company writes (amidst other responsibilities, of course), but has no control over the release process of software of other teams. Henry's team recently released a new version of their software, Osiris. Henry and almost everybody else have left the office. The weekend is just about to begin, but there is one last thing left for Bob to do. Create a conda package for the latest release, so that it is available on Monday.

While building the new release, the build fails :sob: , with the error:
```python
Traceback (most recent call last):
  File "<stdin>", line 1337, in <module>
TypeError: 'NoneType' object is not iterable
``` 

But Bob doesn't give up, musters up courage, and goes ahead and writes a git-formatted-patch. Now his recipe reads:
```yaml
[root@hamunaptra osiris]# cat meta.yaml 
package:
    name: osiris
    version: 1.0.1

source:
    path: .
    patches:
        - 0001-Fix-TypeError-NoneType-in-func-findlibs.patch

...yada...yada..yada...
```

Bob is just 1 minute away from starting his weekend, when:
```bash
[root@hamunaptra osiris]# conda build .
Adding in variants from internal_defaults
INFO:conda_build.variants:Adding in variants from internal_defaults
Adding in variants from /root/conda_build_config.yaml
INFO:conda_build.variants:Adding in variants from /root/conda_build_config.yaml
Attempting to finalize metadata for osiris
INFO:conda_build.metadata:Attempting to finalize metadata for osiris
BUILD START: ['osiris-1.0.1-0.tar.bz2']
Copying /tmp/osiris to /opt/conda/conda-bld/osiris_1516518868448/work
<----------------------------------------------------------------------------------- Why is my patch not being applied?
source tree in: /opt/conda/conda-bld/osiris_1516518868448/work
# b00m! build fails, same error.
```

Now Bob curses Murphy (why the heck did he come up with that law?). He double checks his recipe, his patch, git version and everything (including whether he is already drunk or not), but the build still fails, because his patch is never applied. At this stage, Bob wants to pull his hair out, but he can't, because he is bald (by choice, of course).

Bob remembers that in a similar situation before, a colleague had sent him this: https://yarn.co/yarn-clip/1b19639f-d6e8-4fbe-9f68-380fb8b6536f

Now Bob scans through the conda-build code, line by line, function by function, until he stumbles upon https://github.com/conda/conda-build/blob/3.2.2/conda_build/metadata.py#L395 . That is a ray of hope :tada: !

Bob doesn't know whether that is a bug or a feature. :thinking: 

But Bob knows a workaround. He drops 'NoneType' from the filename of his patch file. And now the build succeeds. FINALLY!

Bob grabs his bag, keys and proceeds to his car to go home and enjoy the weekend and have some :beer: 

Over the weekend, Bob narrates this to his friend, who submits it as an issue on Github.



Discussion:
Great report.  I think the problem is in this overly simplistic line:

https://github.com/conda/conda-build/blob/3.2.2/conda_build/metadata.py#L227

I definitely think the issue here is a bug.

Resolving patch:
diff --git a/conda_build/metadata.py b/conda_build/metadata.py
--- a/conda_build/metadata.py
+++ b/conda_build/metadata.py
@@ -224,7 +224,7 @@ def _trim_None_strings(meta_dict):
                             keep.append(trimmed_dict)
                 # support lists of strings (homogeneous)
                 else:
-                    keep = [i for i in value if 'None' not in i]
+                    keep = [i for i in value if i not in ('None', 'NoneType')]
                 meta_dict[key] = keep
         else:
             log.debug("found unrecognized data type in dictionary: {0}, type: {1}".format(value,


Test patch: