Code

Opened 6 years ago

Closed 2 years ago

#8238 closed Uncategorized (fixed)

django/db/__init__.py assumes it is loaded from the filesystem

Reported by: Guido van Rossum <guido@…> Owned by: nobody
Component: Database layer (models, ORM) Version: master
Severity: Normal Keywords:
Cc: bhuztez@… Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

There is code in the django.db package init.py that lists the available db backends. Unfortunately this code uses os.listdir() on a directory derived from file, and when loaded from a zip archive, this doesn't work. I have a quick hack that works around this, but perhaps there's a better way.

Attachments (2)

db.diff (1.0 KB) - added by Guido van Rossum <guido@…> 6 years ago.
patch
load-backend-pep-302.diff (1.2 KB) - added by bhuztez 2 years ago.
taken from pep-302.5.diff for #596

Download all attachments as: .zip

Change History (9)

Changed 6 years ago by Guido van Rossum <guido@…>

patch

comment:1 Changed 6 years ago by mtredinnick

  • milestone set to 1.0
  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
  • Triage Stage changed from Unreviewed to Accepted

comment:2 Changed 6 years ago by Guido van Rossum <guido@…>

ping?

comment:3 Changed 6 years ago by mtredinnick

The ticket is marked as 1.0. Not 1.0-beta. We addressed those first. It's still open. We'll get to it. :-)

comment:4 Changed 6 years ago by mtredinnick

  • Resolution set to fixed
  • Status changed from new to closed

(In [8424]) Fixed #8238 -- If an invalid database backend is mentioned in settings and the
environment doesn't support os.listdir(), we crashed whilst trying to construct
the friendly error message. This was not so friendly.

This patch handles that case (which occurs in real life in Google App Engine).
Patch from Guido van Rossum.

comment:5 Changed 3 years ago by jacob

  • milestone 1.0 deleted

Milestone 1.0 deleted

Changed 2 years ago by bhuztez

taken from pep-302.5.diff for #596

comment:6 Changed 2 years ago by bhuztez

  • Cc bhuztez@… added
  • Easy pickings unset
  • Resolution fixed deleted
  • Severity set to Normal
  • Status changed from closed to reopened
  • Type set to Uncategorized
  • UI/UX unset

The load-backend-pep-302 patch use pkgutil.iter_modules instead of os.listdir to solve this.

comment:7 Changed 2 years ago by ramiro

  • Resolution set to fixed
  • Status changed from reopened to closed

Thabks for the contribution. Please don't reopen closed for bugs reported and fixed a long time ago with the intention of proposing new features, even when the topics are tightly related. It pollutes ticket history and overall bug tracker stats (e.g. lifetime of tickets)

Open another, new ticket for that.

Version 0, edited 2 years ago by ramiro (next)

Add Comment

Modify Ticket

Change Properties
<Author field>
Action
as closed
as The resolution will be set. Next status will be 'closed'
The resolution will be deleted. Next status will be 'new'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.