Skip to content

Commit

Permalink
Use six.PY3 instead of twisted.python.compat._PY3
Browse files Browse the repository at this point in the history
  • Loading branch information
altendky committed Sep 7, 2020
1 parent 860ff95 commit 9e864e5
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 9 deletions.
8 changes: 5 additions & 3 deletions src/treq/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,12 @@

from io import BytesIO

from six import PY3

from twisted.internet.interfaces import IProtocol
from twisted.internet.defer import Deferred
from twisted.python.components import proxyForInterface
from twisted.python.compat import _PY3, unicode
from twisted.python.compat import unicode
from twisted.python.filepath import FilePath
from hyperlink import DecodedURL, EncodedURL

Expand All @@ -33,7 +35,7 @@
from treq.response import _Response
from requests.cookies import cookiejar_from_dict, merge_cookies

if _PY3:
if PY3:
from urllib.parse import urlencode as _urlencode

def urlencode(query, doseq):
Expand Down Expand Up @@ -377,7 +379,7 @@ def _guess_content_type(filename):
registerAdapter(_from_bytes, bytes, IBodyProducer)
registerAdapter(_from_file, BytesIO, IBodyProducer)

if not _PY3:
if not PY3:
from StringIO import StringIO
registerAdapter(_from_file, StringIO, IBodyProducer)
# Suppress lint failure on Python 3.
Expand Down
6 changes: 4 additions & 2 deletions src/treq/multipart.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,15 @@
from io import BytesIO
from contextlib import closing

from six import PY3

from twisted.internet import defer, task
from twisted.python.compat import unicode, _PY3
from twisted.python.compat import unicode
from twisted.web.iweb import UNKNOWN_LENGTH, IBodyProducer

from zope.interface import implementer

if _PY3:
if PY3:
long = int

CRLF = b"\r\n"
Expand Down
4 changes: 3 additions & 1 deletion src/treq/test/test_multipart.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,16 @@
from twisted.trial import unittest
from zope.interface.verify import verifyObject

from six import PY3

from twisted.python import compat
from twisted.internet import task
from twisted.web.client import FileBodyProducer
from twisted.web.iweb import UNKNOWN_LENGTH, IBodyProducer

from treq.multipart import MultiPartProducer, _LengthConsumer

if compat._PY3:
if PY3:
long = int
unicode = compat.unicode

Expand Down
5 changes: 2 additions & 3 deletions src/treq/test/test_testing.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,13 @@

from mock import ANY

from six import text_type, binary_type
from six import text_type, binary_type, PY3

from twisted.trial.unittest import TestCase
from twisted.web.client import ResponseFailed
from twisted.web.error import SchemeNotSupported
from twisted.web.resource import Resource
from twisted.web.server import NOT_DONE_YET
from twisted.python.compat import _PY3

import treq

Expand Down Expand Up @@ -307,7 +306,7 @@ def test_repr(self):
"""
:obj:`HasHeaders` returns a nice string repr.
"""
if _PY3:
if PY3:
reprOutput = "HasHeaders({b'a': [b'b']})"
else:
reprOutput = "HasHeaders({'a': ['b']})"
Expand Down

0 comments on commit 9e864e5

Please sign in to comment.