mirror of
https://github.com/python/cpython.git
synced 2025-11-21 19:24:44 +00:00
The _compat modules now export _floordiv() instead of _intdiv2() for
better code reuse. _split() Use _floordiv().
This commit is contained in:
parent
c5d1c045ab
commit
1c30aa2292
1 changed files with 4 additions and 5 deletions
|
|
@ -9,10 +9,10 @@ import email.base64MIME
|
||||||
from email.Charset import Charset
|
from email.Charset import Charset
|
||||||
|
|
||||||
try:
|
try:
|
||||||
from email._compat22 import _intdiv2
|
from email._compat22 import _floordiv
|
||||||
except SyntaxError:
|
except SyntaxError:
|
||||||
# Python 2.1 spells integer division differently
|
# Python 2.1 spells integer division differently
|
||||||
from email._compat21 import _intdiv2
|
from email._compat21 import _floordiv
|
||||||
|
|
||||||
CRLFSPACE = '\r\n '
|
CRLFSPACE = '\r\n '
|
||||||
CRLF = '\r\n'
|
CRLF = '\r\n'
|
||||||
|
|
@ -168,9 +168,8 @@ class Header:
|
||||||
last = charset.from_splittable(splittable[splitpnt:], 0)
|
last = charset.from_splittable(splittable[splitpnt:], 0)
|
||||||
return self._split(first, charset) + self._split(last, charset)
|
return self._split(first, charset) + self._split(last, charset)
|
||||||
else:
|
else:
|
||||||
# Divide and conquer. BAW: halfway depends on integer division.
|
# Divide and conquer.
|
||||||
# When porting to Python 2.2, use the // operator.
|
halfway = _floordiv(len(splittable), 2)
|
||||||
halfway = _intdiv2(len(splittable))
|
|
||||||
first = charset.from_splittable(splittable[:halfway], 0)
|
first = charset.from_splittable(splittable[:halfway], 0)
|
||||||
last = charset.from_splittable(splittable[halfway:], 0)
|
last = charset.from_splittable(splittable[halfway:], 0)
|
||||||
return self._split(first, charset) + self._split(last, charset)
|
return self._split(first, charset) + self._split(last, charset)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue