2014.12.31 – Apparently Hell Has Frozen Over

I was kind of dragging this morning. Sort of feeling like I might be getting a cold but maybe just over tired. Once I was up and showered I felt fine though so maybe it was nothing. I got to work early as usual and as always Helen was there already. She is so nice. I am going to miss everyone when I’m done in just one short week.

I started reading over some of the other suggested things in our bug pack to see what I could work on next and got really involved in reading all about actions and how they work. So far I have learned that they are confusing! I asked Mele a few questions about them and she updated our main ticket so it had more information. She also gave me a few tips and said to ask her about anything that I didn’t understand.

Once I saw that Adam was in I asked if he’d take a peek at my PR from yesterday. I was pretty excited to get to merge it in and already had a +1 from Mele. He looked it over but had comments on a few things. A couple were trivial, a few were fine once we talked about them but one really had me confused. It was of course related to Unicode.

I don’t know if I can explain this because I don’t think I fully understand it but in Python 2.* str could be used for text and binary data. Python 2s unicode type became str in Python 3, str became bytes, and basestring was removed. So in 3 all strings are Unicode and 3 will never implicitly convert from strings to bytes and bytes to strings. If one is unsure what type of data they are dealing with things will probably break. Any string literal that should be treated as bytes should have the b prefix so Python 3 knows it is not dealing with a text string. Any string literal that should be Unicode/text in Python 2 should have the u literal prefix. Got that?

Aaaaaaaanyway, I had changed all basestring references to str since basestring went away. All was happy with my tests but since I don’t understand wtf is going on with all of these bytes and blah, blah, blah I did not get that now Python 2.* would puke if explicitly given some unicode (by prefixing the string with u) because str only accepts strings or bytes. Yeah. So I went searching for a way to deal with this but Adam has been doing this forever so found the solution in 2.5 seconds. I probably wouldn’t have known if I had found a solution or not so this was excellent. Once I looked at what he sent it made so much sense. I needed to check for the Python version first and then set a variable (string_type) to be either str or basestring. I got that all fixed up but really hated the syntax of the line I was working with. It was:

if isinstance(alert, string_type) or isinstance(alert, int):

But that seemed repetitive so I tried:

if isinstance(alert, (string_type, int)):

It was just a tiny change but I figured it out myself and it worked. Adam checked it out and gave me my next +1 so I was able to merge it in! That felt amazing.

While he was looking at stuff he noticed an issue with a docstring that would error while running doctests. We hadn’t been running them and they weren’t part of the SOP so I didn’t even think about it. Since I was done with my other ticket I took on fixing the docstring issue and setting up nose to run doctest automatically.

Doctest is kind of interesting. You can create docstrings in Python and they will be displayed when you type help (function) on the command line. They can also be used by reStructuredText Files which are used to create documentation. I’m sure I’m not explaining this clearly but it’s pretty nifty.

When I first ran doctest I got this ridiculous error – something, something, invalid Blackberry PIN – wha?? Holy crap, that was a live test! What the….I suspected doctest was accessing my test scripts that were in the top level directory but were in NO way named test anything. I had no idea that could happen but I moved all of my scripts and sure enough that was it. Good. To. Know.

That seemed pretty smart of doctest but now my errors were related to the tests it was running against dictionaries. Dictionaries are key:value pairs but are returned in no particular order. Doctest doesn’t like this so sometimes the tests pass but sometimes they don’t. That wouldn’t work. Now doctest didn’t seem very smart at all. I searched around and I guess the fix was really worse than just skipping the tests because it made the documentation difficult to read. The functionality was being tested in nose anyway so I think skipping them will be ok. I’ll find out Friday I guess.

I had my weekly 1-on-1 with Mele and told her how much I have loved being at Urban Airship and how much I am going to miss it. I really like all of the people. everyone has been so helpful and I have learned a TON. I’ve still got another week so I plan on making the most of it.

Partway through the day I could tell I was getting a cold for sure. We were supposed to spend New Year’s Eve playing games with Dale, Miri, Kronda and Jess but Jess messaged to say she had a cold. Well we both figured we shouldn’t go infect everyone so game night got postponed.

We decided to order pizza from Handsome Pizza even though BUDGET! because it is their very last night in that location. I am so sad! I’ll find them wherever they go though. Wayne picked me up and all I wanted to do was change into pajamas and sit by the fire. There was a nice one burning when we got home so I curled up on the couch until pizza was ready, ate and went right back to the couch.

Oh right, I nearly forgot about the title of this post. It’s actually, for real, sticking to the ground, snowing in Lake Havasu City, Arizona! I lived there for 25 years and it NEVER ever snowed. Friends were sending me pictures all day.

Today I learned about mojibake. Read it, it’s interesting.