Message121098
> For example, starting on line 152 we have,
> # Py3K
> #return unicode(self.compile())
> # Py2K
> return unicode(self.compile()).\
> encode('ascii', 'backslashreplace')
> # end Py2K
Ok, I can propose two different spellings of this without any
macro processor:
A. conditionally encode for 2.x
def __str__(self):
res = unicode(self.compile())
if sys.version_info < (3,):
res = res.encode('ascii', 'backslashreplace')
return res
B. (if A is deemed to incur too much per-call cost, due to
the version test)
if sys.version_info >= (3,):
def __str__(self):
return unicode(self.compile())
else:
def __str__(self):
return unicode(self.compile()). \
encode('ascii', 'backslashreplace')
In addition, I fail to see how the markup hfuru proposed can be
used to express this case. IIUC, he asks for markup that can tell
2to3 to leave a certain piece of code alone, i.e. unmodified. I
fail to see how this would help in this sqlalchemy example. |
|
Date |
User |
Action |
Args |
2010-11-13 00:17:15 | loewis | set | recipients:
+ loewis, hfuru, vstinner, benjamin.peterson, eric.araujo, bobbyi |
2010-11-13 00:17:12 | loewis | link | issue10070 messages |
2010-11-13 00:17:12 | loewis | create | |
|