This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: test_imp fails on OSX when LANG is set
Type: behavior Stage: test needed
Components: macOS Versions: Python 3.2
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: ronaldoussoren Nosy List: belopolsky, flox, ronaldoussoren, vstinner
Priority: normal Keywords: patch

Created on 2010-06-10 22:39 by belopolsky, last changed 2022-04-11 14:57 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
initfsencoding_apple.patch vstinner, 2010-06-10 23:53
test_sys.patch vstinner, 2010-06-11 00:47
issue8965-test.diff belopolsky, 2010-06-11 01:13
issue8965-test-1.diff belopolsky, 2010-06-11 01:22 Fixed test_sys.patch with comments
Messages (12)
msg107498 - (view) Author: Alexander Belopolsky (belopolsky) * (Python committer) Date: 2010-06-10 22:39
$ LANG=C ./python.exe -m test.regrtest test_imp
test_imp
test test_imp failed -- Traceback (most recent call last):
  File "Lib/test/test_imp.py", line 109, in test_issue5604
    self.assertEqual(fs_encoding, 'utf-8')
AssertionError: 'ascii' != 'utf-8'
- ascii+ utf-8

1 test failed:
    test_imp


Same with LC_ALL=C.  Passes on Linux.
msg107500 - (view) Author: Alexander Belopolsky (belopolsky) * (Python committer) Date: 2010-06-10 23:09
Is this check needed on darwin?  Why not simply set fs_encoding = 'utf-8'?
msg107501 - (view) Author: Ronald Oussoren (ronaldoussoren) * (Python committer) Date: 2010-06-10 23:27
I haven't looked at the actual test yet, but the filesystem encoding on OSX is UTF-8.
msg107503 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2010-06-10 23:53
Oooh. That's my fault. I introduced this regression in issue #8610 (commit r81190). Can you try attached patch please?

The file system encoding is hardcoded to 'utf-8' on Mac OS X (it should not depend on the locale).
msg107506 - (view) Author: Alexander Belopolsky (belopolsky) * (Python committer) Date: 2010-06-11 00:11
Victor,

Your patch works for me and makes sense even though I don't really know where Py_FileSystemDefaultEncoding is set on Darwin. :-)
msg107507 - (view) Author: Alexander Belopolsky (belopolsky) * (Python committer) Date: 2010-06-11 00:16
On the second thought, test_imp is not the right place to test this.  Can you add a sys module test for this issue?
msg107511 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2010-06-11 00:43
Patch commited as r81883 (blocked in 3.1: r81884).

> Can you add a sys module test for this issue?

Ok, I added a test to test_sys: r81885 (blocked in 3.1: r81886).

> I don't really know where Py_FileSystemDefaultEncoding 
> is set on Darwin. :-)

In Python/bltinmodule.c.
msg107512 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2010-06-11 00:47
Hum. To avoid regression, we should maybe have a test with the C locale. 

@belopolsky: Can you try test_sys.patch on Mac OS X?
msg107514 - (view) Author: Alexander Belopolsky (belopolsky) * (Python committer) Date: 2010-06-11 01:03
Nope.
$ ./python.exe -m test.regrtest test_sys
test test_sys failed -- Traceback (most recent call last):
  File "Lib/test/test_sys.py", line 877, in test_getfilesystemencoding
    self.assertEqual(fs_encoding, 'utf-8')
AssertionError: b'utf-8\n' != 'utf-8'

Should be easy to fix, though.
msg107516 - (view) Author: Alexander Belopolsky (belopolsky) * (Python committer) Date: 2010-06-11 01:18
Sorry for extra traffic.  I thought my patch introduced an indentation error, but it looks like you truly don't check sys.getfilesystemencoding() output if not on darwin.
msg107595 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2010-06-11 22:19
I commited issue8965-test-1.diff (r81916) with a minor changes: .strip() => .rstrip() and use @unittest.skipUnless().
msg107602 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2010-06-11 23:06
One more patch to check sys.getfilesystemencoding() on any OS (r81920).
History
Date User Action Args
2022-04-11 14:57:02adminsetgithub: 53211
2010-06-11 23:06:49vstinnersetmessages: + msg107602
2010-06-11 22:19:07vstinnersetmessages: + msg107595
2010-06-11 01:22:56belopolskysetfiles: + issue8965-test-1.diff
2010-06-11 01:18:18belopolskysetmessages: + msg107516
2010-06-11 01:13:55belopolskysetfiles: - issue8965-test.diff
2010-06-11 01:13:44belopolskysetfiles: + issue8965-test.diff
2010-06-11 01:08:03belopolskysetfiles: + issue8965-test.diff
2010-06-11 01:03:17belopolskysetmessages: + msg107514
2010-06-11 00:47:34vstinnersetfiles: + test_sys.patch

messages: + msg107512
2010-06-11 00:43:42vstinnersetstatus: open -> closed
resolution: fixed
messages: + msg107511
2010-06-11 00:16:25belopolskysetmessages: + msg107507
stage: test needed
2010-06-11 00:11:01belopolskysetmessages: + msg107506
2010-06-10 23:53:03vstinnersetfiles: + initfsencoding_apple.patch

nosy: + vstinner
messages: + msg107503

keywords: + patch
2010-06-10 23:27:36ronaldoussorensetmessages: + msg107501
2010-06-10 23:09:29belopolskysetnosy: + flox
messages: + msg107500
2010-06-10 22:39:38belopolskycreate