Comments (14)
Can you send me the file?
from ox.
I've emailed you the xml file.
from ox.
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.
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.
Oops, that should have been:
bundle exec rake demo_error
from ox.
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.
I am running on OS X 10.6.8.
from ox.
I have that installed on a machine at home. I will test on that tomorrow after I get back.
from ox.
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.
update, managed to get everything installed and even better I could recreate the problem!
from ox.
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.
That explains why I was unable to rescue the exception. Great to hear you were able to reproduce it!
from ox.
Please give the latest version a try.
from ox.
The latest version has resolved the issue for me. Thanks!
from ox.
Related Issues (20)
- `StringIO` in `Ox::Builder` HOT 2
- Sax parsing with default encoding set to UTF-8 breaks Ox::Sax#text HOT 2
- OpenSSL::SSL::SSLContext::DEFAULT_CERT_STORE is not shareable across ractors HOT 1
- Issue with gems on M1 that depends on ox HOT 3
- test/tests.rb fails with ruby3.2.0preview3 and onwards HOT 3
- Ruby 3.2 compatibility HOT 2
- cannot load such file -- ox/ox HOT 6
- Cleaning built artifacts after installation breaks macOS HOT 4
- Incorrect ` Start End Mismatch` exception in sax parser HOT 9
- Ruby 2.7.6 LoadError: cannot load such file -- ox/ox HOT 3
- segfault in 2.14.13 -- free(): invalid pointer Aborted (core dumped) HOT 7
- Verbose output of inspect HOT 4
- Segmentation fault in sax_html since 2.14.13 HOT 12
- 2.14.15 cant be installed on windows HOT 1
- Segfault when parsing deeply nested HTML HOT 5
- `Start End Mismatch: element X not closed` errors in sax_test HOT 2
- Ox.load fails with UTF-8 characters in xml element names HOT 4
- ? in unquoted attribute value causes HTML to not be properly parsed HOT 4
- a new mode like :hash_no_attrs but with included attributes HOT 9
- Invalid name for an orphan end tag
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ox.