Login
[x]
Log in using an account from:
Fedora Account System
Red Hat Associate
Red Hat Customer
Or login using a Red Hat Bugzilla account
Forgot Password
Login:
Hide Forgot
Create an Account
Red Hat Bugzilla – Attachment 693154 Details for
Bug 906160
Review Request: python-feedgenerator - Standalone version of django.utils.feedgenerator
[?]
New
Simple Search
Advanced Search
My Links
Browse
Requests
Reports
Current State
Search
Tabular reports
Graphical reports
Duplicates
Other Reports
User Changes
Plotly Reports
Bug Status
Bug Severity
Non-Defaults
|
Product Dashboard
Help
Page Help!
Bug Writing Guidelines
What's new
Browser Support Policy
5.0.4.rh83 Release notes
FAQ
Guides index
User guide
Web Services
Contact
Legal
This site requires JavaScript to be enabled to function correctly, please enable it.
[patch]
Changes between python-feedgenerator and DJango1.5's feed generator
feedgenerator-changes-django-1.5.patch (text/plain), 12.88 KB, created by
Eduardo Echeverria
on 2013-02-05 05:44:21 UTC
(
hide
)
Description:
Changes between python-feedgenerator and DJango1.5's feed generator
Filename:
MIME Type:
Creator:
Eduardo Echeverria
Created:
2013-02-05 05:44:21 UTC
Size:
12.88 KB
patch
obsolete
>diff -urP utils1.5/encoding.py utils/encoding.py >--- utils1.5/encoding.py 2013-02-05 00:59:05.210503758 -0430 >+++ utils/encoding.py 2013-01-08 18:24:48.000000000 -0430 >@@ -10,8 +10,8 @@ > from urllib import quote > import warnings > >-from django.utils.functional import Promise >-from django.utils import six >+from .functional import Promise >+from . import six > > class DjangoUnicodeDecodeError(UnicodeDecodeError): > def __init__(self, obj, *args): >@@ -98,13 +98,25 @@ > if hasattr(s, '__unicode__'): > s = s.__unicode__() > else: >- if six.PY3: >- if isinstance(s, bytes): >- s = six.text_type(s, encoding, errors) >+ try: >+ if six.PY3: >+ if isinstance(s, bytes): >+ s = six.text_type(s, encoding, errors) >+ else: >+ s = six.text_type(s) > else: >- s = six.text_type(s) >- else: >- s = six.text_type(bytes(s), encoding, errors) >+ s = six.text_type(bytes(s), encoding, errors) >+ except UnicodeEncodeError: >+ if not isinstance(s, Exception): >+ raise >+ # If we get to here, the caller has passed in an Exception >+ # subclass populated with non-ASCII data without special >+ # handling to display as a string. We need to handle this >+ # without raising a further exception. We do an >+ # approximation to what the Exception's standard str() >+ # output should be. >+ s = ' '.join([force_text(arg, encoding, strings_only, >+ errors) for arg in s]) > else: > # Note: We use .decode() here, instead of six.text_type(s, encoding, > # errors), so that if s is a SafeBytes, it ends up being a >@@ -162,7 +174,7 @@ > # An Exception subclass containing non-ASCII data that doesn't > # know how to print itself properly. We shouldn't raise a > # further exception. >- return b' '.join([force_bytes(arg, encoding, strings_only, >+ return ' '.join([smart_bytes(arg, encoding, strings_only, > errors) for arg in s]) > return six.text_type(s).encode(encoding, errors) > else: >@@ -213,10 +225,10 @@ > # converted. > if iri is None: > return iri >- return quote(force_bytes(iri), safe=b"/#%[]=:;$&()+,!?*@'~") >+ return quote(smart_bytes(iri), safe=b"/#%[]=:;$&()+,!?*@'~") > > def filepath_to_uri(path): >- """Convert a file system path to a URI portion that is suitable for >+ """Convert an file system path to a URI portion that is suitable for > inclusion in a URL. > > We are assuming input is either UTF-8 or unicode already. >@@ -232,7 +244,7 @@ > return path > # I know about `os.sep` and `os.altsep` but I want to leave > # some flexibility for hardcoding separators. >- return quote(force_bytes(path.replace("\\", "/")), safe=b"/~!*()'") >+ return quote(smart_bytes(path.replace("\\", "/")), safe=b"/~!*()'") > > # The encoding of the default system locale but falls back to the > # given fallback encoding if the encoding is unsupported by python or could >diff -urP utils1.5/feedgenerator.py utils/feedgenerator.py >--- utils1.5/feedgenerator.py 2013-02-05 00:55:25.837491044 -0430 >+++ utils/feedgenerator.py 2013-01-08 18:24:48.000000000 -0430 >@@ -28,12 +28,12 @@ > from urllib.parse import urlparse > except ImportError: # Python 2 > from urlparse import urlparse >-from django.utils.xmlutils import SimplerXMLGenerator >-from django.utils.encoding import force_text, iri_to_uri >-from django.utils import datetime_safe >-from django.utils import six >-from django.utils.six import StringIO >-from django.utils.timezone import is_aware >+from .xmlutils import SimplerXMLGenerator >+from .encoding import force_text, iri_to_uri >+from . import datetime_safe >+from . import six >+from .six import StringIO >+from .timezone import is_aware > > def rfc2822_date(date): > # We can't use strftime() because it produces locale-dependant results, so >diff -urP utils1.5/functional.py utils/functional.py >--- utils1.5/functional.py 2013-02-05 00:59:37.671505639 -0430 >+++ utils/functional.py 2013-01-08 18:24:48.000000000 -0430 >@@ -3,7 +3,7 @@ > from functools import wraps, update_wrapper > import sys > >-from django.utils import six >+from . import six > > # You can't trivially replace this `functools.partial` because this binds to > # classes and returns bound instances, whereas functools.partial (on CPython) >@@ -293,16 +293,6 @@ > self._setup() > return self._wrapped.__dict__ > >- # Python 3.3 will call __reduce__ when pickling; these methods are needed >- # to serialize and deserialize correctly. They are not called in earlier >- # versions of Python. >- @classmethod >- def __newobj__(cls, *args): >- return cls.__new__(cls, *args) >- >- def __reduce__(self): >- return (self.__newobj__, (self.__class__,), self.__getstate__()) >- > # Need to pretend to be the wrapped class, for the sake of objects that care > # about this (especially in equality tests) > __class__ = property(new_method_proxy(operator.attrgetter("__class__"))) >diff -urP utils1.5/six.py utils/six.py >--- utils1.5/six.py 2013-02-05 01:00:17.933507972 -0430 >+++ utils/six.py 2013-01-08 18:24:48.000000000 -0430 >@@ -5,7 +5,7 @@ > import types > > __author__ = "Benjamin Peterson <benjamin@python.org>" >-__version__ = "1.2.0" >+__version__ = "1.1.0" > > > # True if we are running on Python 3. >@@ -26,23 +26,19 @@ > text_type = unicode > binary_type = str > >- if sys.platform == "java": >- # Jython always uses 32 bits. >+ # It's possible to have sizeof(long) != sizeof(Py_ssize_t). >+ class X(object): >+ def __len__(self): >+ return 1 << 31 >+ try: >+ len(X()) >+ except OverflowError: >+ # 32-bit > MAXSIZE = int((1 << 31) - 1) > else: >- # It's possible to have sizeof(long) != sizeof(Py_ssize_t). >- class X(object): >- def __len__(self): >- return 1 << 31 >- try: >- len(X()) >- except OverflowError: >- # 32-bit >- MAXSIZE = int((1 << 31) - 1) >- else: >- # 64-bit >- MAXSIZE = int((1 << 63) - 1) >- del X >+ # 64-bit >+ MAXSIZE = int((1 << 63) - 1) >+ del X > > > def _add_doc(func, doc): >@@ -205,19 +201,12 @@ > _iteritems = "iteritems" > > >-try: >- advance_iterator = next >-except NameError: >- def advance_iterator(it): >- return it.next() >-next = advance_iterator >- >- > if PY3: > def get_unbound_function(unbound): > return unbound > >- Iterator = object >+ >+ advance_iterator = next > > def callable(obj): > return any("__call__" in klass.__dict__ for klass in type(obj).__mro__) >@@ -225,10 +214,9 @@ > def get_unbound_function(unbound): > return unbound.im_func > >- class Iterator(object): > >- def next(self): >- return type(self).__next__(self) >+ def advance_iterator(it): >+ return it.next() > > callable = callable > _add_doc(get_unbound_function, >@@ -243,15 +231,15 @@ > > def iterkeys(d): > """Return an iterator over the keys of a dictionary.""" >- return iter(getattr(d, _iterkeys)()) >+ return getattr(d, _iterkeys)() > > def itervalues(d): > """Return an iterator over the values of a dictionary.""" >- return iter(getattr(d, _itervalues)()) >+ return getattr(d, _itervalues)() > > def iteritems(d): > """Return an iterator over the (key, value) pairs of a dictionary.""" >- return iter(getattr(d, _iteritems)()) >+ return getattr(d, _iteritems)() > > > if PY3: >@@ -370,20 +358,13 @@ > > if PY3: > _iterlists = "lists" >- _assertRaisesRegex = "assertRaisesRegex" > else: > _iterlists = "iterlists" >- _assertRaisesRegex = "assertRaisesRegexp" >- > > def iterlists(d): > """Return an iterator over the values of a MultiValueDict.""" > return getattr(d, _iterlists)() > > >-def assertRaisesRegex(self, *args, **kwargs): >- return getattr(self, _assertRaisesRegex)(*args, **kwargs) >- >- > add_move(MovedModule("_dummy_thread", "dummy_thread")) > add_move(MovedModule("_thread", "thread")) >diff -urP utils1.5/timezone.py utils/timezone.py >--- utils1.5/timezone.py 2013-02-05 00:58:12.828500722 -0430 >+++ utils/timezone.py 2013-01-08 18:24:48.000000000 -0430 >@@ -12,8 +12,8 @@ > except ImportError: > pytz = None > >-from django.conf import settings >-from django.utils import six >+# ### from django.conf import settings >+from . import six > > __all__ = [ > 'utc', 'get_default_timezone', 'get_current_timezone', >@@ -94,26 +94,25 @@ > utc = pytz.utc if pytz else UTC() > """UTC time zone as a tzinfo instance.""" > >-# In order to avoid accessing the settings at compile time, >-# wrap the expression in a function and cache the result. >-_localtime = None >- >-def get_default_timezone(): >- """ >- Returns the default time zone as a tzinfo instance. >- >- This is the time zone defined by settings.TIME_ZONE. >- >- See also :func:`get_current_timezone`. >- """ >- global _localtime >- if _localtime is None: >- if isinstance(settings.TIME_ZONE, six.string_types) and pytz is not None: >- _localtime = pytz.timezone(settings.TIME_ZONE) >- else: >- # This relies on os.environ['TZ'] being set to settings.TIME_ZONE. >- _localtime = LocalTimezone() >- return _localtime >+# ### # In order to avoid accessing the settings at compile time, >+# ### # wrap the expression in a function and cache the result. >+# ### _localtime = None >+# ### >+# ### def get_default_timezone(): >+# ### """ >+# ### Returns the default time zone as a tzinfo instance. >+# ### >+# ### This is the time zone defined by settings.TIME_ZONE. >+# ### >+# ### See also :func:`get_current_timezone`. >+# ### """ >+# ### global _localtime >+# ### if _localtime is None: >+# ### if isinstance(settings.TIME_ZONE, six.string_types) and pytz is not None: >+# ### _localtime = pytz.timezone(settings.TIME_ZONE) >+# ### else: >+# ### _localtime = LocalTimezone() >+# ### return _localtime > > # This function exists for consistency with get_current_timezone_name > def get_default_timezone_name(): >@@ -199,28 +198,28 @@ > activate(self.timezone) > > def __exit__(self, exc_type, exc_value, traceback): >- if self.old_timezone is None: >- deactivate() >- else: >+ if self.old_timezone is not None: > _active.value = self.old_timezone >+ else: >+ del _active.value > > >-# Templates >- >-def template_localtime(value, use_tz=None): >- """ >- Checks if value is a datetime and converts it to local time if necessary. >- >- If use_tz is provided and is not None, that will force the value to >- be converted (or not), overriding the value of settings.USE_TZ. >- >- This function is designed for use by the template engine. >- """ >- should_convert = (isinstance(value, datetime) >- and (settings.USE_TZ if use_tz is None else use_tz) >- and not is_naive(value) >- and getattr(value, 'convert_to_local_time', True)) >- return localtime(value) if should_convert else value >+# ### # Templates >+# ### >+# ### def template_localtime(value, use_tz=None): >+# ### """ >+# ### Checks if value is a datetime and converts it to local time if necessary. >+# ### >+# ### If use_tz is provided and is not None, that will force the value to >+# ### be converted (or not), overriding the value of settings.USE_TZ. >+# ### >+# ### This function is designed for use by the template engine. >+# ### """ >+# ### should_convert = (isinstance(value, datetime) >+# ### and (settings.USE_TZ if use_tz is None else use_tz) >+# ### and not is_naive(value) >+# ### and getattr(value, 'convert_to_local_time', True)) >+# ### return localtime(value) if should_convert else value > > > # Utilities >@@ -240,15 +239,15 @@ > value = timezone.normalize(value) > return value > >-def now(): >- """ >- Returns an aware or naive datetime.datetime, depending on settings.USE_TZ. >- """ >- if settings.USE_TZ: >- # timeit shows that datetime.now(tz=utc) is 24% slower >- return datetime.utcnow().replace(tzinfo=utc) >- else: >- return datetime.now() >+# ### def now(): >+# ### """ >+# ### Returns an aware or naive datetime.datetime, depending on settings.USE_TZ. >+# ### """ >+# ### if settings.USE_TZ: >+# ### # timeit shows that datetime.now(tz=utc) is 24% slower >+# ### return datetime.utcnow().replace(tzinfo=utc) >+# ### else: >+# ### return datetime.now() > > # By design, these four functions don't perform any checks on their arguments. > # The caller should ensure that they don't receive an invalid value like None.
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 906160
:
691870
| 693154