Custom Query (121 matches)

Filters
 
Or
 
  
 
Columns

Show under each result:


Results (19 - 21 of 121)

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
Ticket Resolution Summary Owner Reporter
#4 fixed Inf and NaN handling needs re-vamp xi murphy@…

Reported by murphy@…, 8 years ago.

Description

Try:

yaml.load('...')

On Python 2.3.5 (on Windows) it gives:

>>> yaml.load('...')
Traceback (most recent call last):
  File "<stdin>", line 1, in ?
  File "c:\Python\Lib\site-packages\yaml\__init__.py", line 73, in load
    return loader.get_data()
  File "c:\Python\Lib\site-packages\yaml\constructor.py", line 40, in get_data
    return self.construct_document(self.get_node())
  File "c:\Python\Lib\site-packages\yaml\composer.py", line 24, in get_node
    return self.compose_document()
  File "c:\Python\Lib\site-packages\yaml\composer.py", line 38, in compose_document
    self.get_event()
  File "c:\Python\Lib\site-packages\yaml\parser.py", line 102, in get_event
    self.current_event = self.event_generator.next()
  File "c:\Python\Lib\site-packages\yaml\parser.py", line 123, in parse_stream
    StreamEndToken):
  File "c:\Python\Lib\site-packages\yaml\scanner.py", line 116, in check_token
    self.fetch_more_tokens()
  File "c:\Python\Lib\site-packages\yaml\scanner.py", line 191, in fetch_more_tokens
    if ch == u'.' and self.check_document_end():
  File "c:\Python\Lib\site-packages\yaml\scanner.py", line 704, in check_document_end
    prefix = self.peek(4)
  File "c:\Python\Lib\site-packages\yaml\reader.py", line 125, in peek
    return self.buffer[self.pointer+index]
IndexError: string index out of range
#14 fixed Inf and NaN handling needs re-vamp xi Scott David Daniels <Scott.Daniels@…>

Reported by Scott David Daniels <Scott.Daniels@…>, 8 years ago.

Description

Trying to import YAML fails in Python 2.5. Even simple patches fail, because the root cause is that NaNs and INFs cannot be marshalled/unmarshalled. Marshalling is used to save and restore compiled python modules, so a tested module can work initially, but later fail to load (when not from source).

When handling INFs and NaNs, you need to be careful. 1e300000 is not a safe way to represent infinity, and fails to pickle/unpickle safely from manifest constants. Different C runtimes represent the text for INFs and NaNs differently. Since Python 2.5 folds constants, a simple expression won't solve the problem.

The following changes should allow yaml to work on python 2.5a2 on Win2000 (and I think for 64-bit machines as well):

=============== constructor.py: ===============

*** 231,239 ****
          else:
              return sign*int(value)

-     inf_value = 1e300000
-     nan_value = inf_value/inf_value
-
      def construct_yaml_float(self, node):
          value = str(self.construct_scalar(node))
          value = value.replace('_', '')
--- 231,236 ----
***************
***************
*** 242,251 ****
              sign = -1
          if value[0] in '+-':
              value = value[1:]
!         if value.lower() == '.inf':
!             return sign*self.inf_value
!         elif value.lower() == '.nan':
!             return self.nan_value
          elif ':' in value:
              digits = [float(part) for part in value.split(':')]
              digits.reverse()
--- 239,253 ----
              sign = -1
          if value[0] in '+-':
              value = value[1:]
!         if value.lower() in ('.inf', '.nan'):
!             big = 1e300
!             bigger = big * big
!             while bigger > big and bigger == bigger:
!                 big = bigger
!                 bigger = big * big
!             if value.lower() == '.nan':
!                 return bigger / bigger
!             return sign * bigger
          elif ':' in value:
              digits = [float(part) for part in value.split(':')]
              digits.reverse()

=============== representer.py: ===============

*** 192,200 ****
      def represent_long(self, data):
          return self.represent_scalar(u'tag:yaml.org,2002:int', unicode(data))

!     repr_pos_inf = repr(1e300000)
!     repr_neg_inf = repr(-1e300000)
!     repr_nan = repr(1e300000/1e300000)

      def represent_float(self, data):
          repr_data = repr(data)
--- 192,206 ----
      def represent_long(self, data):
          return self.represent_scalar(u'tag:yaml.org,2002:int', unicode(data))

!     big = 1e300
!     bigger = big * big
!     while bigger > big and bigger == bigger:
!         big = bigger
!         bigger = big * big
!     repr_pos_inf = repr(bigger)
!     repr_neg_inf = repr(-bigger)
!     repr_nan = repr(bigger / bigger)
!     del big, bigger

      def represent_float(self, data):
          repr_data = repr(data)
#115 fixed Initialisation not ANSI compliant xi nothingmuch@…

Reported by nothingmuch@…, 6 years ago.

Description

Hi,

  1. Merijn Brand reported a bug against YAML::LibYAML involving a compliation error of scanner.c on HPUX:

 http://rt.cpan.org/Public/Bug/Display.html?id=42405

Supplied is a patch that hopefully resolves this issue.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
Note: See TracQuery for help on using queries.