mirror of
				https://github.com/ruby/ruby.git
				synced 2022-11-09 12:17:21 -05:00 
			
		
		
		
	merge revision(s) 56363,56365: [Backport #12811]
* load.c (rb_require_safe): SyntaxError created by the parser just has the mesage and needs to set up the backtrace. [ruby-core:77491] [Bug #12811] has the message and needs to set up the backtrace. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_3@56439 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
		
							parent
							
								
									7c0c4c8e5e
								
							
						
					
					
						commit
						10555f93fb
					
				
					 3 changed files with 22 additions and 1 deletions
				
			
		
							
								
								
									
										1
									
								
								load.c
									
										
									
									
									
								
							
							
						
						
									
										1
									
								
								load.c
									
										
									
									
									
								
							| 
						 | 
				
			
			@ -1043,6 +1043,7 @@ rb_require_safe(VALUE fname, int safe)
 | 
			
		|||
    int result = rb_require_internal(fname, safe);
 | 
			
		||||
 | 
			
		||||
    if (result > TAG_RETURN) {
 | 
			
		||||
	if (result == TAG_RAISE) rb_exc_raise(rb_errinfo());
 | 
			
		||||
	JUMP_TAG(result);
 | 
			
		||||
    }
 | 
			
		||||
    if (result < 0) {
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -182,6 +182,26 @@ class TestRequire < Test::Unit::TestCase
 | 
			
		|||
    end
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  def assert_syntax_error_backtrace
 | 
			
		||||
    Dir.mktmpdir do |tmp|
 | 
			
		||||
      req = File.join(tmp, "test.rb")
 | 
			
		||||
      File.write(req, "'\n")
 | 
			
		||||
      e = assert_raise_with_message(SyntaxError, /unterminated/) {
 | 
			
		||||
        yield req
 | 
			
		||||
      }
 | 
			
		||||
      assert_not_nil(bt = e.backtrace)
 | 
			
		||||
      assert_not_empty(bt.find_all {|b| b.start_with? __FILE__})
 | 
			
		||||
    end
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  def test_require_syntax_error
 | 
			
		||||
    assert_syntax_error_backtrace {|req| require req}
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  def test_load_syntax_error
 | 
			
		||||
    assert_syntax_error_backtrace {|req| load req}
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  def test_define_class
 | 
			
		||||
    begin
 | 
			
		||||
      require "socket"
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,6 +1,6 @@
 | 
			
		|||
#define RUBY_VERSION "2.3.2"
 | 
			
		||||
#define RUBY_RELEASE_DATE "2016-10-18"
 | 
			
		||||
#define RUBY_PATCHLEVEL 197
 | 
			
		||||
#define RUBY_PATCHLEVEL 198
 | 
			
		||||
 | 
			
		||||
#define RUBY_RELEASE_YEAR 2016
 | 
			
		||||
#define RUBY_RELEASE_MONTH 10
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue