[Python-3000] setup.py fails in the py3k-struni branch

Ron Adam rrr at ronadam.com
Thu Jun 14 01:49:26 CEST 2007



Guido van Rossum wrote:
> I couldn't get this exact patch to apply, but I implemented something
> equivalent in the py3kstruni branch. See revisions 55964 and 55965.
> Thanks for the suggestion!

This is actually closer to how I started to do it, but I wasn't sure if it 
would catch everything.  Looking at it again, it looks good with the 
exception of riscos.  (The added test should catch that if it's a problem 
so it can be fixed later.)

The reason I made a new test case for added tests is that the existing test 
case based on mapping_tests.BasicTestMappingProtocol doesn't run the added 
test methods.  So I put those under a new test case based on unittest.TestCase.

I can't re-verify this currently because the latest merge broke something 
in my build process.  I'm getting a "lost stderr" message.  I've seen it 
before so it's probably something on my end.  I think the last time this 
happened to me I was able to clear it up by deleting the branch and 
re-updating it.



Another suggestion is to make a change in stringobject.c to represent 8 
bits strings as "str8('somes_tring')"  or just s"some_string" so they can 
more easily be found from unicode strings.  Particularly in the tests. 
This will force a few more tests to fail, but they are things that need to 
be fixed.  Only about 3 or 4 additional modules fail when I tried it.

I was getting failed expect/got test cases that looked exactly the same. 
But after changing the str8 representation those became obvious st8 vs 
unicode comparisons.

Using the shorter 's"string"' form will cause places, where eval or exec 
are using str8, to cause syntax errors.  Which may also be helpful.


BTW,  I will make a new remove_raw_escapes patch so it applies cleanly. 
I'm trying to track down why my patched version of test_tokenize.py passes 
sometimes but not at others.  (I think it's either a tempfile or string io 
issue, or both.)  This was what initiated the above suggestion.

;-)


Cheers,
    Ron


> --Guido
> 
> On 6/12/07, Ron Adam <rrr at ronadam.com> wrote:
>> Guido van Rossum wrote:
>> > On 6/7/07, "Martin v. Löwis" <martin at v.loewis.de> wrote:
>> >> >> The os.environ.get() method probably should return a unicode
>> >> string. (?)
>> >> >
>> >> > Indeed -- care to contribute a patch?
>> >>
>> >> Ideally, such a patch would make use of the Win32 Unicode API for
>> >> environment variables on Windows. People had already been complaining
>> >> that they can't have "funny characters" in the value of an environment
>> >> variable, even though the UI allows them to set the variable just 
>> fine.
>> >
>> > Yeah, but the Windows build of py3k is currently badly broken (e.g.
>> > the _fileio.c extension probably doesn't work at all) -- and I don't
>> > have access to a Windows box to work on it. I'm afraid 3.0a1 will be
>> > released without Windows support. Of course I'm counting on others to
>> > fix that before 3.0 final is released.
>> >
>> > I don't mind for now that the posix.environ variable contains 8-bit
>> > strings -- people shouldn't be importing that anyway.
>>
>>
>> Here's a diff of the patch.  It looks like this may be backported to 2.6
>> since it isn't Unicode specific but casts to the current str type.
>>
>>
>>
>> Cast environ keys and values to current python str type in os.py
>> Added test for environ string types to test_os.py
>> Fixed test_update2, bug 1110478 test, that was being skipped.
>>
>> Test test_tmpfile in test_os.py fails.  Haven't looked into it yet.
>>
>>
>> Index: Lib/os.py
>> ===================================================================
>> --- Lib/os.py   (revision 55924)
>> +++ Lib/os.py   (working copy)
>> @@ -505,7 +505,8 @@
>>               def copy(self):
>>                   return dict(self)
>>
>> -
>> +    # Make sure all environment keys and values are correct str type.
>> +    environ = dict([(str(k), str(v)) for k, v in environ.items()])
>>       environ = _Environ(environ)
>>
>>   def getenv(key, default=None):
>> Index: Lib/test/test_os.py
>> ===================================================================
>> --- Lib/test/test_os.py (revision 55924)
>> +++ Lib/test/test_os.py (working copy)
>> @@ -266,12 +266,25 @@
>>           os.environ.clear()
>>           os.environ.update(self.__save)
>>
>> +class EnvironTests2(unittest.TestCase):
>> +    """Test os.environ for specific problems."""
>> +    def setUp(self):
>> +        self.__save = dict(os.environ)
>> +    def tearDown(self):
>> +        os.environ.clear()
>> +        os.environ.update(self.__save)
>>       # Bug 1110478
>>       def test_update2(self):
>>           if os.path.exists("/bin/sh"):
>>               os.environ.update(HELLO="World")
>>               value = os.popen("/bin/sh -c 'echo $HELLO'").read().strip()
>>               self.assertEquals(value, "World")
>> +    # Verify environ keys and values from the OS are of the
>> +    # correct str type.
>> +    def test_keyvalue_types(self):
>> +        for key, val in os.environ.items():
>> +            self.assertEquals(type(key), str)
>> +            self.assertEquals(type(val), str)
>>
>>   class WalkTests(unittest.TestCase):
>>       """Tests for os.walk()."""
>> @@ -466,6 +479,7 @@
>>           TemporaryFileTests,
>>           StatAttributeTests,
>>           EnvironTests,
>> +        EnvironTests2,
>>           WalkTests,
>>           MakedirTests,
>>           DevNullTests,
>>
>>
>>
> 
> 


More information about the Python-3000 mailing list