send_response
take a string instead of bytes: https://github.com/edx/edx-platform/blob/a9d4f3c972223b502ef1addd6621e31fa49e61e7/common/djangoapps/terrain/stubs/youtube.py#L112-L114self.assertContains
and self.assertNotContains
instead of converting response.content
from bytes
. Reason: self.assertContains
and self.assertNotContains
do the appropriate translations for us and they read much better.assertIn(..response.content)
cases.Question | Answer |
---|---|
What version of Python 3 should our code work on? | For webservices 3.5, For libraries, 3.5 and 3.6 |
How do I indicate that a repo works with Python 3? | Make sure that your openedx.yaml file has an up-to-date oeps section that indicates that your repo is OEP-7 compliant. See here for an example. |
Invalid Syntax ur"regex_string" | The If the string passes in other strings via to do this before interpolating them into your unicode regex string. |
Sorted with cmp seems to be broken? | The cmp argument of sorted goes away in python 3. You need to change how the sorting is done to be able to generate a sane order using the key function instead. |
response.content is now a bytestring | Option A (within a Django app): Convert any Option B (if not using Django.test): Convert string to be a bytestring. Example PR: TODO |
Output of random is inconsistent across Python versions | Option A (when no compatibility issues): Use Python3's Option B (when compatibility issues exist): If there are any data compatibility issues because of legacy code that assumes randomization consistency, use the random2 library in order to stick with Python2's old implementation. A situation where this might happen is if we're only storing a seed and recompute the state of a problem based on that seed using random.choice/shuffle/etc. as happens with Capa problems. See this thread. |