GithubHelp home page GithubHelp logo

Comments (14)

ohler55 avatar ohler55 commented on June 18, 2024

Can you send me the file?

from ox.

trevorrowe avatar trevorrowe commented on June 18, 2024

I've emailed you the xml file.

from ox.

ohler55 avatar ohler55 commented on June 18, 2024

Thanks for the file.

I wrote the following test and got no errors. What are you doing differently? I am also using version 1.5.3 with Ruby 1.9.3-p125. If you can send me a short bit of Ruby code where it breaks I would like to get the problem fixed.

require 'stringio'
require 'ox'

class MySax < ::Ox::Sax
def initialize(); end
def start_element(name); end
def attr(name, value); end
def instruct(target); end
def doctype(value); end
def comment(value); end
def cdata(value); end
def text(value); end
def end_element(name); end
def error(message, line, column)
puts "Error: #{message} at #{line}:#{column}"
end
end

s = File.read('describe_images.xml')
io = StringIO.new(s)
Ox.sax_parse(::Ox::Sax.new, io)
Ox.sax_parse(MySax.new, io)

from ox.

trevorrowe avatar trevorrowe commented on June 18, 2024

I had no issues running the example you gave me, yet my benchmark code continued failing. I was finally able to produce a minimal case that demonstrates the error. It has nothing to do with the size of the file xml string (as you can see by the sample below). It appears to be an issue when run from within a rake task. All my other tests are run as Rspec tests, which explains why they worked.

Here are the steps to reproduce.

I ran this with the following versions:

  • ruby-1.9.3-p125
  • ox-1.5.3
  • rake-0.9.2.2
  • rubygems-1.8.21

Given the following Gemfile:

source 'http://rubygems.org'

gem 'ox'
gem 'rake'

The following Rakefile:

require 'bundler/setup'

Bundler.require

root = File.dirname(__FILE__)
tasks_dir = File.join(root, "tasks")
$:.unshift(tasks_dir)
$:.unshift(File.join(root, "lib"))

Dir[File.join(tasks_dir, "**", "*.rake")].each do |task_file|
  load task_file
end

And the following task file (tasks/demo_error.rake):

task :demo_error do

  require 'stringio'
  require 'ox'

  class MySax < ::Ox::Sax
    def initialize(); end
    def start_element(name); end
    def attr(name, value); end
    def instruct(target); end
    def doctype(value); end
    def comment(value); end
    def cdata(value); end
    def text(value); end
    def end_element(name); end
    def error(message, line, column)
      puts "Error: #{message} at #{line}:#{column}"
    end
  end

  s = "<xml><foo>bar</foo></xml>"
  Ox.sax_parse(::Ox::Sax.new, StringIO.new(s))
  Ox.sax_parse(MySax.new, StringIO.new(s))

end

And executing it like so:

bundle exec demo_error

Then I get the following stack trace:

/Users/trevrowe/xml-parser/tasks/demo_error.rake:23:in `readpartial': end of file reached (EOFError)
from /Users/trevrowe/xml-parser/tasks/demo_error.rake:23:in `sax_parse'
from /Users/trevrowe/xml-parser/tasks/demo_error.rake:23:in `block in <top (required)>'
from /Users/trevrowe/.rvm/gems/ruby-1.9.3-p125/gems/rake-0.9.2.2/lib/rake/task.rb:205:in `call'
from /Users/trevrowe/.rvm/gems/ruby-1.9.3-p125/gems/rake-0.9.2.2/lib/rake/task.rb:205:in `block in execute'
from /Users/trevrowe/.rvm/gems/ruby-1.9.3-p125/gems/rake-0.9.2.2/lib/rake/task.rb:200:in `each'
from /Users/trevrowe/.rvm/gems/ruby-1.9.3-p125/gems/rake-0.9.2.2/lib/rake/task.rb:200:in `execute'
from /Users/trevrowe/.rvm/gems/ruby-1.9.3-p125/gems/rake-0.9.2.2/lib/rake/task.rb:158:in `block in invoke_with_call_chain'
from /Users/trevrowe/.rvm/rubies/ruby-1.9.3-p125/lib/ruby/1.9.1/monitor.rb:211:in `mon_synchronize'
from /Users/trevrowe/.rvm/gems/ruby-1.9.3-p125/gems/rake-0.9.2.2/lib/rake/task.rb:151:in `invoke_with_call_chain'
from /Users/trevrowe/.rvm/gems/ruby-1.9.3-p125/gems/rake-0.9.2.2/lib/rake/task.rb:144:in `invoke'
from /Users/trevrowe/.rvm/gems/ruby-1.9.3-p125/gems/rake-0.9.2.2/lib/rake/application.rb:116:in `invoke_task'
from /Users/trevrowe/.rvm/gems/ruby-1.9.3-p125/gems/rake-0.9.2.2/lib/rake/application.rb:94:in `block (2 levels) in top_level'
from /Users/trevrowe/.rvm/gems/ruby-1.9.3-p125/gems/rake-0.9.2.2/lib/rake/application.rb:94:in `each'
from /Users/trevrowe/.rvm/gems/ruby-1.9.3-p125/gems/rake-0.9.2.2/lib/rake/application.rb:94:in `block in top_level'
from /Users/trevrowe/.rvm/gems/ruby-1.9.3-p125/gems/rake-0.9.2.2/lib/rake/application.rb:133:in `standard_exception_handling'
from /Users/trevrowe/.rvm/gems/ruby-1.9.3-p125/gems/rake-0.9.2.2/lib/rake/application.rb:88:in `top_level'
from /Users/trevrowe/.rvm/gems/ruby-1.9.3-p125/gems/rake-0.9.2.2/lib/rake/application.rb:66:in `block in run'
from /Users/trevrowe/.rvm/gems/ruby-1.9.3-p125/gems/rake-0.9.2.2/lib/rake/application.rb:133:in `standard_exception_handling'
from /Users/trevrowe/.rvm/gems/ruby-1.9.3-p125/gems/rake-0.9.2.2/lib/rake/application.rb:63:in `run'
from /Users/trevrowe/.rvm/gems/ruby-1.9.3-p125/gems/rake-0.9.2.2/bin/rake:33:in `<top (required)>'
from /Users/trevrowe/.rvm/gems/ruby-1.9.3-p125/bin/rake:19:in `load'
from /Users/trevrowe/.rvm/gems/ruby-1.9.3-p125/bin/rake:19:in `<main>'

from ox.

trevorrowe avatar trevorrowe commented on June 18, 2024

Oops, that should have been:

bundle exec rake demo_error

from ox.

ohler55 avatar ohler55 commented on June 18, 2024

Thanks. The bad news is it worked for me on a Mac running the latest OS X, Lion. What platform are you running the test on? I will try to set up a VM to reproduce the problem.

from ox.

trevorrowe avatar trevorrowe commented on June 18, 2024

I am running on OS X 10.6.8.

from ox.

ohler55 avatar ohler55 commented on June 18, 2024

I have that installed on a machine at home. I will test on that tomorrow after I get back.

from ox.

ohler55 avatar ohler55 commented on June 18, 2024

No luck on the machine at home yet. I think I might have to reinstall the OS to get it to build ruby. It's my wife's machine so she will not be happy. I know it is a lot to ask but can I get a restricted login on your machine? If not I understand. There has to be something different that we are missing.

from ox.

ohler55 avatar ohler55 commented on June 18, 2024

update, managed to get everything installed and even better I could recreate the problem!

from ox.

ohler55 avatar ohler55 commented on June 18, 2024

got it! The behavior of rb_protect() was fixed in the most recent OS. The old one raises an exception even if the code ignores it but Ruby waits until the process completes before raising the exception. Very odd bug in Ruby. I have a work around and will release a fix this week after testing and cleanup.

from ox.

trevorrowe avatar trevorrowe commented on June 18, 2024

That explains why I was unable to rescue the exception. Great to hear you were able to reproduce it!

from ox.

ohler55 avatar ohler55 commented on June 18, 2024

Please give the latest version a try.

from ox.

trevorrowe avatar trevorrowe commented on June 18, 2024

The latest version has resolved the issue for me. Thanks!

from ox.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.