zerosleeps

Since 2010

Reproducing Django bug 34486

That Django bug I mentioned a few days ago is a slippery little devil. It’s related to the way a couple of methods available in Django’s contrib.postgres.search module construct their SQL statements. Something in the stack was assuming a connection to the database would be available earlier than is actually was, leading to an exception.

I won’t say it’s impossible to replicate the bug using Django’s test client, but I haven’t worked out a way to do so. Using the test client inside any of the test case classes which allow database interaction means a database connection is opened and maintained early enough. This doesn’t exercise the code path in question, so it never leads to that exception.

The solution I’ve come up with is to not use Django’s test client, instead using Python’s urllib. This means switching to LiveServerTestCase, but it more realistically mimics a fresh, cold, external request.

from django.test import LiveServerTestCase
import urllib.request


class SearchTestCase(LiveServerTestCase):
    def test_search_status(self):
        with urllib.request.urlopen(
            f"{self.live_server_url}/search/?query=foo"
        ) as request:
            self.assertEqual(request.status, 200)

Stop treating eBooks like paper books

What this bloke says, but I’ll expand it to say stop treating any digital medium like it’s physical ancestor. I get irrationally annoyed at work when we’re instructed to turn something that will never be printed on paper into an A4 sized PDF. It’s usually to mimic some governmental form, surprise surprise.

I’ve also grumbled about footnotes in books before - the content is either important enough to appear in the body of the text or it isn’t. I don’t think I’ve ever encountered a book on my Kindle that shows footnotes in a little pop-up dialogue though. I’d perhaps complain about them less if it wasn’t such a chore to get to the footnotes and back again.

Django bug

So I found a bug in Django’s psycopg3 implementation. In the current version as well! It was quickly flagged as a release blocker which made me feel… guilty? I know, strange reaction.

I’m a solo Python developer, so the process of submitting a pull request on such a prominent project isn’t something I ever do. Exciting and scary.

The kind folk responding to my comments are amazing. I didn’t actually have to do any work - just vaguely point in the right direction and shamelessly steal their suggested changes.

Your Competitor Wrote The RFP You’re Bidding On

Pay special attention to the “Nearly every RFP will have” section in this article.

I’ve been involved in these things a few times: as a customer creating the request, as a bidding provider responding to requests, and as a developer trying to meet the requirements and responses given. It’s always been a pencil-pushing exercise, fooling absolutely nobody, and generally a massive waste of everyone’s time. Vague requirements with watery responses which by themselves are arguably true, but when all the individual requirements and responses are put together the thing is pure fantasy.

Ubuntu advertisements

The current state of the default Ubuntu server shell:

Welcome to Ubuntu 22.04.2 LTS (GNU/Linux 5.15.0-69-generic x86_64)

 * Documentation:  https://help.ubuntu.com
 * Management:     https://landscape.canonical.com
 * Support:        https://ubuntu.com/advantage

  System information as of Sun Apr  9 07:03:41 UTC 2023

  System load:  0.0                Processes:             129
  Usage of /:   69.4% of 24.05GB   Users logged in:       0
  Memory usage: 44%                IPv4 address for eth0: [redacted]
  Swap usage:   81%                IPv4 address for eth0: [redacted]

  Get cloud support with Ubuntu Advantage Cloud Guest:
    http://www.ubuntu.com/business/services/cloud

 * Introducing Expanded Security Maintenance for Applications.
   Receive updates to over 25,000 software packages with your
   Ubuntu Pro subscription. Free for personal use.

     https://ubuntu.com/pro

Expanded Security Maintenance for Applications is not enabled.

0 updates can be applied immediately.

Enable ESM Apps to receive additional future security updates.
See https://ubuntu.com/esm or run: sudo pro status


You have no mail.
Last login: Sun Apr  9 01:00:19 2023 from [redacted]
[redacted]@[redacted]:~# 

That’s about 11 lines of advertisement, which is exactly 50% of the non-blank lines. Gross. Canonical’s gotta make their money somehow and I certainly don’t give them any, but this is the last server I have that’s running Ubuntu and I plan on moving it to Debian when version 12 is released.