mirror of
https://github.com/panda3d/panda3d.git
synced 2025-10-04 02:42:49 -04:00
A few modernisation fixes, mostly for Python 3 support
This commit is contained in:
parent
4b9da436a0
commit
088df4a3d2
@ -794,7 +794,7 @@ def _encode_entity(text, pattern=_escape):
|
||||
# the following functions assume an ascii-compatible encoding
|
||||
# (or "utf-16")
|
||||
|
||||
def _escape_cdata(text, encoding=None, replace=string.replace):
|
||||
def _escape_cdata(text, encoding=None):
|
||||
# escape character data
|
||||
try:
|
||||
if encoding:
|
||||
@ -802,14 +802,14 @@ def _escape_cdata(text, encoding=None, replace=string.replace):
|
||||
text = _encode(text, encoding)
|
||||
except UnicodeError:
|
||||
return _encode_entity(text)
|
||||
text = replace(text, "&", "&")
|
||||
text = replace(text, "<", "<")
|
||||
text = replace(text, ">", ">")
|
||||
text = text.replace("&", "&")
|
||||
text = text.replace("<", "<")
|
||||
text = text.replace( ">", ">")
|
||||
return text
|
||||
except (TypeError, AttributeError):
|
||||
_raise_serialization_error(text)
|
||||
|
||||
def _escape_attrib(text, encoding=None, replace=string.replace):
|
||||
def _escape_attrib(text, encoding=None):
|
||||
# escape attribute value
|
||||
try:
|
||||
if encoding:
|
||||
@ -817,11 +817,11 @@ def _escape_attrib(text, encoding=None, replace=string.replace):
|
||||
text = _encode(text, encoding)
|
||||
except UnicodeError:
|
||||
return _encode_entity(text)
|
||||
text = replace(text, "&", "&")
|
||||
text = replace(text, "'", "'") # FIXME: overkill
|
||||
text = replace(text, "\"", """)
|
||||
text = replace(text, "<", "<")
|
||||
text = replace(text, ">", ">")
|
||||
text = text.replace("&", "&")
|
||||
text = text.replace("'", "'") # FIXME: overkill
|
||||
text = text.replace("\"", """)
|
||||
text = text.replace("<", "<")
|
||||
text = text.replace(">", ">")
|
||||
return text
|
||||
except (TypeError, AttributeError):
|
||||
_raise_serialization_error(text)
|
||||
|
@ -68,24 +68,6 @@ from libpandaexpress import ConfigVariableBool
|
||||
|
||||
ScalarTypes = (types.FloatType, types.IntType, types.LongType)
|
||||
|
||||
import __builtin__
|
||||
if not hasattr(__builtin__, 'enumerate'):
|
||||
def enumerate(L):
|
||||
"""Returns (0, L[0]), (1, L[1]), etc., allowing this syntax:
|
||||
for i, item in enumerate(L):
|
||||
...
|
||||
|
||||
enumerate is a built-in feature in Python 2.3, which implements it
|
||||
using an iterator. For now, we can use this quick & dirty
|
||||
implementation that returns a list of tuples that is completely
|
||||
constructed every time enumerate() is called.
|
||||
"""
|
||||
return zip(xrange(len(L)), L)
|
||||
|
||||
__builtin__.enumerate = enumerate
|
||||
else:
|
||||
enumerate = __builtin__.enumerate
|
||||
|
||||
"""
|
||||
# with one integer positional arg, this uses about 4/5 of the memory of the Functor class below
|
||||
def Functor(function, *args, **kArgs):
|
||||
|
Loading…
x
Reference in New Issue
Block a user