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.

Author steve.dower
Recipients brett.cannon, cheryl.sabella, steve.dower, vinay.sajip
Date 2019-01-11.04:39:54
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1547181594.26.0.447414383097.issue35661@roundup.psfhosted.org>
In-reply-to
Content
Your tests actually went the other way. This one puts a trailing space after the prompt and expected it to be there in the file, but also ensured that exactly one space was added at the start.

        self.assertEqual(context.prompt, '(My prompt) ')
        builder.create(self.env_dir)
        data = self.get_text_file_contents('pyvenv.cfg')
        self.assertIn('prompt = (My prompt) \n', data)

In the line "prompt = (My prompt) ", we need to define which of the spaces at either end of the value should be retained by tools trying to use the same prompt. The obvious assumption is to strip both ends, which would break your test. The next most obvious is to quote the string value (e.g. write repr(context.prompt) instead of the prompt directly).

Also, I'm pretty sure I saw some advice once to use multiple lines worth of prompt, which probably breaks many shells but presumably works okay in Bash. You'll need to handle that case as well - again, repr() will do it naturally by encoding newlines an "\n".

Anyone reading the string will have to do the equivalent of Python's literal_eval(), but that's pretty manageable in exchange for avoiding a whole lot of edge cases.
History
Date User Action Args
2019-01-11 04:39:56steve.dowersetrecipients: + steve.dower, brett.cannon, vinay.sajip, cheryl.sabella
2019-01-11 04:39:54steve.dowersetmessageid: <1547181594.26.0.447414383097.issue35661@roundup.psfhosted.org>
2019-01-11 04:39:54steve.dowerlinkissue35661 messages
2019-01-11 04:39:54steve.dowercreate