Closed Bug 616922 Opened 14 years ago Closed 14 years ago

ignore Windows registry when detecting MIME types to fix test failure w/Python 2.7 and Windows

Categories

(Add-on SDK Graveyard :: General, defect)

x86_64
Windows 7
defect
Not set
normal

Tracking

(Not tracked)

RESOLVED FIXED

People

(Reporter: myk, Assigned: myk)

Details

(Whiteboard: [cherry-pick-1.0b1])

Attachments

(1 file)

The SDK appears to support Python 2.7 generally, but I noticed a problem when running the cfx tests on Windows:

--------------------------------------------------------------------------------
Testing cfx...
..F.....................................................................
======================================================================
FAIL: guess_mime_type (cuddlefish.server)
Doctest: cuddlefish.server.guess_mime_type
----------------------------------------------------------------------
Traceback (most recent call last):
  File "C:\Python27\lib\doctest.py", line 2166, in runTest
    raise self.failureException(self.format_failure(new.getvalue()))
AssertionError: Failed doctest test for cuddlefish.server.guess_mime_type
  File "Z:\myk\Projects\addon-sdk\python-lib\cuddlefish\server.py", line 69, in guess_mime_type

----------------------------------------------------------------------
File "Z:\myk\Projects\addon-sdk\python-lib\cuddlefish\server.py", line 84, in cuddlefish.server.guess_mime_type
Failed example:
    guess_mime_type('http://foo.com/blah.jpg')
Expected:
    'image/jpeg'
Got:
    'image/pjpeg'


----------------------------------------------------------------------
Ran 72 tests in 10.642s

FAILED (failures=1)
--------------------------------------------------------------------------------

According to http://bugs.python.org/issue10551, this is because 2.7 consults the registry for MIME types, and the registry is unreliable.  The workaround described in that bug is to initialize the mimetypes module in a way that prevents it from consulting the registry.

Here's a patch that does that and also updates README.txt to mention 2.7.
Attachment #495448 - Flags: review?(adw)
Comment on attachment 495448 [details] [diff] [review]
patch v1: fixes problem

Hmm, OK.  The server should probably not respond with Content-type "image/pjpeg" if a jpeg is requested of it.  Could you point to this bug in your mimetypes.init comment?
Attachment #495448 - Flags: review?(adw) → review+
Oh, I meant to add, are we officially supporting Python 2.7 now?  Was this the only thing holding us back?  At least the Troubleshooting and Getting Started pages mention that 2.5 or 2.6 is required.
(In reply to comment #1)
> Hmm, OK.  The server should probably not respond with Content-type
> "image/pjpeg" if a jpeg is requested of it.  Could you point to this bug in
> your mimetypes.init comment?

Yup, done.

(In reply to comment #2)
> Oh, I meant to add, are we officially supporting Python 2.7 now?  Was this the
> only thing holding us back?  At least the Troubleshooting and Getting Started
> pages mention that 2.5 or 2.6 is required.

As far as I know, this is the only thing holding us back.  I read back through the discussion group looking for issues with Python 2.7, and I didn't find any that could be definitively traced to that version.

Nevertheless, on second thought, we may not be ready to declare support for the version, so I reverted the change to README.txt and only made the change to server.py.


https://github.com/mozilla/addon-sdk/commit/01445464b620e861c4ccb746c3843cbf5523e534
Status: ASSIGNED → RESOLVED
Closed: 14 years ago
Resolution: --- → FIXED
Whiteboard: [cherry-pick-wanted]
https://github.com/mozilla/addon-sdk/commit/adeb09c0c31ba64e657aa3153bf9290ebfdd8a53
Whiteboard: [cherry-pick-wanted] → [cherry-pick-1.0b1]
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: