Skip to content

Commit

Permalink
bpo-33549: Remove shim and deprecation warning to access DocumentLS.a…
Browse files Browse the repository at this point in the history
…sync. (pythonGH-6924)

`obj.async` is now a syntax error, so the warning/shim is
quasi-unnecessary.
  • Loading branch information
Carreau authored and serhiy-storchaka committed May 17, 2018
1 parent d5f1442 commit f90f5d5
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 32 deletions.
10 changes: 0 additions & 10 deletions Lib/test/test_minidom.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,17 +60,7 @@ def checkWholeText(self, node, s):
def testDocumentAsyncAttr(self):
doc = Document()
self.assertFalse(doc.async_)
with self.assertWarns(DeprecationWarning):
self.assertFalse(getattr(doc, 'async', True))
with self.assertWarns(DeprecationWarning):
setattr(doc, 'async', True)
with self.assertWarns(DeprecationWarning):
self.assertTrue(getattr(doc, 'async', False))
self.assertTrue(doc.async_)

self.assertFalse(Document.async_)
with self.assertWarns(DeprecationWarning):
self.assertFalse(getattr(Document, 'async', True))

def testParseFromBinaryFile(self):
with open(tstfile, 'rb') as file:
Expand Down
22 changes: 0 additions & 22 deletions Lib/xml/dom/xmlbuilder.py
Original file line number Diff line number Diff line change
Expand Up @@ -332,29 +332,10 @@ def startContainer(self, element):
del NodeFilter


class _AsyncDeprecatedProperty:
def warn(self, cls):
clsname = cls.__name__
warnings.warn(
"{cls}.async is deprecated; use {cls}.async_".format(cls=clsname),
DeprecationWarning)

def __get__(self, instance, cls):
self.warn(cls)
if instance is not None:
return instance.async_
return False

def __set__(self, instance, value):
self.warn(type(instance))
setattr(instance, 'async_', value)


class DocumentLS:
"""Mixin to create documents that conform to the load/save spec."""

async_ = False
locals()['async'] = _AsyncDeprecatedProperty() # Avoid DeprecationWarning

def _get_async(self):
return False
Expand Down Expand Up @@ -384,9 +365,6 @@ def saveXML(self, snode):
return snode.toxml()


del _AsyncDeprecatedProperty


class DOMImplementationLS:
MODE_SYNCHRONOUS = 1
MODE_ASYNCHRONOUS = 2
Expand Down

0 comments on commit f90f5d5

Please sign in to comment.