classification
Title: test_httpservers fails with non-ascii path
Type: behavior Stage: resolved
Components: Tests Versions: Python 2.7
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: flox, mark.dickinson, vstinner
Priority: normal Keywords: buildbot

Created on 2010-01-10 18:15 by flox, last changed 2010-08-06 18:50 by mark.dickinson. This issue is now closed.

Messages (6)
msg97536 - (view) Author: Florent Xicluna (flox) * (Python committer) Date: 2010-01-10 18:15
/tmp/py2u…→unicode $ ./python Lib/test/regrtest.py test_httpservers
test_httpservers
  File "/tmp/tmplX9agF/cgi-bin/file1.py", line 1
SyntaxError: Non-ASCII character '\xe2' in file /tmp/tmplX9agF/cgi-bin/file1.py on line 1, but no encoding declared; see http://www.python.org/peps/pep-0263.html for details
[17270 refs]
  File "/tmp/tmpVDMVU4/cgi-bin/file1.py", line 1
SyntaxError: Non-ASCII character '\xe2' in file /tmp/tmpVDMVU4/cgi-bin/file1.py on line 1, but no encoding declared; see http://www.python.org/peps/pep-0263.html for details
[17270 refs]
  File "/tmp/tmpAh6jTS/cgi-bin/file1.py", line 1
SyntaxError: Non-ASCII character '\xe2' in file /tmp/tmpAh6jTS/cgi-bin/file1.py on line 1, but no encoding declared; see http://www.python.org/peps/pep-0263.html for details
[17270 refs]
  File "/tmp/tmpLPF9CV/cgi-bin/file2.py", line 1
SyntaxError: Non-ASCII character '\xe2' in file /tmp/tmpLPF9CV/cgi-bin/file2.py on line 1, but no encoding declared; see http://www.python.org/peps/pep-0263.html for details
[17270 refs]
test test_httpservers failed -- multiple errors occurred; run in verbose mode for details

1 test failed:
    test_httpservers
msg98098 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2010-01-21 02:59
CGIHTTPServerTestCase creates .py files with sys.executable in a shebang:
-----
cgi_file1 = """\
#!%s
..."""

with open(self.file1_path, 'w') as file1:
    file1.write(cgi_file1 % sys.executable)
-----
The shebang have to be the first line, and the encoding cookie (#coding:...) have to be written before any non-ASCII character. Since the shebang contains non-ASCII character, the cookie have to be written before... which is impossible.

Whereas issue #7708 contains the tested modules, this issue is specific to the tests themself.

Possible workaround: create a symbolic link to an ASCII directory (eg. "/tmp/python") and use the link in the shebang.
msg101573 - (view) Author: Florent Xicluna (flox) * (Python committer) Date: 2010-03-23 11:45
Fixed with r79297
msg112672 - (view) Author: Mark Dickinson (mark.dickinson) * (Python committer) Date: 2010-08-03 20:42
It looks like r79297 (or rather, its merge to release26-maint and release31-maint) caused test_httpservers to start failing on OS X.
msg112719 - (view) Author: Florent Xicluna (flox) * (Python committer) Date: 2010-08-03 22:49
Confirmed on 2.6 and 3.1 PPC Tiger and PPC Leopard buildbots.

Example (on PPC Leopard 2.6):
test_httpservers
'import site' failed; use -v for traceback
[16390 refs]
'import site' failed; use -v for traceback
[16390 refs]
'import site' failed; use -v for traceback
Traceback (most recent call last):
  File "/private/var/folders/xN/xNsmo12gFOi8bhXr5KKyyU+++TM/-Tmp-/tmpRBInYl/cgi-bin/file2.py", line 2, in <module>
    import cgi
  File "/Users/buildbot/buildarea/2.6.parc-leopard-1/build/Lib/cgi.py", line 37, in <module>
    from operator import attrgetter
ImportError: No module named operator
[16390 refs]
test test_httpservers failed -- Traceback (most recent call last):
  File "/Users/buildbot/buildarea/2.6.parc-leopard-1/build/Lib/test/test_httpservers.py", line 337, in test_post
    self.assertEquals(res.read(), '1, python, 123456\n')
AssertionError: '' != '1, python, 123456\n'


I would suggest to revert these backports from 2.6 and 3.1.
Obviously python is unable to find the "operator" C extension when it is run from a symbolic link.
And this symbolic link is only needed for corner cases (non-ASCII paths).
msg113122 - (view) Author: Mark Dickinson (mark.dickinson) * (Python committer) Date: 2010-08-06 18:50
This isn't a problem any more:  2.6 and 3.1 are now able to follow symbolic links.  Sorry for the noise!
History
Date User Action Args
2010-08-06 18:50:27mark.dickinsonsetstatus: open -> closed

messages: + msg113122
2010-08-03 22:49:17floxsetstatus: closed -> open

messages: + msg112719
2010-08-03 20:42:21mark.dickinsonsetnosy: + mark.dickinson
messages: + msg112672
2010-03-23 11:45:48floxsetstatus: open -> closed
priority: normal
messages: + msg101573

resolution: fixed
stage: needs patch -> resolved
2010-01-21 02:59:29vstinnersetnosy: + vstinner
messages: + msg98098
2010-01-15 16:29:31floxsetkeywords: + buildbot
stage: needs patch
2010-01-10 18:15:23floxcreate